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

refactor: adding eth & tokenfactory types #389

Merged
merged 4 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`,
MsgBurns: `/${MsgServiceName}Burns`,
MsgSetDenomMetadata: `/${MsgServiceName}SetDenomMetadata`,
MsgBurnNative: `/${MsgServiceName}BurnNative`,
}
CalicoNino marked this conversation as resolved.
Show resolved Hide resolved

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.MsgBurns, MsgBurn],
[TOKENFACTORY_MSG_TYPE_URLS.MsgSetDenomMetadata, MsgSetDenomMetadata],
[TOKENFACTORY_MSG_TYPE_URLS.MsgBurnNative, MsgBurnNative],
]
CalicoNino marked this conversation as resolved.
Show resolved Hide resolved

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,
}
10 changes: 9 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 Expand Up @@ -60,6 +67,7 @@ export class NibiruTxClient extends SigningStargateClient {
signer,
{
gasPrice: GasPrice.fromString("0.025unibi"),
registry: new Registry(nibiruRegistryTypes),
accountParser: accountFromNibiru,
...wasmOptions,
}
Expand Down
Loading