Giter Club home page Giter Club logo

sygma-widget's Introduction

Sygma Widget UI

The Sygma Widget is a customizable frontend that leverages the Sygma protocol and can be integrated into any Dapp regardless of the framework used. More information can be found in our docs

This repository is divided into two packages. The Widget package is a web component built using Lit framework that allows you to have a widget for the Sygma protocol project. The React package is a wrapper around the Lit Widget that allows developers to use this application inside react projects.

Quick setup

yarn create vite my-dapp --template react-ts
cd ./my-dapp
yarn install
yarn add @buildwithsygma/sygmaprotocol-react-widget
yarn dev

How to integrate

Check respective READMES to follow instructions on how to integrate the Widget into your codebase.

  • for web component based projects, you can directly install, import and use the Widget. You can find further instructions here
  • for React based projects, please refer to this README file to get further instructions
  • a react example is provided here for a more detailed reference
  • a vanilla example is provided here for a more detailed reference on a bare bones implementation

Configuration through props

You can pass props to the Widget to customize the behaviour of the Widget. You can find the complete reference of the properties avialable here. Below there is an example passing props to whitelist the source and destination network in the react component:

import { SygmaProtocolReactWidget } from "@buildwithsygma/sygmaprotocol-react-widget";

function MyDapp() {
  return (
    <SygmaProtocolReactWidget
      whitelistedSourceNetworks={["sepolia"]}
      whitelistedDestinationNetworks={["cronos"]}
    />
  );
}

sygma-widget's People

Contributors

wainola avatar mpetrunic avatar makmuftic avatar lykhoyda avatar saadjhk avatar fsm1 avatar mj52951 avatar sztok7 avatar haochizzle avatar

Stargazers

Aleksandr Beliaev avatar  avatar  avatar  avatar  avatar

Watchers

Priom Chowdhury avatar  avatar  avatar Freddy Li avatar David Ansermino avatar  avatar Tanya Bushenyova avatar  avatar  avatar

Forkers

nownosw omkark97

sygma-widget's Issues

Create network dropdown selectors

We need to create the dropdown network selectors according to design.

Implementation details

  • render of the network list is dependable on the shared config - or our supported networks-.
  • component receives reactive property from parent that will handle the state changes
  • component should have property that display the default home network if wallet is connected
  • follow style defined in figma

Testing details

Acceptance Criteria

  • component should display a dropdown with options and be able to display the selected one

Externalize walletconnect configuration

Implementation details

Currently wallet connect configuration is hardcoded, make sure widget user can pass wallet connect options. If at least projected for wallet connect is submitted, enable wallet connect!

Testing details

Acceptance Criteria

Display fee

Story

As a bridge user, I want to know which fees I will be paying to bridge tokens.

Background

The fee, as well as the token the fee is charged in should be displayed.

Details

Screenshot is provisional
image

Testing details

Test both Fixed and Percentage fee

Acceptance criteria

Fee and FeeToken are displayed correctly.

Ability to click and copy connected wallet

Implementation details

When clicking connected wallet address, it should copy to clipboard and notify user that it copied.
Connected wallet address component should indicate that it's clickable

Testing details

Acceptance Criteria

Transfer Action Button Component

Implementation details

We need button that has multiple states, including loading and disabled state.

States:
image
image
image
image
image

Testing details

Acceptance criteria

Create Wallet Manager Package

Transfer widget will require connection logic with the providers that it receives, so then it can be connected to the current wallet to check balances and account data

Implementation details

  • Create wallet manager package
  • Package should provide means to connect to Evm or Substrate wallets.
  • For EVM, connection to Metamask would suffice for the MVP. For Substrate, polkadot.js
  • Provide logic to handle connection and get basic information about the connected account: address and balance
  • For susbtrate connection, use app-injector to communicate with polkadot.js extension
  • For susbtrate, wallet class must be able to accept ApiPromise instance to work

Testing details

  • provide unit tests for this package

