Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added submit data call to examples #62

Merged
merged 2 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -1,8 +1,8 @@
// Copyright 2017-2024 @polkadot/app-js authors & contributors
// SPDX-License-Identifier: Apache-2.0

import { constsStakingParameters } from './consts-examples.js';

Check failure on line 4 in packages/page-js/src/snippets/index.ts

View workflow job for this annotation

GitHub Actions / pr (lint)

Run autofix to sort these imports!
import { extrinsicMakeTransfer } from './extrinsics-examples.js';
import { extrinsicMakeTransfer, daSubmitDataCall } 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 @@
storageRetrieveInfoOnQueryKeys,
storageKeys,
constsStakingParameters,
extrinsicMakeTransfer
extrinsicMakeTransfer,
daSubmitDataCall
] as const;
Loading