@dorafactory/maci-sdk 0.0.38 → 0.0.40

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.d.ts CHANGED
@@ -1,14 +1,10 @@
1
- export * from './libs';
2
- export type * from './types';
3
- export * from './types';
4
- export * from './libs/const';
5
1
  export { MaciClient } from './maci';
6
2
  export { Http } from './libs/http';
7
- export { Round } from './libs/query';
8
- export { UserAccount } from './libs/query';
9
- export { Circuit } from './libs/query';
10
- export { Operator } from './libs/query';
11
- export { Proof } from './libs/query';
12
- export { Transaction } from './libs/query';
3
+ export { Round, UserAccount, Circuit, Operator, Proof, Transaction, } from './libs/query';
13
4
  export * from './libs/crypto';
14
- export * from './utils';
5
+ export * from './types';
6
+ export type * from './types';
7
+ export { circuits, getDefaultParams, type NetworkConfig } from './libs/const';
8
+ export { stringizing, bigInt2Buffer } from './libs/crypto/bigintUtils';
9
+ export { isValidAddress } from './utils';
10
+ export { getAMaciRoundCircuitFee } from './libs/contract/utils';
package/dist/index.js CHANGED
@@ -31,20 +31,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  Circuit: () => Circuit,
34
- Contract: () => Contract,
35
- Event: () => Event,
36
34
  G1Point: () => G1Point,
37
35
  G2Point: () => G2Point,
38
36
  Http: () => Http,
39
- Indexer: () => Indexer,
40
- MACI: () => MACI,
41
37
  MaciCertSystemType: () => MaciCertSystemType,
42
38
  MaciCircuitType: () => MaciCircuitType,
43
39
  MaciClient: () => MaciClient2,
44
40
  MaciRoundType: () => MaciRoundType,
45
41
  NOTHING_UP_MY_SLEEVE: () => NOTHING_UP_MY_SLEEVE,
46
42
  Operator: () => Operator,
47
- OracleCertificate: () => OracleCertificate,
48
43
  PAD_KEY_HASH: () => PAD_KEY_HASH,
49
44
  Proof: () => Proof,
50
45
  Round: () => Round,
