Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with arrays of 252-bit field elements in "seer starknet generate" #16

Open
zomglings opened this issue Feb 27, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@zomglings
Copy link
Contributor

When generating code from this Dojo ABI: https://raw.githubusercontent.com/dojoengine/dojo/5a1176e8b00e11101410bda889c854bc5bef76d5/examples/spawn-and-move/abis/base/models/moves.json

All the ..._Felt252 types are buggy.

// Core_Array_Span_core_Felt252Core_Array_Span_core_Felt252 is the Go struct corresponding to the core::array::Span::<(core::felt252, core::array::Span::<core::felt252>)> struct.
type Core_Array_Span_core_Felt252Core_Array_Span_core_Felt252 struct {
	Snapshot []core_Felt252Core_Array_Span_core_Felt252
}

// ParseCore_Array_Span_core_Felt252Core_Array_Span_core_Felt252 parses a Core_Array_Span_core_Felt252Core_Array_Span_core_Felt252 struct from a list of felts. This function returns a tuple of:
// 1. The parsed Core_Array_Span_core_Felt252Core_Array_Span_core_Felt252 struct
// 2. The number of field elements consumed in the parse
// 3. An error if the parse failed, nil otherwise
func ParseCore_Array_Span_core_Felt252Core_Array_Span_core_Felt252(parameters []*felt.Felt) (Core_Array_Span_core_Felt252Core_Array_Span_core_Felt252, int, error) {
	currentIndex := 0
	result := Core_Array_Span_core_Felt252Core_Array_Span_core_Felt252{}

	value0, consumed, err := ParseArray[core_Felt252Core_Array_Span_core_Felt252](Parsecore_Felt252Core_Array_Span_core_Felt252)(parameters[currentIndex:])
	if err != nil {
		return result, 0, err
	}
	result.Snapshot = value0
	currentIndex += consumed

	return result, currentIndex, nil
}
@zomglings zomglings added the bug Something isn't working label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant