Skip to content

Commit

Permalink
Rollback ABCIParams and make params optional for MsgUpdateConsensusPa…
Browse files Browse the repository at this point in the history
…rams
  • Loading branch information
joon9823 committed May 14, 2024
1 parent 3ba32c3 commit 2f8f0c7
Show file tree
Hide file tree
Showing 4 changed files with 45 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.1.50",
"version": "0.1.51",
"description": "The JavaScript SDK for Initia",
"license": "MIT",
"author": "InitiaLabs",
Expand Down
28 changes: 10 additions & 18 deletions src/core/consensus/ABCIParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
}

Expand All @@ -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;
Expand Down
64 changes: 32 additions & 32 deletions src/core/consensus/msgs/MsgUpdateConsensusParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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
);
}

Expand All @@ -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(),
},
};
}
Expand All @@ -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
);
}

Expand All @@ -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(),
};
}

Expand All @@ -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(),
});
}

Expand All @@ -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;
Expand Down

0 comments on commit 2f8f0c7

Please sign in to comment.