Skip to content

Commit

Permalink
Update MsgFinalizeTokenDeposit from opinit
Browse files Browse the repository at this point in the history
  • Loading branch information
joon9823 committed Feb 27, 2024
1 parent 2f9e7e7 commit 3896a7f
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 16 deletions.
101 changes: 92 additions & 9 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@initia/initia.js",
"version": "0.1.32",
"version": "0.1.33",
"description": "The JavaScript SDK for Initia",
"license": "MIT",
"author": "InitiaLabs",
Expand Down Expand Up @@ -85,8 +85,9 @@
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@initia/builder.js": "^0.1.3",
"@initia/initia.proto": "^0.1.26",
"@initia/opinit.proto": "^0.0.2",
"@initia/opinit.proto": "^0.0.3",
"@ledgerhq/hw-transport": "^6.27.12",
"@ledgerhq/hw-transport-webhid": "^6.27.12",
"@ledgerhq/hw-transport-webusb": "^6.27.12",
Expand Down
24 changes: 19 additions & 5 deletions src/core/opchild/msgs/MsgFinalizeTokenDeposit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { JSONSerializable } from '../../../util/json';
import { AccAddress } from '../../bech32';
import { Coin } from '../../Coin';
import { Denom } from '../../Denom';
import { MsgFinalizeTokenDeposit as MsgFinalizeTokenDeposit_pb } from '@initia/opinit.proto/opinit/opchild/v1/tx';
import { Any } from '@initia/initia.proto/google/protobuf/any';
import Long from 'long';
Expand All @@ -26,6 +27,7 @@ export class MsgFinalizeTokenDeposit extends JSONSerializable<
public amount: Coin,
public sequence: number,
public height: number,
public base_denom: Denom,
public data?: string
) {
super();
Expand All @@ -35,7 +37,7 @@ export class MsgFinalizeTokenDeposit extends JSONSerializable<
msgAmino: MsgFinalizeTokenDeposit.Amino
): MsgFinalizeTokenDeposit {
const {
value: { sender, from, to, amount, sequence, height, data },
value: { sender, from, to, amount, sequence, height, base_denom, data },
} = msgAmino;
return new MsgFinalizeTokenDeposit(
sender,
Expand All @@ -44,12 +46,14 @@ export class MsgFinalizeTokenDeposit extends JSONSerializable<
Coin.fromAmino(amount),
Number.parseInt(sequence),
Number.parseInt(height),
base_denom,
data
);
}

public toAmino(): MsgFinalizeTokenDeposit.Amino {
const { sender, from, to, amount, sequence, height, data } = this;
const { sender, from, to, amount, sequence, height, base_denom, data } =
this;
return {
type: 'opchild/MsgFinalizeTokenDeposit',
value: {
Expand All @@ -59,6 +63,7 @@ export class MsgFinalizeTokenDeposit extends JSONSerializable<
amount: amount.toAmino(),
sequence: sequence.toString(),
height: height.toString(),
base_denom,
data,
},
};
Expand All @@ -67,20 +72,23 @@ export class MsgFinalizeTokenDeposit extends JSONSerializable<
public static fromData(
msgData: MsgFinalizeTokenDeposit.Data
): MsgFinalizeTokenDeposit {
const { sender, from, to, amount, sequence, height, data } = msgData;
const { sender, from, to, amount, sequence, height, base_denom, data } =
msgData;
return new MsgFinalizeTokenDeposit(
sender,
from,
to,
Coin.fromData(amount),
Number.parseInt(sequence),
Number.parseInt(height),
base_denom,
data
);
}

public toData(): MsgFinalizeTokenDeposit.Data {
const { sender, from, to, amount, sequence, height, data } = this;
const { sender, from, to, amount, sequence, height, base_denom, data } =
this;
return {
'@type': '/opinit.opchild.v1.MsgFinalizeTokenDeposit',
sender,
Expand All @@ -89,6 +97,7 @@ export class MsgFinalizeTokenDeposit extends JSONSerializable<
amount: amount.toData(),
sequence: sequence.toString(),
height: height.toString(),
base_denom,
data,
};
}
Expand All @@ -103,19 +112,22 @@ export class MsgFinalizeTokenDeposit extends JSONSerializable<
Coin.fromProto(msgProto.amount as Coin),
msgProto.sequence.toNumber(),
msgProto.height.toNumber(),
msgProto.baseDenom,
Buffer.from(msgProto.data).toString('base64')
);
}

public toProto(): MsgFinalizeTokenDeposit.Proto {
const { sender, from, to, amount, sequence, height, data } = this;
const { sender, from, to, amount, sequence, height, base_denom, data } =
this;
return MsgFinalizeTokenDeposit_pb.fromPartial({
sender,
from,
to,
amount: amount.toProto(),
sequence: Long.fromNumber(sequence),
height: Long.fromNumber(height),
baseDenom: base_denom,
data: data ? Buffer.from(data, 'base64') : undefined,
});
}
Expand Down Expand Up @@ -144,6 +156,7 @@ export namespace MsgFinalizeTokenDeposit {
amount: Coin.Amino;
sequence: string;
height: string;
base_denom: Denom;
data?: string;
};
}
Expand All @@ -156,6 +169,7 @@ export namespace MsgFinalizeTokenDeposit {
amount: Coin.Data;
sequence: string;
height: string;
base_denom: Denom;
data?: string;
}

Expand Down

0 comments on commit 3896a7f

Please sign in to comment.