@dorafactory/maci-sdk 0.0.15 → 0.0.17

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/README.md CHANGED
@@ -178,6 +178,7 @@ const signupResponse = await client.maci.signup({
178
178
  signer: wallet,
179
179
  address,
180
180
  contractAddress: 'dora1...',
181
+ maciAccount,
181
182
  oracleCertificate: {
182
183
  amount: certificate.amount,
183
184
  signature: certificate.signature,
@@ -206,6 +207,7 @@ const voteResponse = await client.maci.vote({
206
207
  BigInt(roundInfo.coordinatorPubkeyX),
207
208
  BigInt(roundInfo.coordinatorPubkeyY),
208
209
  ],
210
+ maciAccount,
209
211
  gasStation: true,
210
212
  });
211
213
  ```
@@ -1657,16 +1657,20 @@ declare class MACI {
1657
1657
  contractAddress: string;
1658
1658
  }): Promise<boolean>;
1659
1659
  parseRoundStatus(votingStart: number, votingEnd: number, status: string, currentTime: Date): string;
1660
+ queryRoundBalance({ contractAddress }: {
1661
+ contractAddress: string;
1662
+ }): Promise<string>;
1660
1663
  requestOracleCertificate({ signer, ecosystem, address, contractAddress, }: {
1661
1664
  signer: OfflineSigner;
1662
1665
  ecosystem: CertificateEcosystem;
1663
1666
  address: string;
1664
1667
  contractAddress: string;
1665
1668
  }): Promise<SignatureResponse>;
1666
- signup({ signer, address, contractAddress, oracleCertificate, gasStation, }: {
1669
+ signup({ signer, address, contractAddress, maciAccount, oracleCertificate, gasStation, }: {
1667
1670
  signer: OfflineSigner;
1668
1671
  address: string;
1669
1672
  contractAddress: string;
1673
+ maciAccount?: Account;
1670
1674
  oracleCertificate?: {
1671
1675
  amount: string;
1672
1676
  signature: string;
@@ -1674,7 +1678,7 @@ declare class MACI {
1674
1678
  gasStation?: boolean;
1675
1679
  }): Promise<_cosmjs_cosmwasm_stargate.ExecuteResult>;
1676
1680
  private processVoteOptions;
1677
- vote({ signer, address, stateIdx, contractAddress, selectedOptions, operatorCoordPubKey, gasStation, }: {
1681
+ vote({ signer, address, stateIdx, contractAddress, selectedOptions, operatorCoordPubKey, maciAccount, gasStation, }: {
1678
1682
  signer: OfflineSigner;
1679
1683
  address: string;
1680
1684
  stateIdx: number;
@@ -1684,6 +1688,7 @@ declare class MACI {
1684
1688
  vc: number;
1685
1689
  }[];
1686
1690
  operatorCoordPubKey: PublicKey;
1691
+ maciAccount?: Account;
1687
1692
  gasStation?: boolean;
1688
1693
  }): Promise<_cosmjs_cosmwasm_stargate.DeliverTxResponse>;
1689
1694
  publishMessage({ client, address, payload, contractAddress, gasStation, }: {
package/dist/browser.d.ts CHANGED
@@ -1657,16 +1657,20 @@ declare class MACI {
1657
1657
  contractAddress: string;
1658
1658
  }): Promise<boolean>;
1659
1659
  parseRoundStatus(votingStart: number, votingEnd: number, status: string, currentTime: Date): string;
1660
+ queryRoundBalance({ contractAddress }: {
1661
+ contractAddress: string;
1662
+ }): Promise<string>;
1660
1663
  requestOracleCertificate({ signer, ecosystem, address, contractAddress, }: {
1661
1664
  signer: OfflineSigner;
1662
1665
  ecosystem: CertificateEcosystem;
1663
1666
  address: string;
1664
1667
  contractAddress: string;
1665
1668
  }): Promise<SignatureResponse>;
1666
- signup({ signer, address, contractAddress, oracleCertificate, gasStation, }: {
1669
+ signup({ signer, address, contractAddress, maciAccount, oracleCertificate, gasStation, }: {
1667
1670
  signer: OfflineSigner;
1668
1671
  address: string;
1669
1672
  contractAddress: string;
1673
+ maciAccount?: Account;
1670
1674
  oracleCertificate?: {
1671
1675
  amount: string;
1672
1676
  signature: string;
@@ -1674,7 +1678,7 @@ declare class MACI {
1674
1678
  gasStation?: boolean;
1675
1679
  }): Promise<_cosmjs_cosmwasm_stargate.ExecuteResult>;
1676
1680
  private processVoteOptions;
1677
- vote({ signer, address, stateIdx, contractAddress, selectedOptions, operatorCoordPubKey, gasStation, }: {
1681
+ vote({ signer, address, stateIdx, contractAddress, selectedOptions, operatorCoordPubKey, maciAccount, gasStation, }: {
1678
1682
  signer: OfflineSigner;
1679
1683
  address: string;
1680
1684
  stateIdx: number;
@@ -1684,6 +1688,7 @@ declare class MACI {
1684
1688
  vc: number;
1685
1689
  }[];
1686
1690
  operatorCoordPubKey: PublicKey;
1691
+ maciAccount?: Account;
1687
1692
  gasStation?: boolean;
1688
1693
  }): Promise<_cosmjs_cosmwasm_stargate.DeliverTxResponse>;
1689
1694
  publishMessage({ client, address, payload, contractAddress, gasStation, }: {
package/dist/browser.js CHANGED
@@ -30252,7 +30252,7 @@ var MACI = class {
30252
30252
  return round.data.round.voiceCreditAmount;
30253
30253
  } else {
30254
30254
  throw new Error(
30255
- `Failed to query amaci voice credit: ${round.error.type}`
30255
+ `Failed to query amaci voice credit: ${round.error.type} ${round.error.message}`
30256
30256
  );
30257
30257
  }
30258
30258
  } else {
@@ -30309,7 +30309,9 @@ var MACI = class {
30309
30309
  async getRoundInfo({ contractAddress }) {
30310
30310
  const roundInfo = await this.indexer.getRoundById(contractAddress);
30311
30311
  if (isErrorResponse(roundInfo)) {
30312
- throw new Error(`Failed to get round info: ${roundInfo.error.type}`);
30312
+ throw new Error(
30313
+ `Failed to get round info: ${roundInfo.error.type} ${roundInfo.error.message}`
30314
+ );
30313
30315
  }
30314
30316
  return roundInfo.data.round;
30315
30317
  }
@@ -30347,6 +30349,15 @@ var MACI = class {
30347
30349
  }
30348
30350
  return status;
30349
30351
  }
30352
+ async queryRoundBalance({ contractAddress }) {
30353
+ const roundBalance = await this.indexer.balanceOf(contractAddress);
30354
+ if (isErrorResponse(roundBalance)) {
30355
+ throw new Error(
30356
+ `Failed to query round balance: ${roundBalance.error.type} ${roundBalance.error.message}`
30357
+ );
30358
+ }
30359
+ return roundBalance.data.balance;
30360
+ }
30350
30361
  async requestOracleCertificate({
30351
30362
  signer,
30352
30363
  ecosystem,
@@ -30369,11 +30380,14 @@ var MACI = class {
30369
30380
  signer,
30370
30381
  address,
30371
30382
  contractAddress,
30383
+ maciAccount,
30372
30384
  oracleCertificate,
30373
30385
  gasStation = false
30374
30386
  }) {
30375
30387
  try {
30376
- const maciAccount = await this.circom.genKeypairFromSign(signer, address);
30388
+ if (maciAccount === void 0) {
30389
+ maciAccount = await this.circom.genKeypairFromSign(signer, address);
30390
+ }
30377
30391
  const client = await this.contract.contractClient({
30378
30392
  signer
30379
30393
  });
@@ -30428,6 +30442,7 @@ var MACI = class {
30428
30442
  contractAddress,
30429
30443
  selectedOptions,
30430
30444
  operatorCoordPubKey,
30445
+ maciAccount,
30431
30446
  gasStation = false
30432
30447
  }) {
30433
30448
  if (stateIdx === -1) {
@@ -30444,7 +30459,9 @@ var MACI = class {
30444
30459
  contractAddress,
30445
30460
  voiceCreditBalance
30446
30461
  });
30447
- const maciAccount = await this.circom.genKeypairFromSign(signer, address);
30462
+ if (maciAccount === void 0) {
30463
+ maciAccount = await this.circom.genKeypairFromSign(signer, address);
30464
+ }
30448
30465
  const plan = options.map((o) => {
30449
30466
  return [o.idx, o.vc];
30450
30467
  });