Skip to content

Commit fdef26e

Browse files
committed
WIP: comparing transaction sending and signing
1 parent 04ae1e3 commit fdef26e

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

examples/authorize_and_store_papi_smoldot.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,6 @@ async function main() {
3232
const dataToStore = "Hello, Bulletin with PAPI + Smoldot - " + new Date().toString();
3333
const cid = cidFromBytes(dataToStore);
3434

35-
// Start smoldot with logging enabled
36-
// console.log('\n🚀 Starting smoldot...');
37-
// const client = smoldot.start({
38-
// maxLogLevel: 0, // 0=off, 1=error, 2=warn, 3=info, 4=debug, 5=trace
39-
// logCallback: (level, target, message) => {
40-
// const levelNames = ['ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE'];
41-
// const levelName = levelNames[level - 1] || 'UNKNOWN';
42-
// console.log(`[smoldot:${levelName}] ${target}: ${message}`);
43-
// }
44-
// });
45-
4635
// Note: In real usage, this step is not required — the chain spec with bootNodes should be included as part of the dApp.
4736
// For local testing, we use this to fetch the actual chain spec from the local node.
4837
// Get chain spec from Bob node and remove protocolId to allow smoldot to sync with local chain.
@@ -57,18 +46,37 @@ async function main() {
5746

5847
// Set up a client to connect to the Polkadot relay chain
5948
const client = createClient(getSmProvider(chain));
60-
61-
// Access the `TypedApi` to interact with all available chain calls and types
6249
const bulletinAPI = client.getTypedApi(bulletin);
63-
// const version = await bulletinAPI.constants.System.Version();
64-
// console.log('Version:', version);
6550

66-
const authorizeTx = await bulletinAPI.tx.transactionStorage.authorizeAccount(
51+
// bulletinAPI.tx.Balances.transfer_keep_alive({
52+
// dest: MultiAddress.Id(dest),
53+
// // 1 WND -> 12 decimals
54+
// value: 10n ** 12n,
55+
// })
56+
// .signSubmitAndWatch(signer)
57+
// .subscribe({
58+
// next(value) {
59+
// console.log(value)
60+
// },
61+
// error(err) {
62+
// console.error(err)
63+
// },
64+
// })
65+
66+
bulletinAPI.tx.transactionStorage.authorizeAccount({
6767
who,
6868
transactions,
6969
bytes
70-
);
71-
console.log('Authorized!: ', authorizeTx);
70+
}).signSubmitAndWatch(sudoAccount)
71+
.subscribe({
72+
next(value) {
73+
console.log(value)
74+
},
75+
error(err) {
76+
console.error(err)
77+
},
78+
})
79+
console.log('✅ Authorized!');
7280

7381
const storeTx = await bulletinAPI.tx.transactionStorage.store(dataToStore);
7482
console.log('Stored data!: ', storeTx);

0 commit comments

Comments
 (0)