From 47982e79ad134fcb226e86dcd28f92ec1cdc3dfe Mon Sep 17 00:00:00 2001 From: Neeraj Kashyap Date: Sun, 14 Jan 2024 18:07:57 -0800 Subject: [PATCH] Updated seer starknet generate to understand new bit sizes --- starknet/generators.go | 10 ++++++++-- version/version.go | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/starknet/generators.go b/starknet/generators.go index 062660c..3514eeb 100644 --- a/starknet/generators.go +++ b/starknet/generators.go @@ -3,6 +3,7 @@ package starknet import ( "bytes" "fmt" + "strconv" "strings" "text/template" @@ -53,13 +54,18 @@ type HeaderParameters struct { // Qualified names for Starknet ABI items are of the form: // `core::starknet::contract_address::ContractAddress` func GenerateGoNameForType(qualifiedName string) string { - if qualifiedName == "core::integer::u8" || qualifiedName == "core::integer::u16" || qualifiedName == "core::integer::u32" || qualifiedName == "core::integer::u64" { + if strings.HasPrefix(qualifiedName, "core::integer::u") { + bitsRaw := strings.TrimPrefix(qualifiedName, "core::integer::u") + bits, bitsErr := strconv.Atoi(bitsRaw) + if bitsErr != nil || bits > 64 { + return `*big.Int` + } return "uint64" } else if strings.HasPrefix(qualifiedName, "core::integer::") { return `*big.Int` } else if qualifiedName == "core::starknet::contract_address::ContractAddress" { return "string" - } else if qualifiedName == "core::felt252" { + } else if strings.HasPrefix(qualifiedName, "core::felt25") { return "string" } else if strings.HasPrefix(qualifiedName, "core::array::Array::<") { s1, _ := strings.CutPrefix(qualifiedName, "core::array::Array::<") diff --git a/version/version.go b/version/version.go index 7ae823e..71a61e1 100644 --- a/version/version.go +++ b/version/version.go @@ -1,3 +1,3 @@ package version -var SeerVersion string = "0.0.1" +var SeerVersion string = "0.0.2"