@openzeppelin/miden-multisig-client 0.13.0 → 0.13.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.
- package/README.md +98 -119
- package/dist/account/builder.d.ts +18 -0
- package/dist/account/builder.d.ts.map +1 -1
- package/dist/account/builder.js +59 -29
- package/dist/account/builder.js.map +1 -1
- package/dist/account/builder.test.d.ts +2 -0
- package/dist/account/builder.test.d.ts.map +1 -0
- package/dist/account/builder.test.js +115 -0
- package/dist/account/builder.test.js.map +1 -0
- package/dist/account/index.d.ts +1 -1
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +1 -1
- package/dist/account/index.js.map +1 -1
- package/dist/account/masm/account-components/auth.d.ts +5 -0
- package/dist/account/masm/account-components/auth.d.ts.map +1 -0
- package/dist/account/masm/account-components/auth.js +67 -0
- package/dist/account/masm/account-components/auth.js.map +1 -0
- package/dist/account/masm/auth.d.ts +5 -0
- package/dist/account/masm/auth.d.ts.map +1 -0
- package/dist/account/masm/auth.js +1395 -0
- package/dist/account/masm/auth.js.map +1 -0
- package/dist/account/masm/index.d.ts +3 -0
- package/dist/account/masm/index.d.ts.map +1 -0
- package/dist/account/masm/index.js +5 -0
- package/dist/account/masm/index.js.map +1 -0
- package/dist/account/masm.d.ts +1 -4
- package/dist/account/masm.d.ts.map +1 -1
- package/dist/account/masm.js +3 -1034
- package/dist/account/masm.js.map +1 -1
- package/dist/account/storage.d.ts +2 -2
- package/dist/account/storage.d.ts.map +1 -1
- package/dist/account/storage.js +18 -16
- package/dist/account/storage.js.map +1 -1
- package/dist/client.d.ts +67 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +73 -22
- package/dist/client.js.map +1 -1
- package/dist/client.test.js +31 -32
- package/dist/client.test.js.map +1 -1
- package/dist/index.d.ts +54 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -9
- package/dist/index.js.map +1 -1
- package/dist/inspector.d.ts +32 -6
- package/dist/inspector.d.ts.map +1 -1
- package/dist/inspector.js +58 -23
- package/dist/inspector.js.map +1 -1
- package/dist/inspector.test.js +18 -18
- package/dist/inspector.test.js.map +1 -1
- package/dist/multisig/proposal/execution.d.ts +6 -5
- package/dist/multisig/proposal/execution.d.ts.map +1 -1
- package/dist/multisig/proposal/execution.js +49 -27
- package/dist/multisig/proposal/execution.js.map +1 -1
- package/dist/multisig/proposal/parser.d.ts +3 -3
- package/dist/multisig/proposal/parser.d.ts.map +1 -1
- package/dist/multisig/proposal/parser.js +23 -23
- package/dist/multisig/proposal/parser.js.map +1 -1
- package/dist/multisig/signing.d.ts +3 -3
- package/dist/multisig/signing.d.ts.map +1 -1
- package/dist/multisig/signing.js +3 -3
- package/dist/multisig/signing.js.map +1 -1
- package/dist/multisig.d.ts +187 -46
- package/dist/multisig.d.ts.map +1 -1
- package/dist/multisig.js +650 -289
- package/dist/multisig.js.map +1 -1
- package/dist/multisig.test.js +1680 -241
- package/dist/multisig.test.js.map +1 -1
- package/dist/procedures.d.ts +46 -24
- package/dist/procedures.d.ts.map +1 -1
- package/dist/procedures.js +46 -21
- package/dist/procedures.js.map +1 -1
- package/dist/proposal/factory.d.ts +18 -0
- package/dist/proposal/factory.d.ts.map +1 -0
- package/dist/proposal/factory.js +99 -0
- package/dist/proposal/factory.js.map +1 -0
- package/dist/proposal/metadata.d.ts +8 -0
- package/dist/proposal/metadata.d.ts.map +1 -0
- package/dist/proposal/metadata.js +156 -0
- package/dist/proposal/metadata.js.map +1 -0
- package/dist/proposal/signatures.d.ts +10 -0
- package/dist/proposal/signatures.d.ts.map +1 -0
- package/dist/proposal/signatures.js +54 -0
- package/dist/proposal/signatures.js.map +1 -0
- package/dist/signer.d.ts +2 -0
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +2 -0
- package/dist/signer.js.map +1 -1
- package/dist/signers/ecdsa.d.ts +3 -0
- package/dist/signers/ecdsa.d.ts.map +1 -1
- package/dist/signers/ecdsa.js +8 -4
- package/dist/signers/ecdsa.js.map +1 -1
- package/dist/signers/ecdsa.test.d.ts +2 -0
- package/dist/signers/ecdsa.test.d.ts.map +1 -0
- package/dist/signers/ecdsa.test.js +65 -0
- package/dist/signers/ecdsa.test.js.map +1 -0
- package/dist/signers/falcon.d.ts +3 -0
- package/dist/signers/falcon.d.ts.map +1 -1
- package/dist/signers/falcon.js +8 -4
- package/dist/signers/falcon.js.map +1 -1
- package/dist/signers/falcon.test.js +12 -0
- package/dist/signers/falcon.test.js.map +1 -1
- package/dist/signers/miden-wallet.d.ts +3 -1
- package/dist/signers/miden-wallet.d.ts.map +1 -1
- package/dist/signers/miden-wallet.js +11 -2
- package/dist/signers/miden-wallet.js.map +1 -1
- package/dist/signers/miden-wallet.test.js +26 -0
- package/dist/signers/miden-wallet.test.js.map +1 -1
- package/dist/signers/para.d.ts +3 -3
- package/dist/signers/para.d.ts.map +1 -1
- package/dist/signers/para.js +15 -6
- package/dist/signers/para.js.map +1 -1
- package/dist/signers/para.test.js +39 -0
- package/dist/signers/para.test.js.map +1 -1
- package/dist/transaction/consumeNotes.d.ts.map +1 -1
- package/dist/transaction/consumeNotes.js +1 -0
- package/dist/transaction/consumeNotes.js.map +1 -1
- package/dist/transaction/index.d.ts +2 -1
- package/dist/transaction/index.d.ts.map +1 -1
- package/dist/transaction/index.js +2 -1
- package/dist/transaction/index.js.map +1 -1
- package/dist/transaction/options.d.ts +1 -1
- package/dist/transaction/options.d.ts.map +1 -1
- package/dist/transaction/p2id.d.ts +1 -0
- package/dist/transaction/p2id.d.ts.map +1 -1
- package/dist/transaction/p2id.js +9 -3
- package/dist/transaction/p2id.js.map +1 -1
- package/dist/transaction/p2id.test.d.ts +2 -0
- package/dist/transaction/p2id.test.d.ts.map +1 -0
- package/dist/transaction/p2id.test.js +138 -0
- package/dist/transaction/p2id.test.js.map +1 -0
- package/dist/transaction/rpoRandomCoin.d.ts +7 -0
- package/dist/transaction/rpoRandomCoin.d.ts.map +1 -0
- package/dist/transaction/rpoRandomCoin.js +17 -0
- package/dist/transaction/rpoRandomCoin.js.map +1 -0
- package/dist/transaction/rpoRandomCoin.test.d.ts +2 -0
- package/dist/transaction/rpoRandomCoin.test.d.ts.map +1 -0
- package/dist/transaction/rpoRandomCoin.test.js +52 -0
- package/dist/transaction/rpoRandomCoin.test.js.map +1 -0
- package/dist/transaction/updateGuardian.d.ts +7 -0
- package/dist/transaction/updateGuardian.d.ts.map +1 -0
- package/dist/transaction/{updatePsm.js → updateGuardian.js} +15 -29
- package/dist/transaction/updateGuardian.js.map +1 -0
- package/dist/transaction/updateProcedureThreshold.d.ts +9 -0
- package/dist/transaction/updateProcedureThreshold.d.ts.map +1 -0
- package/dist/transaction/updateProcedureThreshold.js +55 -0
- package/dist/transaction/updateProcedureThreshold.js.map +1 -0
- package/dist/transaction/updateSigners.d.ts.map +1 -1
- package/dist/transaction/updateSigners.js +5 -23
- package/dist/transaction/updateSigners.js.map +1 -1
- package/dist/transaction.d.ts +2 -1
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +2 -1
- package/dist/transaction.js.map +1 -1
- package/dist/types/proposal.d.ts +32 -15
- package/dist/types/proposal.d.ts.map +1 -1
- package/dist/types.d.ts +24 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/digest.d.ts +5 -0
- package/dist/utils/digest.d.ts.map +1 -1
- package/dist/utils/digest.js +34 -1
- package/dist/utils/digest.js.map +1 -1
- package/dist/utils/digest.test.d.ts +2 -0
- package/dist/utils/digest.test.d.ts.map +1 -0
- package/dist/utils/digest.test.js +48 -0
- package/dist/utils/digest.test.js.map +1 -0
- package/dist/utils/signature.d.ts +3 -1
- package/dist/utils/signature.d.ts.map +1 -1
- package/dist/utils/signature.js +31 -6
- package/dist/utils/signature.js.map +1 -1
- package/dist/utils/word.test.js +1 -52
- package/dist/utils/word.test.js.map +1 -1
- package/masm/account_components/auth/multisig.masm +13 -0
- package/masm/account_components/auth/multisig_ecdsa.masm +13 -0
- package/masm/account_components/auth/multisig_guardian.masm +17 -0
- package/masm/account_components/auth/multisig_guardian_ecdsa.masm +17 -0
- package/masm/auth/guardian.masm +177 -0
- package/masm/auth/guardian_ecdsa.masm +178 -0
- package/masm/{multisig.masm → auth/multisig.masm} +149 -55
- package/masm/{multisig_ecdsa.masm → auth/multisig_ecdsa.masm} +148 -56
- package/package.json +11 -9
- package/src/account/builder.test.ts +165 -0
- package/src/account/builder.ts +71 -34
- package/src/account/index.ts +1 -1
- package/src/account/masm/account-components/auth.ts +70 -0
- package/src/account/masm/auth.ts +1398 -0
- package/src/account/masm/index.ts +5 -0
- package/src/account/masm.ts +3 -1040
- package/src/account/storage.ts +18 -16
- package/src/client.test.ts +31 -35
- package/src/client.ts +98 -26
- package/src/index.ts +84 -22
- package/src/inspector.test.ts +17 -17
- package/src/inspector.ts +63 -29
- package/src/multisig/proposal/execution.ts +102 -41
- package/src/multisig/proposal/parser.ts +26 -26
- package/src/multisig/signing.ts +4 -4
- package/src/multisig.test.ts +2097 -248
- package/src/multisig.ts +882 -365
- package/src/procedures.ts +50 -26
- package/src/proposal/factory.ts +171 -0
- package/src/proposal/metadata.ts +165 -0
- package/src/proposal/signatures.ts +68 -0
- package/src/signer.ts +2 -0
- package/src/signers/ecdsa.test.ts +80 -0
- package/src/signers/ecdsa.ts +15 -4
- package/src/signers/falcon.test.ts +19 -0
- package/src/signers/falcon.ts +16 -5
- package/src/signers/miden-wallet.test.ts +47 -0
- package/src/signers/miden-wallet.ts +18 -1
- package/src/signers/para.test.ts +57 -0
- package/src/signers/para.ts +26 -7
- package/src/transaction/consumeNotes.ts +1 -0
- package/src/transaction/index.ts +2 -2
- package/src/transaction/options.ts +1 -2
- package/src/transaction/p2id.test.ts +190 -0
- package/src/transaction/p2id.ts +11 -5
- package/src/transaction/rpoRandomCoin.test.ts +64 -0
- package/src/transaction/rpoRandomCoin.ts +24 -0
- package/src/transaction/{updatePsm.ts → updateGuardian.ts} +19 -32
- package/src/transaction/updateProcedureThreshold.ts +97 -0
- package/src/transaction/updateSigners.ts +12 -27
- package/src/transaction.ts +5 -3
- package/src/types/proposal.ts +43 -11
- package/src/types.ts +29 -11
- package/src/utils/digest.test.ts +55 -0
- package/src/utils/digest.ts +51 -1
- package/src/utils/signature.ts +47 -9
- package/src/utils/word.test.ts +1 -55
- package/dist/account.d.ts +0 -104
- package/dist/account.d.ts.map +0 -1
- package/dist/account.js +0 -136
- package/dist/account.js.map +0 -1
- package/dist/builder.d.ts +0 -54
- package/dist/builder.d.ts.map +0 -1
- package/dist/builder.js +0 -78
- package/dist/builder.js.map +0 -1
- package/dist/http.d.ts +0 -64
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -162
- package/dist/http.js.map +0 -1
- package/dist/keystore.d.ts +0 -65
- package/dist/keystore.d.ts.map +0 -1
- package/dist/keystore.js +0 -121
- package/dist/keystore.js.map +0 -1
- package/dist/miden.d.ts +0 -9
- package/dist/miden.d.ts.map +0 -1
- package/dist/miden.js +0 -26
- package/dist/miden.js.map +0 -1
- package/dist/multisig/metadata.d.ts +0 -18
- package/dist/multisig/metadata.d.ts.map +0 -1
- package/dist/multisig/metadata.js +0 -100
- package/dist/multisig/metadata.js.map +0 -1
- package/dist/multisig/metadata.test.d.ts +0 -2
- package/dist/multisig/metadata.test.d.ts.map +0 -1
- package/dist/multisig/metadata.test.js +0 -323
- package/dist/multisig/metadata.test.js.map +0 -1
- package/dist/signer.test.d.ts +0 -2
- package/dist/signer.test.d.ts.map +0 -1
- package/dist/signer.test.js +0 -117
- package/dist/signer.test.js.map +0 -1
- package/dist/transaction/updatePsm.d.ts +0 -7
- package/dist/transaction/updatePsm.d.ts.map +0 -1
- package/dist/transaction/updatePsm.js.map +0 -1
- package/dist/transport/http.d.ts +0 -64
- package/dist/transport/http.d.ts.map +0 -1
- package/dist/transport/http.js +0 -162
- package/dist/transport/http.js.map +0 -1
- package/dist/transport/index.d.ts +0 -5
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js +0 -5
- package/dist/transport/index.js.map +0 -1
- package/masm/psm.masm +0 -178
- package/masm/psm_ecdsa.masm +0 -179
package/dist/account/masm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masm.js","sourceRoot":"","sources":["../../src/account/masm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"masm.js","sourceRoot":"","sources":["../../src/account/masm.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,0BAA0B;AAE1B,cAAc,iBAAiB,CAAC"}
|
|
@@ -2,9 +2,9 @@ import type { MultisigConfig } from '../types.js';
|
|
|
2
2
|
import { StorageSlot } from '@miden-sdk/miden-sdk';
|
|
3
3
|
export declare class StorageLayoutBuilder {
|
|
4
4
|
buildMultisigSlots(config: MultisigConfig): StorageSlot[];
|
|
5
|
-
|
|
5
|
+
buildGuardianSlots(config: MultisigConfig): StorageSlot[];
|
|
6
6
|
}
|
|
7
7
|
export declare function buildMultisigStorageSlots(config: MultisigConfig): StorageSlot[];
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function buildGuardianStorageSlots(config: MultisigConfig): StorageSlot[];
|
|
9
9
|
export declare const storageLayoutBuilder: StorageLayoutBuilder;
|
|
10
10
|
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/account/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAoB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/account/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAoB,MAAM,sBAAsB,CAAC;AAiBrE,qBAAa,oBAAoB;IAC/B,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,EAAE;IAsCzD,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,EAAE;CAa1D;AAID,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,EAAE,CAE/E;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,EAAE,CAE/E;AAED,eAAO,MAAM,oBAAoB,sBAAwB,CAAC"}
|
package/dist/account/storage.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { StorageSlot, StorageMap, Word } from '@miden-sdk/miden-sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { ensureHexPrefix } from '../utils/encoding.js';
|
|
3
3
|
import { getProcedureRoot } from '../procedures.js';
|
|
4
|
+
// Storage slot names matching the MASM definitions
|
|
4
5
|
const MULTISIG_SLOT_NAMES = {
|
|
5
6
|
THRESHOLD_CONFIG: 'openzeppelin::multisig::threshold_config',
|
|
6
7
|
SIGNER_PUBLIC_KEYS: 'openzeppelin::multisig::signer_public_keys',
|
|
7
8
|
EXECUTED_TRANSACTIONS: 'openzeppelin::multisig::executed_transactions',
|
|
8
9
|
PROCEDURE_THRESHOLDS: 'openzeppelin::multisig::procedure_thresholds',
|
|
9
10
|
};
|
|
10
|
-
const
|
|
11
|
-
SELECTOR: 'openzeppelin::
|
|
12
|
-
PUBLIC_KEY: 'openzeppelin::
|
|
11
|
+
const GUARDIAN_SLOT_NAMES = {
|
|
12
|
+
SELECTOR: 'openzeppelin::guardian::selector',
|
|
13
|
+
PUBLIC_KEY: 'openzeppelin::guardian::public_key',
|
|
13
14
|
};
|
|
14
15
|
export class StorageLayoutBuilder {
|
|
15
16
|
buildMultisigSlots(config) {
|
|
@@ -24,16 +25,17 @@ export class StorageLayoutBuilder {
|
|
|
24
25
|
const signersMap = new StorageMap();
|
|
25
26
|
config.signerCommitments.forEach((commitment, index) => {
|
|
26
27
|
const key = new Word(new BigUint64Array([BigInt(index), 0n, 0n, 0n]));
|
|
27
|
-
const value = Word.fromHex(
|
|
28
|
+
const value = Word.fromHex(ensureHexPrefix(commitment));
|
|
28
29
|
signersMap.insert(key, value);
|
|
29
30
|
});
|
|
30
31
|
const slot1 = StorageSlot.map(MULTISIG_SLOT_NAMES.SIGNER_PUBLIC_KEYS, signersMap);
|
|
31
32
|
const slot2 = StorageSlot.map(MULTISIG_SLOT_NAMES.EXECUTED_TRANSACTIONS, new StorageMap());
|
|
33
|
+
// Map entries: PROC_ROOT => [proc_threshold, 0, 0, 0]
|
|
34
|
+
// Use SDK's Word.fromHex to match how account code procedure roots are represented
|
|
32
35
|
const procThresholdMap = new StorageMap();
|
|
33
36
|
if (config.procedureThresholds) {
|
|
34
|
-
const signatureScheme = config.signatureScheme ?? 'falcon';
|
|
35
37
|
for (const pt of config.procedureThresholds) {
|
|
36
|
-
const rootHex = getProcedureRoot(pt.procedure
|
|
38
|
+
const rootHex = getProcedureRoot(pt.procedure);
|
|
37
39
|
const key = Word.fromHex(rootHex);
|
|
38
40
|
const value = new Word(new BigUint64Array([BigInt(pt.threshold), 0n, 0n, 0n]));
|
|
39
41
|
procThresholdMap.insert(key, value);
|
|
@@ -42,15 +44,15 @@ export class StorageLayoutBuilder {
|
|
|
42
44
|
const slot3 = StorageSlot.map(MULTISIG_SLOT_NAMES.PROCEDURE_THRESHOLDS, procThresholdMap);
|
|
43
45
|
return [slot0, slot1, slot2, slot3];
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
const selector = config.
|
|
47
|
+
buildGuardianSlots(config) {
|
|
48
|
+
const selector = config.guardianEnabled !== false ? 1n : 0n;
|
|
47
49
|
const selectorWord = new Word(new BigUint64Array([selector, 0n, 0n, 0n]));
|
|
48
|
-
const slot0 = StorageSlot.fromValue(
|
|
49
|
-
const
|
|
50
|
+
const slot0 = StorageSlot.fromValue(GUARDIAN_SLOT_NAMES.SELECTOR, selectorWord);
|
|
51
|
+
const guardianKeyMap = new StorageMap();
|
|
50
52
|
const zeroKey = new Word(new BigUint64Array([0n, 0n, 0n, 0n]));
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const slot1 = StorageSlot.map(
|
|
53
|
+
const guardianKey = Word.fromHex(ensureHexPrefix(config.guardianCommitment));
|
|
54
|
+
guardianKeyMap.insert(zeroKey, guardianKey);
|
|
55
|
+
const slot1 = StorageSlot.map(GUARDIAN_SLOT_NAMES.PUBLIC_KEY, guardianKeyMap);
|
|
54
56
|
return [slot0, slot1];
|
|
55
57
|
}
|
|
56
58
|
}
|
|
@@ -58,8 +60,8 @@ const defaultStorageBuilder = new StorageLayoutBuilder();
|
|
|
58
60
|
export function buildMultisigStorageSlots(config) {
|
|
59
61
|
return defaultStorageBuilder.buildMultisigSlots(config);
|
|
60
62
|
}
|
|
61
|
-
export function
|
|
62
|
-
return defaultStorageBuilder.
|
|
63
|
+
export function buildGuardianStorageSlots(config) {
|
|
64
|
+
return defaultStorageBuilder.buildGuardianSlots(config);
|
|
63
65
|
}
|
|
64
66
|
export const storageLayoutBuilder = defaultStorageBuilder;
|
|
65
67
|
//# sourceMappingURL=storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/account/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/account/storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,mDAAmD;AACnD,MAAM,mBAAmB,GAAG;IAC1B,gBAAgB,EAAE,0CAA0C;IAC5D,kBAAkB,EAAE,4CAA4C;IAChE,qBAAqB,EAAE,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AAE,CAAC,CAAC,CAAC,CAAC;QAC/D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAC7E,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,mBAAmB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;QAE9E,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC;CACF;AAED,MAAM,qBAAqB,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAEzD,MAAM,UAAU,yBAAyB,CAAC,MAAsB;IAC9D,OAAO,qBAAqB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAsB;IAC9D,OAAO,qBAAqB,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,21 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MultisigClient - Factory for creating and loading multisig accounts.
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for the multisig SDK. It provides methods
|
|
5
|
+
* to create new multisig accounts and load existing ones.
|
|
6
|
+
*/
|
|
1
7
|
import { type WebClient } from '@miden-sdk/miden-sdk';
|
|
2
|
-
import {
|
|
8
|
+
import { GuardianHttpClient } from '@openzeppelin/guardian-client';
|
|
3
9
|
import { Multisig } from './multisig.js';
|
|
4
10
|
import type { MultisigConfig, Signer } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for MultisigClient.
|
|
13
|
+
*/
|
|
5
14
|
export interface MultisigClientConfig {
|
|
6
|
-
|
|
15
|
+
/** GUARDIAN server endpoint */
|
|
16
|
+
guardianEndpoint?: string;
|
|
17
|
+
/** Miden node RPC endpoint used for state commitment verification */
|
|
18
|
+
midenRpcEndpoint?: string;
|
|
7
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Client for creating and loading multisig accounts.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { MultisigClient, FalconSigner } from '@openzeppelin/miden-multisig-client';
|
|
26
|
+
* import { WebClient, SecretKey } from '@miden-sdk/miden-sdk';
|
|
27
|
+
*
|
|
28
|
+
* // Initialize
|
|
29
|
+
* const webClient = await WebClient.createClient('https://rpc.testnet.miden.io:443');
|
|
30
|
+
* const secretKey = SecretKey.rpoFalconWithRNG(seed);
|
|
31
|
+
* const signer = new FalconSigner(secretKey);
|
|
32
|
+
*
|
|
33
|
+
* // Create client
|
|
34
|
+
* const client = new MultisigClient(webClient, {
|
|
35
|
+
* guardianEndpoint: 'http://localhost:3000',
|
|
36
|
+
* midenRpcEndpoint: 'https://rpc.testnet.miden.io:443',
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Get GUARDIAN pubkey for config
|
|
40
|
+
* const guardianCommitment = await client.guardianClient.getPubkey();
|
|
41
|
+
*
|
|
42
|
+
* // Create multisig
|
|
43
|
+
* const config = { threshold: 2, signerCommitments: [...], guardianCommitment };
|
|
44
|
+
* const multisig = await client.create(config, signer);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
8
47
|
export declare class MultisigClient {
|
|
9
48
|
private readonly webClient;
|
|
10
|
-
private
|
|
49
|
+
private readonly midenRpcEndpoint?;
|
|
50
|
+
private _guardianClient;
|
|
11
51
|
constructor(webClient: WebClient, config?: MultisigClientConfig);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Change the GUARDIAN endpoint.
|
|
54
|
+
*
|
|
55
|
+
* @param endpoint - The new GUARDIAN server endpoint URL
|
|
56
|
+
*/
|
|
57
|
+
setGuardianEndpoint(endpoint: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Access the internal GUARDIAN client.
|
|
60
|
+
*/
|
|
61
|
+
get guardianClient(): GuardianHttpClient;
|
|
62
|
+
/**
|
|
63
|
+
* Create a new multisig account.
|
|
64
|
+
*
|
|
65
|
+
* @param config - Multisig configuration (threshold, signers, GUARDIAN commitment)
|
|
66
|
+
* @param signer - The signer for this client (one of the cosigners)
|
|
67
|
+
* @returns A Multisig instance wrapping the created account
|
|
68
|
+
*/
|
|
18
69
|
create(config: MultisigConfig, signer: Signer): Promise<Multisig>;
|
|
70
|
+
/**
|
|
71
|
+
* Load an existing multisig account from GUARDIAN.
|
|
72
|
+
*
|
|
73
|
+
* @param accountId - The account ID to load
|
|
74
|
+
* @param signer - The signer for this client
|
|
75
|
+
* @returns A Multisig instance for the loaded account
|
|
76
|
+
*/
|
|
19
77
|
load(accountId: string, signer: Signer): Promise<Multisig>;
|
|
20
78
|
}
|
|
21
79
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAsB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAsB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAS;IAC3C,OAAO,CAAC,eAAe,CAAqB;gBAEhC,SAAS,EAAE,SAAS,EAAE,MAAM,GAAE,oBAAyB;IAMnE;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAI3C;;OAEG;IACH,IAAI,cAAc,IAAI,kBAAkB,CAEvC;IAED;;;;;;OAMG;IACG,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgBvE;;;;;;OAMG;IACG,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CA2CjE"}
|
package/dist/client.js
CHANGED
|
@@ -1,36 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MultisigClient - Factory for creating and loading multisig accounts.
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for the multisig SDK. It provides methods
|
|
5
|
+
* to create new multisig accounts and load existing ones.
|
|
6
|
+
*/
|
|
1
7
|
import { Account, AccountId } from '@miden-sdk/miden-sdk';
|
|
2
|
-
import {
|
|
8
|
+
import { GuardianHttpClient } from '@openzeppelin/guardian-client';
|
|
3
9
|
import { Multisig } from './multisig.js';
|
|
4
10
|
import { createMultisigAccount } from './account/index.js';
|
|
5
11
|
import { AccountInspector } from './inspector.js';
|
|
12
|
+
/**
|
|
13
|
+
* Client for creating and loading multisig accounts.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { MultisigClient, FalconSigner } from '@openzeppelin/miden-multisig-client';
|
|
18
|
+
* import { WebClient, SecretKey } from '@miden-sdk/miden-sdk';
|
|
19
|
+
*
|
|
20
|
+
* // Initialize
|
|
21
|
+
* const webClient = await WebClient.createClient('https://rpc.testnet.miden.io:443');
|
|
22
|
+
* const secretKey = SecretKey.rpoFalconWithRNG(seed);
|
|
23
|
+
* const signer = new FalconSigner(secretKey);
|
|
24
|
+
*
|
|
25
|
+
* // Create client
|
|
26
|
+
* const client = new MultisigClient(webClient, {
|
|
27
|
+
* guardianEndpoint: 'http://localhost:3000',
|
|
28
|
+
* midenRpcEndpoint: 'https://rpc.testnet.miden.io:443',
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Get GUARDIAN pubkey for config
|
|
32
|
+
* const guardianCommitment = await client.guardianClient.getPubkey();
|
|
33
|
+
*
|
|
34
|
+
* // Create multisig
|
|
35
|
+
* const config = { threshold: 2, signerCommitments: [...], guardianCommitment };
|
|
36
|
+
* const multisig = await client.create(config, signer);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
6
39
|
export class MultisigClient {
|
|
7
40
|
webClient;
|
|
8
|
-
|
|
41
|
+
midenRpcEndpoint;
|
|
42
|
+
_guardianClient;
|
|
9
43
|
constructor(webClient, config = {}) {
|
|
10
44
|
this.webClient = webClient;
|
|
11
|
-
this.
|
|
45
|
+
this.midenRpcEndpoint = config.midenRpcEndpoint;
|
|
46
|
+
this._guardianClient = new GuardianHttpClient(config.guardianEndpoint ?? 'http://localhost:3000');
|
|
12
47
|
}
|
|
13
|
-
|
|
14
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Change the GUARDIAN endpoint.
|
|
50
|
+
*
|
|
51
|
+
* @param endpoint - The new GUARDIAN server endpoint URL
|
|
52
|
+
*/
|
|
53
|
+
setGuardianEndpoint(endpoint) {
|
|
54
|
+
this._guardianClient = new GuardianHttpClient(endpoint);
|
|
15
55
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return this._psmClient;
|
|
56
|
+
/**
|
|
57
|
+
* Access the internal GUARDIAN client.
|
|
58
|
+
*/
|
|
59
|
+
get guardianClient() {
|
|
60
|
+
return this._guardianClient;
|
|
22
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Create a new multisig account.
|
|
64
|
+
*
|
|
65
|
+
* @param config - Multisig configuration (threshold, signers, GUARDIAN commitment)
|
|
66
|
+
* @param signer - The signer for this client (one of the cosigners)
|
|
67
|
+
* @returns A Multisig instance wrapping the created account
|
|
68
|
+
*/
|
|
23
69
|
async create(config, signer) {
|
|
24
|
-
this.
|
|
70
|
+
this._guardianClient.setSigner(signer);
|
|
25
71
|
const { account } = await createMultisigAccount(this.webClient, config);
|
|
26
|
-
return new Multisig(account, config, this.
|
|
72
|
+
return new Multisig(account, config, this._guardianClient, signer, this.webClient, undefined, this.midenRpcEndpoint);
|
|
27
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Load an existing multisig account from GUARDIAN.
|
|
76
|
+
*
|
|
77
|
+
* @param accountId - The account ID to load
|
|
78
|
+
* @param signer - The signer for this client
|
|
79
|
+
* @returns A Multisig instance for the loaded account
|
|
80
|
+
*/
|
|
28
81
|
async load(accountId, signer) {
|
|
29
|
-
this.
|
|
30
|
-
const stateResponse = await this.
|
|
82
|
+
this._guardianClient.setSigner(signer);
|
|
83
|
+
const stateResponse = await this._guardianClient.getState(accountId);
|
|
31
84
|
const accountBase64 = stateResponse.stateJson.data;
|
|
32
85
|
if (!accountBase64) {
|
|
33
|
-
throw new Error('No account data found in
|
|
86
|
+
throw new Error('No account data found in GUARDIAN state');
|
|
34
87
|
}
|
|
35
88
|
const binaryString = atob(accountBase64);
|
|
36
89
|
const accountBytes = new Uint8Array(binaryString.length);
|
|
@@ -38,21 +91,19 @@ export class MultisigClient {
|
|
|
38
91
|
accountBytes[i] = binaryString.charCodeAt(i);
|
|
39
92
|
}
|
|
40
93
|
const account = Account.deserialize(accountBytes);
|
|
41
|
-
const
|
|
42
|
-
const detected = AccountInspector.fromAccount(account, detectedScheme);
|
|
94
|
+
const detected = AccountInspector.fromAccount(account);
|
|
43
95
|
const config = {
|
|
44
96
|
threshold: detected.threshold,
|
|
45
97
|
signerCommitments: detected.signerCommitments,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
signatureScheme: detected.signatureScheme,
|
|
98
|
+
guardianCommitment: detected.guardianCommitment ?? '',
|
|
99
|
+
guardianEnabled: detected.guardianEnabled,
|
|
49
100
|
procedureThresholds: Array.from(detected.procedureThresholds.entries()).map(([procedure, threshold]) => ({ procedure, threshold })),
|
|
50
101
|
};
|
|
51
102
|
const existingAccount = await this.webClient.getAccount(AccountId.fromHex(accountId));
|
|
52
103
|
if (!existingAccount) {
|
|
53
104
|
await this.webClient.newAccount(account, true);
|
|
54
105
|
}
|
|
55
|
-
return new Multisig(account, config, this.
|
|
106
|
+
return new Multisig(account, config, this._guardianClient, signer, this.webClient, accountId, this.midenRpcEndpoint);
|
|
56
107
|
}
|
|
57
108
|
}
|
|
58
109
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAkB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAalD;;;;;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AAQ,CACjB,OAAO,EACP,MAAM,EACN,IAAI,CAAC,eAAe,EACpB,MAAM,EACN,IAAI,CAAC,SAAS,EACd,SAAS,EACT,IAAI,CAAC,gBAAgB,CACtB,CAAC;IACJ,CAAC;CACF"}
|
package/dist/client.test.js
CHANGED
|
@@ -12,6 +12,7 @@ vi.mock('@miden-sdk/miden-sdk', () => ({
|
|
|
12
12
|
prefix: () => ({ asInt: () => BigInt(1) }),
|
|
13
13
|
suffix: () => ({ asInt: () => BigInt(2) }),
|
|
14
14
|
}),
|
|
15
|
+
serialize: () => new Uint8Array([1, 2, 3]),
|
|
15
16
|
storage: vi.fn(),
|
|
16
17
|
vault: vi.fn(),
|
|
17
18
|
})),
|
|
@@ -24,8 +25,8 @@ vi.mock('./inspector.js', () => ({
|
|
|
24
25
|
threshold: 2,
|
|
25
26
|
numSigners: 2,
|
|
26
27
|
signerCommitments: ['0x' + 'a'.repeat(64), '0x' + 'b'.repeat(64)],
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
guardianEnabled: true,
|
|
29
|
+
guardianCommitment: '0x' + 'c'.repeat(64),
|
|
29
30
|
vaultBalances: [],
|
|
30
31
|
procedureThresholds: new Map(),
|
|
31
32
|
})),
|
|
@@ -45,7 +46,7 @@ vi.mock('./account/index.js', () => ({
|
|
|
45
46
|
seed: new Uint8Array([4, 5, 6]),
|
|
46
47
|
}),
|
|
47
48
|
}));
|
|
48
|
-
// Mock fetch for
|
|
49
|
+
// Mock fetch for GUARDIAN client
|
|
49
50
|
const mockFetch = vi.fn();
|
|
50
51
|
vi.stubGlobal('fetch', mockFetch);
|
|
51
52
|
describe('MultisigClient', () => {
|
|
@@ -64,27 +65,28 @@ describe('MultisigClient', () => {
|
|
|
64
65
|
getAccount: vi.fn().mockResolvedValue(null),
|
|
65
66
|
};
|
|
66
67
|
mockSigner = {
|
|
67
|
-
scheme: 'falcon',
|
|
68
68
|
commitment: '0x' + '1'.repeat(64),
|
|
69
69
|
publicKey: '0x' + '2'.repeat(64),
|
|
70
|
+
scheme: 'falcon',
|
|
70
71
|
signAccountIdWithTimestamp: vi.fn().mockResolvedValue('0x' + 'a'.repeat(128)),
|
|
71
|
-
|
|
72
|
+
signRequest: vi.fn().mockReturnValue('0x' + 'a'.repeat(128)),
|
|
73
|
+
signCommitment: vi.fn().mockReturnValue('0x' + 'b'.repeat(128)),
|
|
72
74
|
};
|
|
73
75
|
});
|
|
74
76
|
describe('constructor', () => {
|
|
75
|
-
it('should create client with default
|
|
77
|
+
it('should create client with default GUARDIAN endpoint', () => {
|
|
76
78
|
const client = new MultisigClient(webClient);
|
|
77
79
|
expect(client).toBeInstanceOf(MultisigClient);
|
|
78
80
|
});
|
|
79
|
-
it('should create client with custom
|
|
80
|
-
const client = new MultisigClient(webClient, {
|
|
81
|
+
it('should create client with custom GUARDIAN endpoint', () => {
|
|
82
|
+
const client = new MultisigClient(webClient, { guardianEndpoint: 'http://custom:8080' });
|
|
81
83
|
expect(client).toBeInstanceOf(MultisigClient);
|
|
82
84
|
});
|
|
83
85
|
});
|
|
84
|
-
describe('
|
|
85
|
-
it('should expose
|
|
86
|
+
describe('guardianClient getter', () => {
|
|
87
|
+
it('should expose GUARDIAN client for getting pubkey', () => {
|
|
86
88
|
const client = new MultisigClient(webClient);
|
|
87
|
-
expect(client.
|
|
89
|
+
expect(client.guardianClient).toBeDefined();
|
|
88
90
|
});
|
|
89
91
|
});
|
|
90
92
|
describe('create', () => {
|
|
@@ -93,20 +95,20 @@ describe('MultisigClient', () => {
|
|
|
93
95
|
const config = {
|
|
94
96
|
threshold: 2,
|
|
95
97
|
signerCommitments: ['0x' + 'a'.repeat(64), '0x' + 'b'.repeat(64)],
|
|
96
|
-
|
|
98
|
+
guardianCommitment: '0x' + 'c'.repeat(64),
|
|
97
99
|
};
|
|
98
100
|
const multisig = await client.create(config, mockSigner);
|
|
99
101
|
expect(multisig).toBeDefined();
|
|
100
102
|
expect(multisig.threshold).toBe(2);
|
|
101
103
|
expect(multisig.signerCommitments).toEqual(config.signerCommitments);
|
|
102
|
-
expect(multisig.
|
|
104
|
+
expect(multisig.guardianCommitment).toBe(config.guardianCommitment);
|
|
103
105
|
});
|
|
104
|
-
it('should set signer on
|
|
106
|
+
it('should set signer on GUARDIAN client', async () => {
|
|
105
107
|
const client = new MultisigClient(webClient);
|
|
106
108
|
const config = {
|
|
107
109
|
threshold: 1,
|
|
108
110
|
signerCommitments: ['0x' + 'a'.repeat(64)],
|
|
109
|
-
|
|
111
|
+
guardianCommitment: '0x' + 'c'.repeat(64),
|
|
110
112
|
};
|
|
111
113
|
const multisig = await client.create(config, mockSigner);
|
|
112
114
|
expect(multisig.signerCommitment).toBe(mockSigner.commitment);
|
|
@@ -133,10 +135,10 @@ describe('MultisigClient', () => {
|
|
|
133
135
|
// Config is detected from account storage via AccountInspector
|
|
134
136
|
expect(multisig.threshold).toBe(2);
|
|
135
137
|
expect(multisig.signerCommitments).toEqual(['0x' + 'a'.repeat(64), '0x' + 'b'.repeat(64)]);
|
|
136
|
-
expect(multisig.
|
|
138
|
+
expect(multisig.guardianCommitment).toBe('0x' + 'c'.repeat(64));
|
|
137
139
|
expect(multisig.account).not.toBeNull();
|
|
138
140
|
});
|
|
139
|
-
it('should throw if account not found on
|
|
141
|
+
it('should throw if account not found on GUARDIAN', async () => {
|
|
140
142
|
const client = new MultisigClient(webClient);
|
|
141
143
|
mockFetch.mockResolvedValueOnce({
|
|
142
144
|
ok: false,
|
|
@@ -146,32 +148,29 @@ describe('MultisigClient', () => {
|
|
|
146
148
|
});
|
|
147
149
|
await expect(client.load('0xnonexistent', mockSigner)).rejects.toThrow();
|
|
148
150
|
});
|
|
149
|
-
|
|
150
|
-
describe('initialize', () => {
|
|
151
|
-
it('should fetch PSM pubkey and return commitment', async () => {
|
|
151
|
+
it('should allow registerOnGuardian after load without explicit initial state', async () => {
|
|
152
152
|
const client = new MultisigClient(webClient);
|
|
153
153
|
mockFetch.mockResolvedValueOnce({
|
|
154
154
|
ok: true,
|
|
155
155
|
json: async () => ({
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
account_id: '0x' + 'd'.repeat(30),
|
|
157
|
+
commitment: '0x' + 'e'.repeat(64),
|
|
158
|
+
state_json: { data: 'base64state' },
|
|
159
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
160
|
+
updated_at: '2024-01-02T00:00:00Z',
|
|
158
161
|
}),
|
|
159
162
|
});
|
|
160
|
-
const result = await client.initialize('falcon');
|
|
161
|
-
expect(result.psmCommitment).toBe('0x' + 'f'.repeat(64));
|
|
162
|
-
expect(result.psmPublicKey).toBe('0x' + 'e'.repeat(64));
|
|
163
|
-
});
|
|
164
|
-
it('should work without specifying scheme', async () => {
|
|
165
|
-
const client = new MultisigClient(webClient);
|
|
166
163
|
mockFetch.mockResolvedValueOnce({
|
|
167
164
|
ok: true,
|
|
168
165
|
json: async () => ({
|
|
169
|
-
|
|
166
|
+
success: true,
|
|
167
|
+
message: 'Account configured',
|
|
168
|
+
ack_pubkey: '0x' + 'f'.repeat(64),
|
|
170
169
|
}),
|
|
171
170
|
});
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
expect(
|
|
171
|
+
const accountId = '0x' + 'd'.repeat(30);
|
|
172
|
+
const multisig = await client.load(accountId, mockSigner);
|
|
173
|
+
await expect(multisig.registerOnGuardian()).resolves.toBeUndefined();
|
|
175
174
|
});
|
|
176
175
|
});
|
|
177
176
|
});
|
package/dist/client.test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.test.js","sourceRoot":"","sources":["../src/client.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,qBAAqB;AACrB,EAAE,CAAC,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC;IACrC,SAAS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L,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @openzeppelin/miden-multisig-client
|
|
3
|
+
*
|
|
4
|
+
* TypeScript SDK for Miden multisig accounts with Guardian integration.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import {
|
|
9
|
+
* MultisigClient,
|
|
10
|
+
* FalconSigner,
|
|
11
|
+
* } from '@openzeppelin/miden-multisig-client';
|
|
12
|
+
* import { WebClient, SecretKey } from '@miden-sdk/miden-sdk';
|
|
13
|
+
*
|
|
14
|
+
* // Initialize WebClient
|
|
15
|
+
* const webClient = await WebClient.createClient('https://rpc.testnet.miden.io:443');
|
|
16
|
+
* await webClient.syncState();
|
|
17
|
+
*
|
|
18
|
+
* // Generate a key dynamically
|
|
19
|
+
* const seed = new Uint8Array(32);
|
|
20
|
+
* crypto.getRandomValues(seed);
|
|
21
|
+
* const secretKey = SecretKey.rpoFalconWithRNG(seed);
|
|
22
|
+
*
|
|
23
|
+
* // Store in miden-sdk's keystore
|
|
24
|
+
* await webClient.addAccountSecretKeyToWebStore(secretKey);
|
|
25
|
+
*
|
|
26
|
+
* // Create a signer
|
|
27
|
+
* const signer = new FalconSigner(secretKey);
|
|
28
|
+
*
|
|
29
|
+
* // Create multisig client
|
|
30
|
+
* const client = new MultisigClient(webClient, {
|
|
31
|
+
* guardianEndpoint: 'http://localhost:3000',
|
|
32
|
+
* midenRpcEndpoint: 'https://rpc.testnet.miden.io:443',
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Get GUARDIAN pubkey for config
|
|
36
|
+
* const guardianCommitment = await client.guardianClient.getPubkey();
|
|
37
|
+
*
|
|
38
|
+
* // Create multisig account
|
|
39
|
+
* const config = { threshold: 2, signerCommitments: [signer.commitment, ...], guardianCommitment };
|
|
40
|
+
* const multisig = await client.create(config, signer);
|
|
41
|
+
*
|
|
42
|
+
* // Register on GUARDIAN and work with proposals
|
|
43
|
+
* await multisig.registerOnGuardian();
|
|
44
|
+
* await multisig.syncProposals();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
1
47
|
export { MultisigClient, type MultisigClientConfig } from './client.js';
|
|
2
48
|
export { Multisig, type AccountState } from './multisig.js';
|
|
3
49
|
export { AccountInspector, type DetectedMultisigConfig, type VaultBalance } from './inspector.js';
|
|
4
|
-
export { executeForSummary, buildUpdateSignersTransactionRequest,
|
|
5
|
-
export {
|
|
6
|
-
export { FalconSigner, EcdsaSigner, ParaSigner, MidenWalletSigner } from './
|
|
7
|
-
export type { ParaSigningContext } from './signers/para.js';
|
|
8
|
-
export type { WalletSigningContext } from './signers/miden-wallet.js';
|
|
9
|
-
export { AuthDigest } from './utils/digest.js';
|
|
10
|
-
export { EcdsaFormat } from './utils/ecdsa.js';
|
|
50
|
+
export { executeForSummary, buildUpdateSignersTransactionRequest, buildUpdateProcedureThresholdTransactionRequest, buildUpdateGuardianTransactionRequest, buildConsumeNotesTransactionRequest, buildP2idTransactionRequest, } from './transaction.js';
|
|
51
|
+
export { GuardianHttpClient, GuardianHttpError } from '@openzeppelin/guardian-client';
|
|
52
|
+
export { FalconSigner, EcdsaSigner, ParaSigner, MidenWalletSigner, type ParaSigningContext, type WalletSigningContext, } from './signer.js';
|
|
11
53
|
export { PublicKeyFormat } from './utils/key.js';
|
|
12
|
-
export {
|
|
13
|
-
export { tryComputeEcdsaCommitmentHex
|
|
14
|
-
export { createMultisigAccount, validateMultisigConfig, buildMultisigStorageSlots,
|
|
15
|
-
export { PROCEDURE_ROOTS,
|
|
16
|
-
export type { MultisigAccountState, MultisigConfig, CreateAccountResult, ProcedureThreshold,
|
|
54
|
+
export { EcdsaFormat } from './utils/ecdsa.js';
|
|
55
|
+
export { tryComputeEcdsaCommitmentHex } from './utils/signature.js';
|
|
56
|
+
export { createMultisigAccount, validateMultisigConfig, buildMultisigStorageSlots, buildGuardianStorageSlots, storageLayoutBuilder, StorageLayoutBuilder, } from './account/index.js';
|
|
57
|
+
export { PROCEDURE_ROOTS, getProcedureRoot, isProcedureName, getProcedureNames, type ProcedureName, } from './procedures.js';
|
|
58
|
+
export type { MultisigAccountState, MultisigConfig, CreateAccountResult, ProcedureThreshold, Proposal, ProposalStatus, ProposalSignatureEntry, ProposalMetadata, ProposalType, ExportedProposal, ExportedTransactionProposal, SignTransactionProposalParams, TransactionProposal, TransactionProposalSignature, TransactionProposalStatus, TransactionType, ConsumableNote, NoteAsset, FalconSignature, Signer, SignatureScheme, AuthConfig, DeltaObject, DeltaStatus, StateObject, CosignerSignature, ConfigureRequest, ConfigureResponse, DeltaProposalRequest, DeltaProposalResponse, ProposalsResponse, PubkeyResponse, SignProposalRequest, } from './types.js';
|
|
17
59
|
//# sourceMappingURL=index.d.ts.map
|