Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #992 from EOSIO/release/22.1.x
Browse files Browse the repository at this point in the history
Merging release/22.1.x into master
  • Loading branch information
Brad Hart committed Jul 12, 2021
2 parents ea34fb9 + 9ccdb11 commit 1fa93d4
Show file tree
Hide file tree
Showing 23 changed files with 1,879 additions and 1,272 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
token: ${{ github.token }}
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
run: |
yarn build-web
- name: Test Web
uses: cypress-io/github-action@1db146275576798796bc39ef83d739924145298a
uses: cypress-io/github-action@6122aa43014e18ec9c2d06fc0bdc5b6759064508
with:
spec: cypress/integration/index.spec.js
- name: Get Protected Status
Expand All @@ -76,7 +76,7 @@ jobs:
git push origin ${GITHUB_REF#refs/*/}
services:
nodeos:
image: eosio/eosjs-ci:release_22.0.x
image: eosio/eosjs-ci:release_2.2.x

ports:
- 8888:8888
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Checkout
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
Expand All @@ -38,7 +38,7 @@ jobs:
run: |
yarn build-web
- name: Test Web
uses: cypress-io/github-action@1db146275576798796bc39ef83d739924145298a
uses: cypress-io/github-action@6122aa43014e18ec9c2d06fc0bdc5b6759064508
with:
spec: cypress/integration/index.spec.js
- name: Publish Edge
Expand All @@ -54,7 +54,7 @@ jobs:

services:
nodeos:
image: eosio/eosjs-ci:develop
image: eosio/eosjs-ci:release_2.2.x

ports:
- 8888:8888
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Checkout
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
Expand All @@ -38,7 +38,7 @@ jobs:
run: |
yarn build-web
- name: Test Web
uses: cypress-io/github-action@1db146275576798796bc39ef83d739924145298a
uses: cypress-io/github-action@6122aa43014e18ec9c2d06fc0bdc5b6759064508
with:
spec: cypress/integration/index.spec.js
- name: Publish Release
Expand All @@ -53,7 +53,7 @@ jobs:

services:
nodeos:
image: eosio/eosjs-ci:release_22.0.x
image: eosio/eosjs-ci:release_2.2.x

ports:
- 8888:8888
Expand All @@ -71,7 +71,7 @@ jobs:
- name: Checkout
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
uses: actions/setup-node@38d90ce44d5275ad62cc48384b3d8a58c500bb5f
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
Expand All @@ -94,7 +94,7 @@ jobs:
run: |
yarn build-web
- name: Test Web
uses: cypress-io/github-action@1db146275576798796bc39ef83d739924145298a
uses: cypress-io/github-action@6122aa43014e18ec9c2d06fc0bdc5b6759064508
with:
spec: cypress/integration/index.spec.js
- name: Publish RC
Expand All @@ -109,7 +109,7 @@ jobs:

services:
nodeos:
image: eosio/eosjs-ci:release_22.0.x
image: eosio/eosjs-ci:release_2.2.x

ports:
- 8888:8888
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.idea
.vscode
dist/
dist-web/
node_modules/
Expand Down
156 changes: 144 additions & 12 deletions cypress/integration/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,145 @@
import { skipOn } from '@cypress/skip-test';

describe('eosjs web test', () => {
it('loads', () => {
cy.visit(('./src/tests/web.html'));
});
it('runs all tests successfully', () => {
cy.visit(('./src/tests/web.html'))
cy.get('div.tests>div>button').each((test) => { // iterate through all the tests
cy.wrap(test).click(); // click the button to start the test
cy.wrap(test).contains('Success', { timeout: 5000 }); // wait 5 seconds for success or treat as failure
cy.wait(500); // allow time for transaction to confirm (prevents duplicate transactions)
});
});
})
it('loads', () => {
cy.visit(('./src/tests/web.html'));
});

it('test Transact With Config Blocks Behind', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithConfigBlocksBehind').click();
cy.get('#testTransactWithConfigBlocksBehind').contains('Success', { timeout: 5000 });
});

it('test Transact With Config Use Last Irreversible', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithConfigUseLastIrreversible').click();
cy.get('#testTransactWithConfigUseLastIrreversible').contains('Success', { timeout: 5000 });
});

it('test Transact Without Config', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithoutConfig').click();
cy.get('#testTransactWithoutConfig').contains('Success', { timeout: 5000 });
});

it('test Transact With Compression', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithCompression').click();
cy.get('#testTransactWithCompression').contains('Success', { timeout: 5000 });
});

