@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 CHANGED
@@ -5772,63 +5772,54 @@ var MACI = class {
5772
5772
  const deactivates = await this.indexer.fetchAllDeactivateLogs(contractAddress);
5773
5773
  return deactivates;
5774
5774
  }
5775
- // async addNewKey({
5776
- // signer,
5777
- // client,
5778
- // address,
5779
- // maciKeypair,
5780
- // newMaciKeypair,
5781
- // contractAddress,
5782
- // gasStation,
5783
- // fee,
5784
- // }: {
5785
- // signer: OfflineSigner;
5786
- // client: SigningCosmWasmClient;
5787
- // address?: string;
5788
- // maciKeypair: Keypair;
5789
- // newMaciKeypair: Keypair;
5790
- // contractAddress: string;
5791
- // gasStation: boolean;
5792
- // fee?: StdFee;
5793
- // }) {
5794
- // const deactivates = await this.fetchAllDeactivateLogs({
5795
- // contractAddress,
5796
- // });
5797
- // const roundInfo = await this.getRoundInfo({
5798
- // contractAddress,
5799
- // });
5800
- // const inputObj = await genAddKeyProof(4, {
5801
- // coordPubKey: [
5802
- // BigInt(roundInfo.coordinatorPubkeyX),
5803
- // BigInt(roundInfo.coordinatorPubkeyY),
5804
- // ],
5805
- // oldKey: maciKeypair,
5806
- // deactivates: deactivates.map((d: any) => d.map(BigInt)),
5807
- // });
5808
- // if (!inputObj) {
5809
- // throw new Error('Failed to generate add key proof');
5810
- // }
5811
- // const amaciClient = await this.contract.amaciClient({
5812
- // signer,
5813
- // contractAddress,
5814
- // });
5815
- // const d = [
5816
- // inputObj.c1[0].toString(),
5817
- // inputObj.c1[1].toString(),
5818
- // inputObj.c2[0].toString(),
5819
- // inputObj.c2[1].toString(),
5820
- // ];
5821
- // const result = await amaciClient.addNewKey({
5822
- // d: d,
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,