@wormhole-foundation/sdk-cosmwasm
Version:
SDK for EVM chains, used in conjunction with @wormhole-foundation/sdk
37 lines • 1.36 kB
JavaScript
import { calculateFee } from "@cosmjs/stargate";
import { encoding } from "@wormhole-foundation/sdk-connect";
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx.js";
import { DEFAULT_FEE, MSG_EXECUTE_CONTRACT_TYPE_URL, averageGasPrices } from "./constants.js";
import { CosmwasmPlatform } from "./platform.js";
export function computeFee(network, chain) {
let avgFee = averageGasPrices.get(network, chain);
if (!avgFee)
avgFee = "0.1";
return calculateFee(DEFAULT_FEE * 1.5, `${avgFee}${CosmwasmPlatform.getNativeDenom(network, chain)}`);
}
export function buildExecuteMsg(sender, contract, msg, funds) {
return {
typeUrl: MSG_EXECUTE_CONTRACT_TYPE_URL,
value: MsgExecuteContract.fromPartial({
sender: sender,
contract: contract,
msg: encoding.bytes.encode(JSON.stringify(msg)),
funds,
}),
};
}
export class CosmwasmUnsignedTransaction {
transaction;
network;
chain;
description;
parallelizable;
constructor(transaction, network, chain, description, parallelizable = false) {
this.transaction = transaction;
this.network = network;
this.chain = chain;
this.description = description;
this.parallelizable = parallelizable;
}
}
//# sourceMappingURL=unsignedTransaction.js.map