@openzeppelin/miden-multisig-client 0.17.0 → 0.18.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +171 -46
  2. package/dist/account/builder.d.ts +4 -4
  3. package/dist/account/builder.d.ts.map +1 -1
  4. package/dist/account/builder.js +17 -7
  5. package/dist/account/builder.js.map +1 -1
  6. package/dist/account/layout.d.ts +5 -5
  7. package/dist/account/layout.d.ts.map +1 -1
  8. package/dist/account/layout.js +5 -5
  9. package/dist/account/layout.js.map +1 -1
  10. package/dist/client.d.ts +18 -1
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js +79 -6
  13. package/dist/client.js.map +1 -1
  14. package/dist/index.d.ts +6 -6
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +5 -5
  17. package/dist/index.js.map +1 -1
  18. package/dist/multisig/authArgErrors.d.ts +28 -31
  19. package/dist/multisig/authArgErrors.d.ts.map +1 -1
  20. package/dist/multisig/authArgErrors.js +42 -46
  21. package/dist/multisig/authArgErrors.js.map +1 -1
  22. package/dist/multisig/consumeNotesErrors.d.ts +13 -1
  23. package/dist/multisig/consumeNotesErrors.d.ts.map +1 -1
  24. package/dist/multisig/consumeNotesErrors.js +17 -0
  25. package/dist/multisig/consumeNotesErrors.js.map +1 -1
  26. package/dist/multisig/signing.d.ts +1 -1
  27. package/dist/multisig/signing.d.ts.map +1 -1
  28. package/dist/multisig/signing.js +8 -3
  29. package/dist/multisig/signing.js.map +1 -1
  30. package/dist/multisig.d.ts +145 -18
  31. package/dist/multisig.d.ts.map +1 -1
  32. package/dist/multisig.js +493 -162
  33. package/dist/multisig.js.map +1 -1
  34. package/dist/procedures.d.ts +7 -7
  35. package/dist/procedures.js +7 -7
  36. package/dist/proposal/factory.d.ts.map +1 -1
  37. package/dist/proposal/factory.js +7 -0
  38. package/dist/proposal/factory.js.map +1 -1
  39. package/dist/prover/workflow.d.ts +7 -3
  40. package/dist/prover/workflow.d.ts.map +1 -1
  41. package/dist/prover/workflow.js +7 -5
  42. package/dist/prover/workflow.js.map +1 -1
  43. package/dist/raw-client.d.ts +1 -0
  44. package/dist/raw-client.d.ts.map +1 -1
  45. package/dist/raw-client.js +10 -2
  46. package/dist/raw-client.js.map +1 -1
  47. package/dist/recovery/publicNoteBackfill.js +1 -1
  48. package/dist/recovery/publicNoteBackfill.js.map +1 -1
  49. package/dist/retry/classify.d.ts +3 -0
  50. package/dist/retry/classify.d.ts.map +1 -1
  51. package/dist/retry/classify.js +2 -2
  52. package/dist/retry/classify.js.map +1 -1
  53. package/dist/signer.d.ts +1 -0
  54. package/dist/signer.d.ts.map +1 -1
  55. package/dist/signer.js +1 -0
  56. package/dist/signer.js.map +1 -1
  57. package/dist/signers/index.d.ts +1 -0
  58. package/dist/signers/index.d.ts.map +1 -1
  59. package/dist/signers/index.js +1 -0
  60. package/dist/signers/index.js.map +1 -1
  61. package/dist/signers/ledger.d.ts +25 -0
  62. package/dist/signers/ledger.d.ts.map +1 -0
  63. package/dist/signers/ledger.js +96 -0
  64. package/dist/signers/ledger.js.map +1 -0
  65. package/dist/state/adopt.d.ts +45 -0
  66. package/dist/state/adopt.d.ts.map +1 -0
  67. package/dist/state/adopt.js +101 -0
  68. package/dist/state/adopt.js.map +1 -0
  69. package/dist/transaction/authArgs.d.ts +57 -0
  70. package/dist/transaction/authArgs.d.ts.map +1 -0
  71. package/dist/transaction/authArgs.js +108 -0
  72. package/dist/transaction/authArgs.js.map +1 -0
  73. package/dist/transaction/consumeNotes.d.ts +9 -5
  74. package/dist/transaction/consumeNotes.d.ts.map +1 -1
  75. package/dist/transaction/consumeNotes.js +8 -23
  76. package/dist/transaction/consumeNotes.js.map +1 -1
  77. package/dist/transaction/noteAuthentication.d.ts +39 -0
  78. package/dist/transaction/noteAuthentication.d.ts.map +1 -0
  79. package/dist/transaction/noteAuthentication.js +94 -0
  80. package/dist/transaction/noteAuthentication.js.map +1 -0
  81. package/dist/transaction/options.d.ts +25 -0
  82. package/dist/transaction/options.d.ts.map +1 -1
  83. package/dist/transaction/p2id.d.ts +3 -2
  84. package/dist/transaction/p2id.d.ts.map +1 -1
  85. package/dist/transaction/p2id.js +36 -27
  86. package/dist/transaction/p2id.js.map +1 -1
  87. package/dist/transaction/summary.d.ts +126 -22
  88. package/dist/transaction/summary.d.ts.map +1 -1
  89. package/dist/transaction/summary.js +164 -22
  90. package/dist/transaction/summary.js.map +1 -1
  91. package/dist/transaction/updateGuardian.d.ts +3 -3
  92. package/dist/transaction/updateGuardian.d.ts.map +1 -1
  93. package/dist/transaction/updateGuardian.js +5 -16
  94. package/dist/transaction/updateGuardian.js.map +1 -1
  95. package/dist/transaction/updateProcedureThreshold.d.ts +3 -3
  96. package/dist/transaction/updateProcedureThreshold.d.ts.map +1 -1
  97. package/dist/transaction/updateProcedureThreshold.js +6 -16
  98. package/dist/transaction/updateProcedureThreshold.js.map +1 -1
  99. package/dist/transaction/updateSigners.d.ts +3 -3
  100. package/dist/transaction/updateSigners.d.ts.map +1 -1
  101. package/dist/transaction/updateSigners.js +9 -16
  102. package/dist/transaction/updateSigners.js.map +1 -1
  103. package/dist/transaction.d.ts +3 -2
  104. package/dist/transaction.d.ts.map +1 -1
  105. package/dist/transaction.js +3 -2
  106. package/dist/transaction.js.map +1 -1
  107. package/dist/types/proposal.d.ts +37 -5
  108. package/dist/types/proposal.d.ts.map +1 -1
  109. package/dist/types/proposal.js +8 -0
  110. package/dist/types/proposal.js.map +1 -1
  111. package/dist/utils/eip712.d.ts +80 -0
  112. package/dist/utils/eip712.d.ts.map +1 -0
  113. package/dist/utils/eip712.js +49 -0
  114. package/dist/utils/eip712.js.map +1 -0
  115. package/dist/utils/signature.d.ts +4 -0
  116. package/dist/utils/signature.d.ts.map +1 -1
  117. package/dist/utils/signature.js +49 -1
  118. package/dist/utils/signature.js.map +1 -1
  119. package/package.json +11 -6
  120. package/src/account/builder.ts +18 -7
  121. package/src/account/layout.ts +5 -5
  122. package/src/client.ts +94 -6
  123. package/src/index.ts +24 -3
  124. package/src/multisig/authArgErrors.ts +47 -53
  125. package/src/multisig/consumeNotesErrors.ts +20 -1
  126. package/src/multisig/signing.ts +8 -2
  127. package/src/multisig.ts +614 -205
  128. package/src/procedures.ts +7 -7
  129. package/src/proposal/factory.ts +7 -0
  130. package/src/prover/workflow.ts +7 -10
  131. package/src/raw-client.ts +11 -7
  132. package/src/recovery/publicNoteBackfill.ts +1 -1
  133. package/src/retry/classify.ts +3 -3
  134. package/src/signer.ts +1 -0
  135. package/src/signers/index.ts +1 -0
  136. package/src/signers/ledger.ts +122 -0
  137. package/src/state/adopt.ts +132 -0
  138. package/src/transaction/authArgs.ts +142 -0
  139. package/src/transaction/consumeNotes.ts +23 -30
  140. package/src/transaction/noteAuthentication.ts +136 -0
  141. package/src/transaction/options.ts +27 -0
  142. package/src/transaction/p2id.ts +45 -34
  143. package/src/transaction/summary.ts +239 -30
  144. package/src/transaction/updateGuardian.ts +8 -22
  145. package/src/transaction/updateProcedureThreshold.ts +8 -20
  146. package/src/transaction/updateSigners.ts +11 -22
  147. package/src/transaction.ts +18 -1
  148. package/src/types/proposal.ts +36 -5
  149. package/src/utils/eip712.ts +57 -0
  150. package/src/utils/signature.ts +57 -0
  151. package/src/prover/test-node.d.ts +0 -6
