@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.js CHANGED
@@ -5552,6 +5552,85 @@ var Contract = class {
5552
5552
  fee
5553
5553
  );
5554
5554
  }
5555
+ async saasGrantToVoter({
5556
+ signer,
5557
+ baseAmount,
5558
+ contractAddress,
5559
+ grantee,
5560
+ gasStation = false,
5561
+ fee = 1.8
5562
+ }) {
5563
+ const client = await createSaasClientBy({
5564
+ rpcEndpoint: this.rpcEndpoint,
5565
+ wallet: signer,
5566
+ contractAddress: this.saasAddress
5567
+ });
5568
+ if (gasStation && typeof fee !== "object") {
5569
+ const [{ address }] = await signer.getAccounts();
5570
+ const contractClient = await this.contractClient({ signer });
5571
+ const msg = {
5572
+ grant_to_voter: {
5573
+ base_amount: baseAmount,
5574
+ contract_addr: contractAddress,
5575
+ grantee
5576
+ }
5577
+ };
5578
+ const gasEstimation = await contractClient.simulate(
5579
+ address,
5580
+ [
5581
+ {
5582
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5583
+ value: {
5584
+ sender: address,
5585
+ contract: this.saasAddress,
5586
+ msg: new TextEncoder().encode(JSON.stringify(msg))
5587
+ }
5588
+ }
5589
+ ],
5590
+ ""
5591
+ );
5592
+ const multiplier = typeof fee === "number" ? fee : 1.8;
5593
+ const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
5594
+ const calculatedFee = (0, import_stargate2.calculateFee)(
5595
+ Math.round(gasEstimation * multiplier),
5596
+ gasPrice
5597
+ );
5598
+ const grantFee = {
5599
+ amount: calculatedFee.amount,
5600
+ gas: calculatedFee.gas,
5601
+ granter: this.saasAddress
5602
+ };
5603
+ return client.grantToVoter(
5604
+ {
5605
+ baseAmount,
5606
+ contractAddr: contractAddress,
5607
+ grantee
5608
+ },
5609
+ grantFee
5610
+ );
5611
+ } else if (gasStation && typeof fee === "object") {
5612
+ const grantFee = {
5613
+ ...fee,
5614
+ granter: this.saasAddress
5615
+ };
5616
+ return client.grantToVoter(
5617
+ {
5618
+ baseAmount,
5619
+ contractAddr: contractAddress,
5620
+ grantee
5621
+ },
5622
+ grantFee
5623
+ );
5624
+ }
5625
+ return client.grantToVoter(
5626
+ {
5627
+ baseAmount,
5628
+ contractAddr: contractAddress,
5629
+ grantee
5630
+ },
5631
+ fee
5632
+ );
5633
+ }
5555
5634
  async addSaasOperator({
5556
5635
  signer,
5557
5636
  operator,