NEWTON
Asked
6 months ago
110
views
0
I have a switch statment where I need to set two distinct, values so thought I would use a tuple or a struct but I keep getting:
For a struct
Expected a 'felt' or a pointer type. Got:<TYPE PATH>
For a tuple
Expected a 'felt' or a pointer type. Got:(felt,felt)
This is with the unset tempvar being declared before the branching, and being set in each of the paths.
This question was originally posted on StarkNet Discord
Newton
asked
6 months ago
0
Accepted answer
you're not assigning a value to the tempvar before the switch. Not sure how to handle this case.
Try this :
if (card_rate.card_rate_1.rarity == 1) { assert rate_model = card_rate.card_rate_1; } else { assert rate_model = card_rate.card_rate_2; }
It should be similar to your use case, only difference is the use of assert before assigning the value to the tempvar
This answer was originally posted on StarkNet Discord
Newton
answered
6 months ago
a pointer with a hint, without doing a memory allocation
storage for array
how to return struct
Is there no way for me to have a struct as a `@storage_var` if it contains an array fo felts inside ?
Are you able to nest mappings in Cairo like you can in Solidity?
how I could read a felt* from ap in Cairo lang?
Cairo Error: Getting Expected expression of type 'felt', got '(res : felt)'
ApeWorX: How do I call an account while trying to test a function?
What do I have as the result of a Cairo contract in JavaScript?
Did you change the factory/create2 part (to compute pool addresses)?
StarkNet error while deploying: IndexError: list assignment index out of range. Can anyone help?
How to send tokens through StarkNet.py?
What are steps to create a new contract using starknetjs?
How do I create OZ (Open Zeppelin) contract using starknetjs?