@dorafactory/maci-sdk 0.0.50 → 0.0.51
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.js +76 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -57
- package/dist/index.mjs.map +1 -1
- package/dist/libs/maci/maci.d.ts +28 -0
- package/dist/maci.d.ts +28 -0
- package/package.json +1 -1
- package/src/libs/maci/maci.ts +70 -60
- package/src/maci.ts +42 -0
package/dist/index.js
CHANGED
|
@@ -5772,63 +5772,54 @@ var MACI = class {
|
|
|
5772
5772
|
const deactivates = await this.indexer.fetchAllDeactivateLogs(contractAddress);
|
|
5773
5773
|
return deactivates;
|
|
5774
5774
|
}
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
// groth16Proof: inputObj.proof,
|
|
5824
|
-
// nullifier: inputObj.nullifier.toString(),
|
|
5825
|
-
// pubkey: {
|
|
5826
|
-
// x: newMaciKeypair.pubKey[0].toString(),
|
|
5827
|
-
// y: newMaciKeypair.pubKey[1].toString(),
|
|
5828
|
-
// },
|
|
5829
|
-
// });
|
|
5830
|
-
// return result;
|
|
5831
|
-
// }
|
|
5775
|
+
async genAddKeyInput({
|
|
5776
|
+
maciKeypair,
|
|
5777
|
+
contractAddress
|
|
5778
|
+
}) {
|
|
5779
|
+
const deactivates = await this.fetchAllDeactivateLogs({
|
|
5780
|
+
contractAddress
|
|
5781
|
+
});
|
|
5782
|
+
const roundInfo = await this.getRoundInfo({
|
|
5783
|
+
contractAddress
|
|
5784
|
+
});
|
|
5785
|
+
const circuitPower = roundInfo.circuitPower;
|
|
5786
|
+
const stateTreeDepth = Number(circuitPower.split("-")[0]);
|
|
5787
|
+
const inputObj = genAddKeyInput(stateTreeDepth + 2, {
|
|
5788
|
+
coordPubKey: [
|
|
5789
|
+
BigInt(roundInfo.coordinatorPubkeyX),
|
|
5790
|
+
BigInt(roundInfo.coordinatorPubkeyY)
|
|
5791
|
+
],
|
|
5792
|
+
oldKey: maciKeypair,
|
|
5793
|
+
deactivates: deactivates.map((d) => d.map(BigInt))
|
|
5794
|
+
});
|
|
5795
|
+
return inputObj;
|
|
5796
|
+
}
|
|
5797
|
+
async addNewKey({
|
|
5798
|
+
signer,
|
|
5799
|
+
contractAddress,
|
|
5800
|
+
d,
|
|
5801
|
+
proof,
|
|
5802
|
+
nullifier,
|
|
5803
|
+
newMaciKeypair,
|
|
5804
|
+
fee = "auto"
|
|
5805
|
+
}) {
|
|
5806
|
+
const client = await this.contract.amaciClient({
|
|
5807
|
+
signer,
|
|
5808
|
+
contractAddress
|
|
5809
|
+
});
|
|
5810
|
+
return await client.addNewKey(
|
|
5811
|
+
{
|
|
5812
|
+
d,
|
|
5813
|
+
groth16Proof: proof,
|
|
5814
|
+
nullifier: nullifier.toString(),
|
|
5815
|
+
pubkey: {
|
|
5816
|
+
x: newMaciKeypair.pubKey[0].toString(),
|
|
5817
|
+
y: newMaciKeypair.pubKey[1].toString()
|
|
5818
|
+
}
|
|
5819
|
+
},
|
|
5820
|
+
fee
|
|
5821
|
+
);
|
|
5822
|
+
}
|
|
5832
5823
|
async claimAMaciRound({
|
|
5833
5824
|
signer,
|
|
5834
5825
|
contractAddress,
|
|
@@ -6319,6 +6310,34 @@ var MaciClient2 = class {
|
|
|
6319
6310
|
fee
|
|
6320
6311
|
});
|
|
6321
6312
|
}
|
|
6313
|
+
async genAddKeyInput({
|
|
6314
|
+
contractAddress,
|
|
6315
|
+
maciKeypair
|
|
6316
|
+
}) {
|
|
6317
|
+
return await this.maci.genAddKeyInput({
|
|
6318
|
+
maciKeypair: maciKeypair || this.maciKeypair,
|
|
6319
|
+
contractAddress
|
|
6320
|
+
});
|
|
6321
|
+
}
|
|
6322
|
+
async addNewKey({
|
|
6323
|
+
signer,
|
|
6324
|
+
contractAddress,
|
|
6325
|
+
d,
|
|
6326
|
+
proof,
|
|
6327
|
+
nullifier,
|
|
6328
|
+
newMaciKeypair,
|
|
6329
|
+
fee = "auto"
|
|
6330
|
+
}) {
|
|
6331
|
+
return await this.maci.addNewKey({
|
|
6332
|
+
signer: this.getSigner(signer),
|
|
6333
|
+
contractAddress,
|
|
6334
|
+
d,
|
|
6335
|
+
proof,
|
|
6336
|
+
nullifier,
|
|
6337
|
+
newMaciKeypair,
|
|
6338
|
+
fee
|
|
6339
|
+
});
|
|
6340
|
+
}
|
|
6322
6341
|
async claimAMaciRound({
|
|
6323
6342
|
signer,
|
|
6324
6343
|
contractAddress,
|