Skip to content

Latest commit

 

History

History
103 lines (81 loc) · 2.48 KB

README.md

File metadata and controls

103 lines (81 loc) · 2.48 KB

@initia/amino-converter

Amino types and proto registry for initia chains


Installation

npm install @initia/amino-converter

Included Types

Usage

With Signing Stargate Client

import { SigningStargateClient } from '@cosmjs/stargate'
import { registry, aminoTypes } from '@initia/amino-converter'

const signingClient = await SigningStargateClient.connectWithSigner(
  '[RPC-URL]',
  signer, // Offline signer
  {
    registry,
    aminoTypes,
  }
)

Add Custom Types

import { Registry } from '@cosmjs/proto-signing'
import { AminoTypes, SigningStargateClient } from '@cosmjs/stargate'
import { protoRegistry, aminoConverters } from '@initia/amino-converter'

const registry = new Registry([...protoRegistry, ...customRegistry])

const aminoTypes = new AminoTypes({
  ...aminoConverters,
  ...customAminoConverters,
})

const signingClient = await SigningStargateClient.connectWithSigner(
  '[RPC-URL]',
  signer, // Offline signer
  {
    registry,
    aminoTypes,
  }
)

Generate Amino Converter With Custom Msg

If you need to use MsgExecuteMessages, MsgSubmitProposal and MsgSubmitTx with your custom messages, you need to register your custom messages to thier amino converter.

import { Registry } from '@cosmjs/proto-signing'
import { AminoTypes, SigningStargateClient } from '@cosmjs/stargate'
import {
  protoRegistry,
  aminoConverters,
  generateMsgExecuteMessagesAminoConverter,
  generateMsgSubmitProposalAminoConverter,
  generateMsgSubmitTxAminoConverter,
} from '@initia/amino-converter'

const registry = new Registry([...protoRegistry, ...customRegistry])

const msgExecuteMessagesAminoConverter =
  generateMsgExecuteMessagesAminoConverter(
    [...protoRegistry, ...customRegistry],
    {
      ...aminoConverters,
      ...customAminoConverters,
    }
  ) // register custom msg

const aminoTypes = new AminoTypes({
  ...aminoConverters,
  ...customAminoConverters,
  msgExecuteMessagesAminoConverter,
})

const signingClient = await SigningStargateClient.connectWithSigner(
  '[RPC-URL]',
  signer, // Offline signer
  {
    registry,
    aminoTypes,
  }
)