Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FLIP 316: FCL Ethereum Provider for Cross-VM Apps #317

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jribbink
Copy link

Closes #316

gasLimit: gasLimit,
value: valueBalance
)
assert(callResult.status == EVM.Status.successful, message: "Call failed")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here also fail case should be ok


/// Executes the calldata from the signer's COA
///
transaction(evmContractAddressHex: String, calldata: String, gasLimit: UInt64, value: UFix64) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if the value field may need to be UInt for consistency with EVM patterns (which would require updates to the subsequent code). Is the conversion is handled by fcl before passing as a transaction arg?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah UInt256 is better choice there

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - I copied this script from https://github.com/onflow/flow-evm-bridge/blob/main/cadence/transactions/evm/call.cdc.

I'll update the script here, but I can also make a PR to https://github.com/onflow/flow-evm-bridge, if we feel this is a better standard to use in general @bluesign @sisyphusSmiling ?

@bluesign
Copy link
Collaborator

bluesign commented Jan 4, 2025

( I don't know much of EVM wallet flow, may be totally wrong here. )

If I understood correctly, eth provider is injected after FCL login. But I think injecting provider before can be better option.

The flow I see on kitty punch, If I click login, it is popping up me a wallet selection dialog. Now if I add updated FCL I have to first login user with non-evm Flow Wallet to have provider in this list. ( I may be wrong on this assumption, but it seems provider is created on current user )

I think it may be better, if provider is in this list ( as we detect in discovery ) let's say BlueWallet ( hypothetical non-erm flow wallet extension ) and another provider maybe something like ( Other Flow Wallets ) which redirects to discovery.

So when I click BlueWallet it can directly authenticate with FCL ( extension pop up ) and I can use it transparently. ( via just initializing FCL )

@jribbink
Copy link
Author

jribbink commented Jan 4, 2025

( I don't know much of EVM wallet flow, may be totally wrong here. )

If I understood correctly, eth provider is injected after FCL login. But I think injecting provider before can be better option.

The flow I see on kitty punch, If I click login, it is popping up me a wallet selection dialog. Now if I add updated FCL I have to first login user with non-evm Flow Wallet to have provider in this list. ( I may be wrong on this assumption, but it seems provider is created on current user )

I think it may be better, if provider is in this list ( as we detect in discovery ) let's say BlueWallet ( hypothetical non-erm flow wallet extension ) and another provider maybe something like ( Other Flow Wallets ) which redirects to discovery.

So when I click BlueWallet it can directly authenticate with FCL ( extension pop up ) and I can use it transparently. ( via just initializing FCL )

Thank you for the feedback @bluesign and I can clarify a bit on the timing of the provider creation.

fcl.currentUser() is a singleton describing the current wallet session that represents either an authenticated or unauthenticated state. (e.g. it is not a requirement that the user has already logged in).

Apologies if it's not clear in the proposal, but the intended use is actually as you describe: the provider is supposed constructed before the user has authenticated with FCL.

So for the KittyPunch/"Blue Wallet" example, it would be as follows:

  1. Wallet-specific FCL Ethereum providers are created during the setup (these services would be fetched from FCL Discovery).
    - e.g. const bwProvider = fcl.currentUser().createEthereumProvider({...blueWallet})
  2. These wallet-specific providers are now used to configure EVM wallet connectors for whatever library is used by the dApp. For Kitty Punch, ThirdWeb is used, so the for instance adding FCL wallets may look something like:
    // This adapter will instantiate providers using `fcl.currentUser().createEthereumProvider(...)
    import {useFclWallets} from "@onflow/fcl-thirdweb-adapter"
    
    const fclWallets = useFclWallets() // includes all wallets from FCL Discovery (e.g. Flow Wallet, Blocto, NuFi...)
    <ThirdwebProvider
          supportedWallets={[
           ...fclWallets,
           ...anyOtherEvmWallets
          ]}
    >
    (obviously exact syntax may vary, but critically, the dev would include FCL using an adapter/plugin)
  3. The user would authenticate with the FCL wallet through the exact same "Connect Wallet" modal. When a user chooses "Blue Wallet" here, they're actually interacting with the FCL Ethereum Provider
    (thirdweb connect -> eth_requestAccounts for FCL Ethereum provider -> fcl.authenticate)

I'll see if I can make some diagrams & add a better description to make this more clear.

@bluesign
Copy link
Collaborator

bluesign commented Jan 5, 2025

thanks @jribbink for this is great explanation. It all makes sense now, I think this is a great idea and very useful for filling the current gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FCL Ethereum Provider for Cross-VM Apps
3 participants