@dorafactory/maci-sdk 0.0.14 → 0.0.16

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.d.mts CHANGED
@@ -1657,6 +1657,10 @@ declare class MACI {
1657
1657
  queryRoundGasStation({ contractAddress }: {
1658
1658
  contractAddress: string;
1659
1659
  }): Promise<boolean>;
1660
+ parseRoundStatus(votingStart: number, votingEnd: number, status: string, currentTime: Date): string;
1661
+ queryRoundBalance({ contractAddress }: {
1662
+ contractAddress: string;
1663
+ }): Promise<string>;
1660
1664
  requestOracleCertificate({ signer, ecosystem, address, contractAddress, }: {
1661
1665
  signer: OfflineSigner;
1662
1666
  ecosystem: CertificateEcosystem;
package/dist/index.d.ts CHANGED
@@ -1657,6 +1657,10 @@ declare class MACI {
1657
1657
  queryRoundGasStation({ contractAddress }: {
1658
1658
  contractAddress: string;
1659
1659
  }): Promise<boolean>;
1660
+ parseRoundStatus(votingStart: number, votingEnd: number, status: string, currentTime: Date): string;
1661
+ queryRoundBalance({ contractAddress }: {
1662
+ contractAddress: string;
1663
+ }): Promise<string>;
1660
1664
  requestOracleCertificate({ signer, ecosystem, address, contractAddress, }: {
1661
1665
  signer: OfflineSigner;
1662
1666
  ecosystem: CertificateEcosystem;
package/dist/index.js CHANGED
@@ -4476,7 +4476,7 @@ var MACI = class {
4476
4476
  return round.data.round.voiceCreditAmount;
4477
4477
  } else {
4478
4478
  throw new Error(
4479
- `Failed to query amaci voice credit: ${round.error.type}`
4479
+ `Failed to query amaci voice credit: ${round.error.type} ${round.error.message}`
4480
4480
  );
4481
4481
  }
4482
4482
  } else {
@@ -4533,7 +4533,9 @@ var MACI = class {
4533
4533
  async getRoundInfo({ contractAddress }) {
4534
4534
  const roundInfo = await this.indexer.getRoundById(contractAddress);
4535
4535
  if (isErrorResponse(roundInfo)) {
4536
- throw new Error(`Failed to get round info: ${roundInfo.error.type}`);
4536
+ throw new Error(
4537
+ `Failed to get round info: ${roundInfo.error.type} ${roundInfo.error.message}`
4538
+ );
4537
4539
  }
4538
4540
  return roundInfo.data.round;
4539
4541
  }
@@ -4549,6 +4551,37 @@ var MACI = class {
4549
4551
  const roundInfo = await this.getRoundInfo({ contractAddress });
4550
4552
  return roundInfo.gasStationEnable;
4551
4553
  }
4554
+ parseRoundStatus(votingStart, votingEnd, status, currentTime) {
4555
+ const startTime = new Date(votingStart / 10 ** 6);
4556
+ const endTime = new Date(votingEnd / 10 ** 6);
4557
+ if (Number(votingStart) === 0) {
4558
+ return "Created";
4559
+ }
4560
+ if (Number(votingEnd) === 0) {
4561
+ if (startTime < currentTime) {
4562
+ return "Ongoing";
4563
+ }
4564
+ } else {
4565
+ if (startTime < currentTime && currentTime < endTime) {
4566
+ return "Ongoing";
4567
+ }
4568
+ if (currentTime > endTime) {
4569
+ if (status !== "Closed") {
4570
+ return "Tallying";
4571
+ }
4572
+ }
4573
+ }
4574
+ return status;
4575
+ }
4576
+ async queryRoundBalance({ contractAddress }) {
4577
+ const roundBalance = await this.indexer.balanceOf(contractAddress);
4578
+ if (isErrorResponse(roundBalance)) {
4579
+ throw new Error(
4580
+ `Failed to query round balance: ${roundBalance.error.type} ${roundBalance.error.message}`
4581
+ );
4582
+ }
4583
+ return roundBalance.data.balance;
4584
+ }
4552
4585
  async requestOracleCertificate({
4553
4586
  signer,
4554
4587
  ecosystem,