Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@connext/nxtp-adapters-subgraph

Package Overview
Dependencies
Maintainers
5
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@connext/nxtp-adapters-subgraph

adapter for subgraph interaction of nxtp protocol

  • 2.4.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by900%
Maintainers
5
Weekly downloads
 
Created
Source

Cross Chain Subgraph for NXTP

The subgraph adapter has been built on top of the graphclient. This basically works in cross-chain mode right now and uses highestValue strategy, but we will integrate the most-synced strategy once they get it released here.

Cross Chain Mode

There are several use cases graphclient can support for cross chain mode. See more details here.

  • Use-case 1: Subgraphs are managed separately and prefixed
  • Use-case 2: Merge responses
  • Use-case 3: Merge root-operation, while union the responses

Cross chain mode has been implemented in the adapter using use-case 1. So in this scenario, developers need to prefix each schema types while being compose, at the level of each source:

sources:
  - name: Connext_Kovan
    handler:
      graphql:
        endpoint: https://api.thegraph.com/subgraphs/name/connext/nxtp-amarok-runtime-v0-kovan
    transforms:
      - prefix:
          value: kovan_
          includeRootOperations: true
          ignore:
            - _SubgraphErrorPolicy_
  - name: Connext_Rinkeby
    handler:
      graphql:
        endpoint: https://api.thegraph.com/subgraphs/name/connext/nxtp-amarok-runtime-v0-rinkeby
    transforms:
      - prefix:
          value: rinkeby_
          includeRootOperations: true
          ignore:
            - _SubgraphErrorPolicy_

The merged schema allows users to execute a cross-chain query through multiple chains at the same time and parse responses.

query something($t: String) { # you can even pass the same GraphQL variable, into multiple GraphQL field arguments
   kovan_something(t: $t) {
     id
   }
   rinkeby_something(t: $t) {
     id
   }
}

How to add a new subgraph

To add a new subgraph, you need to determine source name, endpoint and prefix first. After that, you can add a new source to .graphclientrc.yml and need to regenerate typescript types for schemas to be updated.

How to generate typescript types.

Whenever you add a new source in .graphclientrc.yml or there is an update in subgraph schema, you need to rebuild graphclient. Before building a graphclient, you must create .env file and set the following variables properly. To generate schemas for local subgraphs without running the graph nodes locally, we can use live endpoints like the following.

GRAPH_1337_ENDPOINT=https://api.thegraph.com/subgraphs/name/connext/nxtp-amarok-runtime-v0-rinkeby
GRAPH_1338_ENDPOINT=https://api.thegraph.com/subgraphs/name/connext/nxtp-amarok-runtime-v0-rinkeby
yarn workspace @connext/nxtp-adapters-subgraph build-client

This basically fetches the schemas from endpoints and creates typescript-based entities which are prefixed.

FAQs

Package last updated on 22 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc