Skip to content

Commit 0b777c2

Browse files
bkonturclaude
andcommitted
fix(examples): use TX_MODE_FINALIZED_BLOCK for authorization calls
Wait for finalized blocks in authorizePreimage and authorizeAccount calls to ensure authorization is complete before proceeding with store. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent ffb8e88 commit 0b777c2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

examples/authorize_preimage_and_store_papi.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from "assert";
22
import { createClient } from 'polkadot-api';
33
import { getWsProvider } from 'polkadot-api/ws-provider';
44
import { cryptoWaitReady } from '@polkadot/util-crypto';
5-
import { authorizeAccount, authorizePreimage, fetchCid, store, TX_MODE_IN_BLOCK } from './api.js';
5+
import { authorizeAccount, authorizePreimage, fetchCid, store, TX_MODE_IN_BLOCK, TX_MODE_FINALIZED_BLOCK } from './api.js';
66
import { setupKeyringAndSigners, getContentHash } from './common.js';
77
import { logHeader, logConnection, logSection, logSuccess, logError, logInfo, logTestResult } from './logger.js';
88
import { cidFromBytes } from "./cid_dag_metadata.js";
@@ -43,7 +43,8 @@ async function runPreimageStoreTest(testName, bulletinAPI, sudoSigner, signer, s
4343
bulletinAPI,
4444
sudoSigner,
4545
contentHash,
46-
BigInt(dataToStore.length)
46+
BigInt(dataToStore.length),
47+
TX_MODE_FINALIZED_BLOCK
4748
);
4849

4950
// If signer is provided, also authorize the account (to increment inc_providers/inc_sufficients for `CheckNonce`).
@@ -54,7 +55,8 @@ async function runPreimageStoreTest(testName, bulletinAPI, sudoSigner, signer, s
5455
sudoSigner,
5556
signerAddress,
5657
10, // dummy transactions
57-
BigInt(10000) // dummy bytes
58+
BigInt(10000), // dummy bytes
59+
TX_MODE_FINALIZED_BLOCK
5860
);
5961
}
6062

0 commit comments

Comments
 (0)