@dorafactory/maci-sdk 0.1.3-pre.46.beta.10 → 0.1.3-pre.46.beta.11

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/index.js CHANGED
@@ -6712,6 +6712,28 @@ var MaciApiClient = class {
6712
6712
  { method: "GET" }
6713
6713
  );
6714
6714
  }
6715
+ // ==================== Claim Key APIs ====================
6716
+ /**
6717
+ * Claim MACI Key
6718
+ * Assign the next available pre-generated MACI key pair for an AMACI round (first-come-first-served).
6719
+ * Returns pubkey, secretKey, and the full deactivate Merkle proof.
6720
+ * WARNING: secretKey is returned only once and cannot be retrieved again.
6721
+ */
6722
+ async claimMaciKey(params) {
6723
+ return this.fetch(`/v1/rounds/${params.contractAddress}/claim-key`, {
6724
+ method: "POST"
6725
+ });
6726
+ }
6727
+ /**
6728
+ * Get Claim Statistics
6729
+ * Returns total key slots (scale), claimed count, and available count for the round.
6730
+ * Public endpoint — no authentication required.
6731
+ */
6732
+ async getClaimStats(params) {
6733
+ return this.fetch(`/v1/rounds/${params.contractAddress}/claim-key-stats`, {
6734
+ method: "GET"
6735
+ });
6736
+ }
6715
6737
  };
6716
6738
 
6717
6739
  // src/maci.ts
@@ -7290,6 +7312,19 @@ var MaciClient = class {
7290
7312
  }
7291
7313
  return await this.saasApiClient.setVoteOptions(params);
7292
7314
  }
7315
+ /**
7316
+ * Claim the next available pre-generated MACI key pair for an AMACI round via SaaS API.
7317
+ * The key is assigned on a first-come-first-served basis.
7318
+ * WARNING: secretKey is returned only once — save it immediately, it cannot be retrieved again.
7319
+ * @param contractAddress - Round contract address
7320
+ * @returns Claimed key pair with full deactivate Merkle proof
7321
+ */
7322
+ async saasClaimKey(contractAddress) {
7323
+ if (!this.saasApiClient) {
7324
+ throw new Error("SaaS API client not initialized");
7325
+ }
7326
+ return await this.saasApiClient.claimMaciKey({ contractAddress });
7327
+ }
7293
7328
  };
7294
7329
 
7295
7330
  // src/voter.ts
@@ -8071,6 +8106,7 @@ var VoterClient = class _VoterClient {
8071
8106
  contractAddress,
8072
8107
  deactivateIdx,
8073
8108
  voterScale,
8109
+ preComputedProof,
8074
8110
  newPubkey,
8075
8111
  pollId,
8076
8112
  wasmFile,
@@ -8114,6 +8150,18 @@ var VoterClient = class _VoterClient {
8114
8150
  let preComputedLeaf;
8115
8151
  if (deactivates && deactivates.length > 0) {
8116
8152
  resolvedDeactivates = deactivates.map((d) => d.map(BigInt));
8153
+ } else if (preComputedProof) {
8154
+ if (deactivateIdx === void 0) {
8155
+ throw new Error(
8156
+ "buildPreAddNewKeyPayload: `deactivateIdx` is required when `preComputedProof` is provided"
8157
+ );
8158
+ }
8159
+ preComputedLeaf = preComputedProof.deactivateLeaf.map(BigInt);
8160
+ preComputedTreeProof = {
8161
+ root: preComputedProof.root,
8162
+ pathElements: preComputedProof.pathElements
8163
+ };
8164
+ resolvedDeactivates = [];
8117
8165
  } else {
8118
8166
  if (!contractAddress) {
8119
8167
  throw new Error(
@@ -8127,7 +8175,7 @@ var VoterClient = class _VoterClient {
8127
8175
  }
8128
8176
  if (voterScale === void 0) {
8129
8177
  throw new Error(
8130
- "buildPreAddNewKeyPayload: `voterScale` is required when `deactivates` is not provided"
8178
+ "buildPreAddNewKeyPayload: `voterScale` is required for the K-anonymous API path"
8131
8179
  );
8132
8180
  }
8133
8181
  const indicesParam = buildKAnonymousIndices(deactivateIdx, voterScale);
@@ -8678,6 +8726,7 @@ var VoterClient = class _VoterClient {
8678
8726
  deactivates,
8679
8727
  deactivateIdx,
8680
8728
  voterScale,
8729
+ preComputedProof,
8681
8730
  pollId,
8682
8731
  wasmFile,
8683
8732
  zkeyFile,
@@ -8699,6 +8748,7 @@ var VoterClient = class _VoterClient {
8699
8748
  contractAddress,
8700
8749
  deactivateIdx,
8701
8750
  voterScale,
8751
+ preComputedProof,
8702
8752
  newPubkey,
8703
8753
  pollId: pollId !== void 0 ? BigInt(pollId) : void 0,
8704
8754
  wasmFile,