Giter VIP home page Giter VIP logo

telos-bridge's Introduction

LayerZero

LayerZero Bridge Example dApp

Deploy with Vercel Deploy to Netlify

An example LayerZero dApp built on top of next.js

Quick Start

The easiest way to create a dApp for your LayerZero tokens is to use our create-lz-app utility:

npx create-lz-app ./my-project-directory

This utility will walk you through the process of dApp configuration and will create a working Next.js application you can then deploy using e.g. Vercel or Netlify.

If want to contribute to the development of the shared packages, you can also clone this repository and run the example app (see the repository home page for more details):

# Clone the repository - this also includes reusable packages
git clone https://github.com/LayerZero-Labs/factory.git && cd factory

# Install required dependencies
yarn

# set up .env
cp .env.example .env

# After a fresh clone, you'll need to run an initial build
yarn build

# To only run the example app (on port 3009)
yarn dev --filter=bridge-app

# To also make changes to the reusable packages
yarn dev

Project Structure

The example app is organized by feature. You’ll find verticals for the fungible token bridge and non-fungible token (ONFT) bridge in the features folder, along with core pieces used in each. Within each vertical folder you’ll find stores, components, and configuration specific to that use case.

bridge-app
├── README.md
├── node_modules
├── package.json
├── tsconfig.json
├── public
│   └── static
│        └── icons
└── src
    ├── config.ts
    ├── bootstrap.tsx
    ├── features
    |  ├──core
    |  ├──bridge
    |  └──onft
    └── pages
      ├── bridge.tsx
      ├── oft.tsx
      ├── onft.tsx
      └── _app.tsx

The config file defines and exports an object of type AppConfig. This will describe every token you want to support. The bootstrap file takes that config as an input and hydrates the stores with data and apis to handle bridging all the defined assets. If you are coming from create-lz-app, your config file will contain exactly what you configured in the cli steps, or the default configuration if you chose that option.

Your bridge will be fully functional out of the box for any bridge type. We have the following Next.js pages:

  • bridge: Transfer between any valid pair of registered tokens.
  • OFT: A simplified transfer form designed to swap just one type of OFT between supported networks.
  • ONFT: Transfer ONFTs across supported networks.

You can include or delete any of these pages to customize the exact application you want to build. For information on how to simplify your repo see the relevant section below.

Creating a Fungible Token Bridge

Your configuration should include some fungible tokens, either OFTs, wrapped assets, or tokens supported by our Aptos or Stargate contracts. In this case, your bootstrapping step will set up the bridgeStore with everything it needs, including access to the supported currencies and apis to execute transfers.

If you are not interested in including an ONFT bridge, you can completely remove the onft folder, as well as the /onft page. Next you will have to remove imports from the onft folder and refrences to the onftStore in bootstrap.ts, everything should be under the heading // ONFT ERC721 & ERC1155. Once that's done, feel free to remove dependencies related to the ONFT bridge, namely @layerzerolabs/ui-bridge-onft. You will also want to delete the ONFT tab from the AppHeader component in your layout.

By default we also include an OFT page. This uses the same bridgeStore as the full transfer form, so no code needs to be removed. You may remove the /oft page and OFT tab from the layout.

Creating a simple OFT Bridge

The OFT page is a simplified version of the full transfer form. This page uses the first oft from your AppConfig and is a good choice if you are only interested in transferring one token between its supported networks.

If you are only interested in this page you may remove the onft folder, as well as the /onft page. The same bridgeStore that supports the full transfer page is used in the OFT page so it should not be modified. Similar to above, you will have to remove imports from the onft folder and references to the onftStore in bootstrap.ts, and can remove the @layerzerolabs/ui-bridge-onft dependency.

Creating a Non-Fungible Token Bridge

If your AppConfig includes any items in the onft field, the bootstrapping step will automatically configure your onftStore to support transfers of all your collections across their respective supported networks. The scaffold will also include a store and UI for bridging fungible tokens, if you don't need this you can completely remove the bridge folder, as well as the Bridge and OFT tabs from the AppHeader component in your layout. You will then have to remove imports from the bridge folder and references to the bridgeStore from bootstrap.ts, and can remove all dependencies related to fungible token bridging.

ONFT Balances Providers

To read ONFT balances for your collection you will likely need to implement your own balance provider. We recommend using a third party indexing service like Alchemy, Infura, or Simple Hash.

Your custom provider should implement the ONFTBalanceProvider interface

interface OnftBalanceProvider {
  supports(contract: OnftContract): boolean;
  getAssets(contract: OnftContract, owner: string): Promise<OnftTokenAmount[]>;
}

Where supports returns true if the contract address belongs to your collection, and getAssets should request assets from your third party integration. Once implemented, you can swap the default balance provider in bootstrap.ts to complete your configuration.

Wallet Configuration

The example app ships with support for the following wallets

  • Petra
  • Fewcha
  • Martian
  • Wallet Connect
  • Metamask
  • Phantom
  • Coinbase Wallet
  • Core
  • Pontem
  • Brave
  • PhantomEvm
  • Solflare
  • Coinbase Wallet Solana

You can enable any combination of these in the createWallet helper by adding or removing from the wallets array.

RPC Provider

