diff --git a/codegen/templates/ethereum_project.go b/codegen/templates/ethereum_project.go index 213a31760..4bce54a0e 100644 --- a/codegen/templates/ethereum_project.go +++ b/codegen/templates/ethereum_project.go @@ -10,7 +10,7 @@ import ( "text/template" "github.com/gertd/go-pluralize" - "github.com/iancoleman/strcase" + "github.com/huandu/xstrings" "github.com/streamingfast/eth-go" "go.uber.org/zap" ) @@ -154,7 +154,7 @@ func (p *EthereumProject) Render() (map[string][]byte, error) { name := p.name if finalFileName == "subgraph.yaml.gotmpl" { - name = strcase.ToKebab(p.name) + name = xstrings.ToKebabCase(p.name) } model := map[string]any{ @@ -218,16 +218,16 @@ func BuildEventModels(contract *EthereumContract, multipleContracts bool) (out [ rustABIStructName = name + strconv.FormatUint(uint64(i+1), 10) } - protoFieldName := strcase.ToSnake(pluralizer.Plural(rustABIStructName)) + protoFieldName := xstrings.ToSnakeCase(pluralizer.Plural(rustABIStructName)) // prost will do a to_lower_camel_case() on any struct name - rustGeneratedStructName := strcase.ToCamel(strcase.ToSnake(rustABIStructName)) + rustGeneratedStructName := xstrings.ToCamelCase(xstrings.ToSnakeCase(rustABIStructName)) codegenEvent := codegenEvent{ Rust: &rustEventModel{ ABIStructName: rustGeneratedStructName, ProtoMessageName: rustGeneratedStructName, ProtoOutputModuleFieldName: protoFieldName, - TableChangeEntityName: strcase.ToSnake(rustABIStructName), + TableChangeEntityName: xstrings.ToSnakeCase(rustABIStructName), }, Proto: &protoEventModel{ @@ -285,7 +285,7 @@ func (e *rustEventModel) populateFields(log *eth.LogEventDef, multipleContracts fmt.Printf(" Generating ABI Events for %s (%s)\n", log.Name, strings.Join(paramNames, ",")) for _, parameter := range log.Parameters { - name := strcase.ToSnake(parameter.Name) + name := xstrings.ToSnakeCase(parameter.Name) name = sanitizeProtoFieldName(name) toProtoCode := generateFieldTransformCode(parameter.Type, "event."+name) @@ -613,7 +613,7 @@ func (e *protoEventModel) populateFields(log *eth.LogEventDef) error { e.Fields = make([]protoField, 0, len(log.Parameters)) for _, parameter := range log.Parameters { - fieldName := strcase.ToSnake(parameter.Name) + fieldName := xstrings.ToSnakeCase(parameter.Name) fieldName = sanitizeProtoFieldName(fieldName) fieldType := getProtoFieldType(parameter.Type) if fieldType == SKIP_FIELD { diff --git a/docs/release-notes/change-log.md b/docs/release-notes/change-log.md index 857d93ba7..b91d2d6b2 100644 --- a/docs/release-notes/change-log.md +++ b/docs/release-notes/change-log.md @@ -9,6 +9,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +* Bug in `substreams init` with numbers in ABI types + ## v1.1.22 ### alpha service deployments diff --git a/go.mod b/go.mod index e913ddfe2..6c36b8189 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/gertd/go-pluralize v0.2.1 github.com/google/uuid v1.3.0 - github.com/iancoleman/strcase v0.2.0 + github.com/huandu/xstrings v1.4.0 github.com/ipfs/go-ipfs-api v0.6.0 github.com/itchyny/gojq v0.12.12 github.com/lithammer/dedent v1.1.0 @@ -79,6 +79,7 @@ require ( github.com/bufbuild/connect-grpchealth-go v1.1.1 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/google/s2a-go v0.1.4 // indirect + github.com/iancoleman/strcase v0.2.0 // indirect github.com/mattn/go-sqlite3 v1.14.16 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect diff --git a/go.sum b/go.sum index 7851bb3b6..a0f6876ab 100644 --- a/go.sum +++ b/go.sum @@ -370,6 +370,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM= github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= +github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=