From 4fa8ee085ccd75c9e2e733d65aa1b8a628e99e60 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 29 Jan 2019 19:47:25 +0100 Subject: [PATCH] Remove the nonce when using signAndSend (promise examples) (#648) * Remove the nonce when using signAndSend * Update descriptions --- docs/examples/promise/06_make_transfer/index.js | 10 +++------- docs/examples/promise/10_upgrade_chain/index.js | 5 +---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/docs/examples/promise/06_make_transfer/index.js b/docs/examples/promise/06_make_transfer/index.js index 16e4005846..4a5d8dc1c0 100755 --- a/docs/examples/promise/06_make_transfer/index.js +++ b/docs/examples/promise/06_make_transfer/index.js @@ -16,16 +16,12 @@ async function main () { // Instantiate the API const api = await ApiPromise.create(); - // Retrieve the nonce for Alice, to be used to sign the transaction - const aliceNonce = await api.query.system.accountNonce(alice.address()); - - // Create a extrinsic, transferring 12345 units to Bob. We can also create, - // sign and send in one operation (as per the samples in the Api documentation), - // here we split it out for the sake of readability + // Create a extrinsic, transferring 12345 units to Bob const transfer = api.tx.balances.transfer(BOB_ADDR, 12345); - // Sign and send the transaction using our account. Send the transaction and retrieve the resulting Hash + // Sign and send the transaction using our account transfer.signAndSend(alice, ({ status, type }) => { + // retrieve the hash once we are finalised if (type === 'Finalised') { console.log(`Successful transfer of 12345 from Alice to Bob with hash ${status.asFinalised.toHex()}`); } else { diff --git a/docs/examples/promise/10_upgrade_chain/index.js b/docs/examples/promise/10_upgrade_chain/index.js index 1af6e27251..cce8a81b80 100755 --- a/docs/examples/promise/10_upgrade_chain/index.js +++ b/docs/examples/promise/10_upgrade_chain/index.js @@ -17,9 +17,6 @@ async function main () { // retrieve the upgrade key from the chain state const adminId = await api.query.sudo.key(); - // get the nonce for the admin key - const adminNonce = await api.query.system.accountNonce(adminId); - // find the actual keypair in the keyring (if this is an changed value, the key // needs to be added to the keyring before - this assumes we have defaults, i.e. // Alice as the key - and this already exists on the test keyring) @@ -30,7 +27,7 @@ async function main () { const code = fs.readFileSync('./test.wasm').toString('hex'); const proposal = api.tx.consensus.setCode(`0x${code}`); - console.log(`Upgrading from ${adminId} with nonce ${adminNonce}, ${code.length / 2} bytes`); + console.log(`Upgrading from ${adminId}, ${code.length / 2} bytes`); // preform the actual chain upgrade via the sudo module api.tx.sudo