Change votingPower field to bigint type

This commit is contained in:
Simon Warta
2022-06-29 10:30:45 +02:00
parent 03835af2d4
commit f7c3ef7c7f
7 changed files with 24 additions and 20 deletions
@@ -44,7 +44,7 @@ describe("Adaptor Responses", () => {
});
expect(validator).toEqual({
address: fromHex("A03DC128D38DB0BC5F18AE1872F1CB2E1FD41157"),
votingPower: 169980,
votingPower: BigInt(169980),
pubkey: {
algorithm: "ed25519",
data: fromBase64("2BX6Zuj8RmdJAkD1BAg6KB0v04liyM7jBdwOGIb9F9Q="),
@@ -72,7 +72,7 @@ describe("Adaptor Responses", () => {
algorithm: "ed25519",
data: fromBase64("0kNlxBMpm+5WtfHIG1xsWatOXTKPLtmSqn3EiEIDZeI="),
},
votingPower: 11418237,
votingPower: BigInt(11418237),
});
});
@@ -93,7 +93,7 @@ describe("Adaptor Responses", () => {
algorithm: "ed25519",
data: fromBase64("HjSC7VkhKih6xMhudlqfaFE8ZZnP8RKJPv4iqR7RhcE="),
},
votingPower: 0,
votingPower: BigInt(0),
});
});
});
@@ -116,7 +116,7 @@ describe("Adaptor Responses", () => {
algorithm: "ed25519",
data: fromBase64("0kNlxBMpm+5WtfHIG1xsWatOXTKPLtmSqn3EiEIDZeI="),
},
votingPower: 11228980,
votingPower: BigInt(11228980),
proposerPriority: 62870960,
});
});
@@ -4,7 +4,7 @@ import { JsonRpcSuccessResponse } from "@cosmjs/json-rpc";
import { assert } from "@cosmjs/utils";
import { DateWithNanoseconds, fromRfc3339WithNanoseconds } from "../../dates";
import { apiToSmallInt } from "../../inthelpers";
import { apiToBigInt, apiToSmallInt } from "../../inthelpers";
import { SubscriptionEvent } from "../../rpcclients";
import { BlockIdFlag, CommitSignature, ValidatorPubkey } from "../../types";
import {
@@ -279,7 +279,7 @@ interface RpcValidatorUpdate {
export function decodeValidatorUpdate(data: RpcValidatorUpdate): responses.ValidatorUpdate {
return {
pubkey: decodePubkey(assertObject(data.pub_key)),
votingPower: apiToSmallInt(data.power ?? 0),
votingPower: apiToBigInt(data.power ?? "0"),
};
}
@@ -528,7 +528,7 @@ export function decodeValidatorGenesis(data: RpcValidatorGenesis): responses.Val
return {
address: fromHex(assertNotEmpty(data.address)),
pubkey: decodePubkey(assertObject(data.pub_key)),
votingPower: apiToSmallInt(assertNotEmpty(data.power)),
votingPower: apiToBigInt(assertNotEmpty(data.power)),
};
}
@@ -571,7 +571,7 @@ interface RpcValidatorInfo {
export function decodeValidatorInfo(data: RpcValidatorInfo): responses.Validator {
return {
pubkey: decodePubkey(assertObject(data.pub_key)),
votingPower: apiToSmallInt(assertNotEmpty(data.voting_power)),
votingPower: apiToBigInt(assertNotEmpty(data.voting_power)),
address: fromHex(assertNotEmpty(data.address)),
proposerPriority: data.proposer_priority ? apiToSmallInt(data.proposer_priority) : undefined,
};
@@ -352,13 +352,13 @@ export interface SyncInfo {
export interface Validator {
readonly address: Uint8Array;
readonly pubkey?: ValidatorPubkey;
readonly votingPower: number;
readonly votingPower: bigint;
readonly proposerPriority?: number;
}
export interface ValidatorUpdate {
readonly pubkey: ValidatorPubkey;
readonly votingPower: number;
readonly votingPower: bigint;
}
export interface ConsensusParams {
@@ -44,7 +44,7 @@ describe("Adaptor Responses", () => {
});
expect(validator).toEqual({
address: fromHex("A03DC128D38DB0BC5F18AE1872F1CB2E1FD41157"),
votingPower: 169980,
votingPower: BigInt(169980),
pubkey: {
algorithm: "ed25519",
data: fromBase64("2BX6Zuj8RmdJAkD1BAg6KB0v04liyM7jBdwOGIb9F9Q="),
@@ -72,7 +72,7 @@ describe("Adaptor Responses", () => {
algorithm: "ed25519",
data: fromBase64("0kNlxBMpm+5WtfHIG1xsWatOXTKPLtmSqn3EiEIDZeI="),
},
votingPower: 11418237,
votingPower: BigInt(11418237),
});
});
@@ -93,7 +93,7 @@ describe("Adaptor Responses", () => {
algorithm: "ed25519",
data: fromBase64("HjSC7VkhKih6xMhudlqfaFE8ZZnP8RKJPv4iqR7RhcE="),
},
votingPower: 0,
votingPower: BigInt(0),
});
});
});
@@ -116,7 +116,7 @@ describe("Adaptor Responses", () => {
algorithm: "ed25519",
data: fromBase64("0kNlxBMpm+5WtfHIG1xsWatOXTKPLtmSqn3EiEIDZeI="),
},
votingPower: 11228980,
votingPower: BigInt(11228980),
proposerPriority: 62870960,
});
});
@@ -4,7 +4,7 @@ import { JsonRpcSuccessResponse } from "@cosmjs/json-rpc";
import { assert } from "@cosmjs/utils";
import { DateWithNanoseconds, fromRfc3339WithNanoseconds } from "../../dates";
import { apiToSmallInt } from "../../inthelpers";
import { apiToBigInt, apiToSmallInt } from "../../inthelpers";
import { SubscriptionEvent } from "../../rpcclients";
import { BlockIdFlag, CommitSignature, ValidatorPubkey } from "../../types";
import {
@@ -280,7 +280,7 @@ interface RpcValidatorUpdate {
export function decodeValidatorUpdate(data: RpcValidatorUpdate): responses.ValidatorUpdate {
return {
pubkey: decodePubkey(assertObject(data.pub_key)),
votingPower: apiToSmallInt(data.power ?? 0),
votingPower: apiToBigInt(data.power ?? "0"),
};
}
@@ -529,7 +529,7 @@ export function decodeValidatorGenesis(data: RpcValidatorGenesis): responses.Val
return {
address: fromHex(assertNotEmpty(data.address)),
pubkey: decodePubkey(assertObject(data.pub_key)),
votingPower: apiToSmallInt(assertNotEmpty(data.power)),
votingPower: apiToBigInt(assertNotEmpty(data.power)),
};
}
@@ -572,7 +572,7 @@ interface RpcValidatorInfo {
export function decodeValidatorInfo(data: RpcValidatorInfo): responses.Validator {
return {
pubkey: decodePubkey(assertObject(data.pub_key)),
votingPower: apiToSmallInt(assertNotEmpty(data.voting_power)),
votingPower: apiToBigInt(assertNotEmpty(data.voting_power)),
address: fromHex(assertNotEmpty(data.address)),
proposerPriority: data.proposer_priority ? apiToSmallInt(data.proposer_priority) : undefined,
};
@@ -357,13 +357,13 @@ export interface SyncInfo {
export interface Validator {
readonly address: Uint8Array;
readonly pubkey?: ValidatorPubkey;
readonly votingPower: number;
readonly votingPower: bigint;
readonly proposerPriority?: number;
}
export interface ValidatorUpdate {
readonly pubkey: ValidatorPubkey;
readonly votingPower: number;
readonly votingPower: bigint;
}
export interface ConsensusParams {