@openzeppelin/miden-multisig-client 0.16.0 → 0.16.1
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 +12 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +9 -2
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/multisig.d.ts +63 -2
- package/dist/multisig.d.ts.map +1 -1
- package/dist/multisig.js +131 -7
- package/dist/multisig.js.map +1 -1
- package/dist/multisig.test.js +216 -13
- package/dist/multisig.test.js.map +1 -1
- package/dist/proposal/factory.d.ts.map +1 -1
- package/dist/proposal/factory.js +10 -0
- package/dist/proposal/factory.js.map +1 -1
- package/dist/proposal/factory.test.d.ts +2 -0
- package/dist/proposal/factory.test.d.ts.map +1 -0
- package/dist/proposal/factory.test.js +32 -0
- package/dist/proposal/factory.test.js.map +1 -0
- package/dist/prover/config.d.ts +16 -0
- package/dist/prover/config.d.ts.map +1 -0
- package/dist/prover/config.js +54 -0
- package/dist/prover/config.js.map +1 -0
- package/dist/prover/config.test.d.ts +2 -0
- package/dist/prover/config.test.d.ts.map +1 -0
- package/dist/prover/config.test.js +54 -0
- package/dist/prover/config.test.js.map +1 -0
- package/dist/prover/errors.d.ts +2 -0
- package/dist/prover/errors.d.ts.map +1 -0
- package/dist/prover/errors.js +158 -0
- package/dist/prover/errors.js.map +1 -0
- package/dist/prover/errors.test.d.ts +2 -0
- package/dist/prover/errors.test.d.ts.map +1 -0
- package/dist/prover/errors.test.js +24 -0
- package/dist/prover/errors.test.js.map +1 -0
- package/dist/prover/retry.d.ts +10 -0
- package/dist/prover/retry.d.ts.map +1 -0
- package/dist/prover/retry.js +32 -0
- package/dist/prover/retry.js.map +1 -0
- package/dist/prover/retry.test.d.ts +2 -0
- package/dist/prover/retry.test.d.ts.map +1 -0
- package/dist/prover/retry.test.js +20 -0
- package/dist/prover/retry.test.js.map +1 -0
- package/dist/prover/workflow.d.ts +11 -0
- package/dist/prover/workflow.d.ts.map +1 -0
- package/dist/prover/workflow.js +18 -0
- package/dist/prover/workflow.js.map +1 -0
- package/dist/prover/workflow.test.d.ts +2 -0
- package/dist/prover/workflow.test.d.ts.map +1 -0
- package/dist/prover/workflow.test.js +80 -0
- package/dist/prover/workflow.test.js.map +1 -0
- package/dist/transaction/p2id.d.ts +8 -1
- package/dist/transaction/p2id.d.ts.map +1 -1
- package/dist/transaction/p2id.js +12 -3
- package/dist/transaction/p2id.js.map +1 -1
- package/dist/transaction.d.ts +1 -1
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +1 -1
- package/dist/transaction.js.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +17 -2
- package/src/index.ts +5 -0
- package/src/multisig.test.ts +262 -17
- package/src/multisig.ts +162 -6
- package/src/proposal/factory.test.ts +40 -0
- package/src/proposal/factory.ts +11 -1
- package/src/prover/config.test.ts +90 -0
- package/src/prover/config.ts +78 -0
- package/src/prover/errors.test.ts +53 -0
- package/src/prover/errors.ts +178 -0
- package/src/prover/retry.test.ts +38 -0
- package/src/prover/retry.ts +46 -0
- package/src/prover/test-node.d.ts +6 -0
- package/src/prover/workflow.test.ts +109 -0
- package/src/prover/workflow.ts +19 -0
- package/src/transaction/p2id.ts +29 -10
- package/src/transaction.ts +1 -0
package/README.md
CHANGED
|
@@ -38,9 +38,21 @@ const signer = new FalconSigner(secretKey);
|
|
|
38
38
|
const client = new MultisigClient(midenClient, {
|
|
39
39
|
guardianEndpoint: 'http://localhost:3000',
|
|
40
40
|
midenRpcEndpoint: 'https://rpc.devnet.miden.io',
|
|
41
|
+
prover: {
|
|
42
|
+
url: 'https://prover.example',
|
|
43
|
+
retry: { maxAttempts: 4 },
|
|
44
|
+
},
|
|
41
45
|
});
|
|
42
46
|
```
|
|
43
47
|
|
|
48
|
+
The nested `prover` configuration is optional. Without it, the injected Miden
|
|
49
|
+
client's prover is preserved. By default, cloneable remote provers get two total
|
|
50
|
+
attempts; endpoint-less injected provers, including local and callback provers,
|
|
51
|
+
run once. A custom URL must be absolute HTTP(S), overrides the injected prover,
|
|
52
|
+
and never falls back to a default endpoint. Retries apply only to transient
|
|
53
|
+
proof failures; transaction execution, submission, local state application,
|
|
54
|
+
GUARDIAN calls, and Miden RPC requests are not retried.
|
|
55
|
+
|
|
44
56
|
## Usage
|
|
45
57
|
|
|
46
58
|
### Get GUARDIAN Public Key
|
package/dist/client.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { GuardianHttpClient } from '@openzeppelin/guardian-client';
|
|
|
9
9
|
import type { StateObject } from '@openzeppelin/guardian-client';
|
|
10
10
|
import { Multisig } from './multisig.js';
|
|
11
11
|
import type { MultisigConfig, Signer } from './types.js';
|
|
12
|
+
import { type ProverConfig } from './prover/config.js';
|
|
12
13
|
/**
|
|
13
14
|
* Configuration for MultisigClient.
|
|
14
15
|
*/
|
|
@@ -21,6 +22,8 @@ export interface MultisigClientConfig {
|
|
|
21
22
|
* the injected `MidenClient`; there is no default.
|
|
22
23
|
*/
|
|
23
24
|
midenRpcEndpoint: string;
|
|
25
|
+
/** Multisig-owned remote prover override and proof retry policy. */
|
|
26
|
+
prover?: ProverConfig;
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* One match returned by `MultisigClient.recoverByKey`. Pairs the discovered
|
|
@@ -48,6 +51,10 @@ export interface RecoveredAccount {
|
|
|
48
51
|
* const client = new MultisigClient(midenClient, {
|
|
49
52
|
* guardianEndpoint: 'http://localhost:3000',
|
|
50
53
|
* midenRpcEndpoint: 'https://rpc.devnet.miden.io',
|
|
54
|
+
* prover: {
|
|
55
|
+
* url: 'https://prover.example',
|
|
56
|
+
* retry: { maxAttempts: 4 },
|
|
57
|
+
* },
|
|
51
58
|
* });
|
|
52
59
|
*
|
|
53
60
|
* // Get GUARDIAN pubkey for config
|
|
@@ -61,6 +68,7 @@ export interface RecoveredAccount {
|
|
|
61
68
|
export declare class MultisigClient {
|
|
62
69
|
private readonly midenClient;
|
|
63
70
|
private readonly midenRpcEndpoint;
|
|
71
|
+
private readonly proverConfig;
|
|
64
72
|
private _guardianClient;
|
|
65
73
|
constructor(midenClient: MidenClient, config: MultisigClientConfig);
|
|
66
74
|
/**
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAsB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAsB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAEL,KAAK,YAAY,EAElB,MAAM,oBAAoB,CAAC;AAiB5B;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gEAAgE;IAChE,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,WAAW,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB;IACpD,OAAO,CAAC,eAAe,CAAqB;gBAEhC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB;IASlE;;;;OAIG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAM3C;;OAEG;IACH,IAAI,cAAc,IAAI,kBAAkB,CAEvC;IAED;;;;;;;;;OASG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAe/D;;;;;;OAMG;IACG,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAuBvE;;;;;;OAMG;IACG,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CA6CjE"}
|
package/dist/client.js
CHANGED
|
@@ -10,6 +10,7 @@ import { Multisig } from './multisig.js';
|
|
|
10
10
|
import { createMultisigAccount } from './account/index.js';
|
|
11
11
|
import { AccountInspector } from './inspector.js';
|
|
12
12
|
import { requireConfigValue, requireMidenRpcEndpoint } from './raw-client.js';
|
|
13
|
+
import { resolveProverConfig, } from './prover/config.js';
|
|
13
14
|
async function bindSignerAccountKey(signer, midenClient, accountId) {
|
|
14
15
|
const bindingSigner = signer;
|
|
15
16
|
if (typeof bindingSigner.bindAccountKey === 'function') {
|
|
@@ -33,6 +34,10 @@ async function bindSignerAccountKey(signer, midenClient, accountId) {
|
|
|
33
34
|
* const client = new MultisigClient(midenClient, {
|
|
34
35
|
* guardianEndpoint: 'http://localhost:3000',
|
|
35
36
|
* midenRpcEndpoint: 'https://rpc.devnet.miden.io',
|
|
37
|
+
* prover: {
|
|
38
|
+
* url: 'https://prover.example',
|
|
39
|
+
* retry: { maxAttempts: 4 },
|
|
40
|
+
* },
|
|
36
41
|
* });
|
|
37
42
|
*
|
|
38
43
|
* // Get GUARDIAN pubkey for config
|
|
@@ -46,10 +51,12 @@ async function bindSignerAccountKey(signer, midenClient, accountId) {
|
|
|
46
51
|
export class MultisigClient {
|
|
47
52
|
midenClient;
|
|
48
53
|
midenRpcEndpoint;
|
|
54
|
+
proverConfig;
|
|
49
55
|
_guardianClient;
|
|
50
56
|
constructor(midenClient, config) {
|
|
51
57
|
this.midenClient = midenClient;
|
|
52
58
|
this.midenRpcEndpoint = requireMidenRpcEndpoint(config?.midenRpcEndpoint);
|
|
59
|
+
this.proverConfig = resolveProverConfig(config?.prover, midenClient.defaultProver);
|
|
53
60
|
this._guardianClient = new GuardianHttpClient(requireConfigValue('guardianEndpoint', config?.guardianEndpoint));
|
|
54
61
|
}
|
|
55
62
|
/**
|
|
@@ -98,7 +105,7 @@ export class MultisigClient {
|
|
|
98
105
|
const { account } = await createMultisigAccount(this.midenClient, config, this.midenRpcEndpoint);
|
|
99
106
|
const accountId = account.id().toString();
|
|
100
107
|
await bindSignerAccountKey(signer, this.midenClient, accountId);
|
|
101
|
-
return new Multisig(account, config, this._guardianClient, signer, this.midenClient, undefined, this.midenRpcEndpoint);
|
|
108
|
+
return new Multisig(account, config, this._guardianClient, signer, this.midenClient, undefined, this.midenRpcEndpoint, this.proverConfig);
|
|
102
109
|
}
|
|
103
110
|
/**
|
|
104
111
|
* Load an existing multisig account from GUARDIAN.
|
|
@@ -133,7 +140,7 @@ export class MultisigClient {
|
|
|
133
140
|
await this.midenClient.accounts.insert({ account, overwrite: true });
|
|
134
141
|
}
|
|
135
142
|
await bindSignerAccountKey(signer, this.midenClient, accountId);
|
|
136
|
-
return new Multisig(account, config, this._guardianClient, signer, this.midenClient, accountId, this.midenRpcEndpoint);
|
|
143
|
+
return new Multisig(account, config, this._guardianClient, signer, this.midenClient, accountId, this.midenRpcEndpoint, this.proverConfig);
|
|
137
144
|
}
|
|
138
145
|
}
|
|
139
146
|
//# 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;;;;;GAKG;AAEH,OAAO,EAAoB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAqB,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAqB,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEjG,OAAO,EACL,mBAAmB,GAGpB,MAAM,oBAAoB,CAAC;AAM5B,KAAK,UAAU,oBAAo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W,EAAE,SAAS,CAAC,CAAC;QAEhE,OAAO,IAAI,QAAQ,CACjB,OAAO,EACP,MAAM,EACN,IAAI,CAAC,eAAe,EACpB,MAAM,EACN,IAAI,CAAC,WAAW,EAChB,SAAS,EACT,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,YAAY,CAClB,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
* const client = new MultisigClient(midenClient, {
|
|
26
26
|
* guardianEndpoint: 'http://localhost:3000',
|
|
27
27
|
* midenRpcEndpoint: 'https://rpc.devnet.miden.io',
|
|
28
|
+
* prover: {
|
|
29
|
+
* url: 'https://prover.example',
|
|
30
|
+
* retry: { maxAttempts: 4 },
|
|
31
|
+
* },
|
|
28
32
|
* });
|
|
29
33
|
*
|
|
30
34
|
* // Get GUARDIAN pubkey for config
|
|
@@ -40,6 +44,7 @@
|
|
|
40
44
|
* ```
|
|
41
45
|
*/
|
|
42
46
|
export { MultisigClient, type MultisigClientConfig, type RecoveredAccount, } from './client.js';
|
|
47
|
+
export type { ProverConfig, ProverRetryPolicy } from './prover/config.js';
|
|
43
48
|
export { lookupAuthDigest } from './lookupAuth.js';
|
|
44
49
|
export { Multisig, type AccountState } from './multisig.js';
|
|
45
50
|
export { AccountInspector, type DetectedMultisigConfig, type VaultBalance } from './inspector.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,YAAY,E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E5B,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAChC,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,KAAK,qBAAqB,EAC1B,wBAAwB,EACxB,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,YAAY,EACZ,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,KAAK,aAAa,GACnB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAEV,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAGlB,QAAQ,EACR,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,6BAA6B,EAC7B,mBAAmB,EACnB,4BAA4B,EAC5B,yBAAyB,EAGzB,eAAe,EAGf,cAAc,EACd,SAAS,EAGT,eAAe,EACf,MAAM,EACN,eAAe,EAGf,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,iBAAiB,EAGjB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
* const client = new MultisigClient(midenClient, {
|
|
26
26
|
* guardianEndpoint: 'http://localhost:3000',
|
|
27
27
|
* midenRpcEndpoint: 'https://rpc.devnet.miden.io',
|
|
28
|
+
* prover: {
|
|
29
|
+
* url: 'https://prover.example',
|
|
30
|
+
* retry: { maxAttempts: 4 },
|
|
31
|
+
* },
|
|
28
32
|
* });
|
|
29
33
|
*
|
|
30
34
|
* // Get GUARDIAN pubkey for config
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EACL,cAAc,GAGf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAqB,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAkD,MAAM,gBAAgB,CAAC;AAClG,OAAO,EACL,iBAAiB,EACjB,oCAAoC,EACpC,+CAA+C,EAC/C,qCAAqC,EACrC,mCAAmC,EACnC,2BAA2B,EAC3B,iBAAiB,EACjB,sBAAsB,GAEvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEtF,yEAAyE;AACzE,iEAAiE;AACjE,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AAGvC,yEAAyE;AACzE,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG5E,OAAO,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,iBAAiB,GAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAChC,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAEL,wBAAwB,EACxB,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,YAAY,EACZ,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAElB,MAAM,iBAAiB,CAAC"}
|
package/dist/multisig.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ConsumableNote, ExportedProposal, MultisigConfig, Proposal, Propos
|
|
|
9
9
|
import type { ProcedureName } from './procedures.js';
|
|
10
10
|
import type { MidenClient } from '@miden-sdk/miden-sdk';
|
|
11
11
|
import { Account, AdviceMap, NoteType, TransactionRequest } from '@miden-sdk/miden-sdk';
|
|
12
|
+
import { type ResolvedProverConfig } from './prover/config.js';
|
|
12
13
|
/**
|
|
13
14
|
* Result of fetching account state from GUARDIAN.
|
|
14
15
|
*/
|
|
@@ -38,11 +39,11 @@ export declare class Multisig {
|
|
|
38
39
|
private readonly signer;
|
|
39
40
|
private readonly midenClient;
|
|
40
41
|
private readonly rawClientPromise;
|
|
41
|
-
private readonly
|
|
42
|
+
private readonly proverWorkflow;
|
|
42
43
|
private readonly _accountId;
|
|
43
44
|
private readonly midenRpcEndpoint;
|
|
44
45
|
private proposals;
|
|
45
|
-
constructor(account: Account, config: MultisigConfig, guardian: GuardianHttpClient, signer: Signer, midenClient: MidenClient, accountId: string | undefined, midenRpcEndpoint: string);
|
|
46
|
+
constructor(account: Account, config: MultisigConfig, guardian: GuardianHttpClient, signer: Signer, midenClient: MidenClient, accountId: string | undefined, midenRpcEndpoint: string, proverConfig?: ResolvedProverConfig);
|
|
46
47
|
private getMidenRpcEndpoint;
|
|
47
48
|
private getRawClient;
|
|
48
49
|
private proposalFactory;
|
|
@@ -201,6 +202,66 @@ export declare class Multisig {
|
|
|
201
202
|
* immediately by the multisig account.
|
|
202
203
|
*/
|
|
203
204
|
getConsumableNotes(): Promise<ConsumableNote[]>;
|
|
205
|
+
/**
|
|
206
|
+
* Export a note created by this multisig account as serialized note-file
|
|
207
|
+
* bytes for out-of-band delivery (issue #356).
|
|
208
|
+
*
|
|
209
|
+
* A private note publishes only its commitment on chain, so the recipient
|
|
210
|
+
* can never learn its contents via sync; the sender must hand them the
|
|
211
|
+
* bytes produced here, which they load with {@link importNoteFromBytes}.
|
|
212
|
+
*
|
|
213
|
+
* The note must be an output note of this client (created by a transaction
|
|
214
|
+
* this client executed). When the note's on-chain inclusion proof is
|
|
215
|
+
* already known (after a post-commit sync) the full note with proof is
|
|
216
|
+
* exported; otherwise the note details are exported and the importer's
|
|
217
|
+
* client tracks the note until it commits on chain.
|
|
218
|
+
*
|
|
219
|
+
* @param noteId - ID of the note to export (hex string)
|
|
220
|
+
* @returns Serialized note file bytes
|
|
221
|
+
*/
|
|
222
|
+
exportNoteToBytes(noteId: string): Promise<Uint8Array>;
|
|
223
|
+
/**
|
|
224
|
+
* Export a note created by this multisig account as a note file downloaded
|
|
225
|
+
* by the browser (issue #356). Browser-only convenience over
|
|
226
|
+
* {@link exportNoteToBytes}; use that method directly in non-DOM
|
|
227
|
+
* environments.
|
|
228
|
+
*
|
|
229
|
+
* @param noteId - ID of the note to export (hex string)
|
|
230
|
+
* @param filename - Download filename; defaults to `note_<id>.mno`
|
|
231
|
+
*/
|
|
232
|
+
exportNoteToFile(noteId: string, filename?: string): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Import a note file received out-of-band (issue #356) so the note can be
|
|
235
|
+
* consumed by this multisig account.
|
|
236
|
+
*
|
|
237
|
+
* Sync the Miden client with the network afterwards so the note's on-chain
|
|
238
|
+
* commitment is tracked and the note shows up in {@link getConsumableNotes};
|
|
239
|
+
* it can then be consumed via {@link createConsumeNotesProposal}.
|
|
240
|
+
*
|
|
241
|
+
* @param noteBytes - Serialized note file bytes produced by
|
|
242
|
+
* {@link exportNoteToBytes}
|
|
243
|
+
* @returns The note ID when the file carries one, or the note's details
|
|
244
|
+
* commitment for a details-only file
|
|
245
|
+
*/
|
|
246
|
+
importNoteFromBytes(noteBytes: Uint8Array): Promise<string>;
|
|
247
|
+
/**
|
|
248
|
+
* Import a note file received out-of-band (issue #356) from a browser
|
|
249
|
+
* `File`/`Blob` (e.g. a file-input selection). See
|
|
250
|
+
* {@link importNoteFromBytes} for the returned identifier semantics.
|
|
251
|
+
*/
|
|
252
|
+
importNoteFromFile(file: Blob): Promise<string>;
|
|
253
|
+
/**
|
|
254
|
+
* Compute the ID of the note a P2ID proposal will create when executed.
|
|
255
|
+
*
|
|
256
|
+
* The P2ID note is rebuilt deterministically from the proposal salt, so the
|
|
257
|
+
* ID is known ahead of execution. For a private P2ID this is the ID to pass
|
|
258
|
+
* to {@link exportNoteToBytes} after executing, so the note file can be delivered
|
|
259
|
+
* to the recipient out-of-band (issue #356).
|
|
260
|
+
*
|
|
261
|
+
* Call this before executing the proposal: the asset is derived from the
|
|
262
|
+
* current vault state, which execution itself changes.
|
|
263
|
+
*/
|
|
264
|
+
getP2idNoteId(proposal: Proposal): Promise<string>;
|
|
204
265
|
/**
|
|
205
266
|
* Sign a proposal.
|
|
206
267
|
*
|
package/dist/multisig.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multisig.d.ts","sourceRoot":"","sources":["../src/multisig.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,KAAK,aAAa,EAA4C,KAAK,MAAM,EAAqC,MAAM,+BAA+B,CAAC;AAChN,OAAO,KAAK,EACV,cAAc,EACd,gBA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B,CAAC;IAKvF;;;;OAIG;IACG,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAyDxD;;;;OAIG;IACG,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE;;;;;;OAMG;IACG,oBAAoB,CACxB,uBAAuB,EAAE,UAAU,EACnC,YAAY,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,CAAC;IAgCpB;;;;;;;;;OASG;IACG,sBAAsB,CAC1B,UAAU,EAAE,MAAM,EAClB,uBAAuB,EAAE,UAAU,GAClC,OAAO,CAAC,SAAS,CAAC;YAqDP,oBAAoB;IAgGlC,OAAO,CAAC,gBAAgB;YAKV,wBAAwB;IAiKtC;;OAEG;IACG,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA+BnE;;;;;OAKG;IACH,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAwBhD;;;;;OAKG;IACG,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAcrD;;;;;OAKG;IACG,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA4D9D,OAAO,CAAC,sCAAsC;YAahC,6BAA6B;YAqC7B,mCAAmC;CAmGlD"}
|
package/dist/multisig.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* for proposal management.
|
|
6
6
|
*/
|
|
7
7
|
import { GuardianHttpClient } from '@openzeppelin/guardian-client';
|
|
8
|
-
import { Account, AccountId, AdviceMap, Endpoint, FeltArray, Note, RpcClient, Signature, TransactionRequest, TransactionSummary, Word, } from '@miden-sdk/miden-sdk';
|
|
9
|
-
import { executeForSummary, buildUpdateSignersTransactionRequest, buildUpdateProcedureThresholdTransactionRequest, buildUpdateGuardianTransactionRequest, buildConsumeNotesTransactionRequest, buildP2idTransactionRequest, parseP2idNoteType, p2idNoteTypeToMetadata, } from './transaction.js';
|
|
8
|
+
import { Account, AccountId, AdviceMap, Endpoint, FeltArray, Note, NoteExportFormat, NoteFile, RpcClient, Signature, TransactionRequest, TransactionSummary, Word, } from '@miden-sdk/miden-sdk';
|
|
9
|
+
import { executeForSummary, buildUpdateSignersTransactionRequest, buildUpdateProcedureThresholdTransactionRequest, buildUpdateGuardianTransactionRequest, buildConsumeNotesTransactionRequest, buildP2idNoteFromMetadata, buildP2idTransactionRequest, parseP2idNoteType, p2idNoteTypeToMetadata, } from './transaction.js';
|
|
10
10
|
import { buildConsumeNotesTransactionRequestFromNotes } from './transaction/consumeNotes.js';
|
|
11
11
|
import { CONSUME_NOTES_METADATA_VERSION_V2, MAX_CONSUME_NOTES_METADATA_BYTES, } from './types/proposal.js';
|
|
12
12
|
import { LEGACY_CONSUME_NOTES_ENABLED } from './multisig/config.js';
|
|
@@ -21,6 +21,8 @@ import { ProposalFactory } from './proposal/factory.js';
|
|
|
21
21
|
import { ProposalMetadataCodec } from './proposal/metadata.js';
|
|
22
22
|
import { ProposalSignatures } from './proposal/signatures.js';
|
|
23
23
|
import { getRawMidenClient, getTransactionProver, requireMidenRpcEndpoint, } from './raw-client.js';
|
|
24
|
+
import { resolveProverConfig, } from './prover/config.js';
|
|
25
|
+
import { ProverWorkflow } from './prover/workflow.js';
|
|
24
26
|
/**
|
|
25
27
|
* Represents a multisig account with GUARDIAN integration.
|
|
26
28
|
*/
|
|
@@ -60,11 +62,11 @@ export class Multisig {
|
|
|
60
62
|
signer;
|
|
61
63
|
midenClient;
|
|
62
64
|
rawClientPromise;
|
|
63
|
-
|
|
65
|
+
proverWorkflow;
|
|
64
66
|
_accountId;
|
|
65
67
|
midenRpcEndpoint;
|
|
66
68
|
proposals = new Map();
|
|
67
|
-
constructor(account, config, guardian, signer, midenClient, accountId, midenRpcEndpoint) {
|
|
69
|
+
constructor(account, config, guardian, signer, midenClient, accountId, midenRpcEndpoint, proverConfig) {
|
|
68
70
|
this.account = account;
|
|
69
71
|
this.threshold = config.threshold;
|
|
70
72
|
this.signerCommitments = config.signerCommitments;
|
|
@@ -76,8 +78,8 @@ export class Multisig {
|
|
|
76
78
|
this.midenClient = midenClient;
|
|
77
79
|
this._accountId = accountId ?? (account ? accountIdToHex(account) : '');
|
|
78
80
|
this.midenRpcEndpoint = requireMidenRpcEndpoint(midenRpcEndpoint);
|
|
79
|
-
this.transactionProver = getTransactionProver(midenClient);
|
|
80
81
|
this.rawClientPromise = getRawMidenClient(midenClient, this.midenRpcEndpoint);
|
|
82
|
+
this.proverWorkflow = new ProverWorkflow(this.midenClient, proverConfig ?? resolveProverConfig(undefined, getTransactionProver(midenClient)));
|
|
81
83
|
}
|
|
82
84
|
getMidenRpcEndpoint() {
|
|
83
85
|
return this.midenRpcEndpoint;
|
|
@@ -659,6 +661,128 @@ export class Multisig {
|
|
|
659
661
|
}
|
|
660
662
|
return notes;
|
|
661
663
|
}
|
|
664
|
+
/**
|
|
665
|
+
* Export a note created by this multisig account as serialized note-file
|
|
666
|
+
* bytes for out-of-band delivery (issue #356).
|
|
667
|
+
*
|
|
668
|
+
* A private note publishes only its commitment on chain, so the recipient
|
|
669
|
+
* can never learn its contents via sync; the sender must hand them the
|
|
670
|
+
* bytes produced here, which they load with {@link importNoteFromBytes}.
|
|
671
|
+
*
|
|
672
|
+
* The note must be an output note of this client (created by a transaction
|
|
673
|
+
* this client executed). When the note's on-chain inclusion proof is
|
|
674
|
+
* already known (after a post-commit sync) the full note with proof is
|
|
675
|
+
* exported; otherwise the note details are exported and the importer's
|
|
676
|
+
* client tracks the note until it commits on chain.
|
|
677
|
+
*
|
|
678
|
+
* @param noteId - ID of the note to export (hex string)
|
|
679
|
+
* @returns Serialized note file bytes
|
|
680
|
+
*/
|
|
681
|
+
async exportNoteToBytes(noteId) {
|
|
682
|
+
const webClient = await this.getRawClient();
|
|
683
|
+
const trimmedNoteId = noteId.trim();
|
|
684
|
+
let record;
|
|
685
|
+
try {
|
|
686
|
+
record = await webClient.getOutputNote(trimmedNoteId);
|
|
687
|
+
}
|
|
688
|
+
catch (err) {
|
|
689
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
690
|
+
throw new Error(`Output note ${trimmedNoteId} not found in the local store; only notes created by this client can be exported: ${detail}`);
|
|
691
|
+
}
|
|
692
|
+
if (!record) {
|
|
693
|
+
throw new Error(`Output note ${trimmedNoteId} not found in the local store; only notes created by this client can be exported`);
|
|
694
|
+
}
|
|
695
|
+
const format = record.inclusionProof()
|
|
696
|
+
? NoteExportFormat.Full
|
|
697
|
+
: NoteExportFormat.Details;
|
|
698
|
+
const noteFile = await webClient.exportNoteFile(trimmedNoteId, format);
|
|
699
|
+
return noteFile.serialize();
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Export a note created by this multisig account as a note file downloaded
|
|
703
|
+
* by the browser (issue #356). Browser-only convenience over
|
|
704
|
+
* {@link exportNoteToBytes}; use that method directly in non-DOM
|
|
705
|
+
* environments.
|
|
706
|
+
*
|
|
707
|
+
* @param noteId - ID of the note to export (hex string)
|
|
708
|
+
* @param filename - Download filename; defaults to `note_<id>.mno`
|
|
709
|
+
*/
|
|
710
|
+
async exportNoteToFile(noteId, filename) {
|
|
711
|
+
if (typeof document === 'undefined') {
|
|
712
|
+
throw new Error('exportNoteToFile requires a browser environment; use exportNoteToBytes instead');
|
|
713
|
+
}
|
|
714
|
+
const trimmedNoteId = noteId.trim();
|
|
715
|
+
const noteBytes = await this.exportNoteToBytes(trimmedNoteId);
|
|
716
|
+
const blob = new Blob([noteBytes], { type: 'application/octet-stream' });
|
|
717
|
+
const url = URL.createObjectURL(blob);
|
|
718
|
+
try {
|
|
719
|
+
const anchor = document.createElement('a');
|
|
720
|
+
anchor.href = url;
|
|
721
|
+
anchor.download = filename ?? `note_${trimmedNoteId}.mno`;
|
|
722
|
+
anchor.click();
|
|
723
|
+
}
|
|
724
|
+
finally {
|
|
725
|
+
URL.revokeObjectURL(url);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Import a note file received out-of-band (issue #356) so the note can be
|
|
730
|
+
* consumed by this multisig account.
|
|
731
|
+
*
|
|
732
|
+
* Sync the Miden client with the network afterwards so the note's on-chain
|
|
733
|
+
* commitment is tracked and the note shows up in {@link getConsumableNotes};
|
|
734
|
+
* it can then be consumed via {@link createConsumeNotesProposal}.
|
|
735
|
+
*
|
|
736
|
+
* @param noteBytes - Serialized note file bytes produced by
|
|
737
|
+
* {@link exportNoteToBytes}
|
|
738
|
+
* @returns The note ID when the file carries one, or the note's details
|
|
739
|
+
* commitment for a details-only file
|
|
740
|
+
*/
|
|
741
|
+
async importNoteFromBytes(noteBytes) {
|
|
742
|
+
const webClient = await this.getRawClient();
|
|
743
|
+
let noteFile;
|
|
744
|
+
try {
|
|
745
|
+
noteFile = NoteFile.deserialize(noteBytes);
|
|
746
|
+
}
|
|
747
|
+
catch (err) {
|
|
748
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
749
|
+
throw new Error(`failed to decode note file: ${detail}`);
|
|
750
|
+
}
|
|
751
|
+
return webClient.importNoteFile(noteFile);
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Import a note file received out-of-band (issue #356) from a browser
|
|
755
|
+
* `File`/`Blob` (e.g. a file-input selection). See
|
|
756
|
+
* {@link importNoteFromBytes} for the returned identifier semantics.
|
|
757
|
+
*/
|
|
758
|
+
async importNoteFromFile(file) {
|
|
759
|
+
const noteBytes = new Uint8Array(await file.arrayBuffer());
|
|
760
|
+
return this.importNoteFromBytes(noteBytes);
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Compute the ID of the note a P2ID proposal will create when executed.
|
|
764
|
+
*
|
|
765
|
+
* The P2ID note is rebuilt deterministically from the proposal salt, so the
|
|
766
|
+
* ID is known ahead of execution. For a private P2ID this is the ID to pass
|
|
767
|
+
* to {@link exportNoteToBytes} after executing, so the note file can be delivered
|
|
768
|
+
* to the recipient out-of-band (issue #356).
|
|
769
|
+
*
|
|
770
|
+
* Call this before executing the proposal: the asset is derived from the
|
|
771
|
+
* current vault state, which execution itself changes.
|
|
772
|
+
*/
|
|
773
|
+
async getP2idNoteId(proposal) {
|
|
774
|
+
const metadata = proposal.metadata;
|
|
775
|
+
if (metadata.proposalType !== 'p2id' ||
|
|
776
|
+
!metadata.recipientId ||
|
|
777
|
+
!metadata.faucetId ||
|
|
778
|
+
!metadata.amount ||
|
|
779
|
+
!metadata.saltHex) {
|
|
780
|
+
throw new Error('getP2idNoteId requires a P2ID proposal with recipient, faucet, amount, and salt metadata');
|
|
781
|
+
}
|
|
782
|
+
const account = await this.getStoreAccount();
|
|
783
|
+
const note = buildP2idNoteFromMetadata(this._accountId, metadata.recipientId, metadata.faucetId, BigInt(metadata.amount), account, parseP2idNoteType(metadata.noteType), metadata.saltHex);
|
|
784
|
+
return note.id().toString();
|
|
785
|
+
}
|
|
662
786
|
/**
|
|
663
787
|
* Sign a proposal.
|
|
664
788
|
*
|
|
@@ -738,7 +862,7 @@ export class Multisig {
|
|
|
738
862
|
async executeProposal(proposalId) {
|
|
739
863
|
const { metadata, finalRequest, proposal } = await this.prepareProposalExecution(proposalId);
|
|
740
864
|
const accountId = AccountId.fromHex(this._accountId);
|
|
741
|
-
await this.
|
|
865
|
+
await this.proverWorkflow.submit(accountId, finalRequest);
|
|
742
866
|
if (metadata.proposalType === 'switch_guardian') {
|
|
743
867
|
if (!metadata.newGuardianEndpoint || !metadata.newGuardianPubkey) {
|
|
744
868
|
throw new Error('Switch GUARDIAN proposal metadata is incomplete after execution');
|
|
@@ -784,7 +908,7 @@ export class Multisig {
|
|
|
784
908
|
* after `prepareCustomExecution` rebuilds its request with the returned advice.
|
|
785
909
|
*/
|
|
786
910
|
async submitTransaction(request) {
|
|
787
|
-
await this.
|
|
911
|
+
await this.proverWorkflow.submit(AccountId.fromHex(this._accountId), request);
|
|
788
912
|
}
|
|
789
913
|
/**
|
|
790
914
|
* Create a proposal from a producer-built transaction the SDK does not model
|