F
Flow4mo ago
Bohao

Bohao | Flow (2024-08-16)

[C1.0] Is it possible to have a safe way (no panic) to check if the resource is upgraded?
// I have an arbitrary StoragePath here, and I can also get a corresponding Type.
let unsafeType = account.storage.type(at: path) // No problem for this line.
// But once we compare this type, if its corresponding contract is not upgraded, a panic error will be occurred
let isResource = unsafeType.isSubtype(of: anySafeTypeLikeFTorNFTInterface) // <- Panic!
// I have an arbitrary StoragePath here, and I can also get a corresponding Type.
let unsafeType = account.storage.type(at: path) // No problem for this line.
// But once we compare this type, if its corresponding contract is not upgraded, a panic error will be occurred
let isResource = unsafeType.isSubtype(of: anySafeTypeLikeFTorNFTInterface) // <- Panic!
Do we have any way to figure out if this unsafeType is safe to execute? If the answer is no, many scripts/transactions related to storageAPI will not be able to use...
9 Replies
Needle
Needle4mo ago
I've created a thread for your message. Please continue any relevant discussion in this thread. You can rename this thread using /title <new title> If this is a technical question that others may benefit from, considering also asking it on Stackoverflow: https://stackoverflow.com/questions/ask?tags=onflow-cadence
Bohao
BohaoOP4mo ago
I came up with a temporary solution. Extract all contracts that have successfully staged from the MigrationContractStaging contract as a whitelist, and then filter by Type. Is there a lower cost method? Oh no, new deployed not included for the whitelist...
joshua
joshua4mo ago
I think once this FLIP(https://github.com/onflow/flips/pull/283) is fully implemented, it will be easy because you can check the types to see if they are recovered
joshua
joshua4mo ago
GitHub
Add Type.isRecovered field by turbolent · Pull Request #3505 · on...
Work towards #3480 Description Feedback on onflow/flips#283 has been that it would be great to have a way to determine if a type (of a value) has been recovered, i.e. if the type was defined in a r...
Bohao
BohaoOP4mo ago
Looks great! Can it be merged before mainnet Crescendo upgrade and updated on testnet? Because without this, many scripts and transactions related to StorageAPI will be crashed. cc @turbolent
joshua
joshua4mo ago
Bastian is OOO right now. @Supun | Cadence might know
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Jan
Jan4mo ago
I think we should include this. @Supun | Cadence how risky would you say this change is ?
Unknown User
Unknown User4mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server