Skip to content

Conversation

mfbz
Copy link
Contributor

@mfbz mfbz commented Jul 15, 2025

Closes #2591

@mfbz mfbz requested a review from a team as a code owner July 15, 2025 16:55
Copy link

changeset-bot bot commented Jul 15, 2025

🦋 Changeset detected

Latest commit: 4175aab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@onflow/react-sdk Minor
@onflow/demo Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jul 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-sdk-demo Canceled Canceled Oct 20, 2025 10:08pm

💡 Enable Vercel Agent with $100 free credit for automated AI reviews

@mfbz mfbz changed the title Mfbz/hook ft evm to cadence Added hook to move tokens from evm to cadence Jul 16, 2025
Base automatically changed from feature/components to release/july July 16, 2025 17:04
@jribbink jribbink force-pushed the release/july branch 2 times, most recently from ecfd844 to e1393ed Compare July 25, 2025 00:08
Base automatically changed from release/july to master July 25, 2025 02:47
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new React hook useCrossVmReceiveToken to enable transferring fungible tokens from EVM to Cadence on the Flow blockchain. The hook provides a user-friendly interface for bridging ERC20 tokens to their corresponding Cadence vault equivalents.

  • Added useCrossVmReceiveToken hook with comprehensive Cadence transaction logic for cross-VM token bridging
  • Implemented comprehensive test coverage for both successful and error scenarios
  • Created demo UI component with form inputs and transaction status display

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/react-sdk/src/hooks/useCrossVmReceiveToken.ts Core hook implementation with Cadence transaction generation
packages/react-sdk/src/hooks/useCrossVmReceiveToken.test.ts Unit tests covering various scenarios and edge cases
packages/react-sdk/src/hooks/index.ts Export declaration for the new hook
packages/demo/src/constants.ts Added ClickToken contract address for testnet
packages/demo/src/components/container.tsx Integration of new demo component
packages/demo/src/components/cards/cross-vm-receive-token-card.tsx Interactive demo UI for testing the hook
.changeset/chilly-kangaroos-train.md Changeset documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const clickTokenAddress = getContractAddress("ClickToken", currentNetwork)
return {
name: "ClickToken",
vaultIdentifier: `A.${clickTokenAddress.replace("0x", "")}.EVMVMBridgedToken_a7cf2260e501952c71189d04fad17c704dfb36e6.Vault`,
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

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

The hard-coded token identifier EVMVMBridgedToken_a7cf2260e501952c71189d04fad17c704dfb36e6 contains what appears to be a magic value. Consider extracting this to a constant or making it configurable to improve maintainability.

Suggested change
vaultIdentifier: `A.${clickTokenAddress.replace("0x", "")}.EVMVMBridgedToken_a7cf2260e501952c71189d04fad17c704dfb36e6.Vault`,
vaultIdentifier: `A.${clickTokenAddress.replace("0x", "")}.${EVM_VM_BRIDGED_TOKEN_IDENTIFIER}.Vault`,

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, but hardcoded just for the sake of running the demo

//
// Set a cap on the withdrawable bridge fee
var approxFee = FlowEVMBridgeUtils.calculateBridgeFee(
bytes: 400_000 // 400 kB as upper bound on movable storage used in a single transaction
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

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

The magic number 400_000 for calculating bridge fees should be extracted to a named constant to improve code maintainability and make it easier to adjust if needed.

Suggested change
bytes: 400_000 // 400 kB as upper bound on movable storage used in a single transaction
let BRIDGE_FEE_UPPER_BOUND_BYTES = 400_000 // 400 kB as upper bound on movable storage used in a single transaction
var approxFee = FlowEVMBridgeUtils.calculateBridgeFee(
bytes: BRIDGE_FEE_UPPER_BOUND_BYTES

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, but hardcoded just for the sake of running the demo

self.scopedProvider <- ScopedFTProviders.createScopedFTProvider(
provider: providerCapCopy,
filters: [ providerFilter ],
expiration: getCurrentBlock().timestamp + 1.0
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

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

The expiration time of 1.0 seconds is a magic number that should be extracted to a named constant for better maintainability and clarity of intent.

Suggested change
expiration: getCurrentBlock().timestamp + 1.0
expiration: getCurrentBlock().timestamp + SCOPED_FT_PROVIDER_EXPIRATION_SECONDS

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, but hardcoded just for the sake of running the demo

*
* @returns The mutation object used to send the transaction.
*/
export function useCrossVmReceiveToken({
Copy link
Member

Choose a reason for hiding this comment

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

Same question on naming from the other pr.

@mfbz mfbz changed the title Added hook to move tokens from evm to cadence Add useBridgeTokenFromEvm hook Oct 2, 2025
Copy link

vercel bot commented Oct 20, 2025

Deployment failed with the following error:

Failed to create deployment for team_odoxRGdrzIzasFJE67wM7Gzm in project prj_Sm8VPqaAfgcYJQgrSl9OaRcqkiFR: FetchError: request to https://76.76.21.112/v13/now/deployments?ownerId=team_odoxRGdrzIzasFJE67wM7Gzm&projectId=prj_Sm8VPqaAfgcYJQgrSl9OaRcqkiFR&skipAutoDetectionConfirmation=1&teamId=team_odoxRGdrzIzasFJE67wM7Gzm&traceCarrier=%7B%22ot-baggage-webhookAt%22%3A%221760990675366%22%2C%22ot-baggage-senderUsername%22%3A%22gh.mfbz%22%2C%22baggage%22%3A%22webhookAt%3D1760990675366%2CsenderUsername%3Dgh.mfbz%22%2C%22x-datadog-trace-id%22%3A%227393282319159151552%22%2C%22x-datadog-parent-id%22%3A%228951854390054108791%22%2C%22x-datadog-sampling-priority%22%3A%222%22%2C%22x-datadog-tags%22%3A%22_dd.p.tid%3D68f695d300000000%2C_dd.p.dm%3D-3%22%2C%22traceparent%22%3A%2200-68f695d300000000669a371915a84bc0-7c3b602388323e77-01%22%2C%22tracestate%22%3A%22dd%3Dt.tid%3A68f695d300000000%3Bt.dm%3A-3%3Bs%3A2%3Bp%3A7c3b602388323e77%22%7D failed, reason: socket hang up

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.

Create hook to transfer tokens from evm to cadence

3 participants