Skip to content

Commit 1245db1

Browse files
committed
handle ESC in proxy confirmation without crashing
1 parent 9e41ce5 commit 1245db1

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

packages/cli/src/commands/add.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,9 @@ export default class AddCommand extends Command {
125125
),
126126
);
127127
if (impl) {
128-
const useImplementation = await prompt.confirm(
129-
`Proxy contract detected. Use current implementation contract ABI at ${impl}?`,
130-
true,
131-
);
128+
const useImplementation = await prompt
129+
.confirm(`Proxy contract detected. Use implementation contract ABI at ${impl}?`, true)
130+
.catch(() => false);
132131

133132
if (useImplementation) {
134133
implAddress = impl;

packages/cli/src/commands/init.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -669,21 +669,24 @@ async function processInitForm(
669669
);
670670
initDebugger.extend('processInitForm')("proxyImplementation: '%s'", impl);
671671
if (impl) {
672-
const useImplementation = await prompt.confirm(
673-
`Proxy contract detected. Use current implementation contract ABI at ${impl}?`,
674-
true,
675-
);
676-
677-
if (useImplementation) {
678-
implAddress = impl;
679-
abiFromApi = await retryWithPrompt(() =>
680-
withSpinner(
681-
'Fetching implementation contract ABI...',
682-
'Failed to fetch implementation ABI',
683-
'Warning fetching implementation ABI',
684-
() => contractService.getABI(protocolInstance.getABI(), network.id, implAddress!),
685-
),
672+
try {
673+
const useImplementation = await prompt.confirm(
674+
`Proxy contract detected. Use implementation contract ABI at ${impl}?`,
675+
true,
686676
);
677+
if (useImplementation) {
678+
implAddress = impl;
679+
abiFromApi = await retryWithPrompt(() =>
680+
withSpinner(
681+
'Fetching implementation contract ABI...',
682+
'Failed to fetch implementation ABI',
683+
'Warning fetching implementation ABI',
684+
() => contractService.getABI(protocolInstance.getABI(), network.id, implAddress!),
685+
),
686+
);
687+
}
688+
} catch (error) {
689+
this.error(`Error confirming proxy implementation: ${error.message}`, { exit: 1 });
687690
}
688691
}
689692
}

0 commit comments

Comments
 (0)