-
Notifications
You must be signed in to change notification settings - Fork 180
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
Investigate if we should keep Declare
cheatcode
#82
Comments
Interesting point @cptartur and @MaksymilianDemitraszek. I would also tend to say that, declare can be implicit since it's not a starknet syscall and it's not a logic someone can implement in a contract. On-chain, we cannot test for something declared or not and only class_hash is used, no contract names. It just panic if we provide an undeclared class hash. Which can be tested easily by providing a random value for a class hash. Also, the hard limitation I see with As you mentioned @cptartur, what then can be the better UX to get this class hash back from code. As we will again have the 31 chars limitation (until long strins). But waiting the long string, we can have a // One can pass a valid class hash, or a short string with cairo contract name
// and we lookup first if the short string match a contract name?
// This avoid having an other field contract_name to init...
let prepared = PreparedContract {
class_hash: 'MyContract',
constructor_calldata: @ArrayTrait::new()
};
let contract_address = deploy(prepared).unwrap();
assert(get_class_hash_from_name('MyContract') == get_class_hash(contract_address)); This removes the An other approach, do you think we can use a search/replace in the code to inject the class hash where a use may require it? I have to review the exact path of starknet foundry handles the files, but if we load them as But this then introduces an other semantic and I'm not sure if it's the way to go. Here is an example of what it can look like: let class_hash = __SNFORGE_CLASS_HASH__(MyContract);
// ... |
After we introduce state forking somebody may be willing to deploy contracts that they may not have deployed themselves, IMO it is better to keep it consistent. I thought about a UX using a compiler plugin and dispatchers so class hash can be extracted from dispatcher static field
|
With the changes introduced in #433
I'm not sure about this UX wise. Since short strings get evaluated to felt values anyways, I'm not sure if it would be possible to distinguish if user passed a name of the contract or the value. This could be done with adding separate constructing methods to the
The files are compiled to sierra by scarb at an very early stage and then we are dealing with the compiled artefacts. Preprocessing like that would be possible but it would have to be added as an step before scarb compilation. |
software-mansion/protostar#2170
@MaksymilianDemitraszek suggested that we should remove
declare
cheatcode entirely, and implicitly declare all contracts from the project when running a test runner.This might be a good approach, but there are some open questions:
The text was updated successfully, but these errors were encountered: