@dorafactory/maci-sdk 0.0.53 → 0.0.55
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 +1 -8
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -7
- package/dist/index.mjs.map +1 -1
- package/dist/libs/maci/maci.d.ts +1 -2
- package/dist/maci.d.ts +4 -4
- package/package.json +1 -1
- package/src/libs/maci/maci.ts +12 -7
- package/src/maci.ts +14 -4
package/README.md
CHANGED
|
@@ -188,17 +188,10 @@ const signupResponse = await client.maci.signup({
|
|
|
188
188
|
gasStation: true, // Whether to use gas station
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
-
// 5.
|
|
192
|
-
const stateIdx = await client.maci.getStateIdxByPubKey({
|
|
193
|
-
contractAddress: 'dora1...',
|
|
194
|
-
pubKey: maciAccount.pubKey,
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// 6. Cast vote
|
|
191
|
+
// 5. Cast vote
|
|
198
192
|
const voteResponse = await client.maci.vote({
|
|
199
193
|
signer: wallet,
|
|
200
194
|
address,
|
|
201
|
-
stateIdx,
|
|
202
195
|
contractAddress: 'dora1...',
|
|
203
196
|
selectedOptions: [
|
|
204
197
|
{ idx: 0, vc: 2 }, // Option index and voting weight
|
package/dist/index.js
CHANGED
|
@@ -5505,15 +5505,23 @@ var MACI = class {
|
|
|
5505
5505
|
async vote({
|
|
5506
5506
|
signer,
|
|
5507
5507
|
address,
|
|
5508
|
-
stateIdx,
|
|
5509
5508
|
contractAddress,
|
|
5510
5509
|
selectedOptions,
|
|
5511
5510
|
operatorCoordPubKey,
|
|
5512
5511
|
maciKeypair,
|
|
5513
5512
|
gasStation = false
|
|
5514
5513
|
}) {
|
|
5514
|
+
if (maciKeypair === void 0) {
|
|
5515
|
+
maciKeypair = this.maciKeypair;
|
|
5516
|
+
}
|
|
5517
|
+
const stateIdx = await this.getStateIdxByPubKey({
|
|
5518
|
+
contractAddress,
|
|
5519
|
+
pubKey: maciKeypair.pubKey
|
|
5520
|
+
});
|
|
5515
5521
|
if (stateIdx === -1) {
|
|
5516
|
-
throw new Error(
|
|
5522
|
+
throw new Error(
|
|
5523
|
+
"State index is not set, Please signup or addNewKey first"
|
|
5524
|
+
);
|
|
5517
5525
|
}
|
|
5518
5526
|
try {
|
|
5519
5527
|
const round = await this.indexer.getRoundWithFields(contractAddress, [
|
|
@@ -5565,9 +5573,6 @@ var MACI = class {
|
|
|
5565
5573
|
if (!address) {
|
|
5566
5574
|
address = (await signer.getAccounts())[0].address;
|
|
5567
5575
|
}
|
|
5568
|
-
if (maciKeypair === void 0) {
|
|
5569
|
-
maciKeypair = this.maciKeypair;
|
|
5570
|
-
}
|
|
5571
5576
|
const plan = options.map((o) => {
|
|
5572
5577
|
return [o.idx, o.vc];
|
|
5573
5578
|
});
|
|
@@ -6126,8 +6131,18 @@ var MaciClient2 = class {
|
|
|
6126
6131
|
async getVoiceCreditBalance({
|
|
6127
6132
|
signer,
|
|
6128
6133
|
stateIdx,
|
|
6134
|
+
maciKeypair,
|
|
6129
6135
|
contractAddress
|
|
6130
6136
|
}) {
|
|
6137
|
+
if (maciKeypair === void 0) {
|
|
6138
|
+
maciKeypair = this.maciKeypair;
|
|
6139
|
+
}
|
|
6140
|
+
if (stateIdx === void 0) {
|
|
6141
|
+
stateIdx = await this.getStateIdxByPubKey({
|
|
6142
|
+
contractAddress,
|
|
6143
|
+
pubKey: maciKeypair.pubKey
|
|
6144
|
+
});
|
|
6145
|
+
}
|
|
6131
6146
|
return await this.maci.getVoiceCreditBalance({
|
|
6132
6147
|
signer: this.getSigner(signer),
|
|
6133
6148
|
stateIdx,
|
|
@@ -6287,7 +6302,6 @@ var MaciClient2 = class {
|
|
|
6287
6302
|
async vote({
|
|
6288
6303
|
signer,
|
|
6289
6304
|
address,
|
|
6290
|
-
stateIdx,
|
|
6291
6305
|
contractAddress,
|
|
6292
6306
|
selectedOptions,
|
|
6293
6307
|
operatorCoordPubKey,
|
|
@@ -6297,7 +6311,6 @@ var MaciClient2 = class {
|
|
|
6297
6311
|
return await this.maci.vote({
|
|
6298
6312
|
signer: this.getSigner(signer),
|
|
6299
6313
|
address,
|
|
6300
|
-
stateIdx,
|
|
6301
6314
|
contractAddress,
|
|
6302
6315
|
selectedOptions,
|
|
6303
6316
|
operatorCoordPubKey,
|