Skip to content

Commit

Permalink
Minor improvement to wallet package
Browse files Browse the repository at this point in the history
  • Loading branch information
eternauta1337 committed Mar 15, 2024
1 parent 459dcdc commit a208891
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/ethernaut-wallet/src/tasks/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ const task = require('../scopes/wallet')
pk,
}

if (
signers.activeSigner === undefined ||
!signers[signers.activeSigner]
) {
signers.activeSigner = alias
}

if (signers.activeSigner === 'none') {
signers.activeSigner = alias
}
Expand Down
13 changes: 13 additions & 0 deletions packages/ethernaut-wallet/src/tasks/current.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ require('../scopes/wallet')
.setAction(async () => {
try {
const signers = storage.readSigners()
console.log(signers)
if (Object.keys(signers).length < 2) {
throw new Error(
'No wallets found. Please use the create task to add one.',
)
}

const signer = signers[signers.activeSigner]
if (!signer) {
throw new Error(
'No active wallet found. Please use the activate task to set one.',
)
}

return output.resultBox(
`The current wallet is "${signers.activeSigner}" with address ${signer.address}`,
)
Expand Down

0 comments on commit a208891

Please sign in to comment.