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 SpS Tutorial #773

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions website/pages/en/sps/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ It is really a matter of where you put your logic, in the subgraph or the Substr

Visit the following links for How-To Guides on using code-generation tooling to build your first end-to-end project quickly:

- [Solana](https://substreams.streamingfast.io/documentation/how-to-guides/intro-your-first-application/solana)
- [EVM](https://substreams.streamingfast.io/documentation/how-to-guides/intro-your-first-application/evm)
- [Injective](https://substreams.streamingfast.io/documentation/how-to-guides/intro-your-first-application/injective)
- [Solana](https://substreams.streamingfast.io/documentation/how-to-guides/solana)
- [EVM](https://substreams.streamingfast.io/documentation/how-to-guides/evm)
- [Injective](https://substreams.streamingfast.io/documentation/how-to-guides/injective)
24 changes: 12 additions & 12 deletions website/pages/en/sps/triggers-example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,7 @@ type MyTransfer @entity {

This schema defines a `MyTransfer` entity with fields such as `id`, `amount`, `source`, `designation`, and `signers`.

## Step 4: Generate Protobuf Files

To generate Protobuf objects in AssemblyScript, run the following command:

```bash
npm run protogen
```

This command converts the Protobuf definitions into AssemblyScript, allowing you to use them in the subgraph's handler.

## Step 5: Handle Substreams Data in `mappings.ts`
## Step 4: Handle Substreams Data in `mappings.ts`

With the Protobuf objects generated, you can now handle the decoded Substreams data in your `mappings.ts` file found in the `./src` directory. The example below demonstrates how to extract to subgraph entities the non-derived transfers associated to the Orca account id:

Expand All @@ -120,7 +110,7 @@ export function handleTriggers(bytes: Uint8Array): void {
entity.designation = event.transfer!.accounts!.destination

if (event.transfer!.accounts!.signer!.single != null) {
entity.signers = [event.transfer!.accounts!.signer!.single.signer]
entity.signers = [event.transfer!.accounts!.signer!.single!.signer]
} else if (event.transfer!.accounts!.signer!.multisig != null) {
entity.signers = event.transfer!.accounts!.signer!.multisig!.signers
}
Expand All @@ -130,6 +120,16 @@ export function handleTriggers(bytes: Uint8Array): void {
}
```

## Step 5: Generate Protobuf Files

To generate Protobuf objects in AssemblyScript, run the following command:

```bash
npm run protogen
```

This command converts the Protobuf definitions into AssemblyScript, allowing you to use them in the subgraph's handler.

## Conclusion

You’ve successfully set up a trigger-based Substreams-powered subgraph for a Solana SPL token. You can now further customize your schema, mappings, and modules to suit your specific use case.
Expand Down
Loading