Skip to content

Commit aa998d5

Browse files
committed
Fix errors on amino conversions
1 parent d59c008 commit aa998d5

11 files changed

+83
-53
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@initia/initia.js",
3-
"version": "0.2.25",
3+
"version": "0.2.26",
44
"description": "The JavaScript SDK for Initia",
55
"license": "Apache-2.0",
66
"author": "Initia Foundation",

src/core/ibc/applications/nft-transfer/msgs/MsgNftTransfer.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class MsgNftTransfer extends JSONSerializable<
9292
token_ids,
9393
sender,
9494
receiver,
95-
timeout_height ? Height.fromAmino(timeout_height) : undefined,
95+
Height.fromAmino(timeout_height),
9696
timeout_timestamp,
9797
memo
9898
)
@@ -119,9 +119,9 @@ export class MsgNftTransfer extends JSONSerializable<
119119
token_ids,
120120
sender,
121121
receiver,
122-
timeout_height: timeout_height?.toAmino(),
122+
timeout_height: timeout_height?.toAmino() ?? {},
123123
timeout_timestamp,
124-
memo,
124+
memo: memo === '' ? undefined : memo,
125125
},
126126
}
127127
}
@@ -253,7 +253,7 @@ export namespace MsgNftTransfer {
253253
token_ids: string[]
254254
sender: AccAddress
255255
receiver: string
256-
timeout_height?: Height.Amino
256+
timeout_height: Height.Amino
257257
timeout_timestamp?: string
258258
memo?: string
259259
}

src/core/ibc/applications/transfer/msgs/MsgTransfer.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class MsgTransfer extends JSONSerializable<
8787
token ? Coin.fromAmino(token) : undefined,
8888
sender,
8989
receiver,
90-
timeout_height ? Height.fromAmino(timeout_height) : undefined,
90+
Height.fromAmino(timeout_height),
9191
timeout_timestamp,
9292
memo
9393
)
@@ -112,9 +112,9 @@ export class MsgTransfer extends JSONSerializable<
112112
token: token?.toAmino(),
113113
sender,
114114
receiver,
115-
timeout_height: timeout_height?.toAmino(),
115+
timeout_height: timeout_height?.toAmino() ?? {},
116116
timeout_timestamp,
117-
memo,
117+
memo: memo === '' ? undefined : memo,
118118
},
119119
}
120120
}
@@ -238,7 +238,7 @@ export namespace MsgTransfer {
238238
token?: Coin.Amino
239239
sender: AccAddress
240240
receiver: string
241-
timeout_height?: Height.Amino
241+
timeout_height: Height.Amino
242242
timeout_timestamp?: string
243243
memo?: string
244244
}

src/core/wasm/msgs/MsgExecuteContract.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ export class MsgExecuteContract extends JSONSerializable<
3434
value: { sender, contract, msg, funds },
3535
} = data
3636

37-
return new MsgExecuteContract(sender, contract, msg, Coins.fromAmino(funds))
37+
return new MsgExecuteContract(
38+
sender,
39+
contract,
40+
Buffer.from(JSON.stringify(msg)).toString('base64'),
41+
Coins.fromAmino(funds)
42+
)
3843
}
3944

4045
public toAmino(): MsgExecuteContract.Amino {
@@ -44,15 +49,21 @@ export class MsgExecuteContract extends JSONSerializable<
4449
value: {
4550
sender,
4651
contract,
47-
msg,
52+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
4853
funds: funds.toAmino(),
4954
},
5055
}
5156
}
5257

5358
public static fromData(data: MsgExecuteContract.Data): MsgExecuteContract {
5459
const { sender, contract, msg, funds } = data
55-
return new MsgExecuteContract(sender, contract, msg, Coins.fromData(funds))
60+
61+
return new MsgExecuteContract(
62+
sender,
63+
contract,
64+
Buffer.from(JSON.stringify(msg)).toString('base64'),
65+
Coins.fromData(funds)
66+
)
5667
}
5768

