Skip to content

Commit 99da12b

Browse files
committed
trying to fix prettier
1 parent 3be0142 commit 99da12b

File tree

2 files changed

+38
-41
lines changed

2 files changed

+38
-41
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Using [Entity Changes](https://substreams.streamingfast.io/documentation/consume
1212

1313
It is really a matter of where you put your logic, in the subgraph or the Substreams. Keep in mind that having more of your logic in Substreams benefits from a parallelized model, whereas triggers will be linearly consumed in graph-node.
1414

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

1817
- [Solana](https://substreams.streamingfast.io/documentation/how-to-guides/intro-your-first-application/solana)

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

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Before starting, make sure to:
1212
## Step 1: Initialize Your Project
1313

1414
1. Open your Dev Container and run the following command to initialize your project:
15-
16-
```bash
17-
substreams init
18-
```
19-
15+
16+
```bash
17+
substreams init
18+
```
19+
2020
2. Select the "minimal" project option.
2121
3. Replace the contents of the generated `substreams.yaml` file with the following configuration, which filters transactions for the Orca account on the SPL token program ID:
2222

@@ -26,22 +26,21 @@ package:
2626
name: my_project_sol
2727
version: v0.1.0
2828

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

3232
modules:
33-
34-
- name: map_spl_transfers
35-
use: solana:map_block # Select corresponding modules available within your spkg
36-
initialBlock: 260000082
37-
38-
- name: map_transactions_by_programid
39-
use: solana:solana:transactions_by_programid_without_votes
33+
- name: map_spl_transfers
34+
use: solana:map_block # Select corresponding modules available within your spkg
35+
initialBlock: 260000082
36+
37+
- name: map_transactions_by_programid
38+
use: solana:solana:transactions_by_programid_without_votes
4039

4140
network: solana-mainnet-beta
4241

4342
params: # Modify the param fields to meet your needs
44-
# For program_id: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
43+
# For program_id: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
4544
map_spl_transfers: token_contract:orcaEKTdK7LKz57vaAYr9QeNsVEPfiu6QeMU1kektZE
4645
```
4746
@@ -56,8 +55,8 @@ substreams codegen subgraph
5655
You will generate a`subgraph.yaml` manifest which imports the Substreams package as a data source:
5756

5857
```yaml
59-
...
6058

59+
---
6160
dataSources:
6261
- kind: substreams
6362
name: my_project_sol
@@ -79,11 +78,11 @@ Define the fields you want to save in your subgraph entities by updating the `sc
7978

8079
```graphql
8180
type MyTransfer @entity {
82-
id: ID!
83-
amount: String!
84-
source: String!
85-
designation: String!
86-
signers: [String!]!
81+
id: ID!
82+
amount: String!
83+
source: String!
84+
designation: String!
85+
signers: [String!]!
8786
}
8887
```
8988

@@ -104,30 +103,29 @@ This command converts the Protobuf definitions into AssemblyScript, allowing you
104103
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:
105104

106105
```ts
107-
import { Protobuf } from "as-proto/assembly";
108-
import { Events as protoEvents } from "./pb/sf/solana/spl/token/v1/Events";
109-
import { MyTransfer } from "../generated/schema";
106+
import { Protobuf } from 'as-proto/assembly'
107+
import { Events as protoEvents } from './pb/sf/solana/spl/token/v1/Events'
108+
import { MyTransfer } from '../generated/schema'
110109
111110
export function handleTriggers(bytes: Uint8Array): void {
112-
const input: protoEvents = Protobuf.decode<protoEvents>(bytes, protoEvents.decode);
113-
114-
for (let i=0; i<input.data.length; i++) {
115-
const event = input.data[i];
116-
111+
const input: protoEvents = Protobuf.decode<protoEvents>(bytes, protoEvents.decode)
112+
113+
for (let i = 0; i < input.data.length; i++) {
114+
const event = input.data[i]
115+
117116
if (event.transfer != null) {
118-
let entity_id: string = `${event.txnId}-${i}`;
119-
const entity = new MyTransfer(entity_id);
120-
entity.amount = (event.transfer!.instruction!.amount).toString();
121-
entity.source = event.transfer!.accounts!.source;
122-
entity.designation = event.transfer!.accounts!.destination;
123-
124-
if (event.transfer!.accounts!.signer!.single != null){
125-
entity.signers = [event.transfer!.accounts!.signer!.single.signer];
126-
}
127-
else if (event.transfer!.accounts!.signer!.multisig != null) {
128-
entity.signers = event.transfer!.accounts!.signer!.multisig!.signers;
117+
let entity_id: string = `${event.txnId}-${i}`
118+
const entity = new MyTransfer(entity_id)
119+
entity.amount = event.transfer!.instruction!.amount.toString()
120+
entity.source = event.transfer!.accounts!.source
121+
entity.designation = event.transfer!.accounts!.destination
122+
123+
if (event.transfer!.accounts!.signer!.single != null) {
124+
entity.signers = [event.transfer!.accounts!.signer!.single.signer]
125+
} else if (event.transfer!.accounts!.signer!.multisig != null) {
126+
entity.signers = event.transfer!.accounts!.signer!.multisig!.signers
129127
}
130-
entity.save();
128+
entity.save()
131129
}
132130
}
133131
}

0 commit comments

Comments
 (0)