@unlink-xyz/multisig 0.1.4 → 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 +255 -63
- package/dist/browser/index.js.map +1 -1
- package/dist/src/frost/account.d.ts +8 -0
- package/dist/src/frost/account.d.ts.map +1 -1
- package/dist/src/frost/account.js +16 -10
- package/dist/src/frost/coordinator.d.ts +10 -2
- package/dist/src/frost/coordinator.d.ts.map +1 -1
- package/dist/src/frost/coordinator.js +48 -20
- package/dist/src/frost/listener.d.ts +13 -8
- package/dist/src/frost/listener.d.ts.map +1 -1
- package/dist/src/frost/listener.js +20 -4
- package/dist/src/frost/mock-coordinator.d.ts.map +1 -1
- package/dist/src/frost/mock-coordinator.js +4 -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 +4 -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 +7 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -8
package/dist/browser/index.js
CHANGED
|
@@ -11320,9 +11320,9 @@ function genBech32(encoding) {
|
|
|
11320
11320
|
}
|
|
11321
11321
|
var bech32m = /* @__PURE__ */ genBech32("bech32m");
|
|
11322
11322
|
var VERSION = 1;
|
|
11323
|
-
var LIMIT =
|
|
11323
|
+
var LIMIT = 130;
|
|
11324
11324
|
var ALL_CHAINS = "ffffffffffffffff";
|
|
11325
|
-
var PREFIX = "
|
|
11325
|
+
var PREFIX = "unlink";
|
|
11326
11326
|
var SALT = new TextEncoder().encode("unlink");
|
|
11327
11327
|
function xorWithSalt(hex2) {
|
|
11328
11328
|
const bytes2 = Hex.toBytes(hex2);
|
|
@@ -27982,6 +27982,114 @@ var circuits_default = {
|
|
|
27982
27982
|
template: "JoinSplit",
|
|
27983
27983
|
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
27984
27984
|
params: [5, 2, 16]
|
|
27985
|
+
},
|
|
27986
|
+
joinsplit_1x3_16: {
|
|
27987
|
+
file: "joinsplit",
|
|
27988
|
+
template: "JoinSplit",
|
|
27989
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
27990
|
+
params: [1, 3, 16]
|
|
27991
|
+
},
|
|
27992
|
+
joinsplit_4x3_16: {
|
|
27993
|
+
file: "joinsplit",
|
|
27994
|
+
template: "JoinSplit",
|
|
27995
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
27996
|
+
params: [4, 3, 16]
|
|
27997
|
+
},
|
|
27998
|
+
joinsplit_5x3_16: {
|
|
27999
|
+
file: "joinsplit",
|
|
28000
|
+
template: "JoinSplit",
|
|
28001
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28002
|
+
params: [5, 3, 16]
|
|
28003
|
+
},
|
|
28004
|
+
joinsplit_6x1_16: {
|
|
28005
|
+
file: "joinsplit",
|
|
28006
|
+
template: "JoinSplit",
|
|
28007
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28008
|
+
params: [6, 1, 16]
|
|
28009
|
+
},
|
|
28010
|
+
joinsplit_6x2_16: {
|
|
28011
|
+
file: "joinsplit",
|
|
28012
|
+
template: "JoinSplit",
|
|
28013
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28014
|
+
params: [6, 2, 16]
|
|
28015
|
+
},
|
|
28016
|
+
joinsplit_6x3_16: {
|
|
28017
|
+
file: "joinsplit",
|
|
28018
|
+
template: "JoinSplit",
|
|
28019
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28020
|
+
params: [6, 3, 16]
|
|
28021
|
+
},
|
|
28022
|
+
joinsplit_7x1_16: {
|
|
28023
|
+
file: "joinsplit",
|
|
28024
|
+
template: "JoinSplit",
|
|
28025
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28026
|
+
params: [7, 1, 16]
|
|
28027
|
+
},
|
|
28028
|
+
joinsplit_7x2_16: {
|
|
28029
|
+
file: "joinsplit",
|
|
28030
|
+
template: "JoinSplit",
|
|
28031
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28032
|
+
params: [7, 2, 16]
|
|
28033
|
+
},
|
|
28034
|
+
joinsplit_7x3_16: {
|
|
28035
|
+
file: "joinsplit",
|
|
28036
|
+
template: "JoinSplit",
|
|
28037
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28038
|
+
params: [7, 3, 16]
|
|
28039
|
+
},
|
|
28040
|
+
joinsplit_8x1_16: {
|
|
28041
|
+
file: "joinsplit",
|
|
28042
|
+
template: "JoinSplit",
|
|
28043
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28044
|
+
params: [8, 1, 16]
|
|
28045
|
+
},
|
|
28046
|
+
joinsplit_8x2_16: {
|
|
28047
|
+
file: "joinsplit",
|
|
28048
|
+
template: "JoinSplit",
|
|
28049
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28050
|
+
params: [8, 2, 16]
|
|
28051
|
+
},
|
|
28052
|
+
joinsplit_8x3_16: {
|
|
28053
|
+
file: "joinsplit",
|
|
28054
|
+
template: "JoinSplit",
|
|
28055
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28056
|
+
params: [8, 3, 16]
|
|
28057
|
+
},
|
|
28058
|
+
joinsplit_9x1_16: {
|
|
28059
|
+
file: "joinsplit",
|
|
28060
|
+
template: "JoinSplit",
|
|
28061
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28062
|
+
params: [9, 1, 16]
|
|
28063
|
+
},
|
|
28064
|
+
joinsplit_9x2_16: {
|
|
28065
|
+
file: "joinsplit",
|
|
28066
|
+
template: "JoinSplit",
|
|
28067
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28068
|
+
params: [9, 2, 16]
|
|
28069
|
+
},
|
|
28070
|
+
joinsplit_9x3_16: {
|
|
28071
|
+
file: "joinsplit",
|
|
28072
|
+
template: "JoinSplit",
|
|
28073
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28074
|
+
params: [9, 3, 16]
|
|
28075
|
+
},
|
|
28076
|
+
joinsplit_10x1_16: {
|
|
28077
|
+
file: "joinsplit",
|
|
28078
|
+
template: "JoinSplit",
|
|
28079
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28080
|
+
params: [10, 1, 16]
|
|
28081
|
+
},
|
|
28082
|
+
joinsplit_10x2_16: {
|
|
28083
|
+
file: "joinsplit",
|
|
28084
|
+
template: "JoinSplit",
|
|
28085
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28086
|
+
params: [10, 2, 16]
|
|
28087
|
+
},
|
|
28088
|
+
joinsplit_10x3_16: {
|
|
28089
|
+
file: "joinsplit",
|
|
28090
|
+
template: "JoinSplit",
|
|
28091
|
+
pubs: ["merkleRoot", "boundParamsHash", "nullifiers", "commitmentsOut"],
|
|
28092
|
+
params: [10, 3, 16]
|
|
27985
28093
|
}
|
|
27986
28094
|
};
|
|
27987
28095
|
var registry = {};
|
|
@@ -28605,7 +28713,7 @@ function serializeMultisigAccount(account) {
|
|
|
28605
28713
|
for (const [idx, points] of account.coefficientCommitments) {
|
|
28606
28714
|
coeffEntries.push([idx, points.map(serializePoint)]);
|
|
28607
28715
|
}
|
|
28608
|
-
|
|
28716
|
+
const result = {
|
|
28609
28717
|
version: MULTISIG_ACCOUNT_VERSION,
|
|
28610
28718
|
groupId: account.groupId,
|
|
28611
28719
|
config: account.config,
|
|
@@ -28626,6 +28734,10 @@ function serializeMultisigAccount(account) {
|
|
|
28626
28734
|
gatewayUrl: account.gatewayUrl,
|
|
28627
28735
|
address: account.address
|
|
28628
28736
|
};
|
|
28737
|
+
if (account.name !== void 0) {
|
|
28738
|
+
result.name = account.name;
|
|
28739
|
+
}
|
|
28740
|
+
return result;
|
|
28629
28741
|
}
|
|
28630
28742
|
function deserializeMultisigAccount(data) {
|
|
28631
28743
|
if (data.version !== MULTISIG_ACCOUNT_VERSION) {
|
|
@@ -28636,6 +28748,7 @@ function deserializeMultisigAccount(data) {
|
|
|
28636
28748
|
coefficientCommitments.set(idx, serializedPoints.map(deserializePoint));
|
|
28637
28749
|
}
|
|
28638
28750
|
return {
|
|
28751
|
+
...data.name !== void 0 ? { name: data.name } : {},
|
|
28639
28752
|
groupId: data.groupId,
|
|
28640
28753
|
config: data.config,
|
|
28641
28754
|
participantIndex: data.participantIndex,
|
|
@@ -28662,14 +28775,18 @@ var FrostCoordinator = class {
|
|
|
28662
28775
|
baseUrl;
|
|
28663
28776
|
pollIntervalMs;
|
|
28664
28777
|
timeoutMs;
|
|
28778
|
+
maxRetries;
|
|
28779
|
+
retryDelayMs;
|
|
28665
28780
|
constructor(config3) {
|
|
28666
28781
|
this.baseUrl = config3.baseUrl.replace(/\/$/, "");
|
|
28667
|
-
this.pollIntervalMs = config3.pollIntervalMs ??
|
|
28782
|
+
this.pollIntervalMs = config3.pollIntervalMs ?? 3e3;
|
|
28668
28783
|
this.timeoutMs = config3.timeoutMs ?? 12e4;
|
|
28784
|
+
this.maxRetries = config3.maxRetries ?? 3;
|
|
28785
|
+
this.retryDelayMs = config3.retryDelayMs ?? 500;
|
|
28669
28786
|
}
|
|
28670
28787
|
// === DKG ===
|
|
28671
28788
|
async createDkgSession(threshold, totalParticipants) {
|
|
28672
|
-
const resp = await
|
|
28789
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/dkg/groups`, {
|
|
28673
28790
|
method: "POST",
|
|
28674
28791
|
headers: { "Content-Type": "application/json" },
|
|
28675
28792
|
body: JSON.stringify({
|
|
@@ -28682,9 +28799,10 @@ var FrostCoordinator = class {
|
|
|
28682
28799
|
return { code: body.code };
|
|
28683
28800
|
}
|
|
28684
28801
|
async joinDkgSession(code) {
|
|
28685
|
-
const resp = await
|
|
28686
|
-
|
|
28687
|
-
|
|
28802
|
+
const resp = await this.fetchWithRetry(
|
|
28803
|
+
`${this.baseUrl}/dkg/groups/${code}/join`,
|
|
28804
|
+
{ method: "POST" }
|
|
28805
|
+
);
|
|
28688
28806
|
if (!resp.ok) throw await this.toError(resp);
|
|
28689
28807
|
const body = await resp.json();
|
|
28690
28808
|
return {
|
|
@@ -28694,14 +28812,17 @@ var FrostCoordinator = class {
|
|
|
28694
28812
|
};
|
|
28695
28813
|
}
|
|
28696
28814
|
async submitRound1(code, pkg) {
|
|
28697
|
-
const resp = await
|
|
28698
|
-
|
|
28699
|
-
|
|
28700
|
-
|
|
28701
|
-
|
|
28702
|
-
|
|
28703
|
-
|
|
28704
|
-
|
|
28815
|
+
const resp = await this.fetchWithRetry(
|
|
28816
|
+
`${this.baseUrl}/dkg/groups/${code}/round1`,
|
|
28817
|
+
{
|
|
28818
|
+
method: "POST",
|
|
28819
|
+
headers: { "Content-Type": "application/json" },
|
|
28820
|
+
body: JSON.stringify({
|
|
28821
|
+
participant_index: pkg.participantIndex,
|
|
28822
|
+
data: serializeDkgRound1Package(pkg)
|
|
28823
|
+
})
|
|
28824
|
+
}
|
|
28825
|
+
);
|
|
28705
28826
|
if (!resp.ok) throw await this.toError(resp);
|
|
28706
28827
|
}
|
|
28707
28828
|
async waitForRound1(code) {
|
|
@@ -28711,14 +28832,17 @@ var FrostCoordinator = class {
|
|
|
28711
28832
|
);
|
|
28712
28833
|
}
|
|
28713
28834
|
async submitRound2(code, pkg) {
|
|
28714
|
-
const resp = await
|
|
28715
|
-
|
|
28716
|
-
|
|
28717
|
-
|
|
28718
|
-
|
|
28719
|
-
|
|
28720
|
-
|
|
28721
|
-
|
|
28835
|
+
const resp = await this.fetchWithRetry(
|
|
28836
|
+
`${this.baseUrl}/dkg/groups/${code}/round2`,
|
|
28837
|
+
{
|
|
28838
|
+
method: "POST",
|
|
28839
|
+
headers: { "Content-Type": "application/json" },
|
|
28840
|
+
body: JSON.stringify({
|
|
28841
|
+
participant_index: pkg.participantIndex,
|
|
28842
|
+
data: serializeDkgRound2Package(pkg)
|
|
28843
|
+
})
|
|
28844
|
+
}
|
|
28845
|
+
);
|
|
28722
28846
|
if (!resp.ok) throw await this.toError(resp);
|
|
28723
28847
|
}
|
|
28724
28848
|
async waitForRound2(code) {
|
|
@@ -28728,7 +28852,7 @@ var FrostCoordinator = class {
|
|
|
28728
28852
|
);
|
|
28729
28853
|
}
|
|
28730
28854
|
// === Signing ===
|
|
28731
|
-
async createSigningSession(participants, message, groupId) {
|
|
28855
|
+
async createSigningSession(participants, message, groupId, metadata) {
|
|
28732
28856
|
const body = {
|
|
28733
28857
|
participants,
|
|
28734
28858
|
message: serializeBigint(message)
|
|
@@ -28736,7 +28860,10 @@ var FrostCoordinator = class {
|
|
|
28736
28860
|
if (groupId !== void 0) {
|
|
28737
28861
|
body.group_id = groupId;
|
|
28738
28862
|
}
|
|
28739
|
-
|
|
28863
|
+
if (metadata !== void 0) {
|
|
28864
|
+
body.metadata = metadata;
|
|
28865
|
+
}
|
|
28866
|
+
const resp = await this.fetchWithRetry(`${this.baseUrl}/sign/sessions`, {
|
|
28740
28867
|
method: "POST",
|
|
28741
28868
|
headers: { "Content-Type": "application/json" },
|
|
28742
28869
|
body: JSON.stringify(body)
|
|
@@ -28746,7 +28873,7 @@ var FrostCoordinator = class {
|
|
|
28746
28873
|
return { code: result.code };
|
|
28747
28874
|
}
|
|
28748
28875
|
async submitCommitment(code, c) {
|
|
28749
|
-
const resp = await
|
|
28876
|
+
const resp = await this.fetchWithRetry(
|
|
28750
28877
|
`${this.baseUrl}/sign/sessions/${code}/commitments`,
|
|
28751
28878
|
{
|
|
28752
28879
|
method: "POST",
|
|
@@ -28766,14 +28893,17 @@ var FrostCoordinator = class {
|
|
|
28766
28893
|
);
|
|
28767
28894
|
}
|
|
28768
28895
|
async submitShare(code, share) {
|
|
28769
|
-
const resp = await
|
|
28770
|
-
|
|
28771
|
-
|
|
28772
|
-
|
|
28773
|
-
|
|
28774
|
-
|
|
28775
|
-
|
|
28776
|
-
|
|
28896
|
+
const resp = await this.fetchWithRetry(
|
|
28897
|
+
`${this.baseUrl}/sign/sessions/${code}/shares`,
|
|
28898
|
+
{
|
|
28899
|
+
method: "POST",
|
|
28900
|
+
headers: { "Content-Type": "application/json" },
|
|
28901
|
+
body: JSON.stringify({
|
|
28902
|
+
participant_index: share.participantIndex,
|
|
28903
|
+
data: serializeSignatureShare(share)
|
|
28904
|
+
})
|
|
28905
|
+
}
|
|
28906
|
+
);
|
|
28777
28907
|
if (!resp.ok) throw await this.toError(resp);
|
|
28778
28908
|
}
|
|
28779
28909
|
async waitForShares(code) {
|
|
@@ -28783,19 +28913,23 @@ var FrostCoordinator = class {
|
|
|
28783
28913
|
);
|
|
28784
28914
|
}
|
|
28785
28915
|
async getSigningSessionStatus(code) {
|
|
28786
|
-
const resp = await
|
|
28916
|
+
const resp = await this.fetchWithRetry(
|
|
28917
|
+
`${this.baseUrl}/sign/sessions/${code}/status`
|
|
28918
|
+
);
|
|
28787
28919
|
if (!resp.ok) throw await this.toError(resp);
|
|
28788
28920
|
const body = await resp.json();
|
|
28789
28921
|
return { ...body, message: deserializeBigint(body.message) };
|
|
28790
28922
|
}
|
|
28791
28923
|
async getSigningSession(code) {
|
|
28792
|
-
const resp = await
|
|
28924
|
+
const resp = await this.fetchWithRetry(
|
|
28925
|
+
`${this.baseUrl}/sign/sessions/${code}`
|
|
28926
|
+
);
|
|
28793
28927
|
if (!resp.ok) throw await this.toError(resp);
|
|
28794
28928
|
const body = await resp.json();
|
|
28795
28929
|
return deserializeSessionInfo(body);
|
|
28796
28930
|
}
|
|
28797
28931
|
async listSigningSessions(groupId) {
|
|
28798
|
-
const resp = await
|
|
28932
|
+
const resp = await this.fetchWithRetry(
|
|
28799
28933
|
`${this.baseUrl}/sign/sessions?group_id=${encodeURIComponent(groupId)}`
|
|
28800
28934
|
);
|
|
28801
28935
|
if (!resp.ok) throw await this.toError(resp);
|
|
@@ -28812,30 +28946,36 @@ var FrostCoordinator = class {
|
|
|
28812
28946
|
if (sessions.length > 0) {
|
|
28813
28947
|
return sessions[0];
|
|
28814
28948
|
}
|
|
28815
|
-
await sleep(this.pollIntervalMs);
|
|
28949
|
+
await sleep(this.pollIntervalMs * (0.8 + Math.random() * 0.4));
|
|
28816
28950
|
}
|
|
28817
28951
|
throw new Error("Coordinator polling timeout");
|
|
28818
28952
|
}
|
|
28819
28953
|
// === Internal ===
|
|
28820
28954
|
async pollRound1(code) {
|
|
28821
|
-
const resp = await
|
|
28955
|
+
const resp = await this.fetchWithRetry(
|
|
28956
|
+
`${this.baseUrl}/dkg/groups/${code}/round1`
|
|
28957
|
+
);
|
|
28822
28958
|
if (!resp.ok) throw await this.toError(resp);
|
|
28823
28959
|
return await resp.json();
|
|
28824
28960
|
}
|
|
28825
28961
|
async pollRound2(code) {
|
|
28826
|
-
const resp = await
|
|
28962
|
+
const resp = await this.fetchWithRetry(
|
|
28963
|
+
`${this.baseUrl}/dkg/groups/${code}/round2`
|
|
28964
|
+
);
|
|
28827
28965
|
if (!resp.ok) throw await this.toError(resp);
|
|
28828
28966
|
return await resp.json();
|
|
28829
28967
|
}
|
|
28830
28968
|
async pollCommitments(code) {
|
|
28831
|
-
const resp = await
|
|
28969
|
+
const resp = await this.fetchWithRetry(
|
|
28832
28970
|
`${this.baseUrl}/sign/sessions/${code}/commitments`
|
|
28833
28971
|
);
|
|
28834
28972
|
if (!resp.ok) throw await this.toError(resp);
|
|
28835
28973
|
return await resp.json();
|
|
28836
28974
|
}
|
|
28837
28975
|
async pollShares(code) {
|
|
28838
|
-
const resp = await
|
|
28976
|
+
const resp = await this.fetchWithRetry(
|
|
28977
|
+
`${this.baseUrl}/sign/sessions/${code}/shares`
|
|
28978
|
+
);
|
|
28839
28979
|
if (!resp.ok) throw await this.toError(resp);
|
|
28840
28980
|
return await resp.json();
|
|
28841
28981
|
}
|
|
@@ -28846,12 +28986,32 @@ var FrostCoordinator = class {
|
|
|
28846
28986
|
if (result.complete) {
|
|
28847
28987
|
return result.packages.map((p) => deserializeFn(p));
|
|
28848
28988
|
}
|
|
28849
|
-
await sleep(this.pollIntervalMs);
|
|
28989
|
+
await sleep(this.pollIntervalMs * (0.8 + Math.random() * 0.4));
|
|
28850
28990
|
}
|
|
28851
28991
|
throw new Error("Coordinator polling timeout");
|
|
28852
28992
|
}
|
|
28993
|
+
async fetchWithRetry(url, init4) {
|
|
28994
|
+
let lastError;
|
|
28995
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
28996
|
+
if (attempt > 0) {
|
|
28997
|
+
await sleep(this.retryDelayMs * 2 ** (attempt - 1));
|
|
28998
|
+
}
|
|
28999
|
+
const resp = await fetch(url, init4);
|
|
29000
|
+
if (resp.ok || !isTransientError(resp.status)) {
|
|
29001
|
+
return resp;
|
|
29002
|
+
}
|
|
29003
|
+
lastError = await this.toError(resp);
|
|
29004
|
+
}
|
|
29005
|
+
throw lastError;
|
|
29006
|
+
}
|
|
28853
29007
|
async toError(resp) {
|
|
28854
29008
|
const body = await resp.text();
|
|
29009
|
+
const isHtml = body.trimStart().startsWith("<") || resp.headers.get("content-type")?.includes("text/html");
|
|
29010
|
+
if (isHtml) {
|
|
29011
|
+
return new Error(
|
|
29012
|
+
`Coordinator unavailable (HTTP ${resp.status}). The service may be temporarily overloaded \u2014 try again shortly.`
|
|
29013
|
+
);
|
|
29014
|
+
}
|
|
28855
29015
|
return new Error(`Coordinator error ${resp.status}: ${body}`);
|
|
28856
29016
|
}
|
|
28857
29017
|
};
|
|
@@ -28861,16 +29021,20 @@ function deserializeSessionInfo(raw) {
|
|
|
28861
29021
|
message: deserializeBigint(raw.message),
|
|
28862
29022
|
participants: raw.participants,
|
|
28863
29023
|
status: raw.status,
|
|
28864
|
-
groupId: raw.group_id ?? void 0
|
|
29024
|
+
groupId: raw.group_id ?? void 0,
|
|
29025
|
+
metadata: raw.metadata
|
|
28865
29026
|
};
|
|
28866
29027
|
}
|
|
29028
|
+
function isTransientError(status) {
|
|
29029
|
+
return status === 502 || status === 503 || status === 504;
|
|
29030
|
+
}
|
|
28867
29031
|
function sleep(ms) {
|
|
28868
29032
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
28869
29033
|
}
|
|
28870
29034
|
|
|
28871
29035
|
// src/frost/account.ts
|
|
28872
|
-
function
|
|
28873
|
-
return `${gatewayUrl.replace(/\/$/, "")}/frost`;
|
|
29036
|
+
function resolveFrostUrl(gatewayUrl, explicitFrostUrl) {
|
|
29037
|
+
return explicitFrostUrl ?? `${gatewayUrl.replace(/\/$/, "")}/frost`;
|
|
28874
29038
|
}
|
|
28875
29039
|
function deriveVerificationShare(participantIndex, coefficientCommitments) {
|
|
28876
29040
|
const idx = BigInt(participantIndex);
|
|
@@ -28884,7 +29048,7 @@ function deriveVerificationShare(participantIndex, coefficientCommitments) {
|
|
|
28884
29048
|
}
|
|
28885
29049
|
return result;
|
|
28886
29050
|
}
|
|
28887
|
-
function buildMultisigAccount(result, viewingKeyPair, groupId, config3, participantIndex, gatewayUrl) {
|
|
29051
|
+
function buildMultisigAccount(result, viewingKeyPair, groupId, config3, participantIndex, gatewayUrl, frostUrl) {
|
|
28888
29052
|
const nullifyingKey = computeNullifyingKey(viewingKeyPair.privateKey);
|
|
28889
29053
|
const masterPublicKey = computeMasterPublicKey(
|
|
28890
29054
|
result.groupPublicKey,
|
|
@@ -28905,6 +29069,7 @@ function buildMultisigAccount(result, viewingKeyPair, groupId, config3, particip
|
|
|
28905
29069
|
nullifyingKey,
|
|
28906
29070
|
masterPublicKey,
|
|
28907
29071
|
gatewayUrl,
|
|
29072
|
+
...frostUrl !== void 0 ? { frostUrl } : {},
|
|
28908
29073
|
address
|
|
28909
29074
|
};
|
|
28910
29075
|
}
|
|
@@ -28925,7 +29090,7 @@ async function createMultisig(params) {
|
|
|
28925
29090
|
totalShares: params.totalShares
|
|
28926
29091
|
};
|
|
28927
29092
|
const coordinator = new FrostCoordinator({
|
|
28928
|
-
baseUrl:
|
|
29093
|
+
baseUrl: resolveFrostUrl(params.gatewayUrl, params.frostUrl)
|
|
28929
29094
|
});
|
|
28930
29095
|
const { code } = await coordinator.createDkgSession(
|
|
28931
29096
|
config3.threshold,
|
|
@@ -28959,14 +29124,15 @@ async function createMultisig(params) {
|
|
|
28959
29124
|
code,
|
|
28960
29125
|
config3,
|
|
28961
29126
|
1,
|
|
28962
|
-
params.gatewayUrl
|
|
29127
|
+
params.gatewayUrl,
|
|
29128
|
+
params.frostUrl
|
|
28963
29129
|
);
|
|
28964
29130
|
}
|
|
28965
29131
|
};
|
|
28966
29132
|
}
|
|
28967
29133
|
async function joinMultisig(params) {
|
|
28968
29134
|
const coordinator = new FrostCoordinator({
|
|
28969
|
-
baseUrl:
|
|
29135
|
+
baseUrl: resolveFrostUrl(params.gatewayUrl, params.frostUrl)
|
|
28970
29136
|
});
|
|
28971
29137
|
const { participantIndex, threshold, totalParticipants } = await coordinator.joinDkgSession(params.code);
|
|
28972
29138
|
const config3 = { threshold, totalShares: totalParticipants };
|
|
@@ -28995,12 +29161,16 @@ async function joinMultisig(params) {
|
|
|
28995
29161
|
params.code,
|
|
28996
29162
|
config3,
|
|
28997
29163
|
participantIndex,
|
|
28998
|
-
params.gatewayUrl
|
|
29164
|
+
params.gatewayUrl,
|
|
29165
|
+
params.frostUrl
|
|
28999
29166
|
);
|
|
29000
29167
|
}
|
|
29001
29168
|
async function signMultisig(params) {
|
|
29002
29169
|
const coordinator = new FrostCoordinator({
|
|
29003
|
-
baseUrl:
|
|
29170
|
+
baseUrl: resolveFrostUrl(
|
|
29171
|
+
params.account.gatewayUrl,
|
|
29172
|
+
params.account.frostUrl
|
|
29173
|
+
)
|
|
29004
29174
|
});
|
|
29005
29175
|
const { nonces, commitment } = generateCommitment(
|
|
29006
29176
|
params.account.participantIndex
|
|
@@ -29038,13 +29208,18 @@ function createFrostSigner(params) {
|
|
|
29038
29208
|
publicKey: params.account.groupPublicKey,
|
|
29039
29209
|
sign: async (message) => {
|
|
29040
29210
|
const coordinator = new FrostCoordinator({
|
|
29041
|
-
baseUrl:
|
|
29211
|
+
baseUrl: resolveFrostUrl(
|
|
29212
|
+
params.account.gatewayUrl,
|
|
29213
|
+
params.account.frostUrl
|
|
29214
|
+
)
|
|
29042
29215
|
});
|
|
29043
29216
|
const { code } = await coordinator.createSigningSession(
|
|
29044
29217
|
params.participants,
|
|
29045
29218
|
message,
|
|
29046
|
-
params.account.groupId
|
|
29219
|
+
params.account.groupId,
|
|
29220
|
+
params.metadata
|
|
29047
29221
|
);
|
|
29222
|
+
params.onSessionCreated?.(code);
|
|
29048
29223
|
return signMultisig({
|
|
29049
29224
|
account: params.account,
|
|
29050
29225
|
message,
|
|
@@ -29056,10 +29231,10 @@ function createFrostSigner(params) {
|
|
|
29056
29231
|
|
|
29057
29232
|
// src/frost/listener.ts
|
|
29058
29233
|
async function runSigningListener(params) {
|
|
29059
|
-
const { account, signal, onSession, onError } = params;
|
|
29234
|
+
const { account, signal, onSession, approve, onError } = params;
|
|
29060
29235
|
const pollIntervalMs = params.pollIntervalMs ?? 1e3;
|
|
29061
29236
|
const coordinator = new FrostCoordinator({
|
|
29062
|
-
baseUrl: `${account.gatewayUrl.replace(/\/$/, "")}/frost`,
|
|
29237
|
+
baseUrl: account.frostUrl ?? `${account.gatewayUrl.replace(/\/$/, "")}/frost`,
|
|
29063
29238
|
pollIntervalMs
|
|
29064
29239
|
});
|
|
29065
29240
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -29074,9 +29249,21 @@ async function runSigningListener(params) {
|
|
|
29074
29249
|
seen.add(session.code);
|
|
29075
29250
|
continue;
|
|
29076
29251
|
}
|
|
29252
|
+
const info = {
|
|
29253
|
+
code: session.code,
|
|
29254
|
+
message: session.message,
|
|
29255
|
+
metadata: session.metadata
|
|
29256
|
+
};
|
|
29257
|
+
try {
|
|
29258
|
+
onSession?.(info);
|
|
29259
|
+
} catch (err) {
|
|
29260
|
+
seen.add(session.code);
|
|
29261
|
+
const shouldContinue = onError?.(err, info) ?? true;
|
|
29262
|
+
if (!shouldContinue) return;
|
|
29263
|
+
continue;
|
|
29264
|
+
}
|
|
29265
|
+
if (approve && !await approve(info)) continue;
|
|
29077
29266
|
seen.add(session.code);
|
|
29078
|
-
const info = { code: session.code, message: session.message };
|
|
29079
|
-
onSession?.(info);
|
|
29080
29267
|
try {
|
|
29081
29268
|
await signMultisig({
|
|
29082
29269
|
account,
|
|
@@ -29098,13 +29285,14 @@ async function runSigningListener(params) {
|
|
|
29098
29285
|
|
|
29099
29286
|
// src/wallet/wallet.ts
|
|
29100
29287
|
function createMultisigWallet(config3) {
|
|
29101
|
-
const { gatewayUrl } = config3;
|
|
29288
|
+
const { gatewayUrl, frostUrl } = config3;
|
|
29102
29289
|
return {
|
|
29103
29290
|
create(params) {
|
|
29104
29291
|
return createMultisig({
|
|
29105
29292
|
threshold: params.threshold,
|
|
29106
29293
|
totalShares: params.totalShares,
|
|
29107
29294
|
gatewayUrl,
|
|
29295
|
+
frostUrl,
|
|
29108
29296
|
viewingKeyPair: params.viewingKeyPair
|
|
29109
29297
|
});
|
|
29110
29298
|
},
|
|
@@ -29112,6 +29300,7 @@ function createMultisigWallet(config3) {
|
|
|
29112
29300
|
return joinMultisig({
|
|
29113
29301
|
code: params.code,
|
|
29114
29302
|
gatewayUrl,
|
|
29303
|
+
frostUrl,
|
|
29115
29304
|
viewingKeyPair: params.viewingKeyPair
|
|
29116
29305
|
});
|
|
29117
29306
|
},
|
|
@@ -29126,17 +29315,20 @@ function createMultisigWallet(config3) {
|
|
|
29126
29315
|
createSigner(params) {
|
|
29127
29316
|
return createFrostSigner({
|
|
29128
29317
|
account: params.account,
|
|
29129
|
-
participants: params.participants
|
|
29318
|
+
participants: params.participants,
|
|
29319
|
+
metadata: params.metadata,
|
|
29320
|
+
onSessionCreated: params.onSessionCreated
|
|
29130
29321
|
});
|
|
29131
29322
|
},
|
|
29132
29323
|
async createSigningSession(params) {
|
|
29133
29324
|
const coordinator = new FrostCoordinator({
|
|
29134
|
-
baseUrl: `${gatewayUrl.replace(/\/$/, "")}/frost`
|
|
29325
|
+
baseUrl: frostUrl ?? `${gatewayUrl.replace(/\/$/, "")}/frost`
|
|
29135
29326
|
});
|
|
29136
29327
|
return coordinator.createSigningSession(
|
|
29137
29328
|
params.participants,
|
|
29138
29329
|
params.message,
|
|
29139
|
-
params.groupId
|
|
29330
|
+
params.groupId,
|
|
29331
|
+
params.metadata
|
|
29140
29332
|
);
|
|
29141
29333
|
}
|
|
29142
29334
|
};
|