Add new snippet for api.query.balances.freeBalance.multi (#1288)
This commit is contained in:
parent
06a8870385
commit
2f0172a033
@ -15,7 +15,8 @@ import {
|
||||
storageGetInfo,
|
||||
storageSystemEvents,
|
||||
storageListenToBalanceChange,
|
||||
storageRetrieveInfoOnQueryKeys
|
||||
storageListenToMultipleBalancesChange,
|
||||
storageRetrieveInfoOnQueryKeys
|
||||
} from './storage-examples';
|
||||
|
||||
import { extrinsicMakeTransfer } from './extrinsics-examples';
|
||||
@ -28,6 +29,7 @@ const snippets: Array<Snippet> = [
|
||||
storageGetInfo,
|
||||
storageSystemEvents,
|
||||
storageListenToBalanceChange,
|
||||
storageListenToMultipleBalancesChange,
|
||||
storageRetrieveInfoOnQueryKeys,
|
||||
extrinsicMakeTransfer
|
||||
];
|
||||
|
||||
@ -85,6 +85,23 @@ api.query.balances.freeBalance(ALICE, (balance) => {
|
||||
});`
|
||||
};
|
||||
|
||||
export const storageListenToMultipleBalancesChange: Snippet = {
|
||||
value: 'storageListenToMultipleBalancesChange',
|
||||
text: 'Listen to multiple balances changes',
|
||||
label: { color: 'blue', children: 'Storage', size: 'tiny' },
|
||||
code: `// You may leave this example running and make a transfer
|
||||
// of any value from or to Alice/Bob address in the 'Transfer' App
|
||||
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
|
||||
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
|
||||
|
||||
console.log('Tracking balances for:', [ALICE, BOB])
|
||||
|
||||
// Subscribe and listen to several balance changes
|
||||
api.query.balances.freeBalance.multi([ALICE, BOB], (balance) => {
|
||||
console.log('Change detected, new balances: ', balance)
|
||||
});`
|
||||
};
|
||||
|
||||
export const storageRetrieveInfoOnQueryKeys: Snippet = {
|
||||
value: 'storageRetrieveInfoOnQueryKeys',
|
||||
text: 'Retrieve Info on query keys',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user