coinhall/cosmes

Unable to estimate fee using MnemonicWallet

Closed this issue · 1 comments

Fails when simulating transaction in query method of RPCCLient.

import { MnemonicWallet } from "cosmes/wallet";
import { MsgInstantiateContract } from "cosmes/client";

async function main() {

    const wallet = new MnemonicWallet({
        mnemonic: "address finger arm glide plastic current garment universe people secret mask snack duck what spend congress curious hip wall ensure feel more traffic size",
        bech32Prefix: "terra",
        chainId: "columbus-5",
        rpc: "https://terra-classic-rpc.publicnode.com:443",
        gasPrice: {
            amount: "50",
            denom: "uluna",
        },
        coinType: 330
    })

    const msg = new MsgInstantiateContract(
        wallet.address,
        wallet.address,
        '6036',
        {
            "name": "Test Token",
            "symbol": "TEST",
            "decimals": 6,
            "initial_balances": [
                {
                    "address": wallet.address,
                    "amount": "777777777777777"
                }
            ]
        },
        undefined,
        'My Label'
    )

    const tx = {
        msgs: [msg],
        memo: 'Instantiate Contract via Cosmes'
    }
    

    const fee = await wallet.estimateFee(tx); //TODO fails at estimateFee


}

main();
Error: rpc error: code = Unknown desc = sender: empty address string is not allowed [CosmWasm/wasmd@v0.30.0/x/wasm/types/tx.go:97] With gas wanted: '0' and gas used: '501075' : unknown request
    at RpcClient.query (file:///D:/instantiate-contract/node_modules/cosmes/dist/client/clients/RpcClient.js:37:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async estimate (file:///D:/instantiate-contract/node_modules/cosmes/dist/wallet/wallets/ConnectedWallet.js:46:33)
    at async MnemonicWallet.estimateFee (file:///D:/instantiate-contract/node_modules/cosmes/dist/wallet/wallets/ConnectedWallet.js:59:20)
    at async main (file:///D:/instantiate-contract/index.js:44:17)

Sorry for issue spam lol. MsgInstantiateContract takes object not individual arguments.

    const msg = new MsgInstantiateContract({
       sender: wallet.address,
        admin: wallet.address,
        codeId: '6036',
        msg: {
            "name": "Test Token",
            "symbol": "TEST",
            "decimals": 6,
            "initial_balances": [
                {
                    "address": wallet.address,
                    "amount": "777777777777777"
                }
            ]
        },
        funds: undefined,
        label: 'My Label'
    })