Skip to content

Latest commit

 

History

History
54 lines (36 loc) · 1.88 KB

migrationV1_V2.md

File metadata and controls

54 lines (36 loc) · 1.88 KB

Updated environment initialization

  • Initialize the client with {environment: "test"} or {environment: "production"} instead of providing a chainID. This will enable queries to the correct graph.
  • WalletClient is not required. When initializing without a wallet client, or when the wallet client is set to a chain not supported in the environment, the SDK will default to read only mode.
  • PublicClient is not required. This client is mostly used for transaction simulation. When initializing without a publicClient, the SDK will default to a public client provided by viem for the chain specified by the WalletClient.

Removed GraphQL client

We removed the client in favor of letting developers using the graph directly. During development we learned that there's not a single query that fits all use cases. By using the graph directly, developers can build queries that fit their specific needs.

When using VSCode we recommend using gql.tada for syntax highlighting and other nifty features.

Example for setting up your own graph client

  1. Get your types on If you work on VSCode gql.tada is nice: https://github.com/0no-co/gql.tada

  2. Connect to a graph endpoint

Use urql as your graph client:

https://github.com/urql-graphql/urql

Get Graph URL from SDK

import { CONSTANTS } from "@hypercerts-org/sdk"

Set up urql client:

indexerEnvironment can be an evn var. Either "production" or "test"

export const urqlClient = new Client({
url: CONSTANTS.ENDPOINTS[indexerEnvironment as "production" | "test"],
exchanges: [cacheExchange, fetchExchange],
});

Removed methods

  • getData
  • getMetadata -> in favor of using the Graph

Nerd stuff

  • API client autogenerated from the OpenAPI endpoint
  • Using gql.tada for building queries
  • Reduced package size from 556Kb (2.0.0-alpha.0) to 158Kb (2.0.0-alpha.22)