From 2f8f0c76f2f47c1ac876d197ff3d4f810370b135 Mon Sep 17 00:00:00 2001 From: joon9823 Date: Wed, 15 May 2024 03:40:43 +0900 Subject: [PATCH] Rollback ABCIParams and make params optional for MsgUpdateConsensusParams --- package-lock.json | 4 +- package.json | 2 +- src/core/consensus/ABCIParams.ts | 28 +++----- .../msgs/MsgUpdateConsensusParams.ts | 64 +++++++++---------- 4 files changed, 45 insertions(+), 53 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3c12179..e0db779 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@initia/initia.js", - "version": "0.1.50", + "version": "0.1.51", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@initia/initia.js", - "version": "0.1.50", + "version": "0.1.51", "license": "MIT", "dependencies": { "@initia/initia.proto": "^0.1.33", diff --git a/package.json b/package.json index 98f2b11..30f98f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@initia/initia.js", - "version": "0.1.50", + "version": "0.1.51", "description": "The JavaScript SDK for Initia", "license": "MIT", "author": "InitiaLabs", diff --git a/src/core/consensus/ABCIParams.ts b/src/core/consensus/ABCIParams.ts index cace728..9054ec8 100644 --- a/src/core/consensus/ABCIParams.ts +++ b/src/core/consensus/ABCIParams.ts @@ -10,37 +10,29 @@ export class ABCIParams extends JSONSerializable< /** * @param vote_extensions_enable_height */ - constructor(public vote_extensions_enable_height?: number) { + constructor(public vote_extensions_enable_height: number) { super(); } public static fromAmino(data: ABCIParams.Amino): ABCIParams { - return new ABCIParams( - data.vote_extensions_enable_height - ? Number.parseInt(data.vote_extensions_enable_height) - : undefined - ); + return new ABCIParams(Number.parseInt(data.vote_extensions_enable_height)); } public toAmino(): ABCIParams.Amino { return { vote_extensions_enable_height: - this.vote_extensions_enable_height?.toString(), + this.vote_extensions_enable_height.toString(), }; } public static fromData(data: ABCIParams.Data): ABCIParams { - return new ABCIParams( - data.vote_extensions_enable_height - ? Number.parseInt(data.vote_extensions_enable_height) - : undefined - ); + return new ABCIParams(Number.parseInt(data.vote_extensions_enable_height)); } public toData(): ABCIParams.Data { return { vote_extensions_enable_height: - this.vote_extensions_enable_height?.toString(), + this.vote_extensions_enable_height.toString(), }; } @@ -50,20 +42,20 @@ export class ABCIParams extends JSONSerializable< public toProto(): ABCIParams.Proto { return ABCIParams_pb.fromPartial({ - voteExtensionsEnableHeight: this.vote_extensions_enable_height - ? Long.fromNumber(this.vote_extensions_enable_height) - : undefined, + voteExtensionsEnableHeight: Long.fromNumber( + this.vote_extensions_enable_height + ), }); } } export namespace ABCIParams { export interface Amino { - vote_extensions_enable_height?: string; + vote_extensions_enable_height: string; } export interface Data { - vote_extensions_enable_height?: string; + vote_extensions_enable_height: string; } export type Proto = ABCIParams_pb; diff --git a/src/core/consensus/msgs/MsgUpdateConsensusParams.ts b/src/core/consensus/msgs/MsgUpdateConsensusParams.ts index 811bd5e..0888ac8 100644 --- a/src/core/consensus/msgs/MsgUpdateConsensusParams.ts +++ b/src/core/consensus/msgs/MsgUpdateConsensusParams.ts @@ -21,10 +21,10 @@ export class MsgUpdateConsensusParams extends JSONSerializable< */ constructor( public authority: AccAddress, - public block: BlockParams, - public evidence: EvidenceParams, - public validator: ValidatorParams, - public abci: ABCIParams + public block?: BlockParams, + public evidence?: EvidenceParams, + public validator?: ValidatorParams, + public abci?: ABCIParams ) { super(); } @@ -37,10 +37,10 @@ export class MsgUpdateConsensusParams extends JSONSerializable< } = data; return new MsgUpdateConsensusParams( authority, - BlockParams.fromAmino(block), - EvidenceParams.fromAmino(evidence), - ValidatorParams.fromAmino(validator), - ABCIParams.fromAmino(abci) + block ? BlockParams.fromAmino(block) : undefined, + evidence ? EvidenceParams.fromAmino(evidence) : undefined, + validator ? ValidatorParams.fromAmino(validator) : undefined, + abci ? ABCIParams.fromAmino(abci) : undefined ); } @@ -50,10 +50,10 @@ export class MsgUpdateConsensusParams extends JSONSerializable< type: 'cosmos-sdk/x/consensus/MsgUpdateParams', value: { authority, - block: block.toAmino(), - evidence: evidence.toAmino(), - validator: validator.toAmino(), - abci: abci.toAmino(), + block: block?.toAmino(), + evidence: evidence?.toAmino(), + validator: validator?.toAmino(), + abci: abci?.toAmino(), }, }; } @@ -64,10 +64,10 @@ export class MsgUpdateConsensusParams extends JSONSerializable< const { authority, block, evidence, validator, abci } = data; return new MsgUpdateConsensusParams( authority, - BlockParams.fromData(block), - EvidenceParams.fromData(evidence), - ValidatorParams.fromData(validator), - ABCIParams.fromData(abci) + block ? BlockParams.fromData(block) : undefined, + evidence ? EvidenceParams.fromData(evidence) : undefined, + validator ? ValidatorParams.fromData(validator) : undefined, + abci ? ABCIParams.fromData(abci) : undefined ); } @@ -76,10 +76,10 @@ export class MsgUpdateConsensusParams extends JSONSerializable< return { '@type': '/cosmos.consensus.v1.MsgUpdateParams', authority, - block: block.toData(), - evidence: evidence.toData(), - validator: validator.toData(), - abci: abci.toData(), + block: block?.toData(), + evidence: evidence?.toData(), + validator: validator?.toData(), + abci: abci?.toData(), }; } @@ -99,10 +99,10 @@ export class MsgUpdateConsensusParams extends JSONSerializable< const { authority, block, evidence, validator, abci } = this; return MsgUpdateParams_pb.fromPartial({ authority, - block: block.toProto(), - evidence: evidence.toProto(), - validator: validator.toProto(), - abci: abci.toProto(), + block: block?.toProto(), + evidence: evidence?.toProto(), + validator: validator?.toProto(), + abci: abci?.toProto(), }); } @@ -125,20 +125,20 @@ export namespace MsgUpdateConsensusParams { type: 'cosmos-sdk/x/consensus/MsgUpdateParams'; value: { authority: AccAddress; - block: BlockParams.Amino; - evidence: EvidenceParams.Amino; - validator: ValidatorParams.Amino; - abci: ABCIParams.Amino; + block?: BlockParams.Amino; + evidence?: EvidenceParams.Amino; + validator?: ValidatorParams.Amino; + abci?: ABCIParams.Amino; }; } export interface Data { '@type': '/cosmos.consensus.v1.MsgUpdateParams'; authority: AccAddress; - block: BlockParams.Data; - evidence: EvidenceParams.Data; - validator: ValidatorParams.Data; - abci: ABCIParams.Data; + block?: BlockParams.Data; + evidence?: EvidenceParams.Data; + validator?: ValidatorParams.Data; + abci?: ABCIParams.Data; } export type Proto = MsgUpdateParams_pb;