Skip to content

Commit

Permalink
fix: seed was passed instead of address
Browse files Browse the repository at this point in the history
  • Loading branch information
pLabarta committed Aug 4, 2023
1 parent e06ceba commit 71ef444
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
9 changes: 3 additions & 6 deletions scripts/cc-cli/src/commands/distributeRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ async function distributeRewardsAction(options: OptionValues) {

// Any account can call the distribute_rewards extrinsic
const callerSeed = await getCallerSeedFromEnvOrPrompt();
const caller = initKeyringPair(callerSeed);
const distributeTx = api.tx.staking.payoutStakers(validator, era);

await requireEnoughFundsToSend(distributeTx, callerSeed, api);
await requireEnoughFundsToSend(distributeTx, caller.address, api);

const result = await signSendAndWatch(
distributeTx,
api,
initKeyringPair(callerSeed)
);
const result = await signSendAndWatch(distributeTx, api, caller);

console.log(result.info);
process.exit(0);
Expand Down
2 changes: 1 addition & 1 deletion scripts/cc-cli/src/commands/setKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function setKeysAction(options: OptionValues) {

const tx = api.tx.session.setKeys(keys, "");

await requireEnoughFundsToSend(tx, controllerSeed, api);
await requireEnoughFundsToSend(tx, controller.address, api);

const result = await signSendAndWatch(tx, api, controller);

Expand Down
11 changes: 5 additions & 6 deletions scripts/cc-cli/src/commands/unbond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ async function unbondAction(options: OptionValues) {

// Build account
const controllerSeed = await getControllerSeedFromEnvOrPrompt();
const controllerKeyring = initKeyringPair(controllerSeed);
const controllerAddress = controllerKeyring.address;
const controller = initKeyringPair(controllerSeed);

const controllerStatus = await getValidatorStatus(controllerAddress, api);
const controllerStatus = await getValidatorStatus(controller.address, api);
if (!controllerStatus.stash) {
console.error(
`Cannot unbond, ${controllerAddress} is not a controller account`
`Cannot unbond, ${controller.address} is not a controller account`
);
process.exit(1);
}
Expand All @@ -46,9 +45,9 @@ async function unbondAction(options: OptionValues) {

// Unbond transaction
const tx = api.tx.staking.unbond(amount.toString());
await requireEnoughFundsToSend(tx, controllerAddress, api);
await requireEnoughFundsToSend(tx, controller.address, api);

const result = await signSendAndWatch(tx, api, controllerKeyring);
const result = await signSendAndWatch(tx, api, controller);

console.log(result.info);
process.exit(0);
Expand Down

0 comments on commit 71ef444

Please sign in to comment.