Skip to content
5 changes: 5 additions & 0 deletions .changeset/heavy-socks-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphprotocol/graph-cli': patch
---

Fix `graph add` flag parameters parsing
6 changes: 2 additions & 4 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,7 +136,6 @@ export default class AddCommand extends Command {

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

startBlock ||= Number(await loadStartBlockForContract(network, address)).toString();
} catch (error) {
// we cannot ask user to do prompt in test environment
Expand All @@ -160,8 +159,7 @@ 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);
contractName ||= await loadContractNameForAddress(network, address);
} catch (error) {
// not asking user to do prompt in test environment
if (process.env.NODE_ENV !== 'test') {
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/tests/cli/add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe('Add command', () => {
'0x2E645469f354BB4F5c8a05B3b30A929361cf77eC',
'--contract-name',
'Gravatar',
'--start-block',
'6175244',
'--abi',
`${EXAMPLE_SUBGRAPH_PATH}/abis/Gravity.json`,
],
Expand Down
1 change: 1 addition & 0 deletions packages/cli/tests/cli/add/expected/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dataSources:
source:
address: "0x2E645469f354BB4F5c8a05B3b30A929361cf77eC"
abi: Gravatar
startBlock: 6175244
mapping:
kind: ethereum/events
apiVersion: 0.0.7
Expand Down
Loading