Skip to content

Commit

Permalink
Added submit data call to examples (#62)
Browse files Browse the repository at this point in the history
* Added submit data call to examples

* lint

---------

Co-authored-by: Leouarz <[email protected]>
  • Loading branch information
markopoloparadox and Leouarz authored Apr 6, 2024
1 parent 767efd9 commit b549342
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
19 changes: 19 additions & 0 deletions packages/page-js/src/snippets/extrinsics-examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,22 @@ await transfer.signAndSend(ALICE, ({ events = [], status }) => {
});
});`
};

export const daSubmitDataCall: Snippet = {
value: 'daSubmitDataCall',
text: 'Call Submit Data and listen to events',
label: { color: 'grey', children: 'Extrinsics', size: 'tiny' },
code: `// You need to be connected to a development chain for this example to work.
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
const data = "Hello World";
const submitData = api.tx.dataAvailability.submitData(data);
// Sign and Send the transaction
await submitData.signAndSend(ALICE, ({ events = [], status }) => {
console.log(status);
events.forEach(({ phase, event: { data, method, section } }) => {
console.log(phase.toString() + ' : ' + section + '.' + method + ' ' + data.toString());
});
});`
};
5 changes: 3 additions & 2 deletions packages/page-js/src/snippets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { constsStakingParameters } from './consts-examples.js';
import { extrinsicMakeTransfer } from './extrinsics-examples.js';
import { daSubmitDataCall, extrinsicMakeTransfer } from './extrinsics-examples.js';
import { rpcNetworkAuthoring, rpcNewHead, rpcQueryState, rpcSysthemInfo } from './rpc-examples.js';
import { storageGetInfo, storageKeys, storageListenToBalanceChange, storageListenToMultipleBalancesChange, storageRetrieveInfoOnQueryKeys, storageSystemEvents } from './storage-examples.js';

Expand All @@ -20,5 +20,6 @@ export const allSnippets = [
storageRetrieveInfoOnQueryKeys,
storageKeys,
constsStakingParameters,
extrinsicMakeTransfer
extrinsicMakeTransfer,
daSubmitDataCall
] as const;

0 comments on commit b549342

Please sign in to comment.