Skip to content

Need a way to force delete resources #2170

@aishairzay

Description

@aishairzay

Issue To Be Solved

Resources on cadence should be deletable regardless of if they're loadable.

For example, please reference the following TX:

transaction(
) {
    prepare(acct: AuthAccount) {
      let resource <- acct.load<@AnyResource>(from: /storage/ZayTraderCollection)
      destroy resource
    }
}

You'll see i am loading in storage from ZayTraderCollection as an @AnyResource and trying to destroy it.

This TX fails like the following in TX ID run from my 0x4bcda1de73a17d95 account. flow -n mainnet transactions get d7bb1b5afec90995489a0bf0d36e1c275b546b696c2350f3fb28e0d5ed421986

❌ Transaction Error 
[Error Code: 1101] error caused by: 1 error occurred:
	* transaction invocation failed when executing transaction: [Error Code: 1101] cadence runtime error: Execution failed:
error: Checking failed:
error: mismatched types
   --> 6c4fe48768523577.SchmoesNFT:131:20

error: cannot find variable in this scope: `SchmoesNFT`
   --> 99e68982576033cf.ZayTrader:654:36

error: cannot find type in this scope: `SchmoesNFT`
   --> 99e68982576033cf.ZayTrader:655:35

error: cannot infer type parameter: `T`
   --> 99e68982576033cf.ZayTrader:655:29

error: cannot find variable in this scope: `SchmoesNFT`
   --> 99e68982576033cf.ZayTrader:870:36

error: cannot find type in this scope: `SchmoesNFT`
   --> 99e68982576033cf.ZayTrader:871:35

error: cannot infer type parameter: `T`
   --> 99e68982576033cf.ZayTrader:871:29

error: mismatched types
   --> 99e68982576033cf.ZayTrader:927:24

 --> d7bb1b5afec90995489a0bf0d36e1c275b546b696c2350f3fb28e0d5ed421986:4:6
  |
4 |       let resource <- acct.load<@AnyResource>(from: /storage/ZayTraderCollection)
  |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This error is coming because the resource that's in my account was not updated for secure cadence, and will be a lot more relevant with any future changes to cadence (stable cadence, etc)

Suggested Solution

Along with implementing try/catch as mentioned here (#1990) to help on the read side of things, we also need a way to force delete these things from a TX level to clean up an account. Either the above TX I pasted should be made to work somehow, or we need a new command for it, because in the current state, my account and others are unable to use any DAPPs that have storage iteration due to the old resource being stuck in my account.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions