Skip to content

Commit

Permalink
[fix] outdated link and new updates (#650)
Browse files Browse the repository at this point in the history
* [fix] outdated link and new updates

* [fix] subgraph debug forking page

* [fix] requested changes
  • Loading branch information
yash251 authored Apr 29, 2024
1 parent a65d5d9 commit 36fa381
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 69 deletions.
4 changes: 2 additions & 2 deletions website/pages/en/cookbook/arweave.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Building Subgraphs on Arweave
---

> Arweave support in Graph Node and on the Subgraph Studio is in beta: please reach us on [Discord](https://discord.gg/graphprotocol) with any questions about building Arweave subgraphs!
> Arweave support in Graph Node and on Subgraph Studio is in beta: please reach us on [Discord](https://discord.gg/graphprotocol) with any questions about building Arweave subgraphs!
In this guide, you will learn how to build and deploy Subgraphs to index the Arweave blockchain.

Expand Down Expand Up @@ -95,7 +95,7 @@ Arweave data sources support two types of handlers:

> Transactions are the building blocks of the Arweave permaweb and they are objects created by end-users.

> Note: [Bundlr](https://bundlr.network/) transactions are not supported yet.
> Note: [Irys (previously Bundlr)](https://irys.xyz/) transactions are not supported yet.

## Schema Definition

Expand Down
21 changes: 10 additions & 11 deletions website/pages/en/cookbook/base-testnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This guide will quickly take you through how to initialize, create, and deploy y

What you'll need:

- A Base testnet contract address
- A Base Sepolia testnet contract address
- A crypto wallet (e.g. MetaMask or Coinbase Wallet)

## Subgraph Studio
Expand All @@ -23,17 +23,15 @@ npm install -g @graphprotocol/graph-cli
yarn global add @graphprotocol/graph-cli
```

### 2. Create your subgraph in the Subgraph Studio
### 2. Create your subgraph in Subgraph Studio

Go to the [Subgraph Studio](https://thegraph.com/studio/) and connect your crypto wallet.
Go to [Subgraph Studio](https://thegraph.com/studio/) and connect your crypto wallet.

Once connected, click "Create a Subgraph" and enter a name for your subgraph.

Select "Base (testnet)" as the indexed blockchain and click Create Subgraph.
Once connected, click "Create a Subgraph", enter a name for your subgraph and click Create a Subgraph.

### 3. Initialize your Subgraph

> You can find specific commands for your subgraph in the Subgraph Studio.
> You can find specific commands for your subgraph in Subgraph Studio.
Make sure that the graph-cli is updated to latest (above 0.41.0)

Expand All @@ -52,7 +50,8 @@ Your subgraph slug is an identifier for your subgraph. The CLI tool will walk yo
- Protocol: ethereum
- Subgraph slug: `<SUBGRAPH_SLUG>`
- Directory to create the subgraph in: `<SUBGRAPH_SLUG>`
- Ethereum network: base-testnet \_ Contract address: `<CONTRACT_ADDRESS>`
- Ethereum network: base-sepolia
- Contract address: `<CONTRACT_ADDRESS>`
- Start block (optional)
- Contract name: `<CONTRACT_NAME>`
- Yes/no to indexing events (yes means your subgraph will be bootstrapped with entities in the schema and simple mappings for emitted events)
Expand All @@ -63,17 +62,17 @@ Your subgraph slug is an identifier for your subgraph. The CLI tool will walk yo
The previous command creates a scaffold subgraph that you can use as a starting point for building your subgraph. When making changes to the subgraph, you will mainly work with three files:

- Manifest (subgraph.yaml) - The manifest defines what datasources your subgraphs will index. Make sure to add `base-testnet` as the network name in manifest file to deploy your subgraph on Base testnet.
- Manifest (subgraph.yaml) - The manifest defines what datasources your subgraphs will index. Make sure to add `base-sepolia` as the network name in manifest file to deploy your subgraph on Base Sepolia.
- Schema (schema.graphql) - The GraphQL schema defines what data you wish to retreive from the subgraph.
- AssemblyScript Mappings (mapping.ts) - This is the code that translates data from your datasources to the entities defined in the schema.

If you want to index additional data, you will need extend the manifest, schema and mappings.

For more information on how to write your subgraph, see [Creating a Subgraph](/developing/creating-a-subgraph).

### 4. Deploy to the Subgraph Studio
### 4. Deploy to Subgraph Studio

Before you can deploy your subgraph, you will need to authenticate with the Subgraph Studio. You can do this by running the following command:
Before you can deploy your subgraph, you will need to authenticate with Subgraph Studio. You can do this by running the following command:

Authenticate the subgraph on studio

Expand Down
16 changes: 8 additions & 8 deletions website/pages/en/cookbook/cosmos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Building Subgraphs on Cosmos
---

This guide is an introduction on building subgraphs indexing [Cosmos](https://docs.cosmos.network/) based blockchains.
This guide is an introduction on building subgraphs indexing [Cosmos](https://cosmos.network/) based blockchains.

## What are Cosmos subgraphs?

Expand All @@ -17,21 +17,21 @@ There are four types of handlers supported in Cosmos subgraphs:

Based on the [official Cosmos documentation](https://docs.cosmos.network/):

> [Events](https://docs.cosmos.network/main/core/events) are objects that contain information about the execution of the application. They are mainly used by service providers like block explorers and wallets to track the execution of various messages and index transactions.
> [Events](https://docs.cosmos.network/main/learn/advanced/events) are objects that contain information about the execution of the application. They are mainly used by service providers like block explorers and wallets to track the execution of various messages and index transactions.
> [Transactions](https://docs.cosmos.network/main/core/transactions) are objects created by end-users to trigger state changes in the application.
> [Transactions](https://docs.cosmos.network/main/learn/advanced/transactions) are objects created by end-users to trigger state changes in the application.
> [Messages](https://docs.cosmos.network/main/core/transactions#messages) are module-specific objects that trigger state transitions within the scope of the module they belong to.
> [Messages](https://docs.cosmos.network/main/learn/advanced/transactions#messages) are module-specific objects that trigger state transitions within the scope of the module they belong to.
Even though all data can be accessed with a block handler, other handlers enable subgraph developers to process data in a much more granular way.

## Building a Cosmos subgraph

### Subgraph Dependencies

[graph-cli](https://github.com/graphprotocol/graph-cli) is a CLI tool to build and deploy subgraphs, version `>=0.30.0` is required in order to work with Cosmos subgraphs.
[graph-cli](https://github.com/graphprotocol/graph-tooling/tree/main/packages/cli) is a CLI tool to build and deploy subgraphs, version `>=0.30.0` is required in order to work with Cosmos subgraphs.

[graph-ts](https://github.com/graphprotocol/graph-ts) is a library of subgraph-specific types, version `>=0.27.0` is required in order to work with Cosmos subgraphs.
[graph-ts](https://github.com/graphprotocol/graph-tooling/tree/main/packages/ts) is a library of subgraph-specific types, version `>=0.27.0` is required in order to work with Cosmos subgraphs.

### Subgraph Main Components

Expand Down Expand Up @@ -79,7 +79,7 @@ dataSources:

### Schema Definition

Schema definition describes the structure of the resulting subgraph database and the relationships between entities. This is agnostic of the original data source. There are more details on subgraph schema definition [here](/developing/creating-a-subgraph/#the-graph-ql-schema).
Schema definition describes the structure of the resulting subgraph database and the relationships between entities. This is agnostic of the original data source. There are more details on subgraph schema definition [here](/developing/creating-a-subgraph/#the-graphql-schema).

### AssemblyScript Mappings

Expand Down Expand Up @@ -176,7 +176,7 @@ You can find the full list of types for the Cosmos integration [here](https://gi

### Message decoding

It's important to note that Cosmos messages are chain-specific and they are passed to a subgraph in the form of a serialized [Protocol Buffers](https://developers.google.com/protocol-buffers/) payload. As a result, the message data needs to be decoded in a mapping function before it can be processed.
It's important to note that Cosmos messages are chain-specific and they are passed to a subgraph in the form of a serialized [Protocol Buffers](https://protobuf.dev/) payload. As a result, the message data needs to be decoded in a mapping function before it can be processed.

An example of how to decode message data in a subgraph can be found [here](https://github.com/graphprotocol/graph-tooling/blob/main/examples/cosmos-validator-delegations/src/decoding.ts).

Expand Down
10 changes: 5 additions & 5 deletions website/pages/en/cookbook/grafting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ By adhering to these guidelines, you minimize risks and ensure a smoother migrat

## Building an Existing Subgraph

Building subgraphs is an essential part of The Graph, described more in depth [here](http://localhost:3000/en/cookbook/quick-start/). To be able to build and deploy the existing subgraph used in this tutorial, the following repo is provided:
Building subgraphs is an essential part of The Graph, described more in depth [here](/quick-start/). To be able to build and deploy the existing subgraph used in this tutorial, the following repo is provided:

- [Subgraph example repo](https://github.com/t-proctor/grafting-tutorial)

Expand Down Expand Up @@ -96,14 +96,14 @@ graft:
block: 1502122 # block number
```

- `features:` is a list of all used [feature names](developing/creating-a-subgraph/#experimental-features).
- `features:` is a list of all used [feature names](/developing/creating-a-subgraph/#experimental-features).
- `graft:` is a map of the `base` subgraph and the block to graft on to. The `block` is the block number to start indexing from. The Graph will copy the data of the base subgraph up to and including the given block and then continue indexing the new subgraph from that block on.

The `base` and `block` values can be found by deploying two subgraphs: one for the base indexing and one with grafting

## Deploying the Base Subgraph

1. Go to [The Graph Studio UI](https://thegraph.com/studio/) and create a subgraph on Goerli testnet called `graft-example`
1. Go to [Subgraph Studio](https://thegraph.com/studio/) and create a subgraph on Goerli testnet called `graft-example`
2. Follow the directions in the `AUTH & DEPLOY` section on your subgraph page in the `graft-example` folder from the repo
3. Once finished, verify the subgraph is indexing properly. If you run the following command in The Graph Playground

Expand Down Expand Up @@ -144,8 +144,8 @@ Once you have verified the subgraph is indexing properly, you can quickly update

The graft replacement subgraph.yaml will have a new contract address. This could happen when you update your dapp, redeploy a contract, etc.

1. Go to [The Graph Studio UI](https://thegraph.com/studio/) and create a subgraph on Goerli testnet called `graft-replacement`
2. Create a new manifest. The `subgraph.yaml` for `graph-replacement` contains a different contract address and new information about how it should graft. These are the `block` of the [last event emitted](https://goerli.etherscan.io/tx/0x800c92fcc0edbd26f74e19ad058c62008a47c7789f2064023b987028343dd498) you care about by the old contract and the `base` of the old subgraph. The `base` subgraph ID is the `Deployment ID` of your original `graph-example` subgraph. You can find this in The Graph Studio UI.
1. Go to [Subgraph Studio](https://thegraph.com/studio/) and create a subgraph on Goerli testnet called `graft-replacement`
2. Create a new manifest. The `subgraph.yaml` for `graph-replacement` contains a different contract address and new information about how it should graft. These are the `block` of the [last event emitted](https://goerli.etherscan.io/tx/0x800c92fcc0edbd26f74e19ad058c62008a47c7789f2064023b987028343dd498) you care about by the old contract and the `base` of the old subgraph. The `base` subgraph ID is the `Deployment ID` of your original `graph-example` subgraph. You can find this in Subgraph Studio.
3. Follow the directions in the `AUTH & DEPLOY` section on your subgraph page in the `graft-replacement` folder from the repo
4. Once finished, verify the subgraph is indexing properly. If you run the following command in The Graph Playground

Expand Down
10 changes: 5 additions & 5 deletions website/pages/en/cookbook/near.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This guide is an introduction to building subgraphs indexing smart contracts on

## What is NEAR?

[NEAR](https://near.org/) is a smart contract platform for building decentralized applications. Visit the [official documentation](https://docs.near.org/docs/concepts/new-to-near) for more information.
[NEAR](https://near.org/) is a smart contract platform for building decentralized applications. Visit the [official documentation](https://docs.near.org/concepts/basics/protocol) for more information.

## What are NEAR subgraphs?

Expand All @@ -17,7 +17,7 @@ Subgraphs are event-based, which means that they listen for and then process on-
- Block handlers: these are run on every new block
- Receipt handlers: run every time a message is executed at a specified account

[From the NEAR documentation](https://docs.near.org/docs/concepts/transaction#receipt):
[From the NEAR documentation](https://docs.near.org/build/data-infrastructure/lake-data-structures/receipt):

> A Receipt is the only actionable object in the system. When we talk about "processing a transaction" on the NEAR platform, this eventually means "applying receipts" at some point.
Expand Down Expand Up @@ -72,7 +72,7 @@ dataSources:
- NEAR subgraphs introduce a new `kind` of data source (`near`)
- The `network` should correspond to a network on the hosting Graph Node. On Subgraph Studio, NEAR's mainnet is `near-mainnet`, and NEAR's testnet is `near-testnet`
- NEAR data sources introduce an optional `source.account` field, which is a human-readable ID corresponding to a [NEAR account](https://docs.near.org/docs/concepts/account). This can be an account or a sub-account.
- NEAR data sources introduce an optional `source.account` field, which is a human-readable ID corresponding to a [NEAR account](https://docs.near.org/concepts/protocol/account-model). This can be an account or a sub-account.
- NEAR data sources introduce an alternative optional `source.accounts` field, which contains optional suffixes and prefixes. At least prefix or suffix must be specified, they will match the any account starting or ending with the list of values respectively. The example below would match: `[app|good].*[morning.near|morning.testnet]`. If only a list of prefixes or suffixes is necessary the other field can be omitted.

```yaml
Expand All @@ -88,7 +88,7 @@ accounts:
NEAR data sources support two types of handlers:

- `blockHandlers`: run on every new NEAR block. No `source.account` is required.
- `receiptHandlers`: run on every receipt where the data source's `source.account` is the recipient. Note that only exact matches are processed ([subaccounts](https://docs.near.org/docs/concepts/account#subaccounts) must be added as independent data sources).
- `receiptHandlers`: run on every receipt where the data source's `source.account` is the recipient. Note that only exact matches are processed ([subaccounts](https://docs.near.org/tutorials/crosswords/basics/add-functions-call#create-a-subaccount) must be added as independent data sources).

### Schema Definition

Expand Down Expand Up @@ -280,4 +280,4 @@ If it is a general question about subgraph development, there is a lot more info

## References

- [NEAR developer documentation](https://docs.near.org/docs/develop/basics/getting-started)
- [NEAR developer documentation](https://docs.near.org/tutorials/crosswords/basics/set-up-skeleton)
Loading

0 comments on commit 36fa381

Please sign in to comment.