Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raw Msg MessageComposer #84

Closed
adairrr opened this issue Nov 23, 2022 · 0 comments
Closed

Raw Msg MessageComposer #84

adairrr opened this issue Nov 23, 2022 · 0 comments

Comments

@adairrr
Copy link
Contributor

adairrr commented Nov 23, 2022

It would be great if we could generate a "raw" message composer as well, or have an optional parameter to the message composer so that we can build the "raw" messages like this:

{
  install_module: {
    init_msg: initMsg,
    module,
  }

instead of the MsgExecuteContractEncodeObject (which you need to deconstruct to msg.value.msg otherwise).

The code would probably look like the following:

  installModule = (
    {
      initMsg,
      module,
    }: {
      initMsg?: Binary
      module: ModuleInfo
    },
     // this return typing below does not exist yet but would be really nice!
  ): InstallModuleExecMsg => ({
    install_module: {
      init_msg: initMsg,
      module,
    },
  })

(vs currently):

  installModule = (
    {
      initMsg,
      module,
    }: {
      initMsg?: Binary
      module: ModuleInfo
    },
    funds?: Coin[]
  ): MsgExecuteContractEncodeObject => {
    return {
      typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
      value: MsgExecuteContract.fromPartial({
        sender: this.sender,
        contract: this.contractAddress,
        msg: toUtf8(
          JSON.stringify({
            install_module: {
              init_msg: initMsg,
              module,
            },
          })
        ),
        funds,
      }),
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant