@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/index.mjs
CHANGED
|
@@ -4420,7 +4420,7 @@ var MACI = class {
|
|
|
4420
4420
|
return round.data.round.voiceCreditAmount;
|
|
4421
4421
|
} else {
|
|
4422
4422
|
throw new Error(
|
|
4423
|
-
`Failed to query amaci voice credit: ${round.error.type}`
|
|
4423
|
+
`Failed to query amaci voice credit: ${round.error.type} ${round.error.message}`
|
|
4424
4424
|
);
|
|
4425
4425
|
}
|
|
4426
4426
|
} else {
|
|
@@ -4477,7 +4477,9 @@ var MACI = class {
|
|
|
4477
4477
|
async getRoundInfo({ contractAddress }) {
|
|
4478
4478
|
const roundInfo = await this.indexer.getRoundById(contractAddress);
|
|
4479
4479
|
if (isErrorResponse(roundInfo)) {
|
|
4480
|
-
throw new Error(
|
|
4480
|
+
throw new Error(
|
|
4481
|
+
`Failed to get round info: ${roundInfo.error.type} ${roundInfo.error.message}`
|
|
4482
|
+
);
|
|
4481
4483
|
}
|
|
4482
4484
|
return roundInfo.data.round;
|
|
4483
4485
|
}
|
|
@@ -4493,6 +4495,37 @@ var MACI = class {
|
|
|
4493
4495
|
const roundInfo = await this.getRoundInfo({ contractAddress });
|
|
4494
4496
|
return roundInfo.gasStationEnable;
|
|
4495
4497
|
}
|
|
4498
|
+
parseRoundStatus(votingStart, votingEnd, status, currentTime) {
|
|
4499
|
+
const startTime = new Date(votingStart / 10 ** 6);
|
|
4500
|
+
const endTime = new Date(votingEnd / 10 ** 6);
|
|
4501
|
+
if (Number(votingStart) === 0) {
|
|
4502
|
+
return "Created";
|
|
4503
|
+
}
|
|
4504
|
+
if (Number(votingEnd) === 0) {
|
|
4505
|
+
if (startTime < currentTime) {
|
|
4506
|
+
return "Ongoing";
|
|
4507
|
+
}
|
|
4508
|
+
} else {
|
|
4509
|
+
if (startTime < currentTime && currentTime < endTime) {
|
|
4510
|
+
return "Ongoing";
|
|
4511
|
+
}
|
|
4512
|
+
if (currentTime > endTime) {
|
|
4513
|
+
if (status !== "Closed") {
|
|
4514
|
+
return "Tallying";
|
|
4515
|
+
}
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
return status;
|
|
4519
|
+
}
|
|
4520
|
+
async queryRoundBalance({ contractAddress }) {
|
|
4521
|
+
const roundBalance = await this.indexer.balanceOf(contractAddress);
|
|
4522
|
+
if (isErrorResponse(roundBalance)) {
|
|
4523
|
+
throw new Error(
|
|
4524
|
+
`Failed to query round balance: ${roundBalance.error.type} ${roundBalance.error.message}`
|
|
4525
|
+
);
|
|
4526
|
+
}
|
|
4527
|
+
return roundBalance.data.balance;
|
|
4528
|
+
}
|
|
4496
4529
|
async requestOracleCertificate({
|
|
4497
4530
|
signer,
|
|
4498
4531
|
ecosystem,
|