Skip to content

Passing SPKG instead of contract address to init leads to registry unable to fetch contract info #1898

Open
@0237h

Description

@0237h

Which packages are impacted by your issue?

@graphprotocol/graph-cli

Describe the issue

When providing all the arguments to the CLI for init, this line checks if a contract address or an spkg is provided:

if ((fromContract || spkgPath) && protocol && subgraphName && directory && network && node) {

The registry then tries to use the contract address value to fetch the ABI info.

abi = await contractService.getABI(ABI, network, fromContract!);

But if a SPKG was supplied instead, fromContract is then undefined leading to the contract service's failure to fetch the info.

Logs

oclif:config runCommand init [ 'Test', '.', '--spkg=test.spkg', '--protocol=ethereum', '--network=mainnet', '--node=http://localhost' ] +0ms
oclif:config:ts-path Skipping typescript path lookup for graph-tooling/packages/cli because NODE_ENV is NOT "test" or "development"  oclif:config start prerun hook +443ms
oclif:config prerun hook done +0ms
oclif:graph:init init version: @oclif/[email protected] argv: [ 'Test', '.', '--spkg=test.spkg', '--protocol=ethereum', '--network=mainnet', '--node=http://localhost' ] +0ms
oclif:config start preparse hook +0ms
oclif:config preparse hook done +0ms
graph-cli:commands:init Flags: {
graph-cli:commands:init   protocol: 'ethereum',
graph-cli:commands:init   node: 'http://localhost',
graph-cli:commands:init   'skip-install': false,
graph-cli:commands:init   'skip-git': false,
graph-cli:commands:init   spkg: 'test.spkg',
graph-cli:commands:init   network: 'mainnet',
graph-cli:commands:init   ipfs: 'https://api.thegraph.com/ipfs/api/v0'
graph-cli:commands:init } +0ms
graph-cli:registry loaded 115 networks from latest registry +0ms
graph-cli:protocol Initializing protocol with datasource 'ethereum' +0ms
graph-cli:protocol Initializing protocol ethereum +0ms
graph-cli:contract-service Failed to fetch from contract API: [200] OK (https://mainnet.abi.pinax.network/api?module=contract&action=getabi&address=undefined)
graph-cli:contract-service { status: '0', message: 'NOTOK', result: 'Invalid Address format' } +0ms
graph-cli:contract-service Failed to fetch from https://mainnet.abi.pinax.network/api: Error: NOTOK - Invalid Address format +0ms
graph-cli:contract-service Failed to fetch from contract API: [200] OK (https://eth.blockscout.com/api?module=contract&action=getabi&address=undefined)
graph-cli:contract-service { message: 'Invalid address hash', result: null, status: '0' } +201ms
graph-cli:contract-service Failed to fetch from https://eth.blockscout.com/api: Error: Invalid address hash -  +0ms
graph-cli:contract-service Failed to fetch from contract API: [200] OK (https://api.routescan.io/v2/network/mainnet/evm/1/etherscan/api?module=contract&action=getabi&address=undefined)
graph-cli:contract-service {
graph-cli:contract-service   status: '0',
graph-cli:contract-service   message: 'NOTOK',
graph-cli:contract-service   result: 'Invalid querystring request'
graph-cli:contract-service } +183ms
graph-cli:contract-service Failed to fetch from https://api.routescan.io/v2/network/mainnet/evm/1/etherscan/api: Error: NOTOK - Invalid querystring request +0ms

Notice address=undefined in the URLs.

Reproduction

Github repo

Steps to Reproduce the Bug or Issue

  1. Have an spkg file (e.g. test.spkg)
  2. Run graph init Test ./ --spkg=test.spkg --network=mainnet --protocol=ethereum --node=http://localhost
  3. Nothing happens (silent error), run with DEBUG=* to see the logs.

Expected behavior

ABI should be fetched in case of using SPKG.

Screenshots or Videos

No response

Platform

  • OS: Linux
  • NodeJS: 22.13.0
  • @graphprotocol/* version(s): 0.93.3

Subgraph Manifest

No response

Subgraph GraphQL Schema

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    🔖 Next

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions