@dorafactory/maci-sdk 0.1.2-pre.0 → 0.1.2-pre.2

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.mjs CHANGED
@@ -5471,6 +5471,85 @@ var Contract = class {
5471
5471
  fee
5472
5472
  );
5473
5473
  }
5474
+ async saasGrantToVoter({
5475
+ signer,
5476
+ baseAmount,
5477
+ contractAddress,
5478
+ grantee,
5479
+ gasStation = false,
5480
+ fee = 1.8
5481
+ }) {
5482
+ const client = await createSaasClientBy({
5483
+ rpcEndpoint: this.rpcEndpoint,
5484
+ wallet: signer,
5485
+ contractAddress: this.saasAddress
5486
+ });
5487
+ if (gasStation && typeof fee !== "object") {
5488
+ const [{ address }] = await signer.getAccounts();
5489
+ const contractClient = await this.contractClient({ signer });
5490
+ const msg = {
5491
+ grant_to_voter: {
5492
+ base_amount: baseAmount,
5493
+ contract_addr: contractAddress,
5494
+ grantee
5495
+ }
5496
+ };
5497
+ const gasEstimation = await contractClient.simulate(
5498
+ address,
5499
+ [
5500
+ {
5501
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5502
+ value: {
5503
+ sender: address,
5504
+ contract: this.saasAddress,
5505
+ msg: new TextEncoder().encode(JSON.stringify(msg))
5506
+ }
5507
+ }
5508
+ ],
5509
+ ""
5510
+ );
5511
+ const multiplier = typeof fee === "number" ? fee : 1.8;
5512
+ const gasPrice = GasPrice2.fromString("10000000000peaka");
5513
+ const calculatedFee = calculateFee(
5514
+ Math.round(gasEstimation * multiplier),
5515
+ gasPrice
5516
+ );
5517
+ const grantFee = {
5518
+ amount: calculatedFee.amount,
5519
+ gas: calculatedFee.gas,
5520
+ granter: this.saasAddress
5521
+ };
5522
+ return client.grantToVoter(
5523
+ {
5524
+ baseAmount,
5525
+ contractAddr: contractAddress,
5526
+ grantee
5527
+ },
5528
+ grantFee
5529
+ );
5530
+ } else if (gasStation && typeof fee === "object") {
5531
+ const grantFee = {
5532
+ ...fee,
5533
+ granter: this.saasAddress
5534
+ };
5535
+ return client.grantToVoter(
5536
+ {
5537
+ baseAmount,
5538
+ contractAddr: contractAddress,
5539
+ grantee
5540
+ },
5541
+ grantFee
5542
+ );
5543
+ }
5544
+ return client.grantToVoter(
5545
+ {
5546
+ baseAmount,
5547
+ contractAddr: contractAddress,
5548
+ grantee
5549
+ },
5550
+ fee
5551
+ );
5552
+ }
5474
5553
  async addSaasOperator({
5475
5554
  signer,
5476
5555
  operator,