cadence icon indicating copy to clipboard operation
cadence copied to clipboard

`account.type(at: path)` should not crash when path is set by an outdated contract

Open cybercent opened this issue 2 years ago • 4 comments

Issue to be solved

Users will interact with different contracts in the lifetime of their account and some of those contacts might lag to update to latest Cadence or are left dead.

Currently, there is a crash when reading the account.type(at: path) set by a contract that is out of date.

Suggested Solution

Return the type without loading the broken contract.

cybercent avatar Aug 14 '23 12:08 cybercent

Might be solved by rent fixes to storage iteration.

j1010001 avatar Sep 11 '23 16:09 j1010001

We should probably handle this function just like we do storage iteration, i.e. return an "invalid type", instead of aborting the transaction.

@cybercent Where are you running into this? How important is this to you?

turbolent avatar Sep 11 '23 16:09 turbolent

I'm iterating over paths on various accounts, in order for the script not to break I'm forced to manually ignore the paths set by contracts that are outdated.

I get into a similar issue when reading data from contracts that force unwrap optionals when the expected data is not there. Many flow contracts wrongly force-unwrap optionals in their own data structures without first checking the data is there so MetadataViews break. These are "quality" projects like MotoGP, Titles etc, not NFT "test contracts".

So maybe one way to handle this is to add a try/catch to Cadence that would work on scripts but not work on transactions.

cybercent avatar Sep 18 '23 14:09 cybercent

might be fixed in C1.0, would need to check

j1010001 avatar Nov 01 '24 18:11 j1010001