Skip to content

Commit

Permalink
refactor: adding eth & tokenfactory types (#389)
Browse files Browse the repository at this point in the history
* refactor: adding eth & tokenfactory types

* chore: remove test file

* fix: typo

* refactor: wasmclient doesn't need nibi registry
  • Loading branch information
CalicoNino authored Nov 20, 2024
1 parent d707e12 commit 8c6c34c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/sdk/msg/eth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate"
import {
MsgServiceName,
MsgClientImpl,
MsgConvertCoinToEvm,
MsgConvertCoinToEvmResponse,
Expand All @@ -10,6 +11,21 @@ import {
MsgUpdateParams,
MsgUpdateParamsResponse,
} from "../../protojs/eth/evm/v1/tx"
import { GeneratedType } from "@cosmjs/proto-signing"

export const ETH_MSG_TYPE_URLS = {
MsgEthereumTx: `/${MsgServiceName}EthereumTx`,
MsgUpdateParams: `/${MsgServiceName}UpdateParams`,
MsgCreateFunToken: `/${MsgServiceName}CreateFunToken`,
MsgConvertCoinToEvm: `/${MsgServiceName}ConvertCoinToEvm`,
}

export const ethTypes: ReadonlyArray<[string, GeneratedType]> = [
[ETH_MSG_TYPE_URLS.MsgEthereumTx, MsgEthereumTx],
[ETH_MSG_TYPE_URLS.MsgUpdateParams, MsgUpdateParams],
[ETH_MSG_TYPE_URLS.MsgCreateFunToken, MsgCreateFunToken],
[ETH_MSG_TYPE_URLS.MsgConvertCoinToEvm, MsgConvertCoinToEvm],
]

export interface EthMsgExtension {
ethereumTx: (body: MsgEthereumTx) => Promise<MsgEthereumTxResponse>
Expand Down
40 changes: 40 additions & 0 deletions src/sdk/msg/tokenfactory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createProtobufRpcClient, QueryClient } from "@cosmjs/stargate"
import {
MsgServiceName,
MsgCreateDenom,
MsgClientImpl,
MsgCreateDenomResponse,
Expand All @@ -16,6 +17,27 @@ import {
MsgBurnNative,
MsgBurnNativeResponse,
} from "../../protojs/nibiru/tokenfactory/v1/tx"
import { GeneratedType } from "@cosmjs/proto-signing"

export const TOKENFACTORY_MSG_TYPE_URLS = {
MsgCreateDenom: `/${MsgServiceName}CreateDenom`,
MsgChangeAdmin: `/${MsgServiceName}ChangeAdmin`,
MsgUpdateModuleParams: `/${MsgServiceName}UpdateModuleParams`,
MsgMint: `/${MsgServiceName}Mint`,
MsgBurn: `/${MsgServiceName}Burn`,
MsgSetDenomMetadata: `/${MsgServiceName}SetDenomMetadata`,
MsgBurnNative: `/${MsgServiceName}BurnNative`,
}

export const tokenfactoryTypes: ReadonlyArray<[string, GeneratedType]> = [
[TOKENFACTORY_MSG_TYPE_URLS.MsgCreateDenom, MsgCreateDenom],
[TOKENFACTORY_MSG_TYPE_URLS.MsgChangeAdmin, MsgChangeAdmin],
[TOKENFACTORY_MSG_TYPE_URLS.MsgUpdateModuleParams, MsgUpdateModuleParams],
[TOKENFACTORY_MSG_TYPE_URLS.MsgMint, MsgMint],
[TOKENFACTORY_MSG_TYPE_URLS.MsgBurn, MsgBurn],
[TOKENFACTORY_MSG_TYPE_URLS.MsgSetDenomMetadata, MsgSetDenomMetadata],
[TOKENFACTORY_MSG_TYPE_URLS.MsgBurnNative, MsgBurnNative],
]

export interface TokenFactoryMsgExtension {
createDenom: (body: MsgCreateDenom) => Promise<MsgCreateDenomResponse>
Expand Down Expand Up @@ -57,3 +79,21 @@ export const setupTokenFactoryMsgExtension = (
queryService.BurnNative(MsgBurnNative.fromPartial(body)),
}
}

export {
MsgCreateDenom,
MsgClientImpl,
MsgCreateDenomResponse,
MsgChangeAdmin,
MsgChangeAdminResponse,
MsgUpdateModuleParams,
MsgUpdateModuleParamsResponse,
MsgBurn,
MsgBurnResponse,
MsgMint,
MsgMintResponse,
MsgSetDenomMetadata,
MsgSetDenomMetadataResponse,
MsgBurnNative,
MsgBurnNativeResponse,
}
9 changes: 8 additions & 1 deletion src/sdk/tx/txClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import {
} from "@cosmjs/stargate"
import { Tendermint37Client } from "@cosmjs/tendermint-rpc"
import { setupWasmExtension } from "@cosmjs/cosmwasm-stargate"
import { NibiruExtensions, setupNibiruExtension } from ".."
import {
ethTypes,
NibiruExtensions,
setupNibiruExtension,
tokenfactoryTypes,
} from ".."
import { accountFromNibiru } from "./account"
import {
NibiSigningCosmWasmClient,
Expand All @@ -22,6 +27,8 @@ import {

export const nibiruRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [
...defaultRegistryTypes,
...tokenfactoryTypes,
...ethTypes,
]

export class NibiruTxClient extends SigningStargateClient {
Expand Down

0 comments on commit 8c6c34c

Please sign in to comment.