@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/browser.d.mts +4 -0
- package/dist/browser.d.ts +4 -0
- package/dist/browser.js +35 -2
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +35 -2
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/libs/maci/maci.ts +47 -2
package/dist/browser.d.mts
CHANGED
|
@@ -1656,6 +1656,10 @@ declare class MACI {
|
|
|
1656
1656
|
queryRoundGasStation({ contractAddress }: {
|
|
1657
1657
|
contractAddress: string;
|
|
1658
1658
|
}): Promise<boolean>;
|
|
1659
|
+
parseRoundStatus(votingStart: number, votingEnd: number, status: string, currentTime: Date): string;
|
|
1660
|
+
queryRoundBalance({ contractAddress }: {
|
|
1661
|
+
contractAddress: string;
|
|
1662
|
+
}): Promise<string>;
|
|
1659
1663
|
requestOracleCertificate({ signer, ecosystem, address, contractAddress, }: {
|
|
1660
1664
|
signer: OfflineSigner;
|
|
1661
1665
|
ecosystem: CertificateEcosystem;
|
package/dist/browser.d.ts
CHANGED
|
@@ -1656,6 +1656,10 @@ declare class MACI {
|
|
|
1656
1656
|
queryRoundGasStation({ contractAddress }: {
|
|
1657
1657
|
contractAddress: string;
|
|
1658
1658
|
}): Promise<boolean>;
|
|
1659
|
+
parseRoundStatus(votingStart: number, votingEnd: number, status: string, currentTime: Date): string;
|
|
1660
|
+
queryRoundBalance({ contractAddress }: {
|
|
1661
|
+
contractAddress: string;
|
|
1662
|
+
}): Promise<string>;
|
|
1659
1663
|
requestOracleCertificate({ signer, ecosystem, address, contractAddress, }: {
|
|
1660
1664
|
signer: OfflineSigner;
|
|
1661
1665
|
ecosystem: CertificateEcosystem;
|
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(
|
|
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
|
}
|
|
@@ -30325,6 +30327,37 @@ var MACI = class {
|
|
|
30325
30327
|
const roundInfo = await this.getRoundInfo({ contractAddress });
|
|
30326
30328
|
return roundInfo.gasStationEnable;
|
|
30327
30329
|
}
|
|
30330
|
+
parseRoundStatus(votingStart, votingEnd, status, currentTime) {
|
|
30331
|
+
const startTime = new Date(votingStart / 10 ** 6);
|
|
30332
|
+
const endTime = new Date(votingEnd / 10 ** 6);
|
|
30333
|
+
if (Number(votingStart) === 0) {
|
|
30334
|
+
return "Created";
|
|
30335
|
+
}
|
|
30336
|
+
if (Number(votingEnd) === 0) {
|
|
30337
|
+
if (startTime < currentTime) {
|
|
30338
|
+
return "Ongoing";
|
|
30339
|
+
}
|
|
30340
|
+
} else {
|
|
30341
|
+
if (startTime < currentTime && currentTime < endTime) {
|
|
30342
|
+
return "Ongoing";
|
|
30343
|
+
}
|
|
30344
|
+
if (currentTime > endTime) {
|
|
30345
|
+
if (status !== "Closed") {
|
|
30346
|
+
return "Tallying";
|
|
30347
|
+
}
|
|
30348
|
+
}
|
|
30349
|
+
}
|
|
30350
|
+
return status;
|
|
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
|
+
}
|
|
30328
30361
|
async requestOracleCertificate({
|
|
30329
30362
|
signer,
|
|
30330
30363
|
ecosystem,
|