Skip to content

Commit

Permalink
Made some fixes for Starknet code generation
Browse files Browse the repository at this point in the history
Based on Influence.eth ABIs.

Fixes:
1. Handle `core::starknet::class_hash::ClassHash` as a string.
2. Ignore `@` symbols before type definitions in ABI.
  • Loading branch information
zomglings committed Feb 1, 2024
1 parent bf3c041 commit 2a26e10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions starknet/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var resultEventParserKey string = "-eventparser"
// Qualified names for Starknet ABI items are of the form:
// `core::starknet::contract_address::ContractAddress`
func GenerateGoNameForType(qualifiedName string) string {
qualifiedName = strings.TrimPrefix(qualifiedName, "@")
if strings.HasPrefix(qualifiedName, "core::integer::u") {
bitsRaw := strings.TrimPrefix(qualifiedName, "core::integer::u")
bits, bitsErr := strconv.Atoi(bitsRaw)
Expand All @@ -78,6 +79,8 @@ func GenerateGoNameForType(qualifiedName string) string {
s1, _ := strings.CutPrefix(qualifiedName, "core::array::Array::<")
s2, _ := strings.CutSuffix(s1, ">")
return fmt.Sprintf("[]%s", GenerateGoNameForType(s2))
} else if qualifiedName == "core::starknet::class_hash::ClassHash" {
return "string"
}

components := strings.Split(qualifiedName, "::")
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package version

var SeerVersion string = "0.0.5"
var SeerVersion string = "0.0.6"

0 comments on commit 2a26e10

Please sign in to comment.