Skip to content

Commit

Permalink
Improve startBlock validation
Browse files Browse the repository at this point in the history
  • Loading branch information
0237h committed Nov 29, 2024
1 parent 4032c83 commit a6e830d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/cli/src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class AddCommand extends Command {

if (isLocalHost) this.warn('`localhost` network detected, prompting user for inputs');

let startBlock = startBlockFlag;
let startBlock = parseInt(startBlockFlag ?? '').toString();
let contractName = contractNameFlag;

const entities = getEntities(manifest);
Expand Down Expand Up @@ -136,9 +136,7 @@ export default class AddCommand extends Command {

try {
if (isLocalHost) throw Error; // Triggers user prompting without waiting for Etherscan lookup to fail
if (startBlock === undefined) {
startBlock = Number(await loadStartBlockForContract(network, address)).toString();
}
startBlock ||= Number(await loadStartBlockForContract(network, address)).toString();
} catch (error) {
// we cannot ask user to do prompt in test environment
if (process.env.NODE_ENV !== 'test') {
Expand All @@ -161,7 +159,6 @@ export default class AddCommand extends Command {

try {
if (isLocalHost) throw Error; // Triggers user prompting without waiting for Etherscan lookup to fail

contractName ||= await loadContractNameForAddress(network, address);
} catch (error) {
// not asking user to do prompt in test environment
Expand Down

0 comments on commit a6e830d

Please sign in to comment.