diff --git a/.changeset/blue-parents-rhyme.md b/.changeset/blue-parents-rhyme.md new file mode 100644 index 00000000..91619420 --- /dev/null +++ b/.changeset/blue-parents-rhyme.md @@ -0,0 +1,5 @@ +--- +'@node-real/walletkit': patch +--- + +Fix module resolve issue diff --git a/.changeset/rude-hornets-shop.md b/.changeset/rude-hornets-shop.md new file mode 100644 index 00000000..bca7080d --- /dev/null +++ b/.changeset/rude-hornets-shop.md @@ -0,0 +1,5 @@ +--- +'@node-real/walletkit': patch +--- + +Support telegram mini app diff --git a/examples/nextjs/pages/_app.tsx b/examples/nextjs/pages/_app.tsx index 3b0670d1..f1696eb0 100644 --- a/examples/nextjs/pages/_app.tsx +++ b/examples/nextjs/pages/_app.tsx @@ -19,6 +19,7 @@ const config: WalletKitConfig = { evmConfig({ autoConnect: true, initialChainId: 1, + walletConnectProjectId: 'e68a1816d39726c2afabf05661a32767', wallets: [metaMask(), trustWallet(), walletConnect()], chains: [mainnet] as any[], }), diff --git a/examples/vite/src/App.tsx b/examples/vite/src/App.tsx index 92b7dab6..e1ad0d65 100644 --- a/examples/vite/src/App.tsx +++ b/examples/vite/src/App.tsx @@ -18,6 +18,7 @@ const config: WalletKitConfig = { evmConfig({ autoConnect: true, initialChainId: 1, + walletConnectProjectId: 'e68a1816d39726c2afabf05661a32767', wallets: [metaMask(), trustWallet(), walletConnect()], chains: [mainnet] as any[], }), diff --git a/packages/walletkit/__dev__/App.tsx b/packages/walletkit/__dev__/App.tsx index 8c9ddcef..144378af 100644 --- a/packages/walletkit/__dev__/App.tsx +++ b/packages/walletkit/__dev__/App.tsx @@ -11,7 +11,6 @@ import { binanceWeb3Wallet, bitgetWallet, coinbaseWallet, - EthereumScript, evmConfig, mathWallet, metaMask, @@ -50,6 +49,7 @@ const config: WalletKitConfig = { evmConfig({ autoConnect: true, initialChainId: 1, + walletConnectProjectId: 'e68a1816d39726c2afabf05661a32767', chains: [mainnet, bsc], wallets: [ metaMask(), diff --git a/packages/walletkit/evm/package.json b/packages/walletkit/evm/package.json new file mode 100644 index 00000000..ebe76cbd --- /dev/null +++ b/packages/walletkit/evm/package.json @@ -0,0 +1,3 @@ +{ + "main": "../dist/evm/index.js" +} diff --git a/packages/walletkit/package.json b/packages/walletkit/package.json index 4ae864a8..9733626e 100644 --- a/packages/walletkit/package.json +++ b/packages/walletkit/package.json @@ -14,13 +14,16 @@ "keywords": [ "walletkit" ], - "type": "module", - "files": [ - "dist" - ], "sideEffects": false, "main": "./dist/core/index.js", "types": "./dist/core/index.d.ts", + "type": "module", + "files": [ + "dist", + "evm", + "solana", + "styles.css" + ], "exports": { ".": "./dist/core/index.js", "./styles.css": "./dist/style.css", @@ -38,9 +41,9 @@ "build": "vite build" }, "peerDependencies": { + "@tanstack/react-query": "^5", "react": ">=17", "react-dom": ">=17", - "@tanstack/react-query": "^5", "viem": "^2", "wagmi": "^2" }, @@ -72,6 +75,7 @@ "viem": "^2.17.4", "vite": "^4.5.3", "vite-plugin-dts": "^3.9.1", + "vite-plugin-mkcert": "^1.17.6", "wagmi": "^2.10.10" } } diff --git a/packages/walletkit/solana/package.json b/packages/walletkit/solana/package.json new file mode 100644 index 00000000..c291b98a --- /dev/null +++ b/packages/walletkit/solana/package.json @@ -0,0 +1,3 @@ +{ + "main": "../dist/solana/index.js" +} diff --git a/packages/walletkit/src/core/base/utils/mobile.ts b/packages/walletkit/src/core/base/utils/mobile.ts index 228fbfd6..db238741 100644 --- a/packages/walletkit/src/core/base/utils/mobile.ts +++ b/packages/walletkit/src/core/base/utils/mobile.ts @@ -21,3 +21,17 @@ export function isIOS(): boolean { export function isMobile(): boolean { return isAndroid() || isIOS(); } + +// telegram mini app +export function isTMA(): boolean { + const check = (host: any) => { + return ( + typeof host !== 'undefined' && + 'TelegramWebviewProxy' in host && + 'postEvent' in host.TelegramWebviewProxy && + typeof host.TelegramWebviewProxy.postEvent === 'function' + ); + }; + + return check(window); +} diff --git a/packages/walletkit/src/core/configs/getDefaultConfig.ts b/packages/walletkit/src/core/configs/getDefaultConfig.ts index 3aa649bf..6bca44b0 100644 --- a/packages/walletkit/src/core/configs/getDefaultConfig.ts +++ b/packages/walletkit/src/core/configs/getDefaultConfig.ts @@ -6,11 +6,10 @@ import { EvmConfig } from '@/evm/utils/evmConfig'; type DefaultConfig = Pick; export function getDefaultConfig(config: WalletKitConfig): DefaultConfig { - const evmConfig = config.walletConfigs.find((item) => item.walletType === 'evm') as EvmConfig; + const { appearance, eventConfig, walletConfigs } = config; - const solanaConfig = config.walletConfigs.find( - (item) => item.walletType === 'solana', - ) as SolanaConfig; + const evmConfig = walletConfigs.find((item) => item.walletType === 'evm') as EvmConfig; + const solanaConfig = walletConfigs.find((item) => item.walletType === 'solana') as SolanaConfig; return { appearance: { @@ -27,7 +26,7 @@ export function getDefaultConfig(config: WalletKitConfig): DefaultConfig { walletDownloadUrl: `https://trustwallet.com/`, - ...config.appearance, + ...appearance, }, eventConfig: { @@ -43,7 +42,7 @@ export function getDefaultConfig(config: WalletKitConfig): DefaultConfig { }); } }, - ...config.eventConfig, + ...eventConfig, }, walletConfig: { @@ -52,5 +51,3 @@ export function getDefaultConfig(config: WalletKitConfig): DefaultConfig { }, }; } - -export const WALLET_CONNECT_PROJECT_ID = 'e68a1816d39726c2afabf05661a32767'; diff --git a/packages/walletkit/src/core/configs/types.ts b/packages/walletkit/src/core/configs/types.ts index 35b8da32..83b2a7c1 100644 --- a/packages/walletkit/src/core/configs/types.ts +++ b/packages/walletkit/src/core/configs/types.ts @@ -21,6 +21,7 @@ export interface BaseWallet extends WalletConfig { isVisible?: boolean; render?: (props: WalletRenderProps) => React.ReactNode; showQRCode?: boolean; + useWalletConnect?: boolean; isInstalled: () => boolean | undefined; } diff --git a/packages/walletkit/src/core/modals/ConnectModal/ConnectingView/index.tsx b/packages/walletkit/src/core/modals/ConnectModal/ConnectingView/index.tsx index 482c85b1..4105532e 100644 --- a/packages/walletkit/src/core/modals/ConnectModal/ConnectingView/index.tsx +++ b/packages/walletkit/src/core/modals/ConnectModal/ConnectingView/index.tsx @@ -23,26 +23,27 @@ interface ConnectingViewProps { runConnect: () => void; wallet: BaseWallet; isConnected: boolean; + isReady?: boolean; } export function ConnectingView(props: ConnectingViewProps) { - const { status, runConnect, wallet, isConnected } = props; + const { status, runConnect, wallet, isConnected, isReady = true } = props; const log = useLogger(); const logos = useWalletLogos(wallet.logos); const downloadUrl = useWalletDownloadUrl(wallet.downloadUrls); useEffect(() => { - if (status === CONNECT_STATUS.UNAVAILABLE) return; + log('[connecting page]', `name: ${wallet?.name}, status: ${status}`); + + if (status === CONNECT_STATUS.UNAVAILABLE || !isReady) return; const connectTimeout = setTimeout(runConnect, 600); return () => { clearTimeout(connectTimeout); }; // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); - - log('[connecting page]', `name: ${wallet?.name}, status: ${status}`); + }, [isReady]); const isError = [ CONNECT_STATUS.FAILED, diff --git a/packages/walletkit/src/core/modals/ConnectModal/RouteProvider/index.tsx b/packages/walletkit/src/core/modals/ConnectModal/RouteProvider/index.tsx index 24b9a172..ad9142a7 100644 --- a/packages/walletkit/src/core/modals/ConnectModal/RouteProvider/index.tsx +++ b/packages/walletkit/src/core/modals/ConnectModal/RouteProvider/index.tsx @@ -2,6 +2,7 @@ import { useState, useRef, useMemo, useCallback } from 'react'; import { RouteContext } from './context'; import { EvmConnectingView } from '@/evm/components/EvmConnectingView'; import { EvmConnectWithQRCodeView } from '@/evm/components/EvmConnectWithQRCodeView'; +import { EvmConnectWithWalletConnectView } from '@/evm/components/EvmConnectWithWalletConnectView'; import { SolanaConnectingView } from '@/solana/components/SolanaConnectingView'; import { SolanaConnectWithQRCodeView } from '@/solana/components/SolanaConnectWithQRCodeView'; import { ConnectorsView } from '../ConnectorsView'; @@ -10,6 +11,7 @@ export enum ViewRoutes { CONNECTORS = 'Connectors', EVM_CONNECTING = 'EvmConnecting', EVM_CONNECT_WITH_QRCODE = 'EvmConnectWithQRCode', + EVM_CONNECT_WITH_WALLET_CONNECT = 'EvmConnectWithWalletConnectView', SOLANA_CONNECTING = 'SolanaConnecting', SOLANA_CONNECT_WITH_QRCODE = 'SolanaConnectWithQRCode', } @@ -32,6 +34,8 @@ export function RouteProvider(props: RouteProviderProps) { return ; case ViewRoutes.EVM_CONNECT_WITH_QRCODE: return ; + case ViewRoutes.EVM_CONNECT_WITH_WALLET_CONNECT: + return ; case ViewRoutes.SOLANA_CONNECTING: return ; case ViewRoutes.SOLANA_CONNECT_WITH_QRCODE: diff --git a/packages/walletkit/src/core/providers/WalletKitProvider/index.tsx b/packages/walletkit/src/core/providers/WalletKitProvider/index.tsx index b7fc9f47..4d70e4a6 100644 --- a/packages/walletkit/src/core/providers/WalletKitProvider/index.tsx +++ b/packages/walletkit/src/core/providers/WalletKitProvider/index.tsx @@ -1,5 +1,5 @@ import { ThemeProvider } from '../ThemeProvider'; -import { useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { EvmWalletProvider } from '@/evm/components/EvmWalletProvider'; import { SolanaWalletProvider } from '@/solana/components/SolanaWalletProvider'; import { Action, WalletKitConfig, WalletKitContext } from './context'; @@ -8,6 +8,7 @@ import { ConnectModalProvider } from '@/core/modals/ConnectModal/provider'; import { ToastProvider } from '@/core/base/components/toast/ToastProvider'; import { BaseWallet } from '@/core/configs/types'; import { ProfileModalProvider } from '@/core/modals/ProfileModal/provider'; +import { isTMA } from '@/core/base/utils/mobile'; export interface WalletKitProviderProps { config: WalletKitConfig; @@ -56,6 +57,17 @@ export function WalletKitProvider(props: WalletKitProviderProps) { }; }, [action, config.debug, finalConfig, selectedWallet, wallets]); + // TMA hack + useEffect(() => { + if (isTMA()) { + window.open = (function (open) { + return function (url, _, features) { + return open.call(window, url, '_blank', features); + }; + })(window.open); + } + }, []); + return ( diff --git a/packages/walletkit/src/evm/components/EvmConnectWithQRCodeView/index.tsx b/packages/walletkit/src/evm/components/EvmConnectWithQRCodeView/index.tsx index a36b2604..497a27a2 100644 --- a/packages/walletkit/src/evm/components/EvmConnectWithQRCodeView/index.tsx +++ b/packages/walletkit/src/evm/components/EvmConnectWithQRCodeView/index.tsx @@ -1,16 +1,16 @@ import { ConnectWithQRCode } from '@/core/modals/ConnectModal/ConnectWithQRCode'; import { useSelectedWallet } from '@/core/providers/WalletKitProvider/context'; import { useEvmIsConnected } from '@/evm/hooks/useEvmIsConnected'; -import { useQRCodeUri } from '@/evm/hooks/useQRCodeUri'; +import { useWalletConnectUri } from '@/evm/hooks/useWalletConnectUri'; import { useWalletConnectModal } from '@/evm/hooks/useWalletConnectModal'; import { EvmWallet, isWalletConnect } from '@/evm/wallets'; export function EvmConnectWithQRCodeView() { const { selectedWallet } = useSelectedWallet(); - const wcUri = useQRCodeUri(); + const wcUri = useWalletConnectUri(); const wcModal = useWalletConnectModal(); - const qrCodeUri = wcUri && ((selectedWallet as EvmWallet).getQRCodeUri?.(wcUri) ?? wcUri); + const qrCodeUri = wcUri && ((selectedWallet as EvmWallet).getUri?.(wcUri) ?? wcUri); const isConnected = useEvmIsConnected(); return ( diff --git a/packages/walletkit/src/evm/components/EvmConnectWithWalletConnectView/index.tsx b/packages/walletkit/src/evm/components/EvmConnectWithWalletConnectView/index.tsx new file mode 100644 index 00000000..65911f43 --- /dev/null +++ b/packages/walletkit/src/evm/components/EvmConnectWithWalletConnectView/index.tsx @@ -0,0 +1,65 @@ +import { CONNECT_STATUS } from '@/core/constants'; +import { ConnectingView } from '@/core/modals/ConnectModal/ConnectingView'; +import { useLogger, useSelectedWallet } from '@/core/providers/WalletKitProvider/context'; +import { useEvmIsConnected } from '@/evm/hooks/useEvmIsConnected'; +import { useWalletConnectUri } from '@/evm/hooks/useWalletConnectUri'; +import { EvmWallet } from '@/evm/wallets'; +import { useCallback, useState } from 'react'; + +export function EvmConnectWithWalletConnectView() { + const { selectedWallet } = useSelectedWallet(); + + const log = useLogger(); + const [status, setStatus] = useState(CONNECT_STATUS.CONNECTING); + + const wcUri = useWalletConnectUri({ + onError(error: any) { + if (error.code) { + // https://github.com/MetaMask/eth-rpc-errors/blob/main/src/error-constants.ts + switch (error.code) { + case -32002: + setStatus(CONNECT_STATUS.NOTCONNECTED); + break; + case 4001: + setStatus(CONNECT_STATUS.REJECTED); + break; + default: + setStatus(CONNECT_STATUS.FAILED); + break; + } + } else { + // Sometimes the error doesn't respond with a code + if (error.message) { + switch (error.message) { + case 'User rejected request': + setStatus(CONNECT_STATUS.REJECTED); + break; + default: + setStatus(CONNECT_STATUS.FAILED); + break; + } + } + } + }, + }); + + const walletUri = (selectedWallet as EvmWallet).getUri(wcUri); + const isConnected = useEvmIsConnected(); + + const onClickConnect = useCallback(() => { + log(`[connectWithWalletConnect] walletUri`, walletUri); + setStatus(CONNECT_STATUS.CONNECTING); + window.open(walletUri, '_self', 'noopener noreferrer'); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [walletUri]); + + return ( + + ); +} diff --git a/packages/walletkit/src/evm/components/SetEvmWalletClickRef/index.tsx b/packages/walletkit/src/evm/components/SetEvmWalletClickRef/index.tsx index 44e75052..d1eb49da 100644 --- a/packages/walletkit/src/evm/components/SetEvmWalletClickRef/index.tsx +++ b/packages/walletkit/src/evm/components/SetEvmWalletClickRef/index.tsx @@ -1,5 +1,5 @@ +import { isMobile, isTMA } from '@/core/base/utils/mobile'; import { UseWalletRenderProps } from '@/core/hooks/useWalletRender'; -import { isMobile } from '@/core/index'; import { useConnectModal } from '@/core/modals/ConnectModal/context'; import { ViewRoutes } from '@/core/modals/ConnectModal/RouteProvider'; import { useRouter } from '@/core/modals/ConnectModal/RouteProvider/context'; @@ -33,7 +33,6 @@ export function SetEvmWalletClickRef(props: SetEvmWalletClickRefProps) { const router = useRouter(); const timerRef = useRef(); - const mobile = isMobile(); const { wallets } = useEvmConfig(); clickRef.current = (walletId: string, e: React.MouseEvent) => { @@ -67,31 +66,50 @@ export function SetEvmWalletClickRef(props: SetEvmWalletClickRefProps) { jumpTo(ViewRoutes.EVM_CONNECTING); }; + const jumpToWalletConnectView = () => { + jumpTo(ViewRoutes.EVM_CONNECT_WITH_WALLET_CONNECT); + }; + disconnect(); clearTimeout(timerRef.current); timerRef.current = setTimeout(() => { - if (isWalletConnect(connector.id)) { - if (wallet.showQRCode) { - jumpToQRCodeView(); + if (isTMA()) { + // 1. TMA + if (isMobile()) { + jumpToWalletConnectView(); } else { - wcModal.onOpen(); + jumpToQRCodeView(); } - } else if (!wallet.isInstalled()) { - if (mobile) { + } else if (isMobile()) { + // 2. mobile + if (isWalletConnect(walletId)) { + wcModal.onOpen(); + } else if (wallet.useWalletConnect) { + jumpToWalletConnectView(); + } else if (wallet.isInstalled()) { + jumpToConnectingView(); + } else { const deepLink = wallet.getDeepLink?.(); if (deepLink) { window.open(deepLink, '_self', 'noopener noreferrer'); } else { eventConfig.onError?.(new Error('Not supported wallet'), 'Not supported wallet'); } + } + } else { + // 3. pc + if (isWalletConnect(walletId)) { + if (wallet.showQRCode) { + jumpToQRCodeView(); + } else { + wcModal.onOpen(); + } } else if (wallet.showQRCode) { jumpToQRCodeView(); } else { jumpToConnectingView(); } - } else { - jumpToConnectingView(); } }, 300); }; diff --git a/packages/walletkit/src/evm/hooks/useQRCodeUri.ts b/packages/walletkit/src/evm/hooks/useWalletConnectUri.ts similarity index 87% rename from packages/walletkit/src/evm/hooks/useQRCodeUri.ts rename to packages/walletkit/src/evm/hooks/useWalletConnectUri.ts index 79b0ef9e..856c7139 100644 --- a/packages/walletkit/src/evm/hooks/useQRCodeUri.ts +++ b/packages/walletkit/src/evm/hooks/useWalletConnectUri.ts @@ -5,10 +5,15 @@ import { useEvmIsConnected } from './useEvmIsConnected'; import { useEventConfig, useLogger } from '@/core/providers/WalletKitProvider/context'; import { evmCommonErrorHandler } from '../utils/evmCommonErrorHandler'; import { getEvmGlobalData } from '../globalData'; +import { ConnectErrorType } from 'wagmi/actions'; let timer: any; -export function useQRCodeUri() { +interface UseWalletConnectUriProps { + onError?: (error: ConnectErrorType) => void; +} + +export function useWalletConnectUri(props?: UseWalletConnectUriProps) { const { connectAsync } = useConnect(); const eventConfig = useEventConfig(); @@ -38,6 +43,8 @@ export function useQRCodeUri() { clearTimeout(timer); timer = setTimeout(() => { + props?.onError?.(error); + if (error?.code === 4001) { evmCommonErrorHandler({ log, diff --git a/packages/walletkit/src/evm/utils/evmCommonErrorHandler.ts b/packages/walletkit/src/evm/utils/evmCommonErrorHandler.ts index d2c9cf03..364d9845 100644 --- a/packages/walletkit/src/evm/utils/evmCommonErrorHandler.ts +++ b/packages/walletkit/src/evm/utils/evmCommonErrorHandler.ts @@ -1,4 +1,4 @@ -import { isIOS, isMobile } from '@/core/index'; +import { isIOS, isMobile } from '@/core/base/utils/mobile'; import { binanceWeb3Wallet, trustWallet } from '../wallets'; export function evmCommonErrorHandler(props: { log: any; handler: any; error: any }) { diff --git a/packages/walletkit/src/evm/utils/evmConfig.ts b/packages/walletkit/src/evm/utils/evmConfig.ts index b4f4dc40..ea3ce7cd 100644 --- a/packages/walletkit/src/evm/utils/evmConfig.ts +++ b/packages/walletkit/src/evm/utils/evmConfig.ts @@ -2,14 +2,13 @@ import { http, createConfig, CreateConnectorFn, type CreateConfigParameters } fr import { Chain, mainnet } from 'wagmi/chains'; import { EvmWallet, isWalletConnect, walletConnect } from '@/evm/wallets'; import { Metadata } from '@/core/providers/WalletKitProvider/context'; -import { WALLET_CONNECT_PROJECT_ID } from '@/core/configs/getDefaultConfig'; import { WalletType } from '@/core/configs/types'; import { setEvmGlobalData } from '../globalData'; interface CustomizedEvmConfig extends Omit { autoConnect?: boolean; metadata?: Metadata; - walletConnectProjectId?: string; + walletConnectProjectId: string; initialChainId?: number; wallets: EvmWallet[]; chains?: Chain[]; @@ -23,7 +22,7 @@ export function evmConfig(params: CustomizedEvmConfig) { const { autoConnect = false, metadata = { name: 'WalletKit' }, - walletConnectProjectId = WALLET_CONNECT_PROJECT_ID, + walletConnectProjectId, initialChainId, wallets, chains = [mainnet], diff --git a/packages/walletkit/src/evm/wallets/binanceWeb3Wallet/index.tsx b/packages/walletkit/src/evm/wallets/binanceWeb3Wallet/index.tsx index ec839a09..f5b62c13 100644 --- a/packages/walletkit/src/evm/wallets/binanceWeb3Wallet/index.tsx +++ b/packages/walletkit/src/evm/wallets/binanceWeb3Wallet/index.tsx @@ -3,7 +3,7 @@ import { EvmWallet, InjectedEvmWalletOptions } from '../types'; import { injected } from '../injected'; import { isMobile } from '@/core/base/utils/mobile'; import { sleep } from '@/core/utils/common'; -import { hasInjectedEvmProvider } from '../utils'; +import { getEvmInjectedProvider } from '../utils'; export function binanceWeb3Wallet(props: InjectedEvmWalletOptions = {}): EvmWallet { const { connectorOptions, ...restProps } = props; @@ -13,8 +13,9 @@ export function binanceWeb3Wallet(props: InjectedEvmWalletOptions = {}): EvmWall id: 'binanceWeb3Wallet', walletType: 'evm', showQRCode: true, + useWalletConnect: false, isInstalled() { - return hasInjectedEvmProvider('isBinance'); + return !!getProvider(); }, getDeepLink() { const url = window.location.href; @@ -29,7 +30,7 @@ export function binanceWeb3Wallet(props: InjectedEvmWalletOptions = {}): EvmWall return deeplink; }, - getQRCodeUri(uri) { + getUri(uri) { return uri; }, getCreateConnectorFn() { @@ -44,10 +45,8 @@ export function binanceWeb3Wallet(props: InjectedEvmWalletOptions = {}): EvmWall await sleep(); } }, - async provider(window) { - if (isMobile()) { - return window?.ethereum; - } + async provider() { + return getProvider(); }, }, ...connectorOptions, @@ -56,3 +55,8 @@ export function binanceWeb3Wallet(props: InjectedEvmWalletOptions = {}): EvmWall ...restProps, }; } + +function getProvider() { + if (typeof window === 'undefined') return; + return getEvmInjectedProvider('isBinance'); +} diff --git a/packages/walletkit/src/evm/wallets/bitgetWallet/index.tsx b/packages/walletkit/src/evm/wallets/bitgetWallet/index.tsx index a3b74910..b0d912d2 100644 --- a/packages/walletkit/src/evm/wallets/bitgetWallet/index.tsx +++ b/packages/walletkit/src/evm/wallets/bitgetWallet/index.tsx @@ -1,8 +1,7 @@ import { bitgetWalletConfig } from '@/core/configs/bitgetWallet'; import { EvmWallet, InjectedEvmWalletOptions } from '../types'; import { injected } from '../injected'; -import { isMobile } from '@/core/base/utils/mobile'; -import { getInjectedEvmProvider, hasInjectedEvmProvider } from '../utils'; +import { getEvmInjectedProvider } from '../utils'; export function bitgetWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { const { connectorOptions, ...restProps } = props; @@ -12,19 +11,14 @@ export function bitgetWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { id: 'bitgetWallet', walletType: 'evm', showQRCode: false, + useWalletConnect: false, isInstalled() { - if (typeof window === 'undefined') return false; - - if (isMobile()) { - return !!(window.ethereum || window.bitkeep); - } - - return hasInjectedEvmProvider('isBitgetWallet') || window.bitkeep; + return !!getProvider(); }, getDeepLink() { return `https://bkcode.vip?action=dapp&url=${window.location.href}`; }, - getQRCodeUri(uri) { + getUri(uri) { return `bitkeep://bkconnect/wc?uri=${encodeURIComponent(uri)}`; }, getCreateConnectorFn() { @@ -34,11 +28,7 @@ export function bitgetWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { id: bitgetWallet().id, name: bitgetWallet().name, async provider() { - if (isMobile()) { - return window.ethereum || window.bitkeep?.ethereum; - } - - return getInjectedEvmProvider('isBitgetWallet') ?? window.bitkeep?.ethereum; + return getProvider(); }, }, ...connectorOptions, @@ -47,3 +37,8 @@ export function bitgetWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { ...restProps, }; } + +function getProvider() { + if (typeof window === 'undefined') return; + return getEvmInjectedProvider('isBitEthereum') ?? window.bitkeep?.ethereum; +} diff --git a/packages/walletkit/src/evm/wallets/coinbaseWallet/index.tsx b/packages/walletkit/src/evm/wallets/coinbaseWallet/index.tsx index 3b39a45f..d98395f0 100644 --- a/packages/walletkit/src/evm/wallets/coinbaseWallet/index.tsx +++ b/packages/walletkit/src/evm/wallets/coinbaseWallet/index.tsx @@ -4,7 +4,7 @@ import { } from 'wagmi/connectors'; import { coinbaseWalletConfig } from '@/core/configs/coinbaseWallet'; import { EvmWallet } from '../types'; -import { hasInjectedEvmProvider } from '../utils'; +import { getEvmInjectedProvider } from '../utils'; import { getEvmGlobalData } from '@/evm/globalData'; interface CoinbaseWalletOptions extends Partial { @@ -19,18 +19,17 @@ export function coinbaseWallet(props: CoinbaseWalletOptions = {}): EvmWallet { id: 'coinbaseWalletSDK', walletType: 'evm', showQRCode: false, - isInstalled: () => { - if (typeof window === 'undefined') return false; - - return hasInjectedEvmProvider('isCoinbaseWallet') || !!window.coinbaseWalletExtension; + useWalletConnect: false, + isInstalled() { + return !!getProvider(); }, - getDeepLink: () => { + getDeepLink() { return `https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`; }, - getQRCodeUri: (uri) => { + getUri(uri) { return uri; }, - getCreateConnectorFn: () => { + getCreateConnectorFn() { const { metadata } = getEvmGlobalData(); return wagmiCoinbaseWallet({ @@ -43,3 +42,8 @@ export function coinbaseWallet(props: CoinbaseWalletOptions = {}): EvmWallet { ...restProps, }; } + +function getProvider() { + if (typeof window === 'undefined') return; + return getEvmInjectedProvider('isCoinbaseWallet') || !!window.coinbaseWalletExtension; +} diff --git a/packages/walletkit/src/evm/wallets/mathWallet/index.tsx b/packages/walletkit/src/evm/wallets/mathWallet/index.tsx index 6cd2cd7e..381e8ef8 100644 --- a/packages/walletkit/src/evm/wallets/mathWallet/index.tsx +++ b/packages/walletkit/src/evm/wallets/mathWallet/index.tsx @@ -1,7 +1,7 @@ import { mathWalletConfig } from '@/core/configs/mathWallet'; import { EvmWallet, InjectedEvmWalletOptions } from '../types'; import { injected } from '../injected'; -import { getInjectedEvmProvider, hasInjectedEvmProvider } from '../utils'; +import { getEvmInjectedProvider } from '../utils'; export function mathWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { const { connectorOptions, ...restProps } = props; @@ -11,17 +11,16 @@ export function mathWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { id: 'mathWallet', walletType: 'evm', spinnerColor: undefined, + useWalletConnect: false, isInstalled() { - if (typeof window === 'undefined') return false; - - return hasInjectedEvmProvider('isMathWallet'); + return !!getProvider(); }, getDeepLink() { // return `mathwallet://mathwallet.org?action=link&value=${window.location.href}`; // return `mathwallet://wc?uri=${encodeURIComponent(uri)}`; return undefined; }, - getQRCodeUri(uri) { + getUri(uri) { return uri; }, getCreateConnectorFn() { @@ -31,10 +30,7 @@ export function mathWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { id: mathWallet().id, name: mathWallet().name, async provider() { - if (typeof window === 'undefined') return; - - const provider = getInjectedEvmProvider('isMathWallet'); - return provider; + return getProvider(); }, }, ...connectorOptions, @@ -43,3 +39,8 @@ export function mathWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { ...restProps, }; } + +function getProvider() { + if (typeof window === 'undefined') return; + return getEvmInjectedProvider('isMathWallet'); +} diff --git a/packages/walletkit/src/evm/wallets/metaMask/index.tsx b/packages/walletkit/src/evm/wallets/metaMask/index.tsx index 562c4d15..208e2fd4 100644 --- a/packages/walletkit/src/evm/wallets/metaMask/index.tsx +++ b/packages/walletkit/src/evm/wallets/metaMask/index.tsx @@ -1,7 +1,8 @@ import { metaMaskConfig } from '@/core/configs/metaMask'; -import { hasInjectedEvmProvider } from '../utils'; +import { hasEvmInjectedProvider } from '../utils'; import { injected } from '../injected'; import { InjectedEvmWalletOptions, EvmWallet } from '../types'; +import { isMobile, isTMA } from '@/core/base/utils/mobile'; export function metaMask(props: InjectedEvmWalletOptions = {}): EvmWallet { const { connectorOptions, ...restProps } = props; @@ -11,17 +12,24 @@ export function metaMask(props: InjectedEvmWalletOptions = {}): EvmWallet { id: 'metaMask', walletType: 'evm', showQRCode: false, - isInstalled: () => { - return hasInjectedEvmProvider('isMetaMask'); + useWalletConnect: false, + isInstalled() { + return hasEvmInjectedProvider('isMetaMask'); }, - getDeepLink: () => { + getDeepLink() { const dappPath = window.location.href.replace(/^https?:\/\//, ''); return `dapp://${dappPath}`; }, - getQRCodeUri: (uri) => { - return `metamask://wc?uri=${encodeURIComponent(uri)}`; + getUri(uri) { + const wcUri = `wc?uri=${encodeURIComponent(uri)}`; + + if (isTMA() && isMobile()) { + return `https://metamask.app.link/${wcUri}`; + } + + return `metamask://${wcUri}`; }, - getCreateConnectorFn: () => { + getCreateConnectorFn() { return injected({ shimDisconnect: true, target: 'metaMask', diff --git a/packages/walletkit/src/evm/wallets/okxWallet/index.tsx b/packages/walletkit/src/evm/wallets/okxWallet/index.tsx index 6442f7be..bc2c02bb 100644 --- a/packages/walletkit/src/evm/wallets/okxWallet/index.tsx +++ b/packages/walletkit/src/evm/wallets/okxWallet/index.tsx @@ -2,7 +2,7 @@ import { isMobile } from '@/core/base/utils/mobile'; import { okxWalletConfig } from '@/core/configs/okxWallet'; import { injected } from '../injected'; import { EvmWallet, InjectedEvmWalletOptions } from '../types'; -import { getInjectedEvmProvider, hasInjectedEvmProvider } from '../utils'; +import { getEvmInjectedProvider } from '../utils'; export function okxWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { const { connectorOptions, ...restProps } = props; @@ -12,32 +12,24 @@ export function okxWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { id: 'okxWallet', walletType: 'evm', showQRCode: false, - isInstalled: () => { - if (typeof window === 'undefined') return false; - - if (isMobile()) { - return !!(window.ethereum || window.okexchain); - } - - return hasInjectedEvmProvider('isOkxWallet') || window.okexchain?.isOkxWallet; + useWalletConnect: false, + isInstalled() { + return !!getProvider(); }, - getDeepLink: () => { + getDeepLink() { return `okx://wallet/dapp/details?dappUrl=${window.location.href}`; }, - getQRCodeUri: (uri) => { + getUri(uri) { return `okex://main/wc?uri=${encodeURIComponent(uri)}`; }, - getCreateConnectorFn: () => { + getCreateConnectorFn() { return injected({ shimDisconnect: true, target: { id: okxWallet().id, name: okxWallet().name, async provider() { - if (isMobile()) { - return window.ethereum || window.okexchain; - } - return getInjectedEvmProvider('isOkxWallet') ?? window.okexchain; + return getProvider(); }, }, ...connectorOptions, @@ -46,3 +38,13 @@ export function okxWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { ...restProps, }; } + +function getProvider() { + if (typeof window === 'undefined') return; + + if (isMobile()) { + return window.ethereum || window.okexchain; + } + + return getEvmInjectedProvider('isOkxWallet') ?? window.okexchain; +} diff --git a/packages/walletkit/src/evm/wallets/safe/index.tsx b/packages/walletkit/src/evm/wallets/safe/index.tsx index 10237ed7..13052253 100644 --- a/packages/walletkit/src/evm/wallets/safe/index.tsx +++ b/packages/walletkit/src/evm/wallets/safe/index.tsx @@ -14,19 +14,23 @@ export function safe(props: SafeOptions = {}): EvmWallet { id: 'safe', walletType: 'evm', showQRCode: false, - isInstalled: () => { + useWalletConnect: false, + isInstalled() { return !(typeof window === 'undefined') && window?.parent !== window; }, getDeepLink: () => { return undefined; }, - getCreateConnectorFn: () => { + getCreateConnectorFn() { return wagmiSafe({ allowedDomains: [/gnosis-safe.io$/, /app.safe.global$/], debug: false, ...connectorOptions, }); }, + getUri(uri) { + return uri; + }, ...restProps, }; } diff --git a/packages/walletkit/src/evm/wallets/tokenPocket/index.tsx b/packages/walletkit/src/evm/wallets/tokenPocket/index.tsx index ba21f7ea..c0234705 100644 --- a/packages/walletkit/src/evm/wallets/tokenPocket/index.tsx +++ b/packages/walletkit/src/evm/wallets/tokenPocket/index.tsx @@ -1,7 +1,7 @@ import { tokenPocketConfig } from '@/core/configs/tokenPocket'; import { injected } from '../injected'; import { InjectedEvmWalletOptions, EvmWallet } from '../types'; -import { getInjectedEvmProvider, hasInjectedEvmProvider } from '../utils'; +import { getEvmInjectedProvider } from '../utils'; export function tokenPocket(props: InjectedEvmWalletOptions = {}): EvmWallet { const { connectorOptions, ...restProps } = props; @@ -11,37 +11,27 @@ export function tokenPocket(props: InjectedEvmWalletOptions = {}): EvmWallet { id: 'tokenPocket', walletType: 'evm', showQRCode: false, - isInstalled: () => { - if (typeof window === 'undefined') return false; - - return ( - hasInjectedEvmProvider('isTokenPocket') || - window.tokenpocket?.ethereum || - window.tokenpocket - ); + useWalletConnect: false, + isInstalled() { + return !!getProvider(); }, - getDeepLink: () => { + getDeepLink() { const params = { url: window.location.href, }; return `tpdapp://open?params=${encodeURIComponent(JSON.stringify(params))}`; }, - getQRCodeUri: (uri) => { + getUri(uri) { return `tpoutside://wc?uri=${encodeURIComponent(uri)}`; }, - getCreateConnectorFn: () => { + getCreateConnectorFn() { return injected({ shimDisconnect: true, target: { id: tokenPocket().id, name: tokenPocket().name, async provider() { - const provider = - getInjectedEvmProvider('isTokenPocket') ?? - window.tokenpocket?.ethereum ?? - window.tokenpocket; - - return provider; + return getProvider(); }, }, ...connectorOptions, @@ -50,3 +40,10 @@ export function tokenPocket(props: InjectedEvmWalletOptions = {}): EvmWallet { ...restProps, }; } + +function getProvider() { + if (typeof window === 'undefined') return; + return ( + getEvmInjectedProvider('isTokenPocket') ?? window.tokenpocket?.ethereum ?? window.tokenpocket + ); +} diff --git a/packages/walletkit/src/evm/wallets/trustWallet/index.tsx b/packages/walletkit/src/evm/wallets/trustWallet/index.tsx index 9b340250..5faa350c 100644 --- a/packages/walletkit/src/evm/wallets/trustWallet/index.tsx +++ b/packages/walletkit/src/evm/wallets/trustWallet/index.tsx @@ -2,7 +2,8 @@ import { sleep } from '@/core/utils/common'; import { trustWalletConfig } from '@/core/configs/trustWallet'; import { injected } from '../injected'; import { EvmWallet, InjectedEvmWalletOptions } from '../types'; -import { getInjectedEvmProvider, hasInjectedEvmProvider } from '../utils'; +import { getEvmInjectedProvider } from '../utils'; +import { isMobile, isTMA } from '@/core/base/utils/mobile'; export function trustWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { const { connectorOptions, ...restProps } = props; @@ -12,25 +13,26 @@ export function trustWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { id: 'trust', walletType: 'evm', showQRCode: false, - isInstalled: () => { - if (typeof window === 'undefined') return false; - - return ( - hasInjectedEvmProvider('isTrust') || - window?.trustwallet?.isTrust || - window?.trustWallet?.isTrust - ); + useWalletConnect: false, + isInstalled() { + return !!getProvider(); }, - getDeepLink: () => { + getDeepLink() { const dappPath = `https://link.trustwallet.com/open_url?coin_id=60&url=${encodeURIComponent( window.location.href, )}`; return dappPath; }, - getQRCodeUri: (uri) => { - return `trust://wc?uri=${encodeURIComponent(uri)}`; + getUri(uri) { + const wcUri = `wc?uri=${encodeURIComponent(uri)}`; + + if (isTMA() && isMobile()) { + return `https://link.trustwallet.com/${wcUri}`; + } + + return `trust://${wcUri}`; }, - getCreateConnectorFn: () => { + getCreateConnectorFn() { return injected({ shimDisconnect: true, target: { @@ -41,9 +43,7 @@ export function trustWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { await sleep(); }, async provider() { - const provider = - getInjectedEvmProvider('isTrust') ?? window.trustwallet ?? window.trustWallet; - return provider; + return getProvider(); }, }, ...connectorOptions, @@ -52,3 +52,8 @@ export function trustWallet(props: InjectedEvmWalletOptions = {}): EvmWallet { ...restProps, }; } + +function getProvider() { + if (typeof window === 'undefined') return; + return getEvmInjectedProvider('isTrust') ?? window.trustwallet ?? window.trustWallet; +} diff --git a/packages/walletkit/src/evm/wallets/types.ts b/packages/walletkit/src/evm/wallets/types.ts index f01bdffb..ad436ba9 100644 --- a/packages/walletkit/src/evm/wallets/types.ts +++ b/packages/walletkit/src/evm/wallets/types.ts @@ -5,7 +5,7 @@ import { BaseWallet } from '@/core/configs/types'; export interface EvmWallet extends BaseWallet { getCreateConnectorFn: () => CreateConnectorFn; getDeepLink: () => string | undefined; - getQRCodeUri?: (uri: string) => string; + getUri: (uri: string) => string; } export interface InjectedEvmWalletOptions extends Partial { diff --git a/packages/walletkit/src/evm/wallets/utils.ts b/packages/walletkit/src/evm/wallets/utils.ts index 40feac60..14e15f6f 100644 --- a/packages/walletkit/src/evm/wallets/utils.ts +++ b/packages/walletkit/src/evm/wallets/utils.ts @@ -1,4 +1,4 @@ -export function getInjectedEvmProvider(flag: string): any { +export function getEvmInjectedProvider(flag: string): any { if (typeof window === 'undefined' || typeof window.ethereum === 'undefined') return; const providers = window.ethereum.providers; @@ -9,6 +9,6 @@ export function getInjectedEvmProvider(flag: string): any { : undefined; } -export function hasInjectedEvmProvider(flag: string): boolean { - return Boolean(getInjectedEvmProvider(flag)); +export function hasEvmInjectedProvider(flag: string): boolean { + return Boolean(getEvmInjectedProvider(flag)); } diff --git a/packages/walletkit/src/evm/wallets/walletConnect/index.tsx b/packages/walletkit/src/evm/wallets/walletConnect/index.tsx index 777bae01..57691ff5 100644 --- a/packages/walletkit/src/evm/wallets/walletConnect/index.tsx +++ b/packages/walletkit/src/evm/wallets/walletConnect/index.tsx @@ -1,6 +1,5 @@ import { WalletConnectParameters, walletConnect as wagmiWalletConnect } from 'wagmi/connectors'; import { EvmWallet } from '../types'; -import { isMobile } from '@/core/base/utils/mobile'; import { walletConnectConfig } from '@/core/configs/walletConnect'; import { getEvmGlobalData } from '@/evm/globalData'; @@ -15,10 +14,18 @@ export function walletConnect(props: WalletConnectOptions = {}): EvmWallet { ...walletConnectConfig, id: 'walletConnect', walletType: 'evm', - showQRCode: isMobile() ? false : !connectorOptions?.showQrModal, - isInstalled: () => false, - getDeepLink: () => undefined, - getCreateConnectorFn: () => { + showQRCode: !connectorOptions?.showQrModal, + useWalletConnect: false, + isInstalled() { + return false; + }, + getDeepLink() { + return undefined; + }, + getUri(uri) { + return uri; + }, + getCreateConnectorFn() { const { walletConnectProjectId, metadata } = getEvmGlobalData(); const hasAllAppData = metadata?.name && metadata.icon && metadata.description && metadata.url; diff --git a/packages/walletkit/src/solana/utils/solanaConfig.ts b/packages/walletkit/src/solana/utils/solanaConfig.ts index 786e7637..13b5adaf 100644 --- a/packages/walletkit/src/solana/utils/solanaConfig.ts +++ b/packages/walletkit/src/solana/utils/solanaConfig.ts @@ -1,4 +1,3 @@ -import { WALLET_CONNECT_PROJECT_ID } from '@/core/configs/getDefaultConfig'; import { WalletType } from '@/core/configs/types'; import { Metadata } from '@/core/providers/WalletKitProvider/context'; import { SolanaWallet } from '@/solana/wallets'; @@ -16,11 +15,11 @@ export interface SolanaConfig extends ReturnType { walletType: WalletType; } -export const solanaConfig = (params: CustomizedSolanaConfig) => { +export function solanaConfig(params: CustomizedSolanaConfig) { const { autoConnect = false, metadata = { name: 'WalletKit' }, - walletConnectProjectId = WALLET_CONNECT_PROJECT_ID, + walletConnectProjectId, rpcUrl, wallets, } = params; @@ -43,4 +42,4 @@ export const solanaConfig = (params: CustomizedSolanaConfig) => { rpcUrl, wallets, }; -}; +} diff --git a/packages/walletkit/src/solana/wallets/phantomWallet/index.tsx b/packages/walletkit/src/solana/wallets/phantomWallet/index.tsx index 94e59e7b..1bb67987 100644 --- a/packages/walletkit/src/solana/wallets/phantomWallet/index.tsx +++ b/packages/walletkit/src/solana/wallets/phantomWallet/index.tsx @@ -1,5 +1,5 @@ import { PhantomWalletAdapter, PhantomWalletAdapterConfig } from '@solana/wallet-adapter-wallets'; -import { hasInjectedSolanaProvider } from '../utils'; +import { hasSolanaInjectedProvider } from '../utils'; import { SolanaWallet } from '../types'; import { phantomWalletConfig } from '@/core/configs/phantomWallet'; @@ -16,10 +16,10 @@ export function phantomWallet(props: PhantomOptions = {}): SolanaWallet { walletType: 'solana', adapterName: 'Phantom', showQRCode: false, - isInstalled: () => { - return hasInjectedSolanaProvider('isPhantom'); + isInstalled() { + return hasSolanaInjectedProvider('isPhantom'); }, - getAdapter: () => { + getAdapter() { return new PhantomWalletAdapter({ ...adapterOptions, }); diff --git a/packages/walletkit/src/solana/wallets/trustWallet/index.tsx b/packages/walletkit/src/solana/wallets/trustWallet/index.tsx index dd087857..87ceb82b 100644 --- a/packages/walletkit/src/solana/wallets/trustWallet/index.tsx +++ b/packages/walletkit/src/solana/wallets/trustWallet/index.tsx @@ -1,7 +1,7 @@ import { TrustWalletAdapter, TrustWalletAdapterConfig } from '@solana/wallet-adapter-wallets'; import { SolanaWallet } from '../types'; import { trustWalletConfig } from '@/core/configs/trustWallet'; -import { hasInjectedSolanaProvider } from '../utils'; +import { hasSolanaInjectedProvider } from '../utils'; interface TrustWalletOptions extends Partial { adapterOptions?: Partial; @@ -16,16 +16,16 @@ export function trustWallet(props: TrustWalletOptions = {}): SolanaWallet { walletType: 'solana', adapterName: 'Trust', showQRCode: false, - isInstalled: () => { + isInstalled() { if (typeof window === 'undefined') return false; return ( - hasInjectedSolanaProvider('isTrust') || + hasSolanaInjectedProvider('isTrust') || window?.trustwallet?.solana?.isTrust || window?.trustWallet?.solana?.isTrust ); }, - getAdapter: () => { + getAdapter() { return new TrustWalletAdapter({ ...adapterOptions, }); diff --git a/packages/walletkit/src/solana/wallets/utils.ts b/packages/walletkit/src/solana/wallets/utils.ts index 5e34a74e..1213e91e 100644 --- a/packages/walletkit/src/solana/wallets/utils.ts +++ b/packages/walletkit/src/solana/wallets/utils.ts @@ -1,9 +1,9 @@ -export function getInjectedSolanaProvider(flag: string): any { +export function getSolanaInjectedProvider(flag: string): any { if (typeof window === 'undefined' || typeof window.solana === 'undefined') return; return window.solana[flag] ? window.solana : undefined; } -export function hasInjectedSolanaProvider(flag: string): boolean { - return Boolean(getInjectedSolanaProvider(flag)); +export function hasSolanaInjectedProvider(flag: string): boolean { + return Boolean(getSolanaInjectedProvider(flag)); } diff --git a/packages/walletkit/src/solana/wallets/walletConnect/index.tsx b/packages/walletkit/src/solana/wallets/walletConnect/index.tsx index 1689a16e..09dbc5d4 100644 --- a/packages/walletkit/src/solana/wallets/walletConnect/index.tsx +++ b/packages/walletkit/src/solana/wallets/walletConnect/index.tsx @@ -3,7 +3,6 @@ import { WalletConnectWalletAdapterConfig, } from '@solana/wallet-adapter-wallets'; import { SolanaWallet } from '../types'; -import { isMobile } from '@/core/base/utils/mobile'; import { walletConnectConfig } from '@/core/configs/walletConnect'; import { getSolanaGlobalData } from '@/solana/globalData'; @@ -19,9 +18,11 @@ export function walletConnect(props: WalletConnectOptions = {}): SolanaWallet { id: 'solana:walletConnect', walletType: 'solana', adapterName: 'WalletConnect', - showQRCode: isMobile() ? false : true, - isInstalled: () => false, - getAdapter: () => { + showQRCode: true, + isInstalled() { + return false; + }, + getAdapter() { const { walletConnectProjectId, metadata, rpcUrl } = getSolanaGlobalData(); const hasAllAppData = metadata?.name && metadata.icon && metadata.description && metadata.url; diff --git a/packages/walletkit/styles.css/package.json b/packages/walletkit/styles.css/package.json new file mode 100644 index 00000000..7d0e3bc7 --- /dev/null +++ b/packages/walletkit/styles.css/package.json @@ -0,0 +1,3 @@ +{ + "main": "../dist/style.css" +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83dbd7c1..2023da99 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -313,6 +313,9 @@ importers: vite-plugin-dts: specifier: ^3.9.1 version: 3.9.1(@types/node@22.3.0)(rollup@4.20.0)(typescript@5.5.3)(vite@4.5.3(@types/node@22.3.0)(terser@5.31.6)) + vite-plugin-mkcert: + specifier: ^1.17.6 + version: 1.17.6(vite@4.5.3(@types/node@22.3.0)(terser@5.31.6)) wagmi: specifier: ^2.10.10 version: 2.12.2(@react-native-async-storage/async-storage@1.24.0(react-native@0.74.3(@babel/core@7.25.2)(@babel/preset-env@7.24.8(@babel/core@7.25.2))(@types/react@18.3.3)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(utf-8-validate@5.0.10)))(@tanstack/query-core@5.51.21)(@tanstack/react-query@5.51.21(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(encoding@0.1.13)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.3(@babel/core@7.25.2)(@babel/preset-env@7.24.8(@babel/core@7.25.2))(@types/react@18.3.3)(bufferutil@4.0.8)(encoding@0.1.13)(react@18.3.1)(utf-8-validate@5.0.10))(react@18.3.1)(rollup@4.20.0)(typescript@5.5.3)(utf-8-validate@5.0.10)(viem@2.18.8(bufferutil@4.0.8)(typescript@5.5.3)(utf-8-validate@5.0.10)(zod@3.22.4))(zod@3.22.4) @@ -2479,6 +2482,58 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} + '@octokit/auth-token@4.0.0': + resolution: {integrity: sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==} + engines: {node: '>= 18'} + + '@octokit/core@5.2.0': + resolution: {integrity: sha512-1LFfa/qnMQvEOAdzlQymH0ulepxbxnCYAKJZfMci/5XJyIHWgEYnDmgnKakbTh7CH2tFQ5O60oYDvns4i9RAIg==} + engines: {node: '>= 18'} + + '@octokit/endpoint@9.0.5': + resolution: {integrity: sha512-ekqR4/+PCLkEBF6qgj8WqJfvDq65RH85OAgrtnVp1mSxaXF03u2xW/hUdweGS5654IlC0wkNYC18Z50tSYTAFw==} + engines: {node: '>= 18'} + + '@octokit/graphql@7.1.0': + resolution: {integrity: sha512-r+oZUH7aMFui1ypZnAvZmn0KSqAUgE1/tUXIWaqUCa1758ts/Jio84GZuzsvUkme98kv0WFY8//n0J1Z+vsIsQ==} + engines: {node: '>= 18'} + + '@octokit/openapi-types@22.2.0': + resolution: {integrity: sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg==} + + '@octokit/plugin-paginate-rest@11.3.1': + resolution: {integrity: sha512-ryqobs26cLtM1kQxqeZui4v8FeznirUsksiA+RYemMPJ7Micju0WSkv50dBksTuZks9O5cg4wp+t8fZ/cLY56g==} + engines: {node: '>= 18'} + peerDependencies: + '@octokit/core': '5' + + '@octokit/plugin-request-log@4.0.1': + resolution: {integrity: sha512-GihNqNpGHorUrO7Qa9JbAl0dbLnqJVrV8OXe2Zm5/Y4wFkZQDfTreBzVmiRfJVfE4mClXdihHnbpyyO9FSX4HA==} + engines: {node: '>= 18'} + peerDependencies: + '@octokit/core': '5' + + '@octokit/plugin-rest-endpoint-methods@13.2.2': + resolution: {integrity: sha512-EI7kXWidkt3Xlok5uN43suK99VWqc8OaIMktY9d9+RNKl69juoTyxmLoWPIZgJYzi41qj/9zU7G/ljnNOJ5AFA==} + engines: {node: '>= 18'} + peerDependencies: + '@octokit/core': ^5 + + '@octokit/request-error@5.1.0': + resolution: {integrity: sha512-GETXfE05J0+7H2STzekpKObFe765O5dlAKUTLNGeH+x47z7JjXHfsHKo5z21D/o/IOZTUEI6nyWyR+bZVP/n5Q==} + engines: {node: '>= 18'} + + '@octokit/request@8.4.0': + resolution: {integrity: sha512-9Bb014e+m2TgBeEJGEbdplMVWwPmL1FPtggHQRkV+WVsMggPtEkLKPlcVYm/o8xKLkpJ7B+6N8WfQMtDLX2Dpw==} + engines: {node: '>= 18'} + + '@octokit/rest@20.1.1': + resolution: {integrity: sha512-MB4AYDsM5jhIHro/dq4ix1iWTLGToIGk6cWF5L6vanFaMble5jTX/UBQyiv05HsWnwUtY8JrfHy2LWfKwihqMw==} + engines: {node: '>= 18'} + + '@octokit/types@13.5.0': + resolution: {integrity: sha512-HdqWTf5Z3qwDVlzCrP8UJquMwunpDiMPt5er+QjGzL4hqr/vBVY/MauQgS1xWxCDT1oMx1EULyqxncdCY/NVSQ==} + '@parcel/watcher-android-arm64@2.4.1': resolution: {integrity: sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==} engines: {node: '>= 10.0.0'} @@ -4473,6 +4528,9 @@ packages: bech32@2.0.0: resolution: {integrity: sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==} + before-after-hook@2.2.3: + resolution: {integrity: sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==} + better-path-resolve@1.0.0: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} @@ -5148,6 +5206,9 @@ packages: resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} engines: {node: '>= 0.8'} + deprecation@2.3.1: + resolution: {integrity: sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==} + dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} @@ -8988,6 +9049,9 @@ packages: unist-util-visit@4.1.2: resolution: {integrity: sha512-MSd8OUGISqHdVvfY9TPhyK2VdUrPgxkUtWSuMHF6XAAFuL4LokseigBnZtPnJMu+FbynTkFNnFlyjxpVKujMRg==} + universal-user-agent@6.0.1: + resolution: {integrity: sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==} + universalify@0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'} @@ -9187,6 +9251,12 @@ packages: '@mdx-js/mdx': <2 vite: <3 + vite-plugin-mkcert@1.17.6: + resolution: {integrity: sha512-4JR1RN0HEg/w17eRQJ/Ve2pSa6KCVQcQO6yKtIaKQCFDyd63zGfXHWpygBkvvRSpqa0GcqNKf0fjUJ0HiJQXVQ==} + engines: {node: '>=v16.7.0'} + peerDependencies: + vite: '>=3' + vite@4.5.3: resolution: {integrity: sha512-kQL23kMeX92v3ph7IauVkXkikdDRsYMGTVl5KY2E9OY4ONLvkHf04MDTbnfo6NKxZiDLWzVpP5oTa8hQD8U3dg==} engines: {node: ^14.18.0 || >=16.0.0} @@ -11798,7 +11868,7 @@ snapshots: '@babel/helper-split-export-declaration': 7.24.7 '@babel/parser': 7.24.8 '@babel/types': 7.24.9 - debug: 4.3.5 + debug: 4.3.6 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -13277,6 +13347,69 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 + '@octokit/auth-token@4.0.0': {} + + '@octokit/core@5.2.0': + dependencies: + '@octokit/auth-token': 4.0.0 + '@octokit/graphql': 7.1.0 + '@octokit/request': 8.4.0 + '@octokit/request-error': 5.1.0 + '@octokit/types': 13.5.0 + before-after-hook: 2.2.3 + universal-user-agent: 6.0.1 + + '@octokit/endpoint@9.0.5': + dependencies: + '@octokit/types': 13.5.0 + universal-user-agent: 6.0.1 + + '@octokit/graphql@7.1.0': + dependencies: + '@octokit/request': 8.4.0 + '@octokit/types': 13.5.0 + universal-user-agent: 6.0.1 + + '@octokit/openapi-types@22.2.0': {} + + '@octokit/plugin-paginate-rest@11.3.1(@octokit/core@5.2.0)': + dependencies: + '@octokit/core': 5.2.0 + '@octokit/types': 13.5.0 + + '@octokit/plugin-request-log@4.0.1(@octokit/core@5.2.0)': + dependencies: + '@octokit/core': 5.2.0 + + '@octokit/plugin-rest-endpoint-methods@13.2.2(@octokit/core@5.2.0)': + dependencies: + '@octokit/core': 5.2.0 + '@octokit/types': 13.5.0 + + '@octokit/request-error@5.1.0': + dependencies: + '@octokit/types': 13.5.0 + deprecation: 2.3.1 + once: 1.4.0 + + '@octokit/request@8.4.0': + dependencies: + '@octokit/endpoint': 9.0.5 + '@octokit/request-error': 5.1.0 + '@octokit/types': 13.5.0 + universal-user-agent: 6.0.1 + + '@octokit/rest@20.1.1': + dependencies: + '@octokit/core': 5.2.0 + '@octokit/plugin-paginate-rest': 11.3.1(@octokit/core@5.2.0) + '@octokit/plugin-request-log': 4.0.1(@octokit/core@5.2.0) + '@octokit/plugin-rest-endpoint-methods': 13.2.2(@octokit/core@5.2.0) + + '@octokit/types@13.5.0': + dependencies: + '@octokit/openapi-types': 22.2.0 + '@parcel/watcher-android-arm64@2.4.1': optional: true @@ -17340,7 +17473,15 @@ snapshots: axios@1.7.4: dependencies: - follow-redirects: 1.15.6(debug@4.3.4) + follow-redirects: 1.15.6 + form-data: 4.0.0 + proxy-from-env: 1.1.0 + transitivePeerDependencies: + - debug + + axios@1.7.4(debug@4.3.6): + dependencies: + follow-redirects: 1.15.6(debug@4.3.6) form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -17443,6 +17584,8 @@ snapshots: bech32@2.0.0: {} + before-after-hook@2.2.3: {} + better-path-resolve@1.0.0: dependencies: is-windows: 1.0.2 @@ -18145,6 +18288,8 @@ snapshots: depd@2.0.0: {} + deprecation@2.3.1: {} + dequal@2.0.3: {} des.js@1.1.0: @@ -18252,7 +18397,7 @@ snapshots: engine.io-client@6.5.4(bufferutil@4.0.8)(utf-8-validate@5.0.10): dependencies: '@socket.io/component-emitter': 3.1.2 - debug: 4.3.5 + debug: 4.3.6 engine.io-parser: 5.2.3 ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@5.0.10) xmlhttprequest-ssl: 2.0.0 @@ -18814,10 +18959,16 @@ snapshots: flow-parser@0.243.0: {} + follow-redirects@1.15.6: {} + follow-redirects@1.15.6(debug@4.3.4): optionalDependencies: debug: 4.3.4 + follow-redirects@1.15.6(debug@4.3.6): + optionalDependencies: + debug: 4.3.6 + for-each@0.3.3: dependencies: is-callable: 1.2.7 @@ -20435,7 +20586,7 @@ snapshots: micromark@3.2.0: dependencies: '@types/debug': 4.1.12 - debug: 4.3.5 + debug: 4.3.6 decode-named-character-reference: 1.0.2 micromark-core-commonmark: 1.1.0 micromark-factory-space: 1.1.0 @@ -22284,7 +22435,7 @@ snapshots: socket.io-client@4.7.5(bufferutil@4.0.8)(utf-8-validate@5.0.10): dependencies: '@socket.io/component-emitter': 3.1.2 - debug: 4.3.5 + debug: 4.3.6 engine.io-client: 6.5.4(bufferutil@4.0.8)(utf-8-validate@5.0.10) socket.io-parser: 4.2.4 transitivePeerDependencies: @@ -22295,7 +22446,7 @@ snapshots: socket.io-parser@4.2.4: dependencies: '@socket.io/component-emitter': 3.1.2 - debug: 4.3.5 + debug: 4.3.6 transitivePeerDependencies: - supports-color @@ -22829,6 +22980,8 @@ snapshots: unist-util-is: 5.2.1 unist-util-visit-parents: 5.1.3 + universal-user-agent@6.0.1: {} + universalify@0.1.2: {} unload@2.4.1: {} @@ -23102,6 +23255,16 @@ snapshots: unified: 9.2.2 vite: 4.5.3(@types/node@20.14.10)(terser@5.31.6) + vite-plugin-mkcert@1.17.6(vite@4.5.3(@types/node@22.3.0)(terser@5.31.6)): + dependencies: + '@octokit/rest': 20.1.1 + axios: 1.7.4(debug@4.3.6) + debug: 4.3.6 + picocolors: 1.0.1 + vite: 4.5.3(@types/node@22.3.0)(terser@5.31.6) + transitivePeerDependencies: + - supports-color + vite@4.5.3(@types/node@20.14.10)(terser@5.31.6): dependencies: esbuild: 0.18.20