Fix at example (#4680)

This commit is contained in:
Jaco Greeff 2021-02-17 09:57:07 +01:00 committed by GitHub
parent 3e3270bf1a
commit bd572447ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,19 +112,19 @@ export const storageRetrieveInfoOnQueryKeys: Snippet = {
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
// retrieve the balance, once-off at the latest block
const [nonce, { free }] = await api.query.system.account(ALICE);
const { data: { free } } = await api.query.system.account(ALICE);
console.log('Alice has a current balance of', free.toHuman());
// retrieve balance updates with an optional value callback
const balanceUnsub = await api.query.system.account(ALICE, ([, { free }]) => {
const balanceUnsub = await api.query.system.account(ALICE, ({ data: { free } }) => {
console.log('Alice has an updated balance of', free.toHuman());
});
// retrieve the balance at a block hash in the past
const header = await api.rpc.chain.getHeader();
const prevHash = await api.rpc.chain.getBlockHash(header.blockNumber.subn(42));
const [, { free: prev }] = await api.query.system.account.at(prevHash, ALICE);
const prevHash = await api.rpc.chain.getBlockHash(header.number.unwrap().subn(42));
const { data: { free: prev } } = await api.query.system.account.at(prevHash, ALICE);
console.log('Alice had a balance of', prev.toHuman(), '(42 blocks ago)');
@ -134,7 +134,7 @@ const currSize = await api.query.system.account.size(ALICE);
console.log('Alice account entry has a value hash of', currHash, 'with a size of', currSize);`,
label,
text: 'Retrieve historic query datas',
text: 'Retrieve historic query data',
value: 'storageRetrieveInfoOnQueryKeys'
};