From df1bbb9f45df368f30d71697953c8e61e0b44cb0 Mon Sep 17 00:00:00 2001 From: Geoff Lee <11830048+Vritra4@users.noreply.github.com> Date: Tue, 19 Jul 2022 11:54:13 +0900 Subject: [PATCH 1/2] use isClassic flag inside of packAny() and unpackAny() --- src/core/auth/BaseAccount.ts | 13 +- src/core/auth/ContinuousVestingAccount.ts | 7 +- src/core/auth/DelayedVestingAccount.ts | 5 +- src/core/auth/LazyGradedVestingAccount.ts | 13 +- src/core/auth/PeriodicVestingAccount.ts | 5 +- .../authorizations/GenericAuthorization.ts | 14 +- .../authz/authorizations/SendAuthorization.ts | 11 +- src/core/bank/msgs/MsgMultiSend.ts | 13 +- src/core/bank/msgs/MsgSend.ts | 10 +- src/core/crisis/MsgVerifyInvariant.ts | 29 ++- .../distribution/msgs/MsgFundCommunityPool.ts | 14 +- .../msgs/MsgSetWithdrawAddress.ts | 14 +- .../msgs/MsgWithdrawDelegatorReward.ts | 13 +- .../msgs/MsgWithdrawValidatorCommission.ts | 13 +- .../proposals/CommunityPoolSpendProposal.ts | 13 +- .../allowances/AllowedMsgAllowance.ts | 26 +- .../feegrant/allowances/BasicAllowance.ts | 13 +- .../feegrant/allowances/PeriodicAllowance.ts | 11 +- src/core/gov/Vote.ts | 17 +- src/core/ibc-transfer/DenomTrace.ts | 79 ------ .../ibc-transfer/msgs/MsgTransfer.spec.ts | 96 ------- src/core/ibc-transfer/msgs/MsgTransfer.ts | 234 ------------------ src/core/ibc-transfer/msgs/index.ts | 10 - .../transfer/v1/msgs/MsgTransfer.ts | 13 +- src/core/market/msgs/MsgSwap.ts | 4 +- src/core/market/msgs/MsgSwapSend.ts | 7 +- .../msgs/MsgAggregateExchangeRatePrevote.ts | 7 +- .../msgs/MsgAggregateExchangeRateVote.spec.ts | 14 ++ .../msgs/MsgAggregateExchangeRateVote.ts | 7 +- .../oracle/msgs/MsgDelegateFeedConsent.ts | 5 +- src/core/slashing/msgs/MsgUnjail.ts | 10 +- src/core/staking/msgs/MsgBeginRedelegate.ts | 14 +- src/core/staking/msgs/MsgCreateValidator.ts | 14 +- src/core/staking/msgs/MsgDelegate.ts | 13 +- src/core/staking/msgs/MsgEditValidator.ts | 13 +- src/core/staking/msgs/MsgUndelegate.ts | 13 +- .../CancelSoftwareUpgradeProposal.ts | 13 +- .../proposals/SoftwareUpgradeProposal.ts | 16 +- src/core/wasm/msgs/MsgMigrateCode.ts | 5 +- 39 files changed, 246 insertions(+), 595 deletions(-) delete mode 100644 src/core/ibc-transfer/DenomTrace.ts delete mode 100644 src/core/ibc-transfer/msgs/MsgTransfer.spec.ts delete mode 100644 src/core/ibc-transfer/msgs/MsgTransfer.ts delete mode 100644 src/core/ibc-transfer/msgs/index.ts diff --git a/src/core/auth/BaseAccount.ts b/src/core/auth/BaseAccount.ts index 643c46b73..05e53d5c0 100644 --- a/src/core/auth/BaseAccount.ts +++ b/src/core/auth/BaseAccount.ts @@ -120,17 +120,18 @@ export class BaseAccount extends JSONSerializable< ); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.auth.v1beta1.BaseAccount', - value: BaseAccount_pb.encode(this.toProto()).finish(), + value: BaseAccount_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(pubkeyAny: Any, _?: boolean): BaseAccount { - _; - return BaseAccount.fromProto(BaseAccount_pb.decode(pubkeyAny.value)); + public static unpackAny(pubkeyAny: Any, isClassic?: boolean): BaseAccount { + return BaseAccount.fromProto( + BaseAccount_pb.decode(pubkeyAny.value), + isClassic + ); } } diff --git a/src/core/auth/ContinuousVestingAccount.ts b/src/core/auth/ContinuousVestingAccount.ts index de674741a..8772a5589 100644 --- a/src/core/auth/ContinuousVestingAccount.ts +++ b/src/core/auth/ContinuousVestingAccount.ts @@ -136,7 +136,9 @@ export class ContinuousVestingAccount extends JSONSerializable< } return Any.fromPartial({ typeUrl: '/cosmos.vesting.v1beta1.ContinuousVestingAccount', - value: ContinuousVestingAccount_pb.encode(this.toProto()).finish(), + value: ContinuousVestingAccount_pb.encode( + this.toProto(isClassic) + ).finish(), }); } @@ -148,7 +150,8 @@ export class ContinuousVestingAccount extends JSONSerializable< throw new Error('Not supported for the network'); } return ContinuousVestingAccount.fromProto( - ContinuousVestingAccount_pb.decode(pubkeyAny.value) + ContinuousVestingAccount_pb.decode(pubkeyAny.value), + isClassic ); } } diff --git a/src/core/auth/DelayedVestingAccount.ts b/src/core/auth/DelayedVestingAccount.ts index 0659d41ea..123d9ffbc 100644 --- a/src/core/auth/DelayedVestingAccount.ts +++ b/src/core/auth/DelayedVestingAccount.ts @@ -118,7 +118,7 @@ export class DelayedVestingAccount extends JSONSerializable< } return Any.fromPartial({ typeUrl: '/cosmos.vesting.v1beta1.DelayedVestingAccount', - value: DelayedVestingAccount_pb.encode(this.toProto()).finish(), + value: DelayedVestingAccount_pb.encode(this.toProto(isClassic)).finish(), }); } @@ -130,7 +130,8 @@ export class DelayedVestingAccount extends JSONSerializable< throw new Error('Not supported for the network'); } return DelayedVestingAccount.fromProto( - DelayedVestingAccount_pb.decode(pubkeyAny.value) + DelayedVestingAccount_pb.decode(pubkeyAny.value), + isClassic ); } } diff --git a/src/core/auth/LazyGradedVestingAccount.ts b/src/core/auth/LazyGradedVestingAccount.ts index 8f41c0499..ba1ef2a82 100644 --- a/src/core/auth/LazyGradedVestingAccount.ts +++ b/src/core/auth/LazyGradedVestingAccount.ts @@ -129,21 +129,22 @@ export class LazyGradedVestingAccount extends JSONSerializable< ); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/terra.vesting.v1beta1.LazyGradedVestingAccount', - value: LazyGradedVestingAccount_pb.encode(this.toProto()).finish(), + value: LazyGradedVestingAccount_pb.encode( + this.toProto(isClassic) + ).finish(), }); } public static unpackAny( pubkeyAny: Any, - _?: boolean + isClassic?: boolean ): LazyGradedVestingAccount { - _; return LazyGradedVestingAccount.fromProto( - LazyGradedVestingAccount_pb.decode(pubkeyAny.value) + LazyGradedVestingAccount_pb.decode(pubkeyAny.value), + isClassic ); } } diff --git a/src/core/auth/PeriodicVestingAccount.ts b/src/core/auth/PeriodicVestingAccount.ts index a7bd8bebf..99f199707 100644 --- a/src/core/auth/PeriodicVestingAccount.ts +++ b/src/core/auth/PeriodicVestingAccount.ts @@ -148,7 +148,7 @@ export class PeriodicVestingAccount extends JSONSerializable< } return Any.fromPartial({ typeUrl: '/cosmos.vesting.v1beta1.PeriodicVestingAccount', - value: PeriodicVestingAccount_pb.encode(this.toProto()).finish(), + value: PeriodicVestingAccount_pb.encode(this.toProto(isClassic)).finish(), }); } @@ -160,7 +160,8 @@ export class PeriodicVestingAccount extends JSONSerializable< throw new Error('Not supported for the network'); } return PeriodicVestingAccount.fromProto( - PeriodicVestingAccount_pb.decode(pubkeyAny.value) + PeriodicVestingAccount_pb.decode(pubkeyAny.value), + isClassic ); } } diff --git a/src/core/authz/authorizations/GenericAuthorization.ts b/src/core/authz/authorizations/GenericAuthorization.ts index 041f7e840..293eab859 100644 --- a/src/core/authz/authorizations/GenericAuthorization.ts +++ b/src/core/authz/authorizations/GenericAuthorization.ts @@ -63,18 +63,20 @@ export class GenericAuthorization extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.authz.v1beta1.GenericAuthorization', - value: GenericAuthorization_pb.encode(this.toProto()).finish(), + value: GenericAuthorization_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): GenericAuthorization { - _; + public static unpackAny( + msgAny: Any, + isClassic?: boolean + ): GenericAuthorization { return GenericAuthorization.fromProto( - GenericAuthorization_pb.decode(msgAny.value) + GenericAuthorization_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/authz/authorizations/SendAuthorization.ts b/src/core/authz/authorizations/SendAuthorization.ts index b5667ceb8..fb210744a 100644 --- a/src/core/authz/authorizations/SendAuthorization.ts +++ b/src/core/authz/authorizations/SendAuthorization.ts @@ -66,18 +66,17 @@ export class SendAuthorization extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.bank.v1beta1.SendAuthorization', - value: SendAuthorization_pb.encode(this.toProto()).finish(), + value: SendAuthorization_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): SendAuthorization { - _; + public static unpackAny(msgAny: Any, isClassic?: boolean): SendAuthorization { return SendAuthorization.fromProto( - SendAuthorization_pb.decode(msgAny.value) + SendAuthorization_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/bank/msgs/MsgMultiSend.ts b/src/core/bank/msgs/MsgMultiSend.ts index 7961183f9..21da4b625 100644 --- a/src/core/bank/msgs/MsgMultiSend.ts +++ b/src/core/bank/msgs/MsgMultiSend.ts @@ -127,17 +127,18 @@ export class MsgMultiSend extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.bank.v1beta1.MsgMultiSend', - value: MsgMultiSend_pb.encode(this.toProto()).finish(), + value: MsgMultiSend_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgMultiSend { - _; - return MsgMultiSend.fromProto(MsgMultiSend_pb.decode(msgAny.value)); + public static unpackAny(msgAny: Any, isClassic?: boolean): MsgMultiSend { + return MsgMultiSend.fromProto( + MsgMultiSend_pb.decode(msgAny.value), + isClassic + ); } } diff --git a/src/core/bank/msgs/MsgSend.ts b/src/core/bank/msgs/MsgSend.ts index 8e71fa28a..a16f7bcd7 100644 --- a/src/core/bank/msgs/MsgSend.ts +++ b/src/core/bank/msgs/MsgSend.ts @@ -90,17 +90,15 @@ export class MsgSend extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.bank.v1beta1.MsgSend', - value: MsgSend_pb.encode(this.toProto()).finish(), + value: MsgSend_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgSend { - _; - return MsgSend.fromProto(MsgSend_pb.decode(msgAny.value)); + public static unpackAny(msgAny: Any, isClassic?: boolean): MsgSend { + return MsgSend.fromProto(MsgSend_pb.decode(msgAny.value), isClassic); } } diff --git a/src/core/crisis/MsgVerifyInvariant.ts b/src/core/crisis/MsgVerifyInvariant.ts index bd70f73c8..e29bd171d 100644 --- a/src/core/crisis/MsgVerifyInvariant.ts +++ b/src/core/crisis/MsgVerifyInvariant.ts @@ -25,7 +25,10 @@ export class MsgVerifyInvariant extends JSONSerializable< super(); } - public static fromAmino(data: MsgVerifyInvariant.Amino, _?: boolean): MsgVerifyInvariant { + public static fromAmino( + data: MsgVerifyInvariant.Amino, + _?: boolean + ): MsgVerifyInvariant { _; const { value: { sender, invariantModuleName, invariantRoute }, @@ -38,7 +41,10 @@ export class MsgVerifyInvariant extends JSONSerializable< throw new Error('MsgVerifyInvarant is not allowed to send'); } - public static fromData(data: MsgVerifyInvariant.Data, _?: boolean): MsgVerifyInvariant { + public static fromData( + data: MsgVerifyInvariant.Data, + _?: boolean + ): MsgVerifyInvariant { _; const { sender, invariantModuleName, invariantRoute } = data; return new MsgVerifyInvariant(sender, invariantModuleName, invariantRoute); @@ -55,7 +61,10 @@ export class MsgVerifyInvariant extends JSONSerializable< }; } - public static fromProto(proto: MsgVerifyInvariant.Proto, _?: boolean): MsgVerifyInvariant { + public static fromProto( + proto: MsgVerifyInvariant.Proto, + _?: boolean + ): MsgVerifyInvariant { _; return new MsgVerifyInvariant( proto.sender, @@ -69,18 +78,20 @@ export class MsgVerifyInvariant extends JSONSerializable< throw new Error('MsgVerifyInvarant is not allowed to send'); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.crisis.v1beta1.MsgVerifyInvariant', - value: MsgVerifyInvariant_pb.encode(this.toProto()).finish(), + value: MsgVerifyInvariant_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgVerifyInvariant { - _; + public static unpackAny( + msgAny: Any, + isClassic?: boolean + ): MsgVerifyInvariant { return MsgVerifyInvariant.fromProto( - MsgVerifyInvariant_pb.decode(msgAny.value) + MsgVerifyInvariant_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/distribution/msgs/MsgFundCommunityPool.ts b/src/core/distribution/msgs/MsgFundCommunityPool.ts index fbea93cb5..847f9a980 100644 --- a/src/core/distribution/msgs/MsgFundCommunityPool.ts +++ b/src/core/distribution/msgs/MsgFundCommunityPool.ts @@ -84,18 +84,20 @@ export class MsgFundCommunityPool extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.distribution.v1beta1.MsgFundCommunityPool', - value: MsgFundCommunityPool_pb.encode(this.toProto()).finish(), + value: MsgFundCommunityPool_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgFundCommunityPool { - _; + public static unpackAny( + msgAny: Any, + isClassic?: boolean + ): MsgFundCommunityPool { return MsgFundCommunityPool.fromProto( - MsgFundCommunityPool_pb.decode(msgAny.value) + MsgFundCommunityPool_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/distribution/msgs/MsgSetWithdrawAddress.ts b/src/core/distribution/msgs/MsgSetWithdrawAddress.ts index 137a9c958..7d195530d 100644 --- a/src/core/distribution/msgs/MsgSetWithdrawAddress.ts +++ b/src/core/distribution/msgs/MsgSetWithdrawAddress.ts @@ -89,18 +89,20 @@ export class MsgSetWithdrawAddress extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.distribution.v1beta1.MsgSetWithdrawAddress', - value: MsgSetWithdrawAddress_pb.encode(this.toProto()).finish(), + value: MsgSetWithdrawAddress_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgSetWithdrawAddress { - _; + public static unpackAny( + msgAny: Any, + isClassic?: boolean + ): MsgSetWithdrawAddress { return MsgSetWithdrawAddress.fromProto( - MsgSetWithdrawAddress_pb.decode(msgAny.value) + MsgSetWithdrawAddress_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/distribution/msgs/MsgWithdrawDelegatorReward.ts b/src/core/distribution/msgs/MsgWithdrawDelegatorReward.ts index edfd6f8c4..59c7e53d4 100644 --- a/src/core/distribution/msgs/MsgWithdrawDelegatorReward.ts +++ b/src/core/distribution/msgs/MsgWithdrawDelegatorReward.ts @@ -91,21 +91,22 @@ export class MsgWithdrawDelegatorReward extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward', - value: MsgWithdrawDelegatorReward_pb.encode(this.toProto()).finish(), + value: MsgWithdrawDelegatorReward_pb.encode( + this.toProto(isClassic) + ).finish(), }); } public static unpackAny( msgAny: Any, - _?: boolean + isClassic?: boolean ): MsgWithdrawDelegatorReward { - _; return MsgWithdrawDelegatorReward.fromProto( - MsgWithdrawDelegatorReward_pb.decode(msgAny.value) + MsgWithdrawDelegatorReward_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/distribution/msgs/MsgWithdrawValidatorCommission.ts b/src/core/distribution/msgs/MsgWithdrawValidatorCommission.ts index 13286ad94..1948282bd 100644 --- a/src/core/distribution/msgs/MsgWithdrawValidatorCommission.ts +++ b/src/core/distribution/msgs/MsgWithdrawValidatorCommission.ts @@ -77,21 +77,22 @@ export class MsgWithdrawValidatorCommission extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission', - value: MsgWithdrawValidatorCommission_pb.encode(this.toProto()).finish(), + value: MsgWithdrawValidatorCommission_pb.encode( + this.toProto(isClassic) + ).finish(), }); } public static unpackAny( msgAny: Any, - _?: boolean + isClassic?: boolean ): MsgWithdrawValidatorCommission { - _; return MsgWithdrawValidatorCommission.fromProto( - MsgWithdrawValidatorCommission_pb.decode(msgAny.value) + MsgWithdrawValidatorCommission_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/distribution/proposals/CommunityPoolSpendProposal.ts b/src/core/distribution/proposals/CommunityPoolSpendProposal.ts index 9e335374e..d232a8f5b 100644 --- a/src/core/distribution/proposals/CommunityPoolSpendProposal.ts +++ b/src/core/distribution/proposals/CommunityPoolSpendProposal.ts @@ -113,21 +113,22 @@ export class CommunityPoolSpendProposal extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.distribution.v1beta1.CommunityPoolSpendProposal', - value: CommunityPoolSpendProposal_pb.encode(this.toProto()).finish(), + value: CommunityPoolSpendProposal_pb.encode( + this.toProto(isClassic) + ).finish(), }); } public static unpackAny( msgAny: Any, - _?: boolean + isClassic?: boolean ): CommunityPoolSpendProposal { - _; return CommunityPoolSpendProposal.fromProto( - CommunityPoolSpendProposal_pb.decode(msgAny.value) + CommunityPoolSpendProposal_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/feegrant/allowances/AllowedMsgAllowance.ts b/src/core/feegrant/allowances/AllowedMsgAllowance.ts index e1fdfc94a..ef6d0d19a 100644 --- a/src/core/feegrant/allowances/AllowedMsgAllowance.ts +++ b/src/core/feegrant/allowances/AllowedMsgAllowance.ts @@ -82,39 +82,39 @@ export class AllowedMsgAllowance extends JSONSerializable< public static fromProto( proto: AllowedMsgAllowance.Proto, - _?: boolean + isClassic?: boolean ): AllowedMsgAllowance { - _; const allowance = proto.allowance as Any; return new AllowedMsgAllowance( allowance?.typeUrl === '/cosmos.feegrant.v1beta1.BasicAllowance' - ? BasicAllowance.unpackAny(allowance) - : PeriodicAllowance.unpackAny(allowance), + ? BasicAllowance.unpackAny(allowance, isClassic) + : PeriodicAllowance.unpackAny(allowance, isClassic), proto.allowedMessages ); } - public toProto(_?: boolean): AllowedMsgAllowance.Proto { - _; + public toProto(isClassic?: boolean): AllowedMsgAllowance.Proto { const { allowance, allowed_messages } = this; return AllowedMsgAllowance_pb.fromPartial({ - allowance: allowance.packAny(), + allowance: allowance.packAny(isClassic), allowedMessages: allowed_messages, }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.feegrant.v1beta1.AllowedMsgAllowance', - value: AllowedMsgAllowance_pb.encode(this.toProto()).finish(), + value: AllowedMsgAllowance_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): AllowedMsgAllowance { - _; + public static unpackAny( + msgAny: Any, + isClassic?: boolean + ): AllowedMsgAllowance { return AllowedMsgAllowance.fromProto( - AllowedMsgAllowance_pb.decode(msgAny.value) + AllowedMsgAllowance_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/feegrant/allowances/BasicAllowance.ts b/src/core/feegrant/allowances/BasicAllowance.ts index 2350052a8..e95901cf1 100644 --- a/src/core/feegrant/allowances/BasicAllowance.ts +++ b/src/core/feegrant/allowances/BasicAllowance.ts @@ -109,17 +109,18 @@ export class BasicAllowance extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.feegrant.v1beta1.BasicAllowance', - value: BasicAllowance_pb.encode(this.toProto()).finish(), + value: BasicAllowance_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): BasicAllowance { - _; - return BasicAllowance.fromProto(BasicAllowance_pb.decode(msgAny.value)); + public static unpackAny(msgAny: Any, isClassic?: boolean): BasicAllowance { + return BasicAllowance.fromProto( + BasicAllowance_pb.decode(msgAny.value), + isClassic + ); } } diff --git a/src/core/feegrant/allowances/PeriodicAllowance.ts b/src/core/feegrant/allowances/PeriodicAllowance.ts index a4fd2e6a3..516f7f170 100644 --- a/src/core/feegrant/allowances/PeriodicAllowance.ts +++ b/src/core/feegrant/allowances/PeriodicAllowance.ts @@ -154,18 +154,17 @@ export class PeriodicAllowance extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.feegrant.v1beta1.PeriodicAllowance', - value: PeriodicAllowance_pb.encode(this.toProto()).finish(), + value: PeriodicAllowance_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): PeriodicAllowance { - _; + public static unpackAny(msgAny: Any, isClassic?: boolean): PeriodicAllowance { return PeriodicAllowance.fromProto( - PeriodicAllowance_pb.decode(msgAny.value) + PeriodicAllowance_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/gov/Vote.ts b/src/core/gov/Vote.ts index 06c3c9737..16ede3282 100644 --- a/src/core/gov/Vote.ts +++ b/src/core/gov/Vote.ts @@ -16,7 +16,7 @@ export class Vote extends JSONSerializable { /** * @param proposal_id ID of proposal to vote on * @param voter voter's account address - * @param option one of voting options + * @param options one of voting options */ constructor( public proposal_id: number, @@ -122,7 +122,10 @@ export class WeightedVoteOption extends JSONSerializable< this.weight = new Dec(weight); } - public static fromAmino(data: WeightedVoteOption.Amino, _?: boolean): WeightedVoteOption { + public static fromAmino( + data: WeightedVoteOption.Amino, + _?: boolean + ): WeightedVoteOption { _; const { option, weight } = data; return new WeightedVoteOption(option, weight); @@ -137,7 +140,10 @@ export class WeightedVoteOption extends JSONSerializable< }; } - public static fromData(data: WeightedVoteOption.Data, _?: boolean): WeightedVoteOption { + public static fromData( + data: WeightedVoteOption.Data, + _?: boolean + ): WeightedVoteOption { _; const { option, weight } = data; return new WeightedVoteOption(option, weight); @@ -152,7 +158,10 @@ export class WeightedVoteOption extends JSONSerializable< }; } - public static fromProto(proto: WeightedVoteOption.Proto, _?: boolean): WeightedVoteOption { + public static fromProto( + proto: WeightedVoteOption.Proto, + _?: boolean + ): WeightedVoteOption { _; return new WeightedVoteOption(proto.option, proto.weight); } diff --git a/src/core/ibc-transfer/DenomTrace.ts b/src/core/ibc-transfer/DenomTrace.ts deleted file mode 100644 index df604da5e..000000000 --- a/src/core/ibc-transfer/DenomTrace.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { DenomTrace as DenomTrace_pb } from '@terra-money/terra.proto/ibc/applications/transfer/v1/transfer'; -import { JSONSerializable } from '../../util/json'; - -/** - * DenomTrace is a monotonically increasing data type - * that can be compared against another DenomTrace for the purposes of updating and - * freezing clients - * - * Normally the RevisionDenomTrace is incremented at each height while keeping - * RevisionNumber the same. However some consensus algorithms may choose to - * reset the height in certain conditions e.g. hard forks, state-machine - * breaking changes In these cases, the RevisionNumber is incremented so that - * height continues to be monitonically increasing even as the RevisionDenomTrace - * gets reset - */ -export class DenomTrace extends JSONSerializable< - DenomTrace.Amino, - DenomTrace.Data, - DenomTrace.Proto -> { - /** - * @param path the revision that the client is currently on - * @param base_denom the height within the given revision - */ - constructor(public path: string, public base_denom: string) { - super(); - } - - public static fromAmino(data: DenomTrace.Amino): DenomTrace { - const { path, base_denom } = data; - return new DenomTrace(path, base_denom); - } - - public toAmino(): DenomTrace.Amino { - const { path, base_denom } = this; - const res: DenomTrace.Amino = { - path, - base_denom, - }; - return res; - } - - public static fromData(data: DenomTrace.Data): DenomTrace { - const { path, base_denom } = data; - return new DenomTrace(path, base_denom); - } - - public toData(): DenomTrace.Data { - const { path, base_denom } = this; - const res: DenomTrace.Data = { - path, - base_denom, - }; - return res; - } - - public static fromProto(proto: DenomTrace.Proto): DenomTrace { - return new DenomTrace(proto.path, proto.baseDenom); - } - - public toProto(): DenomTrace.Proto { - const { path, base_denom } = this; - return DenomTrace_pb.fromPartial({ path, baseDenom: base_denom }); - } -} - -export namespace DenomTrace { - export interface Amino { - path: string; - base_denom: string; - } - - export interface Data { - path: string; - base_denom: string; - } - - export type Proto = DenomTrace_pb; -} diff --git a/src/core/ibc-transfer/msgs/MsgTransfer.spec.ts b/src/core/ibc-transfer/msgs/MsgTransfer.spec.ts deleted file mode 100644 index b710e6508..000000000 --- a/src/core/ibc-transfer/msgs/MsgTransfer.spec.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { MsgTransfer } from './MsgTransfer'; -import { Coin } from '../../Coin'; -import { Height } from '../../ibc/core/client/Height'; -import { Numeric } from '../..'; - -describe('MsgTransfer', () => { - it('deserializes correctly', () => { - const send = MsgTransfer.fromData({ - '@type': '/ibc.applications.transfer.v1.MsgTransfer', - source_port: 'sourceport-01', - source_channel: 'sourcehannel-01', - token: { denom: 'uluna', amount: '1024' }, - sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', - receiver: 'recvr17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp', - timeout_height: { - revision_number: '0', - revision_height: '0', - }, - timeout_timestamp: '1642663176848000000', - }); - - expect(send).toMatchObject({ - source_port: 'sourceport-01', - source_channel: 'sourcehannel-01', - token: new Coin('uluna', '1024'), - sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', - receiver: 'recvr17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp', - timeout_height: { - revision_number: 0, - revision_height: 0, - }, - timeout_timestamp: Numeric.parse('1642663176848000000'), - }); - }); - - it('deserializes amino without timeout_height', () => { - const send = MsgTransfer.fromData({ - '@type': '/ibc.applications.transfer.v1.MsgTransfer', - source_port: 'sourceport-01', - source_channel: 'sourcehannel-01', - token: { denom: 'uluna', amount: '1024' }, - sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', - receiver: 'recvr17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp', - timeout_height: new Height(0, 0).toData(), - timeout_timestamp: '1642663176848000000', - }); - const aminoSend = send.toAmino(); - - expect(aminoSend).toMatchObject({ - type: 'cosmos-sdk/MsgTransfer', - value: { - source_port: 'sourceport-01', - source_channel: 'sourcehannel-01', - token: new Coin('uluna', '1024').toAmino(), - sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', - receiver: 'recvr17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp', - timeout_height: {}, - timeout_timestamp: '1642663176848000000', - }, - }); - - expect(send.toData()).toMatchObject({}); - }); - - it('deserializes amino without timeout_timestamp', () => { - const send = MsgTransfer.fromData({ - '@type': '/ibc.applications.transfer.v1.MsgTransfer', - source_port: 'sourceport-01', - source_channel: 'sourcehannel-01', - token: { denom: 'uluna', amount: '1024' }, - sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', - receiver: 'recvr17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp', - timeout_height: { - revision_number: '5', - revision_height: '57240001', - }, - timeout_timestamp: '0', - }); - const aminoSend = send.toAmino(); - - expect(aminoSend).toMatchObject({ - type: 'cosmos-sdk/MsgTransfer', - value: { - source_port: 'sourceport-01', - source_channel: 'sourcehannel-01', - token: new Coin('uluna', '1024').toAmino(), - sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', - receiver: 'recvr17lmam6zguazs5q5u6z5mmx76uj63gldnse2pdp', - timeout_height: new Height(5, 57240001).toAmino(), - timeout_timestamp: undefined, - }, - }); - - expect(send.toData()).toMatchObject({}); - }); -}); diff --git a/src/core/ibc-transfer/msgs/MsgTransfer.ts b/src/core/ibc-transfer/msgs/MsgTransfer.ts deleted file mode 100644 index c8f71a75e..000000000 --- a/src/core/ibc-transfer/msgs/MsgTransfer.ts +++ /dev/null @@ -1,234 +0,0 @@ -import { JSONSerializable } from '../../../util/json'; -import { AccAddress } from '../../bech32'; -import { Coin } from '../../Coin'; -import * as Long from 'long'; -import { Any } from '@terra-money/terra.proto/google/protobuf/any'; -import { MsgTransfer as MsgTransfer_pb } from '@terra-money/terra.proto/ibc/applications/transfer/v1/tx'; -import { Height } from '../../ibc/core/client/Height'; -import { Numeric } from '../../numeric'; -/** - * A basic message for transfer [[Coin]] via IBC. - */ -export class MsgTransfer extends JSONSerializable< - MsgTransfer.Amino, - MsgTransfer.Data, - MsgTransfer.Proto -> { - public source_port: string; - public source_channel: string; - public token?: Coin; - public sender: AccAddress; - public receiver: string; // destination chain can be non-cosmos-based - public timeout_height?: Height; // 0 to disable - public timeout_timestamp?: Numeric.Output; // 0 to disable - /** - * @param source_port the port on which the packet will be sent - * @param source_channel the channel by which the packet will be sent - * @param token the tokens to be transferred - * @param sender the sender address - * @param receiver the recipient address on the destination chain - * @param timeout_height Timeout height relative to the current block height. (0 to disable) - * @param timeout_timestamp Timeout timestamp (in nanoseconds) relative to the current block timestamp. (0 to disable) - */ - constructor( - source_port: string, - source_channel: string, - token: Coin | undefined, - sender: AccAddress, - receiver: string, - timeout_height: Height | undefined, - timeout_timestamp: Numeric.Input | undefined - ) { - super(); - - if (!timeout_height && !timeout_timestamp) { - throw 'both of timeout_height and timeout_timestamp are undefined'; - } - - this.source_port = source_port; - this.source_channel = source_channel; - this.token = token; - this.sender = sender; - this.receiver = receiver; - this.timeout_height = timeout_height; - this.timeout_timestamp = timeout_timestamp - ? Numeric.parse(timeout_timestamp) - : undefined; - } - - public static fromAmino(data: MsgTransfer.Amino): MsgTransfer { - const { - value: { - source_port, - source_channel, - token, - sender, - receiver, - timeout_height, - timeout_timestamp, - }, - } = data; - - if (!timeout_height && !timeout_timestamp) { - throw 'both of timeout_height and timeout_timestamp are undefined'; - } - - return new MsgTransfer( - source_port, - source_channel, - token ? Coin.fromAmino(token) : undefined, - sender, - receiver, - timeout_height ? Height.fromAmino(timeout_height) : undefined, - timeout_timestamp ? Numeric.parse(timeout_timestamp) : undefined - ); - } - - public toAmino(): MsgTransfer.Amino { - const { - source_port, - source_channel, - token, - sender, - receiver, - timeout_height, - timeout_timestamp, - } = this; - return { - type: 'cosmos-sdk/MsgTransfer', - value: { - source_port, - source_channel, - token: token ? token.toAmino() : undefined, - sender, - receiver, - timeout_height: timeout_height?.toAmino() || {}, - timeout_timestamp: timeout_timestamp?.toFixed() || undefined, - }, - }; - } - - public static fromData(data: MsgTransfer.Data): MsgTransfer { - const { - source_port, - source_channel, - token, - sender, - receiver, - timeout_timestamp, - timeout_height, - } = data; - - if (!timeout_height && !timeout_timestamp) { - throw 'both of timeout_height and timeout_timestamp are undefined'; - } - - return new MsgTransfer( - source_port, - source_channel, - token ? Coin.fromData(token) : undefined, - sender, - receiver, - timeout_height ? Height.fromData(timeout_height) : undefined, - timeout_timestamp ? Number.parseInt(timeout_timestamp) : undefined - ); - } - - public toData(): MsgTransfer.Data { - const { - source_port, - source_channel, - token, - sender, - receiver, - timeout_height, - timeout_timestamp, - } = this; - return { - '@type': '/ibc.applications.transfer.v1.MsgTransfer', - source_port, - source_channel, - token: token ? token.toData() : undefined, - sender, - receiver, - timeout_height: timeout_height - ? timeout_height.toData() - : new Height(0, 0).toData(), - timeout_timestamp: timeout_timestamp?.toFixed() || '0', - }; - } - - public static fromProto(proto: MsgTransfer.Proto): MsgTransfer { - if (!proto.timeoutHeight && proto.timeoutTimestamp.toNumber() == 0) { - throw 'both of timeout_height and timeout_timestamp are empty'; - } - - return new MsgTransfer( - proto.sourcePort, - proto.sourceChannel, - proto.token ? Coin.fromProto(proto.token) : undefined, - proto.sender, - proto.receiver, - proto.timeoutHeight ? Height.fromProto(proto.timeoutHeight) : undefined, - proto.timeoutTimestamp.toNumber() - ); - } - - public toProto(): MsgTransfer.Proto { - const { - source_port, - source_channel, - token, - sender, - receiver, - timeout_height, - timeout_timestamp, - } = this; - return MsgTransfer_pb.fromPartial({ - sourcePort: source_port, - sourceChannel: source_channel, - token: token ? token.toProto() : undefined, - sender, - receiver, - timeoutHeight: timeout_height ? timeout_height.toProto() : undefined, - timeoutTimestamp: Long.fromString(timeout_timestamp?.toFixed() || '0'), - }); - } - - public packAny(): Any { - return Any.fromPartial({ - typeUrl: '/ibc.applications.transfer.v1.MsgTransfer', - value: MsgTransfer_pb.encode(this.toProto()).finish(), - }); - } - - public static unpackAny(msgAny: Any): MsgTransfer { - return MsgTransfer.fromProto(MsgTransfer_pb.decode(msgAny.value)); - } -} - -export namespace MsgTransfer { - export interface Amino { - type: 'cosmos-sdk/MsgTransfer'; - value: { - source_port: string; - source_channel: string; - token?: Coin.Amino; - sender: AccAddress; - receiver: string; - timeout_height: Height.Amino; - timeout_timestamp?: string; - }; - } - export interface Data { - '@type': '/ibc.applications.transfer.v1.MsgTransfer'; - source_port: string; - source_channel: string; - token?: Coin.Data; - sender: AccAddress; - receiver: string; - timeout_height: Height.Data; - timeout_timestamp: string; - } - export type Proto = MsgTransfer_pb; -} diff --git a/src/core/ibc-transfer/msgs/index.ts b/src/core/ibc-transfer/msgs/index.ts deleted file mode 100644 index 257ff85fb..000000000 --- a/src/core/ibc-transfer/msgs/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { MsgTransfer } from './MsgTransfer'; - -export * from './MsgTransfer'; - -export type IbcTransferMsg = MsgTransfer; -export namespace IbcTransferMsg { - export type Data = MsgTransfer.Data; - export type Amino = MsgTransfer.Amino; - export type Proto = MsgTransfer.Proto; -} diff --git a/src/core/ibc/applications/transfer/v1/msgs/MsgTransfer.ts b/src/core/ibc/applications/transfer/v1/msgs/MsgTransfer.ts index 774ae9872..fc8f08506 100644 --- a/src/core/ibc/applications/transfer/v1/msgs/MsgTransfer.ts +++ b/src/core/ibc/applications/transfer/v1/msgs/MsgTransfer.ts @@ -201,17 +201,18 @@ export class MsgTransfer extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/ibc.applications.transfer.v1.MsgTransfer', - value: MsgTransfer_pb.encode(this.toProto()).finish(), + value: MsgTransfer_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgTransfer { - _; - return MsgTransfer.fromProto(MsgTransfer_pb.decode(msgAny.value)); + public static unpackAny(msgAny: Any, isClassic?: boolean): MsgTransfer { + return MsgTransfer.fromProto( + MsgTransfer_pb.decode(msgAny.value), + isClassic + ); } } diff --git a/src/core/market/msgs/MsgSwap.ts b/src/core/market/msgs/MsgSwap.ts index b04ea04dd..67fcc9ba2 100644 --- a/src/core/market/msgs/MsgSwap.ts +++ b/src/core/market/msgs/MsgSwap.ts @@ -82,7 +82,7 @@ export class MsgSwap extends JSONSerializable< } return Any.fromPartial({ typeUrl: '/terra.market.v1beta1.MsgSwap', - value: MsgSwap_pb.encode(this.toProto()).finish(), + value: MsgSwap_pb.encode(this.toProto(isClassic)).finish(), }); } @@ -90,7 +90,7 @@ export class MsgSwap extends JSONSerializable< if (!isClassic) { throw new Error('Not supported for the network'); } - return MsgSwap.fromProto(MsgSwap_pb.decode(msgAny.value)); + return MsgSwap.fromProto(MsgSwap_pb.decode(msgAny.value), isClassic); } public static fromData(data: MsgSwap.Data, isClassic?: boolean): MsgSwap { diff --git a/src/core/market/msgs/MsgSwapSend.ts b/src/core/market/msgs/MsgSwapSend.ts index 705a1d181..930cddb50 100644 --- a/src/core/market/msgs/MsgSwapSend.ts +++ b/src/core/market/msgs/MsgSwapSend.ts @@ -98,7 +98,7 @@ export class MsgSwapSend extends JSONSerializable< } return Any.fromPartial({ typeUrl: '/terra.market.v1beta1.MsgSwapSend', - value: MsgSwapSend_pb.encode(this.toProto()).finish(), + value: MsgSwapSend_pb.encode(this.toProto(isClassic)).finish(), }); } @@ -106,7 +106,10 @@ export class MsgSwapSend extends JSONSerializable< if (!isClassic) { throw new Error('Not supported for the network'); } - return MsgSwapSend.fromProto(MsgSwapSend_pb.decode(msgAny.value)); + return MsgSwapSend.fromProto( + MsgSwapSend_pb.decode(msgAny.value), + isClassic + ); } public static fromData( diff --git a/src/core/oracle/msgs/MsgAggregateExchangeRatePrevote.ts b/src/core/oracle/msgs/MsgAggregateExchangeRatePrevote.ts index 5c4ffb6aa..9812e47cf 100644 --- a/src/core/oracle/msgs/MsgAggregateExchangeRatePrevote.ts +++ b/src/core/oracle/msgs/MsgAggregateExchangeRatePrevote.ts @@ -115,7 +115,9 @@ export class MsgAggregateExchangeRatePrevote extends JSONSerializable< return Any.fromPartial({ typeUrl: '/terra.oracle.v1beta1.MsgAggregateExchangeRatePrevote', - value: MsgAggregateExchangeRatePrevote_pb.encode(this.toProto()).finish(), + value: MsgAggregateExchangeRatePrevote_pb.encode( + this.toProto(isClassic) + ).finish(), }); } @@ -128,7 +130,8 @@ export class MsgAggregateExchangeRatePrevote extends JSONSerializable< } return MsgAggregateExchangeRatePrevote.fromProto( - MsgAggregateExchangeRatePrevote_pb.decode(msgAny.value) + MsgAggregateExchangeRatePrevote_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/oracle/msgs/MsgAggregateExchangeRateVote.spec.ts b/src/core/oracle/msgs/MsgAggregateExchangeRateVote.spec.ts index 98df2e032..c1a186183 100644 --- a/src/core/oracle/msgs/MsgAggregateExchangeRateVote.spec.ts +++ b/src/core/oracle/msgs/MsgAggregateExchangeRateVote.spec.ts @@ -17,4 +17,18 @@ describe('MsgAggregateExchangeRateVote', () => { '7929908433e7399845fa60f9ef70ef7f2bb8f01b' ); }); + it('conversion', () => { + const msg = new MsgAggregateExchangeRateVote( + { + ukrw: '245.000', + uusd: '0.2242', + usdr: '0.182', + }, + 'salt', + 'terra1krj7amhhagjnyg2tkkuh6l0550y733jnjulzjh', + 'terravaloper1krj7amhhagjnyg2tkkuh6l0550y733jnjnnlzy' + ); + const anyObj = msg.packAny(true); + expect(MsgAggregateExchangeRateVote.unpackAny(anyObj, true)).toBeDefined(); + }); }); diff --git a/src/core/oracle/msgs/MsgAggregateExchangeRateVote.ts b/src/core/oracle/msgs/MsgAggregateExchangeRateVote.ts index ce8f82675..c4bb91a66 100644 --- a/src/core/oracle/msgs/MsgAggregateExchangeRateVote.ts +++ b/src/core/oracle/msgs/MsgAggregateExchangeRateVote.ts @@ -166,7 +166,9 @@ export class MsgAggregateExchangeRateVote extends JSONSerializable< } return Any.fromPartial({ typeUrl: '/terra.oracle.v1beta1.MsgAggregateExchangeRateVote', - value: MsgAggregateExchangeRateVote_pb.encode(this.toProto()).finish(), + value: MsgAggregateExchangeRateVote_pb.encode( + this.toProto(isClassic) + ).finish(), }); } @@ -178,7 +180,8 @@ export class MsgAggregateExchangeRateVote extends JSONSerializable< throw new Error('Not supported for the network'); } return MsgAggregateExchangeRateVote.fromProto( - MsgAggregateExchangeRateVote_pb.decode(msgAny.value) + MsgAggregateExchangeRateVote_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/oracle/msgs/MsgDelegateFeedConsent.ts b/src/core/oracle/msgs/MsgDelegateFeedConsent.ts index cc699fc99..d017ff242 100644 --- a/src/core/oracle/msgs/MsgDelegateFeedConsent.ts +++ b/src/core/oracle/msgs/MsgDelegateFeedConsent.ts @@ -107,7 +107,7 @@ export class MsgDelegateFeedConsent extends JSONSerializable< } return Any.fromPartial({ typeUrl: '/terra.oracle.v1beta1.MsgDelegateFeedConsent', - value: MsgDelegateFeedConsent_pb.encode(this.toProto()).finish(), + value: MsgDelegateFeedConsent_pb.encode(this.toProto(isClassic)).finish(), }); } @@ -119,7 +119,8 @@ export class MsgDelegateFeedConsent extends JSONSerializable< throw new Error('Not supported for the network'); } return MsgDelegateFeedConsent.fromProto( - MsgDelegateFeedConsent_pb.decode(msgAny.value) + MsgDelegateFeedConsent_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/slashing/msgs/MsgUnjail.ts b/src/core/slashing/msgs/MsgUnjail.ts index 8390245c2..a2e5a2ae4 100644 --- a/src/core/slashing/msgs/MsgUnjail.ts +++ b/src/core/slashing/msgs/MsgUnjail.ts @@ -69,17 +69,15 @@ export class MsgUnjail extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.slashing.v1beta1.MsgUnjail', - value: MsgUnjail_pb.encode(this.toProto()).finish(), + value: MsgUnjail_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgUnjail { - _; - return MsgUnjail.fromProto(MsgUnjail_pb.decode(msgAny.value)); + public static unpackAny(msgAny: Any, isClassic?: boolean): MsgUnjail { + return MsgUnjail.fromProto(MsgUnjail_pb.decode(msgAny.value), isClassic); } } diff --git a/src/core/staking/msgs/MsgBeginRedelegate.ts b/src/core/staking/msgs/MsgBeginRedelegate.ts index ee3f1c686..577b2cf44 100644 --- a/src/core/staking/msgs/MsgBeginRedelegate.ts +++ b/src/core/staking/msgs/MsgBeginRedelegate.ts @@ -137,18 +137,20 @@ export class MsgBeginRedelegate extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.staking.v1beta1.MsgBeginRedelegate', - value: MsgBeginRedelegate_pb.encode(this.toProto()).finish(), + value: MsgBeginRedelegate_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgBeginRedelegate { - _; + public static unpackAny( + msgAny: Any, + isClassic?: boolean + ): MsgBeginRedelegate { return MsgBeginRedelegate.fromProto( - MsgBeginRedelegate_pb.decode(msgAny.value) + MsgBeginRedelegate_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/staking/msgs/MsgCreateValidator.ts b/src/core/staking/msgs/MsgCreateValidator.ts index 9ec12a9be..1725829ad 100644 --- a/src/core/staking/msgs/MsgCreateValidator.ts +++ b/src/core/staking/msgs/MsgCreateValidator.ts @@ -183,18 +183,20 @@ export class MsgCreateValidator extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.staking.v1beta1.MsgCreateValidator', - value: MsgCreateValidator_pb.encode(this.toProto()).finish(), + value: MsgCreateValidator_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgCreateValidator { - _; + public static unpackAny( + msgAny: Any, + isClassic?: boolean + ): MsgCreateValidator { return MsgCreateValidator.fromProto( - MsgCreateValidator_pb.decode(msgAny.value) + MsgCreateValidator_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/staking/msgs/MsgDelegate.ts b/src/core/staking/msgs/MsgDelegate.ts index 1aabab1b1..2077e825f 100644 --- a/src/core/staking/msgs/MsgDelegate.ts +++ b/src/core/staking/msgs/MsgDelegate.ts @@ -71,17 +71,18 @@ export class MsgDelegate extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.staking.v1beta1.MsgDelegate', - value: MsgDelegate_pb.encode(this.toProto()).finish(), + value: MsgDelegate_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgDelegate { - _; - return MsgDelegate.fromProto(MsgDelegate_pb.decode(msgAny.value)); + public static unpackAny(msgAny: Any, isClassic?: boolean): MsgDelegate { + return MsgDelegate.fromProto( + MsgDelegate_pb.decode(msgAny.value), + isClassic + ); } public static fromData(data: MsgDelegate.Data, _?: boolean): MsgDelegate { diff --git a/src/core/staking/msgs/MsgEditValidator.ts b/src/core/staking/msgs/MsgEditValidator.ts index ba28b8e30..e1cba7b73 100644 --- a/src/core/staking/msgs/MsgEditValidator.ts +++ b/src/core/staking/msgs/MsgEditValidator.ts @@ -113,17 +113,18 @@ export class MsgEditValidator extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.staking.v1beta1.MsgEditValidator', - value: MsgEditValidator_pb.encode(this.toProto()).finish(), + value: MsgEditValidator_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgEditValidator { - _; - return MsgEditValidator.fromProto(MsgEditValidator_pb.decode(msgAny.value)); + public static unpackAny(msgAny: Any, isClassic?: boolean): MsgEditValidator { + return MsgEditValidator.fromProto( + MsgEditValidator_pb.decode(msgAny.value), + isClassic + ); } public static fromData( diff --git a/src/core/staking/msgs/MsgUndelegate.ts b/src/core/staking/msgs/MsgUndelegate.ts index ff4441ca5..fac491639 100644 --- a/src/core/staking/msgs/MsgUndelegate.ts +++ b/src/core/staking/msgs/MsgUndelegate.ts @@ -78,17 +78,18 @@ export class MsgUndelegate extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.staking.v1beta1.MsgUndelegate', - value: MsgUndelegate_pb.encode(this.toProto()).finish(), + value: MsgUndelegate_pb.encode(this.toProto(isClassic)).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): MsgUndelegate { - _; - return MsgUndelegate.fromProto(MsgUndelegate_pb.decode(msgAny.value)); + public static unpackAny(msgAny: Any, isClassic?: boolean): MsgUndelegate { + return MsgUndelegate.fromProto( + MsgUndelegate_pb.decode(msgAny.value), + isClassic + ); } public static fromData(data: MsgUndelegate.Data, _?: boolean): MsgUndelegate { diff --git a/src/core/upgrade/proposals/CancelSoftwareUpgradeProposal.ts b/src/core/upgrade/proposals/CancelSoftwareUpgradeProposal.ts index ffdb8daa6..78b6c9c2e 100644 --- a/src/core/upgrade/proposals/CancelSoftwareUpgradeProposal.ts +++ b/src/core/upgrade/proposals/CancelSoftwareUpgradeProposal.ts @@ -79,21 +79,22 @@ export class CancelSoftwareUpgradeProposal extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal', - value: CancelSoftwareUpgradeProposal_pb.encode(this.toProto()).finish(), + value: CancelSoftwareUpgradeProposal_pb.encode( + this.toProto(isClassic) + ).finish(), }); } public static unpackAny( msgAny: Any, - _?: boolean + isClassic?: boolean ): CancelSoftwareUpgradeProposal { - _; return CancelSoftwareUpgradeProposal.fromProto( - CancelSoftwareUpgradeProposal_pb.decode(msgAny.value) + CancelSoftwareUpgradeProposal_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/upgrade/proposals/SoftwareUpgradeProposal.ts b/src/core/upgrade/proposals/SoftwareUpgradeProposal.ts index 676bbb136..09d8faa31 100644 --- a/src/core/upgrade/proposals/SoftwareUpgradeProposal.ts +++ b/src/core/upgrade/proposals/SoftwareUpgradeProposal.ts @@ -100,18 +100,22 @@ export class SoftwareUpgradeProposal extends JSONSerializable< }); } - public packAny(_?: boolean): Any { - _; + public packAny(isClassic?: boolean): Any { return Any.fromPartial({ typeUrl: '/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal', - value: SoftwareUpgradeProposal_pb.encode(this.toProto()).finish(), + value: SoftwareUpgradeProposal_pb.encode( + this.toProto(isClassic) + ).finish(), }); } - public static unpackAny(msgAny: Any, _?: boolean): SoftwareUpgradeProposal { - _; + public static unpackAny( + msgAny: Any, + isClassic?: boolean + ): SoftwareUpgradeProposal { return SoftwareUpgradeProposal.fromProto( - SoftwareUpgradeProposal_pb.decode(msgAny.value) + SoftwareUpgradeProposal_pb.decode(msgAny.value), + isClassic ); } } diff --git a/src/core/wasm/msgs/MsgMigrateCode.ts b/src/core/wasm/msgs/MsgMigrateCode.ts index 51517b3e2..26cfcd534 100644 --- a/src/core/wasm/msgs/MsgMigrateCode.ts +++ b/src/core/wasm/msgs/MsgMigrateCode.ts @@ -82,7 +82,7 @@ export class MsgMigrateCode extends JSONSerializable< } return Any.fromPartial({ typeUrl: '/terra.wasm.v1beta1.MsgMigrateCode', - value: MsgMigrateCode_legacy_pb.encode(this.toProto()).finish(), + value: MsgMigrateCode_legacy_pb.encode(this.toProto(isClassic)).finish(), }); } @@ -91,7 +91,8 @@ export class MsgMigrateCode extends JSONSerializable< throw new Error('Not supported for the network'); } return MsgMigrateCode.fromProto( - MsgMigrateCode_legacy_pb.decode(msgAny.value) + MsgMigrateCode_legacy_pb.decode(msgAny.value), + isClassic ); } From e22e7d0a8591b9813ce7c438d0815c38ec9781b0 Mon Sep 17 00:00:00 2001 From: Geoff Lee <11830048+Vritra4@users.noreply.github.com> Date: Tue, 19 Jul 2022 13:53:38 +0900 Subject: [PATCH 2/2] fix typo --- src/core/gov/Vote.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/gov/Vote.ts b/src/core/gov/Vote.ts index 16ede3282..af9e6463f 100644 --- a/src/core/gov/Vote.ts +++ b/src/core/gov/Vote.ts @@ -16,7 +16,7 @@ export class Vote extends JSONSerializable { /** * @param proposal_id ID of proposal to vote on * @param voter voter's account address - * @param options one of voting options + * @param options voting options */ constructor( public proposal_id: number,