Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
0237h opened this issue Jan 10, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@0237h
Copy link
Collaborator

0237h commented Jan 10, 2025

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

@0237h 0237h added the bug Something isn't working label Jan 10, 2025
@0237h 0237h added this to Tooling Jan 10, 2025
@0237h 0237h moved this to 🔖 Next in Tooling Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 🔖 Next
Development

No branches or pull requests

1 participant