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

Sourcify chains json #1223

Merged
merged 17 commits into from
Nov 29, 2023
Merged

Sourcify chains json #1223

merged 17 commits into from
Nov 29, 2023

Conversation

kuzdogan
Copy link
Member

@kuzdogan kuzdogan commented Nov 28, 2023

Moves the chains list object in sourcify-chains.ts to a JSON called sourcify-chains.json.

The new sourcify-chains.json file also contains the etherscanApi information, which eventually will be stored in the SourcifyChain instance.

Here's a full example of a chain entry:

{
  // the chain id
  "1": {
    "sourcifyName": "Ethereum Mainnet", // required
    "supported": true, // required

    // optional
    "etherscanApi": {
      "apiURL": "https://api.etherscan.io",
      "apiKeyEnvName": "ETHERSCAN_API_KEY" // the name of the environment variable holding the api key
    },

    // optional
    "fetchContractCreationTxUsing": {
      // How to find the transaction hash that created the contract
      "etherscanApi": true, // if supported by the new etherscan api. Need to provide the etherscanApi config
      "blockscoutApi": {
        // blockscout v2 instances have an api endpoint for this
        "url": "https://gnosis.blockscout.com/"
      },
      "blockscoutScrape": {
        // scraping from old (server-side rendered) blockscout ui
        "url": "https://scan.pulsechain.com/"
      },
      "avalancheApi": true // avalanche subnets at glacier-api.avax.network have an api endpoint for this
    },

    // optional
    // Leave empty to use the default rpcs in chains.json i.e. chainid.network/chains.json
    "rpc": [
      "https://rpc.sepolia.io", // can be a simple url
      {
        "type": "FetchRequest", // ethers.js FetchRequest for header authenticated RPCs
        "url": "https://rpc.mainnet.ethpandaops.io",
        "headers": [
          {
            "headerName": "CF-Access-Client-Id",
            "headerEnvName": "CF_ACCESS_CLIENT_ID"
          },
          {
            "headerName": "CF-Access-Client-Secret",
            "headerEnvName": "CF_ACCESS_CLIENT_SECRET"
          }
        ]
      },
      {
        "type": "Alchemy", // Alchemy RPCs
        "url": "https://eth-mainnet.alchemyapi.io/v2/{ALCHEMY_API_KEY}",
        "apiKeyEnvName": "ALCHEMY_API_KEY"
      },
      {
        "type": "Infura", // Infura RPCs
        "url": "https://palm-mainnet.infura.io/v3/{INFURA_API_KEY}",
        "apiKeyEnvName": "INFURA_API_KEY"
      }
    ]
  }
}

This allows users to replace the JSON file directly or mounting an alternative file when running in a container, if they want to support different chains for their own instance.

TODO:

View in Huly HI-558

@marcocastignoli
Copy link
Member

💯 but the sourcify-chains.json file should be configurable without git conflicts. We could do something like this:

image

and at deployment: cp sourcify-chains.example.json sourcify-chains.json

@kuzdogan
Copy link
Member Author

💯 but the sourcify-chains.json file should be configurable without git conflicts. We could do something like this:

image and at deployment: `cp sourcify-chains.example.json sourcify-chains.json`

Not sure if I understand. Git conflicts for new chain PRs? How does the example solve that?

@kuzdogan
Copy link
Member Author

Done. Can you have a final look? @marcocastignoli

@kuzdogan kuzdogan merged commit 984086f into staging Nov 29, 2023
4 checks passed
@kuzdogan kuzdogan deleted the sourcify-chains-json branch December 19, 2023 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants