Skip to content

Commit

Permalink
Merge pull request #319 from terra-money/fix/packing-msgs
Browse files Browse the repository at this point in the history
use isClassic flag inside of packAny() and unpackAny()
  • Loading branch information
Vritra4 authored Jul 19, 2022
2 parents d15fda3 + e22e7d0 commit 0739172
Show file tree
Hide file tree
Showing 39 changed files with 246 additions and 595 deletions.
13 changes: 7 additions & 6 deletions src/core/auth/BaseAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/core/auth/ContinuousVestingAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
}

Expand All @@ -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
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/core/auth/DelayedVestingAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
}

Expand All @@ -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
);
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/core/auth/LazyGradedVestingAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/core/auth/PeriodicVestingAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
}

Expand All @@ -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
);
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/core/authz/authorizations/GenericAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/core/authz/authorizations/SendAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/core/bank/msgs/MsgMultiSend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/core/bank/msgs/MsgSend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
29 changes: 20 additions & 9 deletions src/core/crisis/MsgVerifyInvariant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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
);
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/core/distribution/msgs/MsgFundCommunityPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/core/distribution/msgs/MsgSetWithdrawAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/core/distribution/msgs/MsgWithdrawDelegatorReward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/core/distribution/msgs/MsgWithdrawValidatorCommission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
Expand Down
Loading

0 comments on commit 0739172

Please sign in to comment.