Skip to content

RequestNetwork/payments-subgraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Request Payments subgraph

This repo contains the code and configuration for Request Payment subgraphs:

Mainnets:

Testnets:

It indexes Request's proxy smart-contracts for easy querying of payment data.

Smart-contract addresses can be found here:

Learn more about TheGraph

Contributing

# setup variables
cp .env.sample .env # don't forget to edit the WEB3_URL and, if required, the NETWORK variable

# install dependencies
yarn
# generate ABIs & subgraph manifests, and generate types
yarn prepare

# Run a local Graph Node
docker-compose up -d
# Run

Adding a new chain

This requires the @requestnetwork/smart-contracts package to be deployed.

export NETWORK=my-network

# update to latest version
yarn add --exact @requestnetwork/smart-contracts@next

# add new network
cat <<< $(jq '. + [env.NETWORK] | unique' cli/networks.json) > cli/networks.json

# update CI (update deployment targets with cli/networks.json)
NETWORKS=$(cat ./cli/networks.json) yq e -i '.jobs.deploy.strategy.matrix.chain |= env(NETWORKS)' .github/workflows/deploy.yaml

# create Github Environment (for CI) based on mainnet
yarn subgraph configure-ci $NETWORK

Manifests

The subgraphs manifests are automatically generated using the prepare script, which uses @requestnetwork/smart-contracts NPM package to get the smart-contracts addresses.

One manifest can refer to many different versions of proxies dealing with the same payment network. The first version found is not explicitely mentionned in generated files and data sources naming. Example; EthProxy implicitely refers to the version 0.1.0. Further versions are referenced in this format: EthProxy_0_2_0 for the contract EthProxy of abi version 0.2.0.

Note: The TransferWithReferenceAndFee event is configured twice. That is because the Conversion proxy makes an internal call to the ERC20 Fee proxy. Both TransferWithReferenceAndFee and TransferWithConversionAndReference need to be parsed for the Conversion smart-contract.

Build

export NETWORK=sepolia
yarn build

Deployment

Local

export NETWORK=sepolia
yarn create-local
yarn deploy-local

Hosted

All deployments are semi-automated through GitHub action. The first time a subgraph is deployed, it needs to be created on the Graph Node or on Subgraph Studio.

Graph Node locations:

When a PR is merged on main:

  • test chains are deployed immediately, without approval
  • mainnet chains require a manual approval in GitHub actions.

Important: Once a subgraph is deployed on Subgraph Studio, a manual action is required to publish it to the decentralized network. See the documentation for more information.

Check the deployed version

You can compare the code to the deployed version using one of these commands

# all
yarn subgraph compare
# one network
yarn subgraph compare NETWORK_NAME
# several networks
yarn subgraph compare NETWORK_NAME_1 NETWORK_NAME_2

Example query

{
  payments {
    txHash
    gasPrice
    contractAddress
    block
    amount
    amountInCrypto
    feeAmount
    feeAmountInCrypto
    feeAddress
    tokenAddress
    maxRateTimespan
    reference
    id
    to
    from
    currency
  }
}

Troubleshooting

Delays

Run one of these commands to check for indexing delays.

# all
yarn subgraph monitor
# one network
yarn subgraph monitor --network NETWORK_NAME
# several networks
yarn subgraph monitor --network NETWORK_NAME_1 NETWORK_NAME_2

Some networks will require you to set env vars:

export ALCHEMY_API_KEY=...
export INFURA_API_KEY=...

Hosting service API

URL: https://api.thegraph.com/index-node/graphql Schema: https://github.com/graphprotocol/graph-node/blob/master/server/index-node/src/schema.graphql

Sync failed with no logs

http POST 'https://api.thegraph.com/index-node/graphql'  query="{ indexingStatusForPendingVersion(subgraphName: \"requestnetwork/request-payments-sepolia\") { subgraph fatalError { message } nonFatalErrors {message } } }" | jq .data

Build issue �TS6054: File '~lib/allocator/arena.ts' not found.

You probably have an issue in the package resolution of assemblyscript.

See next issue for resolution.

Install issue Couldn't find match for ...

This is related to the fact TheGraph uses a very old version of assemblyscript (see This PR for migration to the latest version).

In the meantime, yarn cache clean should resolve it.

Failed to fetch status for mainnet: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)

Need to set env var ALCHEMY_API_KEY or INFURA_API_KEY.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published