Skip to content

Commit

Permalink
Merge branch 'develop' into codegen-cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard-Voiculescu committed Sep 9, 2024
2 parents f0edf83 + 6270852 commit 5d3d65e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

## Usage

In `substreams`:
Run the `substreams-codegen` backend:

```bash
cd devel/inittests
go install -v ../../cmd/substreams && substreams init --generator ethereum_init_v1
# remove the DEBUG var if you want info level logs
DEBUG=.* go run ./cmd/substreams-codegen api --http-listen-addr "*:9000"
```

In `substreams-codegen`:
(Optionally) Run the remotebuild server locally:

```bash
DEBUG=* go install -v ./cmd/substreams-codegen && substreams-codegen api --http-listen-addr "*:9000"
GENERATOR_KEEP_FILES=true go run -v ./cmd/remotebuild
```

In `substreams-codegen`:
Use the `substreams` cli to initialize your Substreams.

```bash
GENERATOR_KEEP_FILES=true go run -v ./cmd/remotebuild
substreams init --discovery-endpoint http://localhost:9000
```

## Principles
Expand All @@ -27,8 +27,8 @@ You write a `Conversation` (or `Convo` for short) struct.

- This function embed or has a `state` variable with the state you want to build.
- This _state_ is what gets serialized to JSON and sent to the client. It must be a usable interface, so pick your names wisely.
- Anything that is exported will be shared with the client, and come back during hydration (if a connection gets interrupted, or the user kept its `generator.json` state, and wants to simply rebuild).
- It has an `Update()` method that is registered into the `loop.EventLoop` by the `codegen` framework
- Anything that is exported will be shared with the client, and come back during hydration (if a connection gets interrupted, or the user kept their `generator.json` state, and wants to simply rebuild).
- It has an `Update()` method that is registered into the `loop.EventLoop` by the `codegen` framework.
- This function can mutate state, and it is the only method who can mutate state.
- This function follows the ELM paradigm, and must never do long-running operations, only quick routing.
- A `NextStep()` function will choose where to go based on the current state, and continue the conversation to make sure it is valid and completely filled in.
Expand All @@ -44,6 +44,4 @@ The code generation:

0x1f98431c8ad98523631ae4a59f267346ea31f984 -> Uniswap V3 Factory
https://api.etherscan.io/api?module=contract&action=getabi&address=0xe592427a0aece92de3edee1f18e0157c05861564 -> Uniswap V3 Router
https://info.uniswap.org/#/tokens/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 -> USDC Contract
-> https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
->
https://info.uniswap.org/#/tokens/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 -> USDC Contract -> https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
19 changes: 19 additions & 0 deletions ethfull/templates/triggers/subgraph.yaml.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
specVersion: 1.0.0
description: {{ .Name }} Substreams-powered-Subgraph
indexerHints:
prune: auto
schema:
file: ./schema.graphql
dataSources:
- kind: substreams
name: filtered_events
network: {{ .ChainName }}
source:
package:
moduleName: {{ if and $.TrackAnyEvents $.TrackAnyCalls }}map_events_calls{{ else if $.TrackAnyEvents }}map_events{{ else if $.TrackAnyCalls }}map_calls{{ end }}
file: {{ $.KebabName }}-v0.1.0.spkg
mapping:
apiVersion: 0.0.7
kind: substreams/graph-entities
file: ./src/mappings.ts
handler: {{ if and $.TrackAnyEvents $.TrackAnyCalls }}handleEventsAndCalls{{ else if $.TrackAnyEvents }}handleEvents{{ else if $.TrackAnyCalls }}handleCalls{{ end }}
4 changes: 2 additions & 2 deletions evm-events-calls/chain_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ var ChainConfigByID = map[string]*ChainConfig{
initialBlockCache: make(map[string]uint64),
SupportsCalls: true,
},
"base-mainnet": {
"base": {
DisplayName: "Base Mainnet",
ExplorerLink: "https://basescan.org",
ApiEndpoint: "https://api.basescan.org",
FirehoseEndpoint: "base-mainnet.streamingfast.io",
FirstStreamableBlock: 0,
Network: "base-mainnet",
Network: "base",
abiCache: make(map[string]*ABI),
initialBlockCache: make(map[string]uint64),
SupportsCalls: true,
Expand Down

0 comments on commit 5d3d65e

Please sign in to comment.