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

feat(cli,ironfish): Check if the wallet is locked before fetching accounts #5333

Conversation

rohanjadvani
Copy link
Member

Summary

Check the wallet is unlocked before returning account(s)

Testing Plan

❯ f wallet:balances -d ~/.ironfish-testnet
yarn run v1.22.21

Error: Wallet is locked. Unlock the wallet to fetch accounts
    at useAccount (/Users/rohan/git/ironfish/ironfish-cli/src/utils/account.ts:19:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at BalancesCommand.start (/Users/rohan/git/ironfish/ironfish-cli/src/commands/wallet/balances.ts:36:21)
    at BalancesCommand.run (/Users/rohan/git/ironfish/ironfish-cli/src/command.ts:92:14)
    at async BalancesCommand._run (/Users/rohan/git/ironfish/node_modules/@oclif/core/lib/command.js:301:22)
    at async Config.runCommand (/Users/rohan/git/ironfish/node_modules/@oclif/core/lib/config/config.js:424:25)
    at async run (/Users/rohan/git/ironfish/node_modules/@oclif/core/lib/main.js:95:16)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

❯ f wallet:unlock -d ~/.ironfish-testnet
yarn run v1.22.21

? Enter a passphrase to unlock the wallet: foobar
Unlocked the wallet for 300000ms
✨  Done in 3.24s.

❯ f wallet:balances -d ~/.ironfish-testnet
yarn run v1.22.21

Account: default
 Asset  Balance   
 ────── ──────────
 $IRON✓ 0.00000000
✨  Done in 1.34s.

❯ f wallet:lock -d ~/.ironfish-testnet
yarn run v1.22.21

Locked the wallet
✨  Done in 1.37s.

❯ f wallet:balances -d ~/.ironfish-testnet
yarn run v1.22.21

Error: Wallet is locked. Unlock the wallet to fetch accounts
    at useAccount (/Users/rohan/git/ironfish/ironfish-cli/src/utils/account.ts:19:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at BalancesCommand.start (/Users/rohan/git/ironfish/ironfish-cli/src/commands/wallet/balances.ts:36:21)
    at BalancesCommand.run (/Users/rohan/git/ironfish/ironfish-cli/src/command.ts:92:14)
    at async BalancesCommand._run (/Users/rohan/git/ironfish/node_modules/@oclif/core/lib/command.js:301:22)
    at async Config.runCommand (/Users/rohan/git/ironfish/node_modules/@oclif/core/lib/config/config.js:424:25)
    at async run (/Users/rohan/git/ironfish/node_modules/@oclif/core/lib/main.js:95:16)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference
)? If yes, link a
related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and label it with breaking-change-rpc or breaking-change-sdk.

[ ] Yes

@rohanjadvani rohanjadvani self-assigned this Aug 26, 2024
@rohanjadvani rohanjadvani requested a review from a team as a code owner August 26, 2024 19:58
@rohanjadvani rohanjadvani merged commit d1abc67 into staging Aug 26, 2024
11 checks passed
@rohanjadvani rohanjadvani deleted the rohan/ifl-2883-throw-error-when-trying-to-get-account-when-wallet-is-locked branch August 26, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants