Skip to content

Commit a6e830d

Browse files
committed
Improve startBlock validation
1 parent 4032c83 commit a6e830d

File tree

1 file changed

+2
-5
lines changed
  • packages/cli/src/commands

1 file changed

+2
-5
lines changed

packages/cli/src/commands/add.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default class AddCommand extends Command {
8181

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

84-
let startBlock = startBlockFlag;
84+
let startBlock = parseInt(startBlockFlag ?? '').toString();
8585
let contractName = contractNameFlag;
8686

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

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

162160
try {
163161
if (isLocalHost) throw Error; // Triggers user prompting without waiting for Etherscan lookup to fail
164-
165162
contractName ||= await loadContractNameForAddress(network, address);
166163
} catch (error) {
167164
// not asking user to do prompt in test environment

0 commit comments

Comments
 (0)