0xtrails 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ccip-Cg9-lJ6K.js → ccip-CT_An6eM.js} +39 -39
- package/dist/chains.d.ts +4 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/customTokens.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/gasless.d.ts +1 -2
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-DEojZg7b.js → index-RfqL5Foz.js} +56672 -43550
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +385 -333
- package/dist/intents.d.ts +8 -2
- package/dist/intents.d.ts.map +1 -1
- package/dist/keyMachineClient.d.ts +9 -0
- package/dist/keyMachineClient.d.ts.map +1 -0
- package/dist/keymachine/index.d.ts +14 -0
- package/dist/keymachine/index.d.ts.map +1 -0
- package/dist/keymachine/key-machine.gen.d.ts +461 -0
- package/dist/keymachine/key-machine.gen.d.ts.map +1 -0
- package/dist/onramp/MeshConnectFlow.d.ts +18 -0
- package/dist/onramp/MeshConnectFlow.d.ts.map +1 -0
- package/dist/onramp/MeshConnectIframe.d.ts +13 -0
- package/dist/onramp/MeshConnectIframe.d.ts.map +1 -0
- package/dist/onramp/SendFromExchangeButton.d.ts +16 -0
- package/dist/onramp/SendFromExchangeButton.d.ts.map +1 -0
- package/dist/onramp/TrailsOnRampProvider.d.ts +31 -0
- package/dist/onramp/TrailsOnRampProvider.d.ts.map +1 -0
- package/dist/onramp/index.d.ts +13 -0
- package/dist/onramp/index.d.ts.map +1 -0
- package/dist/onramp/meshconnect.d.ts +30 -0
- package/dist/onramp/meshconnect.d.ts.map +1 -0
- package/dist/onramp/trailsOnramp.d.ts +24 -0
- package/dist/onramp/trailsOnramp.d.ts.map +1 -0
- package/dist/onramp-client/index.d.ts +3 -3
- package/dist/onramp-client/index.d.ts.map +1 -1
- package/dist/paymasterSend.d.ts.map +1 -1
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/query/balance.fetchers.d.ts +31 -2
- package/dist/query/balance.fetchers.d.ts.map +1 -1
- package/dist/query/balance.hooks.d.ts +21 -2
- package/dist/query/balance.hooks.d.ts.map +1 -1
- package/dist/query/balance.queries.d.ts +18 -1
- package/dist/query/balance.queries.d.ts.map +1 -1
- package/dist/query/chains.queries.d.ts.map +1 -1
- package/dist/query/meld.fetchers.d.ts +1 -1
- package/dist/query/meld.fetchers.d.ts.map +1 -1
- package/dist/query/meld.hooks.d.ts +3 -3
- package/dist/query/meld.hooks.d.ts.map +1 -1
- package/dist/query/meld.queries.d.ts +1 -1
- package/dist/query/meld.queries.d.ts.map +1 -1
- package/dist/query/price.fetchers.d.ts +15 -0
- package/dist/query/price.fetchers.d.ts.map +1 -0
- package/dist/query/price.hooks.d.ts +352 -0
- package/dist/query/price.hooks.d.ts.map +1 -0
- package/dist/query/price.queries.d.ts +34 -0
- package/dist/query/price.queries.d.ts.map +1 -0
- package/dist/query/tokenList.queries.d.ts +54 -0
- package/dist/query/tokenList.queries.d.ts.map +1 -0
- package/dist/recover.d.ts +6 -4
- package/dist/recover.d.ts.map +1 -1
- package/dist/tokens.d.ts +13 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +2 -2
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -2
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
- package/dist/transactionIntent/helpers/transactionStateHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +1 -1
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/umd/trails.min.js +291 -202
- package/dist/utils/format.d.ts +7 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/walletUtils.d.ts +2 -1
- package/dist/walletUtils.d.ts.map +1 -1
- package/dist/wallets.d.ts +13 -54
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DirectTransfer.d.ts +1 -1
- package/dist/widget/components/DirectTransfer.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/ExecutionStatusBadge.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/HighPriceImpactBlock.d.ts +7 -0
- package/dist/widget/components/HighPriceImpactBlock.d.ts.map +1 -0
- package/dist/widget/components/MeldHistory.d.ts.map +1 -1
- package/dist/widget/components/MeshExchangeSelection.d.ts +11 -0
- package/dist/widget/components/MeshExchangeSelection.d.ts.map +1 -0
- package/dist/widget/components/OnrampHistoryRow.d.ts +1 -1
- package/dist/widget/components/OnrampHistoryRow.d.ts.map +1 -1
- package/dist/widget/components/OnrampProviderConfirmation.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RefundWarning.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
- package/dist/widget/components/TransactionHistoryItem.d.ts +2 -0
- package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletImage.d.ts.map +1 -1
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/components/Withdraw.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -1
- package/dist/widget/hooks/useCombinedHistory.d.ts +6 -5
- package/dist/widget/hooks/useCombinedHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts +6 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultDestinationToken.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultOriginToken.d.ts.map +1 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts +1 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts.map +1 -1
- package/dist/widget/hooks/useGetIntent.d.ts +3 -2
- package/dist/widget/hooks/useGetIntent.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts +1 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts +3 -2
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts +1 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts +1 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts.map +1 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts +1 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts +1 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +2 -2
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +7 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +0 -1
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +7 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useViewManager.d.ts +1 -1
- package/dist/widget/hooks/useViewManager.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts +2 -0
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/utils/createWagmiConfig.d.ts +2 -2
- package/dist/widget/utils/createWagmiConfig.d.ts.map +1 -1
- package/dist/widget/utils/fundMethodSwitchState.d.ts +1 -0
- package/dist/widget/utils/fundMethodSwitchState.d.ts.map +1 -1
- package/dist/widget/utils/historyFilters.d.ts +13 -0
- package/dist/widget/utils/historyFilters.d.ts.map +1 -0
- package/dist/widget/utils/meldProviderUtils.d.ts +1 -1
- package/dist/widget/utils/meldProviderUtils.d.ts.map +1 -1
- package/dist/widget/utils/meshSupportedTokens.d.ts +4 -0
- package/dist/widget/utils/meshSupportedTokens.d.ts.map +1 -0
- package/dist/widget/utils/onrampConfig.d.ts +11 -0
- package/dist/widget/utils/onrampConfig.d.ts.map +1 -0
- package/dist/widget/utils/statusLabel.d.ts +2 -0
- package/dist/widget/utils/statusLabel.d.ts.map +1 -0
- package/dist/widget/utils/trailsOnrampConfig.d.ts +18 -0
- package/dist/widget/utils/trailsOnrampConfig.d.ts.map +1 -0
- package/dist/widget/widget.d.ts +24 -8
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +9 -7
- package/src/chains.ts +26 -9
- package/src/constants.ts +2 -0
- package/src/customTokens.ts +22 -7
- package/src/error.ts +7 -0
- package/src/gasless.ts +5 -2
- package/src/index.ts +8 -5
- package/src/intents.ts +56 -60
- package/src/keyMachineClient.ts +29 -0
- package/src/keymachine/index.ts +175 -0
- package/src/keymachine/key-machine.gen.ts +993 -0
- package/src/onramp/MeshConnectFlow.tsx +86 -0
- package/src/onramp/MeshConnectIframe.tsx +661 -0
- package/src/onramp/SendFromExchangeButton.tsx +81 -0
- package/src/onramp/TrailsOnRampProvider.tsx +59 -0
- package/src/onramp/index.ts +31 -0
- package/src/onramp/meshconnect.ts +277 -0
- package/src/onramp/trailsOnramp.tsx +130 -0
- package/src/onramp-client/index.ts +4 -6
- package/src/paymasterSend.ts +0 -5
- package/src/prepareSend.ts +45 -44
- package/src/query/balance.fetchers.ts +172 -17
- package/src/query/balance.hooks.ts +69 -6
- package/src/query/balance.queries.ts +63 -0
- package/src/query/chains.queries.ts +1 -6
- package/src/query/meld.fetchers.ts +1 -1
- package/src/query/meld.hooks.ts +1 -1
- package/src/query/meld.queries.ts +1 -1
- package/src/query/price.fetchers.ts +53 -0
- package/src/query/price.hooks.ts +46 -0
- package/src/query/price.queries.ts +364 -0
- package/src/query/tokenList.queries.ts +118 -0
- package/src/recover.ts +89 -26
- package/src/tokens.ts +108 -26
- package/src/transactionIntent/deposits/depositOrchestrator.ts +11 -11
- package/src/transactionIntent/deposits/gaslessDeposit.ts +38 -39
- package/src/transactionIntent/deposits/standardDeposit.ts +5 -30
- package/src/transactionIntent/handlers/intentHandler.ts +29 -12
- package/src/transactionIntent/helpers/transactionStateHelpers.ts +5 -2
- package/src/transactionIntent/quote/normalizeQuote.ts +11 -5
- package/src/transactionIntent/types.ts +1 -1
- package/src/transactions.ts +5 -1
- package/src/utils/format.ts +85 -1
- package/src/walletUtils.ts +2 -1
- package/src/wallets.ts +184 -380
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +134 -109
- package/src/widget/components/ClassicSwap.tsx +26 -24
- package/src/widget/components/ConnectWallet.tsx +4 -2
- package/src/widget/components/ConnectedWallets.tsx +2 -5
- package/src/widget/components/DirectTransfer.tsx +5 -2
- package/src/widget/components/EarnPools.tsx +1 -2
- package/src/widget/components/ExecutionStatusBadge.tsx +10 -4
- package/src/widget/components/Fund.tsx +169 -110
- package/src/widget/components/FundMethods.tsx +5 -9
- package/src/widget/components/HighPriceImpactBlock.tsx +44 -0
- package/src/widget/components/MeldHistory.tsx +4 -28
- package/src/widget/components/MeshExchangeSelection.tsx +218 -0
- package/src/widget/components/OnrampHistoryRow.tsx +3 -27
- package/src/widget/components/OnrampProviderConfirmation.tsx +0 -25
- package/src/widget/components/Pay.tsx +20 -36
- package/src/widget/components/PoolDeposit.tsx +14 -24
- package/src/widget/components/PoolWithdraw.tsx +1 -63
- package/src/widget/components/QRCodeWalletSelect.tsx +5 -2
- package/src/widget/components/QuoteDetails.tsx +113 -106
- package/src/widget/components/Receipt.tsx +0 -11
- package/src/widget/components/Recipients.tsx +2 -1
- package/src/widget/components/RefundWarning.tsx +5 -10
- package/src/widget/components/ThemeProvider.tsx +4 -4
- package/src/widget/components/TokenSelector.tsx +85 -16
- package/src/widget/components/TransactionDetails.tsx +46 -0
- package/src/widget/components/TransactionHistoryItem.tsx +14 -23
- package/src/widget/components/TransferPendingVertical.tsx +17 -11
- package/src/widget/components/WaasFeeOptions.tsx +4 -42
- package/src/widget/components/WalletConnect.tsx +2 -5
- package/src/widget/components/WalletImage.tsx +6 -18
- package/src/widget/components/WalletList.tsx +1 -1
- package/src/widget/components/Withdraw.tsx +22 -23
- package/src/widget/hooks/useAddressWalletIcon.ts +2 -1
- package/src/widget/hooks/useAmountUsd.ts +1 -1
- package/src/widget/hooks/useCombinedHistory.ts +37 -93
- package/src/widget/hooks/useCustomTokenSearch.tsx +63 -33
- package/src/widget/hooks/useDefaultDestinationToken.tsx +2 -5
- package/src/widget/hooks/useDefaultOriginToken.tsx +2 -5
- package/src/widget/hooks/useFiatOnRampCurrencies.ts +1 -1
- package/src/widget/hooks/useGetIntent.ts +5 -4
- package/src/widget/hooks/useIntentReceiptBalances.ts +3 -3
- package/src/widget/hooks/useIntentTransactionHistory.ts +24 -47
- package/src/widget/hooks/useMeldTransactionHistory.ts +4 -2
- package/src/widget/hooks/useMeldTransactionStatus.ts +13 -11
- package/src/widget/hooks/useOnRampQuote.ts +3 -3
- package/src/widget/hooks/useOnRampTransactionStatus.ts +8 -6
- package/src/widget/hooks/useQuote.ts +56 -48
- package/src/widget/hooks/useSelectedFundMethod.tsx +14 -1
- package/src/widget/hooks/useSendForm.ts +52 -31
- package/src/widget/hooks/useTokenList.ts +209 -140
- package/src/widget/hooks/useTrailsSendTransaction.ts +1 -1
- package/src/widget/hooks/useViewManager.tsx +1 -0
- package/src/widget/providers/TrailsProvider.tsx +5 -0
- package/src/widget/styles.ts +1 -1
- package/src/widget/utils/createWagmiConfig.ts +7 -2
- package/src/widget/utils/fundMethodSwitchState.ts +2 -0
- package/src/widget/utils/historyFilters.ts +157 -0
- package/src/widget/utils/meldProviderUtils.ts +8 -2
- package/src/widget/utils/meshSupportedTokens.ts +28 -0
- package/src/widget/utils/onrampConfig.ts +15 -0
- package/src/widget/utils/statusLabel.ts +3 -0
- package/src/widget/utils/trailsOnrampConfig.ts +39 -0
- package/src/widget/widget.tsx +235 -185
- package/dist/onramp-client/trails-onramp.gen.d.ts +0 -570
- package/dist/onramp-client/trails-onramp.gen.d.ts.map +0 -1
- package/dist/prices.d.ts +0 -34
- package/dist/prices.d.ts.map +0 -1
- package/dist/useGasEstimation.d.ts +0 -34
- package/dist/useGasEstimation.d.ts.map +0 -1
- package/dist/widget/hooks/useCustomTokenFetch.d.ts +0 -19
- package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +0 -1
- package/dist/widget/hooks/useTokenWithFreshBalance.d.ts +0 -18
- package/dist/widget/hooks/useTokenWithFreshBalance.d.ts.map +0 -1
- package/src/onramp-client/trails-onramp.gen.ts +0 -1320
- package/src/prices.ts +0 -528
- package/src/useGasEstimation.ts +0 -147
- package/src/widget/assets/Binance_Icon_Logo.svg +0 -14
- package/src/widget/assets/Bitfinex_Icon_Logo.svg +0 -5
- package/src/widget/assets/Coinbase_Icon_Logo.svg +0 -1
- package/src/widget/assets/WalletConnect-logo-blue-bg.svg +0 -11
- package/src/widget/assets/sequence-logo.svg +0 -15
- package/src/widget/hooks/useCustomTokenFetch.tsx +0 -74
- package/src/widget/hooks/useTokenWithFreshBalance.ts +0 -246
package/src/wallets.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { sequenceWallet } from "@0xsequence/connect"
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getWalletIcon,
|
|
4
|
+
getWalletRegistry,
|
|
5
|
+
wagmiConnectorToWalletId,
|
|
6
|
+
type WalletRegistryEntry,
|
|
7
|
+
} from "@0xtrails/wallet-registry"
|
|
3
8
|
import React from "react"
|
|
4
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useConnectors as useWagmiConnectors,
|
|
11
|
+
type Connector as WagmiConnector,
|
|
12
|
+
type CreateConnectorFn,
|
|
13
|
+
} from "wagmi"
|
|
5
14
|
import type { EIP1193Provider } from "viem"
|
|
6
15
|
import {
|
|
7
16
|
baseAccount,
|
|
@@ -15,53 +24,47 @@ import {
|
|
|
15
24
|
DEFAULT_WALLETCONNECT_PROJECT_ID,
|
|
16
25
|
PROD_TRAILS_API_URL,
|
|
17
26
|
} from "./constants.js"
|
|
18
|
-
import WalletConnectLogo from "./widget/assets/WalletConnect-logo-blue-bg.svg"
|
|
19
|
-
import SequenceLogo from "./widget/assets/sequence-logo.svg"
|
|
20
27
|
import { useTrails } from "./widget/providers/TrailsProvider.js"
|
|
21
28
|
|
|
22
|
-
type
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"com.brave.wallet": "brave",
|
|
29
|
+
type ConfigConnector = CreateConnectorFn &
|
|
30
|
+
Partial<
|
|
31
|
+
Pick<
|
|
32
|
+
WagmiConnector,
|
|
33
|
+
| "connect"
|
|
34
|
+
| "disconnect"
|
|
35
|
+
| "getAccounts"
|
|
36
|
+
| "icon"
|
|
37
|
+
| "id"
|
|
38
|
+
| "name"
|
|
39
|
+
| "rdns"
|
|
40
|
+
| "type"
|
|
41
|
+
| "uid"
|
|
42
|
+
>
|
|
43
|
+
>
|
|
44
|
+
|
|
45
|
+
export type WalletConnector = WagmiConnector | ConfigConnector
|
|
46
|
+
|
|
47
|
+
export interface WalletConfig extends WalletRegistryEntry {
|
|
48
|
+
connector?: ConfigConnector
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
export const WALLET_ID_TO_RDNS: Record<string, string> = Object.fromEntries(
|
|
49
|
-
Object.entries(WALLET_RDNS_MAP).map(([rdns, id]) => [id, rdns]),
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
export interface WalletConfig {
|
|
53
|
-
id: string
|
|
54
|
-
name: string
|
|
55
|
-
icon: string
|
|
56
|
-
connector?: Connector
|
|
57
|
-
getWalletConnectDeepLink?: (uri: string) => string
|
|
51
|
+
export interface WalletOption extends WalletRegistryEntry {
|
|
52
|
+
connector: WalletConnector
|
|
53
|
+
source: "config" | "wagmi"
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
interface InternalConnectors {
|
|
57
|
+
injected: ConfigConnector
|
|
58
|
+
walletconnect: ConfigConnector
|
|
59
|
+
safe: ConfigConnector
|
|
60
|
+
baseAccount: ConfigConnector
|
|
61
|
+
gemini: ConfigConnector
|
|
62
|
+
trust: ConfigConnector
|
|
63
|
+
phantom: ConfigConnector
|
|
64
|
+
okx: ConfigConnector
|
|
65
|
+
zerion: ConfigConnector
|
|
66
|
+
ambire: ConfigConnector
|
|
67
|
+
sequence: ConfigConnector
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
// WalletConnect connector singleton to avoid multiple Core initializations.
|
|
@@ -69,8 +72,8 @@ export interface QRCodeWalletOption {
|
|
|
69
72
|
// should NOT create a WalletConnect connector until one is actually needed.
|
|
70
73
|
// This avoids conflicts with apps that bring their own WalletConnect setup
|
|
71
74
|
// (e.g. Reown AppKit) when using hooks-only via TrailsProvider.
|
|
72
|
-
let wcConnectorSingleton:
|
|
73
|
-
export function getWalletConnectConnector():
|
|
75
|
+
let wcConnectorSingleton: ConfigConnector | null = null
|
|
76
|
+
export function getWalletConnectConnector(): ConfigConnector {
|
|
74
77
|
if (!wcConnectorSingleton) {
|
|
75
78
|
wcConnectorSingleton = walletConnect({
|
|
76
79
|
projectId:
|
|
@@ -159,11 +162,11 @@ function resolveProvider(
|
|
|
159
162
|
return candidate as EIP1193Provider
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
|
|
165
|
+
function windowProviderOrWalletConnect(
|
|
163
166
|
walletId: string,
|
|
164
167
|
windowObjectIdentifier: string | string[] | ProviderSelector,
|
|
165
168
|
name: string,
|
|
166
|
-
) {
|
|
169
|
+
): ConfigConnector {
|
|
167
170
|
if (typeof window === "undefined") return getWalletConnectConnector()
|
|
168
171
|
|
|
169
172
|
const windowRecord = window as unknown as Record<string, unknown>
|
|
@@ -183,75 +186,59 @@ export function windowProviderOrWalletConnect(
|
|
|
183
186
|
})
|
|
184
187
|
}
|
|
185
188
|
|
|
186
|
-
/**
|
|
187
|
-
* Hook to get all wallet connectors, creating them lazily with the correct configuration
|
|
188
|
-
*/
|
|
189
|
-
export function useConnectors(): Connector[] {
|
|
190
|
-
const { trailsApiKey, trailsApiUrl } = useTrails()
|
|
191
|
-
|
|
192
|
-
return React.useMemo(() => {
|
|
193
|
-
return getConnectorsInternal(trailsApiKey, trailsApiUrl)
|
|
194
|
-
}, [trailsApiKey, trailsApiUrl])
|
|
195
|
-
}
|
|
196
|
-
|
|
197
189
|
/**
|
|
198
190
|
* Internal function to get connectors (for use outside React components)
|
|
199
191
|
* Exported for use in widget.tsx where hooks can't be used in useMemo
|
|
200
192
|
*/
|
|
201
193
|
|
|
202
194
|
// Cache connectors to prevent recreation on every call
|
|
203
|
-
const connectorsCache = new Map<string,
|
|
195
|
+
const connectorsCache = new Map<string, InternalConnectors>()
|
|
204
196
|
|
|
205
|
-
|
|
197
|
+
function createInternalConnectors(
|
|
206
198
|
projectAccessKey?: string,
|
|
207
199
|
trailsApiUrl?: string,
|
|
208
|
-
):
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
// Return cached connectors if they exist
|
|
212
|
-
const cached = connectorsCache.get(cacheKey)
|
|
213
|
-
if (cached) {
|
|
214
|
-
return cached
|
|
215
|
-
}
|
|
200
|
+
): InternalConnectors {
|
|
201
|
+
const walletConnectConnector = getWalletConnectConnector()
|
|
202
|
+
const walletRegistry = getWalletRegistry()
|
|
216
203
|
|
|
217
204
|
// Create base connectors
|
|
218
205
|
const injectedConnector = injected()
|
|
219
|
-
const baseAccountConnector:
|
|
220
|
-
const geminiConnector:
|
|
221
|
-
const safeConnector:
|
|
206
|
+
const baseAccountConnector: ConfigConnector = baseAccount()
|
|
207
|
+
const geminiConnector: ConfigConnector = gemini()
|
|
208
|
+
const safeConnector: ConfigConnector = safeProviderOrWalletConnect()
|
|
222
209
|
|
|
223
210
|
// Create wallet-specific connectors
|
|
224
211
|
// Note: MetaMask and Rainbow removed - they support EIP-6963 discovery
|
|
225
|
-
const
|
|
212
|
+
const trustConnector = windowProviderOrWalletConnect(
|
|
226
213
|
"trustwallet",
|
|
227
214
|
"trustwallet",
|
|
228
|
-
|
|
215
|
+
walletRegistry.trust.name,
|
|
229
216
|
)
|
|
230
217
|
const phantomConnector = windowProviderOrWalletConnect(
|
|
231
218
|
"phantom",
|
|
232
219
|
["phantom", "ethereum"],
|
|
233
|
-
|
|
220
|
+
walletRegistry.phantom.name,
|
|
234
221
|
)
|
|
235
|
-
const
|
|
236
|
-
"
|
|
222
|
+
const okxConnector = windowProviderOrWalletConnect(
|
|
223
|
+
"okx",
|
|
237
224
|
"okxwallet",
|
|
238
|
-
|
|
225
|
+
walletRegistry.okx.name,
|
|
239
226
|
)
|
|
240
227
|
const zerionConnector = windowProviderOrWalletConnect(
|
|
241
228
|
"zerion",
|
|
242
229
|
"zerionWallet",
|
|
243
|
-
|
|
230
|
+
walletRegistry.zerion.name,
|
|
244
231
|
)
|
|
245
232
|
const ambireConnector = windowProviderOrWalletConnect(
|
|
246
233
|
"ambire",
|
|
247
234
|
"ambire",
|
|
248
|
-
|
|
235
|
+
walletRegistry.ambire.name,
|
|
249
236
|
)
|
|
250
237
|
|
|
251
238
|
// Note: Rabby and Coinbase removed - they support EIP-6963 discovery
|
|
252
239
|
|
|
253
240
|
// Create sequence connector with projectAccessKey
|
|
254
|
-
const sequenceConnector:
|
|
241
|
+
const sequenceConnector: ConfigConnector = sequenceWallet({
|
|
255
242
|
connect: {
|
|
256
243
|
app: "Trails",
|
|
257
244
|
projectAccessKey: projectAccessKey || getConfig("trailsApiKey") || "",
|
|
@@ -260,24 +247,62 @@ export function getConnectorsInternal(
|
|
|
260
247
|
walletAppURL: getSequenceWalletAppUrl(trailsApiUrl),
|
|
261
248
|
})
|
|
262
249
|
|
|
263
|
-
|
|
264
|
-
injectedConnector,
|
|
265
|
-
|
|
266
|
-
safeConnector,
|
|
267
|
-
baseAccountConnector,
|
|
268
|
-
geminiConnector,
|
|
269
|
-
|
|
270
|
-
phantomConnector,
|
|
271
|
-
|
|
272
|
-
zerionConnector,
|
|
273
|
-
ambireConnector,
|
|
274
|
-
sequenceConnector,
|
|
275
|
-
|
|
250
|
+
return {
|
|
251
|
+
injected: injectedConnector,
|
|
252
|
+
walletconnect: walletConnectConnector,
|
|
253
|
+
safe: safeConnector,
|
|
254
|
+
baseAccount: baseAccountConnector,
|
|
255
|
+
gemini: geminiConnector,
|
|
256
|
+
trust: trustConnector,
|
|
257
|
+
phantom: phantomConnector,
|
|
258
|
+
okx: okxConnector,
|
|
259
|
+
zerion: zerionConnector,
|
|
260
|
+
ambire: ambireConnector,
|
|
261
|
+
sequence: sequenceConnector,
|
|
262
|
+
}
|
|
263
|
+
}
|
|
276
264
|
|
|
277
|
-
|
|
278
|
-
|
|
265
|
+
function getCachedInternalConnectors(
|
|
266
|
+
projectAccessKey?: string,
|
|
267
|
+
trailsApiUrl?: string,
|
|
268
|
+
): InternalConnectors {
|
|
269
|
+
const cacheKey = `${projectAccessKey || "default"}:${trailsApiUrl || "default"}`
|
|
279
270
|
|
|
280
|
-
|
|
271
|
+
const cachedConnectors = connectorsCache.get(cacheKey)
|
|
272
|
+
if (cachedConnectors) {
|
|
273
|
+
return cachedConnectors
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const internalConnectors = createInternalConnectors(
|
|
277
|
+
projectAccessKey,
|
|
278
|
+
trailsApiUrl,
|
|
279
|
+
)
|
|
280
|
+
connectorsCache.set(cacheKey, internalConnectors)
|
|
281
|
+
return internalConnectors
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function getConnectorsInternal(
|
|
285
|
+
projectAccessKey?: string,
|
|
286
|
+
trailsApiUrl?: string,
|
|
287
|
+
): ConfigConnector[] {
|
|
288
|
+
const internalConnectors = getCachedInternalConnectors(
|
|
289
|
+
projectAccessKey,
|
|
290
|
+
trailsApiUrl,
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
return [
|
|
294
|
+
internalConnectors.injected,
|
|
295
|
+
internalConnectors.walletconnect,
|
|
296
|
+
internalConnectors.safe,
|
|
297
|
+
internalConnectors.baseAccount,
|
|
298
|
+
internalConnectors.gemini,
|
|
299
|
+
internalConnectors.trust,
|
|
300
|
+
internalConnectors.phantom,
|
|
301
|
+
internalConnectors.okx,
|
|
302
|
+
internalConnectors.zerion,
|
|
303
|
+
internalConnectors.ambire,
|
|
304
|
+
internalConnectors.sequence,
|
|
305
|
+
]
|
|
281
306
|
}
|
|
282
307
|
|
|
283
308
|
/**
|
|
@@ -298,248 +323,112 @@ function getWalletConfigsInternal(
|
|
|
298
323
|
projectAccessKey?: string,
|
|
299
324
|
trailsApiUrl?: string,
|
|
300
325
|
): Record<string, WalletConfig> {
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
safeConnector,
|
|
307
|
-
baseAccountConnector,
|
|
308
|
-
geminiConnector,
|
|
309
|
-
trustwalletConnector,
|
|
310
|
-
phantomConnector,
|
|
311
|
-
okxwalletConnector,
|
|
312
|
-
zerionConnector,
|
|
313
|
-
ambireConnector,
|
|
314
|
-
sequenceConnector,
|
|
315
|
-
] = connectors
|
|
326
|
+
const walletRegistry = getWalletRegistry()
|
|
327
|
+
const internalConnectors = getCachedInternalConnectors(
|
|
328
|
+
projectAccessKey,
|
|
329
|
+
trailsApiUrl,
|
|
330
|
+
)
|
|
316
331
|
|
|
317
332
|
// Create wallet-specific connectors with EIP-6963 priority
|
|
318
333
|
// These will check EIP-6963 first (in widget.tsx), then window properties, then WalletConnect
|
|
319
334
|
const metamaskConnector = windowProviderOrWalletConnect(
|
|
320
335
|
"metamask",
|
|
321
336
|
(provider) => provider.isMetaMask === true,
|
|
322
|
-
|
|
337
|
+
walletRegistry.metamask.name,
|
|
323
338
|
)
|
|
324
339
|
const rabbyConnector = windowProviderOrWalletConnect(
|
|
325
340
|
"rabby",
|
|
326
341
|
(provider) => provider.isRabby === true,
|
|
327
|
-
|
|
342
|
+
walletRegistry.rabby.name,
|
|
328
343
|
)
|
|
329
344
|
const rainbowConnector = windowProviderOrWalletConnect(
|
|
330
345
|
"rainbow",
|
|
331
346
|
"rainbow",
|
|
332
|
-
|
|
347
|
+
walletRegistry.rainbow.name,
|
|
333
348
|
)
|
|
334
349
|
const coinbaseConnector = windowProviderOrWalletConnect(
|
|
335
350
|
"coinbase",
|
|
336
351
|
"coinbaseWalletExtension",
|
|
337
|
-
|
|
352
|
+
walletRegistry.coinbase.name,
|
|
338
353
|
)
|
|
339
354
|
|
|
340
355
|
return {
|
|
341
356
|
injected: {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
connector: injectedConnector,
|
|
345
|
-
icon: WalletIcon as unknown as string,
|
|
357
|
+
...walletRegistry.injected,
|
|
358
|
+
connector: internalConnectors.injected,
|
|
346
359
|
},
|
|
347
360
|
walletconnect: {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
connector: getWalletConnectConnector(),
|
|
351
|
-
icon: WalletConnectLogo as string,
|
|
361
|
+
...walletRegistry.walletconnect,
|
|
362
|
+
connector: internalConnectors.walletconnect,
|
|
352
363
|
},
|
|
353
364
|
metamask: {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
connector: metamaskConnector, // EIP-6963 > window.ethereum.isMetaMask > WalletConnect
|
|
357
|
-
icon: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHZpZXdCb3g9IjAgMCAzMCAzMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjIzIiBoZWlnaHQ9IjIzIiB4PSIzLjUiIHk9IjMuNSIgdmlld0JveD0iMCAwIDE0MS41MSAxMzYuNDIiPjxwYXRoIGZpbGw9IiNGRjVDMTYiIGQ9Im0xMzIuMjQgMTMxLjc1LTMwLjQ4LTkuMDctMjIuOTkgMTMuNzQtMTYuMDMtLjAxLTIzLTEzLjc0LTMwLjQ3IDkuMDhMMCAxMDAuNDdsOS4yNy0zNC43M0wwIDM2LjQgOS4yNyAwbDQ3LjYgMjguNDRoMjcuNzZMMTMyLjI0IDBsOS4yNyAzNi4zOC05LjI3IDI5LjM2IDkuMjcgMzQuNzItOS4yNyAzMS4zWiIvPjxwYXRoIGZpbGw9IiNGRjVDMTYiIGQ9Im05LjI3IDAgNDcuNjEgMjguNDZMNTQuOTggNDggOS4yOSAwWm0zMC40NyAxMDAuNDggMjAuOTUgMTUuOTUtMjAuOTUgNi4yNHYtMjIuMlpNNTkuMDEgNzQuMSA1NSA0OCAyOS4yMiA2NS43NWgtLjAybC4wOCAxOC4yNyAxMC40NS05LjkyaDE5LjI5Wk0xMzIuMjUgMGwtNDcuNiAyOC40Nkw4Ni41MSA0OGw0NS43Mi00OFptLTMwLjQ3IDEwMC40OC0yMC45NCAxNS45NSAyMC45NCA2LjI0di0yMi4yWm0xMC41My0zNC43M0w4Ni41MyA0OCA4Mi41IDc0LjFoMTkuMjdsMTAuNDYgOS45LjA3LTE4LjI2WiIvPjxwYXRoIGZpbGw9IiNFMzQ4MDciIGQ9Im0zOS43MyAxMjIuNjctMzAuNDYgOS4wOEwwIDEwMC40OGgzOS43M3YyMi4yWk01OS4wMiA3NC4xbDUuODIgMzcuNzEtOC4wNy0yMC45Ny0yNy40OS02LjgyIDEwLjQ2LTkuOTJINTlabTQyLjc2IDQ4LjU5IDMwLjQ3IDkuMDcgOS4yNy0zMS4yN2gtMzkuNzR6TTgyLjUgNzQuMDlsLTUuODIgMzcuNzEgOC4wNi0yMC45NyAyNy41LTYuODItMTAuNDctOS45MnoiLz48cGF0aCBmaWxsPSIjRkY4RDVEIiBkPSJtMCAxMDAuNDcgOS4yNy0zNC43M0gyOS4ybC4wNyAxOC4yNyAyNy41IDYuODIgOC4wNiAyMC45Ny00LjE1IDQuNjItMjAuOTQtMTUuOTZIMFptMTQxLjUgMC05LjI2LTM0LjczaC0xOS45M2wtLjA3IDE4LjI3LTI3LjUgNi44Mi04LjA2IDIwLjk3IDQuMTUgNC42MiAyMC45NC0xNS45NmgzOS43NFpNODQuNjQgMjguNDRINTYuODhsLTEuODkgMTkuNTQgOS44NCA2My44aDExLjg1bDkuODUtNjMuOC0xLjktMTkuNTRaIi8+PHBhdGggZmlsbD0iIzY2MTgwMCIgZD0iTTkuMjcgMCAwIDM2LjM4bDkuMjcgMjkuMzZIMjkuMkw1NC45OCA0OHptNDMuOTggODEuNjdoLTkuMDNsLTQuOTIgNC44MSAxNy40NyA0LjMzLTMuNTItOS4xNVpNMTMyLjI0IDBsOS4yNyAzNi4zOC05LjI3IDI5LjM2aC0xOS45M0w4Ni41MyA0OHpNODguMjcgODEuNjdoOS4wNGw0LjkyIDQuODItMTcuNDkgNC4zNCAzLjUzLTkuMTdabS05LjUgNDIuMyAyLjA2LTcuNTQtNC4xNS00LjYySDY0LjgybC00LjE0IDQuNjIgMi4wNSA3LjU0Ii8+PHBhdGggZmlsbD0iI0MwQzRDRCIgZD0iTTc4Ljc3IDEyMy45N3YxMi40NUg2Mi43NHYtMTIuNDVoMTYuMDJaIi8+PHBhdGggZmlsbD0iI0U3RUJGNiIgZD0ibTM5Ljc0IDEyMi42NiAyMyAxMy43NnYtMTIuNDZsLTIuMDUtNy41NHptNjIuMDMgMC0yMyAxMy43NnYtMTIuNDZsMi4wNi03LjU0eiIvPjwvc3ZnPjwvc3ZnPg==",
|
|
358
|
-
getWalletConnectDeepLink: (uri: string) => {
|
|
359
|
-
return `https://metamask.app.link/wc?uri=${encodeURIComponent(uri)}`
|
|
360
|
-
},
|
|
365
|
+
...walletRegistry.metamask,
|
|
366
|
+
connector: metamaskConnector,
|
|
361
367
|
},
|
|
362
368
|
baseAccount: {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
connector: baseAccountConnector,
|
|
366
|
-
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAALZJREFUaEPtmjEOhDAMBNc/O14GvOzys3CAKK6eAlmaVGl2Zc+kTOU685vkc9/bnD2prZK5/TZY24z9P+g4F5hNh7/GdoG37WlAA5CATwgCxHENYISwQAMQII5rACOEBRqAAHFcAxghLNAABIjjGsAIYYEGIEAc1wBGCAs0AAHiuAYwQligAQgQxzWAEcICDUCAOK4BjBAWaAACxHENYISwQAMQII6fBjr+VHkW3+u+tfyxMpJaDgYzYxb/ALZVAAAAAElFTkSuQmCC",
|
|
369
|
+
...walletRegistry.baseAccount,
|
|
370
|
+
connector: internalConnectors.baseAccount,
|
|
367
371
|
},
|
|
368
372
|
safe: {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
connector: safeConnector,
|
|
372
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/3913df81-63c2-4413-d60b-8ff83cbed500?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
373
|
-
getWalletConnectDeepLink: (uri: string) => {
|
|
374
|
-
return `https://gnosis-safe.io/wc?uri=${encodeURIComponent(uri)}`
|
|
375
|
-
},
|
|
373
|
+
...walletRegistry.safe,
|
|
374
|
+
connector: internalConnectors.safe,
|
|
376
375
|
},
|
|
377
376
|
rainbow: {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
connector: rainbowConnector, // EIP-6963 > window.rainbow > WalletConnect
|
|
381
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/7a33d7f1-3d12-4b5c-f3ee-5cd83cb1b500?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
382
|
-
getWalletConnectDeepLink: (uri: string) => {
|
|
383
|
-
return `https://rnbwapp.com/wc?uri=${encodeURIComponent(
|
|
384
|
-
uri,
|
|
385
|
-
)}&connector=connectkit`
|
|
386
|
-
},
|
|
377
|
+
...walletRegistry.rainbow,
|
|
378
|
+
connector: rainbowConnector,
|
|
387
379
|
},
|
|
388
380
|
trust: {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
connector: trustwalletConnector,
|
|
392
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/7677b54f-3486-46e2-4e37-bf8747814f00?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
393
|
-
getWalletConnectDeepLink: (uri: string) => {
|
|
394
|
-
return `https://link.trustwallet.com/wc?uri=${encodeURIComponent(uri)}`
|
|
395
|
-
},
|
|
381
|
+
...walletRegistry.trust,
|
|
382
|
+
connector: internalConnectors.trust,
|
|
396
383
|
},
|
|
397
384
|
ambire: {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
connector: ambireConnector,
|
|
401
|
-
icon: "https://www.ambire.com/favicon.png",
|
|
385
|
+
...walletRegistry.ambire,
|
|
386
|
+
connector: internalConnectors.ambire,
|
|
402
387
|
},
|
|
403
388
|
argent: {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
connector: getWalletConnectConnector(),
|
|
407
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/215158d2-614b-49c9-410f-77aa661c3900?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
389
|
+
...walletRegistry.argent,
|
|
390
|
+
connector: internalConnectors.walletconnect,
|
|
408
391
|
},
|
|
409
392
|
binance: {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
connector: getWalletConnectConnector(),
|
|
413
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/ebac7b39-688c-41e3-7912-a4fefba74600?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
393
|
+
...walletRegistry.binance,
|
|
394
|
+
connector: internalConnectors.walletconnect,
|
|
414
395
|
},
|
|
415
396
|
okx: {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
connector: okxwalletConnector,
|
|
419
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/c55df831-3c52-49fc-d1d1-97a926dc0c00?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
397
|
+
...walletRegistry.okx,
|
|
398
|
+
connector: internalConnectors.okx,
|
|
420
399
|
},
|
|
421
400
|
zerion: {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
connector: zerionConnector,
|
|
425
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/73f6f52f-7862-49e7-bb85-ba93ab72cc00?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
426
|
-
getWalletConnectDeepLink: (uri: string) => {
|
|
427
|
-
return `https://app.zerion.io/wc?uri=${encodeURIComponent(uri)}`
|
|
428
|
-
},
|
|
401
|
+
...walletRegistry.zerion,
|
|
402
|
+
connector: internalConnectors.zerion,
|
|
429
403
|
},
|
|
430
404
|
phantom: {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
connector: phantomConnector,
|
|
434
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/b6ec7b81-bb4f-427d-e290-7631e6e50d00?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
435
|
-
getWalletConnectDeepLink: (_uri: string) => {
|
|
436
|
-
// TODO: https://phantom.com/learn/blog/the-complete-guide-to-phantom-deeplinks
|
|
437
|
-
// return `https://phantom.app/ul/v1/connect`
|
|
438
|
-
// For now, use the browse link to open the Phantom app
|
|
439
|
-
return `https://phantom.app/ul/browse/${encodeURIComponent(typeof window !== "undefined" ? window.location.href : "")}`
|
|
440
|
-
},
|
|
405
|
+
...walletRegistry.phantom,
|
|
406
|
+
connector: internalConnectors.phantom,
|
|
441
407
|
},
|
|
442
408
|
coinbase: {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
connector: coinbaseConnector, // EIP-6963 > window.coinbaseWalletExtension > WalletConnect
|
|
446
|
-
icon: "data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",
|
|
447
|
-
getWalletConnectDeepLink: (uri: string) => {
|
|
448
|
-
return `https://go.cb-w.com/wc?uri=${encodeURIComponent(uri)}`
|
|
449
|
-
},
|
|
409
|
+
...walletRegistry.coinbase,
|
|
410
|
+
connector: coinbaseConnector,
|
|
450
411
|
},
|
|
451
412
|
rabby: {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
connector: rabbyConnector, // EIP-6963 > window.ethereum.isRabby > WalletConnect,
|
|
455
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/255e6ba2-8dfd-43ad-e88e-57cbb98f6800?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
456
|
-
},
|
|
457
|
-
privy: {
|
|
458
|
-
id: "privy",
|
|
459
|
-
name: "Privy",
|
|
460
|
-
icon: "https://avatars.githubusercontent.com/u/81824329?s=200&v=4",
|
|
413
|
+
...walletRegistry.rabby,
|
|
414
|
+
connector: rabbyConnector,
|
|
461
415
|
},
|
|
416
|
+
privy: walletRegistry.privy,
|
|
462
417
|
gemini: {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
connector: geminiConnector,
|
|
466
|
-
icon: "https://explorer-api.walletconnect.com/v3/logo/sm/56a3fd87-2627-4903-fddd-205224dac500?projectId=34357d3c125c2bcf2ce2bc3309d98715",
|
|
418
|
+
...walletRegistry.gemini,
|
|
419
|
+
connector: internalConnectors.gemini,
|
|
467
420
|
},
|
|
468
421
|
sequence: {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
connector: sequenceConnector,
|
|
472
|
-
icon: SequenceLogo as string,
|
|
422
|
+
...walletRegistry.sequence,
|
|
423
|
+
connector: internalConnectors.sequence,
|
|
473
424
|
},
|
|
474
425
|
"sequence-waas": {
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
connector: sequenceConnector,
|
|
478
|
-
icon: SequenceLogo as string,
|
|
426
|
+
...walletRegistry["sequence-waas"],
|
|
427
|
+
connector: internalConnectors.sequence,
|
|
479
428
|
},
|
|
480
429
|
}
|
|
481
430
|
}
|
|
482
431
|
|
|
483
|
-
/**
|
|
484
|
-
* Hook to get QR code wallet options
|
|
485
|
-
*/
|
|
486
|
-
export function useQRCodeWallets(): QRCodeWalletOption[] {
|
|
487
|
-
const { trailsApiKey, trailsApiUrl } = useTrails()
|
|
488
|
-
|
|
489
|
-
return React.useMemo(() => {
|
|
490
|
-
return getQRCodeWalletsInternal(trailsApiKey, trailsApiUrl)
|
|
491
|
-
}, [trailsApiKey, trailsApiUrl])
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Internal function to get QR code wallets (for use outside React components)
|
|
496
|
-
*/
|
|
497
|
-
function getQRCodeWalletsInternal(
|
|
498
|
-
projectAccessKey?: string,
|
|
499
|
-
trailsApiUrl?: string,
|
|
500
|
-
): QRCodeWalletOption[] {
|
|
501
|
-
const walletConfigs = getWalletConfigsInternal(projectAccessKey, trailsApiUrl)
|
|
502
|
-
|
|
503
|
-
return [
|
|
504
|
-
{
|
|
505
|
-
id: "metamask",
|
|
506
|
-
label: "MetaMask",
|
|
507
|
-
usesEip681: true,
|
|
508
|
-
icon: walletConfigs.metamask?.icon || "",
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
id: "coinbase",
|
|
512
|
-
label: "CB Wallet",
|
|
513
|
-
usesEip681: false,
|
|
514
|
-
icon: walletConfigs.coinbase?.icon || "",
|
|
515
|
-
},
|
|
516
|
-
{
|
|
517
|
-
id: "trust",
|
|
518
|
-
label: "Trust Wallet",
|
|
519
|
-
usesEip681: false,
|
|
520
|
-
icon: walletConfigs.trust?.icon || "",
|
|
521
|
-
},
|
|
522
|
-
{
|
|
523
|
-
id: "rabby",
|
|
524
|
-
label: "Rabby",
|
|
525
|
-
usesEip681: false,
|
|
526
|
-
icon: walletConfigs.rabby?.icon || "",
|
|
527
|
-
},
|
|
528
|
-
{
|
|
529
|
-
id: "rainbow",
|
|
530
|
-
label: "Rainbow",
|
|
531
|
-
usesEip681: false,
|
|
532
|
-
icon: walletConfigs.rainbow?.icon || "",
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
id: "phantom",
|
|
536
|
-
label: "Phantom",
|
|
537
|
-
usesEip681: false,
|
|
538
|
-
icon: walletConfigs.phantom?.icon || "",
|
|
539
|
-
},
|
|
540
|
-
] satisfies QRCodeWalletOption[]
|
|
541
|
-
}
|
|
542
|
-
|
|
543
432
|
const PROD_SEQUENCE_WALLET_APP_URL = "https://sequence.app"
|
|
544
433
|
const DEV_SEQUENCE_WALLET_APP_URL = "https://dev.sequence.app"
|
|
545
434
|
|
|
@@ -557,94 +446,9 @@ function getSequenceWalletAppUrl(trailsApiUrl?: string): string {
|
|
|
557
446
|
: PROD_SEQUENCE_WALLET_APP_URL
|
|
558
447
|
}
|
|
559
448
|
|
|
560
|
-
export const
|
|
561
|
-
"
|
|
562
|
-
|
|
563
|
-
"baseAccount",
|
|
564
|
-
"rainbow",
|
|
565
|
-
"phantom",
|
|
566
|
-
]
|
|
567
|
-
|
|
568
|
-
/**
|
|
569
|
-
* Hook to get wallet icon
|
|
570
|
-
*/
|
|
571
|
-
export function useWalletIcon(walletId?: string): string {
|
|
572
|
-
const walletConfigs = useWalletConfigs()
|
|
573
|
-
|
|
574
|
-
return React.useMemo(() => {
|
|
575
|
-
if (!walletId) return ""
|
|
576
|
-
return (walletConfigs[walletId]?.icon || "") as string
|
|
577
|
-
}, [walletId, walletConfigs])
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
/**
|
|
581
|
-
* Hook to get wallet name
|
|
582
|
-
*/
|
|
583
|
-
export function useWalletName(walletId?: string): string {
|
|
584
|
-
const walletConfigs = useWalletConfigs()
|
|
585
|
-
|
|
586
|
-
return React.useMemo(() => {
|
|
587
|
-
if (!walletId) return ""
|
|
588
|
-
return (walletConfigs[walletId]?.name || "") as string
|
|
589
|
-
}, [walletId, walletConfigs])
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
// Legacy functions for backward compatibility (use hooks instead)
|
|
593
|
-
export const getWalletIcon = (
|
|
594
|
-
walletId?: string,
|
|
595
|
-
projectAccessKey?: string,
|
|
596
|
-
): string => {
|
|
597
|
-
if (!walletId) return ""
|
|
598
|
-
const walletConfigs = getWalletConfigsInternal(projectAccessKey)
|
|
599
|
-
return (walletConfigs[walletId]?.icon || "") as string
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
export const getWalletName = (
|
|
603
|
-
walletId?: string,
|
|
604
|
-
projectAccessKey?: string,
|
|
605
|
-
): string => {
|
|
606
|
-
if (!walletId) return ""
|
|
607
|
-
const walletConfigs = getWalletConfigsInternal(projectAccessKey)
|
|
608
|
-
return (walletConfigs[walletId]?.name || "") as string
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Convert a wagmi connector to a wallet ID using EIP-6963 RDNS (preferred) or name fallback.
|
|
613
|
-
* RDNS-based identification is more reliable as it uses the wallet's unique identifier
|
|
614
|
-
* announced via EIP-6963, avoiding conflicts when multiple wallets override window.ethereum.
|
|
615
|
-
*/
|
|
616
|
-
export const wagmiConnectorToWalletId = (wagmiConnector: any): string => {
|
|
617
|
-
// 1. First try RDNS from EIP-6963 info (most reliable)
|
|
618
|
-
// Wagmi's multiInjectedProviderDiscovery populates this from EIP-6963 announcements
|
|
619
|
-
const rdns = wagmiConnector?.info?.rdns
|
|
620
|
-
if (rdns && WALLET_RDNS_MAP[rdns]) {
|
|
621
|
-
return WALLET_RDNS_MAP[rdns]
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
// 2. Fallback to name-based matching for non-EIP-6963 connectors
|
|
625
|
-
const wagmiConnectorName = (
|
|
626
|
-
wagmiConnector?.name ||
|
|
627
|
-
wagmiConnector?.id ||
|
|
628
|
-
""
|
|
629
|
-
).toLowerCase()
|
|
630
|
-
if (wagmiConnectorName.includes("rabby")) return "rabby"
|
|
631
|
-
if (wagmiConnectorName.includes("metamask")) return "metamask"
|
|
632
|
-
if (wagmiConnectorName.includes("walletconnect")) return "walletconnect"
|
|
633
|
-
if (wagmiConnectorName.includes("coinbase")) return "coinbase"
|
|
634
|
-
if (wagmiConnectorName.includes("base")) return "baseAccount"
|
|
635
|
-
if (wagmiConnectorName.includes("rainbow")) return "rainbow"
|
|
636
|
-
if (wagmiConnectorName.includes("trust")) return "trust"
|
|
637
|
-
if (wagmiConnectorName.includes("ambire")) return "ambire"
|
|
638
|
-
if (wagmiConnectorName.includes("argent")) return "argent"
|
|
639
|
-
if (wagmiConnectorName.includes("okx")) return "okxwallet"
|
|
640
|
-
if (wagmiConnectorName.includes("privy")) return "privy"
|
|
641
|
-
if (wagmiConnectorName.includes("gemini")) return "gemini"
|
|
642
|
-
if (wagmiConnectorName.includes("waas")) return "sequence-waas"
|
|
643
|
-
if (wagmiConnectorName.includes("sequence")) return "sequence"
|
|
644
|
-
return wagmiConnector.id || "injected"
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
export const isEmbeddedConnector = (connector?: any): boolean => {
|
|
449
|
+
export const isEmbeddedConnector = (
|
|
450
|
+
connector?: Pick<WalletConnector, "name"> | null,
|
|
451
|
+
): boolean => {
|
|
648
452
|
if (!connector) return false
|
|
649
453
|
if (
|
|
650
454
|
connector.name?.toLowerCase()?.includes("privy") ||
|
|
@@ -660,15 +464,21 @@ export const useWallets = () => {
|
|
|
660
464
|
const walletConfigs = useWalletConfigs()
|
|
661
465
|
|
|
662
466
|
const allWallets = React.useMemo(() => {
|
|
467
|
+
const hasConnector = (
|
|
468
|
+
walletConfig: WalletConfig,
|
|
469
|
+
): walletConfig is WalletConfig & { connector: ConfigConnector } => {
|
|
470
|
+
return Boolean(walletConfig.connector)
|
|
471
|
+
}
|
|
472
|
+
|
|
663
473
|
// Get config wallets that have connectors
|
|
664
474
|
const configWallets = Object.values(walletConfigs)
|
|
665
|
-
.filter(
|
|
475
|
+
.filter(hasConnector)
|
|
666
476
|
.map((config) => ({
|
|
667
477
|
id: config.id,
|
|
668
478
|
name: config.name,
|
|
669
479
|
icon: config.icon,
|
|
670
480
|
connector: config.connector,
|
|
671
|
-
source: "config"
|
|
481
|
+
source: "config",
|
|
672
482
|
}))
|
|
673
483
|
|
|
674
484
|
// Get wagmi wallets
|
|
@@ -680,14 +490,14 @@ export const useWallets = () => {
|
|
|
680
490
|
connector.icon ||
|
|
681
491
|
"",
|
|
682
492
|
connector: connector,
|
|
683
|
-
source: "wagmi"
|
|
493
|
+
source: "wagmi",
|
|
684
494
|
}))
|
|
685
495
|
|
|
686
496
|
// Combine and deduplicate, prioritizing wagmi connector over config connector.
|
|
687
497
|
// We keep config metadata (name, icon) but always prefer the connector instance
|
|
688
498
|
// from the active Wagmi config so that consumer-provided connectors (e.g. WaaS)
|
|
689
499
|
// are used instead of the SDK's own connector instances.
|
|
690
|
-
const allWallets:
|
|
500
|
+
const allWallets: WalletOption[] = []
|
|
691
501
|
|
|
692
502
|
for (const wallet of configWallets) {
|
|
693
503
|
// Always check if the active Wagmi config has a matching connector
|
|
@@ -703,16 +513,16 @@ export const useWallets = () => {
|
|
|
703
513
|
name: wallet.name,
|
|
704
514
|
icon: wallet.icon,
|
|
705
515
|
connector: resolvedConnector,
|
|
706
|
-
source: wagmiConnector ?
|
|
516
|
+
source: wagmiConnector ? "wagmi" : "config",
|
|
707
517
|
})
|
|
708
518
|
}
|
|
709
519
|
|
|
710
520
|
for (const wallet of wagmiWallets) {
|
|
711
521
|
if (
|
|
712
|
-
!allWallets.find((
|
|
522
|
+
!allWallets.find((existingWallet) => existingWallet.id === wallet.id)
|
|
713
523
|
) {
|
|
714
524
|
const configWallet = configWallets.find(
|
|
715
|
-
(config
|
|
525
|
+
(config) => config.id === wallet.id,
|
|
716
526
|
)
|
|
717
527
|
|
|
718
528
|
allWallets.push({
|
|
@@ -720,7 +530,7 @@ export const useWallets = () => {
|
|
|
720
530
|
name: configWallet?.name || wallet.name,
|
|
721
531
|
icon: configWallet?.icon || wallet.icon,
|
|
722
532
|
connector: wallet.connector,
|
|
723
|
-
source: "wagmi"
|
|
533
|
+
source: "wagmi",
|
|
724
534
|
})
|
|
725
535
|
}
|
|
726
536
|
}
|
|
@@ -732,9 +542,3 @@ export const useWallets = () => {
|
|
|
732
542
|
wallets: allWallets,
|
|
733
543
|
}
|
|
734
544
|
}
|
|
735
|
-
|
|
736
|
-
// Helper method to find wallet by ID using the hook (for use in components)
|
|
737
|
-
export const useFindWalletById = (walletId: string) => {
|
|
738
|
-
const { wallets } = useWallets()
|
|
739
|
-
return wallets.find((wallet: any) => wallet.id === walletId) || null
|
|
740
|
-
}
|