flow-playground icon indicating copy to clipboard operation
flow-playground copied to clipboard

'panic' function on borrowed capability causes some resources not to show up in resources explorer in playground

Open hichana opened this issue 4 years ago • 3 comments

The new Playground UI with expanded resources explorer functionality should display all account storage items for any given account. The new functionality works, but somehow when the 'panic' function is applied to a borrowed capability it causes some resources not to show up in account storage.

Steps to reproduce:

  1. fork the following playground: https://play.onflow.org/7c60f681-40c7-4a18-82de-b81b3b6c7915?type=account&id=0
  2. click on the storage icon next to account 0x01, notice storage is empty
  3. deploy the 'ExampleToken' contract
  4. notice that account 0x01's storage is still empty

Now, on a new fork of the playground link before step 2, remove line 146 (the panic), and then on line 145 add a force unwrap operator, ex let recipientRef = recipient.borrow()!. Deploy and watch how account storage shows the 'Minter', 'MainMinter' and 'MainVault' resources properly.

hichana avatar Nov 12 '21 20:11 hichana

This one is a great issue, @hichana did you find out the reason ? If not I will debug this one.

bluesign avatar Nov 16 '21 08:11 bluesign

Hi @bluesign I didn’t find out the reason unfortunately. @MaxStalker helped me uncover it as I was building the new resources explorer, so he might have some insights.

hichana avatar Nov 16 '21 09:11 hichana

Seems problem with executeNonProgram which doesn't have access to builtins. I wrote about this before: https://github.com/onflow/flow-playground/issues/158#issuecomment-881869616

I think same workaround although ugly can work here.

I think also can be fixed in cadence side, actually executeNonProgram should provide builtins I guess ( as Value depends on 'on demand contract loading' ) @turbolent

bluesign avatar Nov 16 '21 13:11 bluesign

Appears to be fixed in the latest build:

image

alse avatar Sep 15 '22 17:09 alse