5869
public toData(): MsgExecuteContract.Data {
@@ -61,7 +72,7 @@ export class MsgExecuteContract extends JSONSerializable<
6172
'@type': '/cosmwasm.wasm.v1.MsgExecuteContract',
6273
sender,
6374
contract,
64-
msg,
75+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
6576
funds: funds.toData(),
6677
}
6778
}
@@ -105,7 +116,7 @@ export namespace MsgExecuteContract {
105116
value: {
106117
sender: AccAddress
107118
contract: AccAddress
108-
msg: string
119+
msg: JSON
109120
funds: Coins.Amino
110121
}
111122
}
@@ -114,7 +125,7 @@ export namespace MsgExecuteContract {
114125
'@type': '/cosmwasm.wasm.v1.MsgExecuteContract'
115126
sender: AccAddress
116127
contract: AccAddress
117-
msg: string
128+
msg: JSON
118129
funds: Coins.Data
119130
}
120131

src/core/wasm/msgs/MsgInstantiateContract.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class MsgInstantiateContract extends JSONSerializable<
4545
admin,
4646
parseInt(code_id),
4747
label,
48-
msg,
48+
Buffer.from(JSON.stringify(msg)).toString('base64'),
4949
Coins.fromAmino(funds)
5050
)
5151
}
@@ -59,7 +59,7 @@ export class MsgInstantiateContract extends JSONSerializable<
5959
admin,
6060
code_id: code_id.toFixed(),
6161
label,
62-
msg,
62+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
6363
funds: funds.toAmino(),
6464
},
6565
}
@@ -74,7 +74,7 @@ export class MsgInstantiateContract extends JSONSerializable<
7474
admin,
7575
parseInt(code_id),
7676
label,
77-
msg,
77+
Buffer.from(JSON.stringify(msg)).toString('base64'),
7878
Coins.fromData(funds)
7979
)
8080
}
@@ -87,7 +87,7 @@ export class MsgInstantiateContract extends JSONSerializable<
8787
admin,
8888
code_id: code_id.toFixed(),
8989
label,
90-
msg,
90+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
9191
funds: funds.toData(),
9292
}
9393
}
@@ -139,7 +139,7 @@ export namespace MsgInstantiateContract {
139139
admin?: AccAddress
140140
code_id: string
141141
label?: string
142-
msg: string
142+
msg: JSON
143143
funds: Coins.Amino
144144
}
145145
}
@@ -150,7 +150,7 @@ export namespace MsgInstantiateContract {
150150
admin?: AccAddress
151151
code_id: string
152152
label?: string
153-
msg: string
153+
msg: JSON
154154
funds: Coins.Data
155155
}
156156

src/core/wasm/msgs/MsgInstantiateContractV2.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class MsgInstantiateContractV2 extends JSONSerializable<
4949
admin,
5050
parseInt(code_id),
5151
label,
52-
msg,
52+
Buffer.from(JSON.stringify(msg)).toString('base64'),
5353
Coins.fromAmino(funds),
5454
salt,
5555
fix_msg
@@ -65,7 +65,7 @@ export class MsgInstantiateContractV2 extends JSONSerializable<
6565
admin,
6666
code_id: code_id.toFixed(),
6767
label,
68-
msg,
68+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
6969
funds: funds.toAmino(),
7070
salt,
7171
fix_msg,
@@ -82,7 +82,7 @@ export class MsgInstantiateContractV2 extends JSONSerializable<
8282
admin,
8383
parseInt(code_id),
8484
label,
85-
msg,
85+
Buffer.from(JSON.stringify(msg)).toString('base64'),
8686
Coins.fromData(funds),
8787
salt,
8888
fix_msg
@@ -97,7 +97,7 @@ export class MsgInstantiateContractV2 extends JSONSerializable<
9797
admin,
9898
code_id: code_id.toFixed(),
9999
label,
100-
msg,
100+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
101101
funds: funds.toData(),
102102
salt,
103103
fix_msg,
@@ -155,7 +155,7 @@ export namespace MsgInstantiateContractV2 {
155155
admin?: AccAddress
156156
code_id: string
157157
label?: string
158-
msg: string
158+
msg: JSON
159159
funds: Coins.Amino
160160
salt: string
161161
fix_msg: boolean
@@ -168,7 +168,7 @@ export namespace MsgInstantiateContractV2 {
168168
admin?: AccAddress
169169
code_id: string
170170
label?: string
171-
msg: string
171+
msg: JSON
172172
funds: Coins.Data
173173
salt: string
174174
fix_msg: boolean

src/core/wasm/msgs/MsgMigrateContract.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ export class MsgMigrateContract extends JSONSerializable<
3131
value: { sender, contract, code_id, msg },
3232
} = data
3333

34-
return new MsgMigrateContract(sender, contract, parseInt(code_id), msg)
34+
return new MsgMigrateContract(
35+
sender,
36+
contract,
37+
parseInt(code_id),
38+
Buffer.from(JSON.stringify(msg)).toString('base64')
39+
)
3540
}
3641