it('test Transact With Context Free Action', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithContextFreeAction').click();
cy.get('#testTransactWithContextFreeAction').contains('Success', { timeout: 5000 });
});

it('test Transact With Context Free Data', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithContextFreeData').click();
cy.get('#testTransactWithContextFreeData').contains('Success', { timeout: 5000 });
});

it('test Transact Without Broadcast', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithoutBroadcast').click();
cy.get('#testTransactWithoutBroadcast').contains('Success', { timeout: 5000 });
});

it('test Broadcast Result', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testBroadcastResult').click();
cy.get('#testBroadcastResult').contains('Success', { timeout: 5000 });
});

it('test Shorthand With Api Json', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testShorthandWithApiJson').click();
cy.get('#testShorthandWithApiJson').contains('Success', { timeout: 5000 });
});

it('test Shorthand With Tx Json', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testShorthandWithTxJson').click();
cy.get('#testShorthandWithTxJson').contains('Success', { timeout: 5000 });
});

it('test Shorthand With Tx Json Context Free Action', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testShorthandWithTxJsonContextFreeAction').click();
cy.get('#testShorthandWithTxJsonContextFreeAction').contains('Success', { timeout: 5000 });
});

it('test Shorthand With Tx Json Context Free Data', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testShorthandWithTxJsonContextFreeData').click();
cy.get('#testShorthandWithTxJsonContextFreeData').contains('Success', { timeout: 5000 });
});

it('test With P256 Elliptic Curve', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithP256EllipticCurve').click();
cy.get('#testWithP256EllipticCurve').contains('Success', { timeout: 5000 });
});

it('test With Return Value Tx', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithReturnValueTx').click();
cy.get('#testWithReturnValueTx').contains('Success', { timeout: 5000 });
});

it('test With Resource Payer Tx', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x' || Cypress.env('NODEOS_VER') === 'release/2.1.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithResourcePayerTx').click();
cy.get('#testWithResourcePayerTx').contains('Success', { timeout: 5000 });
});

it('test With Read Only Query', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x' || Cypress.env('NODEOS_VER') === 'release/2.1.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithReadOnlyQuery').click();
cy.get('#testWithReadOnlyQuery').contains('Success', { timeout: 5000 });
});

it('test With Read Only Failure Trace', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x' || Cypress.env('NODEOS_VER') === 'release/2.1.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithReadOnlyFailureTrace').click();
cy.get('#testWithReadOnlyFailureTrace').contains('Success', { timeout: 5000 });
});

it('test Transact Should Fail', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactShouldFail').click();
cy.get('#testTransactShouldFail').contains('Success', { timeout: 5000 });
});

it('test Rpc Should Fail', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testRpcShouldFail').click();
cy.get('#testRpcShouldFail').contains('Success', { timeout: 5000 });
});
});
5 changes: 5 additions & 0 deletions docs/how-to-guides/01_how-to-submit-a-transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 enables the return of a trace message if your transaction fails. At this time, this is only available for the `push_ro_transaction` endpoint.
31 changes: 31 additions & 0 deletions docs/how-to-guides/20_how-to-set-a-payer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
After the release of v2.2 of nodeos, the resource payer feature is available to sponsor the resources for a transaction. To set a separate payer for the resources for a transaction, add a `resource_payer` object to your transaction that specifies the `payer`, `max_net_bytes`, `max_cpu_us`, and `max_memory_bytes`. This functionality requires the `RESOURCE_PAYER` protocol feature to be enabled on the chain.

A typical use-case for this feature has a service or application pay for the resources of a transaction instead of their users. Since authorization is required for both the user in the transaction and the payer, a possible workflow would have the transaction signed by the user's wallet application and then also signed by the service/application before sent to nodeos.

```javascript
{
resource_payer: {
payer: 'alice',
max_net_bytes: 4096,
max_cpu_us: 400,
max_memory_bytes: 0
},
actions: [{
account: 'eosio.token',
name: 'transfer',
authorization: [{
actor: 'bob',
permission: 'active',
}, {
actor: 'alice',
permission: 'active',
}],
data: {
from: 'bob',
to: 'alice',
quantity: '0.0001 SYS',
memo: 'resource payer',
},
}]
}
```
72 changes: 72 additions & 0 deletions docs/troubleshooting/02_rpcerror.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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 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.

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)
at JsonRpc.<anonymous> (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
}
```

0 comments on commit 1fa93d4

Please sign in to comment.