Skip to content

Commit

Permalink
Check stash status in withdrawUnbondedAction
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhit committed Jun 22, 2023
1 parent e0a8672 commit 7bb478a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/cc-cli/src/commands/withdrawUnbonded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
export function makeWithdrawUnbondedCommand() {
const cmd = new Command("withdraw-unbonded");
cmd.description("Withdraw unbonded funds from a stash account");
cmd.option("-a, --amount [amount]", "Amount to withdraw");
cmd.action(withdrawUnbondedAction);
return cmd;
}
Expand All @@ -20,7 +19,14 @@ async function withdrawUnbondedAction(options: OptionValues) {
const controllerSeed = await getControllerSeedFromEnvOrPrompt();
const controller = initKeyringPair(controllerSeed);

const status = await getStatus(controller.address, api);
const controllerStatus = await getStatus(controller.address, api);

if (!controllerStatus.stash) {
console.error(`Cannot withdraw, ${controller.address} is not staked`);
process.exit(1);
}

const status = await getStatus(controllerStatus.stash, api);
requireStatus(
status,
"canWithdraw",
Expand Down

0 comments on commit 7bb478a

Please sign in to comment.