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

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,30 @@ 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
+ const { contractAddress, ...body } = params;
6724
+ return this.fetch(`/v1/rounds/${contractAddress}/claim-key`, {
6725
+ method: "POST",
6726
+ body: JSON.stringify(body)
6727
+ });
6728
+ }
6729
+ /**
6730
+ * Get Claim Statistics
6731
+ * Returns total key slots (scale), claimed count, and available count for the round.
6732
+ * Public endpoint — no authentication required.
6733
+ */
6734
+ async getClaimStats(params) {
6735
+ return this.fetch(`/v1/rounds/${params.contractAddress}/claim-key-stats`, {
6736
+ method: "GET"
6737
+ });
6738
+ }
6715
6739
  };
6716
6740
 
6717
6741
  // src/maci.ts
@@ -8071,6 +8095,7 @@ var VoterClient = class _VoterClient {
8071
8095
  contractAddress,
8072
8096
  deactivateIdx,
8073
8097
  voterScale,
8098
+ preComputedProof,
8074
8099
  newPubkey,
8075
8100
  pollId,
8076
8101
  wasmFile,
@@ -8114,6 +8139,18 @@ var VoterClient = class _VoterClient {
8114
8139
  let preComputedLeaf;
8115
8140
  if (deactivates && deactivates.length > 0) {
8116
8141
  resolvedDeactivates = deactivates.map((d) => d.map(BigInt));
8142
+ } else if (preComputedProof) {
8143
+ if (deactivateIdx === void 0) {
8144
+ throw new Error(
8145
+ "buildPreAddNewKeyPayload: `deactivateIdx` is required when `preComputedProof` is provided"
8146
+ );
8147
+ }
8148
+ preComputedLeaf = preComputedProof.deactivateLeaf.map(BigInt);
8149
+ preComputedTreeProof = {
8150
+ root: preComputedProof.root,
8151
+ pathElements: preComputedProof.pathElements
8152
+ };
8153
+ resolvedDeactivates = [];
8117
8154
  } else {
8118
8155
  if (!contractAddress) {
8119
8156
  throw new Error(
@@ -8127,7 +8164,7 @@ var VoterClient = class _VoterClient {
8127
8164
  }
8128
8165
  if (voterScale === void 0) {
8129
8166
  throw new Error(
8130
- "buildPreAddNewKeyPayload: `voterScale` is required when `deactivates` is not provided"
8167
+ "buildPreAddNewKeyPayload: `voterScale` is required for the K-anonymous API path"
8131
8168
  );
8132
8169
  }
8133
8170
  const indicesParam = buildKAnonymousIndices(deactivateIdx, voterScale);
@@ -8678,6 +8715,7 @@ var VoterClient = class _VoterClient {
8678
8715
  deactivates,
8679
8716
  deactivateIdx,
8680
8717
  voterScale,
8718
+ preComputedProof,
8681
8719
  pollId,
8682
8720
  wasmFile,
8683
8721
  zkeyFile,
@@ -8699,6 +8737,7 @@ var VoterClient = class _VoterClient {
8699
8737
  contractAddress,
8700
8738
  deactivateIdx,
8701
8739
  voterScale,
8740
+ preComputedProof,
8702
8741
  newPubkey,
8703
8742
  pollId: pollId !== void 0 ? BigInt(pollId) : void 0,
8704
8743
  wasmFile,
@@ -8718,6 +8757,19 @@ var VoterClient = class _VoterClient {
8718
8757
  account: newVoterClient
8719
8758
  };
8720
8759
  }
8760
+ /**
8761
+ * Claim the next available pre-generated MACI key pair for an AMACI round via SaaS API.
8762
+ * The key is assigned on a first-come-first-served basis.
8763
+ * WARNING: secretKey is returned only once — save it immediately, it cannot be retrieved again.
8764
+ * @param params - Parameters including contractAddress and ticket
8765
+ * @returns Claimed key pair with full deactivate Merkle proof
8766
+ */
8767
+ async saasClaimKey(params) {
8768
+ if (!this.saasApiClient) {
8769
+ throw new Error("SaaS API client not initialized");
8770
+ }
8771
+ return await this.saasApiClient.claimMaciKey(params);
8772
+ }
8721
8773
  /**
8722
8774
  * Vote via SaaS API with automatic payload building
8723
8775
  * @param params - Parameters including contract address, operator pubkey, vote options, and ticket