Swap to Mortal transactions by default (#1081)

* Start of mortal tx

* Swap to Mortal transcations by default

* Update SubmittableExtrinsic.ts

* WIP (pre master merge)

* Remove eraLength, allow era to specify

* Oops, linting.... it happens in the best of families

* WIP debugging immortals

* Re-surrect with working meta, and e2e tests

* Update docs/examples/promise/07_make_transfer_with_allowed_block_permissions_only/index.js

Co-Authored-By: Amaury Martiny <amaury.martiny@protonmail.com>

* Update docs/examples/promise/07_make_transfer_with_allowed_block_permissions_only/index.js

Co-Authored-By: Amaury Martiny <amaury.martiny@protonmail.com>

* Remove useless birth/death calls
This commit is contained in:
Jaco Greeff
2019-07-09 15:56:10 +02:00
committed by GitHub
co-authored by Amaury Martiny
parent be0139dfce
commit 2eee6cfea7
9 changed files with 170 additions and 119 deletions
@@ -22,22 +22,18 @@ async function main () {
// get current block
const signedBlock = await api.rpc.chain.getBlock();
// get current block height
// get current block height and hash
const currentHeight = signedBlock.block.header.number;
const blockHash = signedBlock.block.header.hash;
const exERA = new ExtrinsicEra({ current: currentHeight, period: 10 });
// get the beggining of the current era
const eraBirth = exERA.asMortalEra.birth(currentHeight.toNumber());
// get the hash of the beginning of the current era
const eraHash = await api.rpc.chain.getBlockHash(eraBirth);
// construct a mortal era
const era = new ExtrinsicEra({ current: currentHeight, period: 10 });
// Create an extrinsic, transferring 12345 units to Bob
const transfer = api.tx.balances.transfer(BOB, 12345);
// Sign and send the transaction using our account with a nonce and the length of blocks the transaction is valid for
const hash = await transfer.signAndSend(alice, { blockHash: eraHash, era: exERA, nonce });
// Sign and send the transaction using our account with a nonce and the length of blocks the transaction is valid for
const hash = await transfer.signAndSend(alice, { blockHash, era, nonce });
console.log('Transfer sent with hash', hash.toHex());
}