@unlink-xyz/multisig 0.1.5 → 0.1.6
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/dist/browser/index.js +226 -55
- package/dist/browser/index.js.map +1 -1
- package/dist/src/frost/account.d.ts +2 -0
- package/dist/src/frost/account.d.ts.map +1 -1
- package/dist/src/frost/account.js +10 -9
- package/dist/src/frost/coordinator.d.ts +8 -1
- package/dist/src/frost/coordinator.d.ts.map +1 -1
- package/dist/src/frost/coordinator.js +43 -19
- package/dist/src/frost/listener.d.ts.map +1 -1
- package/dist/src/frost/listener.js +1 -1
- package/dist/src/frost/serialization.d.ts +1 -0
- package/dist/src/frost/serialization.d.ts.map +1 -1
- package/dist/src/frost/serialization.js +6 -1
- package/dist/src/frost/types.d.ts +2 -0
- package/dist/src/frost/types.d.ts.map +1 -1
- package/dist/src/wallet/types.d.ts +1 -0
- package/dist/src/wallet/types.d.ts.map +1 -1
- package/dist/src/wallet/wallet.d.ts.map +1 -1
- package/dist/src/wallet/wallet.js +4 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -11,6 +11,7 @@ export declare function createMultisig(params: {
|
|
|
11
11
|
threshold: number;
|
|
12
12
|
totalShares: number;
|
|
13
13
|
gatewayUrl: string;
|
|
14
|
+
frostUrl?: string;
|
|
14
15
|
viewingKeyPair?: ViewingKeyPair;
|
|
15
16
|
}): Promise<{
|
|
16
17
|
groupId: string;
|
|
@@ -19,6 +20,7 @@ export declare function createMultisig(params: {
|
|
|
19
20
|
export declare function joinMultisig(params: {
|
|
20
21
|
code: string;
|
|
21
22
|
gatewayUrl: string;
|
|
23
|
+
frostUrl?: string;
|
|
22
24
|
viewingKeyPair?: ViewingKeyPair;
|
|
23
25
|
}): Promise<MultisigAccount>;
|
|
24
26
|
export declare function signMultisig(params: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/frost/account.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAIL,KAAK,MAAM,EACZ,MAAM,kBAAkB,CAAC;AAU1B,OAAO,KAAK,EAIV,cAAc,EACd,eAAe,EACf,cAAc,EACf,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/frost/account.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAIL,KAAK,MAAM,EACZ,MAAM,kBAAkB,CAAC;AAU1B,OAAO,KAAK,EAIV,cAAc,EACd,eAAe,EACf,cAAc,EACf,MAAM,YAAY,CAAC;AA6EpB,wBAAsB,cAAc,CAAC,MAAM,EAAE;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAA;CAAE,CAAC,CAyDzE;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,GAAG,OAAO,CAAC,eAAe,CAAC,CAyC3B;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE;IACzC,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,GAAG,OAAO,CAAC,cAAc,CAAC,CA0C1B;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,GAAG,MAAM,CAwBT"}
|
|
@@ -10,8 +10,8 @@ import { FrostCoordinator } from "./coordinator.js";
|
|
|
10
10
|
import { babyjubjub, modMul } from "./curve.js";
|
|
11
11
|
import { dkgFinalize, dkgRound1, dkgRound2 } from "./dkg.js";
|
|
12
12
|
import { aggregateSignatures, generateCommitment, generateSignatureShare, } from "./signing.js";
|
|
13
|
-
function
|
|
14
|
-
return `${gatewayUrl.replace(/\/$/, "")}/frost`;
|
|
13
|
+
function resolveFrostUrl(gatewayUrl, explicitFrostUrl) {
|
|
14
|
+
return explicitFrostUrl ?? `${gatewayUrl.replace(/\/$/, "")}/frost`;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* Derive a participant's verification share from coefficient commitments.
|
|
@@ -29,7 +29,7 @@ function deriveVerificationShare(participantIndex, coefficientCommitments) {
|
|
|
29
29
|
}
|
|
30
30
|
return result;
|
|
31
31
|
}
|
|
32
|
-
function buildMultisigAccount(result, viewingKeyPair, groupId, config, participantIndex, gatewayUrl) {
|
|
32
|
+
function buildMultisigAccount(result, viewingKeyPair, groupId, config, participantIndex, gatewayUrl, frostUrl) {
|
|
33
33
|
const nullifyingKey = computeNullifyingKey(viewingKeyPair.privateKey);
|
|
34
34
|
const masterPublicKey = computeMasterPublicKey(result.groupPublicKey, nullifyingKey);
|
|
35
35
|
const address = encodeAddress({
|
|
@@ -47,6 +47,7 @@ function buildMultisigAccount(result, viewingKeyPair, groupId, config, participa
|
|
|
47
47
|
nullifyingKey,
|
|
48
48
|
masterPublicKey,
|
|
49
49
|
gatewayUrl,
|
|
50
|
+
...(frostUrl !== undefined ? { frostUrl } : {}),
|
|
50
51
|
address,
|
|
51
52
|
};
|
|
52
53
|
}
|
|
@@ -69,7 +70,7 @@ export async function createMultisig(params) {
|
|
|
69
70
|
totalShares: params.totalShares,
|
|
70
71
|
};
|
|
71
72
|
const coordinator = new FrostCoordinator({
|
|
72
|
-
baseUrl:
|
|
73
|
+
baseUrl: resolveFrostUrl(params.gatewayUrl, params.frostUrl),
|
|
73
74
|
});
|
|
74
75
|
const { code } = await coordinator.createDkgSession(config.threshold, config.totalShares);
|
|
75
76
|
// Round 1 — generate + submit eagerly so joiners see it
|
|
@@ -88,13 +89,13 @@ export async function createMultisig(params) {
|
|
|
88
89
|
if (!viewingKeyPair) {
|
|
89
90
|
throw new Error("No viewing key available after DKG — at least one participant must provide a viewingKeyPair");
|
|
90
91
|
}
|
|
91
|
-
return buildMultisigAccount(result, viewingKeyPair, code, config, 1, params.gatewayUrl);
|
|
92
|
+
return buildMultisigAccount(result, viewingKeyPair, code, config, 1, params.gatewayUrl, params.frostUrl);
|
|
92
93
|
},
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
96
|
export async function joinMultisig(params) {
|
|
96
97
|
const coordinator = new FrostCoordinator({
|
|
97
|
-
baseUrl:
|
|
98
|
+
baseUrl: resolveFrostUrl(params.gatewayUrl, params.frostUrl),
|
|
98
99
|
});
|
|
99
100
|
const { participantIndex, threshold, totalParticipants } = await coordinator.joinDkgSession(params.code);
|
|
100
101
|
const config = { threshold, totalShares: totalParticipants };
|
|
@@ -110,11 +111,11 @@ export async function joinMultisig(params) {
|
|
|
110
111
|
if (!viewingKeyPair) {
|
|
111
112
|
throw new Error("No viewing key available after DKG — at least one participant must provide a viewingKeyPair");
|
|
112
113
|
}
|
|
113
|
-
return buildMultisigAccount(result, viewingKeyPair, params.code, config, participantIndex, params.gatewayUrl);
|
|
114
|
+
return buildMultisigAccount(result, viewingKeyPair, params.code, config, participantIndex, params.gatewayUrl, params.frostUrl);
|
|
114
115
|
}
|
|
115
116
|
export async function signMultisig(params) {
|
|
116
117
|
const coordinator = new FrostCoordinator({
|
|
117
|
-
baseUrl:
|
|
118
|
+
baseUrl: resolveFrostUrl(params.account.gatewayUrl, params.account.frostUrl),
|
|
118
119
|
});
|
|
119
120
|
const { nonces, commitment } = generateCommitment(params.account.participantIndex);
|
|
120
121
|
await coordinator.submitCommitment(params.signingSessionCode, commitment);
|
|
@@ -147,7 +148,7 @@ export function createFrostSigner(params) {
|
|
|
147
148
|
publicKey: params.account.groupPublicKey,
|
|
148
149
|
sign: async (message) => {
|
|
149
150
|
const coordinator = new FrostCoordinator({
|
|
150
|
-
baseUrl:
|
|
151
|
+
baseUrl: resolveFrostUrl(params.account.gatewayUrl, params.account.frostUrl),
|
|
151
152
|
});
|
|
152
153
|
const { code } = await coordinator.createSigningSession(params.participants, message, params.account.groupId, params.metadata);
|
|
153
154
|
params.onSessionCreated?.(code);
|
|
@@ -7,15 +7,21 @@
|
|
|
7
7
|
import type { DkgRound1Package, DkgRound2Package, SignatureShare, SigningCommitment } from "./types.js";
|
|
8
8
|
export interface CoordinatorConfig {
|
|
9
9
|
baseUrl: string;
|
|
10
|
-
/** Polling interval in ms (default
|
|
10
|
+
/** Polling interval in ms (default 3000) */
|
|
11
11
|
pollIntervalMs?: number;
|
|
12
12
|
/** Timeout in ms (default 60000) */
|
|
13
13
|
timeoutMs?: number;
|
|
14
|
+
/** Max retries for transient errors (default 3) */
|
|
15
|
+
maxRetries?: number;
|
|
16
|
+
/** Initial retry delay in ms (default 500) */
|
|
17
|
+
retryDelayMs?: number;
|
|
14
18
|
}
|
|
15
19
|
export declare class FrostCoordinator {
|
|
16
20
|
private baseUrl;
|
|
17
21
|
private pollIntervalMs;
|
|
18
22
|
private timeoutMs;
|
|
23
|
+
private maxRetries;
|
|
24
|
+
private retryDelayMs;
|
|
19
25
|
constructor(config: CoordinatorConfig);
|
|
20
26
|
createDkgSession(threshold: number, totalParticipants: number): Promise<{
|
|
21
27
|
code: string;
|
|
@@ -48,6 +54,7 @@ export declare class FrostCoordinator {
|
|
|
48
54
|
private pollCommitments;
|
|
49
55
|
private pollShares;
|
|
50
56
|
private pollUntilComplete;
|
|
57
|
+
private fetchWithRetry;
|
|
51
58
|
private toError;
|
|
52
59
|
}
|
|
53
60
|
export type SigningSessionInfo = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../src/frost/coordinator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../src/frost/coordinator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAS;gBAEjB,MAAM,EAAE,iBAAiB;IAU/B,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,MAAM,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AA;KAAE,CAAC;IASzC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAS5D,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IASnE,qBAAqB,CACzB,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,kBAAkB,CAAC;YAiBhB,UAAU;YAUV,UAAU;YAUV,eAAe;YAUf,UAAU;YAUV,iBAAiB;YAejB,cAAc;YAkBd,OAAO;CAYtB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC"}
|
|
@@ -9,14 +9,18 @@ export class FrostCoordinator {
|
|
|
9
9
|
baseUrl;
|
|
10
10
|
pollIntervalMs;
|
|
11
11
|
timeoutMs;
|
|
12
|
+
maxRetries;
|
|
13
|
+
retryDelayMs;
|
|
12
14
|
constructor(config) {
|
|
13
15
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
14
|
-
this.pollIntervalMs = config.pollIntervalMs ??
|
|
16
|
+
this.pollIntervalMs = config.pollIntervalMs ?? 3000;
|
|
15
17
|
this.timeoutMs = config.timeoutMs ?? 120000;
|
|
18
|
+
this.maxRetries = config.maxRetries ?? 3;
|
|
19
|
+
this.retryDelayMs = config.retryDelayMs ?? 500;
|
|
16
20
|
}
|
|
17
21
|
// === DKG ===
|
|
18
22
|
async createDkgSession(threshold, totalParticipants) {
|
|
19
|
-
const resp = await
|
|
23
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/dkg/groups`, {
|
|
20
24
|
method: "POST",
|
|
21
25
|
headers: { "Content-Type": "application/json" },
|
|
22
26
|
body: JSON.stringify({
|
|
@@ -30,9 +34,7 @@ export class FrostCoordinator {
|
|
|
30
34
|
return { code: body.code };
|
|
31
35
|
}
|
|
32
36
|
async joinDkgSession(code) {
|
|
33
|
-
const resp = await
|
|
34
|
-
method: "POST",
|
|
35
|
-
});
|
|
37
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/dkg/groups/${code}/join`, { method: "POST" });
|
|
36
38
|
if (!resp.ok)
|
|
37
39
|
throw await this.toError(resp);
|
|
38
40
|
const body = (await resp.json());
|
|
@@ -43,7 +45,7 @@ export class FrostCoordinator {
|
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
47
|
async submitRound1(code, pkg) {
|
|
46
|
-
const resp = await
|
|
48
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/dkg/groups/${code}/round1`, {
|
|
47
49
|
method: "POST",
|
|
48
50
|
headers: { "Content-Type": "application/json" },
|
|
49
51
|
body: JSON.stringify({
|
|
@@ -58,7 +60,7 @@ export class FrostCoordinator {
|
|
|
58
60
|
return this.pollUntilComplete(() => this.pollRound1(code), deserializeDkgRound1Package);
|
|
59
61
|
}
|
|
60
62
|
async submitRound2(code, pkg) {
|
|
61
|
-
const resp = await
|
|
63
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/dkg/groups/${code}/round2`, {
|
|
62
64
|
method: "POST",
|
|
63
65
|
headers: { "Content-Type": "application/json" },
|
|
64
66
|
body: JSON.stringify({
|
|
@@ -84,7 +86,7 @@ export class FrostCoordinator {
|
|
|
84
86
|
if (metadata !== undefined) {
|
|
85
87
|
body.metadata = metadata;
|
|
86
88
|
}
|
|
87
|
-
const resp = await
|
|
89
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/sign/sessions`, {
|
|
88
90
|
method: "POST",
|
|
89
91
|
headers: { "Content-Type": "application/json" },
|
|
90
92
|
body: JSON.stringify(body),
|
|
@@ -95,7 +97,7 @@ export class FrostCoordinator {
|
|
|
95
97
|
return { code: result.code };
|
|
96
98
|
}
|
|
97
99
|
async submitCommitment(code, c) {
|
|
98
|
-
const resp = await
|
|
100
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/sign/sessions/${code}/commitments`, {
|
|
99
101
|
method: "POST",
|
|
100
102
|
headers: { "Content-Type": "application/json" },
|
|
101
103
|
body: JSON.stringify({
|
|
@@ -110,7 +112,7 @@ export class FrostCoordinator {
|
|
|
110
112
|
return this.pollUntilComplete(() => this.pollCommitments(code), deserializeSigningCommitment);
|
|
111
113
|
}
|
|
112
114
|
async submitShare(code, share) {
|
|
113
|
-
const resp = await
|
|
115
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/sign/sessions/${code}/shares`, {
|
|
114
116
|
method: "POST",
|
|
115
117
|
headers: { "Content-Type": "application/json" },
|
|
116
118
|
body: JSON.stringify({
|
|
@@ -125,21 +127,21 @@ export class FrostCoordinator {
|
|
|
125
127
|
return this.pollUntilComplete(() => this.pollShares(code), deserializeSignatureShare);
|
|
126
128
|
}
|
|
127
129
|
async getSigningSessionStatus(code) {
|
|
128
|
-
const resp = await
|
|
130
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/sign/sessions/${code}/status`);
|
|
129
131
|
if (!resp.ok)
|
|
130
132
|
throw await this.toError(resp);
|
|
131
133
|
const body = (await resp.json());
|
|
132
134
|
return { ...body, message: deserializeBigint(body.message) };
|
|
133
135
|
}
|
|
134
136
|
async getSigningSession(code) {
|
|
135
|
-
const resp = await
|
|
137
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/sign/sessions/${code}`);
|
|
136
138
|
if (!resp.ok)
|
|
137
139
|
throw await this.toError(resp);
|
|
138
140
|
const body = (await resp.json());
|
|
139
141
|
return deserializeSessionInfo(body);
|
|
140
142
|
}
|
|
141
143
|
async listSigningSessions(groupId) {
|
|
142
|
-
const resp = await
|
|
144
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/sign/sessions?group_id=${encodeURIComponent(groupId)}`);
|
|
143
145
|
if (!resp.ok)
|
|
144
146
|
throw await this.toError(resp);
|
|
145
147
|
const body = (await resp.json());
|
|
@@ -155,31 +157,31 @@ export class FrostCoordinator {
|
|
|
155
157
|
if (sessions.length > 0) {
|
|
156
158
|
return sessions[0];
|
|
157
159
|
}
|
|
158
|
-
await sleep(this.pollIntervalMs);
|
|
160
|
+
await sleep(this.pollIntervalMs * (0.8 + Math.random() * 0.4));
|
|
159
161
|
}
|
|
160
162
|
throw new Error("Coordinator polling timeout");
|
|
161
163
|
}
|
|
162
164
|
// === Internal ===
|
|
163
165
|
async pollRound1(code) {
|
|
164
|
-
const resp = await
|
|
166
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/dkg/groups/${code}/round1`);
|
|
165
167
|
if (!resp.ok)
|
|
166
168
|
throw await this.toError(resp);
|
|
167
169
|
return (await resp.json());
|
|
168
170
|
}
|
|
169
171
|
async pollRound2(code) {
|
|
170
|
-
const resp = await
|
|
172
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/dkg/groups/${code}/round2`);
|
|
171
173
|
if (!resp.ok)
|
|
172
174
|
throw await this.toError(resp);
|
|
173
175
|
return (await resp.json());
|
|
174
176
|
}
|
|
175
177
|
async pollCommitments(code) {
|
|
176
|
-
const resp = await
|
|
178
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/sign/sessions/${code}/commitments`);
|
|
177
179
|
if (!resp.ok)
|
|
178
180
|
throw await this.toError(resp);
|
|
179
181
|
return (await resp.json());
|
|
180
182
|
}
|
|
181
183
|
async pollShares(code) {
|
|
182
|
-
const resp = await
|
|
184
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/sign/sessions/${code}/shares`);
|
|
183
185
|
if (!resp.ok)
|
|
184
186
|
throw await this.toError(resp);
|
|
185
187
|
return (await resp.json());
|
|
@@ -191,12 +193,31 @@ export class FrostCoordinator {
|
|
|
191
193
|
if (result.complete) {
|
|
192
194
|
return result.packages.map((p) => deserializeFn(p));
|
|
193
195
|
}
|
|
194
|
-
await sleep(this.pollIntervalMs);
|
|
196
|
+
await sleep(this.pollIntervalMs * (0.8 + Math.random() * 0.4));
|
|
195
197
|
}
|
|
196
198
|
throw new Error("Coordinator polling timeout");
|
|
197
199
|
}
|
|
200
|
+
async fetchWithRetry(url, init) {
|
|
201
|
+
let lastError;
|
|
202
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
203
|
+
if (attempt > 0) {
|
|
204
|
+
await sleep(this.retryDelayMs * 2 ** (attempt - 1));
|
|
205
|
+
}
|
|
206
|
+
const resp = await fetch(url, init);
|
|
207
|
+
if (resp.ok || !isTransientError(resp.status)) {
|
|
208
|
+
return resp;
|
|
209
|
+
}
|
|
210
|
+
lastError = await this.toError(resp);
|
|
211
|
+
}
|
|
212
|
+
throw lastError;
|
|
213
|
+
}
|
|
198
214
|
async toError(resp) {
|
|
199
215
|
const body = await resp.text();
|
|
216
|
+
const isHtml = body.trimStart().startsWith("<") ||
|
|
217
|
+
resp.headers.get("content-type")?.includes("text/html");
|
|
218
|
+
if (isHtml) {
|
|
219
|
+
return new Error(`Coordinator unavailable (HTTP ${resp.status}). The service may be temporarily overloaded — try again shortly.`);
|
|
220
|
+
}
|
|
200
221
|
return new Error(`Coordinator error ${resp.status}: ${body}`);
|
|
201
222
|
}
|
|
202
223
|
}
|
|
@@ -210,6 +231,9 @@ function deserializeSessionInfo(raw) {
|
|
|
210
231
|
metadata: raw.metadata,
|
|
211
232
|
};
|
|
212
233
|
}
|
|
234
|
+
function isTransientError(status) {
|
|
235
|
+
return status === 502 || status === 503 || status === 504;
|
|
236
|
+
}
|
|
213
237
|
function sleep(ms) {
|
|
214
238
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
215
239
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../src/frost/listener.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,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EAAE,WAAW,CAAC;IACrB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5C;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAChE,mFAAmF;IACnF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC;IAC7D,6CAA6C;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAoEf"}
|
|
@@ -15,7 +15,7 @@ export async function runSigningListener(params) {
|
|
|
15
15
|
const { account, signal, onSession, approve, onError } = params;
|
|
16
16
|
const pollIntervalMs = params.pollIntervalMs ?? 1000;
|
|
17
17
|
const coordinator = new FrostCoordinator({
|
|
18
|
-
baseUrl: `${account.gatewayUrl.replace(/\/$/, "")}/frost`,
|
|
18
|
+
baseUrl: account.frostUrl ?? `${account.gatewayUrl.replace(/\/$/, "")}/frost`,
|
|
19
19
|
pollIntervalMs,
|
|
20
20
|
});
|
|
21
21
|
const seen = new Set();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/frost/serialization.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAGhB,WAAW,EACX,eAAe,EAEf,cAAc,EACd,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAIpB,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MA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AID,wBAAgB,uBAAuB,CACrC,CAAC,EAAE,cAAc,GAChB,wBAAwB,CAK1B;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,wBAAwB,GAC7B,cAAc,CAKhB;AAID,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,KAAK,kBAAkB,GAAG;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,OAAO,wBAAwB,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,sBAAsB,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IACvD,cAAc,EAAE,wBAAwB,CAAC;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,eAAe,GACvB,yBAAyB,CA+B3B;AAED,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,yBAAyB,GAC9B,eAAe,CA+BjB"}
|
|
@@ -140,7 +140,7 @@ export function serializeMultisigAccount(account) {
|
|
|
140
140
|
for (const [idx, points] of account.coefficientCommitments) {
|
|
141
141
|
coeffEntries.push([idx, points.map(serializePoint)]);
|
|
142
142
|
}
|
|
143
|
-
|
|
143
|
+
const result = {
|
|
144
144
|
version: MULTISIG_ACCOUNT_VERSION,
|
|
145
145
|
groupId: account.groupId,
|
|
146
146
|
config: account.config,
|
|
@@ -161,6 +161,10 @@ export function serializeMultisigAccount(account) {
|
|
|
161
161
|
gatewayUrl: account.gatewayUrl,
|
|
162
162
|
address: account.address,
|
|
163
163
|
};
|
|
164
|
+
if (account.name !== undefined) {
|
|
165
|
+
result.name = account.name;
|
|
166
|
+
}
|
|
167
|
+
return result;
|
|
164
168
|
}
|
|
165
169
|
export function deserializeMultisigAccount(data) {
|
|
166
170
|
if (data.version !== MULTISIG_ACCOUNT_VERSION) {
|
|
@@ -171,6 +175,7 @@ export function deserializeMultisigAccount(data) {
|
|
|
171
175
|
coefficientCommitments.set(idx, serializedPoints.map(deserializePoint));
|
|
172
176
|
}
|
|
173
177
|
return {
|
|
178
|
+
...(data.name !== undefined ? { name: data.name } : {}),
|
|
174
179
|
groupId: data.groupId,
|
|
175
180
|
config: data.config,
|
|
176
181
|
participantIndex: data.participantIndex,
|
|
@@ -138,6 +138,7 @@ export type DkgResult = {
|
|
|
138
138
|
* High-level multisig account with derived keys and address.
|
|
139
139
|
*/
|
|
140
140
|
export type MultisigAccount = {
|
|
141
|
+
name?: string;
|
|
141
142
|
groupId: string;
|
|
142
143
|
config: FrostConfig;
|
|
143
144
|
participantIndex: number;
|
|
@@ -149,6 +150,7 @@ export type MultisigAccount = {
|
|
|
149
150
|
nullifyingKey: bigint;
|
|
150
151
|
masterPublicKey: bigint;
|
|
151
152
|
gatewayUrl: string;
|
|
153
|
+
frostUrl?: string;
|
|
152
154
|
address: string;
|
|
153
155
|
};
|
|
154
156
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/frost/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE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tE,UAAU,EAAE,UAAU,CAAC;IACvB,oBAAoB;IACpB,KAAK,EAAE,UAAU,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,oFAAoF;IACpF,oBAAoB,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,0EAA0E;IAC1E,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,6DAA6D;IAC7D,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,KAAK,CAAC;IACtB,8EAA8E;IAC9E,sBAAsB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import type { AccountView, Signer } from "@unlink-xyz/core";
|
|
|
2
2
|
import type { MultisigAccount, ViewingKeyPair } from "../frost/types.js";
|
|
3
3
|
export type MultisigWalletConfig = {
|
|
4
4
|
gatewayUrl: string;
|
|
5
|
+
frostUrl?: string;
|
|
5
6
|
};
|
|
6
7
|
export type CreateParams = {
|
|
7
8
|
threshold: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/wallet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEzE,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/wallet/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEzE,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC;QACpC,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;KAC1C,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACnD,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,WAAW,CAAC;IACrD,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAAC;IACjD,oBAAoB,CAClB,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/wallet/wallet.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAKV,cAAc,EACd,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,oBAAoB,GAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/wallet/wallet.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAKV,cAAc,EACd,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,oBAAoB,GAC3B,cAAc,CAqDhB"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createFrostSigner, createMultisig, joinMultisig, } from "../frost/account.js";
|
|
2
2
|
import { FrostCoordinator } from "../frost/coordinator.js";
|
|
3
3
|
export function createMultisigWallet(config) {
|
|
4
|
-
const { gatewayUrl } = config;
|
|
4
|
+
const { gatewayUrl, frostUrl } = config;
|
|
5
5
|
return {
|
|
6
6
|
create(params) {
|
|
7
7
|
return createMultisig({
|
|
8
8
|
threshold: params.threshold,
|
|
9
9
|
totalShares: params.totalShares,
|
|
10
10
|
gatewayUrl,
|
|
11
|
+
frostUrl,
|
|
11
12
|
viewingKeyPair: params.viewingKeyPair,
|
|
12
13
|
});
|
|
13
14
|
},
|
|
@@ -15,6 +16,7 @@ export function createMultisigWallet(config) {
|
|
|
15
16
|
return joinMultisig({
|
|
16
17
|
code: params.code,
|
|
17
18
|
gatewayUrl,
|
|
19
|
+
frostUrl,
|
|
18
20
|
viewingKeyPair: params.viewingKeyPair,
|
|
19
21
|
});
|
|
20
22
|
},
|
|
@@ -36,7 +38,7 @@ export function createMultisigWallet(config) {
|
|
|
36
38
|
},
|
|
37
39
|
async createSigningSession(params) {
|
|
38
40
|
const coordinator = new FrostCoordinator({
|
|
39
|
-
baseUrl: `${gatewayUrl.replace(/\/$/, "")}/frost`,
|
|
41
|
+
baseUrl: frostUrl ?? `${gatewayUrl.replace(/\/$/, "")}/frost`,
|
|
40
42
|
});
|
|
41
43
|
return coordinator.createSigningSession(params.participants, params.message, params.groupId, params.metadata);
|
|
42
44
|
},
|