@openzeppelin/miden-multisig-client 0.18.0-rc.2 → 0.18.0-rc.3
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.
- package/README.md +46 -4
- package/dist/account/builder.d.ts +3 -4
- package/dist/account/builder.d.ts.map +1 -1
- package/dist/account/builder.js +6 -13
- package/dist/account/builder.js.map +1 -1
- package/dist/client.d.ts +11 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -3
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +14 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/multisig.d.ts +40 -9
- package/dist/multisig.d.ts.map +1 -1
- package/dist/multisig.js +97 -108
- package/dist/multisig.js.map +1 -1
- package/dist/procedures.d.ts +5 -5
- package/dist/procedures.js +5 -5
- package/dist/recovery/proposalNoteImport.d.ts +5 -6
- package/dist/recovery/proposalNoteImport.d.ts.map +1 -1
- package/dist/recovery/proposalNoteImport.js +12 -13
- package/dist/recovery/proposalNoteImport.js.map +1 -1
- package/dist/recovery/publicNoteBackfill.d.ts +2 -3
- package/dist/recovery/publicNoteBackfill.d.ts.map +1 -1
- package/dist/recovery/publicNoteBackfill.js +4 -5
- package/dist/recovery/publicNoteBackfill.js.map +1 -1
- package/dist/transaction/authArgs.d.ts +2 -3
- package/dist/transaction/authArgs.d.ts.map +1 -1
- package/dist/transaction/authArgs.js +7 -14
- package/dist/transaction/authArgs.js.map +1 -1
- package/dist/transaction/consumeNotes.d.ts +4 -12
- package/dist/transaction/consumeNotes.d.ts.map +1 -1
- package/dist/transaction/consumeNotes.js +10 -4
- package/dist/transaction/consumeNotes.js.map +1 -1
- package/dist/transaction/noteAuthentication.d.ts +2 -3
- package/dist/transaction/noteAuthentication.d.ts.map +1 -1
- package/dist/transaction/noteAuthentication.js +11 -11
- package/dist/transaction/noteAuthentication.js.map +1 -1
- package/dist/transaction/options.d.ts +0 -7
- package/dist/transaction/options.d.ts.map +1 -1
- package/dist/transaction/p2id.d.ts +2 -3
- package/dist/transaction/p2id.d.ts.map +1 -1
- package/dist/transaction/p2id.js.map +1 -1
- package/dist/transaction/summary.d.ts +8 -14
- package/dist/transaction/summary.d.ts.map +1 -1
- package/dist/transaction/summary.js +64 -20
- package/dist/transaction/summary.js.map +1 -1
- package/dist/transaction/updateGuardian.d.ts +3 -7
- package/dist/transaction/updateGuardian.d.ts.map +1 -1
- package/dist/transaction/updateGuardian.js +3 -4
- package/dist/transaction/updateGuardian.js.map +1 -1
- package/dist/transaction/updateProcedureThreshold.d.ts +3 -8
- package/dist/transaction/updateProcedureThreshold.d.ts.map +1 -1
- package/dist/transaction/updateProcedureThreshold.js +3 -4
- package/dist/transaction/updateProcedureThreshold.js.map +1 -1
- package/dist/transaction/updateSigners.d.ts +3 -8
- package/dist/transaction/updateSigners.d.ts.map +1 -1
- package/dist/transaction/updateSigners.js +3 -4
- package/dist/transaction/updateSigners.js.map +1 -1
- package/package.json +4 -4
- package/src/account/builder.ts +6 -13
- package/src/client.ts +13 -10
- package/src/config.ts +14 -0
- package/src/index.ts +2 -3
- package/src/multisig.ts +125 -143
- package/src/procedures.ts +5 -5
- package/src/recovery/proposalNoteImport.ts +13 -15
- package/src/recovery/publicNoteBackfill.ts +6 -6
- package/src/transaction/authArgs.ts +15 -21
- package/src/transaction/consumeNotes.ts +6 -34
- package/src/transaction/noteAuthentication.ts +18 -13
- package/src/transaction/options.ts +0 -9
- package/src/transaction/p2id.ts +2 -3
- package/src/transaction/summary.ts +27 -69
- package/src/transaction/updateGuardian.ts +5 -23
- package/src/transaction/updateProcedureThreshold.ts +5 -25
- package/src/transaction/updateSigners.ts +5 -22
- package/dist/raw-client.d.ts +0 -14
- package/dist/raw-client.d.ts.map +0 -1
- package/dist/raw-client.js +0 -60
- package/dist/raw-client.js.map +0 -1
- package/src/raw-client.ts +0 -89
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChainAnchor, Word } from '@miden-sdk/miden-sdk';
|
|
2
2
|
import { BoundBlockNotDeclaredError } from '../multisig/authArgErrors.js';
|
|
3
|
-
import { getRawMidenClient } from '../raw-client.js';
|
|
4
3
|
import { base64ToUint8Array, normalizeHexWord, uint8ArrayToBase64 } from '../utils/encoding.js';
|
|
5
4
|
import { requestBoundBlockNum } from './authArgs.js';
|
|
6
5
|
/**
|
|
@@ -56,12 +55,23 @@ export function isStaleChainError(error) {
|
|
|
56
55
|
const message = error instanceof Error ? error.message : String(error);
|
|
57
56
|
return message.includes('has been pruned');
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Derives the summary awaiting authorization for a proposal the caller is
|
|
60
|
+
* creating now, and captures a `ChainAnchor` at the current sync height to ship
|
|
61
|
+
* with it.
|
|
62
|
+
*
|
|
63
|
+
* The summary is derived at the chain tip, like every other execution of a
|
|
64
|
+
* multisig proposal (see {@link executeForSummaryAtTip}). The anchor still
|
|
65
|
+
* travels in the proposal: it names the block the request's auth args bind,
|
|
66
|
+
* which is how a rebuild learns that block, and 0.18.0-rc.1 clients re-execute
|
|
67
|
+
* at it. A proposer builds at the sync height the anchor is captured at, and
|
|
68
|
+
* the check below is what makes that hold.
|
|
69
|
+
*/
|
|
70
|
+
export async function executeForSummary(client, accountId, txRequest) {
|
|
71
|
+
const anchor = await client.transactions.captureAnchor(txRequest);
|
|
62
72
|
let summary;
|
|
63
73
|
try {
|
|
64
|
-
summary = await executeForSummaryAtTip(
|
|
74
|
+
summary = await executeForSummaryAtTip(client, accountId, txRequest);
|
|
65
75
|
}
|
|
66
76
|
catch (error) {
|
|
67
77
|
anchor.free();
|
|
@@ -79,10 +89,32 @@ export async function executeForSummary(client, accountId, txRequest, midenRpcEn
|
|
|
79
89
|
}
|
|
80
90
|
return { summary, anchor };
|
|
81
91
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Executes a multisig request at the chain tip to obtain the summary awaiting
|
|
94
|
+
* authorization. This is how cosigners and the executor reproduce a proposal's
|
|
95
|
+
* summary, whatever block they have synced to.
|
|
96
|
+
*
|
|
97
|
+
* Since protocol 0.17 a multisig summary binds the block its auth args name
|
|
98
|
+
* (the bound block), not the block the transaction executes against, so it
|
|
99
|
+
* reproduces at any later tip once the bound block is in the transaction's
|
|
100
|
+
* partial blockchain. The request declares it through `withBlockNumbers`, and
|
|
101
|
+
* foreign accounts, the fee faucet among them, load at the tip. Re-executing at
|
|
102
|
+
* the proposal's anchor instead loads them at the bound block, which a node
|
|
103
|
+
* prunes about 50 blocks later (issue #462).
|
|
104
|
+
*
|
|
105
|
+
* The client has to have synced to at least the bound block. When it has not,
|
|
106
|
+
* this syncs once before executing.
|
|
107
|
+
*
|
|
108
|
+
* @throws BoundBlockNotDeclaredError when the request binds a block in its
|
|
109
|
+
* multisig auth args without declaring it.
|
|
110
|
+
*/
|
|
111
|
+
export async function executeForSummaryAtTip(client, accountId, txRequest) {
|
|
112
|
+
await prepareTipExecution(client, txRequest);
|
|
113
|
+
return client.transactions.preview({
|
|
114
|
+
operation: 'custom',
|
|
115
|
+
account: accountId,
|
|
116
|
+
request: txRequest,
|
|
117
|
+
});
|
|
86
118
|
}
|
|
87
119
|
/**
|
|
88
120
|
* Gets `client` ready to execute `request` at the chain tip: checks the
|
|
@@ -92,10 +124,10 @@ export async function executeForSummaryAtTip(client, accountId, txRequest, miden
|
|
|
92
124
|
* @throws BoundBlockNotDeclaredError when the request binds a block in its
|
|
93
125
|
* multisig auth args without declaring it.
|
|
94
126
|
*/
|
|
95
|
-
export async function prepareTipExecution(client, request,
|
|
127
|
+
export async function prepareTipExecution(client, request, syncChain) {
|
|
96
128
|
const boundBlockNum = requireDeclaredBoundBlock(request);
|
|
97
129
|
if (boundBlockNum !== undefined) {
|
|
98
|
-
await syncToBoundBlock(client, boundBlockNum,
|
|
130
|
+
await syncToBoundBlock(client, boundBlockNum, syncChain);
|
|
99
131
|
}
|
|
100
132
|
}
|
|
101
133
|
/**
|
|
@@ -117,8 +149,8 @@ export function requireDeclaredBoundBlock(request) {
|
|
|
117
149
|
* proposal binds. Execution at a tip below it fails with "requested block N is
|
|
118
150
|
* after transaction reference block M", and a store that has never synced (a
|
|
119
151
|
* cosigner that has only just loaded the account) holds no header to rebuild
|
|
120
|
-
* the request from. `
|
|
121
|
-
* policy.
|
|
152
|
+
* the request from. The sync is a chain sync; `syncChain` lets a caller wrap
|
|
153
|
+
* it in its own retry policy.
|
|
122
154
|
*
|
|
123
155
|
* This does not make a store that is already past the bound block current. An
|
|
124
156
|
* execution loads foreign accounts, the fee faucet among them, at the store's
|
|
@@ -127,20 +159,32 @@ export function requireDeclaredBoundBlock(request) {
|
|
|
127
159
|
*
|
|
128
160
|
* @throws ChainBehindBoundBlockError when the node has not reached the block.
|
|
129
161
|
*/
|
|
130
|
-
export async function syncToBoundBlock(client, blockNum,
|
|
162
|
+
export async function syncToBoundBlock(client, blockNum, syncChain = () => client.syncChain()) {
|
|
131
163
|
if ((await client.getSyncHeight()) >= blockNum) {
|
|
132
164
|
return;
|
|
133
165
|
}
|
|
134
|
-
await
|
|
166
|
+
await syncChain();
|
|
135
167
|
const syncHeight = await client.getSyncHeight();
|
|
136
168
|
if (syncHeight < blockNum) {
|
|
137
169
|
throw new ChainBehindBoundBlockError({ syncHeight, boundBlockNum: blockNum });
|
|
138
170
|
}
|
|
139
171
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Executes a transaction at the given `ChainAnchor`'s reference block to
|
|
174
|
+
* obtain the summary awaiting authorization.
|
|
175
|
+
*
|
|
176
|
+
* For a summary that binds the reference block, such as a single-signature
|
|
177
|
+
* one. A multisig proposal's summary binds its bound block instead and is
|
|
178
|
+
* reproduced with {@link executeForSummaryAtTip}: re-executing it at an anchor
|
|
179
|
+
* fails once the node prunes the anchor block's account state.
|
|
180
|
+
*/
|
|
181
|
+
export async function executeForSummaryAt(client, accountId, txRequest, anchor) {
|
|
182
|
+
return client.transactions.preview({
|
|
183
|
+
operation: 'custom',
|
|
184
|
+
account: accountId,
|
|
185
|
+
request: txRequest,
|
|
186
|
+
anchor,
|
|
187
|
+
});
|
|
144
188
|
}
|
|
145
189
|
/**
|
|
146
190
|
* Serializes a `ChainAnchor` to base64 for the proposal wire payload.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/transaction/summary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/transaction/summary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD;;;;GAIG;AACH,MAAM,oCAAoC,GAAG,CAAC,CAAC;AAC/C,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,SAAS,GAAG,IAAI,CAAC;IAE1B,YAAY,OAA2E;QACrF,KAAK,CACH,kDAAkD,OAAO,CAAC,yBAAyB,OAAO;YACxF,gCAAgC,OAAO,CAAC,mBAAmB,0BAA0B;YACrF,iFAAiF,CACpF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC3C,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC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AAmB,CAAC,YAAoB;IACtD,MAAM,MAAM,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACnD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACrD,OAAO,IAAI,CAAC,YAAY,CACtB,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,CAAC,CAAC,CAC/E,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAAC,OAA2B;IAC3E,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,oCAAoC,CAAC,CAAC,KAAK,EAAE,CAAC;IACjF,OAAO,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { type MidenClient, TransactionRequest,
|
|
2
|
-
import type {
|
|
3
|
-
export declare function buildUpdateGuardianTransactionRequest(client: MidenClient, newGuardianPubkey: string, options:
|
|
4
|
-
request: TransactionRequest;
|
|
5
|
-
salt: Word;
|
|
6
|
-
}>;
|
|
7
|
-
export declare function buildUpdateGuardianTransactionRequest(client: WasmWebClient, newGuardianPubkey: string, options: MultisigRequestOptions): Promise<{
|
|
1
|
+
import { type MidenClient, TransactionRequest, Word } from '@miden-sdk/miden-sdk';
|
|
2
|
+
import type { MultisigRequestOptions } from './options.js';
|
|
3
|
+
export declare function buildUpdateGuardianTransactionRequest(client: MidenClient, newGuardianPubkey: string, options: MultisigRequestOptions): Promise<{
|
|
8
4
|
request: TransactionRequest;
|
|
9
5
|
salt: Word;
|
|
10
6
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateGuardian.d.ts","sourceRoot":"","sources":["../../src/transaction/updateGuardian.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,kBAAkB,EAElB,
|
|
1
|
+
{"version":3,"file":"updateGuardian.d.ts","sourceRoot":"","sources":["../../src/transaction/updateGuardian.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,kBAAkB,EAElB,IAAI,EACL,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AA6B3D,wBAAsB,qCAAqC,CACzD,MAAM,EAAE,WAAW,EACnB,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAYtD"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { compileTxScript } from '../raw-client.js';
|
|
2
1
|
import { normalizeHexWord } from '../utils/encoding.js';
|
|
3
2
|
import { authSchemeId } from '../utils/signature.js';
|
|
4
3
|
import { buildMultisigRequest, multisigRequestBuilder } from './authArgs.js';
|
|
5
|
-
async function buildUpdateGuardianScript(client, newGuardianPubkey, signatureScheme
|
|
4
|
+
async function buildUpdateGuardianScript(client, newGuardianPubkey, signatureScheme) {
|
|
6
5
|
// A word literal preserves the key's element order on the operand stack.
|
|
7
6
|
const keyLiteral = normalizeHexWord(newGuardianPubkey);
|
|
8
7
|
const schemeId = authSchemeId(signatureScheme);
|
|
@@ -19,11 +18,11 @@ pub proc main
|
|
|
19
18
|
dropw
|
|
20
19
|
end
|
|
21
20
|
`;
|
|
22
|
-
return
|
|
21
|
+
return client.compile.txScript({ code: scriptSource });
|
|
23
22
|
}
|
|
24
23
|
export async function buildUpdateGuardianTransactionRequest(client, newGuardianPubkey, options) {
|
|
25
24
|
const signatureScheme = options.signatureScheme ?? 'falcon';
|
|
26
|
-
const script = await buildUpdateGuardianScript(client, newGuardianPubkey, signatureScheme
|
|
25
|
+
const script = await buildUpdateGuardianScript(client, newGuardianPubkey, signatureScheme);
|
|
27
26
|
const { builder, saltHex } = await multisigRequestBuilder(client, options);
|
|
28
27
|
let txBuilder = builder.withCustomScript(script);
|
|
29
28
|
if (options.signatureAdviceMap) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateGuardian.js","sourceRoot":"","sources":["../../src/transaction/updateGuardian.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateGuardian.js","sourceRoot":"","sources":["../../src/transaction/updateGuardian.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAI7E,KAAK,UAAU,yBAAyB,CACtC,MAAmB,EACnB,iBAAyB,EACzB,eAAgC;IAEhC,yEAAyE;IACzE,MAAM,UAAU,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;IAE/C,qFAAqF;IACrF,MAAM,YAAY,GAAG;;;;;WAKZ,UAAU;WACV,QAAQ;;;;;GAKhB,CAAC;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,MAAmB,EACnB,iBAAyB,EACzB,OAA+B;IAE/B,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,QAAQ,CAAC;IAC5D,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;IAE3F,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3E,IAAI,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAEjD,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,OAAO,CAAC,SAAS,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { type MidenClient, TransactionRequest,
|
|
1
|
+
import { type MidenClient, TransactionRequest, Word } from '@miden-sdk/miden-sdk';
|
|
2
2
|
import { type ProcedureName } from '../procedures.js';
|
|
3
|
-
import type {
|
|
4
|
-
export declare function buildUpdateProcedureThresholdTransactionRequest(client: MidenClient, procedure: ProcedureName, threshold: number, options:
|
|
5
|
-
request: TransactionRequest;
|
|
6
|
-
salt: Word;
|
|
7
|
-
configHash: Word;
|
|
8
|
-
}>;
|
|
9
|
-
export declare function buildUpdateProcedureThresholdTransactionRequest(client: WasmWebClient, procedure: ProcedureName, threshold: number, options: MultisigRequestOptions): Promise<{
|
|
3
|
+
import type { MultisigRequestOptions } from './options.js';
|
|
4
|
+
export declare function buildUpdateProcedureThresholdTransactionRequest(client: MidenClient, procedure: ProcedureName, threshold: number, options: MultisigRequestOptions): Promise<{
|
|
10
5
|
request: TransactionRequest;
|
|
11
6
|
salt: Word;
|
|
12
7
|
configHash: Word;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateProcedureThreshold.d.ts","sourceRoot":"","sources":["../../src/transaction/updateProcedureThreshold.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAEhB,kBAAkB,EAElB,
|
|
1
|
+
{"version":3,"file":"updateProcedureThreshold.d.ts","sourceRoot":"","sources":["../../src/transaction/updateProcedureThreshold.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EAEhB,kBAAkB,EAElB,IAAI,EAEL,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AA+C3D,wBAAsB,+CAA+C,CACnE,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,IAAI,CAAA;CAAE,CAAC,CAYxE"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Felt, FeltArray, Poseidon2, Word as WordType, } from '@miden-sdk/miden-sdk';
|
|
2
2
|
import { getProcedureRoot } from '../procedures.js';
|
|
3
|
-
import { compileTxScript } from '../raw-client.js';
|
|
4
3
|
import { normalizeHexWord } from '../utils/encoding.js';
|
|
5
4
|
import { buildMultisigRequest, multisigRequestBuilder } from './authArgs.js';
|
|
6
5
|
function buildProcedureThresholdFelts(procedure, threshold) {
|
|
@@ -21,7 +20,7 @@ function buildProcedureThresholdFelts(procedure, threshold) {
|
|
|
21
20
|
function buildProcedureThresholdConfigHash(procedure, threshold) {
|
|
22
21
|
return Poseidon2.hashElements(new FeltArray(buildProcedureThresholdFelts(procedure, threshold)));
|
|
23
22
|
}
|
|
24
|
-
async function buildUpdateProcedureThresholdScript(client, procedure, threshold
|
|
23
|
+
async function buildUpdateProcedureThresholdScript(client, procedure, threshold) {
|
|
25
24
|
const procedureRoot = normalizeHexWord(getProcedureRoot(procedure));
|
|
26
25
|
const scriptSource = `
|
|
27
26
|
use miden::standards::auth::multisig
|
|
@@ -35,11 +34,11 @@ pub proc main
|
|
|
35
34
|
drop
|
|
36
35
|
end
|
|
37
36
|
`;
|
|
38
|
-
return
|
|
37
|
+
return client.compile.txScript({ code: scriptSource });
|
|
39
38
|
}
|
|
40
39
|
export async function buildUpdateProcedureThresholdTransactionRequest(client, procedure, threshold, options) {
|
|
41
40
|
const configHash = buildProcedureThresholdConfigHash(procedure, threshold);
|
|
42
|
-
const script = await buildUpdateProcedureThresholdScript(client, procedure, threshold
|
|
41
|
+
const script = await buildUpdateProcedureThresholdScript(client, procedure, threshold);
|
|
43
42
|
const { builder, saltHex } = await multisigRequestBuilder(client, options);
|
|
44
43
|
let txBuilder = builder.withCustomScript(script);
|
|
45
44
|
if (options.signatureAdviceMap) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateProcedureThreshold.js","sourceRoot":"","sources":["../../src/transaction/updateProcedureThreshold.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,SAAS,EAET,SAAS,
|
|
1
|
+
{"version":3,"file":"updateProcedureThreshold.js","sourceRoot":"","sources":["../../src/transaction/updateProcedureThreshold.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,SAAS,EAET,SAAS,EAIT,IAAI,IAAI,QAAQ,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAsB,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG7E,SAAS,4BAA4B,CAAC,SAAwB,EAAE,SAAiB;IAC/E,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtF,OAAO;QACL,GAAG,aAAa,CAAC,OAAO,EAAE;QAC1B,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC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AAO,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,CAAC;AACxF,CAAC"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { FeltArray, type MidenClient, TransactionRequest,
|
|
2
|
-
import type {
|
|
1
|
+
import { FeltArray, type MidenClient, TransactionRequest, Word } from '@miden-sdk/miden-sdk';
|
|
2
|
+
import type { MultisigRequestOptions } from './options.js';
|
|
3
3
|
import type { SignatureScheme } from '../types.js';
|
|
4
4
|
export declare function buildMultisigConfigAdvice(threshold: number, signerCommitments: string[], signatureScheme: SignatureScheme): {
|
|
5
5
|
configHash: Word;
|
|
6
6
|
payload: FeltArray;
|
|
7
7
|
};
|
|
8
|
-
export declare function buildUpdateSignersTransactionRequest(client: MidenClient, threshold: number, signerCommitments: string[], options:
|
|
9
|
-
request: TransactionRequest;
|
|
10
|
-
salt: Word;
|
|
11
|
-
configHash: Word;
|
|
12
|
-
}>;
|
|
13
|
-
export declare function buildUpdateSignersTransactionRequest(client: WasmWebClient, threshold: number, signerCommitments: string[], options: MultisigRequestOptions): Promise<{
|
|
8
|
+
export declare function buildUpdateSignersTransactionRequest(client: MidenClient, threshold: number, signerCommitments: string[], options: MultisigRequestOptions): Promise<{
|
|
14
9
|
request: TransactionRequest;
|
|
15
10
|
salt: Word;
|
|
16
11
|
configHash: Word;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateSigners.d.ts","sourceRoot":"","sources":["../../src/transaction/updateSigners.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EACT,KAAK,WAAW,EAEhB,kBAAkB,EAElB,
|
|
1
|
+
{"version":3,"file":"updateSigners.d.ts","sourceRoot":"","sources":["../../src/transaction/updateSigners.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EACT,KAAK,WAAW,EAEhB,kBAAkB,EAElB,IAAI,EAEL,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwBnD,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,EAAE,EAC3B,eAAe,EAAE,eAAe,GAC/B;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,SAAS,CAAA;CAAE,CAW1C;AAeD,wBAAsB,oCAAoC,CACxD,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,EAAE,EAC3B,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,IAAI,CAAA;CAAE,CAAC,CAuCxE"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AdviceMap, Felt, FeltArray, Poseidon2, Word as WordType, } from '@miden-sdk/miden-sdk';
|
|
2
|
-
import { compileTxScript } from '../raw-client.js';
|
|
3
2
|
import { normalizeHexWord } from '../utils/encoding.js';
|
|
4
3
|
import { authSchemeId } from '../utils/signature.js';
|
|
5
4
|
import { buildMultisigRequest, multisigRequestBuilder } from './authArgs.js';
|
|
@@ -28,7 +27,7 @@ export function buildMultisigConfigAdvice(threshold, signerCommitments, signatur
|
|
|
28
27
|
const payload = new FeltArray(buildMultisigConfigFelts(threshold, signerCommitments, signatureScheme));
|
|
29
28
|
return { configHash, payload };
|
|
30
29
|
}
|
|
31
|
-
async function buildUpdateSignersScript(client
|
|
30
|
+
async function buildUpdateSignersScript(client) {
|
|
32
31
|
const scriptSource = `
|
|
33
32
|
use miden::standards::auth::multisig
|
|
34
33
|
|
|
@@ -37,7 +36,7 @@ pub proc main
|
|
|
37
36
|
call.multisig::update_signers_and_threshold
|
|
38
37
|
end
|
|
39
38
|
`;
|
|
40
|
-
return
|
|
39
|
+
return client.compile.txScript({ code: scriptSource });
|
|
41
40
|
}
|
|
42
41
|
export async function buildUpdateSignersTransactionRequest(client, threshold, signerCommitments, options) {
|
|
43
42
|
const signatureScheme = options.signatureScheme ?? 'falcon';
|
|
@@ -46,7 +45,7 @@ export async function buildUpdateSignersTransactionRequest(client, threshold, si
|
|
|
46
45
|
const { configHash: configHashForReturn } = buildMultisigConfigAdvice(threshold, signerCommitments, signatureScheme);
|
|
47
46
|
const advice = new AdviceMap();
|
|
48
47
|
advice.insert(configHashForAdvice, payload);
|
|
49
|
-
const script = await buildUpdateSignersScript(client
|
|
48
|
+
const script = await buildUpdateSignersScript(client);
|
|
50
49
|
const { builder, saltHex } = await multisigRequestBuilder(client, options);
|
|
51
50
|
let txBuilder = builder
|
|
52
51
|
.withCustomScript(script)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateSigners.js","sourceRoot":"","sources":["../../src/transaction/updateSigners.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,SAAS,EAET,SAAS,
|
|
1
|
+
{"version":3,"file":"updateSigners.js","sourceRoot":"","sources":["../../src/transaction/updateSigners.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,SAAS,EAET,SAAS,EAIT,IAAI,IAAI,QAAQ,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAI7E,SAAS,wBAAwB,CAC/B,SAAiB,EACjB,iBAA2B,EAC3B,eAAgC;IAEhC,MAAM,YAAY,GAAG,iBAAiB,CAAC,MAAM,CAAC;IAC9C,MAAM,QAAQ,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAW;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,SAA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1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openzeppelin/miden-multisig-client",
|
|
3
|
-
"version": "0.18.0-rc.
|
|
3
|
+
"version": "0.18.0-rc.3",
|
|
4
4
|
"description": "TypeScript SDK for Miden multisig accounts with GUARDIAN integration",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"test:qualification": "vitest run --config vitest.qualification.config.ts"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@miden-sdk/miden-sdk": "0.17.0-rc.
|
|
45
|
+
"@miden-sdk/miden-sdk": "0.17.0-rc.5",
|
|
46
46
|
"@noble/curves": "^1.9.7",
|
|
47
47
|
"@noble/hashes": "^2.0.1",
|
|
48
|
-
"@openzeppelin/guardian-client": "^0.18.0-rc.
|
|
48
|
+
"@openzeppelin/guardian-client": "^0.18.0-rc.3"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@openzeppelin/guardian-operator-client": "^0.18.0-rc.
|
|
51
|
+
"@openzeppelin/guardian-operator-client": "^0.18.0-rc.3",
|
|
52
52
|
"@playwright/test": "^1.60.0",
|
|
53
53
|
"@types/node": "^24.13.5",
|
|
54
54
|
"fake-indexeddb": "^6.2.5",
|
package/src/account/builder.ts
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
type MidenClient,
|
|
16
16
|
} from "@miden-sdk/miden-sdk";
|
|
17
17
|
import { getProcedureRoot } from "../procedures.js";
|
|
18
|
-
import { isPublicMidenClient, type RawClientSource } from "../raw-client.js";
|
|
19
18
|
import { MAX_SIGNERS } from "./layout.js";
|
|
20
19
|
import type { MultisigConfig, CreateAccountResult } from "../types.js";
|
|
21
20
|
import { normalizeSignerCommitment } from "../utils/signature.js";
|
|
@@ -84,15 +83,13 @@ function buildGuardedMultisigComponent(
|
|
|
84
83
|
/**
|
|
85
84
|
* Creates a multisig account with GUARDIAN authentication.
|
|
86
85
|
*
|
|
87
|
-
* @param client - Initialized MidenClient
|
|
86
|
+
* @param client - Initialized MidenClient
|
|
88
87
|
* @param config - Multisig configuration
|
|
89
|
-
* @param midenRpcEndpoint - RPC endpoint for the client's network
|
|
90
88
|
* @returns The created account and seed
|
|
91
89
|
*/
|
|
92
90
|
export async function createMultisigAccount(
|
|
93
|
-
client:
|
|
91
|
+
client: MidenClient,
|
|
94
92
|
config: MultisigConfig,
|
|
95
|
-
midenRpcEndpoint: string,
|
|
96
93
|
): Promise<CreateAccountResult> {
|
|
97
94
|
validateMultisigConfig(config);
|
|
98
95
|
const authComponent = buildGuardedMultisigComponent(config);
|
|
@@ -117,14 +114,10 @@ export async function createMultisigAccount(
|
|
|
117
114
|
|
|
118
115
|
const result = accountBuilder.buildWithoutSchemaCommitment();
|
|
119
116
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
} else {
|
|
126
|
-
await client.newAccount(result.account, false);
|
|
127
|
-
}
|
|
117
|
+
await client.accounts.insert({
|
|
118
|
+
account: result.account,
|
|
119
|
+
overwrite: false,
|
|
120
|
+
});
|
|
128
121
|
|
|
129
122
|
return {
|
|
130
123
|
account: result.account,
|
package/src/client.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { StateObject } from '@openzeppelin/guardian-client';
|
|
|
11
11
|
import { Multisig } from './multisig.js';
|
|
12
12
|
import { createMultisigAccount } from './account/index.js';
|
|
13
13
|
import { AccountInspector, assertCompleteDetectedConfig } from './inspector.js';
|
|
14
|
-
import {
|
|
14
|
+
import { requireConfigValue, requireMidenRpcEndpoint } from './config.js';
|
|
15
15
|
import type { MultisigConfig, Signer } from './types.js';
|
|
16
16
|
import { isSafeToAdoptGuardianState, readOnChainCommitment } from './state/adopt.js';
|
|
17
17
|
import { normalizeHexWord } from './utils/encoding.js';
|
|
@@ -48,9 +48,11 @@ export interface MultisigClientConfig {
|
|
|
48
48
|
/** GUARDIAN server endpoint. Required — there is no default. */
|
|
49
49
|
guardianEndpoint: string;
|
|
50
50
|
/**
|
|
51
|
-
* Miden node RPC endpoint
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* Miden node RPC endpoint the SDK reads directly: on-chain commitments for
|
|
52
|
+
* state verification, and note inclusion proofs for consume-notes proposals
|
|
53
|
+
* and note recovery. Everything else, execution included, goes through the
|
|
54
|
+
* injected `MidenClient`. Required — must point at the same network as the
|
|
55
|
+
* injected `MidenClient`; there is no default.
|
|
54
56
|
*/
|
|
55
57
|
midenRpcEndpoint: string;
|
|
56
58
|
/** Multisig-owned remote prover override and proof retry policy. */
|
|
@@ -72,13 +74,18 @@ export interface RecoveredAccount {
|
|
|
72
74
|
/**
|
|
73
75
|
* Client for creating and loading multisig accounts.
|
|
74
76
|
*
|
|
77
|
+
* In a browser, create the injected `MidenClient` with `useWorker: false` until
|
|
78
|
+
* https://github.com/0xMiden/web-sdk/issues/441 is fixed: a worker-mode client
|
|
79
|
+
* applies transactions in a Web Worker that never sees the account state this
|
|
80
|
+
* SDK writes.
|
|
81
|
+
*
|
|
75
82
|
* @example
|
|
76
83
|
* ```typescript
|
|
77
84
|
* import { MultisigClient, FalconSigner } from '@openzeppelin/miden-multisig-client';
|
|
78
85
|
* import { MidenClient, AuthSecretKey } from '@miden-sdk/miden-sdk';
|
|
79
86
|
*
|
|
80
87
|
* // Initialize
|
|
81
|
-
* const midenClient = await MidenClient.createDevnet();
|
|
88
|
+
* const midenClient = await MidenClient.createDevnet({ useWorker: false });
|
|
82
89
|
* const secretKey = AuthSecretKey.rpoFalconWithRNG(seed);
|
|
83
90
|
* const signer = new FalconSigner(secretKey);
|
|
84
91
|
*
|
|
@@ -170,11 +177,7 @@ export class MultisigClient {
|
|
|
170
177
|
async create(config: MultisigConfig, signer: Signer): Promise<Multisig> {
|
|
171
178
|
this._guardianClient.setSigner(signer);
|
|
172
179
|
|
|
173
|
-
const { account } = await createMultisigAccount(
|
|
174
|
-
this.midenClient,
|
|
175
|
-
config,
|
|
176
|
-
this.midenRpcEndpoint,
|
|
177
|
-
);
|
|
180
|
+
const { account } = await createMultisigAccount(this.midenClient, config);
|
|
178
181
|
const accountId = account.id().toString();
|
|
179
182
|
await bindSignerAccountKey(signer, this.midenClient, accountId);
|
|
180
183
|
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function requireConfigValue(field: string, value?: unknown): string {
|
|
2
|
+
if (typeof value !== 'string') {
|
|
3
|
+
throw new Error(`missing required configuration: ${field}`);
|
|
4
|
+
}
|
|
5
|
+
const normalizedValue = value.trim();
|
|
6
|
+
if (normalizedValue === '') {
|
|
7
|
+
throw new Error(`missing required configuration: ${field}`);
|
|
8
|
+
}
|
|
9
|
+
return normalizedValue;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function requireMidenRpcEndpoint(endpoint?: string): string {
|
|
13
|
+
return requireConfigValue('midenRpcEndpoint', endpoint);
|
|
14
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* } from '@openzeppelin/miden-multisig-client';
|
|
12
12
|
* import { MidenClient, AuthSecretKey } from '@miden-sdk/miden-sdk';
|
|
13
13
|
*
|
|
14
|
-
* const midenClient = await MidenClient.createDevnet();
|
|
14
|
+
* const midenClient = await MidenClient.createDevnet({ useWorker: false });
|
|
15
15
|
* const secretKey = AuthSecretKey.rpoFalconWithRNG(undefined);
|
|
16
16
|
*
|
|
17
17
|
* // Store in miden-sdk's keystore
|
|
@@ -59,6 +59,7 @@ export { lookupAuthDigest } from './lookupAuth.js';
|
|
|
59
59
|
export {
|
|
60
60
|
Multisig,
|
|
61
61
|
type AccountState,
|
|
62
|
+
type SyncStateResult,
|
|
62
63
|
type CreateProposalOptions,
|
|
63
64
|
type CreateSignerProposalOptions,
|
|
64
65
|
type CreateP2idProposalOptions,
|
|
@@ -95,8 +96,6 @@ export {
|
|
|
95
96
|
// hex, directly comparable to `ExportedProposal.commitment` / `Proposal.id`.
|
|
96
97
|
export { computeCommitmentFromTxSummary } from './multisig/helpers.js';
|
|
97
98
|
export type {
|
|
98
|
-
MidenClientMultisigRequestOptions,
|
|
99
|
-
MidenClientSignatureOptions,
|
|
100
99
|
MultisigRequestOptions,
|
|
101
100
|
SignatureOptions,
|
|
102
101
|
} from './transaction/options.js';
|