From d4c35c2900b887eccda6928a01f6f88ec16e001c Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Tue, 27 Apr 2021 16:59:50 -0400 Subject: [PATCH 01/12] In progress changes --- src/eosjs-api.ts | 27 +++++++- src/eosjs-jsonrpc.ts | 15 +++++ src/eosjs-rpc-interfaces.ts | 13 +++- src/eosjs-serialize.ts | 4 +- src/tests/eosjs-jsonrpc.test.ts | 33 ++++++++++ src/tests/node.js | 18 ++++++ src/tests/node.test.ts | 15 +++++ src/tests/type-checks.test.ts | 110 ++++++++++++++++++++++++++++++-- src/tests/web.html | 51 +++++++++++++++ 9 files changed, 275 insertions(+), 11 deletions(-) diff --git a/src/eosjs-api.ts b/src/eosjs-api.ts index c1399901d..b68f631a9 100644 --- a/src/eosjs-api.ts +++ b/src/eosjs-api.ts @@ -28,7 +28,8 @@ import { PushTransactionArgs, GetBlockHeaderStateResult, GetBlockInfoResult, - GetBlockResult + GetBlockResult, + GetContractQueryResult, } from './eosjs-rpc-interfaces'; import * as ser from './eosjs-serialize'; @@ -345,6 +346,30 @@ export class Api { return pushTransactionArgs as PushTransactionArgs; } + /** + * Create and optionally broadcast a read-only query transaction. + * + * See `transact` for details of configuration options. + * + * @returns Contract query response if `broadcast`, `{signatures, serializedTransaction}` if `!broadcast` + */ + public async readOnlyQuery( + accountName: string, + transaction: Transaction, + { broadcast = true, sign = true, requiredKeys, blocksBehind, useLastIrreversible, expireSeconds }: + TransactConfig = {}): Promise + { + const pushTransactionArgs = await this.transact( + transaction, + { broadcast: false, sign, requiredKeys, compression: false, blocksBehind, useLastIrreversible, expireSeconds } + ) as PushTransactionArgs; + + if (broadcast) { + return this.rpc.get_contract_query(accountName, pushTransactionArgs) as Promise; + } + return pushTransactionArgs as PushTransactionArgs; + } + public async query( account: string, short: boolean, query: Query, { sign, requiredKeys, authorization = [] }: QueryConfig diff --git a/src/eosjs-jsonrpc.ts b/src/eosjs-jsonrpc.ts index 374a8a613..6c11b44dd 100644 --- a/src/eosjs-jsonrpc.ts +++ b/src/eosjs-jsonrpc.ts @@ -17,6 +17,7 @@ import { GetBlockResult, GetCodeResult, GetCodeHashResult, + GetContractQueryResult, GetCurrencyStatsResult, GetInfoResult, GetProducerScheduleResult, @@ -166,6 +167,20 @@ export class JsonRpc implements AuthorityProvider, AbiProvider { return await this.fetch('/v1/chain/get_code_hash', { account_name: accountName }); } + /** Raw call to `/v1/chain/get_contract_query */ + public async get_contract_query(accountName: string, + { signatures, serializedTransaction }: PushTransactionArgs): Promise { + return await this.fetch('/v1/chain/get_contract_query', { + account_name: accountName, + transaction: { + signatures, + compression: 0, + packed_context_free_data: arrayToHex(new Uint8Array(0)), + packed_trx: arrayToHex(serializedTransaction), + } + }); + } + /** Raw call to `/v1/chain/get_currency_balance` */ public async get_currency_balance(code: string, account: string, symbol: string = null): Promise { return await this.fetch('/v1/chain/get_currency_balance', { code, account, symbol }); diff --git a/src/eosjs-rpc-interfaces.ts b/src/eosjs-rpc-interfaces.ts index 4ea959cff..72926322f 100644 --- a/src/eosjs-rpc-interfaces.ts +++ b/src/eosjs-rpc-interfaces.ts @@ -3,7 +3,7 @@ * copyright defined in eosjs/LICENSE.txt */ -import { TransactionReceiptHeader, Transaction } from './eosjs-api-interfaces'; +import { TransactionReceiptHeader, Transaction, TransactionTrace } from './eosjs-api-interfaces'; import { Authorization } from './eosjs-serialize'; /** Structured format for abis */ @@ -341,6 +341,17 @@ export interface GetCodeHashResult { code_hash: string; } +/** Return value of `/v1/chain/get_contract_query` */ +export interface GetContractQueryResult { + head_block_num: number; + head_block_id: string; + last_irreversible_block_num: number; + last_irreversible_block_id: string; + code_hash: string; + pending_transactions: string[]; + result: TransactionTrace; +} + /** Return value of `/v1/chain/get_currency_stats` */ export interface GetCurrencyStatsResult { [key: string]: { diff --git a/src/eosjs-serialize.ts b/src/eosjs-serialize.ts index 64438b9ee..4a9cbe42c 100644 --- a/src/eosjs-serialize.ts +++ b/src/eosjs-serialize.ts @@ -127,7 +127,7 @@ export interface Action { account: string; name: string; authorization: Authorization[]; - data: any; + data?: any; hex_data?: string; } @@ -136,7 +136,7 @@ export interface SerializedAction { account: string; name: string; authorization: Authorization[]; - data: string; + data?: string; } /** Serialize and deserialize data */ diff --git a/src/tests/eosjs-jsonrpc.test.ts b/src/tests/eosjs-jsonrpc.test.ts index 53e315350..70f82cade 100644 --- a/src/tests/eosjs-jsonrpc.test.ts +++ b/src/tests/eosjs-jsonrpc.test.ts @@ -198,6 +198,39 @@ describe('JSON RPC', () => { expect(fetch).toBeCalledWith(endpoint + expPath, expParams); }); + it('calls get_contract_query', async () => { + const expPath = '/v1/chain/get_contract_query'; + const accountName = 'myaccountaaa'; + const signatures = [ + 'George Washington', + 'John Hancock', + 'Abraham Lincoln', + ]; + const serializedTransaction = new Uint8Array([ + 0, 16, 32, 128, 255, + ]); + const expReturn = { data: '12345' }; + const expParams = { + body: JSON.stringify({ + account_name: accountName, + transaction: { + signatures, + compression: 0, + packed_context_free_data: '', + packed_trx: '00102080ff' + } + }), + method: 'POST', + }; + + fetchMock.once(JSON.stringify(expReturn)); + + const response = await jsonRpc.get_contract_query(accountName, { signatures, serializedTransaction }); + + expect(response).toEqual(expReturn); + expect(fetch).toBeCalledWith(endpoint + expPath, expParams); + }); + it('calls get_currency_balance with all params', async () => { const expPath = '/v1/chain/get_currency_balance'; const code = 'morse'; diff --git a/src/tests/node.js b/src/tests/node.js index 98afd5095..f894cb468 100644 --- a/src/tests/node.js +++ b/src/tests/node.js @@ -177,6 +177,23 @@ const transactWithReturnValue = async () => { }); }; +const readOnlyQuery = async () => { + return await api.readOnlyQuery('readonly', { + actions: [{ + account: 'readonly', + name: 'get', + authorization: [{ + actor: 'readonly', + permission: 'active', + }], + data: {}, + }], + }, { + blocksBehind: 3, + expireSeconds: 30 + }); +}; + const broadcastResult = async (signaturesAndPackedTransaction) => await api.pushSignedTransaction(signaturesAndPackedTransaction); const transactShouldFail = async () => await api.transact({ @@ -210,5 +227,6 @@ module.exports = { transactWithShorthandTxJsonContextFreeAction, transactWithShorthandTxJsonContextFreeData, transactWithReturnValue, + readOnlyQuery, rpcShouldFail }; diff --git a/src/tests/node.test.ts b/src/tests/node.test.ts index e95c3baeb..ba4799379 100644 --- a/src/tests/node.test.ts +++ b/src/tests/node.test.ts @@ -101,6 +101,21 @@ describe('Node JS environment', () => { expect(transactionResponse.processed.action_traces[0].return_value_data).toEqual(expectedValue); }); + it('confirms the return value of the read-only query', async () => { + const expectedValue = [ + {'age': 25, 'gender': 1, 'id': 1, 'name': 'Bob Smith'}, + {'age': 42, 'gender': 1, 'id': 3, 'name': 'John Smith'}, + {'age': 27, 'gender': 1, 'id': 4, 'name': 'Jack Smith'}, + {'age': 20, 'gender': 0, 'id': 2, 'name': 'Alice Smith'}, + {'age': 26, 'gender': 0, 'id': 5, 'name': 'Youko Niihara'}, + {'age': 18, 'gender': 0, 'id': 6, 'name': 'Rose Lee'}, + {'age': 25, 'gender': 0, 'id': 7, 'name': 'Youko Kawakami'}, + {'age': 24, 'gender': 0, 'id': 8, 'name': 'Yuu Yamada'} + ]; + transactionResponse = await tests.readOnlyQuery(); + expect(transactionResponse.result.action_traces[0].return_value_data).toEqual(expectedValue); + }); + it('throws appropriate error message without configuration object or TAPOS in place', async () => { try { failedAsPlanned = true; diff --git a/src/tests/type-checks.test.ts b/src/tests/type-checks.test.ts index 80f6ec083..fdd3997d6 100644 --- a/src/tests/type-checks.test.ts +++ b/src/tests/type-checks.test.ts @@ -29,6 +29,7 @@ import { AbiBinToJsonResult, TraceApiGetBlockResult, DBSizeGetResult, + GetContractQueryResult, } from '../eosjs-rpc-interfaces'; import { TransactResult } from '../eosjs-api-interfaces'; import 'jest-extended'; @@ -405,7 +406,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - data: 'any', + 'data?': 'any', 'hex_data?': 'string', }, 'context_free_data?': 'number', @@ -416,7 +417,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - data: 'any', + 'data?': 'any', 'hex_data?': 'string', }, 'transaction_extensions?': { @@ -514,6 +515,101 @@ describe('Chain API Plugin Endpoints', () => { verifyType(result, getCodeHashResult); }); + it('validates return type of get_contract_query', async () => { + const transaction: PushTransactionArgs = await api.transact({ + actions: [{ + account: 'readonly', + name: 'get', + authorization: [{ + actor: 'readonly', + permission: 'active', + }], + data: {}, + }], + }, { + sign: true, + broadcast: false, + useLastIrreversible: true, + expireSeconds: 30, + }) as PushTransactionArgs; + const result: GetContractQueryResult = await rpc.get_contract_query('readonly', transaction); + const getContractQueryResult: any = { + head_block_num: 'number', + head_block_id: 'string', + last_irreversible_block_num: 'number', + last_irreversible_block_id: 'string', + code_hash: 'string', + pending_transactions: 'string', + result: { + id: 'string', + block_num: 'number', + block_time: 'string', + 'producer_block_id&': 'string', + 'receipt&': { + status: 'string', + cpu_usage_us: 'number', + net_usage_words: 'number', + }, + elapsed: 'number', + net_usage: 'number', + scheduled: 'boolean', + action_traces: { + action_ordinal: 'number', + creator_action_ordinal: 'number', + closest_unnotified_ancestor_action_ordinal: 'number', + receipt: { + receiver: 'string', + act_digest: 'string', + global_sequence: 'number', + recv_sequence: 'number', + auth_sequence: [ 'string', 'number' ], + code_sequence: 'number', + abi_sequence: 'number', + }, + receiver: 'string', + act: { + account: 'string', + name: 'string', + authorization: { + actor: 'string', + permission: 'string', + }, + 'data?': 'any', + 'hex_data?': 'string', + }, + context_free: 'boolean', + elapsed: 'number', + console: 'string', + trx_id: 'string', + block_num: 'number', + block_time: 'string', + 'producer_block_id&': 'string', + account_ram_deltas: { + account: 'string', + delta: 'number', + }, + account_disk_deltas: { + account: 'string', + delta: 'number', + }, + except: 'any', + 'error_code&': 'number', + 'return_value?': 'any', + 'return_value_hex_data?': 'string', + 'return_value_data?': 'any', + 'inline_traces?': 'any', // ActionTrace, recursive? + }, + 'account_ram_delta&': { + account: 'string', + delta: 'number', + }, + 'except&': 'string', + 'error_code&': 'number', + } + }; + verifyType(result, getContractQueryResult); + }); + it('validates return type of get_currency_balance', async () => { const result: string[] = await rpc.get_currency_balance('eosio.token', 'bob', 'SYS'); result.forEach((element: any) => { @@ -677,7 +773,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - data: 'any', + 'data?': 'any', 'hex_data?': 'string', }, 'context_free_data?': 'number', @@ -688,7 +784,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - data: 'any', + 'data?': 'any', 'hex_data?': 'string', }, 'transaction_extensions?': { @@ -846,7 +942,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - data: 'any', + 'data?': 'any', 'hex_data?': 'string', }, context_free: 'boolean', @@ -962,7 +1058,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - data: 'any', + 'data?': 'any', 'hex_data?': 'string', }, context_free: 'boolean', @@ -1059,7 +1155,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - data: 'any', + 'data?': 'any', 'hex_data?': 'string', }, context_free: 'boolean', diff --git a/src/tests/web.html b/src/tests/web.html index 9688ee3bc..305eaf8a4 100644 --- a/src/tests/web.html +++ b/src/tests/web.html @@ -474,6 +474,56 @@ resultsLabel.innerText = FAILED; return false; } + + const readOnlyQuery = async () => { + return await api.readOnlyQuery('readonly', { + actions: [{ + account: 'readonly', + name: 'get', + authorization: [{ + actor: 'readonly', + permission: 'active', + }], + data: {}, + }], + }, { + blocksBehind: 3, + expireSeconds: 30 + }); + } + + const testWithReadOnlyQuery = async (e) => { + const expectedValue = [ + {'age': 25, 'gender': 1, 'id': 1, 'name': 'Bob Smith'}, + {'age': 42, 'gender': 1, 'id': 3, 'name': 'John Smith'}, + {'age': 27, 'gender': 1, 'id': 4, 'name': 'Jack Smith'}, + {'age': 20, 'gender': 0, 'id': 2, 'name': 'Alice Smith'}, + {'age': 26, 'gender': 0, 'id': 5, 'name': 'Youko Niihara'}, + {'age': 18, 'gender': 0, 'id': 6, 'name': 'Rose Lee'}, + {'age': 25, 'gender': 0, 'id': 7, 'name': 'Youko Kawakami'}, + {'age': 24, 'gender': 0, 'id': 8, 'name': 'Yuu Yamada'} + ]; + resultsLabel = e.target; + resultsLabel.innerText = EXECUTING; + + try { + transactionResponse = await readOnlyQuery(); + } catch (error) { + resultsLabel.className = 'failed'; + resultsLabel.innerText = FAILED; + console.error('Transact Read Only Query Test Failure: ', error.message); + return false; + } + + if (transactionResponse.result.action_traces[0].return_value_data === expectedValue) { + resultsLabel.className = "success"; + resultsLabel.innerText = SUCCESS; + return true; + } + resultsLabel.className = 'failed'; + resultsLabel.innerText = FAILED; + return false; + } const transactShouldFail = async () => await api.transact({ actions: [{ @@ -564,6 +614,7 @@

Web Build Integration Tests

Transact with .with() Using Tx and Json Abi with Context Free Data

Transact elliptic p256/KeyType.r1 Keys and Signatures

Transact Return Values

+

Read Only Query

Invalid Transaction Throws Error

Invalid Rpc Call Throws Rpc Error

From f084bd4b619a96056da8f54aebf1685da2311dbc Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Wed, 28 Apr 2021 20:07:09 -0400 Subject: [PATCH 02/12] Tests passing --- .github/eosjs-ci/Dockerfile | 11 +++++++++-- .github/eosjs-ci/scripts/deploy_contracts.sh | 7 +++++++ .github/workflows/ci.yml | 2 +- src/tests/web.html | 18 +++++++++--------- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/eosjs-ci/Dockerfile b/.github/eosjs-ci/Dockerfile index f26af56d7..b14952916 100644 --- a/.github/eosjs-ci/Dockerfile +++ b/.github/eosjs-ci/Dockerfile @@ -2,8 +2,8 @@ #### docker build --tag eosjs-ci:test ./.github/eosjs-ci #### docker run --publish 8888:8888 eosjs-ci:test -ARG EOSBRANCH=develop -ARG CDTBRANCH=develop +ARG EOSBRANCH=read_only_query_EPE-746 +ARG CDTBRANCH=qy-read-only-action FROM eosio/eosio.cdt:${CDTBRANCH} as contracts WORKDIR /root ### base @@ -14,6 +14,12 @@ RUN git clone https://github.com/EOSIO/eos \ && cd eos \ && git checkout develop +RUN git clone https://github.com/EOSIO/eosio.cdt \ + && cd eosio.cdt \ + && git checkout qy-read-only-action \ + && mkdir build && cd build && mkdir read_only_query_tests && cd .. \ + && eosio-cpp -abigen ./tests/unit/test_contracts/read_only_query_tests.cpp -o ./build/read_only_query_tests/read_only_query_tests.wasm + RUN git clone https://github.com/EOSIO/eosio.contracts \ && cd eosio.contracts \ && git checkout develop \ @@ -41,6 +47,7 @@ WORKDIR /root RUN mkdir -p "/opt/eosio/bin/contracts" COPY --from=contracts /root/eos/contracts/contracts/eosio.bios/bin/* /opt/eosio/bin/contracts/eosio.bios/ COPY --from=contracts /root/eos/contracts/contracts/eosio.boot/bin/* /opt/eosio/bin/contracts/eosio.boot/ +COPY --from=contracts /root/eosio.cdt/build/read_only_query_tests/* /opt/eosio/bin/contracts/read_only_query_tests/ COPY --from=contracts /root/eosio.contracts/build/ /opt/eosio/bin/contracts COPY --from=contracts /root/key-value-example-app/contracts/kv_todo/build/* /opt/eosio/bin/contracts/kv_todo/ COPY --from=contracts /root/return-values-example-app/contracts/action_return_value/build/* /opt/eosio/bin/contracts/action_return_value/ diff --git a/.github/eosjs-ci/scripts/deploy_contracts.sh b/.github/eosjs-ci/scripts/deploy_contracts.sh index f4a694e96..cf2ad9a10 100644 --- a/.github/eosjs-ci/scripts/deploy_contracts.sh +++ b/.github/eosjs-ci/scripts/deploy_contracts.sh @@ -162,6 +162,7 @@ cleos create account eosio eosio.vpay $SYSTEM_ACCOUNT_PUBLIC_KEY cleos create account eosio eosio.rex $SYSTEM_ACCOUNT_PUBLIC_KEY cleos create account eosio eosio.token $SYSTEM_ACCOUNT_PUBLIC_KEY cleos create account eosio returnvalue $SYSTEM_ACCOUNT_PUBLIC_KEY +cleos create account eosio readonly $EXAMPLE_ACCOUNT_PUBLIC_KEY cleos create account eosio todo $SYSTEM_ACCOUNT_PUBLIC_KEY cleos create account eosio bob $EXAMPLE_ACCOUNT_PUBLIC_KEY cleos create account eosio alice $EXAMPLE_ACCOUNT_PUBLIC_KEY @@ -214,6 +215,10 @@ sleep 1s setabi returnvalue $CONTRACTS_DIR/action_return_value/action_return_value.abi setcode returnvalue $CONTRACTS_DIR/action_return_value/action_return_value.wasm +sleep 1s +setabi readonly $CONTRACTS_DIR/read_only_query_tests/read_only_query_tests.abi +setcode readonly $CONTRACTS_DIR/read_only_query_tests/read_only_query_tests.wasm + sleep 1s setabi eosio.token $CONTRACTS_DIR/eosio.token/eosio.token.abi setcode eosio.token $CONTRACTS_DIR/eosio.token/eosio.token.wasm @@ -229,6 +234,8 @@ cleos push action todo upsert '["bf581bee-9f2c-447b-94ad-78e4984b6f51", "todo", cleos push action todo upsert '["b7b0d09d-a82b-44d9-b067-3bae2d02917e", "todo", "Start Blockchain", false]' -p todo@active cleos push action todo upsert '["ac8acfe7-cd4e-4d22-8400-218b697a4517", "todo", "Deploy Hello World Contract", false]' -p todo@active +cleos push action readonly setup '[]' -p readonly@active + echo "All done initializing the blockchain" if [[ -z $NODEOS_RUNNING ]]; then diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3b30ebce..e62e4358d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: git push origin ${GITHUB_REF#refs/*/} services: nodeos: - image: eosio/eosjs-ci:develop + image: eosio/eosjs-ci:read_only_queries ports: - 8888:8888 diff --git a/src/tests/web.html b/src/tests/web.html index 305eaf8a4..c118f2c80 100644 --- a/src/tests/web.html +++ b/src/tests/web.html @@ -494,14 +494,14 @@ const testWithReadOnlyQuery = async (e) => { const expectedValue = [ - {'age': 25, 'gender': 1, 'id': 1, 'name': 'Bob Smith'}, - {'age': 42, 'gender': 1, 'id': 3, 'name': 'John Smith'}, - {'age': 27, 'gender': 1, 'id': 4, 'name': 'Jack Smith'}, - {'age': 20, 'gender': 0, 'id': 2, 'name': 'Alice Smith'}, - {'age': 26, 'gender': 0, 'id': 5, 'name': 'Youko Niihara'}, - {'age': 18, 'gender': 0, 'id': 6, 'name': 'Rose Lee'}, - {'age': 25, 'gender': 0, 'id': 7, 'name': 'Youko Kawakami'}, - {'age': 24, 'gender': 0, 'id': 8, 'name': 'Yuu Yamada'} + {'id': 1, 'name': 'Bob Smith', 'gender': 1, 'age': 25}, + {'id': 3, 'name': 'John Smith', 'gender': 1, 'age': 42}, + {'id': 4, 'name': 'Jack Smith', 'gender': 1, 'age': 27}, + {'id': 2, 'name': 'Alice Smith', 'gender': 0, 'age': 20,}, + {'id': 5, 'name': 'Youko Niihara', 'gender': 0, 'age': 26}, + {'id': 6, 'name': 'Rose Lee', 'gender': 0, 'age': 18}, + {'id': 7, 'name': 'Youko Kawakami', 'gender': 0, 'age': 25}, + {'id': 8, 'name': 'Yuu Yamada', 'gender': 0, 'age': 24} ]; resultsLabel = e.target; resultsLabel.innerText = EXECUTING; @@ -515,7 +515,7 @@ return false; } - if (transactionResponse.result.action_traces[0].return_value_data === expectedValue) { + if (JSON.stringify(transactionResponse.result.action_traces[0].return_value_data) === JSON.stringify(expectedValue)) { resultsLabel.className = "success"; resultsLabel.innerText = SUCCESS; return true; From b6966c21db66676829f01e634b27278b374f4de1 Mon Sep 17 00:00:00 2001 From: "Block.one DevOps" Date: Thu, 29 Apr 2021 00:12:46 +0000 Subject: [PATCH 03/12] Updating package.json and yarn.lock --- package.json | 12 +-- yarn.lock | 228 ++++++++++++++++++++++----------------------------- 2 files changed, 102 insertions(+), 138 deletions(-) diff --git a/package.json b/package.json index f7c25c52f..bbae5cf61 100644 --- a/package.json +++ b/package.json @@ -35,24 +35,24 @@ "devDependencies": { "@blockone/eslint-config-blockone": "^4.0.0", "@types/elliptic": "^6.4.12", - "@types/jest": "^26.0.22", - "@types/node": "^14.14.41", + "@types/jest": "^26.0.23", + "@types/node": "^14.14.43", "@types/node-fetch": "^2.5.10", "@types/pako": "^1.0.1", "buffer": "^6.0.3", "clean-webpack-plugin": "^3.0.0", "crypto-browserify": "^3.12.0", - "cypress": "^7.1.0", + "cypress": "^7.2.0", "eosjs-ecc": "^4.0.7", - "eslint": "^7.24.0", + "eslint": "^7.25.0", "jest": "^26.6.3", "jest-extended": "^0.11.5", "jest-fetch-mock": "^3.0.3", "rimraf": "^3.0.2", "ts-jest": "^26.5.5", - "ts-loader": "^9.0.2", + "ts-loader": "^9.1.1", "typescript": "^4.2.4", - "webpack": "^5.34.0", + "webpack": "^5.36.1", "webpack-cli": "^4.6.0" }, "jest": { diff --git a/yarn.lock b/yarn.lock index 5f50d82a7..8a93fedd5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -51,7 +51,7 @@ eslint-visitor-keys "^1.3.0" semver "^6.3.0" -"@babel/generator@^7.13.16", "@babel/generator@^7.13.9": +"@babel/generator@^7.13.16": version "7.13.16" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.13.16.tgz#0befc287031a201d84cdfc173b46b320ae472d14" integrity sha512-grBBR75UnKOcUWMp8WoDxNsWCFl//XCK6HWTrBQKTr5SV9f5g0pNOjdyzi/DTBv12S9GnYPInIXQBTky7OXEMg== @@ -161,13 +161,13 @@ integrity sha512-TopkMDmLzq8ngChwRlyjR6raKD6gMSae4JdYDB8bByKreQgG0RBTuKe9LRxW3wFtUnjxOPRKBDwEH6Mg5KeDfw== "@babel/helpers@^7.13.16": - version "7.13.16" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.13.16.tgz#08af075f786fd06a56e41bcac3e8cc87ddc4d0b3" - integrity sha512-x5otxUaLpdWHl02P4L94wBU+2BJXBkvO+6d6uzQ+xD9/h2hTSAwA5O8QV8GqKx/l8i+VYmKKQg9e2QGTa2Wu3Q== + version "7.13.17" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.13.17.tgz#b497c7a00e9719d5b613b8982bda6ed3ee94caf6" + integrity sha512-Eal4Gce4kGijo1/TGJdqp3WuhllaMLSrW6XcL0ulyUAQOuxHcCafZE8KHg9857gcTehsm/v7RcOx2+jp0Ryjsg== dependencies: "@babel/template" "^7.12.13" - "@babel/traverse" "^7.13.15" - "@babel/types" "^7.13.16" + "@babel/traverse" "^7.13.17" + "@babel/types" "^7.13.17" "@babel/highlight@^7.10.4", "@babel/highlight@^7.12.13": version "7.13.10" @@ -178,7 +178,7 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.15", "@babel/parser@^7.13.16": +"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.16": version "7.13.16" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.16.tgz#0f18179b0448e6939b1f3f5c4c355a3a9bcdfd37" integrity sha512-6bAg36mCwuqLO0hbR+z7PHuqWiCeP7Dzg73OpQwsAB1Eb8HnGEz5xYBzCfbu+YjoaJsJs+qheDxVAuqbt3ILEw== @@ -283,24 +283,24 @@ "@babel/parser" "^7.12.13" "@babel/types" "^7.12.13" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.13.13", "@babel/traverse@^7.13.15": - version "7.13.15" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.13.15.tgz#c38bf7679334ddd4028e8e1f7b3aa5019f0dada7" - integrity sha512-/mpZMNvj6bce59Qzl09fHEs8Bt8NnpEDQYleHUPZQ3wXUMvXi+HJPLars68oAbmp839fGoOkv2pSL2z9ajCIaQ== +"@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.13.13", "@babel/traverse@^7.13.15", "@babel/traverse@^7.13.17": + version "7.13.17" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.13.17.tgz#c85415e0c7d50ac053d758baec98b28b2ecfeea3" + integrity sha512-BMnZn0R+X6ayqm3C3To7o1j7Q020gWdqdyP50KEoVqaCO2c/Im7sYZSmVgvefp8TTMQ+9CtwuBp0Z1CZ8V3Pvg== dependencies: "@babel/code-frame" "^7.12.13" - "@babel/generator" "^7.13.9" + "@babel/generator" "^7.13.16" "@babel/helper-function-name" "^7.12.13" "@babel/helper-split-export-declaration" "^7.12.13" - "@babel/parser" "^7.13.15" - "@babel/types" "^7.13.14" + "@babel/parser" "^7.13.16" + "@babel/types" "^7.13.17" debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.12.13", "@babel/types@^7.13.12", "@babel/types@^7.13.14", "@babel/types@^7.13.16", "@babel/types@^7.3.0", "@babel/types@^7.3.3": - version "7.13.16" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.13.16.tgz#916120b858aa5655cfba84bd0f6021ff5bdb4e65" - integrity sha512-7enM8Wxhrl1hB1+k6+xO6RmxpNkaveRWkdpyii8DkrLWRgr0l3x29/SEuhTIkP+ynHsU/Hpjn8Evd/axv/ll6Q== +"@babel/types@^7.0.0", "@babel/types@^7.12.13", "@babel/types@^7.13.12", "@babel/types@^7.13.14", "@babel/types@^7.13.16", "@babel/types@^7.13.17", "@babel/types@^7.3.0", "@babel/types@^7.3.3": + version "7.13.17" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.13.17.tgz#48010a115c9fba7588b4437dd68c9469012b38b4" + integrity sha512-RawydLgxbOPDlTLJNtoIypwdmAy//uQIzlKt2+iBiJaRlVuI6QLUxVAyWGNfOzp8Yu4L4lLIacoCyTNtpb4wiA== dependencies: "@babel/helper-validator-identifier" "^7.12.11" to-fast-properties "^2.0.0" @@ -774,10 +774,10 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@^26.0.22": - version "26.0.22" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.22.tgz#8308a1debdf1b807aa47be2838acdcd91e88fbe6" - integrity sha512-eeWwWjlqxvBxc4oQdkueW5OF/gtfSceKk4OnOAGlUSwS/liBRtZppbJuz1YkgbrbfGOoeBHun9fOvXnjNwrSOw== +"@types/jest@^26.0.23": + version "26.0.23" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.23.tgz#a1b7eab3c503b80451d019efb588ec63522ee4e7" + integrity sha512-ZHLmWMJ9jJ9PTiT58juykZpL7KjwJywFN3Rr2pTSkyQfydf/rk22yS7W8p5DaVUMQ2BQC7oYiU3FjbTM/mYrOA== dependencies: jest-diff "^26.0.0" pretty-format "^26.0.0" @@ -800,10 +800,15 @@ "@types/node" "*" form-data "^3.0.0" -"@types/node@*", "@types/node@^14.14.31", "@types/node@^14.14.41": - version "14.14.41" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.41.tgz#d0b939d94c1d7bd53d04824af45f1139b8c45615" - integrity sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g== +"@types/node@*": + version "15.0.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-15.0.1.tgz#ef34dea0881028d11398be5bf4e856743e3dc35a" + integrity sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA== + +"@types/node@^14.14.31", "@types/node@^14.14.43": + version "14.14.43" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.43.tgz#26bcbb0595b305400e8ceaf9a127a7f905ae49c8" + integrity sha512-3pwDJjp1PWacPTpH0LcfhgjvurQvrZFBrC6xxjaUEZ7ifUtT32jtjPxEMMblpqd2Mvx+k8haqQJLQxolyGN/cQ== "@types/normalize-package-data@^2.4.0": version "2.4.0" @@ -826,9 +831,9 @@ integrity sha512-dIPoZ3g5gcx9zZEszaxLSVTvMReD3xxyyDnQUjA6IYDG9Ba2AV0otMPs+77sG9ojB4Qr2N2Vk5RnKeuA0X/0bg== "@types/sizzle@^2.3.2": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.2.tgz#a811b8c18e2babab7d542b3365887ae2e4d9de47" - integrity sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg== + version "2.3.3" + resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.3.tgz#ff5e2f1902969d305225a047c8a0fd5c915cebef" + integrity sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ== "@types/source-list-map@*": version "0.1.2" @@ -1143,10 +1148,10 @@ acorn@^7.1.1, acorn@^7.4.0: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== -acorn@^8.0.4, acorn@^8.1.0: - version "8.1.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.1.1.tgz#fb0026885b9ac9f48bac1e185e4af472971149ff" - integrity sha512-xYiIVjNuqtKXMxlRMDc6mZUhXehod4a3gbZ1qRlM7icK4EbxUFNLhWoPblCvFtB2Y9CIqHP3CF/rdxLItaQv8g== +acorn@^8.1.0, acorn@^8.2.1: + version "8.2.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.2.1.tgz#0d36af126fb6755095879c1dc6fd7edf7d60a5fb" + integrity sha512-z716cpm5TX4uzOzILx8PavOE6C6DKshHDw1aQN52M/yNSqE9s5O8SMfyhCCfCJ3HmTL0NkVOi+8a/55T7YB3bg== ajv-keywords@^3.5.2: version "3.5.2" @@ -1164,9 +1169,9 @@ ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5: uri-js "^4.2.2" ajv@^8.0.1: - version "8.1.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.1.0.tgz#45d5d3d36c7cdd808930cc3e603cf6200dbeb736" - integrity sha512-B/Sk2Ix7A36fs/ZkuGLIR86EdjbgR6fsAcbx9lOP/QBSXujDNbVmIS/U4Itz5k8fPFDeVZl/zQ/gJW4Jrq6XjQ== + version "8.2.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.2.0.tgz#c89d3380a784ce81b2085f48811c4c101df4c602" + integrity sha512-WSNGFuyWd//XO8n/m/EaOlNLtO0yL8EXT/74LqT4khdhpZjP7lkj/kT5uwRmGitKEVp/Oj7ZUHeGfPtgHhQ5CA== dependencies: fast-deep-equal "^3.1.1" json-schema-traverse "^1.0.0" @@ -1591,13 +1596,13 @@ browserify-sign@^4.0.0: safe-buffer "^5.2.0" browserslist@^4.14.5: - version "4.16.4" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.4.tgz#7ebf913487f40caf4637b892b268069951c35d58" - integrity sha512-d7rCxYV8I9kj41RH8UKYnvDYCRENUlHRgyXy/Rhr/1BaeLGfiCptEdFE8MIrvGfWbBFNjVYx76SQWvNX1j+/cQ== + version "4.16.5" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.5.tgz#952825440bca8913c62d0021334cbe928ef062ae" + integrity sha512-C2HAjrM1AI/djrpAUU/tr4pml1DqLIzJKSLDBXBrNErl9ZCCTXdhwxdJjYc16953+mBWf7Lw+uUJgpgb8cN71A== dependencies: - caniuse-lite "^1.0.30001208" + caniuse-lite "^1.0.30001214" colorette "^1.2.2" - electron-to-chromium "^1.3.712" + electron-to-chromium "^1.3.719" escalade "^3.1.1" node-releases "^1.1.71" @@ -1672,14 +1677,6 @@ cachedir@^2.3.0: resolved "https://registry.yarnpkg.com/cachedir/-/cachedir-2.3.0.tgz#0c75892a052198f0b21c7c1804d8331edfcae0e8" integrity sha512-A+Fezp4zxnit6FanDmv9EqXNAi3vt9DWp51/71UEhXukb7QUuvtv9344h91dyAxuTLoSYJFU299qzR3tzwPAhw== -call-bind@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== - dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" - callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -1695,10 +1692,10 @@ camelcase@^6.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809" integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== -caniuse-lite@^1.0.30001208: - version "1.0.30001214" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001214.tgz#70f153c78223515c6d37a9fde6cd69250da9d872" - integrity sha512-O2/SCpuaU3eASWVaesQirZv1MSjUNOvmugaD8zNSJqw6Vv5SGwoOpA9LJs3pNPfM745nxqPvfZY3MQKY4AKHYg== +caniuse-lite@^1.0.30001214: + version "1.0.30001219" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001219.tgz#5bfa5d0519f41f993618bd318f606a4c4c16156b" + integrity sha512-c0yixVG4v9KBc/tQ2rlbB3A/bgBFRvl8h8M4IeUbqCca4gsiCfvtaheUssbnux/Mb66Vjz7x8yYjDgYcNQOhyQ== capture-exit@^2.0.0: version "2.0.0" @@ -1733,9 +1730,9 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1: supports-color "^5.3.0" chalk@^4.0.0, chalk@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" - integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== + version "4.1.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.1.tgz#c80b3fab28bf6371e6863325eee67e618b77e6ad" + integrity sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg== dependencies: ansi-styles "^4.1.0" supports-color "^7.1.0" @@ -1925,10 +1922,10 @@ commander@^7.0.0: resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== -comment-parser@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.1.2.tgz#e5317d7a2ec22b470dcb54a29b25426c30bf39d8" - integrity sha512-AOdq0i8ghZudnYv8RUnHrhTgafUGs61Rdz9jemU5x2lnZwAWyOq7vySo626K59e1fVKH1xSRorJwPVRLSWOoAQ== +comment-parser@1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.1.5.tgz#453627ef8f67dbcec44e79a9bd5baa37f0bce9b2" + integrity sha512-RePCE4leIhBlmrqiYTvaqEeGYg7qpSl4etaIabKtdOQVi+mSTIBBklGUwIr79GXYnl3LpMwmDw4KeR2stNc6FA== common-tags@^1.8.0: version "1.8.0" @@ -2086,10 +2083,10 @@ cssstyle@^2.3.0: dependencies: cssom "~0.3.6" -cypress@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-7.1.0.tgz#6cb5dc22c6271a9d7a79a2477251a95afc77e531" - integrity sha512-AptQP9fVtN/FfOv8rJ9hTGJE2XQFc8saLHT38r/EeyWhzp0q/+P/DYRTDtjGZHeLTCNznAUrT4lal8jm+ouS7Q== +cypress@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-7.2.0.tgz#6a3364e18972f898fff1fb12c1ff747939e45ddc" + integrity sha512-lHHGay+YsffDn4M0bkkwezylBVHUpwwhtqte4LNPrFRCHy77X38+1PUe3neFb3glVTM+rbILtTN6FhO2djcOuQ== dependencies: "@cypress/listr-verbose-renderer" "^0.4.1" "@cypress/request" "^2.88.5" @@ -2318,10 +2315,10 @@ ecurve@1.0.5: dependencies: bigi "^1.1.0" -electron-to-chromium@^1.3.712: - version "1.3.717" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.717.tgz#78d4c857070755fb58ab64bcc173db1d51cbc25f" - integrity sha512-OfzVPIqD1MkJ7fX+yTl2nKyOE4FReeVfMCzzxQS+Kp43hZYwHwThlGP+EGIZRXJsxCM7dqo8Y65NOX/HP12iXQ== +electron-to-chromium@^1.3.719: + version "1.3.723" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.723.tgz#52769a75635342a4db29af5f1e40bd3dad02c877" + integrity sha512-L+WXyXI7c7+G1V8ANzRsPI5giiimLAUDC6Zs1ojHHPhYXb3k/iTABFmWjivEtsWrRQymjnO66/rO2ZTABGdmWg== elegant-spinner@^1.0.1: version "1.0.1" @@ -2433,16 +2430,16 @@ escodegen@^2.0.0: source-map "~0.6.1" eslint-plugin-jsdoc@^32.2.0: - version "32.3.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-32.3.0.tgz#7c9fa5da8c72bd6ad7d97bbf8dee8bc29bec3f9e" - integrity sha512-zyx7kajDK+tqS1bHuY5sapkad8P8KT0vdd/lE55j47VPG2MeenSYuIY/M/Pvmzq5g0+3JB+P3BJGUXmHxtuKPQ== + version "32.3.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-32.3.3.tgz#c430f5d289b6251cb1bf49585858b2335890dab3" + integrity sha512-WxXohbMYlZvCt3r7MepwT++nTLsO4CPegWcm5toM4IGq3MBmYkG+Uf5yDa+n1MwPXLg+KbJqAsI19hmkVD7MPg== dependencies: - comment-parser "1.1.2" + comment-parser "1.1.5" debug "^4.3.1" jsdoctypeparser "^9.0.0" - lodash "^4.17.20" + lodash "^4.17.21" regextras "^0.7.1" - semver "^7.3.4" + semver "^7.3.5" spdx-expression-parse "^3.0.1" eslint-plugin-prefer-arrow@^1.2.3: @@ -2475,10 +2472,10 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== -eslint@^7.20.0, eslint@^7.24.0: - version "7.24.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.24.0.tgz#2e44fa62d93892bfdb100521f17345ba54b8513a" - integrity sha512-k9gaHeHiFmGCDQ2rEfvULlSLruz6tgfA8DEn+rY9/oYPFFTlz55mM/Q/Rij1b2Y42jwZiK3lXvNTw6w6TXzcKQ== +eslint@^7.20.0, eslint@^7.25.0: + version "7.25.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.25.0.tgz#1309e4404d94e676e3e831b3a3ad2b050031eb67" + integrity sha512-TVpSovpvCNpLURIScDRB6g5CYu/ZFq9GfX2hLNIV4dSBKxIWojeDODvYl3t0k0VtMxYeR8OXPCFE5+oHMlGfhw== dependencies: "@babel/code-frame" "7.12.11" "@eslint/eslintrc" "^0.4.0" @@ -2923,15 +2920,6 @@ get-caller-file@^2.0.1: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== -get-intrinsic@^1.0.2: - version "1.1.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" - integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== - dependencies: - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - get-package-type@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" @@ -3088,11 +3076,6 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has-symbols@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423" - integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== - has-value@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" @@ -3283,13 +3266,6 @@ is-arrayish@^0.2.1: resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= -is-boolean-object@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.0.tgz#e2aaad3a3a8fca34c28f6eee135b156ed2587ff0" - integrity sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA== - dependencies: - call-bind "^1.0.0" - is-buffer@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" @@ -3310,9 +3286,9 @@ is-ci@^3.0.0: ci-info "^3.1.1" is-core-module@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" - integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== + version "2.3.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.3.0.tgz#d341652e3408bca69c4671b79a0954a3d349f887" + integrity sha512-xSphU2KG9867tsYdLD4RWQ1VqdFl4HTO9Thf3I/3dLEfr0dbPTWKsuCKrgqMljg4nPE+Gq0VCnzT3gr0CyBmsw== dependencies: has "^1.0.3" @@ -3407,11 +3383,6 @@ is-installed-globally@~0.4.0: global-dirs "^3.0.0" is-path-inside "^3.0.2" -is-number-object@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197" - integrity sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw== - is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -3482,11 +3453,6 @@ is-stream@^2.0.0: resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3" integrity sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw== -is-string@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" - integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== - is-typedarray@^1.0.0, is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -4282,7 +4248,7 @@ lodash.truncate@^4.4.2: resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM= -lodash@4.x, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.7.0: +lodash@4.x, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -5329,7 +5295,7 @@ schema-utils@^3.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@7.x, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4: +semver@7.x, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: version "7.3.5" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== @@ -5729,19 +5695,17 @@ symbol-tree@^3.2.4: integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== table@^6.0.4: - version "6.3.1" - resolved "https://registry.yarnpkg.com/table/-/table-6.3.1.tgz#ff50199ca5de00bc695596d581f7550759889b35" - integrity sha512-kNpMVSN4fj9KY4G6tNDVIT59uaG8ZELGQ+cmFSqivmWkCXJLd00VfRmtyHa8X7AeM75PQ/6/TtEtWjTDs1jXJw== + version "6.6.0" + resolved "https://registry.yarnpkg.com/table/-/table-6.6.0.tgz#905654b79df98d9e9a973de1dd58682532c40e8e" + integrity sha512-iZMtp5tUvcnAdtHpZTWLPF0M7AgiQsURR2DwmxnJwSy8I3+cY+ozzVvYha3BOLG2TB+L0CqjIz+91htuj6yCXg== dependencies: ajv "^8.0.1" - is-boolean-object "^1.1.0" - is-number-object "^1.0.4" - is-string "^1.0.5" lodash.clonedeep "^4.5.0" lodash.flatten "^4.4.0" lodash.truncate "^4.4.2" slice-ansi "^4.0.0" string-width "^4.2.0" + strip-ansi "^6.0.0" tapable@^2.1.1, tapable@^2.2.0: version "2.2.0" @@ -5769,9 +5733,9 @@ terser-webpack-plugin@^5.1.1: terser "^5.5.1" terser@^5.5.1: - version "5.6.1" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.6.1.tgz#a48eeac5300c0a09b36854bf90d9c26fb201973c" - integrity sha512-yv9YLFQQ+3ZqgWCUk+pvNJwgUTdlIxUk1WTN+RnaFJe2L7ipG2csPT0ra2XRm7Cs8cxN7QXmK1rFzEwYEQkzXw== + version "5.7.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.7.0.tgz#a761eeec206bc87b605ab13029876ead938ae693" + integrity sha512-HP5/9hp2UaZt5fYkuhNBR8YyRcT8juw8+uFbAme53iN9hblvKnLUTKkmwJG6ocWpIKf8UK4DoeWG4ty0J6S6/g== dependencies: commander "^2.20.0" source-map "~0.7.2" @@ -5890,10 +5854,10 @@ ts-jest@^26.5.5: semver "7.x" yargs-parser "20.x" -ts-loader@^9.0.2: - version "9.0.2" - resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.0.2.tgz#8e73d836122ba99f9c28f207a22d280c2502bd7a" - integrity sha512-whFcWsvFRb91lzLLwU06jKS8ZwQsXA7Rk2NNLBjWNDFoaZgfSjrh8UJvc7sMknR9Vhs6NroQlw+0+2wW3fjR9Q== +ts-loader@^9.1.1: + version "9.1.1" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.1.1.tgz#83f598c37e648f3b6b2350bfac6f58f9253d078c" + integrity sha512-u91MdIE4rtN/06Q881uUzVeMoYy+CdFXoanCQXVGRubKKxgLjqQ/H9nkDbp6klkiPv3t18KLjZbEofkJodM3ow== dependencies: chalk "^4.1.0" enhanced-resolve "^5.0.0" @@ -6159,17 +6123,17 @@ webpack-sources@^2.1.1: source-list-map "^2.0.1" source-map "^0.6.1" -webpack@^5.34.0: - version "5.34.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.34.0.tgz#8f12bfd3474e7543232345b89294cfe8a5191c10" - integrity sha512-+WiFMgaZqhu7zKN64LQ7z0Ml4WWI+9RwG6zmS0wJDQXiCeg3hpN8fYFNJ+6WlosDT55yVxTfK7XHUAOVR4rLyA== +webpack@^5.36.1: + version "5.36.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.36.1.tgz#d82bad3384f84ed45a8de3844c31730f56361ab7" + integrity sha512-2u25a82T+6quAxSlzEpN/R/RICwt20ONU3z3Ko05S8KVH9FXILcBYb2hD/rQtZT5y7lRAIsIIs05pdndY7ourQ== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.47" "@webassemblyjs/ast" "1.11.0" "@webassemblyjs/wasm-edit" "1.11.0" "@webassemblyjs/wasm-parser" "1.11.0" - acorn "^8.0.4" + acorn "^8.2.1" browserslist "^4.14.5" chrome-trace-event "^1.0.2" enhanced-resolve "^5.8.0" From 6df4a345ea3b16f5b075b4980eae69be4a5a0ab8 Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Thu, 29 Apr 2021 12:26:39 -0400 Subject: [PATCH 04/12] Removing type changes for separate PR --- src/eosjs-serialize.ts | 4 ++-- src/tests/type-checks.test.ts | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/eosjs-serialize.ts b/src/eosjs-serialize.ts index 4a9cbe42c..64438b9ee 100644 --- a/src/eosjs-serialize.ts +++ b/src/eosjs-serialize.ts @@ -127,7 +127,7 @@ export interface Action { account: string; name: string; authorization: Authorization[]; - data?: any; + data: any; hex_data?: string; } @@ -136,7 +136,7 @@ export interface SerializedAction { account: string; name: string; authorization: Authorization[]; - data?: string; + data: string; } /** Serialize and deserialize data */ diff --git a/src/tests/type-checks.test.ts b/src/tests/type-checks.test.ts index fdd3997d6..e66e140d8 100644 --- a/src/tests/type-checks.test.ts +++ b/src/tests/type-checks.test.ts @@ -406,7 +406,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - 'data?': 'any', + data: 'any', 'hex_data?': 'string', }, 'context_free_data?': 'number', @@ -417,7 +417,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - 'data?': 'any', + data: 'any', 'hex_data?': 'string', }, 'transaction_extensions?': { @@ -574,7 +574,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - 'data?': 'any', + data: 'any', 'hex_data?': 'string', }, context_free: 'boolean', @@ -773,7 +773,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - 'data?': 'any', + data: 'any', 'hex_data?': 'string', }, 'context_free_data?': 'number', @@ -784,7 +784,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - 'data?': 'any', + data: 'any', 'hex_data?': 'string', }, 'transaction_extensions?': { @@ -942,7 +942,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - 'data?': 'any', + data: 'any', 'hex_data?': 'string', }, context_free: 'boolean', @@ -1058,7 +1058,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - 'data?': 'any', + data: 'any', 'hex_data?': 'string', }, context_free: 'boolean', @@ -1155,7 +1155,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - 'data?': 'any', + data: 'any', 'hex_data?': 'string', }, context_free: 'boolean', From 5b1bd491b69c207107b4bb21ba6862c4ef3a433b Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Fri, 4 Jun 2021 19:30:20 -0400 Subject: [PATCH 05/12] Adjusting to renamed endpoint and additional changes --- .github/eosjs-ci/Dockerfile | 7 +- .github/workflows/ci.yml | 2 +- src/eosjs-api-interfaces.ts | 2 + src/eosjs-api.ts | 43 +++---- src/eosjs-jsonrpc.ts | 31 +++--- src/eosjs-rpc-interfaces.ts | 22 ++-- src/tests/eosjs-jsonrpc.test.ts | 64 ++++++----- src/tests/node.js | 5 +- src/tests/type-checks.test.ts | 192 ++++++++++++++++---------------- src/tests/web.html | 5 +- 10 files changed, 183 insertions(+), 190 deletions(-) diff --git a/.github/eosjs-ci/Dockerfile b/.github/eosjs-ci/Dockerfile index b14952916..7fcddaafa 100644 --- a/.github/eosjs-ci/Dockerfile +++ b/.github/eosjs-ci/Dockerfile @@ -2,8 +2,8 @@ #### docker build --tag eosjs-ci:test ./.github/eosjs-ci #### docker run --publish 8888:8888 eosjs-ci:test -ARG EOSBRANCH=read_only_query_EPE-746 -ARG CDTBRANCH=qy-read-only-action +ARG EOSBRANCH=develop +ARG CDTBRANCH=develop FROM eosio/eosio.cdt:${CDTBRANCH} as contracts WORKDIR /root ### base @@ -16,7 +16,7 @@ RUN git clone https://github.com/EOSIO/eos \ RUN git clone https://github.com/EOSIO/eosio.cdt \ && cd eosio.cdt \ - && git checkout qy-read-only-action \ + && git checkout develop \ && mkdir build && cd build && mkdir read_only_query_tests && cd .. \ && eosio-cpp -abigen ./tests/unit/test_contracts/read_only_query_tests.cpp -o ./build/read_only_query_tests/read_only_query_tests.wasm @@ -40,7 +40,6 @@ RUN cd cfhello \ && mkdir build \ && eosio-cpp -abigen ./cfhello.cpp -o ./build/cfhello.wasm - FROM eosio/eosio:${EOSBRANCH} ENTRYPOINT ["nodeos", "--data-dir", "/root/.local/share", "-e", "-p", "eosio", "--replay-blockchain", "--plugin", "eosio::producer_plugin", "--plugin", "eosio::chain_api_plugin", "--plugin", "eosio::trace_api_plugin", "--trace-no-abis", "--plugin", "eosio::db_size_api_plugin", "--plugin", "eosio::http_plugin", "--http-server-address=0.0.0.0:8888", "--access-control-allow-origin=*", "--contracts-console", "--http-validate-host=false", "--enable-account-queries=true", "--verbose-http-errors", "--max-transaction-time=100"] WORKDIR /root diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e62e4358d..e3b30ebce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: git push origin ${GITHUB_REF#refs/*/} services: nodeos: - image: eosio/eosjs-ci:read_only_queries + image: eosio/eosjs-ci:develop ports: - 8888:8888 diff --git a/src/eosjs-api-interfaces.ts b/src/eosjs-api-interfaces.ts index 2203e3510..5518ff4c8 100644 --- a/src/eosjs-api-interfaces.ts +++ b/src/eosjs-api-interfaces.ts @@ -89,6 +89,8 @@ export interface Transaction { export interface TransactConfig { broadcast?: boolean; sign?: boolean; + readOnlyTrx?: boolean; + returnFailureTraces?: boolean; requiredKeys?: string[]; compression?: boolean; blocksBehind?: number; diff --git a/src/eosjs-api.ts b/src/eosjs-api.ts index b68f631a9..140f5815a 100644 --- a/src/eosjs-api.ts +++ b/src/eosjs-api.ts @@ -275,6 +275,8 @@ export class Api { * `broadcast`: broadcast this transaction? * `sign`: sign this transaction? * `compression`: compress this transaction? + * `readOnlyTrx`: read only transaction? + * `returnFailureTraces`: return failure traces? (only available for read only transactions currently) * * If both `blocksBehind` and `expireSeconds` are present, * then fetch the block which is `blocksBehind` behind head block, @@ -288,8 +290,18 @@ export class Api { */ public async transact( transaction: Transaction, - { broadcast = true, sign = true, requiredKeys, compression, blocksBehind, useLastIrreversible, expireSeconds }: - TransactConfig = {}): Promise + { + broadcast = true, + sign = true, + readOnlyTrx, + returnFailureTraces, + requiredKeys, + compression, + blocksBehind, + useLastIrreversible, + expireSeconds + }: + TransactConfig = {}): Promise { let info: GetInfoResult; @@ -338,6 +350,9 @@ export class Api { } if (broadcast) { let result; + if (readOnlyTrx) { + return this.rpc.push_ro_transaction(pushTransactionArgs, returnFailureTraces) as Promise; + } if (compression) { return this.pushCompressedSignedTransaction(pushTransactionArgs) as Promise; } @@ -346,30 +361,6 @@ export class Api { return pushTransactionArgs as PushTransactionArgs; } - /** - * Create and optionally broadcast a read-only query transaction. - * - * See `transact` for details of configuration options. - * - * @returns Contract query response if `broadcast`, `{signatures, serializedTransaction}` if `!broadcast` - */ - public async readOnlyQuery( - accountName: string, - transaction: Transaction, - { broadcast = true, sign = true, requiredKeys, blocksBehind, useLastIrreversible, expireSeconds }: - TransactConfig = {}): Promise - { - const pushTransactionArgs = await this.transact( - transaction, - { broadcast: false, sign, requiredKeys, compression: false, blocksBehind, useLastIrreversible, expireSeconds } - ) as PushTransactionArgs; - - if (broadcast) { - return this.rpc.get_contract_query(accountName, pushTransactionArgs) as Promise; - } - return pushTransactionArgs as PushTransactionArgs; - } - public async query( account: string, short: boolean, query: Query, { sign, requiredKeys, authorization = [] }: QueryConfig diff --git a/src/eosjs-jsonrpc.ts b/src/eosjs-jsonrpc.ts index 6c11b44dd..971f5a23b 100644 --- a/src/eosjs-jsonrpc.ts +++ b/src/eosjs-jsonrpc.ts @@ -17,7 +17,6 @@ import { GetBlockResult, GetCodeResult, GetCodeHashResult, - GetContractQueryResult, GetCurrencyStatsResult, GetInfoResult, GetProducerScheduleResult, @@ -28,6 +27,7 @@ import { GetTableRowsResult, PushTransactionArgs, PackedTrx, + ReadOnlyTransactResult, GetBlockHeaderStateResult, GetTableByScopeResult, DBSizeGetResult, @@ -94,6 +94,7 @@ export class JsonRpc implements AuthorityProvider, AbiProvider { if (!response.ok) { throw new RpcError(json); } + // check each return value for every action for an error and call `new RpcError`? return json; } @@ -167,20 +168,6 @@ export class JsonRpc implements AuthorityProvider, AbiProvider { return await this.fetch('/v1/chain/get_code_hash', { account_name: accountName }); } - /** Raw call to `/v1/chain/get_contract_query */ - public async get_contract_query(accountName: string, - { signatures, serializedTransaction }: PushTransactionArgs): Promise { - return await this.fetch('/v1/chain/get_contract_query', { - account_name: accountName, - transaction: { - signatures, - compression: 0, - packed_context_free_data: arrayToHex(new Uint8Array(0)), - packed_trx: arrayToHex(serializedTransaction), - } - }); - } - /** Raw call to `/v1/chain/get_currency_balance` */ public async get_currency_balance(code: string, account: string, symbol: string = null): Promise { return await this.fetch('/v1/chain/get_currency_balance', { code, account, symbol }); @@ -326,6 +313,20 @@ export class JsonRpc implements AuthorityProvider, AbiProvider { }); } + /** Raw call to `/v1/chain/push_ro_transaction */ + public async push_ro_transaction({ signatures, compression = 0, serializedTransaction }: PushTransactionArgs, + returnFailureTraces: boolean = false): Promise { + return await this.fetch('/v1/chain/push_ro_transaction', { + transaction: { + signatures, + compression, + packed_context_free_data: arrayToHex(new Uint8Array(0)), + packed_trx: arrayToHex(serializedTransaction), + }, + return_failure_traces: returnFailureTraces, + }); + } + public async push_transactions(transactions: PushTransactionArgs[]): Promise { const packedTrxs: PackedTrx[] = transactions.map(({signatures, compression = 0, serializedTransaction, serializedContextFreeData }: PushTransactionArgs) => { return { diff --git a/src/eosjs-rpc-interfaces.ts b/src/eosjs-rpc-interfaces.ts index 72926322f..dd14c0fc1 100644 --- a/src/eosjs-rpc-interfaces.ts +++ b/src/eosjs-rpc-interfaces.ts @@ -341,17 +341,6 @@ export interface GetCodeHashResult { code_hash: string; } -/** Return value of `/v1/chain/get_contract_query` */ -export interface GetContractQueryResult { - head_block_num: number; - head_block_id: string; - last_irreversible_block_num: number; - last_irreversible_block_id: string; - code_hash: string; - pending_transactions: string[]; - result: TransactionTrace; -} - /** Return value of `/v1/chain/get_currency_stats` */ export interface GetCurrencyStatsResult { [key: string]: { @@ -480,6 +469,17 @@ export interface PushTransactionArgs { serializedContextFreeData?: Uint8Array; } +/** Return value of `/v1/chain/push_ro_transaction` */ +export interface ReadOnlyTransactResult { + head_block_num: number; + head_block_id: string; + last_irreversible_block_num: number; + last_irreversible_block_id: string; + code_hash: string; + pending_transactions: string[]; + result: TransactionTrace; +} + export interface DBSizeIndexCount { index: string; row_count: number; diff --git a/src/tests/eosjs-jsonrpc.test.ts b/src/tests/eosjs-jsonrpc.test.ts index 70f82cade..e25d20a8d 100644 --- a/src/tests/eosjs-jsonrpc.test.ts +++ b/src/tests/eosjs-jsonrpc.test.ts @@ -198,39 +198,6 @@ describe('JSON RPC', () => { expect(fetch).toBeCalledWith(endpoint + expPath, expParams); }); - it('calls get_contract_query', async () => { - const expPath = '/v1/chain/get_contract_query'; - const accountName = 'myaccountaaa'; - const signatures = [ - 'George Washington', - 'John Hancock', - 'Abraham Lincoln', - ]; - const serializedTransaction = new Uint8Array([ - 0, 16, 32, 128, 255, - ]); - const expReturn = { data: '12345' }; - const expParams = { - body: JSON.stringify({ - account_name: accountName, - transaction: { - signatures, - compression: 0, - packed_context_free_data: '', - packed_trx: '00102080ff' - } - }), - method: 'POST', - }; - - fetchMock.once(JSON.stringify(expReturn)); - - const response = await jsonRpc.get_contract_query(accountName, { signatures, serializedTransaction }); - - expect(response).toEqual(expReturn); - expect(fetch).toBeCalledWith(endpoint + expPath, expParams); - }); - it('calls get_currency_balance with all params', async () => { const expPath = '/v1/chain/get_currency_balance'; const code = 'morse'; @@ -699,6 +666,37 @@ describe('JSON RPC', () => { expect(fetch).toBeCalledWith(endpoint + expPath, expParams); }); + it('calls push_ro_transaction', async () => { + const expPath = '/v1/chain/push_ro_transaction'; + const signatures = [ + 'George Washington', + 'John Hancock', + 'Abraham Lincoln', + ]; + const serializedTransaction = new Uint8Array([ + 0, 16, 32, 128, 255, + ]); + const expReturn = { data: '12345' }; + const expParams = { + body: JSON.stringify({ + transaction: { + signatures, + compression: 0, + packed_context_free_data: '', + packed_trx: '00102080ff' + } + }), + method: 'POST', + }; + + fetchMock.once(JSON.stringify(expReturn)); + + const response = await jsonRpc.push_ro_transaction({ signatures, serializedTransaction }); + + expect(response).toEqual(expReturn); + expect(fetch).toBeCalledWith(endpoint + expPath, expParams); + }); + it('calls send_transaction', async () => { const expPath = '/v1/chain/send_transaction'; const signatures = [ diff --git a/src/tests/node.js b/src/tests/node.js index f894cb468..f4421ae3b 100644 --- a/src/tests/node.js +++ b/src/tests/node.js @@ -178,7 +178,7 @@ const transactWithReturnValue = async () => { }; const readOnlyQuery = async () => { - return await api.readOnlyQuery('readonly', { + return await api.transact({ actions: [{ account: 'readonly', name: 'get', @@ -190,7 +190,8 @@ const readOnlyQuery = async () => { }], }, { blocksBehind: 3, - expireSeconds: 30 + expireSeconds: 30, + readOnlyTrx: true, }); }; diff --git a/src/tests/type-checks.test.ts b/src/tests/type-checks.test.ts index e66e140d8..98cffbfd6 100644 --- a/src/tests/type-checks.test.ts +++ b/src/tests/type-checks.test.ts @@ -26,10 +26,10 @@ import { GetTableRowsResult, GetTableByScopeResult, PushTransactionArgs, + ReadOnlyTransactResult, AbiBinToJsonResult, TraceApiGetBlockResult, DBSizeGetResult, - GetContractQueryResult, } from '../eosjs-rpc-interfaces'; import { TransactResult } from '../eosjs-api-interfaces'; import 'jest-extended'; @@ -515,101 +515,6 @@ describe('Chain API Plugin Endpoints', () => { verifyType(result, getCodeHashResult); }); - it('validates return type of get_contract_query', async () => { - const transaction: PushTransactionArgs = await api.transact({ - actions: [{ - account: 'readonly', - name: 'get', - authorization: [{ - actor: 'readonly', - permission: 'active', - }], - data: {}, - }], - }, { - sign: true, - broadcast: false, - useLastIrreversible: true, - expireSeconds: 30, - }) as PushTransactionArgs; - const result: GetContractQueryResult = await rpc.get_contract_query('readonly', transaction); - const getContractQueryResult: any = { - head_block_num: 'number', - head_block_id: 'string', - last_irreversible_block_num: 'number', - last_irreversible_block_id: 'string', - code_hash: 'string', - pending_transactions: 'string', - result: { - id: 'string', - block_num: 'number', - block_time: 'string', - 'producer_block_id&': 'string', - 'receipt&': { - status: 'string', - cpu_usage_us: 'number', - net_usage_words: 'number', - }, - elapsed: 'number', - net_usage: 'number', - scheduled: 'boolean', - action_traces: { - action_ordinal: 'number', - creator_action_ordinal: 'number', - closest_unnotified_ancestor_action_ordinal: 'number', - receipt: { - receiver: 'string', - act_digest: 'string', - global_sequence: 'number', - recv_sequence: 'number', - auth_sequence: [ 'string', 'number' ], - code_sequence: 'number', - abi_sequence: 'number', - }, - receiver: 'string', - act: { - account: 'string', - name: 'string', - authorization: { - actor: 'string', - permission: 'string', - }, - data: 'any', - 'hex_data?': 'string', - }, - context_free: 'boolean', - elapsed: 'number', - console: 'string', - trx_id: 'string', - block_num: 'number', - block_time: 'string', - 'producer_block_id&': 'string', - account_ram_deltas: { - account: 'string', - delta: 'number', - }, - account_disk_deltas: { - account: 'string', - delta: 'number', - }, - except: 'any', - 'error_code&': 'number', - 'return_value?': 'any', - 'return_value_hex_data?': 'string', - 'return_value_data?': 'any', - 'inline_traces?': 'any', // ActionTrace, recursive? - }, - 'account_ram_delta&': { - account: 'string', - delta: 'number', - }, - 'except&': 'string', - 'error_code&': 'number', - } - }; - verifyType(result, getContractQueryResult); - }); - it('validates return type of get_currency_balance', async () => { const result: string[] = await rpc.get_currency_balance('eosio.token', 'bob', 'SYS'); result.forEach((element: any) => { @@ -978,6 +883,101 @@ describe('Chain API Plugin Endpoints', () => { verifyType(result, transactResult); }); + it('validates return type of push_ro_transaction', async () => { + const transaction: PushTransactionArgs = await api.transact({ + actions: [{ + account: 'readonly', + name: 'get', + authorization: [{ + actor: 'readonly', + permission: 'active', + }], + data: {}, + }], + }, { + sign: true, + broadcast: false, + useLastIrreversible: true, + expireSeconds: 30, + }) as PushTransactionArgs; + const result: ReadOnlyTransactResult = await rpc.push_ro_transaction(transaction); + const readOnlyTransactResult: any = { + head_block_num: 'number', + head_block_id: 'string', + last_irreversible_block_num: 'number', + last_irreversible_block_id: 'string', + code_hash: 'string', + pending_transactions: 'string', + result: { + id: 'string', + block_num: 'number', + block_time: 'string', + 'producer_block_id&': 'string', + 'receipt&': { + status: 'string', + cpu_usage_us: 'number', + net_usage_words: 'number', + }, + elapsed: 'number', + net_usage: 'number', + scheduled: 'boolean', + action_traces: { + action_ordinal: 'number', + creator_action_ordinal: 'number', + closest_unnotified_ancestor_action_ordinal: 'number', + receipt: { + receiver: 'string', + act_digest: 'string', + global_sequence: 'number', + recv_sequence: 'number', + auth_sequence: [ 'string', 'number' ], + code_sequence: 'number', + abi_sequence: 'number', + }, + receiver: 'string', + act: { + account: 'string', + name: 'string', + authorization: { + actor: 'string', + permission: 'string', + }, + data: 'any', + 'hex_data?': 'string', + }, + context_free: 'boolean', + elapsed: 'number', + console: 'string', + trx_id: 'string', + block_num: 'number', + block_time: 'string', + 'producer_block_id&': 'string', + account_ram_deltas: { + account: 'string', + delta: 'number', + }, + account_disk_deltas: { + account: 'string', + delta: 'number', + }, + except: 'any', + 'error_code&': 'number', + 'return_value?': 'any', + 'return_value_hex_data?': 'string', + 'return_value_data?': 'any', + 'inline_traces?': 'any', // ActionTrace, recursive? + }, + 'account_ram_delta&': { + account: 'string', + delta: 'number', + }, + 'except&': 'string', + 'error_code&': 'number', + } + }; + verifyType(result, readOnlyTransactResult); + }); + it('validates return type of push_transactions', async () => { const transactionA: PushTransactionArgs = await api.transact({ actions: [{ diff --git a/src/tests/web.html b/src/tests/web.html index c118f2c80..42513ea38 100644 --- a/src/tests/web.html +++ b/src/tests/web.html @@ -476,7 +476,7 @@ } const readOnlyQuery = async () => { - return await api.readOnlyQuery('readonly', { + return await api.transact({ actions: [{ account: 'readonly', name: 'get', @@ -488,7 +488,8 @@ }], }, { blocksBehind: 3, - expireSeconds: 30 + expireSeconds: 30, + readOnlyTrx: true, }); } From 3d35686ed66ab19bc319d0ba2af6860f8aaf4ecb Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Mon, 7 Jun 2021 08:17:43 -0400 Subject: [PATCH 06/12] Adjusting the type and adding returnFailureTraces to tests --- src/eosjs-api.ts | 8 ++++---- src/tests/eosjs-jsonrpc.test.ts | 3 ++- src/tests/node.js | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/eosjs-api.ts b/src/eosjs-api.ts index 140f5815a..dcd490d6a 100644 --- a/src/eosjs-api.ts +++ b/src/eosjs-api.ts @@ -29,7 +29,7 @@ import { GetBlockHeaderStateResult, GetBlockInfoResult, GetBlockResult, - GetContractQueryResult, + ReadOnlyTransactResult, } from './eosjs-rpc-interfaces'; import * as ser from './eosjs-serialize'; @@ -301,7 +301,7 @@ export class Api { useLastIrreversible, expireSeconds }: - TransactConfig = {}): Promise + TransactConfig = {}): Promise { let info: GetInfoResult; @@ -351,7 +351,7 @@ export class Api { if (broadcast) { let result; if (readOnlyTrx) { - return this.rpc.push_ro_transaction(pushTransactionArgs, returnFailureTraces) as Promise; + return this.rpc.push_ro_transaction(pushTransactionArgs, returnFailureTraces) as Promise; } if (compression) { return this.pushCompressedSignedTransaction(pushTransactionArgs) as Promise; @@ -545,7 +545,7 @@ export class TransactionBuilder { return this; } - public async send(config?: TransactConfig): Promise { + public async send(config?: TransactConfig): Promise { const contextFreeDataSet: Uint8Array[] = []; const contextFreeActions: ser.SerializedAction[] = []; const actions: ser.SerializedAction[] = this.actions.map((actionBuilder) => actionBuilder.serializedData as ser.SerializedAction); diff --git a/src/tests/eosjs-jsonrpc.test.ts b/src/tests/eosjs-jsonrpc.test.ts index e25d20a8d..8528aa885 100644 --- a/src/tests/eosjs-jsonrpc.test.ts +++ b/src/tests/eosjs-jsonrpc.test.ts @@ -684,7 +684,8 @@ describe('JSON RPC', () => { compression: 0, packed_context_free_data: '', packed_trx: '00102080ff' - } + }, + return_failure_traces: false }), method: 'POST', }; diff --git a/src/tests/node.js b/src/tests/node.js index f4421ae3b..1e6c847e1 100644 --- a/src/tests/node.js +++ b/src/tests/node.js @@ -192,6 +192,7 @@ const readOnlyQuery = async () => { blocksBehind: 3, expireSeconds: 30, readOnlyTrx: true, + returnFailureTraces: true, }); }; From 093c43760df83312ea60706d19fdf75ce0eee5a7 Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Wed, 16 Jun 2021 08:53:53 -0400 Subject: [PATCH 07/12] Adding support for failure traces --- .../01_how-to-submit-a-transaction.md | 5 ++ docs/troubleshooting/02_rpcerror.md | 72 +++++++++++++++++++ src/eosjs-jsonrpc.ts | 2 + src/eosjs-rpcerror.ts | 6 ++ src/tests/node.js | 25 +++++++ src/tests/node.test.ts | 11 +++ 6 files changed, 121 insertions(+) create mode 100644 docs/troubleshooting/02_rpcerror.md diff --git a/docs/how-to-guides/01_how-to-submit-a-transaction.md b/docs/how-to-guides/01_how-to-submit-a-transaction.md index 84d143b93..5b70369d1 100644 --- a/docs/how-to-guides/01_how-to-submit-a-transaction.md +++ b/docs/how-to-guides/01_how-to-submit-a-transaction.md @@ -133,3 +133,8 @@ By providing that function inside `tx.associateContextFree()`, the transaction o #### Return Values From nodeos version 2.1, the ability to receive return values from smart contracts to eosjs has been introduced. In the above examples, the `transaction` object will include the values `transaction_id` and the `processed` object. If your smart contract returns values, you will be able to find the values within the `transaction.processed.action_traces` array. The order of the `action_traces` array matches the order of actions in your transaction and within those `action_trace` objects, you can find your deserialized return value for your action in the `return_value` field. + +### Read-Only Transactions +Adding `readOnlyTrx` to the `transact` config will send the transaction through the `push_ro_transaction` endpoint in the `chain_api`. This endpoint will ensure that the transaction will not make any changes despite the actions in the transaction. It is typically useful for doing queries using actions but normal actions will also work with this endpoint, but they won't make changes. + +Adding `returnFailureTraces` to the `transact` config will return a trace of the failure if your transaction fails. At this time, this is only available for read-only transactions. diff --git a/docs/troubleshooting/02_rpcerror.md b/docs/troubleshooting/02_rpcerror.md new file mode 100644 index 000000000..8f26033f3 --- /dev/null +++ b/docs/troubleshooting/02_rpcerror.md @@ -0,0 +1,72 @@ +When a call to the chain_api is performed and fails, it will result in an RPCError object being generated to inform why the transaction failed. + +The RPCError object will error with the concise message, for instance 'Invalid transaction', but additional details can be found in both the `details` field and the `json` field. The `json` field holds the entire json response from `nodeos` while the `details` field specifically holds the error object in the `json`. This is typically in different places of the `json` depending on what endpoint is used in `nodeos` so the `details` field is available to quickly see the error information without needing to search through the `json` object. + +As you can see below, the concise error message might not give enough information to really discern the issue. While the error has `eosio_assert_message assertion failure` as the concise error, in the `details` field the `overdrawn balance` error mentioned. It's important to note that the format of the `details` object can be different depending on what endpoint is used. +```javascript +RpcError: eosio_assert_message assertion failure + at new RpcError (eosjs-rpcerror.ts:20:13) + at JsonRpc. (eosjs-jsonrpc.ts:90:23) + at step (eosjs-jsonrpc.js:37:23) + at Object.next (eosjs-jsonrpc.js:18:53) + at fulfilled (eosjs-jsonrpc.js:9:58) + at processTicksAndRejections (node:internal/process/task_queues:94:5) { + details: { + code: 3050003, + name: 'eosio_assert_message_exception', + message: 'eosio_assert_message assertion failure', + stack: [ + { + context: { + level: 'error', + file: 'cf_system.cpp', + line: 14, + method: 'eosio_assert', + hostname: '', + thread_name: 'nodeos', + timestamp: '2021-06-16T05:26:03.665' + }, + format: 'assertion failure with message: ${s}', + data: { s: 'overdrawn balance' } + }, + { + context: { + level: 'warn', + file: 'apply_context.cpp', + line: 143, + method: 'exec_one', + hostname: '', + thread_name: 'nodeos', + timestamp: '2021-06-16T05:26:03.665' + }, + format: 'pending console output: ${console}', + data: { console: '' } + } + ] + }, + json: { + head_block_num: 1079, + head_block_id: '00003384ff2dd671472e8290e7ee0fbc00ee1f450ce5c10de0a9c245ab5b5b22', + last_irreversible_block_num: 1070, + last_irreversible_block_id: '00003383946519b67bac1a0f31898826b472d81fd40b7fccb49a2f486bd292d1', + code_hash: '800bb7fedd86155047064bffdaa3c32cca76cda40eb80f5c4a7676c7f57da579', + pending_transactions: [], + result: { + id: '01a0cbb6c0215df53f07ecdcf0fb750a4134938b38a72946a0f6f25cf3f43bcb', + block_num: 1079, + block_time: '2021-06-14T21:13:04.500', + producer_block_id: null, + receipt: null, + elapsed: 189, + net_usage: 137, + scheduled: false, + action_traces: [Array], + account_ram_delta: null, + except: [Object], + error_code: '10000000000000000000', + bill_to_accounts: [] + } + }, + isFetchError: true +} +``` diff --git a/src/eosjs-jsonrpc.ts b/src/eosjs-jsonrpc.ts index 971f5a23b..c5e23e00c 100644 --- a/src/eosjs-jsonrpc.ts +++ b/src/eosjs-jsonrpc.ts @@ -86,6 +86,8 @@ export class JsonRpc implements AuthorityProvider, AbiProvider { json = await response.json(); if (json.processed && json.processed.except) { throw new RpcError(json); + } else if (json.result && json.result.except) { + throw new RpcError(json); } } catch (e) { e.isFetchError = true; diff --git a/src/eosjs-rpcerror.ts b/src/eosjs-rpcerror.ts index 4924da02b..38cfd389a 100644 --- a/src/eosjs-rpcerror.ts +++ b/src/eosjs-rpcerror.ts @@ -7,12 +7,18 @@ export class RpcError extends Error { /** Detailed error information */ public json: any; + public details: any; constructor(json: any) { if (json.error && json.error.details && json.error.details.length && json.error.details[0].message) { super(json.error.details[0].message); + this.details = json.error.details; } else if (json.processed && json.processed.except && json.processed.except.message) { super(json.processed.except.message); + this.details = json.processed.except; + } else if (json.result && json.result.except && json.result.except.message) { + super(json.result.except.message); + this.details = json.result.except; } else { super(json.message); } diff --git a/src/tests/node.js b/src/tests/node.js index 1e6c847e1..c143975d5 100644 --- a/src/tests/node.js +++ b/src/tests/node.js @@ -196,6 +196,30 @@ const readOnlyQuery = async () => { }); }; +const readOnlyFailureTrace = async () => { + return await api.transact({ + actions: [{ + account: 'eosio.token', + name: 'transfer', + authorization: [{ + actor: 'alice', + permission: 'active', + }], + data: { + from: 'alice', + to: 'bob', + quantity: '2000000.0000 SYS', + memo: 'failureTrace', + }, + }] + }, { + blocksBehind: 3, + expireSeconds: 30, + readOnlyTrx: true, + returnFailureTraces: true, + }); +}; + const broadcastResult = async (signaturesAndPackedTransaction) => await api.pushSignedTransaction(signaturesAndPackedTransaction); const transactShouldFail = async () => await api.transact({ @@ -230,5 +254,6 @@ module.exports = { transactWithShorthandTxJsonContextFreeData, transactWithReturnValue, readOnlyQuery, + readOnlyFailureTrace, rpcShouldFail }; diff --git a/src/tests/node.test.ts b/src/tests/node.test.ts index ba4799379..266fef88e 100644 --- a/src/tests/node.test.ts +++ b/src/tests/node.test.ts @@ -116,6 +116,17 @@ describe('Node JS environment', () => { expect(transactionResponse.result.action_traces[0].return_value_data).toEqual(expectedValue); }); + it('returns failure trace for failed transaction', async () => { + let err; + try { + await tests.readOnlyFailureTrace(); + } catch (e) { + err = e.details; + } + expect(err.code).toEqual(3050003); + expect(err.stack[0].data.s).toEqual('overdrawn balance'); + }); + it('throws appropriate error message without configuration object or TAPOS in place', async () => { try { failedAsPlanned = true; From ac605caa518388d0e1306e75f544bec9df68ca15 Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Wed, 23 Jun 2021 14:42:46 -0400 Subject: [PATCH 08/12] Removing comment --- src/eosjs-jsonrpc.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/eosjs-jsonrpc.ts b/src/eosjs-jsonrpc.ts index c5e23e00c..67ff80cfb 100644 --- a/src/eosjs-jsonrpc.ts +++ b/src/eosjs-jsonrpc.ts @@ -96,7 +96,6 @@ export class JsonRpc implements AuthorityProvider, AbiProvider { if (!response.ok) { throw new RpcError(json); } - // check each return value for every action for an error and call `new RpcError`? return json; } From dd851d9e31b0bc34ed2f2ba8981ab287a49eaf88 Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Thu, 1 Jul 2021 07:22:04 -0400 Subject: [PATCH 09/12] Making requested changes --- docs/how-to-guides/01_how-to-submit-a-transaction.md | 4 ++-- docs/troubleshooting/02_rpcerror.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/how-to-guides/01_how-to-submit-a-transaction.md b/docs/how-to-guides/01_how-to-submit-a-transaction.md index 5b70369d1..6b29858ca 100644 --- a/docs/how-to-guides/01_how-to-submit-a-transaction.md +++ b/docs/how-to-guides/01_how-to-submit-a-transaction.md @@ -135,6 +135,6 @@ By providing that function inside `tx.associateContextFree()`, the transaction o From nodeos version 2.1, the ability to receive return values from smart contracts to eosjs has been introduced. In the above examples, the `transaction` object will include the values `transaction_id` and the `processed` object. If your smart contract returns values, you will be able to find the values within the `transaction.processed.action_traces` array. The order of the `action_traces` array matches the order of actions in your transaction and within those `action_trace` objects, you can find your deserialized return value for your action in the `return_value` field. ### Read-Only Transactions -Adding `readOnlyTrx` to the `transact` config will send the transaction through the `push_ro_transaction` endpoint in the `chain_api`. This endpoint will ensure that the transaction will not make any changes despite the actions in the transaction. It is typically useful for doing queries using actions but normal actions will also work with this endpoint, but they won't make changes. +From nodeos version 2.2, read-only queries have been introduced to eosjs. Adding `readOnlyTrx` to the `transact` config will send the transaction through the `push_ro_transaction` endpoint in the `chain_api`. The `push_ro_transaction` endpoint does not allow the transaction to make any data changes despite the actions in the transaction. The `push_ro_transaction` endpoint may also be used to call normal actions, but any data changes that action will make will be rolled back. -Adding `returnFailureTraces` to the `transact` config will return a trace of the failure if your transaction fails. At this time, this is only available for read-only transactions. +Adding returnFailureTraces to the transact config enables the return of a trace message if your transaction fails. At this time, this is only available for the `push_ro_transaction` endpoint. diff --git a/docs/troubleshooting/02_rpcerror.md b/docs/troubleshooting/02_rpcerror.md index 8f26033f3..c93709176 100644 --- a/docs/troubleshooting/02_rpcerror.md +++ b/docs/troubleshooting/02_rpcerror.md @@ -1,8 +1,8 @@ -When a call to the chain_api is performed and fails, it will result in an RPCError object being generated to inform why the transaction failed. +When a call to the chain_api is performed and fails, it will result in an RPCError object being generated which contains information on why the transaction failed. -The RPCError object will error with the concise message, for instance 'Invalid transaction', but additional details can be found in both the `details` field and the `json` field. The `json` field holds the entire json response from `nodeos` while the `details` field specifically holds the error object in the `json`. This is typically in different places of the `json` depending on what endpoint is used in `nodeos` so the `details` field is available to quickly see the error information without needing to search through the `json` object. +The RPCError object will contain a concise error message, for instance 'Invalid transaction'. However additional details can be found in the `details` field and the `json` field. The `json` field holds the complete json response from nodeos. The `details` field specifically holds the error object in the `json` field. The data content of the `json` and `details` vary depending on the endpoint is used to call nodeos. Use the `details` field to quickly find error information. -As you can see below, the concise error message might not give enough information to really discern the issue. While the error has `eosio_assert_message assertion failure` as the concise error, in the `details` field the `overdrawn balance` error mentioned. It's important to note that the format of the `details` object can be different depending on what endpoint is used. +In the `details` and `json` examples below, you can see that the error message may not contain enough information to discern what caused the action to fail. The error message contains `eosio_assert_message` assertion failure. Looking further at the details you can see an `overdrawn balance` message. ```javascript RpcError: eosio_assert_message assertion failure at new RpcError (eosjs-rpcerror.ts:20:13) From 91fd1f7a4e9b0560cc4e3e614164e9bf2205ef9e Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Thu, 1 Jul 2021 12:42:26 -0400 Subject: [PATCH 10/12] Adjusting data to be empty in the push_ro_transaction test data is optional already in the type --- src/tests/type-checks.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/type-checks.test.ts b/src/tests/type-checks.test.ts index ab7b30e0d..656930570 100644 --- a/src/tests/type-checks.test.ts +++ b/src/tests/type-checks.test.ts @@ -949,7 +949,7 @@ describe('Chain API Plugin Endpoints', () => { actor: 'string', permission: 'string', }, - data: 'any', + 'data?': 'any', 'hex_data?': 'string', }, context_free: 'boolean', From 11e3efe6b8fb2e19b28ec68c7bc30de265d6a908 Mon Sep 17 00:00:00 2001 From: Bradley Hart Date: Thu, 1 Jul 2021 13:07:11 -0400 Subject: [PATCH 11/12] Adding `bill_to_accounts` to push_ro_transaction endpoint --- src/tests/type-checks.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/type-checks.test.ts b/src/tests/type-checks.test.ts index 656930570..b7ac8db56 100644 --- a/src/tests/type-checks.test.ts +++ b/src/tests/type-checks.test.ts @@ -980,6 +980,7 @@ describe('Chain API Plugin Endpoints', () => { }, 'except&': 'string', 'error_code&': 'number', + bill_to_accounts: 'string', } }; verifyType(result, readOnlyTransactResult); From c4985926bd9848ab5019cb8fae8e0bac2dbf1034 Mon Sep 17 00:00:00 2001 From: "Block.one DevOps" Date: Thu, 1 Jul 2021 17:38:52 +0000 Subject: [PATCH 12/12] Updating package.json and yarn.lock --- package.json | 2 +- yarn.lock | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 4b9e238f8..ec17ff982 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "rimraf": "^3.0.2", "ts-jest": "^26.5.6", "ts-loader": "^9.2.3", - "typescript": "^4.3.4", + "typescript": "^4.3.5", "webpack": "^5.41.1", "webpack-cli": "^4.7.2" }, diff --git a/yarn.lock b/yarn.lock index 4376c0b39..4487cf499 100644 --- a/yarn.lock +++ b/yarn.lock @@ -822,9 +822,9 @@ integrity sha512-GdZbRSJ3Cv5fiwT6I0SQ3ckeN2PWNqxd26W9Z2fCK1tGrrasGy4puvNFtnddqH9UJFMQYXxEuuB7B8UK+LLwSg== "@types/prettier@^2.0.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.3.0.tgz#2e8332cc7363f887d32ec5496b207d26ba8052bb" - integrity sha512-hkc1DATxFLQo4VxPDpMH1gCkPpBbpOoJ/4nhuXw4n63/0R6bCpQECj4+K226UJ4JO/eJQz+1mC2I7JsWanAdQw== + version "2.3.1" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.3.1.tgz#54dd88bdc7f49958329666af3779561e47d5dab3" + integrity sha512-NVkb4p4YjI8E3O6+1m8I+8JlMpFZwfSbPGdaw0wXuyPRTEz0SLKwBUWNSO7Maoi8tQMPC8JLZNWkrcKPI7/sLA== "@types/sinonjs__fake-timers@^6.0.2": version "6.0.2" @@ -2287,9 +2287,9 @@ ecurve@1.0.5: bigi "^1.1.0" electron-to-chromium@^1.3.723: - version "1.3.762" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.762.tgz#3fa4e3bcbda539b50e3aa23041627063a5cffe61" - integrity sha512-LehWjRpfPcK8F1Lf/NZoAwWLWnjJVo0SZeQ9j/tvnBWYcT99qDqgo4raAfS2oTKZjPrR/jxruh85DGgDUmywEA== + version "1.3.763" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.763.tgz#93f6f02506d099941f557b9db9ba50b30215bf15" + integrity sha512-UyvEPae0wvzsyNJhVfGeFSOlUkHEze8xSIiExO5tZQ8QTr7obFiJWGk3U4e7afFOJMQJDszqU/3Pk5jtKiaSEg== elliptic@6.5.4, elliptic@^6.5.3: version "6.5.4" @@ -5720,10 +5720,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@^4.3.4: - version "4.3.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.4.tgz#3f85b986945bcf31071decdd96cf8bfa65f9dcbc" - integrity sha512-uauPG7XZn9F/mo+7MrsRjyvbxFpzemRjKEZXS4AK83oP2KKOJPvb+9cO/gmnv8arWZvhnjVOXz7B49m1l0e9Ew== +typescript@^4.3.5: + version "4.3.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4" + integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA== union-value@^1.0.0: version "1.0.1"