The core bootstrap is where we initialize a providerFactory. In this context we're referring to rpc node providers, and the factory maps a chainId to a FailoverProvider. See the ui-evm documentation for more details, in short we connect to RPC nodes based on a weighted score, and fallback to another option in case of multiple failures.

The providerFactory is used in some the the generic store providers and is sent to the app specific bootstrapping steps.

Disclaimer

DISCLAIMER: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Deployment Links

Main Net: https://bridge.telos.net Netlify Status

Test Net: https://telos-bridge-testnet.netlify.app Netlify Status

telos-bridge's People

Contributors

dependabot[bot] avatar donnyquixotic avatar ezra-sg avatar janjakubnanista avatar kyle-layerzero avatar pmjanus avatar poplexity avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telos-bridge's Issues

Add token to wallet

Description
User should be able to seamlessly add any token in dropdown to their wallet

Brave browser wallet not detected, unable to connect

Describe the bug
Brave wallet not detected on mobile.

To Reproduce
Steps to reproduce the behavior:

  1. Go to bridge.telos.net
  2. See no wallet detected (see screenshots) and inability to connect

Expected behavior
Wallet should be detected and prompted for connection on click of Brave wallet option if using Brave browser on desktop or mobile.

Screenshots
Bridge:
Screenshot_20231030_133627_Brave.jpg
Teloscan:
Screenshot_20231030_133610_Telegram.jpg

Desktop and Mobile:

  • Browser: Brave

Additional context

  • Adding the network first by visiting Teloscan does not resolve the issue.
  • Brave is only supported on mobile atm. see telosnetwork/teloscan#544

Related Issue

Site doesn't detect metamask connection when it is on some networks (Mode, Dymension, Manta Pacific)

Describe the bug
If your wallet is using one of those three networks (maybe others) (I added them in https://chainlist.org/ selecting the top RPC on the table they give), then connect to the site as normal, the top right Connect button disappears but your wallet is not "connected" as displayed by the ui elements above the token input fields.

To Reproduce
Steps to reproduce the behavior:

  1. Set metamask to one of the mentioned networks.
  2. Click connect
  3. View UI elements, they should still say connect
  4. Change to another network such as avalanche, the wallet will be connected and ui elements update to disconnect
  5. Swap back to one of the mentioned networks and the UI elements should go back to Connect

Expected behavior
Site should detect metamask connection even on these networks, so we can give a good user experience, when they want to swap the site can prompt to change to the needed network.

Native OFT

Overview

Deploy native OFT contract for TLOS and add support for native OFT bridge transfers.

Acceptance Criteria

  1. Chain and token selection is consistent with current token bridge
  2. Bridge transfers execute successfully between all network options
  3. Transaction progress indicators & history are consistent with current token bridge
  4. Optional extra gas on destination is successfully transferred

Tasks

  • deploy & configure native OFT contract (testnet)
  • deploy & configure destination contract(s) (testnet)
  • implement UI interface & route
  • implement transfer
  • implement gas on destination
  • implement transaction progress & history
  • integrate into main bridge interface
  • release on testnet
  • update network settings for mainnet PR

Mainnet Contracts

Telos

  • Deploy
  • Verify
  • Configure

Ethereum

  • Deploy
  • Verify
  • Configure

BNB

  • Deploy
  • Verify
  • Configure

Polygon

  • Deploy
  • Verify
  • Configure

Arbitrum

  • Deploy
  • Verify
  • Configure

Avalanche

  • Deploy
  • Verify
  • Configure

Set up testnet instance

Overview

  • set up public testnet instance

Acceptance Criteria

  • set up netlify instance
  • link deployments in README
  • bridge testnet assets

Hide slippage for OFT transfers

Description

  • Slippage does not apply to OFT transfers

Solution

  • hide slippage when OFT is selected
  • (alternative) set slippage to 0

Telos Cloud Login Integration

Overview

Allow users to connect to the bridge using the telos cloud login (gmail).

Links

Acceptance Criteria

  • User can log in through their gmail account and have access to their metakeep account
  • User can bridge from their telos cloud login account

Tasks

  • Get Testing App ID
  • Setup OAUTH Service
  • Get Production App ID

Add Polygon ETH token to MetaMask wallet

Describe the bug
Unable to add Polygon ETH token to MetaMask wallet

To Reproduce
Steps to reproduce the behavior:

  1. Select Polygon and ETH
  2. Click on '+' to add token to wallet
  3. See screenshot

Expected behavior
Should add correct token to wallet

Screenshots
image_2024-02-21_17-14-52 (2)
image_2024-02-21_17-14-52

Update telos logo

Update all logo and favicons to new telos bridge logo.
Blocked while we receive the logo from Marketing.

Cannot connect wallet on mobile

Describe the bug
Cannot connect to any mobile wallet on mobile browser. It does work using the MetaMask in-app browser as it provides the injected provider. We should only display relevant options and information to the user.

To Reproduce
Steps to reproduce the behavior:

  1. Go to bridge.telos.net
  2. Click on 'Connect' (towards bottom of screen)
  3. See wallet options
  4. See nothing happen on click any option

Expected behavior
Should support all visible options (or hide until supported) prioritizing MetaMask to redirect to MetaMask browser or temporarily hide wallet options and provide information to the user directing them to the MM app.

Screenshots
If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

  • Browser: Chome/Brave

Related Issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.