From bdcec3282c0f35a50d0bb926ec904b4b3781de89 Mon Sep 17 00:00:00 2001 From: Enol <51820585+enoldev@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:22:09 +0200 Subject: [PATCH] Update SpS Tutorial (#773) --- website/pages/en/sps/introduction.mdx | 6 +++--- website/pages/en/sps/triggers-example.mdx | 24 +++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/website/pages/en/sps/introduction.mdx b/website/pages/en/sps/introduction.mdx index 3e50521589af..12e3f81c6d53 100644 --- a/website/pages/en/sps/introduction.mdx +++ b/website/pages/en/sps/introduction.mdx @@ -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) diff --git a/website/pages/en/sps/triggers-example.mdx b/website/pages/en/sps/triggers-example.mdx index d8d61566295e..64479efc0abf 100644 --- a/website/pages/en/sps/triggers-example.mdx +++ b/website/pages/en/sps/triggers-example.mdx @@ -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: @@ -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 } @@ -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.