Skip to content

Commit 7e79c5f

Browse files
cgilbe27CalicoNino
andauthored
feat: develop -> main (#408)
* chore: unstoppable domain proxy (#404) * fix: move curly braces * refactor: adding custom amino messages (#407) * refactor: adding custom amino converter for convert to evm msg * chore: comment and linting * chore: new file instead of index * chore: linting --------- Co-authored-by: Calico Nino <54007257+CalicoNino@users.noreply.github.com>
1 parent 29cd907 commit 7e79c5f

File tree

5 files changed

+88
-1
lines changed

5 files changed

+88
-1
lines changed

nibiru

Submodule nibiru updated 97 files

src/sdk/aminomsgs/customamino.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { AminoConverter } from "@cosmjs/stargate"
2+
3+
/**
4+
* MsgConvertCoinToEvm defines the structure of the Protobuf message
5+
* used to convert a Cosmos coin to its EVM representation.
6+
*/
7+
interface MsgConvertCoinToEvm {
8+
/** The target Ethereum address that will receive the converted tokens */
9+
toEthAddr: string
10+
11+
/** The Cosmos sender address initiating the conversion */
12+
sender: string
13+
14+
/** The bank coin object containing the denom and amount to convert */
15+
bankCoin: {
16+
denom: string
17+
amount: string
18+
}
19+
}
20+
21+
/**
22+
* Amino-encoded version of MsgConvertCoinToEvm.
23+
* Uses snake_case field names as required by the Amino standard.
24+
*/
25+
interface AminoMsgConvertCoinToEvm {
26+
/** The Ethereum address in snake_case format */
27+
to_eth_addr: string
28+
29+
/** The Cosmos sender address */
30+
sender: string
31+
32+
/** The coin to be converted, in Amino format */
33+
bank_coin: {
34+
denom: string
35+
amount: string
36+
}
37+
}
38+
39+
/**
40+
* AminoConverters used by the AminoTypes class to serialize/deserialize
41+
* MsgConvertCoinToEvm messages to/from Amino-compatible JSON format.
42+
*/
43+
export const customAminoConverters: Record<string, AminoConverter> = {
44+
"/eth.evm.v1.MsgConvertCoinToEvm": {
45+
/**
46+
* Identifier for this Amino message type.
47+
* This must match the type used by legacy clients or signing tools.
48+
*/
49+
aminoType: "eth/MsgConvertCoinToEvm",
50+
51+
/**
52+
* Converts a Protobuf MsgConvertCoinToEvm into its Amino-encoded representation.
53+
* @param msg - The Protobuf message object
54+
* @returns The Amino-encoded JSON representation
55+
*/
56+
toAmino: (msg: MsgConvertCoinToEvm): AminoMsgConvertCoinToEvm => ({
57+
to_eth_addr: msg.toEthAddr,
58+
sender: msg.sender,
59+
bank_coin: {
60+
denom: msg.bankCoin.denom,
61+
amount: msg.bankCoin.amount,
62+
},
63+
}),
64+
65+
/**
66+
* Converts an Amino-encoded MsgConvertCoinToEvm into its Protobuf representation.
67+
* @param amino - The Amino JSON object
68+
* @returns The Protobuf-style message object
69+
*/
70+
fromAmino: (amino: AminoMsgConvertCoinToEvm): MsgConvertCoinToEvm => ({
71+
toEthAddr: amino.to_eth_addr,
72+
sender: amino.sender,
73+
bankCoin: {
74+
denom: amino.bank_coin.denom,
75+
amount: amino.bank_coin.amount,
76+
},
77+
}),
78+
},
79+
}

src/sdk/aminomsgs/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* @file Automatically generated by barrelsby.
3+
*/
4+
5+
export * from "./customamino"

src/sdk/core/signingcosmwasmclient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
import { MsgWithdrawDelegatorReward } from "cosmjs-types/cosmos/distribution/v1beta1/tx"
7575
import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing"
7676
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx"
77+
import { customAminoConverters } from "../aminomsgs"
7778

7879
function createDeliverTxResponseErrorMessage(
7980
result: DeliverTxResponse
@@ -162,6 +163,7 @@ export class NibiSigningCosmWasmClient extends NibiCosmWasmClient {
162163
aminoTypes = new AminoTypes({
163164
...createDefaultAminoConverters(),
164165
...createWasmAminoConverters(),
166+
...customAminoConverters,
165167
}),
166168
} = options
167169
this.registry = registry

src/sdk/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* @file Automatically generated by barrelsby.
33
*/
44

5+
export * from "./aminomsgs/index"
56
export * from "./core/index"
67
export * from "./msg/index"
78
export * from "./query/index"

0 commit comments

Comments
 (0)