-
Notifications
You must be signed in to change notification settings - Fork 108
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
starknet_getCompiledCasm #642
base: v0.8.0
Are you sure you want to change the base?
Conversation
type CasmCompiledContractClass struct { | ||
EntryPointsByType CasmEntryPointsByType `json:"entry_points_by_type"` | ||
ByteCode []*felt.Felt `json:"bytecode"` | ||
Prime []*felt.Felt `json:"prime"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not NumAsHex for prime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, thanks!
ByteCode []*felt.Felt `json:"bytecode"` | ||
Prime []*felt.Felt `json:"prime"` | ||
CompilerVersion string `json:"compiler_version"` | ||
Hints Hints `json:"hints"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be [2]Hints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did that because hints
is a tuple of [intenger, []hint] and Golang doesn't allow an array of multiple types. So I created a struct having these two fields and two helper methods for getting the values: the Values()
that returns both values the way Golang usually does (int, []Hint) and the Tuple()
that returns an [2]any
array in case someone needs it in this format
@@ -16,3 +19,18 @@ func UnwrapJSON(data map[string]interface{}, tag string) (map[string]interface{} | |||
} | |||
return data, nil | |||
} | |||
|
|||
func GetTypedFieldFromJSON[T any](data map[string]interface{}, tag string) (T, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using it in previous commits but not now, I'll remove it then
func (hints *Hints) Values() (int, []Hint) { | ||
return hints.Int, hints.HintArr | ||
} | ||
|
||
func (hints *Hints) Tuple() [2]any { | ||
return [2]any{hints.Int, hints.HintArr} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these functions for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered here
#623
This PR aims to implement some RPC v0.8.0 updates to starknet.go. The ones addressed by this PR are:
Methods
starknet_getCompiledCasm
Components
CASM_COMPILED_CONTRACT_CLASS
CASM_ENTRY_POINT
CellRef
Deref
DoubleDeref
Immediate
BinOp
ResOperand
HINT
DEPRECATED_HINT
CORE_HINT
STARKNET_HINT
Errors
COMPILATION_ERROR
Note: As the RPC v0.8.0 has not yet been released, we can't fully test these changes as the nodes haven't implemented them yet. They will be updated before merging into main
Also, there's the creation of a new utility to get a typed field from a map representing a JSON