-
Notifications
You must be signed in to change notification settings - Fork 117
feat: add widget light #664
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cdda344
feat: add widget light draft
chybisov b6038c1
refactor: make it ecosystem agnostic
chybisov 86c86e2
refactor: widget light adjustments
chybisov c49689a
refactor: update widget light providers and handlers for improved mod…
chybisov c7e3faa
refactor: simplify theme integration and enhance font loading in widg…
chybisov 9f2fdfe
Merge branch 'main' into add-widget-light
chybisov 07843ca
feat: add minimal wagmi example
chybisov edf59a9
chore: update packages
chybisov fc7bf42
chore: update exports handling
chybisov f55a7bd
fix: package example
chybisov e05e2b9
chore(release): 4.0.0-alpha.1
chybisov 892d256
chore: add cpy-cli as a devDependency
chybisov 8dbfaaa
chore: update build scripts
chybisov 22a1922
chore(release): 4.0.0-alpha.2
chybisov faf5274
chore: update dependencies
chybisov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| VITE_OPENSEA_API_KEY=ee7460014fda4f58804f25c29a27df35 | ||
| VITE_WALLET_CONNECT=5432e3507d41270bee46b7b85bbc2ef8 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # LI.FI Widget NFT Checkout | ||
|
|
||
| The demo of the LI.FI Widget NFT Checkout based on the OpenSea API. | ||
|
|
||
| ### How to run? | ||
|
|
||
| ``` | ||
| pnpm dev | ||
| ``` | ||
|
|
||
| ### How to test? | ||
|
|
||
| 1. Find an NFT on the [OpenSea](https://opensea.io/). Please make sure it has an active listing and the test wallet has enough tokens to buy it. While we will be able to pay with any token in the process, the OpenSea SDK checks for the token in which the NFT is listed to generate transaction data. | ||
| 2. Let's say we found this NFT https://opensea.io/assets/base/0x9e81df5258908dbeef4f841d0ab3816b10850426/2578 | ||
| 3. We need to replace the `opensea.io/assets` part with `localhost:3000` or `widget.li.fi`, depending on the testing environment, so the final URL should look like this | ||
| http://localhost:3000/base/0x9e81df5258908dbeef4f841d0ab3816b10850426/2578 or this https://widget.li.fi/base/0x9e81df5258908dbeef4f841d0ab3816b10850426/2578 | ||
| 4. Open the URL and make sure the test wallet is switched to the chain the NFT is on so OpenSea SDK can generate transaction data. | ||
| 5. Select any token on any chain and pay for NFT. | ||
|
|
||
| ### Live Demo | ||
|
|
||
| https://github.com/lifinance/widget/assets/18644653/af360181-3856-4276-b309-f923f476f40b | ||
|
|
||
| #### Demo Transactions | ||
|
|
||
| https://optimistic.etherscan.io/tx/0xa9f4e4304822cfe01808555b66e047761361c9e54b2387f93e23e9ffb92ba151 | ||
| https://polygonscan.com/tx/0x370682cbbc544e0ea258da774220b529a086c4b22941b924587cd2e0105579f6 | ||
|
|
||
| ### What does it look like? | ||
|
|
||
| <img src="https://github.com/lifinance/widget/assets/18644653/636c3071-c47e-45db-9ebd-1b7f502c2bab" width="400" /> | ||
|
|
||
| ### Questions? | ||
|
|
||
| Please don't hesitate to open an issue or contact us if you have any questions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <link rel="shortcut icon" href="/favicon.png" /> | ||
| <link rel="icon" href="/favicon.ico" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <link rel="apple-touch-icon" href="/logo192.png" /> | ||
|
|
||
| <!-- | ||
| manifest.json provides metadata used when your web app is installed on a | ||
| user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
| --> | ||
| <link rel="manifest" href="/manifest.json" /> | ||
| <title>LI.FI Widget</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <noscript>You need to enable JavaScript to run this app.</noscript> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.tsx"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| { | ||
| "name": "nft-checkout", | ||
| "version": "1.0.0", | ||
| "type": "module", | ||
| "scripts": { | ||
| "analyze": "source-map-explorer 'dist/assets/*.js' --no-border-checks", | ||
| "dev": "vite", | ||
| "build": "tsc && vite build", | ||
| "check:types": "tsc --noEmit", | ||
| "clean": "rm -rf dist tsconfig.tsbuildinfo", | ||
| "preview": "vite preview", | ||
| "pre-push:validate": "pnpm check:types" | ||
| }, | ||
| "author": "Eugene Chybisov <eugene@li.finance>", | ||
| "dependencies": { | ||
| "@lifi/sdk": "^4.0.0-alpha.13", | ||
| "@lifi/wallet-management": "workspace:*", | ||
| "@lifi/widget": "workspace:*", | ||
| "@lifi/widget-provider-bitcoin": "workspace:*", | ||
| "@lifi/widget-provider-ethereum": "workspace:*", | ||
| "@lifi/widget-provider-solana": "workspace:*", | ||
| "@lifi/widget-provider-sui": "workspace:*", | ||
| "@mui/icons-material": "^7.3.6", | ||
| "@mui/material": "^7.3.6", | ||
| "@mui/system": "^7.3.6", | ||
| "@opensea/seaport-js": "4.0.6", | ||
| "@tanstack/react-query": "^5.90.20", | ||
| "bignumber.js": "^9.3.0", | ||
| "ethers": "^6.16.0", | ||
| "events": "^3.3.0", | ||
| "react": "^19.2.4", | ||
| "react-dom": "^19.2.4", | ||
| "react-router-dom": "^7.13.0", | ||
| "viem": "^2.45.1", | ||
| "wagmi": "^3.1.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@esbuild-plugins/node-globals-polyfill": "^0.2.3", | ||
| "@vitejs/plugin-react-swc": "^4.2.3", | ||
| "source-map-explorer": "^2.5.3", | ||
| "typescript": "^5.9.3", | ||
| "vite": "^7.3.0", | ||
| "vite-plugin-node-polyfills": "0.25.0", | ||
| "web-vitals": "^5.1.0" | ||
| }, | ||
| "browserslist": { | ||
| "production": [ | ||
| "> 1%", | ||
| "last 2 versions", | ||
| "not dead", | ||
| "not IE > 0", | ||
| "not op_mini all" | ||
| ], | ||
| "development": [ | ||
| "last 1 chrome version", | ||
| "last 1 firefox version", | ||
| "last 1 safari version" | ||
| ] | ||
| }, | ||
| "private": true | ||
| } |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "short_name": "LI.FI Widget", | ||
| "name": "LI.FI Widget", | ||
| "icons": [ | ||
| { | ||
| "src": "favicon.ico", | ||
| "sizes": "64x64 32x32 24x24 16x16", | ||
| "type": "image/x-icon" | ||
| }, | ||
| { | ||
| "src": "logo192.png", | ||
| "type": "image/png", | ||
| "sizes": "192x192" | ||
| }, | ||
| { | ||
| "src": "logo512.png", | ||
| "type": "image/png", | ||
| "sizes": "512x512" | ||
| } | ||
| ], | ||
| "start_url": ".", | ||
| "display": "standalone", | ||
| "theme_color": "#000000", | ||
| "background_color": "#ffffff" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # https://www.robotstxt.org/robotstxt.html | ||
| User-agent: * | ||
| Disallow: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { LiFiWidget } from '@lifi/widget' | ||
| import { Box, CssBaseline } from '@mui/material' | ||
| import type { NFTNetwork } from './components/NFTOpenSea/index.js' | ||
| import { | ||
| NFTOpenSea, | ||
| NFTOpenSeaSecondary, | ||
| openSeaContractTool, | ||
| } from './components/NFTOpenSea/index.js' | ||
| import { widgetConfig } from './config.js' | ||
| import './index.css' | ||
|
|
||
| export const App = () => { | ||
| const pathnameParams = window.location.pathname.substring(1).split('/') | ||
|
|
||
| return ( | ||
| <Box | ||
| sx={{ | ||
| display: 'flex', | ||
| height: '100vh', | ||
| }} | ||
| > | ||
| <CssBaseline /> | ||
| <Box | ||
| sx={{ | ||
| flex: 1, | ||
| margin: 'auto', | ||
| }} | ||
| > | ||
| <LiFiWidget | ||
| contractComponent={ | ||
| <NFTOpenSea | ||
| network={pathnameParams[0] as NFTNetwork} | ||
| contractAddress={pathnameParams[1]} | ||
| tokenId={pathnameParams[2]} | ||
| /> | ||
| } | ||
| contractSecondaryComponent={ | ||
| <NFTOpenSeaSecondary | ||
| network={pathnameParams[0] as NFTNetwork} | ||
| contractAddress={pathnameParams[1]} | ||
| tokenId={pathnameParams[2]} | ||
| /> | ||
| } | ||
| contractCompactComponent={ | ||
| <NFTOpenSeaSecondary | ||
| network={pathnameParams[0] as NFTNetwork} | ||
| contractAddress={pathnameParams[1]} | ||
| tokenId={pathnameParams[2]} | ||
| /> | ||
| } | ||
| contractTool={openSeaContractTool} | ||
| config={widgetConfig} | ||
| integrator={widgetConfig.integrator} | ||
| open | ||
| /> | ||
| </Box> | ||
| </Box> | ||
| ) | ||
| } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { MetricType } from 'web-vitals' | ||
|
|
||
| export const reportWebVitals = (onPerfEntry?: (metric: MetricType) => void) => { | ||
| if (onPerfEntry && onPerfEntry instanceof Function) { | ||
| import('web-vitals').then(({ onCLS, onINP, onFCP, onLCP, onTTFB }) => { | ||
| onCLS(onPerfEntry) | ||
| onINP(onPerfEntry) | ||
| onFCP(onPerfEntry) | ||
| onLCP(onPerfEntry) | ||
| onTTFB(onPerfEntry) | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /// <reference types="vite/client" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "extends": "../../tsconfig.json", | ||
| "compilerOptions": { | ||
| "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo", | ||
| "outDir": "dist", | ||
| "rootDir": "./src", | ||
| "composite": true | ||
| }, | ||
| "include": ["src"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", | ||
| "composite": true, | ||
| "module": "ESNext", | ||
| "moduleResolution": "Bundler", | ||
| "allowSyntheticDefaultImports": true | ||
| }, | ||
| "include": ["vite.config.ts"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill' | ||
| import react from '@vitejs/plugin-react-swc' | ||
| import { defineConfig } from 'vite' | ||
| import { nodePolyfills } from 'vite-plugin-node-polyfills' | ||
|
|
||
| // https://vitejs.dev/config/ | ||
| export default defineConfig({ | ||
| plugins: [nodePolyfills(), react()], | ||
| esbuild: { | ||
| target: 'esnext', | ||
| }, | ||
| build: { | ||
| sourcemap: true, | ||
| }, | ||
| optimizeDeps: { | ||
| esbuildOptions: { | ||
| define: { | ||
| global: 'globalThis', | ||
| }, | ||
| plugins: [ | ||
| NodeGlobalsPolyfillPlugin({ | ||
| process: true, | ||
| buffer: true, | ||
| }), | ||
| ], | ||
| }, | ||
| }, | ||
| server: { | ||
| port: 3000, | ||
| open: true, | ||
| }, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| VITE_WIDGET_URL=https://widget.li.fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| VITE_WIDGET_URL=http://localhost:3000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Widget Light — Host</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.tsx"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "name": "vite-iframe-wagmi", | ||
| "private": true, | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "vite", | ||
| "build": "tsc && vite build", | ||
| "preview": "vite preview" | ||
| }, | ||
| "dependencies": { | ||
| "@lifi/widget-light": "^4.0.0-alpha.2", | ||
| "@tanstack/react-query": "^5.90.20", | ||
| "react": "^19.2.4", | ||
| "react-dom": "^19.2.4", | ||
| "viem": "^2.45.1", | ||
| "wagmi": "^3.4.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^19.2.13", | ||
| "@types/react-dom": "^19.2.3", | ||
| "@vitejs/plugin-react": "^5.1.3", | ||
| "typescript": "^5.9.3", | ||
| "vite": "^7.3.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { LiFiWidgetLight } from '@lifi/widget-light' | ||
| import { useEthereumIframeHandler } from '@lifi/widget-light/ethereum' | ||
| import { useMemo } from 'react' | ||
| import { WalletHeader } from './components/WalletHeader' | ||
| import { widgetConfig } from './widgetConfig' | ||
|
|
||
| const WIDGET_URL = import.meta.env.VITE_WIDGET_URL || 'https://widget.li.fi' | ||
| const WIDGET_ORIGIN = new URL(WIDGET_URL).origin | ||
|
|
||
| export function HostApp() { | ||
| const ethHandler = useEthereumIframeHandler() | ||
| const handlers = useMemo(() => [ethHandler], [ethHandler]) | ||
|
|
||
| return ( | ||
| <div className="app"> | ||
| <WalletHeader /> | ||
|
|
||
| <div className="app-content"> | ||
| <LiFiWidgetLight | ||
| src={WIDGET_URL} | ||
| config={widgetConfig} | ||
| handlers={handlers} | ||
| iframeOrigin={WIDGET_ORIGIN} | ||
| autoResize={false} | ||
| className="widget-iframe" | ||
| title="LI.FI Widget" | ||
| /> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposed secret in examples/nft-checkout/.env - high severity
Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
Reply
@AikidoSec ignore: [REASON]to ignore this issue.More Info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine in this case