-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First draft of common patterns on codegens.
Some are not tested, might have typos in templates.
- Loading branch information
Alexandre Bourget
committed
Sep 11, 2024
1 parent
1208fec
commit 7105f4d
Showing
12 changed files
with
117 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This template holds chunks of common README.md | ||
|
||
{{ define "readme_usage" -}} | ||
## Usage | ||
|
||
```bash | ||
substreams build | ||
substreams auth | ||
substreams gui | ||
``` | ||
{{- end }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package codegen | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
"text/template" | ||
|
||
"github.com/bmatcuk/doublestar/v4" | ||
) | ||
|
||
//go:embed common-templates/*.gotmpl | ||
var commonTemplatesFS embed.FS | ||
|
||
var commonTemplates *template.Template | ||
|
||
func init() { | ||
var err error | ||
commonTemplates, err = parseCommonTemplates() | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
func parseCommonTemplates() (*template.Template, error) { | ||
t := template.New("").Funcs(templateFuncs) | ||
filenames, err := doublestar.Glob(commonTemplatesFS, "**/*.gotmpl") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
for _, filename := range filenames { | ||
b, err := fs.ReadFile(commonTemplatesFS, filename) | ||
if err != nil { | ||
return nil, err | ||
} | ||
_, err = t.New(filename).Parse(string(b)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
return t, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,12 @@ | ||
# EVM Minimal | ||
# {{ .Name }} Substreams modules | ||
|
||
## Build your Substreams | ||
This package was initialized via `substreams init`, using the `evm-minimal` template. | ||
|
||
```bash | ||
substreams build | ||
``` | ||
|
||
## Authenticate | ||
|
||
To run your Substreams you will need to [authenticate](https://substreams.streamingfast.io/documentation/consume/authentication) yourself. | ||
|
||
```bash | ||
substreams auth | ||
``` | ||
|
||
## Run your Substreams | ||
|
||
```bash | ||
substreams gui | ||
``` | ||
{{ template "readme_usage" }} | ||
|
||
## Modules | ||
|
||
`map_my_data`: This module will do a simple computation of the number of **transactions** in each block. | ||
### `map_my_data` | ||
|
||
This module extracts small bits of block data, and does simple computations over the | ||
number of **transactions** in each block. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# {{ .Name }} Substreams modules | ||
|
||
This package was initialized via `substreams init`, using the `injective-events` template. | ||
|
||
{{ template "readme_usage" }} | ||
|
||
## Modules | ||
|
||
### `{{ .ModuleName }}` | ||
|
||
This module uses the [Injective Foundational Modules](https://github.com/streamingfast/substreams-foundational-modules/) | ||
and applies filters on the chosen events and attributes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,11 @@ | ||
# Injective Minimal | ||
# {{ .Name }} Substreams modules | ||
|
||
## Build your Substreams | ||
This package was initialized via `substreams init`, using the `injective-minimal` template. | ||
|
||
```bash | ||
substreams build | ||
``` | ||
|
||
## Authenticate | ||
|
||
To run your Substreams you will need to [authenticate](https://substreams.streamingfast.io/documentation/consume/authentication) yourself. | ||
|
||
```bash | ||
substreams auth | ||
``` | ||
|
||
## Run your Substreams | ||
|
||
```bash | ||
substreams gui | ||
``` | ||
{{ template "readme_usage" }} | ||
|
||
## Modules | ||
|
||
`map_my_data`: This module will do a simple computation of the number of **transactions** in each block. | ||
### `map_my_data` | ||
|
||
This module will do a simple computation of the number of **transactions** in each block. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters