Skip to content

Commit

Permalink
adding default value of project name to all codegens
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard-Voiculescu committed Aug 19, 2024
1 parent e536afa commit 10eeff7
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 39 deletions.
1 change: 1 addition & 0 deletions ethfull/convo.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
return c.action(codegen.InputProjectName{}).
TextInput(codegen.InputProjectNameTextInput(), "Submit").
Description(codegen.InputProjectNameDescription()).
DefaultValue("my_project").
Validation(codegen.InputProjectNameRegex(), codegen.InputProjectNameValidation()).
Cmd()

Expand Down
1 change: 1 addition & 0 deletions evm-minimal/convo.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
return c.action(codegen.InputProjectName{}).
TextInput(codegen.InputProjectNameTextInput(), "Submit").
Description(codegen.InputProjectNameDescription()).
DefaultValue("my_project").
Validation(codegen.InputProjectNameRegex(), codegen.InputProjectNameValidation()).
Cmd()

Expand Down
6 changes: 2 additions & 4 deletions evm-minimal/templates/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ substreams build
To run your Substreams you will need to [authenticate](https://substreams.streamingfast.io/documentation/consume/authentication) yourself.

```bash
export API_KEY="your_api_key"
export SUBSTREAMS_API_TOKEN=$(curl https://auth.thegraph.market/v1/auth/issue -s --data-binary '{"api_key":"'$API_KEY'"}' | jq -r .token)
substreams auth
```

## Run your Substreams

```bash
substreams run ./substreams.yaml map_my_data -t +1000
substreams gui ./substreams.yaml map_my_data -t +1000
substreams gui ./substreams.yaml
```
1 change: 1 addition & 0 deletions injective-events/convo.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func (c *InjectiveConvo) Update(msg loop.Msg) loop.Cmd {
return c.action(codegen.InputProjectName{}).
TextInput(codegen.InputProjectNameTextInput(), "Submit").
Description(codegen.InputProjectNameDescription()).
DefaultValue("my_project").
Validation(codegen.InputProjectNameRegex(), codegen.InputProjectNameValidation()).
Cmd()

Expand Down
42 changes: 42 additions & 0 deletions injective-minimal/chain_configs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package injectiveminimal

import "sort"

type ChainConfig struct {
ID string // Public
DisplayName string // Public
ExplorerLink string
FirehoseEndpoint string
Network string

initialBlockCache map[string]uint64
}

var ChainConfigs []*ChainConfig

var ChainConfigByID = map[string]*ChainConfig{
"injective-mainnet": {
DisplayName: "Injective Mainnet",
ExplorerLink: "https://explorer.injective.network/",
FirehoseEndpoint: "mainnet.injective.streamingfast.io:443",
Network: "injective-mainnet",
initialBlockCache: make(map[string]uint64),
},
"injective-testnet": {
DisplayName: "Injective Testnet",
ExplorerLink: "https://testnet.explorer.injective.network/",
FirehoseEndpoint: "testnet.injective.streamingfast.io:443",
Network: "injective-testnet",
initialBlockCache: make(map[string]uint64),
},
}

func init() {
for k, v := range ChainConfigByID {
v.ID = k
ChainConfigs = append(ChainConfigs, v)
}
sort.Slice(ChainConfigs, func(i, j int) bool {
return ChainConfigs[i].DisplayName < ChainConfigs[j].DisplayName
})
}
5 changes: 2 additions & 3 deletions injective-minimal/convo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ethfull
package injectiveminimal

import (
"encoding/json"
Expand Down Expand Up @@ -47,8 +47,6 @@ func cmd(msg any) loop.Cmd {
}
}

// This function does NOT mutate anything. Only reads.

func (c *Convo) validate() error {
if _, err := json.Marshal(c.state); err != nil {
return fmt.Errorf("validating state format: %w", err)
Expand Down Expand Up @@ -102,6 +100,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
return c.action(codegen.InputProjectName{}).
TextInput(codegen.InputProjectNameTextInput(), "Submit").
Description(codegen.InputProjectNameDescription()).
DefaultValue("my_project").
Validation(codegen.InputProjectNameRegex(), codegen.InputProjectNameValidation()).
Cmd()

Expand Down
2 changes: 1 addition & 1 deletion injective-minimal/convo_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ethfull
package injectiveminimal

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion injective-minimal/generate.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ethfull
package injectiveminimal

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion injective-minimal/logging.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ethfull
package injectiveminimal

import (
"github.com/streamingfast/logging"
Expand Down
7 changes: 6 additions & 1 deletion injective-minimal/state.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ethfull
package injectiveminimal

import (
"strings"
Expand Down Expand Up @@ -30,3 +30,8 @@ type Project struct {

func (p *Project) ModuleName() string { return strings.ReplaceAll(p.Name, "-", "_") }
func (p *Project) KebabName() string { return strings.ReplaceAll(p.Name, "_", "-") }

func (p *Project) ChainConfig() *ChainConfig { return ChainConfigByID[p.ChainName] }
func (p *Project) ChainEndpoint() string { return ChainConfigByID[p.ChainName].FirehoseEndpoint }
func (p *Project) ChainNetwork() string { return ChainConfigByID[p.ChainName].Network }
func (p *Project) IsValidChainName(input string) bool { return ChainConfigByID[input] != nil }
14 changes: 0 additions & 14 deletions injective-minimal/types.go

This file was deleted.

3 changes: 1 addition & 2 deletions sol-minimal/convo.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ func cmd(msg any) loop.Cmd {
}
}

// This function does NOT mutate anything. Only reads.

func (c *Convo) validate() error {
if _, err := json.Marshal(c.state); err != nil {
return fmt.Errorf("validating state format: %w", err)
Expand Down Expand Up @@ -103,6 +101,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
return c.action(codegen.InputProjectName{}).
TextInput(codegen.InputProjectNameTextInput(), "Submit").
Description(codegen.InputProjectNameDescription()).
DefaultValue("my_project").
Validation(codegen.InputProjectNameRegex(), codegen.InputProjectNameValidation()).
Cmd()

Expand Down
6 changes: 2 additions & 4 deletions sol-minimal/templates/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ substreams build
To run your Substreams you will need to [authenticate](https://substreams.streamingfast.io/documentation/consume/authentication) yourself.

```bash
export API_KEY="your_api_key"
export SUBSTREAMS_API_TOKEN=$(curl https://auth.thegraph.market/v1/auth/issue -s --data-binary '{"api_key":"'$API_KEY'"}' | jq -r .token)
substreams auth
```

## Run your Substreams

```bash
substreams run ./substreams.yaml map_my_data -t +1000
substreams gui ./substreams.yaml map_my_data -t +1000
substreams gui ./substreams.yaml
```
1 change: 1 addition & 0 deletions starknet-minimal/convo.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
return c.action(codegen.InputProjectName{}).
TextInput(codegen.InputProjectNameTextInput(), "Submit").
Description(codegen.InputProjectNameDescription()).
DefaultValue("my_project").
Validation(codegen.InputProjectNameRegex(), codegen.InputProjectNameValidation()).
Cmd()

Expand Down
6 changes: 2 additions & 4 deletions starknet-minimal/templates/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ substreams build
To run your Substreams you will need to [authenticate](https://substreams.streamingfast.io/documentation/consume/authentication) yourself.

```bash
export API_KEY="your_api_key"
export SUBSTREAMS_API_TOKEN=$(curl https://auth.thegraph.market/v1/auth/issue -s --data-binary '{"api_key":"'$API_KEY'"}' | jq -r .token)
substreams auth
```

## Run your Substreams

```bash
substreams run ./substreams.yaml map_my_data -t +1000
substreams gui ./substreams.yaml map_my_data -t +1000
substreams gui ./substreams.yaml
```
1 change: 1 addition & 0 deletions starknet-sql/convo.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
return c.action(codegen.InputProjectName{}).
TextInput(codegen.InputProjectNameTextInput(), "Submit").
Description(codegen.InputProjectNameDescription()).
DefaultValue("my_project").
Validation(codegen.InputProjectNameRegex(), codegen.InputProjectNameValidation()).
Cmd()

Expand Down
1 change: 1 addition & 0 deletions vara-minimal/convo.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (c *Convo) Update(msg loop.Msg) loop.Cmd {
return c.action(codegen.InputProjectName{}).
TextInput(codegen.InputProjectNameTextInput(), "Submit").
Description(codegen.InputProjectNameDescription()).
DefaultValue("my_project").
Validation(codegen.InputProjectNameRegex(), codegen.InputProjectNameValidation()).
Cmd()

Expand Down
6 changes: 2 additions & 4 deletions vara-minimal/templates/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ substreams build
To run your Substreams you will need to [authenticate](https://substreams.streamingfast.io/documentation/consume/authentication) yourself.

```bash
export API_KEY="your_api_key"
export SUBSTREAMS_API_TOKEN=$(curl https://auth.thegraph.market/v1/auth/issue -s --data-binary '{"api_key":"'$API_KEY'"}' | jq -r .token)
substreams auth
```

## Run your Substreams

```bash
substreams run ./substreams.yaml map_my_data -t +1000
substreams gui ./substreams.yaml map_my_data -t +1000
substreams gui ./substreams.yaml
```

0 comments on commit 10eeff7

Please sign in to comment.