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:
co-authored by
Amaury Martiny
parent
be0139dfce
commit
2eee6cfea7
+6
-10
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user