Skip to content

Commit

Permalink
Fix errors on amino conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
joon9823 committed Jan 10, 2025
1 parent d59c008 commit aa998d5
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 53 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@initia/initia.js",
"version": "0.2.25",
"version": "0.2.26",
"description": "The JavaScript SDK for Initia",
"license": "Apache-2.0",
"author": "Initia Foundation",
Expand Down
8 changes: 4 additions & 4 deletions src/core/ibc/applications/nft-transfer/msgs/MsgNftTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class MsgNftTransfer extends JSONSerializable<
token_ids,
sender,
receiver,
timeout_height ? Height.fromAmino(timeout_height) : undefined,
Height.fromAmino(timeout_height),
timeout_timestamp,
memo
)
Expand All @@ -119,9 +119,9 @@ export class MsgNftTransfer extends JSONSerializable<
token_ids,
sender,
receiver,
timeout_height: timeout_height?.toAmino(),
timeout_height: timeout_height?.toAmino() ?? {},
timeout_timestamp,
memo,
memo: memo === '' ? undefined : memo,
},
}
}
Expand Down Expand Up @@ -253,7 +253,7 @@ export namespace MsgNftTransfer {
token_ids: string[]
sender: AccAddress
receiver: string
timeout_height?: Height.Amino
timeout_height: Height.Amino
timeout_timestamp?: string
memo?: string
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/ibc/applications/transfer/msgs/MsgTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class MsgTransfer extends JSONSerializable<
token ? Coin.fromAmino(token) : undefined,
sender,
receiver,
timeout_height ? Height.fromAmino(timeout_height) : undefined,
Height.fromAmino(timeout_height),
timeout_timestamp,
memo
)
Expand All @@ -112,9 +112,9 @@ export class MsgTransfer extends JSONSerializable<
token: token?.toAmino(),
sender,
receiver,
timeout_height: timeout_height?.toAmino(),
timeout_height: timeout_height?.toAmino() ?? {},
timeout_timestamp,
memo,
memo: memo === '' ? undefined : memo,
},
}
}
Expand Down Expand Up @@ -238,7 +238,7 @@ export namespace MsgTransfer {
token?: Coin.Amino
sender: AccAddress
receiver: string
timeout_height?: Height.Amino
timeout_height: Height.Amino
timeout_timestamp?: string
memo?: string
}
Expand Down
23 changes: 17 additions & 6 deletions src/core/wasm/msgs/MsgExecuteContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ export class MsgExecuteContract extends JSONSerializable<
value: { sender, contract, msg, funds },
} = data

return new MsgExecuteContract(sender, contract, msg, Coins.fromAmino(funds))
return new MsgExecuteContract(
sender,
contract,
Buffer.from(JSON.stringify(msg)).toString('base64'),
Coins.fromAmino(funds)
)
}

public toAmino(): MsgExecuteContract.Amino {
Expand All @@ -44,15 +49,21 @@ export class MsgExecuteContract extends JSONSerializable<
value: {
sender,
contract,
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
funds: funds.toAmino(),
},
}
}

public static fromData(data: MsgExecuteContract.Data): MsgExecuteContract {
const { sender, contract, msg, funds } = data
return new MsgExecuteContract(sender, contract, msg, Coins.fromData(funds))

return new MsgExecuteContract(
sender,
contract,
Buffer.from(JSON.stringify(msg)).toString('base64'),
Coins.fromData(funds)
)
}

public toData(): MsgExecuteContract.Data {
Expand All @@ -61,7 +72,7 @@ export class MsgExecuteContract extends JSONSerializable<
'@type': '/cosmwasm.wasm.v1.MsgExecuteContract',
sender,
contract,
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
funds: funds.toData(),
}
}
Expand Down Expand Up @@ -105,7 +116,7 @@ export namespace MsgExecuteContract {
value: {
sender: AccAddress
contract: AccAddress
msg: string
msg: JSON
funds: Coins.Amino
}
}
Expand All @@ -114,7 +125,7 @@ export namespace MsgExecuteContract {
'@type': '/cosmwasm.wasm.v1.MsgExecuteContract'
sender: AccAddress
contract: AccAddress
msg: string
msg: JSON
funds: Coins.Data
}

Expand Down
12 changes: 6 additions & 6 deletions src/core/wasm/msgs/MsgInstantiateContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class MsgInstantiateContract extends JSONSerializable<
admin,
parseInt(code_id),
label,
msg,
Buffer.from(JSON.stringify(msg)).toString('base64'),
Coins.fromAmino(funds)
)
}
Expand All @@ -59,7 +59,7 @@ export class MsgInstantiateContract extends JSONSerializable<
admin,
code_id: code_id.toFixed(),
label,
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
funds: funds.toAmino(),
},
}
Expand All @@ -74,7 +74,7 @@ export class MsgInstantiateContract extends JSONSerializable<
admin,
parseInt(code_id),
label,
msg,
Buffer.from(JSON.stringify(msg)).toString('base64'),
Coins.fromData(funds)
)
}
Expand All @@ -87,7 +87,7 @@ export class MsgInstantiateContract extends JSONSerializable<
admin,
code_id: code_id.toFixed(),
label,
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
funds: funds.toData(),
}
}
Expand Down Expand Up @@ -139,7 +139,7 @@ export namespace MsgInstantiateContract {
admin?: AccAddress
code_id: string
label?: string
msg: string
msg: JSON
funds: Coins.Amino
}
}
Expand All @@ -150,7 +150,7 @@ export namespace MsgInstantiateContract {
admin?: AccAddress
code_id: string
label?: string
msg: string
msg: JSON
funds: Coins.Data
}