@@ -1 +1 @@
1
- {"version":3,"file":"consumeNotes.d.ts","sourceRoot":"","sources":["../../src/transaction/consumeNotes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,IAAI,EACJ,kBAAkB,EAClB,aAAa,EACb,IAAI,EACL,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAElF;;;GAGG;AACH,wBAAgB,4CAA4C,CAC1D,KAAK,EAAE,IAAI,EAAE,EACb,OAAO,GAAE,gBAAqB,GAC7B;IAAE,OAAO,EAAE,kBAAkB,CAAC;IAAC,IAA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jB,OAAO,EAAE,iCAAiC,GACzC,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AACxD,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC"}
@@ -1,13 +1,8 @@
1
- import { NoteAndArgs, NoteAndArgsArray, TransactionRequestBuilder, Word as WordType, } from '@miden-sdk/miden-sdk';
1
+ import { NoteAndArgs, NoteAndArgsArray } from '@miden-sdk/miden-sdk';
2
2
  import { LegacyConsumeNotesNoteMissingError } from '../multisig/consumeNotesErrors.js';
3
3
  import { getRawMidenClient } from '../raw-client.js';
4
- import { normalizeHexWord } from '../utils/encoding.js';
5
- import { randomWord } from '../utils/random.js';
6
- /**
7
- * Build a consume-notes request from loaded `Note` objects (no local-store
8
- * read). v2 verification path for issue #229.
9
- */
10
- export function buildConsumeNotesTransactionRequestFromNotes(notes, options = {}) {
4
+ import { buildMultisigRequest, multisigRequestBuilder } from './authArgs.js';
5
+ export async function buildConsumeNotesTransactionRequestFromNotes(client, notes, options) {
11
6
  if (notes.length === 0) {
12
7
  throw new Error('At least one note is required');
13
8
  }
@@ -15,24 +10,14 @@ export function buildConsumeNotesTransactionRequestFromNotes(notes, options = {}
15
10
  for (const note of notes) {
16
11
  noteAndArgsArray.push(new NoteAndArgs(note, null));
17
12
  }
18
- const authSaltHex = options.salt ? options.salt.toHex() : randomWord().toHex();
19
- const authSaltForBuilder = WordType.fromHex(normalizeHexWord(authSaltHex));
20
- let txBuilder = new TransactionRequestBuilder();
21
- txBuilder = txBuilder.withInputNotes(noteAndArgsArray);
22
- txBuilder = txBuilder.withFeeConversionSalt(authSaltForBuilder);
23
- // Borrows rather than consumes: the glue passes `__wbg_ptr` without taking it,
24
- // so the handle stays ours to release once the builder has read it.
25
- authSaltForBuilder.free?.();
13
+ const { builder, saltHex } = await multisigRequestBuilder(client, options);
14
+ let txBuilder = builder.withInputNotes(noteAndArgsArray);
26
15
  if (options.signatureAdviceMap) {
27
16
  txBuilder = txBuilder.extendAdviceMap(options.signatureAdviceMap);
28
17
  }
29
- const authSaltForReturn = WordType.fromHex(normalizeHexWord(authSaltHex));
30
- return {
31
- request: txBuilder.build(),
32
- salt: authSaltForReturn,
33
- };
18
+ return buildMultisigRequest(txBuilder, saltHex, options.accountId);
34
19
  }
35
- export async function buildConsumeNotesTransactionRequest(client, noteIds, options = {}) {
20
+ export async function buildConsumeNotesTransactionRequest(client, noteIds, options) {
36
21
  if (noteIds.length === 0) {
37
22
  throw new Error('At least one note ID is required');
38
23
  }
@@ -45,6 +30,6 @@ export async function buildConsumeNotesTransactionRequest(client, noteIds, optio
45
30
  }
46
31
  notes.push(inputNoteRecord.toNote());
47
32
  }
48
- return buildConsumeNotesTransactionRequestFromNotes(notes, options);
33
+ return buildConsumeNotesTransactionRequestFromNotes(rawClient, notes, options);
49
34
  }
50
35
  //# sourceMappingURL=consumeNotes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consumeNotes.js","sourceRoot":"","sources":["../../src/transaction/consumeNotes.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,yBAAyB,EACzB,IAAI,IAAI,QAAQ,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kCAAkC,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD;;;GAGG;AACH,MAAM,UAAU,4CAA4C,CAC1D,KAAa,EACb,UAA4B,EAAE;IAE9B,IAAI,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*
4
+ * miden-client decides per input note, at execution time and from the local
5
+ * store alone, whether it is consumed as *authenticated* (the store holds
6
+ * its inclusion proof) or *unauthenticated* (anything else). The two modes
7
+ * commit differently into the transaction summary,
8
+ * `hash(nullifier || note_id_or_ZERO)`, so the proposer and every verifier
9
+ * must be in the same mode or the summary commitment, and with it the
10
+ * proposal id, differs. That was issue #409's live shape: a cosigner whose
11
+ * fresh store had never seen the notes failed with "metadata does not match
12
+ * tx_summary". Proposal creation and every rebuild call
13
+ * {@link ensureNotesAuthenticated} first, so the executed transaction is the
14
+ * one the cosigners signed regardless of what each store held before.
15
+ */
16
+ import { type Note } from '@miden-sdk/miden-sdk';
17
+ import type { RawClientSource } from '../raw-client.js';
18
+ import { type RpcConfig } from '../rpc/config.js';
19
+ export interface EnsureNotesAuthenticatedOptions {
20
+ /** Miden node RPC endpoint the inclusion proofs are fetched from. */
21
+ midenRpcEndpoint: string;
22
+ /** Retry policy for the proof fetch; defaults to the SDK's RPC defaults. */
23
+ rpc?: RpcConfig;
24
+ }
25
+ /**
26
+ * Makes every note in `notes` an authenticated input note in the client's
27
+ * local store: present, with its on-chain inclusion proof and block header.
28
+ *
29
+ * Notes already authenticated locally are left alone. For the rest the
30
+ * inclusion proofs come from the node in one round trip (the node serves
31
+ * proofs for private notes too) and each note is imported as committed,
32
+ * which also upgrades a proof-less record the store already tracked.
33
+ *
34
+ * @throws {ConsumeNoteNotAuthenticatedError} when a note is not committed on
35
+ * chain yet, the node does not serve its proof, the import fails, or the
36
+ * record still lacks authentication after a sync.
37
+ */
38
+ export declare function ensureNotesAuthenticated(midenClient: RawClientSource, notes: readonly Note[], options: EnsureNotesAuthenticatedOptions): Promise<void>;
39
+ //# sourceMappingURL=noteAuthentication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noteAuthentication.d.ts","sourceRoot":"","sources":["../../src/transaction/noteAuthentication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAY,KAAK,IAAI,EAAsC,MAAM,sBAAsB,CAAC;AAG/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIpE,MAAM,WAAW,+BAA+B;IAC9C,qEAAqE;IACrE,gBAAgB,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,GAAG,CAAC,EAAE,SAAS,CAAC;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,eAAe,EAC5B,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,IAAI,CAAC,CA+Df"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Canonical consumption mode for `consume_notes` proposals: authenticated.
3
+ *
4
+ * miden-client decides per input note, at execution time and from the local
5
+ * store alone, whether it is consumed as *authenticated* (the store holds
6
+ * its inclusion proof) or *unauthenticated* (anything else). The two modes
7
+ * commit differently into the transaction summary,
8
+ * `hash(nullifier || note_id_or_ZERO)`, so the proposer and every verifier
9
+ * must be in the same mode or the summary commitment, and with it the
10
+ * proposal id, differs. That was issue #409's live shape: a cosigner whose
11
+ * fresh store had never seen the notes failed with "metadata does not match
12
+ * tx_summary". Proposal creation and every rebuild call
13
+ * {@link ensureNotesAuthenticated} first, so the executed transaction is the
14
+ * one the cosigners signed regardless of what each store held before.
15
+ */
16
+ import { Endpoint, RpcClient } from '@miden-sdk/miden-sdk';
17
+ import { ConsumeNoteNotAuthenticatedError } from '../multisig/consumeNotesErrors.js';
18
+ import { getRawMidenClient } from '../raw-client.js';
19
+ import { importNoteWithProof } from '../recovery/proposalNoteImport.js';
20
+ import { resolveRpcConfig } from '../rpc/config.js';
21
+ import { retryRpcRead } from '../rpc/retry.js';
22
+ import { normalizeHexWord } from '../utils/encoding.js';
23
+ /**
24
+ * Makes every note in `notes` an authenticated input note in the client's
25
+ * local store: present, with its on-chain inclusion proof and block header.
26
+ *
27
+ * Notes already authenticated locally are left alone. For the rest the
28
+ * inclusion proofs come from the node in one round trip (the node serves
29
+ * proofs for private notes too) and each note is imported as committed,
30
+ * which also upgrades a proof-less record the store already tracked.
31
+ *
32
+ * @throws {ConsumeNoteNotAuthenticatedError} when a note is not committed on
33
+ * chain yet, the node does not serve its proof, the import fails, or the
34
+ * record still lacks authentication after a sync.
35
+ */
36
+ export async function ensureNotesAuthenticated(midenClient, notes, options) {
37
+ const webClient = await getRawMidenClient(midenClient, options.midenRpcEndpoint);
38
+ const pending = await unauthenticatedNotes(webClient, notes);
39
+ if (pending.length === 0) {
40
+ return;
41
+ }
42
+ const proofs = new Map();
43
+ try {
44
+ const rpcClient = new RpcClient(new Endpoint(options.midenRpcEndpoint));
45
+ const fetched = await retryRpcRead(() => rpcClient.getNotesById(pending.map((note) => note.id())), resolveRpcConfig(options.rpc));
46
+ for (const entry of fetched) {
47
+ proofs.set(normalizeHexWord(entry.noteId.toString()), entry.inclusionProof);
48
+ }
49
+ }
50
+ catch (error) {
51
+ throw new ConsumeNoteNotAuthenticatedError(noteIdHex(pending[0]), `failed to fetch inclusion proofs from the node: ${errorDetail(error)}`);
52
+ }
53
+ for (const note of pending) {
54
+ const idHex = noteIdHex(note);
55
+ const proof = proofs.get(idHex);
56
+ if (!proof) {
57
+ throw new ConsumeNoteNotAuthenticatedError(idHex, 'the node has no inclusion proof for it (not committed on chain yet)');
58
+ }
59
+ const { outcome, wasImported } = await importNoteWithProof(webClient, 'proposal', idHex, note, proof);
60
+ if (!wasImported) {
61
+ throw new ConsumeNoteNotAuthenticatedError(idHex, `failed to import it with its inclusion proof: ${outcome.reason ?? 'unknown error'}`);
62
+ }
63
+ }
64
+ // The import authenticates a note committed at or below the client's sync
65
+ // height; a newer one lands unverified until a sync fetches its block
66
+ // header. A cosigner that just loaded the account is typically behind the
67
+ // note's block, so sync once and re-check before failing.
68
+ if ((await unauthenticatedNotes(webClient, notes)).length > 0) {
69
+ await webClient.syncState();
70
+ }
71
+ const still = await unauthenticatedNotes(webClient, notes);
72
+ if (still.length > 0) {
73
+ throw new ConsumeNoteNotAuthenticatedError(noteIdHex(still[0]), 'its inclusion proof was imported but the local store could not verify it ' +
74
+ 'against the chain even after a sync');
75
+ }
76
+ }
77
+ /** The subset of `notes` whose local record is missing or carries no proof. */
78
+ async function unauthenticatedNotes(webClient, notes) {
79
+ const pending = [];
80
+ for (const note of notes) {
81
+ const record = await webClient.getInputNote(noteIdHex(note));
82
+ if (!record || !record.isAuthenticated()) {
83
+ pending.push(note);
84
+ }
85
+ }
86
+ return pending;
87
+ }
88
+ function noteIdHex(note) {
89
+ return normalizeHexWord(note.id().toString());
90
+ }
91
+ function errorDetail(error) {
92
+ return error instanceof Error ? error.message : String(error);
93
+ }
94
+ //# sourceMappingURL=noteAuthentication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noteAuthentication.js","sourceRoot":"","sources":["../../src/transaction/noteAuthentication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAsC,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE/F,OAAO,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAErF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAkB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AASxD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,WAA4B,EAC5B,KAAsB,EACtB,OAAwC;IAExC,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC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AC,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -5,8 +5,33 @@ export interface SignatureOptions {
5
5
  signatureAdviceMap?: AdviceMap;
6
6
  signatureScheme?: SignatureScheme;
7
7
  midenRpcEndpoint?: string;
8
+ /**
9
+ * The block the transaction summary binds. Omitted, the store's sync height,
10
+ * which is right for the party creating a proposal. A cosigner or executor
11
+ * rebuilding a proposal pins it to the proposal's anchor block, or the rebuilt
12
+ * summary can never match the signed one.
13
+ */
14
+ boundBlockNum?: number;
15
+ /**
16
+ * Blocks after the bound block at which the approvers' signatures stop
17
+ * authorizing the transaction, so it must be included by then. Bound by the
18
+ * summary, so a rebuild must pass the same value. At most 65535 blocks, the
19
+ * furthest a transaction can expire after its reference block; omitted, the
20
+ * approval never expires, which is the upstream default.
21
+ */
22
+ approvalExpirationDelta?: number;
8
23
  }
9
24
  export interface MidenClientSignatureOptions extends SignatureOptions {
10
25
  midenRpcEndpoint: string;
11
26
  }
27
+ /**
28
+ * Options for a request a multisig account executes. The account decides the
29
+ * auth args the request has to carry, so every multisig builder needs it.
30
+ */
31
+ export interface MultisigRequestOptions extends SignatureOptions {
32
+ accountId: string;
33
+ }
34
+ export interface MidenClientMultisigRequestOptions extends MultisigRequestOptions {
35
+ midenRpcEndpoint: string;
36
+ }
12
37
  //# sourceMappingURL=options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/transaction/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/transaction/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,kBAAkB,CAAC,EAAE,SAAS,CAAC;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,2BAA4B,SAAQ,gBAAgB;IACnE,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iCAAkC,SAAQ,sBAAsB;IAC/E,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
@@ -1,5 +1,6 @@
1
1
  import type { TransactionRequest, Word } from '@miden-sdk/miden-sdk';
2
2
  import { Note, NoteType } from '@miden-sdk/miden-sdk';
3
+ import type { RawClientSource } from '../raw-client.js';
3
4
  import type { SignatureOptions } from './options.js';
4
5
  import type { P2idNoteVisibility } from '../types/proposal.js';
5
6
  /**
@@ -37,8 +38,8 @@ export declare function deriveP2idSerialNumber(salt: Word): Word;
37
38
  * callback flag is encoded in the faucet account ID.
38
39
  */
39
40
  export declare function buildP2idNoteFromMetadata(senderId: string, recipientId: string, faucetId: string, amount: bigint, noteType: NoteType, saltHex: string, heights?: P2ideHeightOptions): Note;
40
- export declare function buildP2idTransactionRequest(senderId: string, recipientId: string, faucetId: string, amount: bigint, options?: P2idTransactionOptions): {
41
+ export declare function buildP2idTransactionRequest(client: RawClientSource, senderId: string, recipientId: string, faucetId: string, amount: bigint, options?: P2idTransactionOptions): Promise<{
41
42
  request: TransactionRequest;
42
43
  salt: Word;
43
- };
44
+ }>;
44
45
  //# sourceMappingURL=p2id.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"p2id.d.ts","sourceRoot":"","sources":["../../src/transaction/p2id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAML,IAAI,EAOJ,QAAQ,EAIT,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB,EAAE,kBAAkB;IAClF,qEAAqE;IACrE,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAUrE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,kBAAkB,GAAG,SAAS,CAErG;AAED,wBAAgB,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AS,GAAG,QAAQ,CAUrE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,kBAAkB,GAAG,SAAS,CAErG;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAMvD;AAiED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,kBAAuB,GAC/B,IAAI,CASN;AAED,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAuBtD"}
@@ -1,5 +1,5 @@
1
- import { AccountId, Felt, FeltArray, FungibleAsset, MidenArrays, Note, NoteAssets, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteTag, NoteType, Poseidon2, TransactionRequestBuilder, Word as WordType, } from '@miden-sdk/miden-sdk';
2
- import { randomWord } from '../utils/random.js';
1
+ import { AccountId, Felt, FeltArray, FungibleAsset, MidenArrays, Note, NoteAssets, NoteMetadata, NoteRecipient, NoteScript, NoteStorage, NoteTag, NoteType, Poseidon2, Word as WordType, } from '@miden-sdk/miden-sdk';
2
+ import { buildMultisigRequest, multisigRequestBuilder } from './authArgs.js';
3
3
  import { normalizeHexWord } from '../utils/encoding.js';
4
4
  import { parseP2ideHeight } from '../types/proposal.js';
5
5
  /**
@@ -33,22 +33,39 @@ export function deriveP2idSerialNumber(salt) {
33
33
  ...zeroWord.toFelts(),
34
34
  ]));
35
35
  }
36
+ /**
37
+ * P2ID storage since protocol 0.17 rc.5: target account, then a two-felt salt.
38
+ * Zero salt is the upstream default. A secret salt hides the target from
39
+ * guesses against the storage commitment; this builder keeps the note
40
+ * deterministic in the proposal salt, which already derives the serial number.
41
+ */
42
+ function p2idStorage(recipient) {
43
+ return [recipient.suffix(), recipient.prefix(), new Felt(0n), new Felt(0n)];
44
+ }
45
+ /**
46
+ * P2IDE storage: reclaimer (the sender), target, then reclaim and timelock
47
+ * heights. Zero encodes an unset height. The script requires all six items.
48
+ */
49
+ function p2ideStorage(sender, recipient, reclaimHeight, timelockHeight) {
50
+ return [
51
+ sender.suffix(),
52
+ sender.prefix(),
53
+ recipient.suffix(),
54
+ recipient.prefix(),
55
+ new Felt(BigInt(reclaimHeight)),
56
+ new Felt(BigInt(timelockHeight)),
57
+ ];
58
+ }
36
59
  function buildP2idNote(sender, recipient, noteAssets, noteType, saltHex, heights = {}) {
37
60
  const salt = WordType.fromHex(normalizeHexWord(saltHex));
38
61
  const serialNum = deriveP2idSerialNumber(salt);
39
62
  const reclaimHeight = parseP2ideHeight('reclaimHeight', heights.reclaimHeight);
40
63
  const timelockHeight = parseP2ideHeight('timelockHeight', heights.timelockHeight);
41
64
  const isP2ide = reclaimHeight !== undefined || timelockHeight !== undefined;
42
- // P2IDE storage layout (miden-standards `P2ideNoteStorage`): the P2ID
43
- // storage plus reclaim/timelock heights as felts, 0 encoding "unset".
44
65
  const noteScript = isP2ide ? NoteScript.p2ide() : NoteScript.p2id();
45
- const storageFelts = [
46
- recipient.suffix(),
47
- recipient.prefix(),
48
- ];
49
- if (isP2ide) {
50
- storageFelts.push(new Felt(BigInt(reclaimHeight ?? 0)), new Felt(BigInt(timelockHeight ?? 0)));
51
- }
66
+ const storageFelts = isP2ide
67
+ ? p2ideStorage(sender, recipient, reclaimHeight ?? 0, timelockHeight ?? 0)
68
+ : p2idStorage(recipient);
52
69
  const noteStorage = new NoteStorage(new FeltArray(storageFelts));
53
70
  const noteRecipient = new NoteRecipient(serialNum, noteScript, noteStorage);
54
71
  const noteTag = NoteTag.withAccountTarget(recipient);
@@ -69,24 +86,16 @@ export function buildP2idNoteFromMetadata(senderId, recipientId, faucetId, amoun
69
86
  const noteAssets = new NoteAssets([asset]);
70
87
  return buildP2idNote(sender, recipient, noteAssets, noteType, saltHex, heights);
71
88
  }
72
- export function buildP2idTransactionRequest(senderId, recipientId, faucetId, amount, options = {}) {
73
- const authSaltHex = options.salt ? options.salt.toHex() : randomWord().toHex();
74
- const note = buildP2idNoteFromMetadata(senderId, recipientId, faucetId, amount, options.noteType ?? NoteType.Public, authSaltHex, { reclaimHeight: options.reclaimHeight, timelockHeight: options.timelockHeight });
75
- const outputNotes = new MidenArrays.NoteArray([note]);
76
- const authSaltForBuilder = WordType.fromHex(normalizeHexWord(authSaltHex));
77
- let txBuilder = new TransactionRequestBuilder();
78
- txBuilder = txBuilder.withOwnOutputNotes(outputNotes);
79
- txBuilder = txBuilder.withFeeConversionSalt(authSaltForBuilder);
80
- // Borrows rather than consumes: the glue passes `__wbg_ptr` without taking it,
81
- // so the handle stays ours to release once the builder has read it.
82
- authSaltForBuilder.free?.();
89
+ export async function buildP2idTransactionRequest(client, senderId, recipientId, faucetId, amount, options = {}) {
90
+ const { builder, saltHex } = await multisigRequestBuilder(client, {
91
+ ...options,
92
+ accountId: senderId,
93
+ });
94
+ const note = buildP2idNoteFromMetadata(senderId, recipientId, faucetId, amount, options.noteType ?? NoteType.Public, saltHex, { reclaimHeight: options.reclaimHeight, timelockHeight: options.timelockHeight });
95
+ let txBuilder = builder.withOwnOutputNotes(new MidenArrays.NoteArray([note]));
83
96
  if (options.signatureAdviceMap) {
84
97
  txBuilder = txBuilder.extendAdviceMap(options.signatureAdviceMap);
85
98
  }
86
- const authSaltForReturn = WordType.fromHex(normalizeHexWord(authSaltHex));
87
- return {
88
- request: txBuilder.build(),
89
- salt: authSaltForReturn,
90
- };
99
+ return buildMultisigRequest(txBuilder, saltHex, senderId);
91
100
  }
92
101
  //# sourceMappingURL=p2id.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"p2id.js","sourceRoot":"","sources":["../../src/transaction/p2id.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,SAAS,EACT,aAAa,EACb,WAAW,EACX,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,WAAW,EACX,OAAO,EACP,QAAQ,EACR,SAAS,EACT,yBAAyB,EACzB,IAAI,IAAI,QAAQ,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAmBxD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAyB;IACzD,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC,MAAM,CAAC;QACzB,KAAK,SAAS;YACZ,OAAO,QAAQ,CAAC,OAAO,CAAC;QAC1B;YACE,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,mCAAmC,CAAC,CAAC;IAChG,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAA8B;IACnE,OAAO,QAAQ,KAAK,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,IAAU;IAC/C,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1D,OAAO,SAAS,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC;QAC1C,GAAG,IAAI,CAAC,O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IAAI,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE9E,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC/B,SAAS,GAAG,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC"}
@@ -1,12 +1,51 @@
1
1
  import type { MidenClient, TransactionRequest, TransactionSummary, WasmWebClient } from '@miden-sdk/miden-sdk';
2
2
  import { ChainAnchor, Word } from '@miden-sdk/miden-sdk';
3
3
  /**
4
- * Captures a `ChainAnchor` for the request at the current sync height and
5
- * executes the transaction against it to obtain the summary awaiting
6
- * authorization. The anchor is returned alongside the summary so the proposer
7
- * can ship it with the signed data; cosigners and the executor then reproduce
8
- * the summary — which binds the reference block commitment since protocol
9
- * 0.16 — with {@link executeForSummaryAt} regardless of their own sync height.
4
+ * The summary binds the block the request's auth args name, and the anchor
5
+ * the store's sync height at capture. A sync landing between the build and the
6
+ * capture leaves them one block apart, and every cosigner's anchor check would
7
+ * then fail on a proposal nothing else is wrong with. Caught here, before the
8
+ * proposal is pushed, so the proposer rebuilds instead.
9
+ */
10
+ export declare class SummaryAnchorMismatchError extends Error {
11
+ readonly retryable = true;
12
+ constructor(details: {
13
+ anchorCommitmentHex: string;
14
+ summaryBlockCommitmentHex: string;
15
+ });
16
+ }
17
+ /**
18
+ * The Miden client synced and its node still has not produced the block a
19
+ * proposal binds, so the proposal cannot execute at this client's tip yet.
20
+ * Worth retrying once the node catches up.
21
+ */
22
+ export declare class ChainBehindBoundBlockError extends Error {
23
+ readonly retryable = true;
24
+ readonly syncHeight: number;
25
+ readonly boundBlockNum: number;
26
+ constructor(details: {
27
+ syncHeight: number;
28
+ boundBlockNum: number;
29
+ });
30
+ }
31
+ /**
32
+ * Whether a failed re-execution came from chain state this client can catch up
33
+ * with rather than from the proposal itself: a node that has not reached the
34
+ * bound block yet, or account state the node pruned because this client had
35
+ * not synced recently. Either clears on a later attempt, which syncs first.
36
+ */
37
+ export declare function isStaleChainError(error: unknown): boolean;
38
+ /**
39
+ * Derives the summary awaiting authorization for a proposal the caller is
40
+ * creating now, and captures a `ChainAnchor` at the current sync height to ship
41
+ * with it.
42
+ *
43
+ * The summary is derived at the chain tip, like every other execution of a
44
+ * multisig proposal (see {@link executeForSummaryAtTip}). The anchor still
45
+ * travels in the proposal: it names the block the request's auth args bind,
46
+ * which is how a rebuild learns that block, and 0.18.0-rc.1 clients re-execute
47
+ * at it. A proposer builds at the sync height the anchor is captured at, and
48
+ * the check below is what makes that hold.
10
49
  */
11
50
  export declare function executeForSummary(client: MidenClient, accountId: string, txRequest: TransactionRequest, midenRpcEndpoint: string): Promise<{
12
51
  summary: TransactionSummary;
@@ -16,11 +55,68 @@ export declare function executeForSummary(client: WasmWebClient, accountId: stri
16
55
  summary: TransactionSummary;
17
56
  anchor: ChainAnchor;
18
57
  }>;
58
+ /**
59
+ * Executes a multisig request at the chain tip to obtain the summary awaiting
60
+ * authorization. This is how cosigners and the executor reproduce a proposal's
61
+ * summary, whatever block they have synced to.
62
+ *
63
+ * Since protocol 0.17 a multisig summary binds the block its auth args name
64
+ * (the bound block), not the block the transaction executes against, so it
65
+ * reproduces at any later tip once the bound block is in the transaction's
66
+ * partial blockchain. The request declares it through `withBlockNumbers`, and
67
+ * foreign accounts, the fee faucet among them, load at the tip. Re-executing at
68
+ * the proposal's anchor instead loads them at the bound block, which a node
69
+ * prunes about 50 blocks later (issue #462).
70
+ *
71
+ * The client has to have synced to at least the bound block. When it has not,
72
+ * this syncs once before executing.
73
+ *
74
+ * @throws BoundBlockNotDeclaredError when the request binds a block in its
75
+ * multisig auth args without declaring it.
76
+ */
77
+ export declare function executeForSummaryAtTip(client: MidenClient, accountId: string, txRequest: TransactionRequest, midenRpcEndpoint: string): Promise<TransactionSummary>;
78
+ export declare function executeForSummaryAtTip(client: WasmWebClient, accountId: string, txRequest: TransactionRequest, midenRpcEndpoint?: string): Promise<TransactionSummary>;
79
+ /**
80
+ * Gets `client` ready to execute `request` at the chain tip: checks the
81
+ * request declares the block its multisig auth args bind, and syncs to that
82
+ * block (see {@link syncToBoundBlock}).
83
+ *
84
+ * @throws BoundBlockNotDeclaredError when the request binds a block in its
85
+ * multisig auth args without declaring it.
86
+ */
87
+ export declare function prepareTipExecution(client: WasmWebClient, request: TransactionRequest, syncState?: () => Promise<unknown>): Promise<void>;
88
+ /**
89
+ * The block `request`'s multisig auth args bind, after checking the request
90
+ * declares it. `undefined` for a request without multisig auth args, which
91
+ * has no bound block to declare.
92
+ *
93
+ * @throws BoundBlockNotDeclaredError when the block is bound but not declared.
94
+ */
95
+ export declare function requireDeclaredBoundBlock(request: TransactionRequest): number | undefined;
96
+ /**
97
+ * Syncs `client` once when its sync height is below `blockNum`, the block a
98
+ * proposal binds. Execution at a tip below it fails with "requested block N is
99
+ * after transaction reference block M", and a store that has never synced (a
100
+ * cosigner that has only just loaded the account) holds no header to rebuild
101
+ * the request from. `syncState` lets a caller wrap the sync in its own retry
102
+ * policy.
103
+ *
104
+ * This does not make a store that is already past the bound block current. An
105
+ * execution loads foreign accounts, the fee faucet among them, at the store's
106
+ * sync height, which a node prunes about 50 blocks later, so the multisig
107
+ * entry points that re-execute a proposal sync the chain first.
108
+ *
109
+ * @throws ChainBehindBoundBlockError when the node has not reached the block.
110
+ */
111
+ export declare function syncToBoundBlock(client: WasmWebClient, blockNum: number, syncState?: () => Promise<unknown>): Promise<void>;
19
112
  /**
20
113
  * Executes a transaction at the given `ChainAnchor`'s reference block to
21
- * obtain the summary awaiting authorization — the anchored counterpart of
22
- * {@link executeForSummary} for cosigners and executors holding a proposal's
23
- * anchor.
114
+ * obtain the summary awaiting authorization.
115
+ *
116
+ * For a summary that binds the reference block, such as a single-signature
117
+ * one. A multisig proposal's summary binds its bound block instead and is
118
+ * reproduced with {@link executeForSummaryAtTip}: re-executing it at an anchor
119
+ * fails once the node prunes the anchor block's account state.
24
120
  */
25
121
  export declare function executeForSummaryAt(client: MidenClient, accountId: string, txRequest: TransactionRequest, anchor: ChainAnchor, midenRpcEndpoint: string): Promise<TransactionSummary>;
26
122
  export declare function executeForSummaryAt(client: WasmWebClient, accountId: string, txRequest: TransactionRequest, anchor: ChainAnchor, midenRpcEndpoint?: string): Promise<TransactionSummary>;
@@ -32,22 +128,30 @@ export declare function chainAnchorToBase64(anchor: ChainAnchor): string;
32
128
  * Deserializes a `ChainAnchor` from its base64 wire form. `ChainAnchor`
33
129
  * deserialization validates the header/chain consistency internally, so a
34
130
  * decoded anchor only needs its block commitment checked against the signed
35
- * transaction summary before it is safe to execute against.
131
+ * transaction summary before the block it names is taken as the one the
132
+ * summary binds.
36
133
  */
37
134
  export declare function chainAnchorFromBase64(anchorBase64: string): ChainAnchor;
38
135
  /**
39
- * Reads the auth args back out of a transaction summary.
40
- *
41
- * Since miden-protocol 0.16-rc the summary binds seven user-defined elements
42
- * instead of a dedicated salt word. The guarded-multisig auth component zeroes
43
- * the leading three and passes the auth args as the trailing four, so the auth
44
- * args are the tail of `userParams()`.
136
+ * The block a proposal's `chainAnchor` names, which is the block its summary
137
+ * binds: a custom producer rebuilds its request at this block. Decodes the
138
+ * anchor for the one number and frees it.
139
+ */
140
+ export declare function chainAnchorBlockNum(anchorBase64: string): number;
141
+ /**
142
+ * Reads the salt a multisig transaction summary binds.
45
143
  *
46
- * This is the auth-arg word, *not* the proposal salt. When the request declares
47
- * a fee conversion salt, miden-client uses it to commit the native conversion
48
- * info under `hash(CONVERSION_INFO || SALT)`. That commitment is not invertible
49
- * to the salt. Keep the salt alongside the proposal — `ProposalMetadata.saltHex`
50
- * — rather than trying to recover it from the summary.
144
+ * Since protocol 0.17 the multisig auth components bind the salt itself into
145
+ * the summary's user params rather than a commitment derived from it, so the
146
+ * value cosigners signed over is readable again. A proposal still carries the
147
+ * salt in its metadata, because a request has to be rebuilt before any summary
148
+ * exists; this reader is the cross-check that the two agree.
149
+ */
150
+ export declare function summarySalt(summary: TransactionSummary): Word;
151
+ /**
152
+ * Reads the block at which the approvers' signatures stop authorizing the
153
+ * transaction, or `undefined` for an approval that never expires, which is
154
+ * what this package's builders produce.
51
155
  */
52
- export declare function summaryAuthArg(summary: TransactionSummary): Word;
156
+ export declare function summaryApprovalExpirationBlockNum(summary: TransactionSummary): number | undefined;
53
157
  //# sourceMappingURL=summary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/transaction/summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAa,WAAW,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAWpE;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,kBAAkB,EAC7B,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC;AACjE,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,kBAAkB,EAC7B,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC;AAcjE;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,kBAAkB,EAC7B,MAAM,EAAE,WAAW,EACnB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,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