onflow / kitty-items

Kitty Items: CryptoKitties Sample App
https://kitty-items.onflow.org
Apache License 2.0
408 stars 213 forks source link

Transactions cause fcl to switch currentUser to ServiceAccount (0.0.78) #225

Closed cbcomdev closed 2 months ago

cbcomdev commented 2 years ago

Note: I'm cross-posting this from https://github.com/onflow/fcl-js/issues/1017 at the request of @chasefleming

Problem

While working on a project which implements functionality from KittyItems, I noticed that transactions appeared to be forcing currentUser to automatically swap to the ServiceAccount. This is with @onflow/fcl 0.0.78, fcl-dev-wallet:0.3.1, and emulator:latest. This did not happen with fcl-js 0.0.77.

Steps to Reproduce

You will see the following warning in dev console:

You are manually enabling a very experimental feature that is not yet standard, use at your own risk.
         You can disable this warning by setting fcl.warning.suppress.redir to true in your config

You'll also see that fcl.currentUser().subscribe has updated the current user back to ServiceAccount. Additionally, you can see that even the Initialize and Mint transactions called when logged in as ServiceAccount caused the warning to fire and currentUser to swap (though, since you're logged in as ServiceAccount at the time, it doesn't impact anything).

This warning is coming from: https://github.com/onflow/fcl-js/blob/master/packages/fcl/src/current-user/index.js#L116

alse commented 2 years ago

Hey @cbcomdev, KittyItems was just updated to use @onflow/fcl:0.0.79-alpha.3 and fcl-dev-wallet:0.3.2. I couldn't reproduce the problem in the latest version, could you give it a try?