@unlink-xyz/multisig 0.1.4 → 0.1.5

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.
@@ -28728,7 +28728,7 @@ var FrostCoordinator = class {
28728
28728
  );
28729
28729
  }
28730
28730
  // === Signing ===
28731
- async createSigningSession(participants, message, groupId) {
28731
+ async createSigningSession(participants, message, groupId, metadata) {
28732
28732
  const body = {
28733
28733
  participants,
28734
28734
  message: serializeBigint(message)
@@ -28736,6 +28736,9 @@ var FrostCoordinator = class {
28736
28736
  if (groupId !== void 0) {
28737
28737
  body.group_id = groupId;
28738
28738
  }
28739
+ if (metadata !== void 0) {
28740
+ body.metadata = metadata;
28741
+ }
28739
28742
  const resp = await fetch(`${this.baseUrl}/sign/sessions`, {
28740
28743
  method: "POST",
28741
28744
  headers: { "Content-Type": "application/json" },
@@ -28861,7 +28864,8 @@ function deserializeSessionInfo(raw) {
28861
28864
  message: deserializeBigint(raw.message),
28862
28865
  participants: raw.participants,
28863
28866
  status: raw.status,
28864
- groupId: raw.group_id ?? void 0
28867
+ groupId: raw.group_id ?? void 0,
28868
+ metadata: raw.metadata
28865
28869
  };
28866
28870
  }
28867
28871
  function sleep(ms) {
@@ -29043,8 +29047,10 @@ function createFrostSigner(params) {
29043
29047
  const { code } = await coordinator.createSigningSession(
29044
29048
  params.participants,
29045
29049
  message,
29046
- params.account.groupId
29050
+ params.account.groupId,
29051
+ params.metadata
29047
29052
  );
29053
+ params.onSessionCreated?.(code);
29048
29054
  return signMultisig({
29049
29055
  account: params.account,
29050
29056
  message,
@@ -29056,7 +29062,7 @@ function createFrostSigner(params) {
29056
29062
 
29057
29063
  // src/frost/listener.ts
29058
29064
  async function runSigningListener(params) {
29059
- const { account, signal, onSession, onError } = params;
29065
+ const { account, signal, onSession, approve, onError } = params;
29060
29066
  const pollIntervalMs = params.pollIntervalMs ?? 1e3;
29061
29067
  const coordinator = new FrostCoordinator({
29062
29068
  baseUrl: `${account.gatewayUrl.replace(/\/$/, "")}/frost`,
@@ -29074,9 +29080,21 @@ async function runSigningListener(params) {
29074
29080
  seen.add(session.code);
29075
29081
  continue;
29076
29082
  }
29083
+ const info = {
29084
+ code: session.code,
29085
+ message: session.message,
29086
+ metadata: session.metadata
29087
+ };
29088
+ try {
29089
+ onSession?.(info);
29090
+ } catch (err) {
29091
+ seen.add(session.code);
29092
+ const shouldContinue = onError?.(err, info) ?? true;
29093
+ if (!shouldContinue) return;
29094
+ continue;
29095
+ }
29096
+ if (approve && !await approve(info)) continue;
29077
29097
  seen.add(session.code);
29078
- const info = { code: session.code, message: session.message };
29079
- onSession?.(info);
29080
29098
  try {
29081
29099
  await signMultisig({
29082
29100
  account,
@@ -29126,7 +29144,9 @@ function createMultisigWallet(config3) {
29126
29144
  createSigner(params) {
29127
29145
  return createFrostSigner({
29128
29146
  account: params.account,
29129
- participants: params.participants
29147
+ participants: params.participants,
29148
+ metadata: params.metadata,
29149
+ onSessionCreated: params.onSessionCreated
29130
29150
  });
29131
29151
  },
29132
29152
  async createSigningSession(params) {
@@ -29136,7 +29156,8 @@ function createMultisigWallet(config3) {
29136
29156
  return coordinator.createSigningSession(
29137
29157
  params.participants,
29138
29158
  params.message,
29139
- params.groupId
29159
+ params.groupId,
29160
+ params.metadata
29140
29161
  );
29141
29162
  }
29142
29163
  };