@dorafactory/maci-sdk 0.1.2-pre.6 → 0.1.2-pre.8

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
@@ -5347,7 +5347,9 @@ var Contract = class {
5347
5347
  link,
5348
5348
  maxVoter,
5349
5349
  voteOptionMap,
5350
- whitelistBackendPubkey
5350
+ whitelistBackendPubkey,
5351
+ gasStation = false,
5352
+ fee = 1.8
5351
5353
  }) {
5352
5354
  const startTime = (startVoting.getTime() * 1e6).toString();
5353
5355
  const endTime = (endVoting.getTime() * 1e6).toString();
@@ -5359,7 +5361,7 @@ var Contract = class {
5359
5361
  const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
5360
5362
  BigInt(operatorPubkey)
5361
5363
  );
5362
- const createResponse = await client.createOracleMaciRound({
5364
+ const roundParams = {
5363
5365
  certificationSystem: "0",
5364
5366
  circuitType: "0",
5365
5367
  coordinator: {
@@ -5376,7 +5378,55 @@ var Contract = class {
5376
5378
  endTime,
5377
5379
  voteOptionMap,
5378
5380
  whitelistBackendPubkey: whitelistBackendPubkey || this.whitelistBackendPubkey
5379
- });
5381
+ };
5382
+ let createResponse;
5383
+ if (gasStation && typeof fee !== "object") {
5384
+ const [{ address }] = await signer.getAccounts();
5385
+ const contractClient = await this.contractClient({ signer });
5386
+ const msg = {
5387
+ create_oracle_maci_round: roundParams
5388
+ };
5389
+ const gasEstimation = await contractClient.simulate(
5390
+ address,
5391
+ [
5392
+ {
5393
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5394
+ value: {
5395
+ sender: address,
5396
+ contract: this.saasAddress,
5397
+ msg: new TextEncoder().encode(JSON.stringify(msg))
5398
+ }
5399
+ }
5400
+ ],
5401
+ ""
5402
+ );
5403
+ const multiplier = typeof fee === "number" ? fee : 1.8;
5404
+ const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
5405
+ const calculatedFee = (0, import_stargate2.calculateFee)(
5406
+ Math.round(gasEstimation * multiplier),
5407
+ gasPrice
5408
+ );
5409
+ const grantFee = {
5410
+ amount: calculatedFee.amount,
5411
+ gas: calculatedFee.gas,
5412
+ granter: this.saasAddress
5413
+ };
5414
+ createResponse = await client.createOracleMaciRound(
5415
+ roundParams,
5416
+ grantFee
5417
+ );
5418
+ } else if (gasStation && typeof fee === "object") {
5419
+ const grantFee = {
5420
+ ...fee,
5421
+ granter: this.saasAddress
5422
+ };
5423
+ createResponse = await client.createOracleMaciRound(
5424
+ roundParams,
5425
+ grantFee
5426
+ );
5427
+ } else {
5428
+ createResponse = await client.createOracleMaciRound(roundParams, fee);
5429
+ }
5380
5430
  let contractAddress = "";
5381
5431
  createResponse.events.map((event) => {
5382
5432
  if (event.type === "wasm") {