From 77b6bd45bf1e2e2316b6670c97afeb58a916923d Mon Sep 17 00:00:00 2001 From: bakasura980 Date: Tue, 30 Jun 2020 17:30:47 +0300 Subject: [PATCH] Revert "Merge pull request #61 from LimeChain/documentation-link" This reverts commit 0c00dd9b337a96e7e18d0815ced8b3b8f3603b85, reversing changes made to ace2e6dba7959db7af26e1a9724ec967e8f3f468. --- README.md | 2 +- index.d.ts | 23 -- package.json | 18 +- src/account/authority-account/account.js | 25 +- .../multi-signature-account/account.js | 14 +- src/account/normal-account/account.js | 17 +- src/contract/contract.js | 2 +- tests/testing-contracts/compiled/faucet.abi | 10 - tests/testing-contracts/compiled/faucet.wasm | Bin 12289 -> 12196 bytes tests/testing-contracts/faucet.cpp | 2 - tests/types/account.ts | 384 ------------------ tests/types/contract.ts | 213 ---------- tests/types/provider.ts | 279 ------------- tests/types/utils/index.ts | 38 -- tsconfig.json | 27 -- types/account/index.d.ts | 89 ---- types/contract/index.d.ts | 84 ---- types/index.d.ts | 6 - types/miscellaneous/index.d.ts | 103 ----- types/provider/index.d.ts | 42 -- types/table-reader/index.d.ts | 53 --- types/utils/index.d.ts | 12 - 22 files changed, 32 insertions(+), 1411 deletions(-) delete mode 100644 index.d.ts delete mode 100644 tests/types/account.ts delete mode 100644 tests/types/contract.ts delete mode 100644 tests/types/provider.ts delete mode 100644 tests/types/utils/index.ts delete mode 100644 tsconfig.json delete mode 100644 types/account/index.d.ts delete mode 100644 types/contract/index.d.ts delete mode 100644 types/index.d.ts delete mode 100644 types/miscellaneous/index.d.ts delete mode 100644 types/provider/index.d.ts delete mode 100644 types/table-reader/index.d.ts delete mode 100644 types/utils/index.d.ts diff --git a/README.md b/README.md index 8ea0ebf..0145c14 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ eoslime.js EOS development and deployment framework based on eosjs.js. The framework's main purpose is to make the process of unit testing, deployment and compilation much simpler and much easier. Telegram - https://t.me/eoslime -Documentation - https://docs.eoslime.limechain.tech/ +Documentation - https://lyubo.gitbook.io/eoslime/ diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index cb77958..0000000 --- a/index.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -// Type definitions for EOSLime -// Project: https://github.com/LimeChain/eoslime -// Definitions by: Lyubomir Kiprov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -import { utils } from './types/utils'; -import { ContractFactory } from './types/contract'; -import { Provider, NetworkDetails } from './types/provider'; -import { AccountFactory, MultiSignatureFactory } from './types/account'; - -interface EOSLime { - utils: utils; - Provider: Provider; - Account: AccountFactory; - Contract: ContractFactory; - MultiSigAccount: MultiSignatureFactory; -} - -export const utils: utils; -export const NETWORKS: Array; - -export function init (network?: string, config?: NetworkDetails): EOSLime; -export function init (config?: NetworkDetails): EOSLime; diff --git a/package.json b/package.json index dbe78ed..b924d01 100644 --- a/package.json +++ b/package.json @@ -3,20 +3,14 @@ "version": "1.0.4", "description": "eoslime is an EOS development and deployment framework based on eosjs.js", "main": "index.js", - "types": "index.d.ts", "scripts": { - "build": "tsc", - "test": "bash ./tests/testing-contracts/compile.sh && mocha './tests/*.js'", - "test-prod": "bash ./tests/testing-contracts/compile.sh && nyc --check-coverage mocha './tests/*.js'", - "test-types": "bash ./tests/testing-contracts/compile.sh && mocha -r ts-node/register tests/**/contract.ts", + "test": "bash ./tests/testing-contracts/compile.sh && nyc --check-coverage mocha './tests/*.js'", + "test-dev": "bash ./tests/testing-contracts/compile.sh && mocha './tests/*.js'", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov" }, "author": "Lyubomir Kiprov (Limechain)", "license": "MIT", "dependencies": { - "@types/assert": "^1.5.1", - "@types/mocha": "^7.0.2", - "assert": "^2.0.0", "chalk": "2.4.2", "cli-table": "0.3.1", "crypto-js": "3.1.9-1", @@ -27,11 +21,6 @@ "simple-git": "1.132.0", "yargs": "12.0.5" }, - "devDependencies": { - "nyc": "14.1.1", - "ts-node": "^8.10.2", - "typescript": "^3.9.5" - }, "keywords": [ "lime", "eos", @@ -51,5 +40,8 @@ "homepage": "https://github.com/LimeChain/eoslime#readme", "bin": { "eoslime": "./cli.js" + }, + "devDependencies": { + "nyc": "14.1.1" } } \ No newline at end of file diff --git a/src/account/authority-account/account.js b/src/account/authority-account/account.js index a17b20a..2e7da6f 100644 --- a/src/account/authority-account/account.js +++ b/src/account/authority-account/account.js @@ -1,29 +1,28 @@ -const is = require('../../helpers/is'); -const Account = require('../normal-account/account'); +const is = require('../../helpers/is') -class AuthorityAccount extends Account { +class AuthorityAccount { - constructor (parentPermission, name, privateKey, provider, permission) { - super(name, privateKey, provider, permission); - this.parentPermission = parentPermission; + static construct(account, parentPermission) { + account.setAuthorityAbilities = setAuthorityAbilities(account, parentPermission); + return account; } +} - async setAuthorityAbilities (abilities) { +const setAuthorityAbilities = function (account, parentAuthority) { + return async function (abilities) { is(abilities).instanceOf('Array'); - const txReceipt = await this.provider.eos.transaction(tr => { + await account.provider.eos.transaction(tr => { for (let i = 0; i < abilities.length; i++) { const ability = abilities[i]; tr.linkauth({ - account: this.name, + account: account.name, code: ability.contract, type: ability.action, - requirement: this.executiveAuthority.permission + requirement: account.executiveAuthority.permission }, { authorization: [`${this.name}@${parentAuthority}`] }); } - }, { broadcast: true, sign: true, keyProvider: this.privateKey }); - - return txReceipt; + }, { broadcast: true, sign: true, keyProvider: account.privateKey }); } } diff --git a/src/account/multi-signature-account/account.js b/src/account/multi-signature-account/account.js index 6cb6ef4..a7a95bf 100644 --- a/src/account/multi-signature-account/account.js +++ b/src/account/multi-signature-account/account.js @@ -3,27 +3,27 @@ const BaseAccount = require('../base-account'); class MultiSignatureAccount extends BaseAccount { - constructor (name, privateKey, provider, authority) { + constructor(name, privateKey, provider, authority) { super(name, privateKey, provider, authority) - this.accounts = [this]; + this.accounts = []; this.proposals = {}; } - loadKeys (privateKeys) { + loadKeys(privateKeys) { for (let i = 0; i < privateKeys.length; i++) { this.accounts.push(new BaseAccount(this.name, privateKeys[i], this.provider, this.executiveAuthority.permission)); } } - loadAccounts (accounts) { + loadAccounts(accounts) { for (let i = 0; i < accounts.length; i++) { is(accounts[i]).instanceOf('BaseAccount'); this.accounts.push(accounts[i]); } } - async propose (contractAction, actionData) { + async propose(contractAction, actionData) { is(contractAction).instanceOf('ContractFunction'); const actionTx = await contractAction.sign(this, ...actionData); @@ -33,7 +33,7 @@ class MultiSignatureAccount extends BaseAccount { return proposalId; } - async approve (publicKey, proposalId) { + async approve(publicKey, proposalId) { const approver = this.accounts.find((account) => { return account.publicKey == publicKey }); requireExistingApprover(approver); requireExistingProposal(this.proposals, proposalId); @@ -47,7 +47,7 @@ class MultiSignatureAccount extends BaseAccount { proposalTx.signatures.push(approverSignedTx.transaction.signatures[0]); } - async processProposal (proposalId) { + async processProposal(proposalId) { requireExistingProposal(this.proposals, proposalId); await requireEnoughApprovals(this, this.proposals[proposalId]); diff --git a/src/account/normal-account/account.js b/src/account/normal-account/account.js index 523ed35..3e68a25 100644 --- a/src/account/normal-account/account.js +++ b/src/account/normal-account/account.js @@ -1,11 +1,11 @@ const is = require('../../helpers/is') const eosECC = require('eosjs').modules.ecc; const BaseAccount = require('../base-account'); -// const AuthorityAccount = require('../authority-account/account'); +const AuthorityAccount = require('../authority-account/account'); class Account extends BaseAccount { - constructor (name, privateKey, provider, permission) { + constructor(name, privateKey, provider, permission) { super(name, privateKey, provider, permission); } @@ -54,13 +54,9 @@ class Account extends BaseAccount { } await updateAuthority.call(this, authorityName, this.executiveAuthority.permission, authorization); - // return new AuthorityAccount( - // this.executiveAuthority.permission, - // this.name, - // this.privateKey, - // this.provider, - // authorityName - // ); + const authorityAccount = new Account(this.name, this.privateKey, this.provider, authorityName); + + return AuthorityAccount.construct(authorityAccount, this.executiveAuthority.permission); } async increaseThreshold (threshold) { @@ -119,7 +115,7 @@ class Account extends BaseAccount { } const updateAuthority = async function (authorityName, parent, auth) { - const txReceipt = await this.provider.eos.transaction(tr => { + await this.provider.eos.transaction(tr => { tr.updateauth({ account: this.name, permission: authorityName, @@ -129,7 +125,6 @@ const updateAuthority = async function (authorityName, parent, auth) { }, { broadcast: true, sign: true, keyProvider: this.privateKey }); - return txReceipt; } module.exports = Account; diff --git a/src/contract/contract.js b/src/contract/contract.js index cf21ab1..b3e5681 100644 --- a/src/contract/contract.js +++ b/src/contract/contract.js @@ -2,7 +2,7 @@ const is = require('./../helpers/is'); const FunctionsFactory = require('./contract-function/functions-factory'); class Contract { - constructor (provider, abi, contractName, contractExecutorAccount) { + constructor(provider, abi, contractName, contractExecutorAccount) { this.abi = abi; this.name = contractName; this.provider = provider; diff --git a/tests/testing-contracts/compiled/faucet.abi b/tests/testing-contracts/compiled/faucet.abi index 02cd667..a4c8c59 100644 --- a/tests/testing-contracts/compiled/faucet.abi +++ b/tests/testing-contracts/compiled/faucet.abi @@ -25,11 +25,6 @@ } ] }, - { - "name": "test", - "base": "", - "fields": [] - }, { "name": "withdraw", "base": "", @@ -69,11 +64,6 @@ "type": "produce", "ricardian_contract": "" }, - { - "name": "test", - "type": "test", - "ricardian_contract": "" - }, { "name": "withdraw", "type": "withdraw", diff --git a/tests/testing-contracts/compiled/faucet.wasm b/tests/testing-contracts/compiled/faucet.wasm index 5d5fd646c8ed11e09589c1f747981791791e1bf9..a6c4179e05e84faeac4dfaf174470e63e472cd82 100755 GIT binary patch delta 158 zcmZonSQ5YCATyJm?&QPF%9EcnTXFsi(q&-~(BqysS&PMDas`Xh=GiPR{EYsS9|*TI z`fbh-*~Z8iuvuPAnUT?Vva@&vP;8Gl8zW=z=ED*k?2JK^&&a=H44%AO!JIK<@@EC3 z%~^_3ARR}QRpupnTFqu(F zj+04&ML|3 { - const account = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - assertAccount(account); - }); - - it('Should create account [account creator]', async () => { - const creatorAccount = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - - const accountName = await utils.randomName(); - const privateKey = await utils.randomPrivateKey(); - - const account = await eoslime.Account.create(accountName, privateKey, creatorAccount); - assertAccount(account); - }); - - it('Should create account [default account]', async () => { - const accountName = await utils.randomName(); - const privateKey = await utils.randomPrivateKey(); - - const account = await eoslime.Account.create(accountName, privateKey); - assertAccount(account); - }); - - it('Should create account from name [account creator]', async () => { - const creatorAccount = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - - const accountName = await utils.randomName(); - const account = await eoslime.Account.createFromName(accountName, creatorAccount); - assertAccount(account); - }); - - it('Should create account from name [default account]', async () => { - const accountName = await utils.randomName(); - const account = await eoslime.Account.createFromName(accountName); - - assertAccount(account); - }); - - it('Should create random account [account creator]', async () => { - const creatorAccount = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - const account = await eoslime.Account.createRandom(creatorAccount); - - assertAccount(account); - }); - - it('Should create random account [default account]', async () => { - const account = await eoslime.Account.createRandom(); - assertAccount(account); - }); - - it('Should create random accounts [account creator]', async () => { - const creatorAccount = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - - const accounts = await eoslime.Account.createRandoms(2, creatorAccount); - for (const account of accounts) { - assertAccount(account); - } - }); - - it('Should create random accounts [default account]', async () => { - const accounts = await eoslime.Account.createRandoms(2); - for (const account of accounts) { - assertAccount(account); - } - }); - - it('Should create encrypted account [account creator]', async () => { - const creatorAccount = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - const encryptedAccount = await eoslime.Account.createEncrypted('PASSWORD', creatorAccount); - - assert(encryptedAccount.network); - assert(encryptedAccount.cipherText); - assert(encryptedAccount.authority.actor); - assert(encryptedAccount.authority.permission); - }); - - it('Should create encrypted account [default account]', async () => { - const encryptedAccount = await eoslime.Account.createEncrypted('PASSWORD'); - - assert(encryptedAccount.network); - assert(encryptedAccount.cipherText); - assert(encryptedAccount.authority.actor); - assert(encryptedAccount.authority.permission); - }); - - it('Should convert encrypted account into account', async () => { - const encryptedAccount = await eoslime.Account.createEncrypted('PASSWORD'); - const decryptedAccount = eoslime.Account.fromEncrypted(encryptedAccount, 'PASSWORD'); - - assertAccount(decryptedAccount); - }); - }); - - describe('Main functions', function () { - - it('Should send EOS tokens', async () => { - const SEND_AMOUNT = '10.0000'; - const senderAccount = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - const receiverAccount = await eoslime.Account.createRandom(); - - const tx = await senderAccount.send(receiverAccount, SEND_AMOUNT, 'SYS'); - assertTransactionResult(tx); - }); - - it('Should buy ram [payer]', async () => { - const payer = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - const account = await eoslime.Account.createRandom(); - - const tx = await account.buyRam(1000, payer); - assertTransactionResult(tx); - }); - - it('Should buy ram by self', async () => { - const eosAccount = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - const account = await eoslime.Account.createRandom(); - - await eosAccount.send(account, '10.0000', 'SYS'); - - const tx = await account.buyRam(1000); - assertTransactionResult(tx); - }); - - it('Should buy bandwidth [payer]', async () => { - const payer = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - const account = await eoslime.Account.createRandom(); - - const tx = await account.buyBandwidth('10.0000 SYS', '10.0000 SYS', payer); - assertTransactionResult(tx); - }); - - it('Should buy bandwidth by self', async () => { - const eosAccount = eoslime.Account.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - const account = await eoslime.Account.createRandom(); - - await eosAccount.send(account, '10.0000', 'SYS'); - - const tx = await account.buyBandwidth('10 SYS', '10 SYS'); - assertTransactionResult(tx); - }); - - it('Should create authority', async () => { - const account = await eoslime.Account.createRandom(); - const newAuthorityAccount = await account.createSubAuthority('custom'); - - assertAccount(newAuthorityAccount); - assert(typeof (newAuthorityAccount.setAuthorityAbilities) == 'function'); - }); - - it('Should create permission for active authority', async () => { - const account = await eoslime.Account.createRandom(); - const tx = await account.addPermission('eosio.code'); - - assertTransactionResult(tx); - }); - - it('Should add permission with weight', async () => { - const accounts = await eoslime.Account.createRandom(); - const tx = await accounts.addPermission('eosio.code', 2); - - assertTransactionResult(tx); - }); - - it('Should allow another a keys pair to act on behalf', async () => { - const account = await eoslime.Account.createRandom(); - const keysPair = await utils.generateKeys(); - - const tx = await account.addAuthorityKey(keysPair.publicKey); - assertTransactionResult(tx); - }); - - it('Should add keys pair with weight', async () => { - const WEIGHT = 2; - - const account = await eoslime.Account.createRandom(); - const keysPair = await utils.generateKeys(); - - const tx = await account.addAuthorityKey(keysPair.publicKey, WEIGHT); - assertTransactionResult(tx); - }); - - it('Should allow another account to act on behalf', async () => { - const accounts = await eoslime.Account.createRandoms(2); - const child = accounts[0]; - const parent = accounts[1]; - - const tx = await child.addOnBehalfAccount(parent.name, 'active'); - assertTransactionResult(tx); - }); - - it('Should add authority account with weight', async () => { - const WEIGHT = 2; - - const accounts = await eoslime.Account.createRandoms(2); - const child = accounts[0]; - const parent = accounts[1]; - - const tx = await child.addOnBehalfAccount(parent.name, 'active', WEIGHT); - assertTransactionResult(tx); - }); - - it('Should increase authority threshold', async () => { - const THRESHOLD = 2; - const account = await eoslime.Account.createRandom(); - - const keysPair = await utils.generateKeys(); - await account.addAuthorityKey(keysPair.publicKey); - const tx = await account.increaseThreshold(THRESHOLD); - - assertTransactionResult(tx); - }); - - it('Should set weight correctly authority threshold', async () => { - const account = await eoslime.Account.createRandom(); - - const WEIGHT = 2; - const tx = await account.setWeight(WEIGHT); - - assertTransactionResult(tx); - }); - - it('Should get authority details', async () => { - const account = await eoslime.Account.createRandom(); - const authorityInfo = await account.getAuthorityInfo(); - - assert(authorityInfo.perm_name) - assert(authorityInfo.parent) - assert(authorityInfo.required_auth.threshold) - assert(Array.isArray(authorityInfo.required_auth.keys)) - assert(Array.isArray(authorityInfo.required_auth.accounts)) - assert(Array.isArray(authorityInfo.required_auth.waits)) - }); - - it('Should get balance', async () => { - const account = await eoslime.Account.createRandom(); - const accBalance = await account.getBalance(); - - assert(accBalance.length == 0); - }); - }); - }); - - describe('Authority Account', function () { - it('Should set authority abilities', async () => { - const { name } = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - - const account = await eoslime.Account.createRandom(); - const authorityAccount = await account.createSubAuthority('custom'); - - const tx = await authorityAccount.setAuthorityAbilities([ - { - action: 'test', - contract: name - } - ]); - - assertTransactionResult(tx); - }); - }); - - describe('MultiSignature Account', function () { - function assertMultiSigAccount (account: MultiSignatureAccount) { - assert(account.name); - assert(account.accounts); - assert(account.provider); - assert(account.proposals); - assert(account.publicKey); - assert(account.privateKey); - assert(account.executiveAuthority.actor); - assert(account.executiveAuthority.permission); - - assert(typeof (account.loadKeys) == 'function'); - assert(typeof (account.loadAccounts) == 'function'); - - assert(typeof (account.propose) == 'function'); - assert(typeof (account.approve) == 'function'); - assert(typeof (account.processProposal) == 'function'); - } - - describe('Static functions', function () { - it('Should load multi signature account', async () => { - const account = eoslime.MultiSigAccount.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - assertMultiSigAccount(account); - }); - }); - - describe('Main functions', function () { - - let contract: Contract; - - // TODO: Implement stub version - beforeEach(async () => { - contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - }); - - it('Should load more keys', async () => { - const keys = [ - (await utils.generateKeys()).privateKey, - (await utils.generateKeys()).privateKey - ]; - - const multiSigAccount = eoslime.MultiSigAccount.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - multiSigAccount.loadKeys(keys); - }); - - it('Should load more accounts', async () => { - const accounts = await eoslime.Account.createRandoms(2); - - const multiSigAccount = eoslime.MultiSigAccount.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - multiSigAccount.loadAccounts(accounts); - }); - - it('Should propose a transaction to be broadcasted', async () => { - const multiSigAccount = eoslime.MultiSigAccount.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - const proposalId = await multiSigAccount.propose(contract.actions.test, []); - - assert(proposalId); - }); - - it('Should approve a transaction for broadcasting', async () => { - const multiSigAccount = eoslime.MultiSigAccount.load(ACCOUNT_NAME, ACCOUNT_PRIVATE_KEY); - const proposalId = await multiSigAccount.propose(contract.actions.test, []); - - await multiSigAccount.approve(multiSigAccount.publicKey, proposalId); - }); - - it('Should broadcast a proposed transaction', async () => { - const { name, privateKey } = await eoslime.Account.createRandom(); - - const multiSigAccount = eoslime.MultiSigAccount.load(name, privateKey); - const proposalId = await multiSigAccount.propose(contract.actions.test, []); - - const tx = await multiSigAccount.processProposal(proposalId); - assert(tx.processed !== undefined); - assert(tx.transaction_id !== undefined); - }); - }); - }); -}); diff --git a/tests/types/contract.ts b/tests/types/contract.ts deleted file mode 100644 index 080a1d8..0000000 --- a/tests/types/contract.ts +++ /dev/null @@ -1,213 +0,0 @@ -import assert from 'assert'; -import { it } from 'mocha'; - -import { init } from '../../'; -const eoslime = init(); - -import { - Contract, - TransactionResult -} from '../../types'; - -import { assertRawTransaction, assertSignedAction, assertTransactionResult } from './utils'; - -const ABI_PATH = "./tests/testing-contracts/compiled/faucet.abi"; -const WASM_PATH = "./tests/testing-contracts/compiled/faucet.wasm"; - -describe("Contract", function () { - - const account = eoslime.Account.load('eosio', '5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3'); - - const assertContract = function (contract: Contract): void { - assert(typeof contract.actions.produce == "function"); - assert(typeof contract.tables.withdrawers !== undefined); - - - assert(contract.abi !== undefined); - assert(contract.name !== undefined); - assert(contract.executor !== undefined); - } - - describe("Instantiation", function () { - it("Should have fromFile function", async () => { - const contract = eoslime.Contract.fromFile(ABI_PATH, 'contracttest', account); - assertContract(contract); - }); - - it("Should have at function", async () => { - const { name } = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - const contract = await eoslime.Contract.at(name, account); - assertContract(contract); - }); - - it("Should set default account as executor if none is provided", async () => { - const contract = eoslime.Contract.fromFile(ABI_PATH, 'contracttest'); - assertContract(contract); - }); - }); - - describe("Deployment", function () { - it("Should have deploy function", async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - assertContract(contract); - }); - - it("Should have deployOnAccount function", async () => { - const contractAccount = await eoslime.Account.createRandom() - const contract = await eoslime.Contract.deployOnAccount(WASM_PATH, ABI_PATH, contractAccount); - assertContract(contract); - }); - - it("Should have deployRaw function", async () => { - const contract_A = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - const rawWASM = await contract_A.getRawWASM(); - - const contract = await eoslime.Contract.deployRaw(rawWASM, contract_A.abi); - assertContract(contract); - }); - - it("Should have deployRawOnAccount function", async () => { - const contract_A = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - const rawWASM = await contract_A.getRawWASM(); - const contractAccount = await eoslime.Account.createRandom() - - const contract = await eoslime.Contract.deployRawOnAccount( - rawWASM, - contract_A.abi, - contractAccount - ); - assertContract(contract); - }); - }); - - describe("Blockchain actions", function () { - - it("Should have blockchain actions", async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - const tx = await contract.actions.test([]) - - assertTransactionResult(tx); - }); - - it("Should execute a blockchain action from another executor", async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - await contract.actions.test([], { from: account }); - }); - - it('Should process nonce-action', async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - await contract.actions.test([], { unique: true }); - }); - - it('Should process token action', async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - await contract.actions.test([], { tokens: '5.0000 SYS' }); - }); - - describe("Methods", function () { - - it('Should get a raw transaction from an action', async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - const rawActionTx = await contract.actions.test.getRawTransaction([]); - - assertRawTransaction(rawActionTx); - }); - - it('Should get a raw transaction from an action with options', async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - const rawActionTx = await contract.actions.test.getRawTransaction([], { from: account }); - - assertRawTransaction(rawActionTx); - }); - - it('Should sign an action without broadcasting it', async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - const signedActionTx = await contract.actions.test.sign([]); - assertSignedAction(signedActionTx); - }); - - it('Should sign an action with options without broadcasting it', async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - - const signer = await eoslime.Account.createRandom(); - const signedActionTx = await contract.actions.test.sign([], { from: signer, unique: true }); - assertSignedAction(signedActionTx); - }); - }); - }); - - describe("Blockchain tables", function () { - - it("Should have a default table getter", async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - assert(typeof contract.tables.withdrawers !== undefined); - }); - - it("Should have table query functions", async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - - // With equal criteria - await contract.tables.withdrawers.equal('custom').find(); - - // With range criteria - await contract.tables.withdrawers.range(0, 1).find(); - - // With limit - await contract.tables.withdrawers.limit(10).find(); - - // With different index (By Balance) - await contract.tables.withdrawers.index(2).find(); - - // With scope - await contract.tables.withdrawers.scope(contract.name).find(); - }); - }); - - describe("Inline a contract", function () { - it("Should have makeInline function", async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - - assert(typeof contract.makeInline == 'function') - await contract.makeInline(); - }); - }); - - describe("Retrieve raw WASM", function () { - it("Should have getRawWASM function", async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - - assert(typeof contract.getRawWASM == 'function'); - await contract.getRawWASM(); - }); - }); - - describe("Events", function () { - it("Should have init event", async () => { - const { name } = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - - eoslime.Contract.on('init', (contract: Contract) => { assertContract(contract) }); - eoslime.Contract.fromFile(ABI_PATH, name, account); - }); - - it("Should have deploy event", async () => { - eoslime.Contract.on('deploy', (contract: Contract, deployTx) => { - assertContract(contract); - assert(deployTx.length == 2); - }); - - await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - }); - - describe("Blockchain action events", function () { - it("Should have getRawWASM function", async () => { - const contract = await eoslime.Contract.deploy(WASM_PATH, ABI_PATH); - contract.actions.test.on('processed', (txReceipt: TransactionResult, ...params: any[]) => { - assertTransactionResult(txReceipt); - assert(params[0] == contract.executor.name); - }); - - await contract.actions.withdraw([contract.executor.name]); - }); - }); - }); -}); diff --git a/tests/types/provider.ts b/tests/types/provider.ts deleted file mode 100644 index 0cf6030..0000000 --- a/tests/types/provider.ts +++ /dev/null @@ -1,279 +0,0 @@ -import assert from 'assert'; -import { it } from 'mocha'; - -import { init } from '../../'; -const { Provider } = init(); - -describe('Provider', function () { - - const Networks = { - bos: { - name: 'bos', - url: 'https://hapi.bos.eosrio.io', - chainId: 'd5a3d18fbb3c084e3b1f3fa98c21014b5f3db536cc15d08f9f6479517c6a3d86' - }, - local: { - name: 'local', - url: 'http://127.0.0.1:8888', - chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f' - }, - worbli: { - name: 'main', - url: 'https://eos.greymass.com', - chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906' - }, - jungle: { - name: 'jungle', - url: 'https://jungle2.cryptolions.io', - chainId: 'e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473' - }, - main: { - name: 'main', - url: 'https://eos.greymass.com', - chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906' - }, - kylin: { - name: 'kylin', - url: 'https://kylin.eoscanada.com', - chainId: '5fff1dae8dc8e2fc4d5b23b2c7665c97f9e9d8edf2b6485a86ba311c25639191' - }, - custom: { - name: 'custom', - url: 'https://custom.com', - chainId: '123' - }, - } - - describe('Instantiation eoslime', function () { - it('Should instantiate with a correct Provider from connection', async () => { - // Local - const localProvider = init().Provider; - assert(JSON.stringify(localProvider.network) == JSON.stringify(Networks.local)); - - // Jungle - const jungleProvider = init('jungle').Provider; - assert(JSON.stringify(jungleProvider.network) == JSON.stringify(Networks.jungle)); - - // Worbli - const worbliProvider = init('worbli').Provider; - assert(JSON.stringify(worbliProvider.network) == JSON.stringify(Networks.worbli)); - - // Main - const mainProvider = init('main').Provider; - assert(JSON.stringify(mainProvider.network) == JSON.stringify(Networks.main)); - - // Bos - const bosProvider = init('bos').Provider; - assert(JSON.stringify(bosProvider.network) == JSON.stringify(Networks.bos)); - - // Kylin - const kylinProvider = init('kylin').Provider; - assert(JSON.stringify(kylinProvider.network) == JSON.stringify(Networks.kylin)); - - // Custom - const customProvider = init({ url: Networks.custom.url, chainId: Networks.custom.chainId }).Provider; - assert(JSON.stringify(customProvider.network) == JSON.stringify(Networks.custom)); - }); - - it('Should instantiate with a correct Provider from provided connection', async () => { - - // Local - const localProvider = init('local', { url: Networks.custom.url }).Provider; - assert(JSON.stringify(localProvider.network.name) == JSON.stringify(Networks.local.name)); - assert(JSON.stringify(localProvider.network.chainId) == JSON.stringify(Networks.local.chainId)); - assert(JSON.stringify(localProvider.network.url) == JSON.stringify(Networks.custom.url)); - - // Jungle - const jungleProvider = init('jungle', { chainId: Networks.custom.chainId }).Provider; - assert(JSON.stringify(jungleProvider.network.name) == JSON.stringify(Networks.jungle.name)); - assert(JSON.stringify(jungleProvider.network.url) == JSON.stringify(Networks.jungle.url)); - assert(jungleProvider.network.chainId == Networks.custom.chainId); - - // Worbli - const worbliProvider = init('worbli', { url: Networks.custom.url }).Provider; - assert(JSON.stringify(worbliProvider.network.name) == JSON.stringify(Networks.worbli.name)); - assert(JSON.stringify(worbliProvider.network.url) == JSON.stringify(Networks.custom.url)); - assert(JSON.stringify(worbliProvider.network.chainId) == JSON.stringify(Networks.worbli.chainId)); - - // Main - const mainProvider = init('main', { url: Networks.custom.url }).Provider; - assert(JSON.stringify(mainProvider.network.name) == JSON.stringify(Networks.main.name)); - assert(JSON.stringify(mainProvider.network.url) == JSON.stringify(Networks.custom.url)); - assert(JSON.stringify(mainProvider.network.chainId) == JSON.stringify(Networks.main.chainId)); - - // Bos - const bosProvider = init('bos', { url: Networks.custom.url }).Provider; - assert(JSON.stringify(bosProvider.network.name) == JSON.stringify(Networks.bos.name)); - assert(JSON.stringify(bosProvider.network.url) == JSON.stringify(Networks.custom.url)); - assert(JSON.stringify(bosProvider.network.chainId) == JSON.stringify(Networks.bos.chainId)); - - // Kylin - const kylinProvider = init('kylin', { url: Networks.custom.url }).Provider; - assert(JSON.stringify(kylinProvider.network.name) == JSON.stringify(Networks.kylin.name)); - assert(JSON.stringify(kylinProvider.network.url) == JSON.stringify(Networks.custom.url)); - assert(JSON.stringify(kylinProvider.network.chainId) == JSON.stringify(Networks.kylin.chainId)); - }); - }); - - describe('Create Provider', function () { - it('Should be able to create a new Provider with default connection', async () => { - // Local - const localProvider = new Provider('local'); - assert(JSON.stringify(localProvider.network) == JSON.stringify(Networks.local)); - - // Jungle - const jungleProvider = new Provider('jungle'); - assert(JSON.stringify(jungleProvider.network) == JSON.stringify(Networks.jungle)); - - // Worbli - const worbliProvider = new Provider('worbli'); - assert(JSON.stringify(worbliProvider.network) == JSON.stringify(Networks.worbli)); - - // Main - const mainProvider = new Provider('main'); - assert(JSON.stringify(mainProvider.network) == JSON.stringify(Networks.main)); - - // Bos - const bosProvider = new Provider('bos'); - assert(JSON.stringify(bosProvider.network) == JSON.stringify(Networks.bos)); - - // Kylin - const kylinProvider = new Provider('kylin'); - assert(JSON.stringify(kylinProvider.network) == JSON.stringify(Networks.kylin)); - - // Custom - const customProvider = new Provider({ url: Networks.custom.url, chainId: Networks.custom.chainId }); - assert(JSON.stringify(customProvider.network) == JSON.stringify(Networks.custom)); - }); - - it('Should be able to create a new Provider from connection', async () => { - // Local - const localProvider = new Provider('local', { url: Networks.custom.url }); - assert(JSON.stringify(localProvider.network.name) == JSON.stringify(Networks.local.name)); - assert(JSON.stringify(localProvider.network.chainId) == JSON.stringify(Networks.local.chainId)); - assert(JSON.stringify(localProvider.network.url) == JSON.stringify(Networks.custom.url)); - - // Jungle - const jungleProvider = new Provider('jungle', { chainId: Networks.custom.chainId }); - assert(JSON.stringify(jungleProvider.network.name) == JSON.stringify(Networks.jungle.name)); - assert(JSON.stringify(jungleProvider.network.url) == JSON.stringify(Networks.jungle.url)); - assert(jungleProvider.network.chainId == Networks.custom.chainId); - - // Worbli - const worbliProvider = new Provider('worbli', { url: Networks.custom.url }); - assert(JSON.stringify(worbliProvider.network.name) == JSON.stringify(Networks.worbli.name)); - assert(JSON.stringify(worbliProvider.network.url) == JSON.stringify(Networks.custom.url)); - assert(JSON.stringify(worbliProvider.network.chainId) == JSON.stringify(Networks.worbli.chainId)); - - // Main - const mainProvider = new Provider('main', { url: Networks.custom.url }); - assert(JSON.stringify(mainProvider.network.name) == JSON.stringify(Networks.main.name)); - assert(JSON.stringify(mainProvider.network.url) == JSON.stringify(Networks.custom.url)); - assert(JSON.stringify(mainProvider.network.chainId) == JSON.stringify(Networks.main.chainId)); - - // Bos - const bosProvider = new Provider('bos', { url: Networks.custom.url }); - assert(JSON.stringify(bosProvider.network.name) == JSON.stringify(Networks.bos.name)); - assert(JSON.stringify(bosProvider.network.url) == JSON.stringify(Networks.custom.url)); - assert(JSON.stringify(bosProvider.network.chainId) == JSON.stringify(Networks.bos.chainId)); - - // Kylin - const kylinProvider = new Provider('kylin', { url: Networks.custom.url }); - assert(JSON.stringify(kylinProvider.network.name) == JSON.stringify(Networks.kylin.name)); - assert(JSON.stringify(kylinProvider.network.url) == JSON.stringify(Networks.custom.url)); - assert(JSON.stringify(kylinProvider.network.chainId) == JSON.stringify(Networks.kylin.chainId)); - }); - }); - - describe('Reset provider', function () { - it('Should be able to reset the provider', async () => { - const jungleProvider = new Provider('jungle'); - Provider.reset(jungleProvider); - - assert(JSON.stringify(Provider.network) == JSON.stringify(Networks.jungle)); - }); - }); - - describe('Retrieve table [Table Reader]', function () { - - describe("Select Query", function () { - it("Should have correct chain of functions", async () => { - const query = Provider.select('table'); - assert(typeof query.from == 'function'); - }); - }); - - describe("From Query", function () { - it("Should have correct chain of functions", async () => { - const query = Provider.select('table').from('from'); - assert(typeof query.scope == 'function'); - assert(typeof query.equal == 'function'); - assert(typeof query.range == 'function'); - assert(typeof query.limit == 'function'); - assert(typeof query.index == 'function'); - assert(typeof query.find == 'function'); - }); - }); - - describe("Scope Query", function () { - it("Should have correct chain of functions", async () => { - const query = Provider.select('table').from('from').scope('scope'); - assert(typeof query.equal == 'function'); - assert(typeof query.range == 'function'); - assert(typeof query.limit == 'function'); - assert(typeof query.index == 'function'); - assert(typeof query.find == 'function'); - }); - }); - - describe("Equal Query", function () { - it("Should have correct chain of functions", async () => { - const query = Provider.select('table').from('from').scope('scope').equal('equal'); - assert(typeof query.limit == 'function'); - assert(typeof query.index == 'function'); - assert(typeof query.find == 'function'); - }); - }); - - describe("Range Query", function () { - it("Should have correct chain of functions", async () => { - const query = Provider.select('table').from('from').scope('scope').range(0, 1); - assert(typeof query.limit == 'function'); - assert(typeof query.index == 'function'); - assert(typeof query.find == 'function'); - }); - }); - - describe("Limit Query", function () { - it("Should have correct chain of functions", async () => { - const query = Provider.select('table').from('from').scope('scope').limit(10); - assert(typeof query.equal == 'function'); - assert(typeof query.range == 'function'); - assert(typeof query.index == 'function'); - assert(typeof query.find == 'function'); - }); - }); - - describe("Index Query", function () { - it("Should have correct chain of functions", async () => { - const query = Provider.select('table').from('from').scope('scope').index(2); - assert(typeof query.equal == 'function'); - assert(typeof query.range == 'function'); - assert(typeof query.limit == 'function'); - assert(typeof query.find == 'function'); - }); - }); - }); - - describe('Retrieve contract ABI', function () { - it('Should retrieve contract ABI', async () => { - await Provider.getABI('eosio'); - }); - }); - - describe('Retrieve contract raw WASM', function () { - it('Should retrieve contract raw WASM', async () => { - await Provider.getRawWASM('eosio'); - }); - }); -}); diff --git a/tests/types/utils/index.ts b/tests/types/utils/index.ts deleted file mode 100644 index 3a6e6a2..0000000 --- a/tests/types/utils/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import assert from 'assert'; - -import { TransactionResult, RawTransaction, SignedTransaction } from '../../../types'; - -export function assertRawTransaction (rawTransaction: RawTransaction): void { - assert(rawTransaction.actions !== undefined); - assert(rawTransaction.delay_sec !== undefined); - assert(rawTransaction.expiration !== undefined); - assert(rawTransaction.ref_block_num !== undefined); - assert(rawTransaction.max_cpu_usage_ms !== undefined); - assert(rawTransaction.ref_block_prefix !== undefined); - assert(rawTransaction.max_net_usage_words !== undefined); - assert(rawTransaction.context_free_actions !== undefined); -} - -export function assertSignedAction (signedTx: SignedTransaction): void { - assert(signedTx.compression !== undefined); - assert(signedTx.signatures.length > 0); - assertRawTransaction(signedTx.transaction); -} - -export function assertTransactionResult (txResult: TransactionResult): void { - assert(txResult.broadcast !== undefined); - assert(txResult.transaction_id !== undefined); - assert(txResult.processed.id !== undefined); - assert(txResult.processed.block_num !== undefined); - assert(txResult.processed.block_time !== undefined); - assert(txResult.processed.producer_block_id !== undefined); - assert(txResult.processed.receipt !== undefined); - assert(txResult.processed.elapsed !== undefined); - assert(txResult.processed.net_usage !== undefined); - assert(txResult.processed.scheduled !== undefined); - assert(txResult.processed.action_traces !== undefined); - assert(txResult.processed.account_ram_delta !== undefined); - assert(txResult.processed.except !== undefined); - assert(txResult.processed.error_code !== undefined); - assertSignedAction(txResult.transaction); -} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 3092dbc..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "esModuleInterop": true, - "resolveJsonModule": true, - "allowSyntheticDefaultImports": true, - "suppressImplicitAnyIndexErrors": true, - "target": "es6", - "noImplicitAny": true, - "moduleResolution": "node", - "sourceMap": true, - "outDir": "dist", - "baseUrl": ".", - "paths": { - "*": [ - "node_modules/*", - "types/*" - ] - }, - "experimentalDecorators": true, - "emitDecoratorMetadata": true - }, - "include": [ - "./index.d.ts", - "./types/**/*" - ] -} \ No newline at end of file diff --git a/types/account/index.d.ts b/types/account/index.d.ts deleted file mode 100644 index d2e6cb9..0000000 --- a/types/account/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { BaseProvider } from '../provider'; -import { ContractFunction } from '../contract'; -import { TransactionResult, AuthorityDetails, BroadCastedTransaction } from '../miscellaneous'; - -interface ExecutiveAuthority { - actor: string, - permission: string; -} - -interface EncryptedAccount { - name: string; - network: string; - authority: ExecutiveAuthority; - cipherText: string; -} - -export class AccountFactory { - - constructor (provider: BaseProvider); - - public load (name: string, privateKey: string, authorityName?: string): Account; - public create (accountName: string, privateKey: string, accountCreator?: Account): Promise; - public createFromName (accountName: string, accountCreator?: Account): Promise; - public createRandom (accountCreator?: Account): Promise; - public createRandoms (accountsCount: number, accountCreator?: Account): Promise> - public createEncrypted (password: string, accountCreator?: Account): Promise; - public fromEncrypted (encryptedAccount: EncryptedAccount, password: string): Account; -} - -declare class BaseAccount { - public name: string; - public publicKey: string; - public privateKey: string; - public provider: BaseProvider; - public executiveAuthority: ExecutiveAuthority; - - constructor (name: string, privateKey: string, provider: BaseProvider, permission: string); - public getAuthorityInfo (): Promise; -} - -export class Account extends BaseAccount { - - constructor (name: string, privateKey: string, provider: BaseProvider, permission: string); - - public buyRam (bytes: number, payer?: Account): Promise; - public buyBandwidth (cpu: string, net: string, payer?: Account): Promise; - public send (receiver: Account, amount: string, symbol: string): Promise; - public createSubAuthority (authorityName: string, threshold?: number): Promise; - public increaseThreshold (threshold: number): Promise; - public addPermission (authorityName: string, weight?: number): Promise; - public addOnBehalfAccount (accountName: string, authority?: string, weight?: number): Promise; - public addAuthorityKey (publicKey: string, weight?: number): Promise; - public setWeight (weight: number): Promise; - public getBalance (symbol?: string, code?: string): Promise>; -} - -interface AuthorityAbilities { - action: string; - contract: string; -} - -declare class AuthorityAccount extends Account { - - public parentPermission: string; - - constructor (parentPermission: string, name: string, privateKey: string, provider: BaseProvider, permission: string); - public setAuthorityAbilities (abilities: Array): Promise; -} - -export class MultiSignatureFactory { - - constructor (provider: BaseProvider); - public load (name: string, privateKey: string, authorityName?: string): MultiSignatureAccount; -} - -export class MultiSignatureAccount extends BaseAccount { - - public accounts: Array; - public proposals: Array; - - constructor (name: string, privateKey: string, provider: BaseProvider, authority: string); - - public loadKeys (privateKeys: Array): void; - public loadAccounts (accounts: Array): void; - public propose (contractAction: ContractFunction, actionData: Array): Promise; - public approve (publicKey: string, proposalId: number): Promise; - public processProposal (proposalId: number): Promise; -} - diff --git a/types/contract/index.d.ts b/types/contract/index.d.ts deleted file mode 100644 index ccf0279..0000000 --- a/types/contract/index.d.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { FromQuery } from '../table-reader'; -import { BaseProvider } from '../provider'; -import { Account, BaseAccount } from '../account'; -import { TransactionResult, RawTransaction, SignedTransaction } from '../miscellaneous'; - -declare abstract class EventClass { - public events: Array; - public eventsHooks: Map void>; - - constructor (events: Array); - - public on (eventName: string, callback: (...params: any[]) => void): void; - public emit (eventName: string, ...params: any[]): void; -} - -declare class ContractInitializator extends EventClass { - - constructor (provider: BaseProvider); - - /* Own functions */ - public at (contractName: string, contractExecutorAccount?: Account): Promise; - public fromFile (abi: any, contractName: string, contractExecutorAccount?: Account): Contract -} - - -interface DeployOptions { - inline: boolean; -} - -export class ContractFactory extends ContractInitializator { - - constructor (provider: BaseProvider); - - /* Overwrite EventClass */ - public on (eventName: 'init', callback: (contract: Contract) => void): void; - public on (eventName: 'deploy', callback: (contract: Contract, deployTx: [TransactionResult, TransactionResult]) => void): void; - - /* Own functions */ - public deploy (wasmPath: string, abiPath: string, options?: DeployOptions): Promise; - public deployRaw (wasm: string, abi: any, options?: DeployOptions): Promise; - public deployOnAccount (wasmPath: string, abiPath: string, contractAccount: Account, options?: DeployOptions): Promise; - public deployRawOnAccount (wasm: string, abi: any, contractAccount: Account, options?: DeployOptions): Promise; -} - -interface ContractFunctionOptions { - from?: BaseAccount; - unique?: boolean; - tokens?: string -} - -export interface ContractFunction extends EventClass { - - (params: any[], options?: ContractFunctionOptions): Promise; - - /* Overwrite EventClass */ - on (eventName: 'processed', callback: (txResult: TransactionResult, ...fnParams: any[]) => void): void; - - /* Own functions */ - getRawTransaction (params: any[], options?: ContractFunctionOptions): Promise; - sign (params: any[], options?: ContractFunctionOptions): Promise; -} - -interface ContractFunctions { - [prop: string]: ContractFunction; -} - -interface ContractTables { - [prop: string]: FromQuery; -} - -export class Contract { - public abi: any; - public name: string; - public executor: BaseAccount; - public provider: BaseProvider; - - public tables: ContractTables; - public actions: ContractFunctions; - - constructor (provider: BaseProvider, abi: any, contractName: string, contractExecutorAccount: Account); - - public makeInline (): Promise; - public getRawWASM (): Promise; -} diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index fca8482..0000000 --- a/types/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ - -export * from './account'; -export * from './contract'; -export * from './provider'; -export * from './miscellaneous'; -export * from './utils'; \ No newline at end of file diff --git a/types/miscellaneous/index.d.ts b/types/miscellaneous/index.d.ts deleted file mode 100644 index 0daf462..0000000 --- a/types/miscellaneous/index.d.ts +++ /dev/null @@ -1,103 +0,0 @@ -interface TxActionTrace { - action_ordinal: number; - creator_action_ordinal: number; - closest_unnotified_ancestor_action_ordinal: number; - receipt: TxReceipt; - receiver: string; - act: TxAction; - context_free: boolean; - elapsed: number; - console: string; - trx_id: string; - block_num: number; - block_time: string; - producer_block_id: string; - account_ram_deltas: Array; - except: string; - error_code: string; - inline_traces: TxActionTrace -} - -interface TxReceipt { - status: string; - cpu_usage_us: number; - net_usage_words: number; -} - -interface TxAction { - account: string; - name: string; - authorization: [ - { - actor: string; - permission: string; - } - ]; - data: string; -} - -export interface RawTransaction { - expiration: string; - ref_block_num: number; - ref_block_prefix: number; - max_net_usage_words: number; - max_cpu_usage_ms: number; - delay_sec: number; - context_free_actions: Array; - actions: Array; - transaction_extensions: Array; -} - -export interface SignedTransaction { - compression: string; - transaction: RawTransaction; - signatures: Array; -} - -export interface BroadCastedTransaction { - transaction_id: string; - processed: - { - id: string; - block_num: number; - block_time: string; - producer_block_id: string; - receipt: TxReceipt; - elapsed: number; - net_usage: number; - scheduled: boolean; - action_traces: Array; - account_ram_delta: string; - except: string; - error_code: string; - } -} - -export interface TransactionResult extends BroadCastedTransaction { - broadcast: boolean; - transaction: SignedTransaction; -} - -interface TxAuthorityKey { - key: string; - weight: number; -} - -interface AuthAccount { - permission: { - actor: string; - permission: string - }; - weight: number; -} - -export interface AuthorityDetails { - perm_name: string; - parent: string; - required_auth: { - threshold: number; - keys: Array; - accounts: Array; - waits: Array; - } -} diff --git a/types/provider/index.d.ts b/types/provider/index.d.ts deleted file mode 100644 index 43fa113..0000000 --- a/types/provider/index.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { Account } from '../account'; -import { SelectQuery } from '../table-reader'; - -export interface NetworkDetails { - url?: string; - chainId?: string; -} - -interface NetworkData { - name: string; - url: string; - chainId: string; -} - -export class BaseProvider { - public eos: any; - public network: NetworkData; - public defaultAccount: Account; - - constructor (networkConfig: NetworkData); - - public select (table: string): SelectQuery; - public getABI (contractName: string): Promise; - public getRawWASM (contractName: string): Promise; -} - -declare class ProviderFactory { - - private instance: Provider; - private __provider: BaseProvider; - - constructor (network: string, config: NetworkDetails); - - public reset (newProvider: BaseProvider): void; - public availableNetworks (): Array; -} - -export interface Provider extends BaseProvider, ProviderFactory { - new(network?: string, config?: NetworkDetails): BaseProvider; - new(config?: NetworkDetails): BaseProvider; -} - diff --git a/types/table-reader/index.d.ts b/types/table-reader/index.d.ts deleted file mode 100644 index 5244ff2..0000000 --- a/types/table-reader/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -export class SelectQuery { - from (contractName: string): FromQuery; -} - -export class FromQuery { - equal (value: any): EqualQuery; - limit (limit: number): LimitQuery; - scope (accountName: string): ScopeQuery; - range (minValue: any, maxValue: any): RangeQuery; - index (index: number, keyType?: string): IndexQuery; - - find (): Promise>; -} - -export class ScopeQuery { - equal (value: any): EqualQuery; - limit (limit: number): LimitQuery; - range (minValue: any, maxValue: any): RangeQuery; - index (index: number, keyType?: string): IndexQuery; - - find (): Promise>; -} - -export class EqualQuery { - limit (limit: number): LimitQuery; - index (index: number, keyType: string): IndexQuery; - - find (): Promise>; -} - -export class RangeQuery { - limit (limit: number): LimitQuery; - index (index: number, keyType: string): IndexQuery; - - find (): Promise>; -} - -export class LimitQuery { - equal (value: any): EqualQuery; - range (minValue: any, maxValue: any): RangeQuery; - index (index: number, keyType: string): IndexQuery; - - find (): Promise>; -} - -export class IndexQuery { - equal (value: any): EqualQuery; - limit (limit: number): LimitQuery; - range (minValue: any, maxValue: any): RangeQuery; - - find (): Promise>; -} - diff --git a/types/utils/index.d.ts b/types/utils/index.d.ts deleted file mode 100644 index 6b29301..0000000 --- a/types/utils/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -interface KeysPair { - publicKey: string; - privateKey: string; -} - -export interface utils { - toName (encodedName: string): string; - randomName (): Promise; - generateKeys (): Promise; - randomPrivateKey (): Promise; - nameFromPrivateKey (privateKey: string): Promise; -}