Acceptance Criteria

  • create unit test for the package. Add those to the pipeline
  • pipeline for building and linting should also pass

filter source/dest network on network selection (inside WidgetController)

"filter source/dest network on network selection (inside WidgetController)"

Description
In sygma bridge, there may not be a route for every combination of source/destination networks. So when the user selects the source network, we should use sygma SDK to fetch available destination networks for this source network.

Css refactor

Implementation details

  • change css to adopt BEM/kebab case for classes
  • convert units to rem
  • remove fixed dimensions

Testing details

Acceptance Criteria

Network selector component

  • start branch from #62
  • add styling according to design
  • filter source/dest network on network selection (inside WidgetController)
  • render network icons

Theming and customization of the Widget

Define properties and elements that are going to be customizable for the Widget

Implementation details

  • provide theme and means to customize it via props definition as it's defined in the spec definition

Testing details

  • Test if Widget is able to be customize passing props defined in the tech specification

Acceptance Criteria

  • Widget render default view with base theme
  • Widget UI interface changes according to props being passed

Add link to Sygma Explorer after deposit is created

Implementation details

  • Once deposit is submited add link to Explorer UI to track status of the transaction

Testing details

Acceptance Criteria

  • once deposited, link to the Explorer UI should lead to the detail view

Create React package

Lit allows us to wrap our web component into a react one. Hence, in a different package we can define a react component to be used for react frontends, for ease of use.

Implementation details

  • create package that imports Lit widget and wraps it into a react component
  • provide unit test of the react component working properly
  • create "examples" directory in the root of the repo and add it to the workspaces
  • in examples directory create simple example nextjs app and install sygma react widget inside

Testing details

  • imported react component is able to render on basic react app

Acceptance Criteria

  • widget example using react component

Retry and loading for getting bridge routes

Implementation details