3742
public toAmino(): MsgMigrateContract.Amino {
@@ -42,14 +47,20 @@ export class MsgMigrateContract extends JSONSerializable<
4247
sender,
4348
contract,
4449
code_id: code_id.toFixed(),
45-
msg,
50+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
4651
},
4752
}
4853
}
4954

5055
public static fromData(data: MsgMigrateContract.Data): MsgMigrateContract {
5156
const { sender, contract, code_id, msg } = data
52-
return new MsgMigrateContract(sender, contract, parseInt(code_id), msg)
57+
58+
return new MsgMigrateContract(
59+
sender,
60+
contract,
61+
parseInt(code_id),
62+
Buffer.from(JSON.stringify(msg)).toString('base64')
63+
)
5364
}
5465

5566
public toData(): MsgMigrateContract.Data {
@@ -59,7 +70,7 @@ export class MsgMigrateContract extends JSONSerializable<
5970
sender,
6071
contract,
6172
code_id: code_id.toFixed(),
62-
msg,
73+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
6374
}
6475
}
6576

@@ -103,7 +114,7 @@ export namespace MsgMigrateContract {
103114
sender: AccAddress
104115
contract: AccAddress
105116
code_id: string
106-
msg: string
117+
msg: JSON
107118
}
108119
}
109120

@@ -112,7 +123,7 @@ export namespace MsgMigrateContract {
112123
sender: AccAddress
113124
contract: AccAddress
114125
code_id: string
115-
msg: string
126+
msg: JSON
116127
}
117128

118129
export type Proto = MsgMigrateContract_pb

src/core/wasm/msgs/MsgStoreAndInstantiateContract.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class MsgStoreAndInstantiateContract extends JSONSerializable<
7373
unpin_code,
7474
admin,
7575
label,
76-
msg,
76+
Buffer.from(JSON.stringify(msg)).toString('base64'),
7777
Coins.fromAmino(funds),
7878
source,
7979
builder,
@@ -105,7 +105,7 @@ export class MsgStoreAndInstantiateContract extends JSONSerializable<
105105
unpin_code,
106106
admin,
107107
label,
108-
msg,
108+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
109109
funds: funds.toAmino(),
110110
source,
111111
builder,
@@ -140,7 +140,7 @@ export class MsgStoreAndInstantiateContract extends JSONSerializable<
140140
unpin_code,
141141
admin,
142142
label,
143-
msg,
143+
Buffer.from(JSON.stringify(msg)).toString('base64'),
144144
Coins.fromData(funds),
145145
source,
146146
builder,
@@ -171,7 +171,7 @@ export class MsgStoreAndInstantiateContract extends JSONSerializable<
171171
unpin_code,
172172
admin,
173173
label,
174-
msg,
174+
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
175175
funds: funds.toData(),
176176
source,
177177
builder,
@@ -253,7 +253,7 @@ export namespace MsgStoreAndInstantiateContract {
253253
unpin_code?: boolean
254254
admin?: AccAddress
255255
label?: string
256-
msg: string
256+
msg: JSON
257257
funds: Coins.Amino
258258
source: string
259259
builder: string
@@ -269,7 +269,7 @@ export namespace MsgStoreAndInstantiateContract {
269269
unpin_code?: boolean
270270
admin?: AccAddress
271271
label?: string
272-
msg: string
272+
msg: JSON
273273
funds: Coins.Amino
274274
source: string
275275
builder: string

0 commit comments

Comments
 (0)