Skip to content

Commit

Permalink
Do not exit interactive mode when no confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
eternauta1337 committed Mar 17, 2024
1 parent 5a62474 commit 0ce3cbb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/ethernaut-interact/src/internal/connect-signer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ module.exports = async function connectSigner(noConfirm) {
)

if (balance <= 0 && !noConfirm) {
await warnWithPrompt(
const response = await warnWithPrompt(
'WARNING! Signer balance is 0. You may not be able to send transactions.',
)
if (response === false) return
}

return signer
Expand Down
2 changes: 2 additions & 0 deletions packages/ethernaut-interact/src/internal/interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ module.exports = async function interact({
return await executeRead(contract, sig, params)
} else {
const signer = await connectSigner(noConfirm)
if (!signer) return

contract = contract.connect(signer)

return await executeWrite(
Expand Down
3 changes: 2 additions & 1 deletion packages/ethernaut-interact/src/internal/warn-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ module.exports = async function warnWithPrompt(message) {
type: 'confirm',
message: 'Continue anyway?',
})
if (!response) process.exit(0)
if (response === undefined) process.exit(0)
return response
}

0 comments on commit 0ce3cbb

Please sign in to comment.