@@ -67,8 +62,6 @@ __export(index_exports, {
67
62
  genRandomBabyJubValue: () => genRandomBabyJubValue,
68
63
  genRandomSalt: () => genRandomSalt,
69
64
  getAMaciRoundCircuitFee: () => getAMaciRoundCircuitFee,
70
- getCircuitType: () => getCircuitType,
71
- getContractParams: () => getContractParams,
72
65
  getDefaultParams: () => getDefaultParams,
73
66
  hash12: () => hash12,
74
67
  hash2: () => hash2,
@@ -79,7 +72,6 @@ __export(index_exports, {
79
72
  hashLeftRight: () => hashLeftRight,
80
73
  hashN: () => hashN,
81
74
  hashOne: () => hashOne,
82
- hexToDecimalString: () => hexToDecimalString,
83
75
  isValidAddress: () => isValidAddress,
84
76
  packPubKey: () => packPubKey,
85
77
  poseidon: () => poseidon,
@@ -91,8 +83,7 @@ __export(index_exports, {
91
83
  sha256Hash: () => sha256Hash,
92
84
  signMessage: () => signMessage2,
93
85
  stringizing: () => stringizing,
94
- unpackPubKey: () => unpackPubKey,
95
- validator_operator_set: () => validator_operator_set
86
+ unpackPubKey: () => unpackPubKey
96
87
  });
97
88
  module.exports = __toCommonJS(index_exports);
98
89
 
@@ -399,107 +390,6 @@ var circuits = {
399
390
  zipUrl: "https://github.com/DoraFactory/Vota-Circuits/archive/refs/heads/main.zip"
400
391
  }
401
392
  };
402
- var validator_operator_set = {
403
- doravaloper12yk434ut3un4wx0rult2aww89rsrel8nhmp387: {
404
- operator_address: "",
405
- account_address: "dora12yk434ut3un4wx0rult2aww89rsrel8nydy83p",
406
- allocation: "22571615985356796592128",
407
- allocation_dora: 22571.615985356795,
408
- moniker: "\u{1D425}\u{1D41E}\u{1D42C}\u{1D427}\u{1D422}\u{1D424} | \u{1D414}\u{1D413}\u{1D412}\u{1D400}",
409
- program_voting_power: 0.06432895760166438,
410
- tokens: "200731587709257889972292"
411
- },
412
- doravaloper15frh0nn3v4yp3vv6sk4pn6jg9l8rt82f7uqfk5: {
413
- operator_address: "",
414
- account_address: "dora15frh0nn3v4yp3vv6sk4pn6jg9l8rt82fd29lqt",
415
- allocation: "33745159209325474873344",
416
- allocation_dora: 33745.15920932547,
417
- moniker: "NomadValidator",
418
- program_voting_power: 0.09617348254756773,
419
- tokens: "300099000000000000000000"
420
- },
421
- doravaloper1ddewp74vd2w8jhth2p0uazmc8ajgtcuf3ntqgn: {
422
- operator_address: "",
423
- account_address: "dora1ddewp74vd2w8jhth2p0uazmc8ajgtcufz9wk7v",
424
- allocation: "40789397021635754590208",
425
- allocation_dora: 40789.397021635756,
426
- moniker: "polkachu.com",
427
- program_voting_power: 0.11624951413777938,
428
- tokens: "362744095556470434789338"
429
- },
430
- doravaloper1gh8j89jtc2vx6d3y4ehllcdlvluwa49w6xmjsm: {
431
- operator_address: "",
432
- account_address: "dora1gh8j89jtc2vx6d3y4ehllcdlvluwa49wfs7yxy",
433
- allocation: "33743029941764137943040",
434
- allocation_dora: 33743.029941764136,
435
- moniker: "ITRocket",
436
- program_voting_power: 0.09616741414897524,
437
- tokens: "300080064215405665352721"
438
- },
439
- doravaloper1j8ru7p8zctup6grfwuga6ndrjj7v88wzn407x7: {
440
- operator_address: "",
441
- account_address: "dora1j8ru7p8zctup6grfwuga6ndrjj7v88wzqr2gsp",
442
- allocation: "22646525272055477174272",
443
- allocation_dora: 22646.525272055478,
444
- moniker: "StakeUs",
445
- program_voting_power: 0.06454244857772638,
446
- tokens: "201397763319500000000000"
447
- },
448
- doravaloper1l5zz0kkjt2n7nllsrymy96mc2v2gehda0zc85s: {
449
- operator_address: "",
450
- account_address: "dora1l5zz0kkjt2n7nllsrymy96mc2v2gehdau5a3z0",
451
- allocation: "22622846742220005965824",
452
- allocation_dora: 22622.846742220005,
453
- moniker: "BlackNodes",
454
- program_voting_power: 0.06447496492290769,
455
- tokens: "201187187838702364379121"
456
- },
457
- doravaloper1m9v3txhhtadjxpv09gwjhhs344qsxgfscwxjkg: {
458
- operator_address: "",
459
- account_address: "dora1m9v3txhhtadjxpv09gwjhhs344qsxgfstcryqh",
460
- allocation: "22549006983854435598336",
461
- allocation_dora: 22549.006983854437,
462
- moniker: "\u{1F44B} 79anvi \u{1F340}",
463
- program_voting_power: 0.06426452209558432,
464
- tokens: "200530523648490887200824"
465
- },
466
- doravaloper1tu8006g60t62zwgwf5knkaujv0uzhp2a6wh94h: {
467
- operator_address: "",
468
- account_address: "dora1tu8006g60t62zwgwf5knkaujv0uzhp2afcjnrg",
469
- allocation: "39369183740744815345664",
470
- allocation_dora: 39369.18374074482,
471
- moniker: "Citadel.one",
472
- program_voting_power: 0.11220191559671686,
473
- tokens: "350114000000000000000000"
474
- },
475
- doravaloper1x5z0tkafrgyeuqkrwfjr933vghjxchqnqlhcdw: {
476
- operator_address: "",
477
- account_address: "dora1x5z0tkafrgyeuqkrwfjr933vghjxchqnnfjwm3",
478
- allocation: "22611521290904268701696",
479
- allocation_dora: 22611.521290904268,
480
- moniker: "1ce",
481
- program_voting_power: 0.064442687460896,
482
- tokens: "201086469492900000000000"
483
- },
484
- doravaloper1z6kfew2nhuh02szc2hdecw4fqey2d32auucvux: {
485
- operator_address: "",
486
- account_address: "dora1z6kfew2nhuh02szc2hdecw4fqey2d32a02a62e",
487
- allocation: "45246951843662957379584",
488
- allocation_dora: 45246.95184366296,
489
- moniker: "Nodes.Guru",
490
- program_voting_power: 0.12895351616135226,
491
- tokens: "402385566389000000000006"
492
- },
493
- doravaloper1zzne8ufazycklx4j6mgc987t8ykd6wxu63223v: {
494
- operator_address: "",
495
- account_address: "dora1zzne8ufazycklx4j6mgc987t8ykd6wxu63223v",
496
- allocation: "44982761968475888943104",
497
- allocation_dora: 44982.76196847589,
498
- moniker: "ZKV",
499
- program_voting_power: 0.12820057674882976,
500
- tokens: "400036100000000000000000"
501
- }
502
- };
503
393
  function getDefaultParams(network = "mainnet") {
504
394
  switch (network) {
505
395
  case "mainnet":
@@ -627,10 +517,6 @@ function verifyIsBech32(address) {
627
517
  function isValidAddress(address) {
628
518
  return address.startsWith("dora") && verifyIsBech32(address) === void 0;
629
519
  }
630
- function hexToDecimalString(hexString) {
631
- const decimalString = BigInt("0x" + hexString).toString(10);
632
- return decimalString;
633
- }
634
520
 
635
521
  // src/libs/query/operator.ts
636
522
  var Operator = class {
@@ -4134,22 +4020,6 @@ var QTR_LIB = {
4134
4020
  };
4135
4021
 
4136
4022
  // src/libs/contract/utils.ts
4137
- function getCircuitType(circuitType) {
4138
- let maciVoteType = null;
4139
- switch (circuitType) {
4140
- case "0" /* IP1V */:
4141
- maciVoteType = "0";
4142
- break;
4143
- case "1" /* QV */:
4144
- maciVoteType = "1";
4145
- break;
4146
- default:
4147
- throw new Error(
4148
- `Invalid circuit type ${circuitType}, only support 1P1V and QV`
4149
- );
4150
- }
4151
- return maciVoteType;
4152
- }
4153
4023
  function getContractParams(type, circuitType, proofSystem, maxVoter, maxOption) {
4154
4024
  let parameters;
4155
4025
  let groth16ProcessVkey = null;
@@ -4881,7 +4751,8 @@ var Contract = class {
4881
4751
  maxOption,
4882
4752
  voiceCreditAmount,
4883
4753
  circuitType,
4884
- preDeactivateRoot
4754
+ preDeactivateRoot,
4755
+ fee = "auto"
4885
4756
  }) {
4886
4757
  const start_time = (startVoting.getTime() * 10 ** 6).toString();
4887
4758
  const end_time = (endVoting.getTime() * 10 ** 6).toString();
@@ -4912,7 +4783,7 @@ var Contract = class {
4912
4783
  certificationSystem: "0",
4913
4784
  circuitType
4914
4785
  },
4915
- "auto",
4786
+ fee,
4916
4787
  void 0,
4917
4788
  [requiredFee]
4918
4789
  );
@@ -4944,7 +4815,8 @@ var Contract = class {
4944
4815
  maxVoter,
4945
4816
  maxOption,
4946
4817
  circuitType,
4947
- certSystemType
4818
+ certSystemType,
4819
+ fee = "auto"
4948
4820
  }) {
4949
4821
  const start_time = (startVoting.getTime() * 10 ** 6).toString();
4950
4822
  const end_time = (endVoting.getTime() * 10 ** 6).toString();
@@ -4993,7 +4865,7 @@ var Contract = class {
4993
4865
  qtr_lib: QTR_LIB
4994
4866
  },
4995
4867
  `[MACI] ${title}`,
4996
- "auto"
4868
+ fee
4997
4869
  );
4998
4870
  return instantiateResponse;
4999
4871
  }
@@ -5009,7 +4881,8 @@ var Contract = class {
5009
4881
  circuitType,
5010
4882
  whitelistEcosystem,
5011
4883
  whitelistSnapshotHeight,
5012
- whitelistVotingPowerArgs
4884
+ whitelistVotingPowerArgs,
4885
+ fee = "auto"
5013
4886
  }) {
5014
4887
  const start_time = (startVoting.getTime() * 1e6).toString();
5015
4888
  const end_time = (endVoting.getTime() * 1e6).toString();
@@ -5048,7 +4921,7 @@ var Contract = class {
5048
4921
  feegrant_operator: this.feegrantOperator
5049
4922
  },
5050
4923
  `[Oracle MACI] ${title}`,
5051
- "auto"
4924
+ fee
5052
4925
  );
5053
4926
  return instantiateResponse;
5054
4927
  }
@@ -5467,7 +5340,8 @@ var MACI = class {
5467
5340
  contractAddress,
5468
5341
  maciKeypair,
5469
5342
  oracleCertificate,
5470
- gasStation = false
5343
+ gasStation = false,
5344
+ fee
5471
5345
  }) {
5472
5346
  try {
5473
5347
  if (!address) {
@@ -5486,7 +5360,8 @@ var MACI = class {
5486
5360
  pubKey: maciKeypair.pubKey,
5487
5361
  contractAddress,
5488
5362
  oracleCertificate,
5489
- gasStation
5363
+ gasStation,
5364
+ fee
5490
5365
  });
5491
5366
  } else {
5492
5367
  return await this.signupSimple({
@@ -5494,7 +5369,8 @@ var MACI = class {
5494
5369
  address,
5495
5370
  pubKey: maciKeypair.pubKey,
5496
5371
  contractAddress,
5497
- gasStation
5372
+ gasStation,
5373
+ fee
5498
5374
  });
5499
5375
  }
5500
5376
  } catch (error) {
@@ -5624,10 +5500,11 @@ var MACI = class {
5624
5500
  address,
5625
5501
  pubKey,
5626
5502
  contractAddress,
5627
- gasStation
5503
+ gasStation,
5504
+ fee
5628
5505
  }) {
5629
5506
  const gasPrice = import_stargate2.GasPrice.fromString("100000000000peaka");
5630
- const fee = (0, import_stargate2.calculateFee)(6e7, gasPrice);
5507
+ fee = fee || (0, import_stargate2.calculateFee)(6e7, gasPrice);
5631
5508
  if (gasStation === true) {
5632
5509
  const grantFee = {
5633
5510
  amount: fee.amount,
@@ -5668,10 +5545,11 @@ var MACI = class {
5668
5545
  pubKey,
5669
5546
  contractAddress,
5670
5547
  oracleCertificate,
5671
- gasStation
5548
+ gasStation,
5549
+ fee
5672
5550
  }) {
5673
5551
  const gasPrice = import_stargate2.GasPrice.fromString("100000000000peaka");
5674
- const fee = (0, import_stargate2.calculateFee)(6e7, gasPrice);
5552
+ fee = fee || (0, import_stargate2.calculateFee)(6e7, gasPrice);
5675
5553
  if (gasStation === true) {
5676
5554
  const grantFee = {
5677
5555
  amount: fee.amount,
@@ -5712,13 +5590,14 @@ var MACI = class {
5712
5590
  }
5713
5591
  async claimAMaciRound({
5714
5592
  signer,
5715
- contractAddress
5593
+ contractAddress,
5594
+ fee = "auto"
5716
5595
  }) {
5717
5596
  const client = await this.contract.amaciClient({
5718
5597
  signer,
5719
5598
  contractAddress
5720
5599
  });
5721
- return client.claim();
5600
+ return client.claim(fee);
5722
5601
  }
5723
5602
  async getOracleCertificateConfig() {
5724
5603
  const ecosystems = await this.oracleCertificate.listEcosystems();
@@ -5736,7 +5615,8 @@ var MACI = class {
5736
5615
  signer,
5737
5616
  contractAddress,
5738
5617
  address,
5739
- amount
5618
+ amount,
5619
+ fee = "auto"
5740
5620
  }) {
5741
5621
  const client = await this.contract.contractClient({
5742
5622
  signer
@@ -5783,7 +5663,7 @@ var MACI = class {
5783
5663
  }
5784
5664
  ];
5785
5665
  try {
5786
- const result = await client.signAndBroadcast(address, msgs, "auto");
5666
+ const result = await client.signAndBroadcast(address, msgs, fee);
5787
5667
  return result;
5788
5668
  } catch (err) {
5789
5669
  throw err;
@@ -5799,7 +5679,8 @@ var MACI = class {
5799
5679
  async batchRevokeWithdraw({
5800
5680
  signer,
5801
5681
  contractAddress,
5802
- address
5682
+ address,
5683
+ fee = "auto"
5803
5684
  }) {
5804
5685
  const client = await this.contract.contractClient({
5805
5686
  signer
@@ -5838,7 +5719,7 @@ var MACI = class {
5838
5719
  }
5839
5720
  ];
5840
5721
  try {
5841
- const result = await client.signAndBroadcast(address, msgs, "auto");
5722
+ const result = await client.signAndBroadcast(address, msgs, fee);
5842
5723
  return result;
5843
5724
  } catch (err) {
5844
5725
  throw err;
@@ -6148,7 +6029,8 @@ var MaciClient2 = class {
6148
6029
  contractAddress,
6149
6030
  maciKeypair,
6150
6031
  oracleCertificate,
6151
- gasStation = false
6032
+ gasStation = false,
6033
+ fee
6152
6034
  }) {
6153
6035
  return await this.maci.signup({
6154
6036
  signer: this.getSigner(signer),
@@ -6156,7 +6038,8 @@ var MaciClient2 = class {
6156
6038
  contractAddress,
6157
6039
  maciKeypair,
6158
6040
  oracleCertificate,
6159
- gasStation
6041
+ gasStation,
6042
+ fee
6160
6043
  });
6161
6044
  }
6162
6045
  async vote({
@@ -6182,12 +6065,13 @@ var MaciClient2 = class {
6182
6065
  }
6183
6066
  async claimAMaciRound({
6184
6067
  signer,
6185
- contractAddress
6068
+ contractAddress,
6069
+ fee = "auto"
6186
6070
  }) {
6187
- signer = this.getSigner(signer);
6188
6071
  return await this.maci.claimAMaciRound({
6189
- signer,
6190
- contractAddress
6072
+ signer: this.getSigner(signer),
6073
+ contractAddress,
6074
+ fee
6191
6075
  });
6192
6076
  }
6193
6077
  async getOracleCertificateConfig() {
@@ -6197,7 +6081,8 @@ var MaciClient2 = class {
6197
6081
  signer,
6198
6082
  contractAddress,
6199
6083
  address,
6200
- amount
6084
+ amount,
6085
+ fee = "auto"
6201
6086
  }) {
6202
6087
  if (!address) {
6203
6088
  address = await this.getAddress(signer);
@@ -6206,13 +6091,15 @@ var MaciClient2 = class {
6206
6091
  signer: this.getSigner(signer),
6207
6092
  contractAddress,
6208
6093
  address,
6209
- amount
6094
+ amount,
6095
+ fee
6210
6096
  });
6211
6097
  }
6212
6098
  async batchRevokeWithdraw({
6213
6099
  signer,
6214
6100
  contractAddress,
6215
- address
6101
+ address,
6102
+ fee = "auto"
6216
6103
  }) {
6217
6104
  if (!address) {
6218
6105
  address = await this.getAddress(signer);
@@ -6220,27 +6107,23 @@ var MaciClient2 = class {
6220
6107
  return await this.maci.batchRevokeWithdraw({
6221
6108
  signer: this.getSigner(signer),
6222
6109
  contractAddress,
6223
- address
6110
+ address,
6111
+ fee
6224
6112
  });
6225
6113
  }
6226
6114
  };
6227
6115
  // Annotate the CommonJS export names for ESM import in node:
6228
6116
  0 && (module.exports = {
6229
6117
  Circuit,
6230
- Contract,
6231
- Event,
6232
6118
  G1Point,
6233
6119
  G2Point,
6234
6120
  Http,
6235
- Indexer,
6236
- MACI,
6237
6121
  MaciCertSystemType,
6238
6122
  MaciCircuitType,
6239
6123
  MaciClient,
6240
6124
  MaciRoundType,
6241
6125
  NOTHING_UP_MY_SLEEVE,
6242
6126
  Operator,
6243
- OracleCertificate,
6244
6127
  PAD_KEY_HASH,
6245
6128
  Proof,
6246
6129
  Round,
@@ -6263,8 +6146,6 @@ var MaciClient2 = class {
6263
6146
  genRandomBabyJubValue,
6264
6147
  genRandomSalt,
6265
6148
  getAMaciRoundCircuitFee,
6266
- getCircuitType,
6267
- getContractParams,
6268
6149
  getDefaultParams,
6269
6150
  hash12,
6270
6151
  hash2,
@@ -6275,7 +6156,6 @@ var MaciClient2 = class {
6275
6156
  hashLeftRight,
6276
6157
  hashN,
6277
6158
  hashOne,
6278
- hexToDecimalString,
6279
6159
  isValidAddress,
6280
6160
  packPubKey,
6281
6161
  poseidon,
@@ -6287,7 +6167,6 @@ var MaciClient2 = class {
6287
6167
  sha256Hash,
6288
6168
  signMessage,
6289
6169
  stringizing,
6290
- unpackPubKey,
6291
- validator_operator_set
6170
+ unpackPubKey
6292
6171
  });
6293
6172
  //# sourceMappingURL=index.js.map