Without bridge routes, we cannot do much in the widget. I would propose to retry infinitely and present full widget loading until we finally fetch routes (API has hardcoded values so only way this would fail if user doesn't have internet connection)

Testing details

Acceptance Criteria

Workflow to deploy to cloudflare pages

Implementation details

  • setup GA workflow to deploy widget package to cloudflare pages
  • workflow must implement very minimal UI that uses both packages for QA testing
  • modify release workflows to also publish to cloudflare as we do with Explorer UI

Nit: GA actions and deploy could be one instead of two distinctive ones. Implementation of the small UI is responsible to handle how to implement the built packages ie: having either one view with both or using one react view and calling the lit web component and the react component

Testing details

Acceptance Criteria

  • pipeline is able to publish widget and react widget on cloudflare space as per opening PR

Resource amount input + type selector

Implementation details

  • provide styling from figma
  • resources should be filtered based on src/dest networks
    • resource selector should be disabled until both networks are selected
  • on resource selected, wallet balance should be presented
    • refresh balance periodically
  • display warning if input amount is greater than balance (but don't prevent transfer as we might have wrong balance)
  • implement logic for "useMax" button

Testing details

Acceptance Criteria

Fix workflows

Implementation details

  • remove uneccesarry lint step
  • minor corrections on workflows

Testing details

Acceptance Criteria

Create transfer status component

Implementation details

  • should be implemented according to latest design :)

Testing details

Acceptance Criteria

  • component renders messages and progress according to some stage and messages defined

Create SDK Manager package: Evm to Evm

Transfer widget must use Sygma SDK and hence provide the means to call the SDK methods

Implementation details

  • Create logic that integrates SDK to this package.
  • Create interfaces to call the relevant methods to perform a transfer.
  • package should return updates on the state of the transfer
  • provide means to hook to the events for the transfer and return updates to be displayed on the UI
  • provide unit test for it

Testing details

  • upon connection to the provider and type of connection selected, one of the current asset transfers are created
  • in isolation package is able to perform a evm to evm

Acceptance Criteria

  • test are passing on pipeline
  • using the package, we are able to make a evm to evm transfer

Create address to transfer component

Implementation details

  • by default it transfer to the same address that the wallet is connected, if destination chain is Evm based
  • if destination chain is not Evm, toggle should not be rendered
  • if toggle is active, input to add the address should be render
  • we should apply styles defined in figma

Testing details

Acceptance Criteria

  • if toggle is active, input must be displayed

Run unit tests in browser

We are currently running tests in jsdom but it seems like it's not supporting all features like actual browser. For example substrate address checksum doesn't work. We are currently running in happy-dom but ideally we wanna setup vitest to run in actual browser.

Only blocker seems to be sygma-contracts which has some non-browser deps as prod dependencies.

Display token balance once token is selected

Implementation details

  • Once token is selected display the balance
  • add max option to the layout of the component

Testing details

Acceptance Criteria

  • amount component should display balance upon being selected
  • max option is clickable and it sets out the max amount for the token

Widget Loader

Implementation details

  • design is pending so just create some overlay and gif,
  • it should display whenever some async task is being done

Testing details

Acceptance Criteria

Create Amount to Transfer component

Implementation details

  • component should display both value or amount to tranfer and dropdown selector with the tokens available to select
  • token list depends of resources per network defined in the shared config

To define:

  • display transaction fee
  • display price impact
  • display amount to receive on destination network

Testing details

Acceptance Criteria

  • upon token selection, user is able to select amount to transfer

Destination address not submitted until you click outside

Expected Behavior

It should submit address for validation if there isn't new input for 500ms (or some other constant)

Current Behavior

Nothing happens until you click outside of text area

Possible Solution

Steps to Reproduce (for bugs)

Version

Sygma commit (or docker tag):
sygma-solidity version:
sygma-substrate version:
Go version:

Setup repository

Setup initial widget repository

Implementation details

  • We want to replicate release/publish flow we are using on our SDK.

Acceptance criteria

  • Successfully building empty react widget application
  • Added release please flow to the repository
  • Add publish flow to the repository
  • Add basic README instructions

Wallet connect button

Implementation details

  • add styling according to figma (it's called "Switch account" but it should be "Connect Wallet" until wallet is connected)
  • make sure to display connected address (design pending)
  • component should be hidden until source network is selected
  • if evm network is selected, display webonboard (at least Metamask and WalletConnect should be supported)
  • if substrate network is selected you need to create own popup (to choose between different wallet extensions and WalletConnect). Maybe we can reuse https://polkadot.cloud/overview

Testing details

Acceptance Criteria

Ability to "Start new transfer" is not working

Severity: High | Priority: High

Context: Use a valid flow for E2E transfer on widget version 0.1.0 (2024-02-22) is not working.

STR:

  1. Select from "Sepolia" and destination "Mumbai".
  2. Connect to metmask wallet and select ERC20LRTest token.
  3. Fill in 5 tokens and select approve spending.
  4. Transfer tokens.
  5. Select "Start new transfer" from the last screen.

Exp: The user to be redirected to the start transfer screen (similar to the first interaction)
Act: Nothing happens when pressing "Start new transfer"

Resource amount validation isn't retrigger on account balance updates

Expected Behavior

Once you connect wallet and update balance,amount input should be validated again

Current Behavior

validation message stays even though it's valid value

Possible Solution

Steps to Reproduce (for bugs)

Version

Sygma commit (or docker tag):
sygma-solidity version:
sygma-substrate version:
Go version:

Wallet account selector

Implementation details

Substrate doesn't have the same concept around single connected account like in ethereum. We should display all accounts from connected wallet and allow user to select from which he wants to send transaction.

Testing details

Acceptance Criteria

Fix small issue from latest release

Implementation details

  • events object doesn't exists in the browser context. Evm.ts class cannot be used

Testing details

Acceptance Criteria

  • wallet manager context works properly as dependency

Widget scope of changes V1.0.0

Main idea of this issue is to layout the discussion regarding scope of work and changes required for V2 of widget.

Implementation details

Testing details

Acceptance Criteria

Layout and theme for the UI

Prepare layout and define theme pallete for the UI

Implementation details

  • define basic layout for the Widget interface
  • provide unit test for the component

For the MVP UI must contain the following:

  • form with two inputs: amount and destination address
  • button to initiate transfer
  • render message, below for, that showcase the status of the transfer

Testing details

  • Test that Widget renders default view

Acceptance Criteria

SDK Manager Package: Substrate to EVM

Implementation details

Below are very high-level outlines of functionality, to be elaborated on once #6 is completed

  • Create logic that integrates SDK to this package.
  • Create interfaces to call the relevant methods to perform a transfer.
  • Package should return updates on the state of the transfer
  • Provide means to hook to the events for the transfer and return updates to be displayed on the UI
  • Provide unit test for it

Testing details

  • Upon connection to the provider and type of connection selected, one of the current asset transfers are created
  • In isolation package is able to perform a Substrate to EVM fungible transfer

Acceptance Criteria

  • Test are passing on pipeline
  • Using the package, we are able to make a Substrate to EVM transfer

Fix release pipeline for wallet package

Release pipeline wasn't being triggered nor wasn't publising package to npm

Implementation details

  • pipeline should publish version 0.0.1
  • fix namepsaces uses on the workflow that were off by a d in the namepsace for the package

Testing details

  • package should be published

Acceptance Criteria

Create examples for the widget

We should have examples to showcase usage of the widget in different frameworks

Implementation details

  • create vue example implementing the widget
  • create vanilla js example
  • create lit example
  • create angular example

Testing details

  • test that examples are able to work on development mode and build successfully

Acceptance Criteria

  • examples render customized version of the widget

Create Widget Package 0.1.0

Widget package is the one that uses sdk-manager and wallet-manager package.

Implementation details

  • implement Widget package according to the spec and design
  • Widget should receive props for customization and be able to change according to that, ie: providing different primary and secondary color as the one defined as base

Testing details

Acceptance Criteria

Test issue for transfer widget

transfer widget: there is the chance to have two main layouts for it: main one for full desktop or webpage view and in menu or tiny one, for some possible uses cases regarding wallet menus
transfer widget: estimate how long would it take to have new design and UX experience for the widget. Ideal scenario: to have design first ready and then create implementation issues
transfer widget features: evm to evm, evm to substrate, wallet connection: metamask and polkadot.js. To be defined is this is enough for connection purposes
transfer widget specs: to be define high level specs regarding the widget itself: this could be combination of UI (new and simple swap UI) + some nice to have for interested parties to implement in their websites
transfer widget specs: to be define tech specs: params to pass to the widget to be connected to sygma protocol through SDK, etc.
rough deadline: 4 to 6 weeks. Ideally before Berlin Blockchain week

Create preflight modal

Implementation details

  • modal should display message as defined in Figma
  • background should be blurred according to design
  • message should be passed as prop
  • open and close reactive properties depend on the parent component

Testing details

Acceptance Criteria

  • upon activation modal display passed message as prop
  • background is blurred

Substrate Wallet Selector component

Implementation details

The substrate ecosystem doesn't have ready-made framework-agnostic UI component for selecting the wallet. It should pop simple modal listing all available extension wallets + wallet connect. Assets for displaying wallets: https://polkadot.cloud/extensions

Testing details

Acceptance Criteria

Enable adding other web3 wallets

Implementation details

We should enable users to configure other wallets in Onboard library.

Testing details

Acceptance Criteria

Expose environment property to widget user

Implementation details

Currently, the environment is hardcoded to the testnet. We should allow users to set it themselves when using the widget. It should default to mainnet. Our Cloudflare deployment should override and use TESTNET.

Testing details

Acceptance Criteria

Placeholder zero stays in input once you start typing amount

Expected Behavior

Zero is actual placeholder and not preselected input.

Current Behavior

Placeholder zero stays in input once you start typing amount

Possible Solution

Steps to Reproduce (for bugs)

Version

Sygma commit (or docker tag):
sygma-solidity version:
sygma-substrate version:
Go version:

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.