Expand Down
12 changes: 6 additions & 6 deletions src/core/wasm/msgs/MsgInstantiateContractV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class MsgInstantiateContractV2 extends JSONSerializable<
admin,
parseInt(code_id),
label,
msg,
Buffer.from(JSON.stringify(msg)).toString('base64'),
Coins.fromAmino(funds),
salt,
fix_msg
Expand All @@ -65,7 +65,7 @@ export class MsgInstantiateContractV2 extends JSONSerializable<
admin,
code_id: code_id.toFixed(),
label,
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
funds: funds.toAmino(),
salt,
fix_msg,
Expand All @@ -82,7 +82,7 @@ export class MsgInstantiateContractV2 extends JSONSerializable<
admin,
parseInt(code_id),
label,
msg,
Buffer.from(JSON.stringify(msg)).toString('base64'),
Coins.fromData(funds),
salt,
fix_msg
Expand All @@ -97,7 +97,7 @@ export class MsgInstantiateContractV2 extends JSONSerializable<
admin,
code_id: code_id.toFixed(),
label,
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
funds: funds.toData(),
salt,
fix_msg,
Expand Down Expand Up @@ -155,7 +155,7 @@ export namespace MsgInstantiateContractV2 {
admin?: AccAddress
code_id: string
label?: string
msg: string
msg: JSON
funds: Coins.Amino
salt: string
fix_msg: boolean
Expand All @@ -168,7 +168,7 @@ export namespace MsgInstantiateContractV2 {
admin?: AccAddress
code_id: string
label?: string
msg: string
msg: JSON
funds: Coins.Data
salt: string
fix_msg: boolean
Expand Down
23 changes: 17 additions & 6 deletions src/core/wasm/msgs/MsgMigrateContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ export class MsgMigrateContract extends JSONSerializable<
value: { sender, contract, code_id, msg },
} = data

return new MsgMigrateContract(sender, contract, parseInt(code_id), msg)
return new MsgMigrateContract(
sender,
contract,
parseInt(code_id),
Buffer.from(JSON.stringify(msg)).toString('base64')
)
}

public toAmino(): MsgMigrateContract.Amino {
Expand All @@ -42,14 +47,20 @@ export class MsgMigrateContract extends JSONSerializable<
sender,
contract,
code_id: code_id.toFixed(),
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
},
}
}

public static fromData(data: MsgMigrateContract.Data): MsgMigrateContract {
const { sender, contract, code_id, msg } = data
return new MsgMigrateContract(sender, contract, parseInt(code_id), msg)

return new MsgMigrateContract(
sender,
contract,
parseInt(code_id),
Buffer.from(JSON.stringify(msg)).toString('base64')
)
}

public toData(): MsgMigrateContract.Data {
Expand All @@ -59,7 +70,7 @@ export class MsgMigrateContract extends JSONSerializable<
sender,
contract,
code_id: code_id.toFixed(),
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
}
}

Expand Down Expand Up @@ -103,7 +114,7 @@ export namespace MsgMigrateContract {
sender: AccAddress
contract: AccAddress
code_id: string
msg: string
msg: JSON
}
}

Expand All @@ -112,7 +123,7 @@ export namespace MsgMigrateContract {
sender: AccAddress
contract: AccAddress
code_id: string
msg: string
msg: JSON
}

export type Proto = MsgMigrateContract_pb
Expand Down
12 changes: 6 additions & 6 deletions src/core/wasm/msgs/MsgStoreAndInstantiateContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class MsgStoreAndInstantiateContract extends JSONSerializable<
unpin_code,
admin,
label,
msg,
Buffer.from(JSON.stringify(msg)).toString('base64'),
Coins.fromAmino(funds),
source,
builder,
Expand Down Expand Up @@ -105,7 +105,7 @@ export class MsgStoreAndInstantiateContract extends JSONSerializable<
unpin_code,
admin,
label,
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
funds: funds.toAmino(),
source,
builder,
Expand Down Expand Up @@ -140,7 +140,7 @@ export class MsgStoreAndInstantiateContract extends JSONSerializable<
unpin_code,
admin,
label,
msg,
Buffer.from(JSON.stringify(msg)).toString('base64'),
Coins.fromData(funds),
source,
builder,
Expand Down Expand Up @@ -171,7 +171,7 @@ export class MsgStoreAndInstantiateContract extends JSONSerializable<
unpin_code,
admin,
label,
msg,
msg: JSON.parse(Buffer.from(msg, 'base64').toString()),
funds: funds.toData(),
source,
builder,
Expand Down Expand Up @@ -253,7 +253,7 @@ export namespace MsgStoreAndInstantiateContract {
unpin_code?: boolean
admin?: AccAddress
label?: string
msg: string
msg: JSON
funds: Coins.Amino
source: string
builder: string
Expand All @@ -269,7 +269,7 @@ export namespace MsgStoreAndInstantiateContract {
unpin_code?: boolean
admin?: AccAddress
label?: string
msg: string
msg: JSON
funds: Coins.Amino
source: string
builder: string
Expand Down
Loading

0 comments on commit aa998d5

Please sign in to comment.