Skip to content

Commit d95e7d0

Browse files
authored
fix(cli): read allowance fields from AuthorizationExtent (#125)
### Problem `dotns bulletin authorize` reports `Authorization was finalized but not applied` even when the on-chain call succeeds. The misleading error `may not have Authorizer privileges` fires every time, blocking CI deploys. Example in [mark3t CI](https://github.com/paritytech/mark3t/actions/runs/25509126698/job/74863965404?pr=209). ### Root cause After paritytech/polkadot-bulletin-chain [#448](paritytech/polkadot-bulletin-chain#448), AuthorizationExtent fields `transactions` and `bytes` now mean consumed counters, not allowances. New fields `transactions_allowance` and `bytes_allowance` carry the granted total instead. ```rust // pallets/transaction-storage/src/lib.rs after #448 pub struct AuthorizationExtent { pub transactions: u32, // CONSUMED so far pub transactions_allowance: u32, // total ALLOWANCE (new field) pub bytes: u64, // CONSUMED so far pub bytes_permanent: u64, pub bytes_allowance: u64, // total ALLOWANCE (new field) } ``` The CLI compares the consumed counter (0 for a fresh authorization) against the requested allowance (1_000_000 default), so 0 >= 1_000_000 is false → "not applied". The error fires only when on-chain dispatch already succeeded (event.ok === true in the finalized case handler). The "Authorizer privileges" wording is a misleading hardcoded message - the actual cause is the wrong field read. ### Fix Read `transactions_allowance` and `bytes_allowance` from `AuthorizationExtent`, update `AuthorizationStatus` type to expose them, fix the comparison in the post-flight verification and pre-flight quota check. JSON output field names kept stable for backwards-compat. ### Test plan - bunx tsc --noEmit clean - bun run lint clean - bun run test:unit — 163/163 passing - Metadata refresh applied; .papi/metadata/bulletin.scale includes `transactions_allowance`, `bytes_allowance`, `bytes_permanent`
1 parent fb19ed3 commit d95e7d0

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

packages/cli/.papi/descriptors/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.0-autogenerated.1427683338681917606",
2+
"version": "0.1.0-autogenerated.15093024273838411924",
33
"name": "@polkadot-api/descriptors",
44
"files": [
55
"dist"
15.6 KB
Binary file not shown.

packages/cli/.papi/polkadot-api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"wsUrl": "wss://paseo-bulletin-rpc.polkadot.io",
1313
"metadata": ".papi/metadata/bulletin.scale",
1414
"genesis": "0x744960c32e3a3df5440e1ecd4d34096f1ce2230d7016a5ada8a765d5a622b4ea",
15-
"codeHash": "0x9838682961f13a0665e7dac54178aa99531391530e60e879a9eab84d6dc2a199"
15+
"codeHash": "0xd248224df107ca81267a5a4d0671bb9618dbb1a43fae7fad6ba2331a45a10ac5"
1616
}
1717
}
1818
}

packages/cli/src/cli/commands/bulletin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,8 @@ export function attachBulletinCommands(root: Command): void {
933933
rpc: bulletinRpc,
934934
authorized: authStatus.authorized,
935935
expired: authStatus.expired ?? false,
936-
transactions: authStatus.transactions ?? 0,
937-
bytes: (authStatus.bytes ?? BigInt(0)).toString(),
936+
transactions: authStatus.transactions_allowance ?? 0,
937+
bytes: (authStatus.bytes_allowance ?? BigInt(0)).toString(),
938938
expiresAt: expirationToISOString(authStatus.currentBlock, authStatus.expiration),
939939
});
940940
} else {
@@ -964,11 +964,11 @@ export function attachBulletinCommands(root: Command): void {
964964
);
965965
console.log(
966966
chalk.gray(" transactions: ") +
967-
chalk.white((authStatus.transactions ?? 0).toLocaleString()),
967+
chalk.white((authStatus.transactions_allowance ?? 0).toLocaleString()),
968968
);
969969
console.log(
970970
chalk.gray(" bytes: ") +
971-
chalk.white(formatBytes(authStatus.bytes ?? BigInt(0))),
971+
chalk.white(formatBytes(authStatus.bytes_allowance ?? BigInt(0))),
972972
);
973973

974974
if (isExpired) {

packages/cli/src/commands/bulletin.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,8 @@ export async function authorizeAccount(
432432
const existingAuthorization = await checkAuthorization(rpc, targetAddress);
433433

434434
if (existingAuthorization.authorized) {
435-
const existingTransactions = existingAuthorization.transactions ?? 0;
436-
const existingBytes = existingAuthorization.bytes ?? BigInt(0);
435+
const existingTransactions = existingAuthorization.transactions_allowance ?? 0;
436+
const existingBytes = existingAuthorization.bytes_allowance ?? BigInt(0);
437437

438438
if (existingAuthorization.expired) {
439439
emitPhase(onPhase, "authorize", "warning", "Authorization expired");
@@ -496,8 +496,8 @@ export async function authorizeAccount(
496496
if (
497497
verification.authorized &&
498498
!verification.expired &&
499-
(verification.transactions ?? 0) >= transactions &&
500-
(verification.bytes ?? BigInt(0)) >= bytes
499+
(verification.transactions_allowance ?? 0) >= transactions &&
500+
(verification.bytes_allowance ?? BigInt(0)) >= bytes
501501
) {
502502
emitPhase(onPhase, "authorize", "success", "Account authorized");
503503
resolve({ txHash, blockHash: event.block.hash });
@@ -572,8 +572,8 @@ export async function checkAuthorization(
572572

573573
return {
574574
authorized: true,
575-
transactions: authorizationState.extent.transactions,
576-
bytes: authorizationState.extent.bytes,
575+
transactions_allowance: authorizationState.extent.transactions_allowance,
576+
bytes_allowance: authorizationState.extent.bytes_allowance,
577577
expiration,
578578
currentBlock,
579579
expired,

packages/cli/src/types/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ export type AuthorizeAccountOptions = {
379379
export type AuthorizationStatus = {
380380
/** Whether an authorization entry exists in chain storage */
381381
authorized: boolean;
382-
/** Remaining transaction allowance */
383-
transactions?: number;
384-
/** Remaining byte allowance */
385-
bytes?: bigint;
382+
/** Total transaction allowance granted by `authorize_account` */
383+
transactions_allowance?: number;
384+
/** Total byte allowance granted by `authorize_account` */
385+
bytes_allowance?: bigint;
386386
/** Block number at which the authorization expires */
387387
expiration?: number;
388388
/** Current chain block number at time of query */

0 commit comments

Comments
 (0)