Skip to content

Commit 4b0f462

Browse files
committed
Fix format
1 parent 0c10608 commit 4b0f462

File tree

5 files changed

+42
-45
lines changed

5 files changed

+42
-45
lines changed

website/pages/en/sps/_meta.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
'sps-intro': '',
3-
'triggers': '',
4-
'triggers-example': ''
5-
}
2+
'sps-intro': '',
3+
triggers: '',
4+
'triggers-example': '',
5+
}

website/pages/en/sps/sps-intro.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ title: Introduction
44

55
By leveraging a Substreams package (`.yaml`) as a data source, your subgraph gains access to pre-extracted, indexed blockchain data, enabling more efficient and scalable data handling, especially when dealing with large or complex blockchain networks.
66

7-
This technology opens up more efficient and versatile indexing for diverse blockchain environments. For more information on how to build a Substreams-powered subgraph, [click here](./triggers.mdx). You can also visit the following links for How-To Guides on using code-generation tooling to scaffold your first end to end project quickly:
7+
This technology opens up more efficient and versatile indexing for diverse blockchain environments. For more information on how to build a Substreams-powered subgraph, [click here](./triggers.mdx). You can also visit the following links for How-To Guides on using code-generation tooling to scaffold your first end to end project quickly:
88

99
- [Solana](https://substreams.streamingfast.io/documentation/how-to-guides/intro-your-first-application/solana)
1010
- [EVM](https://substreams.streamingfast.io/documentation/how-to-guides/intro-your-first-application/evm)
1111
- [Injective](https://substreams.streamingfast.io/documentation/how-to-guides/intro-your-first-application/injective)
1212

1313
**Public Substreams packages**
1414

15-
A Substreams package is a precompiled binary file that defines the specific data you want to extract from the blockchain—similar to the `mapping.ts` file in traditional subgraphs.
16-
17-
Visit [substreams.dev](https://substreams.dev/) to explore a growing collection of ready-to-use Substreams packages across various blockchain networks that can be easily integrated into your subgraph. If you can’t find a suitable Substreams package and want to build your own, click [here](https://thegraph.com/docs/en/substreams/) for detailed instructions on creating a custom package tailored to your needs.
15+
A Substreams package is a precompiled binary file that defines the specific data you want to extract from the blockchain—similar to the `mapping.ts` file in traditional subgraphs.
1816

17+
Visit [substreams.dev](https://substreams.dev/) to explore a growing collection of ready-to-use Substreams packages across various blockchain networks that can be easily integrated into your subgraph. If you can’t find a suitable Substreams package and want to build your own, click [here](https://thegraph.com/docs/en/substreams/) for detailed instructions on creating a custom package tailored to your needs.

website/pages/en/sps/triggers-example.mdx

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Example Susbtreams Trigger
33
---
44

5-
Here you’ll walk through a Solana based example for setting up your Substreams-powered subgraph project. If you haven’t already, first check out the [Getting Started Guide](https://github.com/streamingfast/substreams/blob/enol/how-to-guides/docs/new/how-to-guides/intro-how-to-guides.md) for more information on how to initialize your project.
5+
Here you’ll walk through a Solana based example for setting up your Substreams-powered subgraph project. If you haven’t already, first check out the [Getting Started Guide](https://github.com/streamingfast/substreams/blob/enol/how-to-guides/docs/new/how-to-guides/intro-how-to-guides.md) for more information on how to initialize your project.
66

77
Consider the following example of a Substreams manifest (`substreams.yaml`), a configuration file similar to the `subgraph.yaml`, using the SPL token program Id:
88

@@ -12,17 +12,17 @@ package:
1212
name: my_project_sol
1313
version: v0.1.0
1414

15-
imports: #Pass your spkg of interest
15+
imports: #Pass your spkg of interest
1616
solana: https://github.com/streamingfast/substreams-solana-spl-token/raw/master/tokens/solana-spl-token-v0.1.0.spkg
1717

1818
modules:
19-
19+
2020
- name: map_spl_transfers
2121
use: solana:map_block #Select corresponding modules available within your spkg
2222
initialBlock: 260000082
23-
23+
2424
- name: map_transactions_by_programid
25-
use: solana:solana:transactions_by_programid_without_votes
25+
use: solana:solana:transactions_by_programid_without_votes
2626

2727
network: solana-mainnet-beta
2828

@@ -31,8 +31,6 @@ params: #Modify the param fields to meet your needs
3131
map_spl_transfers: token_contract:orcaEKTdK7LKz57vaAYr9QeNsVEPfiu6QeMU1kektZE
3232
```
3333

34-
35-
3634
Now see the corresponding subgraph manifest **(`subgraph.yaml`)** using a Substreams package as the data source:
3735

3836
```yaml
@@ -57,45 +55,44 @@ dataSources:
5755
handler: handleTriggers
5856
```
5957
60-
Once your manifests are created, define in the `schema.graphql` the data fields you’d like saved in your subgraph entities:
58+
Once your manifests are created, define in the `schema.graphql` the data fields you’d like saved in your subgraph entities:
6159

6260
```graphql
6361
type MyTransfer @entity {
64-
id: ID!
65-
amount: String!
66-
source: String!
67-
designation: String!
68-
signers: [String!]!
62+
id: ID!
63+
amount: String!
64+
source: String!
65+
designation: String!
66+
signers: [String!]!
6967
}
7068
```
7169

7270
The Protobuf object is generated in AssemblyScript by running `npm run protogen` after running `substreams codegen subgraph` in the devcontainer, so you can import it in the subgraph code. Then transform your decoded Substreams data within the `src/mappings.ts` file, just like in a standard subgraph:
7371

7472
```tsx
75-
import { Protobuf } from "as-proto/assembly";
76-
import { Events as protoEvents } from "./pb/sf/solana/spl/token/v1/Events";
77-
import { MyTransfer } from "../generated/schema";
73+
import { Protobuf } from 'as-proto/assembly'
74+
import { Events as protoEvents } from './pb/sf/solana/spl/token/v1/Events'
75+
import { MyTransfer } from '../generated/schema'
7876
7977
export function handleTriggers(bytes: Uint8Array): void {
80-
const input: protoEvents = Protobuf.decode<protoEvents>(bytes, protoEvents.decode);
81-
82-
for (let i=0; i<input.data.length; i++) {
83-
const event = input.data[i];
84-
78+
const input: protoEvents = Protobuf.decode<protoEvents>(bytes, protoEvents.decode)
79+
80+
for (let i = 0; i < input.data.length; i++) {
81+
const event = input.data[i]
82+
8583
if (event.transfer != null) {
86-
let entity_id: string = `${event.txnId}-${i}`;
87-
const entity = new MyTransfer(entity_id);
88-
entity.amount = (event.transfer!.instruction!.amount).toString();
89-
entity.source = event.transfer!.accounts!.source;
90-
entity.designation = event.transfer!.accounts!.destination;
91-
92-
if (event.transfer!.accounts!.signer!.single != null){
93-
entity.signers = [event.transfer!.accounts!.signer!.single.signer];
94-
}
95-
else if (event.transfer!.accounts!.signer!.multisig != null) {
96-
entity.signers = event.transfer!.accounts!.signer!.multisig!.signers;
84+
let entity_id: string = `${event.txnId}-${i}`
85+
const entity = new MyTransfer(entity_id)
86+
entity.amount = event.transfer!.instruction!.amount.toString()
87+
entity.source = event.transfer!.accounts!.source
88+
entity.designation = event.transfer!.accounts!.destination
89+
90+
if (event.transfer!.accounts!.signer!.single != null) {
91+
entity.signers = [event.transfer!.accounts!.signer!.single.signer]
92+
} else if (event.transfer!.accounts!.signer!.multisig != null) {
93+
entity.signers = event.transfer!.accounts!.signer!.multisig!.signers
9794
}
98-
entity.save();
95+
entity.save()
9996
}
10097
}
10198
}
@@ -107,5 +104,4 @@ Here's what you’re seeing in the `mappings.ts`:
107104
2. Looping over the transactions
108105
3. Create a new subgraph entity for every transaction
109106

110-
> Note: It's beneficial to have more of your logic in Substreams, as it allows for a parallelized model, whereas triggers are linearly consumed in `graph-node`.
111-
>
107+
> Note: It's beneficial to have more of your logic in Substreams, as it allows for a parallelized model, whereas triggers are linearly consumed in `graph-node`.

website/pages/en/sps/triggers.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
----
22
title: Substreams Triggers
3-
----
3+
---
4+
5+
-
46

57
Substreams triggers allow you to integrate Substreams data directly into your subgraph. By importing the [Protobuf definitions](https://substreams.streamingfast.io/documentation/develop/creating-protobuf-schemas#protobuf-overview) emitted by your Substreams module, you can receive and process this data in your subgraph's handler. This enables efficient and streamlined data handling within the subgraph framework.
68

website/pages/en/substreams.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Substreams
44

55
![Substreams Logo](/img/substreams-logo.png)
66

7-
Substreams is a powerful blockchain indexing technology designed to enhance performance and scalability within The Graph Network. It offers the following features:
7+
Substreams is a powerful blockchain indexing technology designed to enhance performance and scalability within The Graph Network. It offers the following features:
88

99
- **Accelerated Indexing**: Substreams reduces subgraph indexing time thanks to a parallelized engine, enabling faster data retrieval and processing.
1010
- **Multi-Chain Support**: Substreams expand indexing capabilities beyond EVM-based chains, supporting ecosystems like Solana, Injective, Starknet, and Vara.

0 commit comments

Comments
 (0)