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

Update local-subsquid.md #416

Closed
wants to merge 1 commit into from
Closed

Conversation

wuzhong-papermoon
Copy link
Contributor

Copy link
Contributor

@eshaben eshaben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Almost there with this one!

sqd down
```

2. 重新启动您的Squid:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the closest I could get to the actual line that needs to be updated. Starting at line 423. But this set of steps should have a number 3, and the sqd archive-up && sqd up commands can be removed. It should look like the following:

1. Shut down your Squid

    ```bash
    sqd down
    ```

2. Start your Squid back up:

    ```bash
    sqd up
    ```

3. Start indexing again:

    ```bash
    sqd process
    ```

}
就这么简单!现在你可以在 [http://localhost:4350/graphql](http://localhost:4350/graphql){target=_blank} 的GraphQL沙盒对你的Squid运行查询语句。您可以尝试创建您自己的GraphQL 语句,或使用以下查询语句:

???+ code "Sample query"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please translate "Sample query"?

```
![Run sqd typegen](/images/tutorials/integrations/local-subsquid/local-squid-5.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![Run sqd typegen](/images/tutorials/integrations/local-subsquid/local-squid-5.png)
![Run sqd typegen](/images/tutorials/integrations/local-subsquid/local-squid-5.webp)

@@ -567,9 +408,17 @@ processor.run(new TypeormDatabase(), async (ctx) => {

在终端中,您应当能看见检索器在处理区块!

![Spin up a Subsquid indexer](/images/tutorials/integrations/local-subsquid/local-squid-7.webp)
![Run sqd process](/images/tutorials/integrations/local-subsquid/local-squid-6.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![Run sqd process](/images/tutorials/integrations/local-subsquid/local-squid-6.png)
![Run sqd process](/images/tutorials/integrations/local-subsquid/local-squid-6.webp)

--8<-- 'code/tutorials/integrations/local-subsquid/sample-query.graphql'
```

![Running queries in GraphQL playground](/images/tutorials/integrations/local-subsquid/local-squid-7.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
![Running queries in GraphQL playground](/images/tutorials/integrations/local-subsquid/local-squid-7.png)
![Running queries in GraphQL playground](/images/tutorials/integrations/local-subsquid/local-squid-7.webp)

export const contractAddress = 'INSERT_CONTRACT_ADDRESS'.toLowerCase();
```

`.toLowerCase()` 很重要,因为Subsquid处理器对大小写敏感,一些区块浏览器会使用大写字母格式化合约地址。接下来你会看到一行 `export const processor = new EvmBatchProcessor()` , 接着是 `.setDataSource`。我们需要在这里做一些修改。Subsquid 为许多链(包括 Moonbeam、Moonriver 和 Moonbase Alpha)提供了[可用存档](https://docs.subsquid.io/evm-indexing/supported-networks/){target=_blank},这些存档可以加快数据检索过程。对于索引本地开发节点,无需使用存档,唯一的数据源将是本地节点的 RPC URL。你可以将存档行注释掉或删除。修改后,你的代码应该类似于以下内容:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`.toLowerCase()` 很重要,因为Subsquid处理器对大小写敏感,一些区块浏览器会使用大写字母格式化合约地址。接下来你会看到一行 `export const processor = new EvmBatchProcessor()` , 接着是 `.setDataSource`。我们需要在这里做一些修改。Subsquid 为许多链(包括 Moonbeam、Moonriver 和 Moonbase Alpha)提供了[可用存档](https://docs.subsquid.io/evm-indexing/supported-networks/){target=_blank},这些存档可以加快数据检索过程。对于索引本地开发节点,无需使用存档,唯一的数据源将是本地节点的 RPC URL。你可以将存档行注释掉或删除。修改后,你的代码应该类似于以下内容:
`.toLowerCase()` 很重要,因为Subsquid处理器对大小写敏感,一些区块浏览器会使用大写字母格式化合约地址。接下来你会看到一行 `export const processor = new EvmBatchProcessor()` , 接着是 `.setDataSource`。我们需要在这里做一些修改。Subsquid 为许多链(包括 Moonbeam、Moonriver 和 Moonbase Alpha)提供了[可用存档](https://docs.subsquid.io/evm-indexing/supported-networks/){target=\_blank},这些存档可以加快数据检索过程。对于索引本地开发节点,无需使用存档,唯一的数据源将是本地节点的 RPC URL。你可以将存档行注释掉或删除。修改后,你的代码应该类似于以下内容:


### 转换并储存数据 {: #transform-and-save-the-data}

`processor.ts` 定义使用的数据,`main.ts` 定义大部分与处理和转换该数据相关的操作。简单来说,我们要进一步处理Subsquid处理器读取处理过的数据,并将所需的部分插入TypeORM数据库中。有关Subsquid如何工作的更多详细信息,请查看[Subsquid的开发Squid文档](https://docs.subsquid.io/basics/squid-development/){target=_blank}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`processor.ts` 定义使用的数据,`main.ts` 定义大部分与处理和转换该数据相关的操作。简单来说,我们要进一步处理Subsquid处理器读取处理过的数据,并将所需的部分插入TypeORM数据库中。有关Subsquid如何工作的更多详细信息,请查看[Subsquid的开发Squid文档](https://docs.subsquid.io/basics/squid-development/){target=_blank}
`processor.ts` 定义使用的数据,`main.ts` 定义大部分与处理和转换该数据相关的操作。简单来说,我们要进一步处理Subsquid处理器读取处理过的数据,并将所需的部分插入TypeORM数据库中。有关Subsquid如何工作的更多详细信息,请查看[Subsquid的开发Squid文档](https://docs.subsquid.io/basics/squid-development/){target=\_blank}

txHash
}
}
就这么简单!现在你可以在 [http://localhost:4350/graphql](http://localhost:4350/graphql){target=_blank} 的GraphQL沙盒对你的Squid运行查询语句。您可以尝试创建您自己的GraphQL 语句,或使用以下查询语句:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
就这么简单!现在你可以在 [http://localhost:4350/graphql](http://localhost:4350/graphql){target=_blank} 的GraphQL沙盒对你的Squid运行查询语句。您可以尝试创建您自己的GraphQL 语句,或使用以下查询语句:
就这么简单!现在你可以在 [http://localhost:4350/graphql](http://localhost:4350/graphql){target=\_blank} 的GraphQL沙盒对你的Squid运行查询语句。您可以尝试创建您自己的GraphQL 语句,或使用以下查询语句:


这将返回所有的转账数据,包括转账至Alith账户的初始交易,以及Alith发送给Baltathar、Charleth、Dorothy和Ethan的转账。

就是这样!你已成功使用Subsquid在本地Moonbeam开发节点上索引数据!你可以在[GitHub](https://github.com/eshaben/local-squid-demo){target=_blank}上查看整个项目。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
就是这样!你已成功使用Subsquid在本地Moonbeam开发节点上索引数据!你可以在[GitHub](https://github.com/eshaben/local-squid-demo){target=_blank}上查看整个项目。
就是这样!你已成功使用Subsquid在本地Moonbeam开发节点上索引数据!你可以在[GitHub](https://github.com/eshaben/local-squid-demo){target=\_blank}上查看整个项目。

--8<-- 'code/tutorials/integrations/local-subsquid/main-with-logging.ts'
```

有关调试模式的更多信息,请参见 [Subsquid 调试指南](https://docs.subsquid.io/basics/logging/){target=_blank}。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
有关调试模式的更多信息,请参见 [Subsquid 调试指南](https://docs.subsquid.io/basics/logging/){target=_blank}。
有关调试模式的更多信息,请参见 [Subsquid 调试指南](https://docs.subsquid.io/basics/logging/){target=\_blank}。

@eshaben eshaben closed this May 10, 2024
@eshaben eshaben deleted the Translate-793-subsquid branch May 10, 2024 01:09
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.

None yet

2 participants