@dorafactory/maci-sdk 0.1.3-pre.29 → 0.1.3-pre.31

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
@@ -9136,6 +9136,9 @@ var MaciClient2 = class {
9136
9136
  return packPubKey(pubkey || this.maciKeypair.pubKey);
9137
9137
  }
9138
9138
  unpackMaciPubkey(pubkey) {
9139
+ if (Array.isArray(pubkey) && pubkey.length === 2) {
9140
+ return pubkey;
9141
+ }
9139
9142
  return unpackPubKey(BigInt(pubkey));
9140
9143
  }
9141
9144
  async getAddress(signer) {
@@ -10203,6 +10206,9 @@ var VoterClient = class _VoterClient {
10203
10206
  return packPubKey(pubkey || this.accountManager.currentPubkey.toPoints());
10204
10207
  }
10205
10208
  unpackMaciPubkey(pubkey) {
10209
+ if (Array.isArray(pubkey) && pubkey.length === 2) {
10210
+ return pubkey;
10211
+ }
10206
10212
  return unpackPubKey(BigInt(pubkey));
10207
10213
  }
10208
10214
  getPubkey(derivePathParams) {
@@ -10261,11 +10267,12 @@ var VoterClient = class _VoterClient {
10261
10267
  return message;
10262
10268
  };
10263
10269
  }
10264
- async getStateIdxByPubKey({
10270
+ async getStateIdx({
10265
10271
  contractAddress,
10266
- pubKey
10272
+ pubkey
10267
10273
  }) {
10268
- const response = await this.indexer.getSignUpEventByPubKey(contractAddress, pubKey);
10274
+ pubkey = this.unpackMaciPubkey(pubkey || this.accountManager.currentPubkey.toPoints());
10275
+ const response = await this.indexer.getSignUpEventByPubKey(contractAddress, pubkey);
10269
10276
  if (isErrorResponse(response)) {
10270
10277
  return -1;
10271
10278
  }
@@ -10515,14 +10522,12 @@ var VoterClient = class _VoterClient {
10515
10522
  }
10516
10523
  async saasVote({
10517
10524
  contractAddress,
10518
- // stateIdx,
10519
10525
  operatorPubkey,
10520
10526
  selectedOptions,
10521
10527
  derivePathParams
10522
10528
  }) {
10523
- const stateIdx = await this.getStateIdxByPubKey({
10524
- contractAddress,
10525
- pubKey: this.getPubkey(derivePathParams).toPoints()
10529
+ const stateIdx = await this.getStateIdx({
10530
+ contractAddress
10526
10531
  });
10527
10532
  if (stateIdx === -1) {
10528
10533
  throw new Error("State index is not set, Please signup or addNewKey first");