Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error when staking bond amount in chainspec is a bigint #1119

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions javascript/packages/orchestrator/src/chainSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const debug = require("debug")("zombie::chain-spec");
const JSONStream = require("JSONStream");

// track 1st staking as default;
let stakingBond: number | undefined;
let stakingBond: bigint | undefined;

export type KeyType = "session" | "aura" | "grandpa";

Expand Down Expand Up @@ -73,7 +73,7 @@ export function clearAuthorities(specPath: string) {

// Clear staking
if (runtimeConfig?.staking) {
stakingBond = runtimeConfig.staking.stakers[0][2];
stakingBond = BigInt(runtimeConfig.staking.stakers[0][2]);
runtimeConfig.staking.stakers = [];
runtimeConfig.staking.invulnerables = [];
runtimeConfig.staking.validatorCount = 0;
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function addBalances(specPath: string, nodes: Node[]) {
const balanceToAdd = stakingBond
? node.validator && node.balance > stakingBond
? node.balance
: stakingBond! + 1
: stakingBond! + BigInt(1)
: node.balance;
runtimeConfig.balances.balances.push([stash_key, balanceToAdd]);

Expand Down Expand Up @@ -206,7 +206,7 @@ export async function addStaking(specPath: string, node: Node) {
runtimeConfig.staking.stakers.push([
sr_stash.address,
sr_stash.address,
stakingBond || 1000000000000,
stakingBond || BigInt(1000000000000),
"Validator",
]);

Expand Down Expand Up @@ -354,7 +354,7 @@ export async function generateNominators(
// create account
const nom = await generateKeyFromSeed(`nom-${i}`);
// add to balances
const balanceToAdd = stakingBond! + 1;
const balanceToAdd = stakingBond! + BigInt(1);
runtimeConfig.balances.balances.push([nom.address, balanceToAdd]);
// random nominations
const count = crypto.randomInt(maxForRandom) % maxNominations;
Expand Down
2 changes: 1 addition & 1 deletion javascript/packages/orchestrator/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export interface Node {
name: string;
key?: string;
accounts?: any;
balance?: number;
balance?: bigint;
command?: string;
commandWithArgs?: string;
fullCommand?: string;
Expand Down