From 5ec9154676de3270ef4d01a3ae608c1cef2c5b46 Mon Sep 17 00:00:00 2001 From: nature-lover-iv Date: Thu, 12 Sep 2024 10:42:53 +0100 Subject: [PATCH 1/8] chore: add base chain, make token optional for top up modal to open --- public/assets/chains/base.svg | 3 +++ src/constants/chains.ts | 7 +++++++ src/services/wagmiService.ts | 2 +- src/shared/SybilTopUp/SybilTopUp.tsx | 6 +++--- src/shared/TopUpModal/TopUpModal.tsx | 8 +++++--- 5 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 public/assets/chains/base.svg diff --git a/public/assets/chains/base.svg b/public/assets/chains/base.svg new file mode 100644 index 0000000..22d8935 --- /dev/null +++ b/public/assets/chains/base.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/constants/chains.ts b/src/constants/chains.ts index 05cf9aa..04b05fc 100644 --- a/src/constants/chains.ts +++ b/src/constants/chains.ts @@ -14,6 +14,7 @@ import { aurora, auroraTestnet, lineaTestnet, + base, Chain, } from 'wagmi/chains'; import { ExplorerType } from 'Interfaces/chain'; @@ -34,6 +35,7 @@ const mantaImg = '/assets/chains/manta.png'; const blastImg = '/assets/chains/blast.png'; const arbitrumImg = '/assets/chains/arbitrum.png'; const zircuitImg = '/assets/chains/zircuit.png'; +const baseImg = '/assets/chains/base.svg'; type EnhancedChain = Chain & { img: string; @@ -57,6 +59,11 @@ const CHAINS: EnhancedChain[] = [ img: ethereumImg, explorerType: ExplorerType.ScanExplorer, }, + { + ...base, + img: baseImg, + explorerType: ExplorerType.ScanExplorer, + }, { ...sepolia, rpcUrls: { diff --git a/src/services/wagmiService.ts b/src/services/wagmiService.ts index f77ac0c..f95e255 100644 --- a/src/services/wagmiService.ts +++ b/src/services/wagmiService.ts @@ -20,7 +20,7 @@ import APOLLO_COORDINATOR_CONTRACT_EVENTS_ABI from 'ABIs/ApolloCoordinatorEvents import { toastWrapper, tryDecode } from './utils'; interface UseTokenBalanceProps { - tokenAddress: Address; + tokenAddress?: Address; address: Address; enabled: boolean; chainId: number; diff --git a/src/shared/SybilTopUp/SybilTopUp.tsx b/src/shared/SybilTopUp/SybilTopUp.tsx index a31511d..a15a8c0 100644 --- a/src/shared/SybilTopUp/SybilTopUp.tsx +++ b/src/shared/SybilTopUp/SybilTopUp.tsx @@ -12,8 +12,8 @@ import { useSybilDeposit } from './useSybilDeposit'; export const SybilTopUp = () => { const { isOpen, onOpen, onOpenChange } = useModal(); - const [chain, setChain] = useState(null); - const [token, setToken] = useState(null); + const [chain, setChain] = useState(); + const [token, setToken] = useState(); const { isDepositing, sybilDeposit } = useSybilDeposit({ setIsModalVisible: onOpenChange }); @@ -43,7 +43,7 @@ export const SybilTopUp = () => { } }, [chain]); - const enabled = mappedChains && chain && token; + const enabled = mappedChains && chain; return ( <> diff --git a/src/shared/TopUpModal/TopUpModal.tsx b/src/shared/TopUpModal/TopUpModal.tsx index 808dbce..c24d2bd 100644 --- a/src/shared/TopUpModal/TopUpModal.tsx +++ b/src/shared/TopUpModal/TopUpModal.tsx @@ -18,7 +18,7 @@ interface TopUpModalProps { submit: (chain: number, token: AllowedToken, amount: number) => void; setChain: (AllowedChain: any) => void; chain: AllowedChain; - token: AllowedToken; + token?: AllowedToken; setToken?: (AllowedToken: any) => void; } @@ -37,7 +37,7 @@ export const TopUpModal = ({ const { address, chain: currentChain } = useAccount(); const [amount, setAmount] = useState( - token.symbol === 'ETH' ? DEFAULT_TOP_UP_AMOUNT_ETH : DEFAULT_TOP_UP_AMOUNT, + token?.symbol === 'ETH' ? DEFAULT_TOP_UP_AMOUNT_ETH : DEFAULT_TOP_UP_AMOUNT, ); const { balance } = useTokenBalance({ @@ -54,7 +54,9 @@ export const TopUpModal = ({ } } - submit(chain.chainId, token, amount); + if (token) { + submit(chain.chainId, token, amount); + } }, [chain.chainId, token, amount]); const actions = useMemo( From c4b947fe4d06836da133c8d306706b92ccc34e66 Mon Sep 17 00:00:00 2001 From: Nature is King Date: Thu, 12 Sep 2024 13:26:06 +0100 Subject: [PATCH 2/8] Feat: integrate lifi sdk, use for token balances feat: integrate lifi sdk, use it for query user token balances for allowed chains and tokens, merge this data with allowedChains to show --- .github/workflows/dev-deploy.yml | 1 + .github/workflows/prod-deploy.yml | 1 + package-lock.json | 1095 ++++++++++++++++++++++++-- package.json | 1 + src/components/Select/NewSelect.tsx | 2 +- src/constants/config.ts | 3 + src/index.tsx | 38 +- src/services/lifi.ts | 51 ++ src/shared/SybilTopUp/SybilTopUp.tsx | 48 +- src/shared/TopUpModal/TopUpModal.tsx | 2 +- src/types/common.ts | 2 + src/utils/mappers.ts | 6 +- src/utils/numberFormat.ts | 6 + tsconfig.json | 3 + vite.config.ts | 1 + 15 files changed, 1162 insertions(+), 98 deletions(-) create mode 100644 src/services/lifi.ts create mode 100644 src/types/common.ts create mode 100644 src/utils/numberFormat.ts diff --git a/.github/workflows/dev-deploy.yml b/.github/workflows/dev-deploy.yml index 830fdd3..70833ca 100644 --- a/.github/workflows/dev-deploy.yml +++ b/.github/workflows/dev-deploy.yml @@ -15,6 +15,7 @@ env: VITE_ROLLBAR_ACCESS_TOKEN: ${{ secrets.VITE_ROLLBAR_ACCESS_TOKEN }} VITE_GOOGLE_ANALYTICS_TRACKING_CODE: ${{ secrets.VITE_GOOGLE_ANALYTICS_TRACKING_CODE }} VITE_ETHERSCAN_API_KEY: ${{ secrets.VITE_ETHERSCAN_API_KEY }} + VITE_LIFI_SDK_INTEGRATOR: ${{ secrets.VITE_LIFI_SDK_INTEGRATOR }} jobs: deploy: diff --git a/.github/workflows/prod-deploy.yml b/.github/workflows/prod-deploy.yml index 5e361fb..f9b9661 100644 --- a/.github/workflows/prod-deploy.yml +++ b/.github/workflows/prod-deploy.yml @@ -15,6 +15,7 @@ env: VITE_ROLLBAR_ACCESS_TOKEN: ${{ secrets.VITE_ROLLBAR_ACCESS_TOKEN }} VITE_GOOGLE_ANALYTICS_TRACKING_CODE: ${{ secrets.VITE_GOOGLE_ANALYTICS_TRACKING_CODE }} VITE_ETHERSCAN_API_KEY: ${{ secrets.VITE_ETHERSCAN_API_KEY }} + VITE_LIFI_SDK_INTEGRATOR: ${{ secrets.VITE_LIFI_SDK_INTEGRATOR }} jobs: deploy: diff --git a/package-lock.json b/package-lock.json index 24a9c29..db8e614 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "@fortawesome/free-regular-svg-icons": "^6.4.2", "@fortawesome/free-solid-svg-icons": "^6.4.2", "@fortawesome/react-fontawesome": "^0.2.0", + "@lifi/sdk": "^3.2.0", "@microlink/react-json-view": "^1.23.0", "@nextui-org/react": "^2.3.6", "@rollbar/react": "^0.11.1", @@ -2447,9 +2448,10 @@ "peer": true }, "node_modules/@babel/runtime": { - "version": "7.24.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.5.tgz", - "integrity": "sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.6.tgz", + "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", + "license": "MIT", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -2531,6 +2533,19 @@ "node": ">=0.1.90" } }, + "node_modules/@commitlint/format": { + "version": "7.6.1", + "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-7.6.1.tgz", + "integrity": "sha512-Ldzf5N2Sr9RQqvlYwaQn4vz1WOZ7byYinspC/WCrbfcETGy28j7QE4OueZU6nNB9TjwwEorKm13uy7tDWPR7dg==", + "license": "MIT", + "dependencies": { + "babel-runtime": "^6.23.0", + "chalk": "^2.0.1" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -6904,6 +6919,32 @@ "node": ">=v12.0.0" } }, + "node_modules/@lifi/sdk": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@lifi/sdk/-/sdk-3.2.0.tgz", + "integrity": "sha512-weV+gExp6JgJT9SB6sGaED1T2/QvJSXqzeTSj/KC/T66B5r7M1WOnJDqx//mAxB+xV1j1BdPqaBw9OSJUBIuPw==", + "license": "Apache-2.0", + "dependencies": { + "@lifi/types": "^15.9.0", + "@solana/wallet-adapter-base": "^0.9.23", + "@solana/web3.js": "^1.95.3", + "viem": "^2.21.4" + }, + "peerDependencies": { + "@solana/wallet-adapter-base": "^0.9.0", + "@solana/web3.js": "^1.93.0", + "viem": "^2.16.0" + } + }, + "node_modules/@lifi/types": { + "version": "15.11.0", + "resolved": "https://registry.npmjs.org/@lifi/types/-/types-15.11.0.tgz", + "integrity": "sha512-kQNbzkcLzzWs+awKoLPtgTdXkE7gfagWZJNqYOyqPnHDGtYaJXnl3euT2tt31LDMQdC24fjlvHw0k3LJ3PQGTw==", + "license": "Apache-2.0", + "dependencies": { + "@commitlint/format": "7.6.1" + } + }, "node_modules/@lit-labs/ssr-dom-shim": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.0.tgz", @@ -12850,9 +12891,10 @@ } }, "node_modules/@scure/base": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", - "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==", + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.8.tgz", + "integrity": "sha512-6CyAclxj3Nb0XT7GHK6K4zK6k2xJm6E4Ft0Ohjt4WgegiFUHEtFb2CGzmPmGBwoIhrLsqNLYfLr04Y1GePrzZg==", + "license": "MIT", "funding": { "url": "https://paulmillr.com/funding/" } @@ -12954,6 +12996,108 @@ "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==" }, + "node_modules/@solana/buffer-layout": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz", + "integrity": "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==", + "license": "MIT", + "dependencies": { + "buffer": "~6.0.3" + }, + "engines": { + "node": ">=5.10" + } + }, + "node_modules/@solana/wallet-adapter-base": { + "version": "0.9.23", + "resolved": "https://registry.npmjs.org/@solana/wallet-adapter-base/-/wallet-adapter-base-0.9.23.tgz", + "integrity": "sha512-apqMuYwFp1jFi55NxDfvXUX2x1T0Zh07MxhZ/nCCTGys5raSfYUh82zen2BLv8BSDj/JxZ2P/s7jrQZGrX8uAw==", + "license": "Apache-2.0", + "dependencies": { + "@solana/wallet-standard-features": "^1.1.0", + "@wallet-standard/base": "^1.0.1", + "@wallet-standard/features": "^1.0.3", + "eventemitter3": "^4.0.7" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.77.3" + } + }, + "node_modules/@solana/wallet-standard-features": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@solana/wallet-standard-features/-/wallet-standard-features-1.2.0.tgz", + "integrity": "sha512-tUd9srDLkRpe1BYg7we+c4UhRQkq+XQWswsr/L1xfGmoRDF47BPSXf4zE7ZU2GRBGvxtGt7lwJVAufQyQYhxTQ==", + "license": "Apache-2.0", + "dependencies": { + "@wallet-standard/base": "^1.0.1", + "@wallet-standard/features": "^1.0.3" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@solana/web3.js": { + "version": "1.95.3", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.3.tgz", + "integrity": "sha512-O6rPUN0w2fkNqx/Z3QJMB9L225Ex10PRDH8bTaIUPZXMPV0QP8ZpPvjQnXK+upUczlRgzHzd6SjKIha1p+I6og==", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.25.0", + "@noble/curves": "^1.4.2", + "@noble/hashes": "^1.4.0", + "@solana/buffer-layout": "^4.0.1", + "agentkeepalive": "^4.5.0", + "bigint-buffer": "^1.1.5", + "bn.js": "^5.2.1", + "borsh": "^0.7.0", + "bs58": "^4.0.1", + "buffer": "6.0.3", + "fast-stable-stringify": "^1.0.0", + "jayson": "^4.1.1", + "node-fetch": "^2.7.0", + "rpc-websockets": "^9.0.2", + "superstruct": "^2.0.2" + } + }, + "node_modules/@solana/web3.js/node_modules/@noble/curves": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.6.0.tgz", + "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.5.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@solana/web3.js/node_modules/@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@solana/web3.js/node_modules/superstruct": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-2.0.2.tgz", + "integrity": "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@spruceid/siwe-parser": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@spruceid/siwe-parser/-/siwe-parser-1.1.3.tgz", @@ -13252,8 +13396,6 @@ "version": "3.4.38", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", - "optional": true, - "peer": true, "dependencies": { "@types/node": "*" } @@ -13663,6 +13805,21 @@ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" }, + "node_modules/@types/uuid": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", + "license": "MIT" + }, + "node_modules/@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/yargs": { "version": "17.0.32", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.32.tgz", @@ -13991,6 +14148,27 @@ } } }, + "node_modules/@wallet-standard/base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@wallet-standard/base/-/base-1.0.1.tgz", + "integrity": "sha512-1To3ekMfzhYxe0Yhkpri+Fedq0SYcfrOfJi3vbLjMwF2qiKPjTGLwZkf2C9ftdQmxES+hmxhBzTwF4KgcOwf8w==", + "license": "Apache-2.0", + "engines": { + "node": ">=16" + } + }, + "node_modules/@wallet-standard/features": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@wallet-standard/features/-/features-1.0.3.tgz", + "integrity": "sha512-m8475I6W5LTatTZuUz5JJNK42wFRgkJTB0I9tkruMwfqBF2UN2eomkYNVf9RbrsROelCRzSFmugqjKZBFaubsA==", + "license": "Apache-2.0", + "dependencies": { + "@wallet-standard/base": "^1.0.1" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/@walletconnect/core": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.13.0.tgz", @@ -14904,6 +15082,27 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/abitype": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.5.tgz", + "integrity": "sha512-YzDhti7cjlfaBhHutMaboYB21Ha3rXR9QTkNJFzYC4kC8YclaiwPBBBJY8ejFdu2wnJeZCVZSMlQJ7fi8S6hsw==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3 >=3.22.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -14976,6 +15175,18 @@ "node": ">= 6.0.0" } }, + "node_modules/agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "license": "MIT", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -15791,6 +16002,22 @@ "@babel/core": "^7.0.0" } }, + "node_modules/babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", + "license": "MIT", + "dependencies": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "node_modules/babel-runtime/node_modules/regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "license": "MIT" + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -15802,6 +16029,15 @@ "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==", "dev": true }, + "node_modules/base-x": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.10.tgz", + "integrity": "sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/base16": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/base16/-/base16-1.0.0.tgz", @@ -15872,6 +16108,19 @@ "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" }, + "node_modules/bigint-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz", + "integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "bindings": "^1.3.0" + }, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/bignumber.js": { "version": "9.1.2", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", @@ -15888,6 +16137,15 @@ "node": ">=8" } }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "license": "MIT", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, "node_modules/bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", @@ -16026,6 +16284,17 @@ "ieee754": "^1.1.13" } }, + "node_modules/borsh": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", + "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", + "license": "Apache-2.0", + "dependencies": { + "bn.js": "^5.2.0", + "bs58": "^4.0.0", + "text-encoding-utf-8": "^1.0.2" + } + }, "node_modules/bowser": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz", @@ -16342,6 +16611,15 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", + "license": "MIT", + "dependencies": { + "base-x": "^3.0.2" + } + }, "node_modules/bser": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", @@ -17579,6 +17857,14 @@ "toggle-selection": "^1.0.6" } }, + "node_modules/core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", + "hasInstallScript": true, + "license": "MIT" + }, "node_modules/core-js-compat": { "version": "3.35.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.35.0.tgz", @@ -18274,6 +18560,18 @@ "source-map": "~0.6.1" } }, + "node_modules/delay": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", + "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -18854,6 +19152,21 @@ "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", "integrity": "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==" }, + "node_modules/es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==", + "license": "MIT" + }, + "node_modules/es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", + "license": "MIT", + "dependencies": { + "es6-promise": "^4.0.3" + } + }, "node_modules/esbuild": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz", @@ -19930,6 +20243,14 @@ "url": "https://github.com/sponsors/jaydenseric" } }, + "node_modules/eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==", + "engines": { + "node": "> 0.1.90" + } + }, "node_modules/fast-decode-uri-component": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", @@ -20015,6 +20336,12 @@ "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" }, + "node_modules/fast-stable-stringify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", + "integrity": "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==", + "license": "MIT" + }, "node_modules/fast-text-encoding": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.6.tgz", @@ -20185,6 +20512,12 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "license": "MIT" + }, "node_modules/filesize": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/filesize/-/filesize-6.4.0.tgz", @@ -21762,6 +22095,15 @@ "node": ">=16.17.0" } }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "license": "MIT", + "dependencies": { + "ms": "^2.0.0" + } + }, "node_modules/husky": { "version": "9.1.5", "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.5.tgz", @@ -22860,6 +23202,15 @@ "unfetch": "^4.2.0" } }, + "node_modules/isomorphic-ws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", + "license": "MIT", + "peerDependencies": { + "ws": "*" + } + }, "node_modules/isows": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.4.tgz", @@ -22904,6 +23255,59 @@ "@pkgjs/parseargs": "^0.11.0" } }, + "node_modules/jayson": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/jayson/-/jayson-4.1.2.tgz", + "integrity": "sha512-5nzMWDHy6f+koZOuYsArh2AXs73NfWYVlFyJJuCedr93GpY+Ku8qq10ropSXVfHK+H0T6paA88ww+/dV+1fBNA==", + "license": "MIT", + "dependencies": { + "@types/connect": "^3.4.33", + "@types/node": "^12.12.54", + "@types/ws": "^7.4.4", + "commander": "^2.20.3", + "delay": "^5.0.0", + "es6-promisify": "^5.0.0", + "eyes": "^0.1.8", + "isomorphic-ws": "^4.0.1", + "json-stringify-safe": "^5.0.1", + "JSONStream": "^1.3.5", + "uuid": "^8.3.2", + "ws": "^7.5.10" + }, + "bin": { + "jayson": "bin/jayson.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jayson/node_modules/@types/node": { + "version": "12.20.55", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", + "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==", + "license": "MIT" + }, + "node_modules/jayson/node_modules/ws": { + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", + "license": "MIT", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/jest-environment-node": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz", @@ -23735,6 +24139,31 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", + "engines": [ + "node >= 0.2.0" + ], + "license": "MIT" + }, + "node_modules/JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", + "license": "(MIT OR Apache-2.0)", + "dependencies": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + }, + "bin": { + "JSONStream": "bin.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/jsonwebtoken": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", @@ -30327,6 +30756,65 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, + "node_modules/rpc-websockets": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-9.0.2.tgz", + "integrity": "sha512-YzggvfItxMY3Lwuax5rC18inhbjJv9Py7JXRHxTIi94JOLrqBsSsUUc5bbl5W6c11tXhdfpDPK0KzBhoGe8jjw==", + "license": "LGPL-3.0-only", + "dependencies": { + "@swc/helpers": "^0.5.11", + "@types/uuid": "^8.3.4", + "@types/ws": "^8.2.2", + "buffer": "^6.0.3", + "eventemitter3": "^5.0.1", + "uuid": "^8.3.2", + "ws": "^8.5.0" + }, + "funding": { + "type": "paypal", + "url": "https://paypal.me/kozjak" + }, + "optionalDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + } + }, + "node_modules/rpc-websockets/node_modules/@types/ws": { + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", + "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/rpc-websockets/node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "license": "MIT" + }, + "node_modules/rpc-websockets/node_modules/ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -31930,6 +32418,11 @@ "url": "https://opencollective.com/webpack" } }, + "node_modules/text-encoding-utf-8": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", + "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" + }, "node_modules/text-hex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", @@ -32003,8 +32496,7 @@ "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", - "dev": true + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" }, "node_modules/through2": { "version": "2.0.5", @@ -33215,7 +33707,6 @@ "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", "hasInstallScript": true, "optional": true, - "peer": true, "dependencies": { "node-gyp-build": "^4.3.0" }, @@ -33350,24 +33841,26 @@ } }, "node_modules/viem": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.12.1.tgz", - "integrity": "sha512-71gxcGCXdNXQuBhpqXblVRH1F3hP/wONCptVOCW4r6VrCEXL/9vfNyCdQKtK/0WGyXm04Zs9Jf/AOAxKqf6FmQ==", + "version": "2.21.6", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.21.6.tgz", + "integrity": "sha512-YX48IVl6nZ4FRsY4ypv2RrxtQVWysIY146/lBW53tma8u32h8EsiA7vecw9ZbrueNUy/asHR4Egu68Z6FOvDzQ==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/wevm" } ], + "license": "MIT", "dependencies": { "@adraffy/ens-normalize": "1.10.0", - "@noble/curves": "1.2.0", - "@noble/hashes": "1.3.2", - "@scure/bip32": "1.3.2", - "@scure/bip39": "1.2.1", - "abitype": "1.0.0", + "@noble/curves": "1.4.0", + "@noble/hashes": "1.4.0", + "@scure/bip32": "1.4.0", + "@scure/bip39": "1.4.0", + "abitype": "1.0.5", "isows": "1.0.4", - "ws": "8.13.0" + "webauthn-p256": "0.0.5", + "ws": "8.17.1" }, "peerDependencies": { "typescript": ">=5.0.4" @@ -33379,20 +33872,22 @@ } }, "node_modules/viem/node_modules/@noble/curves": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", - "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.0.tgz", + "integrity": "sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==", + "license": "MIT", "dependencies": { - "@noble/hashes": "1.3.2" + "@noble/hashes": "1.4.0" }, "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/viem/node_modules/@noble/hashes": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", - "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "license": "MIT", "engines": { "node": ">= 16" }, @@ -33400,30 +33895,50 @@ "url": "https://paulmillr.com/funding/" } }, - "node_modules/viem/node_modules/abitype": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.0.tgz", - "integrity": "sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==", + "node_modules/viem/node_modules/@scure/bip32": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.4.0.tgz", + "integrity": "sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg==", + "license": "MIT", + "dependencies": { + "@noble/curves": "~1.4.0", + "@noble/hashes": "~1.4.0", + "@scure/base": "~1.1.6" + }, "funding": { - "url": "https://github.com/sponsors/wevm" + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/@scure/bip39": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.4.0.tgz", + "integrity": "sha512-BEEm6p8IueV/ZTfQLp/0vhw4NPnT9oWf5+28nvmeUICjP99f4vr2d+qc7AVGDDtwRep6ifR43Yed9ERVmiITzw==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "~1.5.0", + "@scure/base": "~1.1.8" }, - "peerDependencies": { - "typescript": ">=5.0.4", - "zod": "^3 >=3.22.0" + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/@scure/bip39/node_modules/@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - }, - "zod": { - "optional": true - } + "funding": { + "url": "https://paulmillr.com/funding/" } }, "node_modules/viem/node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "license": "MIT", "engines": { "node": ">=10.0.0" }, @@ -33828,6 +34343,49 @@ "node": ">= 8" } }, + "node_modules/webauthn-p256": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/webauthn-p256/-/webauthn-p256-0.0.5.tgz", + "integrity": "sha512-drMGNWKdaixZNobeORVIqq7k5DsRC9FnG201K2QjeOoQLmtSDaSsVZdkg6n5jUALJKcAG++zBPJXmv6hy0nWFg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@noble/curves": "^1.4.0", + "@noble/hashes": "^1.4.0" + } + }, + "node_modules/webauthn-p256/node_modules/@noble/curves": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.6.0.tgz", + "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.5.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/webauthn-p256/node_modules/@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/webcrypto-core": { "version": "1.7.7", "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.7.7.tgz", @@ -36031,9 +36589,9 @@ "peer": true }, "@babel/runtime": { - "version": "7.24.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.5.tgz", - "integrity": "sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.6.tgz", + "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", "requires": { "regenerator-runtime": "^0.14.0" } @@ -36102,6 +36660,15 @@ "dev": true, "optional": true }, + "@commitlint/format": { + "version": "7.6.1", + "resolved": "https://registry.npmjs.org/@commitlint/format/-/format-7.6.1.tgz", + "integrity": "sha512-Ldzf5N2Sr9RQqvlYwaQn4vz1WOZ7byYinspC/WCrbfcETGy28j7QE4OueZU6nNB9TjwwEorKm13uy7tDWPR7dg==", + "requires": { + "babel-runtime": "^6.23.0", + "chalk": "^2.0.1" + } + }, "@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -39239,6 +39806,25 @@ "lodash": "^4.17.21" } }, + "@lifi/sdk": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@lifi/sdk/-/sdk-3.2.0.tgz", + "integrity": "sha512-weV+gExp6JgJT9SB6sGaED1T2/QvJSXqzeTSj/KC/T66B5r7M1WOnJDqx//mAxB+xV1j1BdPqaBw9OSJUBIuPw==", + "requires": { + "@lifi/types": "^15.9.0", + "@solana/wallet-adapter-base": "^0.9.23", + "@solana/web3.js": "^1.95.3", + "viem": "^2.21.4" + } + }, + "@lifi/types": { + "version": "15.11.0", + "resolved": "https://registry.npmjs.org/@lifi/types/-/types-15.11.0.tgz", + "integrity": "sha512-kQNbzkcLzzWs+awKoLPtgTdXkE7gfagWZJNqYOyqPnHDGtYaJXnl3euT2tt31LDMQdC24fjlvHw0k3LJ3PQGTw==", + "requires": { + "@commitlint/format": "7.6.1" + } + }, "@lit-labs/ssr-dom-shim": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.0.tgz", @@ -43600,9 +44186,9 @@ "integrity": "sha512-/dqU66RvHw50n+7x3nwnJedq8V6iLQyoWitNdjx5cFTBmae+rpP+LvHq+LqZfXJVkB1qNytMdjFjdyES0t79gQ==" }, "@scure/base": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", - "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==" + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.8.tgz", + "integrity": "sha512-6CyAclxj3Nb0XT7GHK6K4zK6k2xJm6E4Ft0Ohjt4WgegiFUHEtFb2CGzmPmGBwoIhrLsqNLYfLr04Y1GePrzZg==" }, "@scure/bip32": { "version": "1.3.2", @@ -43688,6 +44274,76 @@ "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==" }, + "@solana/buffer-layout": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz", + "integrity": "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==", + "requires": { + "buffer": "~6.0.3" + } + }, + "@solana/wallet-adapter-base": { + "version": "0.9.23", + "resolved": "https://registry.npmjs.org/@solana/wallet-adapter-base/-/wallet-adapter-base-0.9.23.tgz", + "integrity": "sha512-apqMuYwFp1jFi55NxDfvXUX2x1T0Zh07MxhZ/nCCTGys5raSfYUh82zen2BLv8BSDj/JxZ2P/s7jrQZGrX8uAw==", + "requires": { + "@solana/wallet-standard-features": "^1.1.0", + "@wallet-standard/base": "^1.0.1", + "@wallet-standard/features": "^1.0.3", + "eventemitter3": "^4.0.7" + } + }, + "@solana/wallet-standard-features": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@solana/wallet-standard-features/-/wallet-standard-features-1.2.0.tgz", + "integrity": "sha512-tUd9srDLkRpe1BYg7we+c4UhRQkq+XQWswsr/L1xfGmoRDF47BPSXf4zE7ZU2GRBGvxtGt7lwJVAufQyQYhxTQ==", + "requires": { + "@wallet-standard/base": "^1.0.1", + "@wallet-standard/features": "^1.0.3" + } + }, + "@solana/web3.js": { + "version": "1.95.3", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.3.tgz", + "integrity": "sha512-O6rPUN0w2fkNqx/Z3QJMB9L225Ex10PRDH8bTaIUPZXMPV0QP8ZpPvjQnXK+upUczlRgzHzd6SjKIha1p+I6og==", + "requires": { + "@babel/runtime": "^7.25.0", + "@noble/curves": "^1.4.2", + "@noble/hashes": "^1.4.0", + "@solana/buffer-layout": "^4.0.1", + "agentkeepalive": "^4.5.0", + "bigint-buffer": "^1.1.5", + "bn.js": "^5.2.1", + "borsh": "^0.7.0", + "bs58": "^4.0.1", + "buffer": "6.0.3", + "fast-stable-stringify": "^1.0.0", + "jayson": "^4.1.1", + "node-fetch": "^2.7.0", + "rpc-websockets": "^9.0.2", + "superstruct": "^2.0.2" + }, + "dependencies": { + "@noble/curves": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.6.0.tgz", + "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", + "requires": { + "@noble/hashes": "1.5.0" + } + }, + "@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==" + }, + "superstruct": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-2.0.2.tgz", + "integrity": "sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==" + } + } + }, "@spruceid/siwe-parser": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@spruceid/siwe-parser/-/siwe-parser-1.1.3.tgz", @@ -43957,8 +44613,6 @@ "version": "3.4.38", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", - "optional": true, - "peer": true, "requires": { "@types/node": "*" } @@ -44366,6 +45020,19 @@ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" }, + "@types/uuid": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", + "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==" + }, + "@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "requires": { + "@types/node": "*" + } + }, "@types/yargs": { "version": "17.0.32", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.32.tgz", @@ -44543,6 +45210,19 @@ } } }, + "@wallet-standard/base": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@wallet-standard/base/-/base-1.0.1.tgz", + "integrity": "sha512-1To3ekMfzhYxe0Yhkpri+Fedq0SYcfrOfJi3vbLjMwF2qiKPjTGLwZkf2C9ftdQmxES+hmxhBzTwF4KgcOwf8w==" + }, + "@wallet-standard/features": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@wallet-standard/features/-/features-1.0.3.tgz", + "integrity": "sha512-m8475I6W5LTatTZuUz5JJNK42wFRgkJTB0I9tkruMwfqBF2UN2eomkYNVf9RbrsROelCRzSFmugqjKZBFaubsA==", + "requires": { + "@wallet-standard/base": "^1.0.1" + } + }, "@walletconnect/core": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.13.0.tgz", @@ -45416,6 +46096,12 @@ "dev": true, "optional": true }, + "abitype": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.5.tgz", + "integrity": "sha512-YzDhti7cjlfaBhHutMaboYB21Ha3rXR9QTkNJFzYC4kC8YclaiwPBBBJY8ejFdu2wnJeZCVZSMlQJ7fi8S6hsw==", + "requires": {} + }, "abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -45466,6 +46152,14 @@ "debug": "4" } }, + "agentkeepalive": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", + "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", + "requires": { + "humanize-ms": "^1.2.1" + } + }, "aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -46131,6 +46825,22 @@ "babel-plugin-syntax-trailing-function-commas": "^7.0.0-beta.0" } }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==", + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + } + } + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -46142,6 +46852,14 @@ "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==", "dev": true }, + "base-x": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.10.tgz", + "integrity": "sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ==", + "requires": { + "safe-buffer": "^5.0.1" + } + }, "base16": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/base16/-/base16-1.0.0.tgz", @@ -46191,6 +46909,14 @@ "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==" }, + "bigint-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz", + "integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==", + "requires": { + "bindings": "^1.3.0" + } + }, "bignumber.js": { "version": "9.1.2", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", @@ -46201,6 +46927,14 @@ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", @@ -46304,6 +47038,16 @@ } } }, + "borsh": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", + "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", + "requires": { + "bn.js": "^5.2.0", + "bs58": "^4.0.0", + "text-encoding-utf-8": "^1.0.2" + } + }, "bowser": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz", @@ -46565,6 +47309,14 @@ "update-browserslist-db": "^1.0.13" } }, + "bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", + "requires": { + "base-x": "^3.0.2" + } + }, "bser": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", @@ -47525,6 +48277,11 @@ "toggle-selection": "^1.0.6" } }, + "core-js": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==" + }, "core-js-compat": { "version": "3.35.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.35.0.tgz", @@ -48047,6 +48804,11 @@ } } }, + "delay": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", + "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==" + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -48533,6 +49295,19 @@ "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", "integrity": "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==" }, + "es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, + "es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", + "requires": { + "es6-promise": "^4.0.3" + } + }, "esbuild": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz", @@ -49338,6 +50113,11 @@ "integrity": "sha512-FuoE1qtbJ4bBVvv94CC7s0oTnKUGvQs+Rjf1L2SJFfS+HTVVjhPFtehPdQ0JiGPqVNfSSZvL5yzHHQq2Z4WNhQ==", "dev": true }, + "eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==" + }, "fast-decode-uri-component": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fast-decode-uri-component/-/fast-decode-uri-component-1.0.1.tgz", @@ -49412,6 +50192,11 @@ "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" }, + "fast-stable-stringify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", + "integrity": "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==" + }, "fast-text-encoding": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.6.tgz", @@ -49554,6 +50339,11 @@ "flat-cache": "^3.0.4" } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, "filesize": { "version": "6.4.0", "resolved": "https://registry.npmjs.org/filesize/-/filesize-6.4.0.tgz", @@ -50759,6 +51549,14 @@ "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==" }, + "humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "requires": { + "ms": "^2.0.0" + } + }, "husky": { "version": "9.1.5", "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.5.tgz", @@ -51514,6 +52312,12 @@ "unfetch": "^4.2.0" } }, + "isomorphic-ws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", + "requires": {} + }, "isows": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.4.tgz", @@ -51542,6 +52346,38 @@ "@pkgjs/parseargs": "^0.11.0" } }, + "jayson": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/jayson/-/jayson-4.1.2.tgz", + "integrity": "sha512-5nzMWDHy6f+koZOuYsArh2AXs73NfWYVlFyJJuCedr93GpY+Ku8qq10ropSXVfHK+H0T6paA88ww+/dV+1fBNA==", + "requires": { + "@types/connect": "^3.4.33", + "@types/node": "^12.12.54", + "@types/ws": "^7.4.4", + "commander": "^2.20.3", + "delay": "^5.0.0", + "es6-promisify": "^5.0.0", + "eyes": "^0.1.8", + "isomorphic-ws": "^4.0.1", + "json-stringify-safe": "^5.0.1", + "JSONStream": "^1.3.5", + "uuid": "^8.3.2", + "ws": "^7.5.10" + }, + "dependencies": { + "@types/node": { + "version": "12.20.55", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", + "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" + }, + "ws": { + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", + "requires": {} + } + } + }, "jest-environment-node": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.7.0.tgz", @@ -52201,6 +53037,20 @@ "universalify": "^2.0.0" } }, + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==" + }, + "JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", + "requires": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + } + }, "jsonwebtoken": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", @@ -57270,6 +58120,43 @@ } } }, + "rpc-websockets": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-9.0.2.tgz", + "integrity": "sha512-YzggvfItxMY3Lwuax5rC18inhbjJv9Py7JXRHxTIi94JOLrqBsSsUUc5bbl5W6c11tXhdfpDPK0KzBhoGe8jjw==", + "requires": { + "@swc/helpers": "^0.5.11", + "@types/uuid": "^8.3.4", + "@types/ws": "^8.2.2", + "buffer": "^6.0.3", + "bufferutil": "^4.0.1", + "eventemitter3": "^5.0.1", + "utf-8-validate": "^5.0.2", + "uuid": "^8.3.2", + "ws": "^8.5.0" + }, + "dependencies": { + "@types/ws": { + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", + "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", + "requires": { + "@types/node": "*" + } + }, + "eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" + }, + "ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "requires": {} + } + } + }, "run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -58461,6 +59348,11 @@ } } }, + "text-encoding-utf-8": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", + "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" + }, "text-hex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", @@ -58522,8 +59414,7 @@ "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", - "dev": true + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" }, "through2": { "version": "2.0.5", @@ -59364,7 +60255,6 @@ "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", "optional": true, - "peer": true, "requires": { "node-gyp-build": "^4.3.0" } @@ -59471,43 +60361,64 @@ } }, "viem": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.12.1.tgz", - "integrity": "sha512-71gxcGCXdNXQuBhpqXblVRH1F3hP/wONCptVOCW4r6VrCEXL/9vfNyCdQKtK/0WGyXm04Zs9Jf/AOAxKqf6FmQ==", + "version": "2.21.6", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.21.6.tgz", + "integrity": "sha512-YX48IVl6nZ4FRsY4ypv2RrxtQVWysIY146/lBW53tma8u32h8EsiA7vecw9ZbrueNUy/asHR4Egu68Z6FOvDzQ==", "requires": { "@adraffy/ens-normalize": "1.10.0", - "@noble/curves": "1.2.0", - "@noble/hashes": "1.3.2", - "@scure/bip32": "1.3.2", - "@scure/bip39": "1.2.1", - "abitype": "1.0.0", + "@noble/curves": "1.4.0", + "@noble/hashes": "1.4.0", + "@scure/bip32": "1.4.0", + "@scure/bip39": "1.4.0", + "abitype": "1.0.5", "isows": "1.0.4", - "ws": "8.13.0" + "webauthn-p256": "0.0.5", + "ws": "8.17.1" }, "dependencies": { "@noble/curves": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", - "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.0.tgz", + "integrity": "sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==", "requires": { - "@noble/hashes": "1.3.2" + "@noble/hashes": "1.4.0" } }, "@noble/hashes": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", - "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==" + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==" }, - "abitype": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.0.tgz", - "integrity": "sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==", - "requires": {} + "@scure/bip32": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.4.0.tgz", + "integrity": "sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg==", + "requires": { + "@noble/curves": "~1.4.0", + "@noble/hashes": "~1.4.0", + "@scure/base": "~1.1.6" + } + }, + "@scure/bip39": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.4.0.tgz", + "integrity": "sha512-BEEm6p8IueV/ZTfQLp/0vhw4NPnT9oWf5+28nvmeUICjP99f4vr2d+qc7AVGDDtwRep6ifR43Yed9ERVmiITzw==", + "requires": { + "@noble/hashes": "~1.5.0", + "@scure/base": "~1.1.8" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==" + } + } }, "ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "requires": {} } } @@ -59717,6 +60628,30 @@ "integrity": "sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ==", "dev": true }, + "webauthn-p256": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/webauthn-p256/-/webauthn-p256-0.0.5.tgz", + "integrity": "sha512-drMGNWKdaixZNobeORVIqq7k5DsRC9FnG201K2QjeOoQLmtSDaSsVZdkg6n5jUALJKcAG++zBPJXmv6hy0nWFg==", + "requires": { + "@noble/curves": "^1.4.0", + "@noble/hashes": "^1.4.0" + }, + "dependencies": { + "@noble/curves": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.6.0.tgz", + "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", + "requires": { + "@noble/hashes": "1.5.0" + } + }, + "@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==" + } + } + }, "webcrypto-core": { "version": "1.7.7", "resolved": "https://registry.npmjs.org/webcrypto-core/-/webcrypto-core-1.7.7.tgz", diff --git a/package.json b/package.json index f32df22..6dbf7ef 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "@fortawesome/free-regular-svg-icons": "^6.4.2", "@fortawesome/free-solid-svg-icons": "^6.4.2", "@fortawesome/react-fontawesome": "^0.2.0", + "@lifi/sdk": "^3.2.0", "@microlink/react-json-view": "^1.23.0", "@nextui-org/react": "^2.3.6", "@rollbar/react": "^0.11.1", diff --git a/src/components/Select/NewSelect.tsx b/src/components/Select/NewSelect.tsx index 5c2323b..4e5bfae 100644 --- a/src/components/Select/NewSelect.tsx +++ b/src/components/Select/NewSelect.tsx @@ -76,7 +76,7 @@ export const NewSelect = ({ items, handleChange, selectedItem, title }: SelectPr )}
{item.data.label} - ({item.data.value}) + {item.data.value}
)); diff --git a/src/constants/config.ts b/src/constants/config.ts index a5fb3aa..6a950ec 100644 --- a/src/constants/config.ts +++ b/src/constants/config.ts @@ -29,4 +29,7 @@ export default { zeroXApiKey: import.meta.env.VITE_ZERO_X_API_KEY, wagmiConnectProjectId: import.meta.env.VITE_WALLET_CONNECT_PROJECT_ID, + + liFiSdkIntegrator: import.meta.env.VITE_LIFI_SDK_INTEGRATOR, + liFiApiUrl: 'https://li.quest/v1', }; diff --git a/src/index.tsx b/src/index.tsx index 147a370..c791082 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,12 +4,14 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client'; import { ApolloProvider } from '@apollo/client/react'; import { WagmiProvider } from 'wagmi'; +import { getWalletClient, switchChain } from '@wagmi/core'; import { createWeb3Modal } from '@web3modal/wagmi/react'; import { defaultWagmiConfig } from '@web3modal/wagmi/react/config'; import { Toaster } from 'sonner'; // todo: remove later import { ToastContainer } from 'react-toastify'; import Modal from 'react-modal'; +import { createConfig as createLiFiConfig, EVM } from '@lifi/sdk'; import config from 'Constants/config'; import CHAINS from 'Constants/chains'; @@ -23,19 +25,33 @@ import 'react-toastify/dist/ReactToastify.css'; // todo: remove later Modal.setAppElement('#app'); +createLiFiConfig({ + apiUrl: config.liFiApiUrl, + integrator: config.liFiSdkIntegrator, + providers: [ + EVM({ + getWalletClient: () => getWalletClient(wagmiConfig), + switchChain: async (chainId) => { + const chain = await switchChain(wagmiConfig, { chainId }); + return getWalletClient(wagmiConfig, { chainId: chain.id }); + }, + }), + ], +}); + // react query const queryClient = new QueryClient({ - // defaultOptions: { - // queries: { - // staleTime: TIME_TO_WAIT, - // refetchOnMount: true, - // refetchOnReconnect: true, - // refetchOnWindowFocus: false, - // refetchInterval: TIME_TO_WAIT, - // cacheTime: CACHE_TIME, - // retry: QUERY_CLIENT_DEFAULT_RETRY_COUNT, - // }, - // }, + defaultOptions: { + queries: { + // staleTime: TIME_TO_WAIT, + refetchOnMount: false, + refetchOnReconnect: true, + refetchOnWindowFocus: false, + // refetchInterval: TIME_TO_WAIT, + // cacheTime: CACHE_TIME, + // retry: QUERY_CLIENT_DEFAULT_RETRY_COUNT, + }, + }, }); const link = new HttpLink({ diff --git a/src/services/lifi.ts b/src/services/lifi.ts new file mode 100644 index 0000000..7b81f43 --- /dev/null +++ b/src/services/lifi.ts @@ -0,0 +1,51 @@ +import type { Token, TokenAmount } from '@lifi/types'; +import { useQuery } from '@tanstack/react-query'; +import { getTokens, getTokenBalancesByChain } from '@lifi/sdk'; +import { Address } from 'viem'; + +import logger from 'Utils/logger'; + +export type ChainTokenMap = { + [chainId: number]: Address[]; +}; + +export type ChainTokenBalances = { [chainId: number]: TokenAmount[] }; + +type TokensByChain = { [chainId: number]: Token[] }; + +// query +export const useTokenBalances = (chainTokenMap: ChainTokenMap, walletAddress?: Address) => + useQuery({ + queryKey: ['token-balances', walletAddress, chainTokenMap], + queryFn: async () => { + try { + if (!walletAddress) return []; + + const tokensResponse = await getTokens({ + chains: Object.keys(chainTokenMap).map(Number), + }); + + const filteredTokens = Object.keys(chainTokenMap).reduce((acc, chainId) => { + acc[Number(chainId)] = tokensResponse.tokens[Number(chainId)].filter((token) => + chainTokenMap[Number(chainId)].includes(<`0x${string}`>token.address), + ); + + return acc; + }, {}); + + const tokenBalances: ChainTokenBalances = await getTokenBalancesByChain( + walletAddress, + filteredTokens, + ); + + logger.log('[service] queried token balances', { tokenBalances }); + + return tokenBalances; + } catch (error) { + logger.error('[service] Failed to query api keys', error); + } + + return; + }, + enabled: Boolean(walletAddress && Object.keys(chainTokenMap).length > 0), + }); diff --git a/src/shared/SybilTopUp/SybilTopUp.tsx b/src/shared/SybilTopUp/SybilTopUp.tsx index a15a8c0..8fe8423 100644 --- a/src/shared/SybilTopUp/SybilTopUp.tsx +++ b/src/shared/SybilTopUp/SybilTopUp.tsx @@ -1,16 +1,29 @@ import { useState, useEffect, useMemo } from 'react'; import { Button } from '@nextui-org/react'; +import { useAccount } from 'wagmi'; +import { formatUnits } from 'viem'; +import { useTokenBalances, ChainTokenMap } from 'Services/lifi'; import { TopUpModal } from 'Shared/TopUpModal'; import { useFetchAllowedChains } from 'Services/sybilService'; import { useModal } from 'Components/Modal'; import { mapTokensToOptions, mapChainsToNewOptions, mapTokenToOption } from 'Utils/mappers'; import { AllowedChain, AllowedToken } from 'Interfaces/common'; +import { formatFiatPrice } from 'Utils/numberFormat'; import { useSybilDeposit } from './useSybilDeposit'; +const getChainTokenMap = (allowedChains: AllowedChain[]) => { + return allowedChains.reduce((acc, chain) => { + acc[chain.chainId] = chain.tokens.map((token) => token.address); + + return acc; + }, {}); +}; + export const SybilTopUp = () => { const { isOpen, onOpen, onOpenChange } = useModal(); + const { address } = useAccount(); const [chain, setChain] = useState(); const [token, setToken] = useState(); @@ -19,9 +32,40 @@ export const SybilTopUp = () => { const { data: allowedChains, isLoading: isChainsLoading } = useFetchAllowedChains(); + const chainTokenMap = useMemo(() => getChainTokenMap(allowedChains ?? []), [allowedChains]); + + const { data: balances } = useTokenBalances(chainTokenMap, address); + + const mergedAllowedChains = useMemo(() => { + if (!allowedChains) { + return []; + } + + return allowedChains.map((chain) => { + const chainBalances = balances?.[chain.chainId] || []; + + return { + ...chain, + tokens: chain.tokens.map((token) => { + const tokenAmount = chainBalances.find((balance) => balance.address === token.address); + + const tokenBalance = + tokenAmount && tokenAmount.amount + ? parseFloat(formatUnits(tokenAmount.amount, tokenAmount.decimals)) + : 0; + + return { + ...token, + balance: `${tokenBalance} (${formatFiatPrice(tokenBalance * parseFloat(String(tokenAmount?.priceUSD ?? 1)))})`, + }; + }), + }; + }); + }, [allowedChains, balances]); + const mappedChains = useMemo( - () => allowedChains && mapChainsToNewOptions(allowedChains), - [allowedChains], + () => mergedAllowedChains && mapChainsToNewOptions(mergedAllowedChains), + [mergedAllowedChains], ); const mappedTokens = useMemo(() => chain && mapTokensToOptions(chain.tokens), [chain]); diff --git a/src/shared/TopUpModal/TopUpModal.tsx b/src/shared/TopUpModal/TopUpModal.tsx index c24d2bd..a0cdb22 100644 --- a/src/shared/TopUpModal/TopUpModal.tsx +++ b/src/shared/TopUpModal/TopUpModal.tsx @@ -1,9 +1,9 @@ -import { useTokenBalance } from 'Services/wagmiService'; import { useState, useCallback, useMemo } from 'react'; import { useSwitchChain, useAccount } from 'wagmi'; import { Input } from '@nextui-org/react'; import { type Address } from 'viem'; +import { useTokenBalance } from 'Services/wagmiService'; import { DEFAULT_TOP_UP_AMOUNT, DEFAULT_TOP_UP_AMOUNT_ETH } from 'Constants/ui'; import { NewSelect } from 'Components/Select/NewSelect'; import { Modal } from 'Components/Modal'; diff --git a/src/types/common.ts b/src/types/common.ts new file mode 100644 index 0000000..1580d3a --- /dev/null +++ b/src/types/common.ts @@ -0,0 +1,2 @@ +export type Nullable = T | null; +export type Nullish = Nullable | undefined; diff --git a/src/utils/mappers.ts b/src/utils/mappers.ts index 710da88..61375a5 100644 --- a/src/utils/mappers.ts +++ b/src/utils/mappers.ts @@ -1,5 +1,5 @@ -import { CHAINS_MAP } from 'Constants/chains.ts'; -import { TOKEN_IMAGES } from 'Constants/tokens.ts'; +import { CHAINS_MAP } from 'Constants/chains'; +import { TOKEN_IMAGES } from 'Constants/tokens'; export const mapChainToNewOption = (chain: any) => { const chainData = CHAINS_MAP[chain.chainId]; @@ -19,7 +19,7 @@ export const mapTokenToOption = (token: any) => ({ ...token, key: token.address, label: token.symbol, - value: token.address, + value: token.balance ?? token.address, avatar: TOKEN_IMAGES[token.symbol.toUpperCase()] ?? TOKEN_IMAGES.default, }); diff --git a/src/utils/numberFormat.ts b/src/utils/numberFormat.ts new file mode 100644 index 0000000..16e304e --- /dev/null +++ b/src/utils/numberFormat.ts @@ -0,0 +1,6 @@ +import { Nullish } from 'Types/common'; + +export function formatFiatPrice(price: Nullish, currency = 'USD'): string { + if (price === null || price === undefined) return '-'; + return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(price); +} diff --git a/tsconfig.json b/tsconfig.json index 192aa6f..7dde5aa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -68,6 +68,9 @@ "Hooks/*": [ "./hooks/*" ], + "Types/*": [ + "./types/*" + ], }, "outDir": "./dist", "incremental": true diff --git a/vite.config.ts b/vite.config.ts index 98a3997..b9ef7d3 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -26,6 +26,7 @@ export default defineConfig({ Stores: path.resolve(__dirname, './src/stores/'), SVGIcons: path.resolve(__dirname, './src/SVGIcons/'), Hooks: path.resolve(__dirname, './src/hooks/'), + Types: path.resolve(__dirname, './src/types/'), }, }, }); From 95aef54ae6d61d3053321ecf7b965a32956be870 Mon Sep 17 00:00:00 2001 From: nature-lover-iv Date: Mon, 6 Jan 2025 12:54:55 +0000 Subject: [PATCH 3/8] feat: add sybil canister selector --- src/canisters/sybilCanister.ts | 11 ++++++ src/constants/config.ts | 7 ++++ src/pages/APIKeys/APIKeys.tsx | 3 ++ src/pages/APIKeys/CanisterSelector.tsx | 36 +++++++++++++++++++ src/services/sybilService.ts | 50 +++++++++++++++++++------- src/stores/useApiKeyStore.ts | 6 ++++ 6 files changed, 100 insertions(+), 13 deletions(-) create mode 100644 src/pages/APIKeys/CanisterSelector.tsx diff --git a/src/canisters/sybilCanister.ts b/src/canisters/sybilCanister.ts index 2a7e4bd..f0b3786 100644 --- a/src/canisters/sybilCanister.ts +++ b/src/canisters/sybilCanister.ts @@ -1,6 +1,17 @@ +import { useMemo } from 'react'; + import { createActor } from 'OD/createActor'; import config from 'Constants/config'; +import { useApiKeyStore } from 'Stores/useApiKeyStore'; const sybilCanister = createActor(config.sybil_canister_id, 'sybil'); +export const useSybilCanister = () => { + const selectedCanister = useApiKeyStore.use.selectedCanister(); + + return useMemo(() => { + return createActor(selectedCanister, 'sybil'); + }, [selectedCanister]); +}; + export default sybilCanister; diff --git a/src/constants/config.ts b/src/constants/config.ts index 6a950ec..4f89942 100644 --- a/src/constants/config.ts +++ b/src/constants/config.ts @@ -18,8 +18,15 @@ export default { THE_GRAPH_URL: import.meta.env.VITE_THE_GRAPH_URL, + sybilCansiters: [ + 'wth3l-tiaaa-aaaap-aa5uq-cai', + 'xywyw-qiaaa-aaaad-aaema-cai', + 'tysiw-qaaaa-aaaak-qcikq-cai', + ], + pythia_canister_id: isStaging ? 'xmz4o-gqaaa-aaaag-qcjva-cai' : 'ettff-uaaaa-aaaag-abpcq-cai', sybil_canister_id: isStaging ? 'tysiw-qaaaa-aaaak-qcikq-cai' : 'wth3l-tiaaa-aaaap-aa5uq-cai', + // sybil_canister_id: isStaging ? 'xywyw-qiaaa-aaaad-aaema-cai' : 'wth3l-tiaaa-aaaap-aa5uq-cai', apollo_canister_id: isStaging ? 'ndeka-riaaa-aaaak-afmaq-cai' : 'iuq3c-pqaaa-aaaag-qdcva-cai', weatherSource1Key: import.meta.env.VITE_WEATHER_SOURCE_1_KEY, diff --git a/src/pages/APIKeys/APIKeys.tsx b/src/pages/APIKeys/APIKeys.tsx index 433381c..ebac71a 100644 --- a/src/pages/APIKeys/APIKeys.tsx +++ b/src/pages/APIKeys/APIKeys.tsx @@ -12,6 +12,7 @@ import { SybilTopUp } from 'Shared/SybilTopUp'; import { KeysTable } from './KeysTable'; import { DomainsTable } from './DomainsTable'; import { Example } from './Example'; +import { CanisterSelector } from './CanisterSelector'; export const APIKeys = () => { const { width } = useWindowDimensions(); @@ -38,6 +39,8 @@ export const APIKeys = () => { + + diff --git a/src/pages/APIKeys/CanisterSelector.tsx b/src/pages/APIKeys/CanisterSelector.tsx new file mode 100644 index 0000000..c49a66a --- /dev/null +++ b/src/pages/APIKeys/CanisterSelector.tsx @@ -0,0 +1,36 @@ +import { useCallback } from 'react'; +import { Select, SelectItem } from '@nextui-org/react'; + +import config from 'Constants/config'; +import { useApiKeyStore } from 'Stores/useApiKeyStore'; + +const items = config.sybilCansiters.map((canister) => ({ + key: canister, + label: canister, +})); + +export const CanisterSelector = () => { + const selectedCanister = useApiKeyStore.use.selectedCanister(); + const setSelectedCanister = useApiKeyStore.use.updateSelectedCanister(); + + const handleSelectionChange = useCallback( + (items: any[], handleChange: (arg0: any) => void) => (e: any) => { + const item = items.find((item) => item.key == e.target.value); + + handleChange(item.key); + }, + [], + ); + + return ( + + ); +}; diff --git a/src/services/sybilService.ts b/src/services/sybilService.ts index d41b273..0dbd5ae 100644 --- a/src/services/sybilService.ts +++ b/src/services/sybilService.ts @@ -1,13 +1,14 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { type Address, type Hash } from 'viem'; -import sybilCanister from 'Canisters/sybilCanister'; +import { useSybilCanister } from 'Canisters/sybilCanister'; import { GeneralResponse } from 'Interfaces/common'; import { remove0x } from 'Utils/addressUtils'; import { useGlobalState } from 'Providers/GlobalState'; import logger from 'Utils/logger'; import { DEFAULT_DOMAIN_LIMIT_PER_DAY } from 'Constants/ui'; import { type AllowedChain } from 'Interfaces/common'; +import { useApiKeyStore } from 'Stores/useApiKeyStore'; import { okOrErrResponseWrapper, toastWrapper } from './utils'; @@ -34,9 +35,11 @@ export type ApiKey = Omit & { // query export const useFetchApiKeys = () => { const { addressData } = useGlobalState(); + const sybilCanister = useSybilCanister(); + const selectedCanister = useApiKeyStore.use.selectedCanister(); return useQuery({ - queryKey: ['apiKeys', addressData], + queryKey: ['apiKeys', addressData, selectedCanister], queryFn: async () => { try { const promise = sybilCanister.get_api_keys( @@ -80,9 +83,11 @@ export const useFetchApiKeys = () => { // query export const useFetchAllowedDomains = () => { const { addressData } = useGlobalState(); + const sybilCanister = useSybilCanister(); + const selectedCanister = useApiKeyStore.use.selectedCanister(); return useQuery({ - queryKey: ['allowedDomains', addressData], + queryKey: ['allowedDomains', addressData, selectedCanister], queryFn: async () => { try { const promise = sybilCanister.get_allowed_domains( @@ -124,6 +129,7 @@ export const useFetchAllowedDomains = () => { export const useGenerateApiKey = () => { const { addressData } = useGlobalState(); const queryClient = useQueryClient(); + const sybilCanister = useSybilCanister(); return useMutation({ mutationFn: async () => { @@ -152,6 +158,7 @@ export const useGenerateApiKey = () => { export const useGrantDomain = () => { const { addressData } = useGlobalState(); const queryClient = useQueryClient(); + const sybilCanister = useSybilCanister(); return useMutation({ mutationFn: async (domain: string) => { @@ -180,9 +187,12 @@ export const useGrantDomain = () => { // todo: add to tokens coin of the chain + change transfer for this case // query -export const useFetchAllowedChains = () => - useQuery({ - queryKey: ['allowedChains'], +export const useFetchAllowedChains = () => { + const sybilCanister = useSybilCanister(); + const selectedCanister = useApiKeyStore.use.selectedCanister(); + + return useQuery({ + queryKey: ['allowedChains', selectedCanister], queryFn: async () => { try { const res: any = await sybilCanister.get_allowed_chains(); @@ -208,11 +218,15 @@ export const useFetchAllowedChains = () => return; }, }); +}; // query -export const useFetchSybilTreasureAddress = () => - useQuery({ - queryKey: ['treasureAddress'], +export const useFetchSybilTreasureAddress = () => { + const sybilCanister = useSybilCanister(); + const selectedCanister = useApiKeyStore.use.selectedCanister(); + + return useQuery({ + queryKey: ['treasureAddress', selectedCanister], queryFn: async () => { try { const res: Address = (await sybilCanister.get_treasure_address()) as Address; @@ -227,11 +241,13 @@ export const useFetchSybilTreasureAddress = () => return; }, }); +}; // mutate export const useDeposit = () => { const { addressData } = useGlobalState(); const queryClient = useQueryClient(); + const sybilCanister = useSybilCanister(); return useMutation({ mutationFn: async ({ chainId, tx_hash }: { chainId: number; tx_hash: Hash }) => { @@ -266,9 +282,11 @@ export const useDeposit = () => { // query export const useFetchBalance = () => { const { addressData } = useGlobalState(); + const sybilCanister = useSybilCanister(); + const selectedCanister = useApiKeyStore.use.selectedCanister(); return useQuery({ - queryKey: ['balance', addressData.address], + queryKey: ['balance', addressData.address, selectedCanister], queryFn: async () => { try { const promise = sybilCanister.get_balance(addressData.address) as Promise; @@ -290,9 +308,12 @@ export const useFetchBalance = () => { }; // query -export const useFetchBaseFee = () => - useQuery({ - queryKey: ['baseFee'], +export const useFetchBaseFee = () => { + const sybilCanister = useSybilCanister(); + const selectedCanister = useApiKeyStore.use.selectedCanister(); + + return useQuery({ + queryKey: ['baseFee', selectedCanister], queryFn: async () => { try { const res = (await sybilCanister.get_base_fee()) as bigint; @@ -307,11 +328,13 @@ export const useFetchBaseFee = () => return; }, }); +}; // mutate export const useDeleteApiKey = () => { const { addressData } = useGlobalState(); const queryClient = useQueryClient(); + const sybilCanister = useSybilCanister(); return useMutation({ mutationFn: async (apiKey: string) => { @@ -339,6 +362,7 @@ export const useDeleteApiKey = () => { export const useBanDomain = () => { const { addressData } = useGlobalState(); const queryClient = useQueryClient(); + const sybilCanister = useSybilCanister(); return useMutation({ mutationFn: async (domain: string) => { diff --git a/src/stores/useApiKeyStore.ts b/src/stores/useApiKeyStore.ts index 780b0c7..903a6d3 100644 --- a/src/stores/useApiKeyStore.ts +++ b/src/stores/useApiKeyStore.ts @@ -1,19 +1,25 @@ import { create } from 'zustand'; +import config from 'Constants/config'; + import { createSelectors } from './createSelectors'; type State = { selectedApiKey: string | null; + selectedCanister: string; }; type Action = { updateSelectedApiKey: (apiKey: string | null) => void; + updateSelectedCanister: (canister: string) => void; }; const useApiKeyStoreBase = create((set) => ({ selectedApiKey: '', + selectedCanister: config.sybilCansiters[0], updateSelectedApiKey: (apiKey) => set(() => ({ selectedApiKey: apiKey })), + updateSelectedCanister: (canister) => set(() => ({ selectedCanister: canister })), })); export const useApiKeyStore = createSelectors(useApiKeyStoreBase); From 40a64cb5b8f7b1559dfcf0873fce912988fbc999 Mon Sep 17 00:00:00 2001 From: nature-lover-iv Date: Mon, 6 Jan 2025 12:58:22 +0000 Subject: [PATCH 4/8] chore: remove domain logic --- src/pages/APIKeys/APIKeys.tsx | 5 -- src/pages/APIKeys/DomainsTable.tsx | 68 ------------------- src/services/sybilService.ts | 105 ----------------------------- 3 files changed, 178 deletions(-) delete mode 100644 src/pages/APIKeys/DomainsTable.tsx diff --git a/src/pages/APIKeys/APIKeys.tsx b/src/pages/APIKeys/APIKeys.tsx index ebac71a..a7b36ed 100644 --- a/src/pages/APIKeys/APIKeys.tsx +++ b/src/pages/APIKeys/APIKeys.tsx @@ -10,7 +10,6 @@ import ROUTES from 'Constants/routes'; import { SybilTopUp } from 'Shared/SybilTopUp'; import { KeysTable } from './KeysTable'; -import { DomainsTable } from './DomainsTable'; import { Example } from './Example'; import { CanisterSelector } from './CanisterSelector'; @@ -56,10 +55,6 @@ export const APIKeys = () => {
- -
- -
); diff --git a/src/pages/APIKeys/DomainsTable.tsx b/src/pages/APIKeys/DomainsTable.tsx deleted file mode 100644 index c67af4f..0000000 --- a/src/pages/APIKeys/DomainsTable.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import { useCallback, useMemo, useState } from 'react'; -import { Input } from '@nextui-org/react'; - -import { Modal, useModal } from 'Components/Modal.tsx'; -import { type Column } from 'Components/Table'; -import { useBanDomain, useFetchAllowedDomains, useGrantDomain } from 'Services/sybilService'; - -import { SybilTable } from './SybilTable'; - -const additionalColumns: Column[] = [ - { - label: 'Domain', - key: 'domain', - }, -]; - -export const DomainsTable = () => { - const [newDomain, setNewDomain] = useState(''); - - const { isOpen, onOpenChange, onOpen, onClose } = useModal(); - - const { data: allowedDomains, isLoading } = useFetchAllowedDomains(); - const { mutate: grantDomain, isPending } = useGrantDomain(); - const { mutate: banDomain } = useBanDomain(); - - const grantAction = useMemo( - () => [ - { - label: 'Grant', - onPress: () => { - grantDomain(newDomain); - setNewDomain(''); - onClose(); - }, - }, - ], - [newDomain], - ); - - return ( - <> - - - - setNewDomain(e.target.value), [])} - /> - - - ); -}; diff --git a/src/services/sybilService.ts b/src/services/sybilService.ts index 0dbd5ae..f589444 100644 --- a/src/services/sybilService.ts +++ b/src/services/sybilService.ts @@ -6,7 +6,6 @@ import { GeneralResponse } from 'Interfaces/common'; import { remove0x } from 'Utils/addressUtils'; import { useGlobalState } from 'Providers/GlobalState'; import logger from 'Utils/logger'; -import { DEFAULT_DOMAIN_LIMIT_PER_DAY } from 'Constants/ui'; import { type AllowedChain } from 'Interfaces/common'; import { useApiKeyStore } from 'Stores/useApiKeyStore'; @@ -80,51 +79,6 @@ export const useFetchApiKeys = () => { }); }; -// query -export const useFetchAllowedDomains = () => { - const { addressData } = useGlobalState(); - const sybilCanister = useSybilCanister(); - const selectedCanister = useApiKeyStore.use.selectedCanister(); - - return useQuery({ - queryKey: ['allowedDomains', addressData, selectedCanister], - queryFn: async () => { - try { - const promise = sybilCanister.get_allowed_domains( - addressData.message, - remove0x(addressData.signature), - ) as Promise; - const wrappedPromise = okOrErrResponseWrapper(promise); - - const res = await wrappedPromise; - - // formatter - const allowedDomains: AllowedDomain[] = res.map(([domain, domainData]: any) => { - return { - key: domain, - domain, - ownerAddress: domainData.grantor_address, - lastRequest: domainData.last_request, - requestCount: Number(domainData.request_count), - requestCountPerMethod: domainData.request_count_per_method, - requestLimit: Number(domainData.request_limit), - requestCountToday: Number(domainData.request_count_today), - }; - }); - - logger.log('[service] queried allowed domains', { res, allowedDomains }); - - return allowedDomains; - } catch (error) { - logger.error('[service] Failed to query allowed domains', error); - } - - return; - }, - enabled: Boolean(addressData && addressData.signature), - }); -}; - // mutate export const useGenerateApiKey = () => { const { addressData } = useGlobalState(); @@ -154,37 +108,6 @@ export const useGenerateApiKey = () => { }); }; -// mutate -export const useGrantDomain = () => { - const { addressData } = useGlobalState(); - const queryClient = useQueryClient(); - const sybilCanister = useSybilCanister(); - - return useMutation({ - mutationFn: async (domain: string) => { - const promise = sybilCanister.grant( - domain, - [DEFAULT_DOMAIN_LIMIT_PER_DAY], - addressData.message, - remove0x(addressData.signature), - ) as Promise; - const wrappedPromise = okOrErrResponseWrapper(promise); - - const res = await toastWrapper(wrappedPromise, 'Grant Domain'); - - console.log('[service] granted domain', { res }); - - return res; - }, - onError: (error, variables, context) => { - logger.error(`[service] Failed to grant domain`, error, variables, context); - }, - onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ['allowedDomains'] }); - }, - }); -}; - // todo: add to tokens coin of the chain + change transfer for this case // query export const useFetchAllowedChains = () => { @@ -357,31 +280,3 @@ export const useDeleteApiKey = () => { }, }); }; - -// mutate -export const useBanDomain = () => { - const { addressData } = useGlobalState(); - const queryClient = useQueryClient(); - const sybilCanister = useSybilCanister(); - - return useMutation({ - mutationFn: async (domain: string) => { - const promise = sybilCanister.restrict( - domain, - addressData.message, - remove0x(addressData.signature), - ); - const res = await toastWrapper(promise, 'Ban Domain'); - - logger.log('[service] ban domain', { res }); - - return res; - }, - onError: (error: any, variables: any, context: any) => { - logger.error(`[service] Failed to ban domain`, error, variables, context); - }, - onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ['allowedDomains'] }); - }, - }); -}; From 0793224a686cdc172eeab1ecdd0d4c098ce965c1 Mon Sep 17 00:00:00 2001 From: nature-lover-iv Date: Mon, 6 Jan 2025 13:09:02 +0000 Subject: [PATCH 5/8] chore: add copy button for api keys --- src/pages/APIKeys/SybilTable.tsx | 56 ++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/pages/APIKeys/SybilTable.tsx b/src/pages/APIKeys/SybilTable.tsx index 906f77d..0cf4db4 100644 --- a/src/pages/APIKeys/SybilTable.tsx +++ b/src/pages/APIKeys/SybilTable.tsx @@ -1,27 +1,25 @@ import { useCallback, useMemo, useState } from 'react'; -import { Button, Progress, Tooltip, type TableProps } from '@nextui-org/react'; -import { formatUnits } from 'viem'; +import { Button, type TableProps, Snippet } from '@nextui-org/react'; import { useGlobalState } from 'Providers/GlobalState'; import { Table, type Column } from 'Components/Table'; import { DeleteIcon } from 'SVGICons/DeleteIcon'; import { Modal, useModal } from 'Components/Modal'; -import { type ApiKey, type AllowedDomain, useFetchBaseFee } from 'Services/sybilService'; -import { BALANCE_USD_DECIMALS } from 'Utils/balance'; +import { type ApiKey, useFetchBaseFee } from 'Services/sybilService'; const columns: Column[] = [ { key: 'requestCount', label: 'Requests', }, - { - key: 'spent', - label: 'Spent', - }, - { - key: 'limit', - label: 'Limit (1d)', - }, + // { + // key: 'spent', + // label: 'Spent', + // }, + // { + // key: 'limit', + // label: 'Limit (1d)', + // }, { key: 'actions', label: 'Actions', @@ -62,26 +60,34 @@ export const SybilTable = ({ const { data: baseFee, isLoading: isFeeLoading } = useFetchBaseFee(); const renderCell = useCallback( - (item: ApiKey | AllowedDomain, columnKey: string) => { + (item: ApiKey, columnKey: string) => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-expect-error const cellValue = item[columnKey]; switch (columnKey) { - case 'spent': - return item.requestCount && baseFee - ? `$${formatUnits(BigInt(item.requestCount) * baseFee, BALANCE_USD_DECIMALS)}` - : 0; - case 'limit': + case 'apiKey': return ( - - - +
+ + {item.apiKey} + +
); + // case 'spent': + // return item.requestCount && baseFee + // ? `$${formatUnits(BigInt(item.requestCount) * baseFee, BALANCE_USD_DECIMALS)}` + // : 0; + // case 'limit': + // return ( + // + // + // + // ); case 'actions': return (
From cd7db370fc4d1c4a045503e695638e8cf89ff28e Mon Sep 17 00:00:00 2001 From: nature-lover-iv Date: Mon, 6 Jan 2025 13:12:54 +0000 Subject: [PATCH 6/8] chore: add tooltip for balance with unrounded value --- src/shared/SybilBalance/SybilBalance.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/shared/SybilBalance/SybilBalance.tsx b/src/shared/SybilBalance/SybilBalance.tsx index ed905ee..8478050 100644 --- a/src/shared/SybilBalance/SybilBalance.tsx +++ b/src/shared/SybilBalance/SybilBalance.tsx @@ -1,3 +1,4 @@ +import { Tooltip } from '@nextui-org/react'; import { Typography } from 'antd'; import { formatBalance } from 'Utils/balance'; import { useFetchBalance } from 'Services/sybilService'; @@ -6,10 +7,14 @@ export const SybilBalance = () => { const { data: balance, isLoading: isBalanceLoading } = useFetchBalance(); return ( - - Balance:{' '} - {(!balance || isBalanceLoading) && balance !== 0 ? '...' : formatBalance(balance).toFixed(2)}{' '} - USD - + + + Balance:{' '} + {(!balance || isBalanceLoading) && balance !== 0 + ? '...' + : formatBalance(balance).toFixed(2)}{' '} + USD + + ); }; From 8c4756491cfb801e9ef7fe25a1bcdaa85bf92784 Mon Sep 17 00:00:00 2001 From: nature-lover-iv Date: Tue, 7 Jan 2025 16:53:59 +0000 Subject: [PATCH 7/8] chore: add dxr methods to example --- src/pages/APIKeys/Example.tsx | 65 +++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/src/pages/APIKeys/Example.tsx b/src/pages/APIKeys/Example.tsx index 440784c..6a45c81 100644 --- a/src/pages/APIKeys/Example.tsx +++ b/src/pages/APIKeys/Example.tsx @@ -1,12 +1,12 @@ import { useState, useCallback, useMemo } from 'react'; import { Select, SelectItem, Card, CardFooter, Switch, Snippet, Link } from '@nextui-org/react'; -import config from 'Constants/config'; +// import config from 'Constants/config'; import { useApiKeyStore } from 'Stores/useApiKeyStore'; import { useFetchApiKeys } from 'Services/sybilService'; // https://tysiw-qaaaa-aaaak-qcikq-cai.icp0.io/get_xrc_data_with_proof?id=DOGE/LINK -const host = `https://${config.sybil_canister_id}.icp0.io/`; +// const host = `https://${config.sybil_canister_id}.icp0.io/`; const feeds = [ { @@ -38,19 +38,29 @@ const feeds = [ const methods = [ { - key: 'get_xrc_data_with_proof', - label: 'get_xrc_data_with_proof', + key: 'get_dxr_data_batch', + label: 'get_dxr_data_batch', }, { - key: 'read_logs_with_proof', - label: 'read_logs_with_proof', - }, - { - key: 'read_contract_with_proof', - label: 'read_contract_with_proof', + key: 'get_dxr_data_batch_with_proof', + label: 'get_dxr_data_batch_with_proof', }, + // { + // key: 'get_xrc_data_with_proof', + // label: 'get_xrc_data_with_proof', + // }, + // { + // key: 'read_logs_with_proof', + // label: 'read_logs_with_proof', + // }, + // { + // key: 'read_contract_with_proof', + // label: 'read_contract_with_proof', + // }, ]; +const getDxrDataBatchExtraFields = ['chain_id', 'pool_addresses[]', 'dex_type']; + const readLogsExtraFields = ['chain_id', 'block_from', 'block_to', 'topics', 'limit', 'addresses']; const readContractExtraFields = [ @@ -65,9 +75,11 @@ const readContractExtraFields = [ export const Example = () => { const selectedApiKey = useApiKeyStore.use.selectedApiKey(); const updateSelectedApiKey = useApiKeyStore.use.updateSelectedApiKey(); + const selectedCanister = useApiKeyStore.use.selectedCanister(); + const host = `https://${selectedCanister}.icp0.io/`; const { data: apiKeys } = useFetchApiKeys(); - const [feed, setFeed] = useState(feeds[0].key); + const [feed] = useState(feeds[0].key); const [method, setMethod] = useState(methods[0].key); const [bytes, setBytes] = useState(true); const [cacheTtl, setCacheTtl] = useState(true); @@ -89,34 +101,37 @@ export const Example = () => { } }, [apiKeys, selectedApiKey]); - const selectedFeed = useMemo(() => [feed], [feed]); + // const selectedFeed = useMemo(() => [feed], [feed]); const selectedMethod = useMemo(() => [method], [method]); const codeString = useMemo(() => { + console.log({ method, getDxrDataBatchExtraFields }); if (method === 'get_xrc_data_with_proof') { return `${host}${method}?id=${feed}${selectedApiKey ? `&api_key=${selectedApiKey}` : ''}${bytes ? `&bytes=true` : ''}${cacheTtl ? `&cache_ttl=1800` : ''}`; } else if (method === 'read_logs_with_proof') { return `${host}${method}?${readLogsExtraFields.map((field) => `${field}={}`).join('&')}${selectedApiKey ? `&api_key=${selectedApiKey}` : ''}${bytes ? `&bytes=true` : ''}${cacheTtl ? `&cache_ttl=1800` : ''}`; } else if (method === 'read_contract_with_proof') { return `${host}${method}?${readContractExtraFields.map((field) => `${field}={}`).join('&')}${selectedApiKey ? `&api_key=${selectedApiKey}` : ''}${bytes ? `&bytes=true` : ''}${cacheTtl ? `&cache_ttl=1800` : ''}`; + } else if (method === 'get_dxr_data_batch_with_proof') { + return `${host}${method}?${getDxrDataBatchExtraFields.map((field) => `${field}={}`).join('&')}${selectedApiKey ? `&api_key=${selectedApiKey}` : ''}${bytes ? `&bytes=true` : ''}${cacheTtl ? `&cache_ttl=1800` : ''}`; } return ''; - }, [method, feed, selectedApiKey, bytes, cacheTtl]); + }, [host, method, feed, selectedApiKey, bytes, cacheTtl]); return (
- + {/**/} + {/* {(feed) => {feed.label}}*/} + {/**/}