Skip to content

Commit

Permalink
Update SpS Tutorial (#773)
Browse files Browse the repository at this point in the history
  • Loading branch information
enoldev authored Sep 18, 2024
1 parent 3949b8d commit bdcec32
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
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

0 comments on commit bdcec32

Please sign in to comment.