0xtrails 0.1.13 → 0.2.1
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/aave.d.ts.map +1 -1
- package/dist/analytics.d.ts +12 -2
- package/dist/analytics.d.ts.map +1 -1
- package/dist/apiClient.d.ts +1 -1
- package/dist/apiClient.d.ts.map +1 -1
- package/dist/{ccip-D3gTQONK.js → ccip-BbfANth7.js} +12 -12
- package/dist/cctp.d.ts.map +1 -1
- package/dist/cctpqueue.d.ts +3 -3
- package/dist/cctpqueue.d.ts.map +1 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +18 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +6 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/contractUtils.d.ts +2 -0
- package/dist/contractUtils.d.ts.map +1 -1
- package/dist/customChains.d.ts +24 -0
- package/dist/customChains.d.ts.map +1 -0
- package/dist/gasless.d.ts +19 -7
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-CnUM7lKf.js → index-WpIVoh3X.js} +36741 -31761
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +405 -394
- package/dist/indexerClient.d.ts +10 -0
- package/dist/indexerClient.d.ts.map +1 -1
- package/dist/intentEntrypoint.d.ts +122 -0
- package/dist/intentEntrypoint.d.ts.map +1 -0
- package/dist/intents.d.ts +5 -3
- package/dist/intents.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts.map +1 -1
- package/dist/morpho.d.ts.map +1 -1
- package/dist/pools.d.ts +3 -1
- package/dist/pools.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +18 -9
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +1 -1
- package/dist/prices.d.ts.map +1 -1
- package/dist/relaySdk.d.ts.map +1 -1
- package/dist/relayer.d.ts.map +1 -1
- package/dist/toast.d.ts +9 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/tokenBalances.d.ts +6 -2
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +6 -5
- package/dist/trails.d.ts.map +1 -1
- package/dist/trailsClient.d.ts +12 -0
- package/dist/trailsClient.d.ts.map +1 -0
- package/dist/trailsRouter.d.ts +22 -0
- package/dist/trailsRouter.d.ts.map +1 -0
- package/dist/transactions.d.ts +8 -1
- package/dist/transactions.d.ts.map +1 -1
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts +7 -0
- package/dist/widget/components/AccountSettings.d.ts.map +1 -0
- package/dist/widget/components/ChainList.d.ts +0 -1
- package/dist/widget/components/ChainList.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +46 -0
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -0
- package/dist/widget/components/ConfigDisplay.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts +9 -0
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -0
- package/dist/widget/components/DebugMenu.d.ts.map +1 -1
- package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
- package/dist/widget/components/DebugToast.d.ts +3 -0
- package/dist/widget/components/DebugToast.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +22 -0
- package/dist/widget/components/FeeOption.d.ts.map +1 -0
- package/dist/widget/components/FeeOptions.d.ts +13 -17
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +44 -0
- package/dist/widget/components/Fund.d.ts.map +1 -0
- package/dist/widget/components/FundMethods.d.ts +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSendForm.d.ts.map +1 -1
- package/dist/widget/components/Identicon.d.ts +9 -0
- package/dist/widget/components/Identicon.d.ts.map +1 -0
- package/dist/widget/components/MeshConnectExchanges.d.ts +5 -2
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectFlow.d.ts +2 -0
- package/dist/widget/components/MeshConnectFlow.d.ts.map +1 -1
- package/dist/widget/components/NativeGasOption.d.ts +12 -0
- package/dist/widget/components/NativeGasOption.d.ts.map +1 -0
- package/dist/widget/components/Pay.d.ts +46 -0
- package/dist/widget/components/Pay.d.ts.map +1 -0
- package/dist/widget/components/PaySendForm.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receive.d.ts.map +1 -1
- package/dist/widget/components/RecentTokens.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts +9 -0
- package/dist/widget/components/Recipients.d.ts.map +1 -0
- package/dist/widget/components/RefundWarning.d.ts +9 -0
- package/dist/widget/components/RefundWarning.d.ts.map +1 -0
- package/dist/widget/components/SimpleSwap.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/SwapSettings.d.ts +1 -5
- package/dist/widget/components/SwapSettings.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/ThemeSyncer.d.ts +6 -0
- package/dist/widget/components/ThemeSyncer.d.ts.map +1 -0
- package/dist/widget/components/Toast.d.ts +24 -0
- package/dist/widget/components/Toast.d.ts.map +1 -0
- package/dist/widget/components/TokenList.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/TruncatedAddress.d.ts +2 -0
- package/dist/widget/components/TruncatedAddress.d.ts.map +1 -1
- package/dist/widget/components/UserPreferences.d.ts +7 -0
- package/dist/widget/components/UserPreferences.d.ts.map +1 -0
- package/dist/widget/hooks/useBack.d.ts +2 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useBalanceVisible.d.ts +1 -0
- package/dist/widget/hooks/useBalanceVisible.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts +1 -1
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts +54 -0
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -0
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts +34 -0
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -0
- package/dist/widget/hooks/useRecipients.d.ts +17 -0
- package/dist/widget/hooks/useRecipients.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +32 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts +14 -0
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts +12 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +10 -13
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useSwapAmount.d.ts +13 -0
- package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -0
- package/dist/widget/hooks/useSwapSettings.d.ts +16 -0
- package/dist/widget/hooks/useSwapSettings.d.ts.map +1 -0
- package/dist/widget/hooks/useTargetAmount.d.ts +5 -0
- package/dist/widget/hooks/useTargetAmount.d.ts.map +1 -0
- package/dist/widget/hooks/useTheme.d.ts +14 -0
- package/dist/widget/hooks/useTheme.d.ts.map +1 -0
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.js +2 -2
- package/dist/widget/widget.d.ts +9 -0
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +38 -36
- package/src/aave.ts +6 -1
- package/src/analytics.ts +109 -53
- package/src/apiClient.ts +1 -1
- package/src/cctp.ts +6 -2
- package/src/cctpqueue.ts +7 -7
- package/src/chains.ts +18 -0
- package/src/config.ts +63 -17
- package/src/constants.ts +20 -16
- package/src/contractUtils.ts +33 -2
- package/src/customChains.ts +24 -0
- package/src/gasless.ts +162 -109
- package/src/index.ts +11 -1
- package/src/indexerClient.ts +73 -1
- package/src/intentEntrypoint.ts +218 -0
- package/src/intents.ts +85 -54
- package/src/metaTxnMonitor.ts +1 -0
- package/src/morpho.ts +13 -2
- package/src/pools.ts +68 -86
- package/src/prepareSend.ts +1719 -967
- package/src/prices.ts +51 -7
- package/src/relaySdk.ts +6 -4
- package/src/relayer.ts +6 -3
- package/src/toast.ts +110 -0
- package/src/tokenBalances.ts +112 -20
- package/src/tokens.ts +70 -7
- package/src/trails.ts +81 -80
- package/src/trailsClient.ts +48 -0
- package/src/{proxyCaller.ts → trailsRouter.ts} +25 -20
- package/src/transactions.ts +30 -88
- package/src/umd.tsx +1 -1
- package/src/wallets.ts +2 -1
- package/src/widget/assets/sequence-logo.svg +15 -0
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountActionsDropdown.tsx +18 -159
- package/src/widget/components/AccountIntentTransactionHistory.tsx +346 -63
- package/src/widget/components/AccountSettings.tsx +102 -0
- package/src/widget/components/ChainFilterDropdown.tsx +1 -1
- package/src/widget/components/ChainList.tsx +10 -20
- package/src/widget/components/ClassicSwap.tsx +921 -0
- package/src/widget/components/ConfigDisplay.tsx +41 -5
- package/src/widget/components/ConnectWallet.tsx +168 -11
- package/src/widget/components/ConnectedWallets.tsx +342 -0
- package/src/widget/components/DebugMenu.tsx +2 -0
- package/src/widget/components/DebugScreensList.tsx +3 -0
- package/src/widget/components/DebugToast.tsx +63 -0
- package/src/widget/components/Earn.tsx +112 -143
- package/src/widget/components/EarnPools.tsx +2 -4
- package/src/widget/components/EarnPoolsFilters.tsx +6 -6
- package/src/widget/components/FeeOption.tsx +78 -0
- package/src/widget/components/FeeOptions.tsx +192 -127
- package/src/widget/components/Fund.tsx +1236 -0
- package/src/widget/components/FundMethods.tsx +4 -4
- package/src/widget/components/FundSendForm.tsx +1 -34
- package/src/widget/components/Identicon.tsx +158 -0
- package/src/widget/components/MeshConnectExchanges.tsx +32 -3
- package/src/widget/components/MeshConnectFlow.tsx +23 -4
- package/src/widget/components/NativeGasOption.tsx +99 -0
- package/src/widget/components/Pay.tsx +1092 -0
- package/src/widget/components/PaySendForm.tsx +1 -38
- package/src/widget/components/QuoteDetails.tsx +1 -30
- package/src/widget/components/Receipt.tsx +1 -1
- package/src/widget/components/Receive.tsx +4 -2
- package/src/widget/components/RecentTokens.tsx +2 -1
- package/src/widget/components/Recipients.tsx +448 -0
- package/src/widget/components/RefundWarning.tsx +61 -0
- package/src/widget/components/ScreenHeader.tsx +1 -1
- package/src/widget/components/SimpleSwap.tsx +74 -58
- package/src/widget/components/Swap.tsx +35 -853
- package/src/widget/components/SwapSettings.tsx +5 -11
- package/src/widget/components/ThemeProvider.tsx +32 -0
- package/src/widget/components/ThemeSyncer.tsx +47 -0
- package/src/widget/components/Toast.tsx +315 -0
- package/src/widget/components/TokenList.tsx +2 -34
- package/src/widget/components/TokenSelector.tsx +14 -3
- package/src/widget/components/TransactionDetails.tsx +153 -13
- package/src/widget/components/TransferPendingVertical.tsx +1 -1
- package/src/widget/components/TruncatedAddress.tsx +5 -1
- package/src/widget/components/UserPreferences.tsx +155 -0
- package/src/widget/components/WalletList.tsx +1 -1
- package/src/widget/hooks/useBack.tsx +4 -0
- package/src/widget/hooks/useBalanceVisible.tsx +40 -2
- package/src/widget/hooks/useCheckout.ts +13 -0
- package/src/widget/hooks/useCurrentScreen.tsx +4 -0
- package/src/widget/hooks/useDebugScreens.ts +12 -2
- package/src/widget/hooks/useDefaultTokenSelection.tsx +471 -0
- package/src/widget/hooks/useIntentTransactionHistory.ts +212 -0
- package/src/widget/hooks/usePayMessage.tsx +370 -0
- package/src/widget/hooks/useRecipients.ts +168 -0
- package/src/widget/hooks/useSelectedFeeToken.tsx +299 -0
- package/src/widget/hooks/useSelectedMeshExchange.tsx +46 -0
- package/src/widget/hooks/useSelectedRecipient.tsx +48 -0
- package/src/widget/hooks/useSendForm.ts +257 -49
- package/src/widget/hooks/useSwapAmount.tsx +50 -0
- package/src/widget/hooks/useSwapSettings.tsx +100 -0
- package/src/widget/hooks/useTargetAmount.ts +23 -0
- package/src/widget/hooks/useTheme.tsx +80 -0
- package/src/widget/hooks/useTokenList.ts +20 -11
- package/src/widget/index.css +45 -21
- package/src/widget/widget.tsx +294 -136
- package/dist/address.d.ts +0 -2
- package/dist/address.d.ts.map +0 -1
- package/dist/proxyCaller.d.ts +0 -21
- package/dist/proxyCaller.d.ts.map +0 -1
- package/src/address.ts +0 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type React from "react"
|
|
2
2
|
import { Wallet, QrCode, Building2 } from "lucide-react"
|
|
3
3
|
import { useAccount } from "wagmi"
|
|
4
|
-
import { truncateAddress } from "../../
|
|
4
|
+
import { truncateAddress } from "../../utils.js"
|
|
5
5
|
import { useTheme } from "../components/ThemeProvider.js"
|
|
6
6
|
import WalletConnectLogoWhite from "../assets/WalletConnect-logo-white.svg"
|
|
7
7
|
import WalletConnectLogoBlack from "../assets/WalletConnect-logo-black.svg"
|
|
@@ -10,7 +10,7 @@ import { ScreenHeader } from "./ScreenHeader.js"
|
|
|
10
10
|
export interface FundMethodsProps {
|
|
11
11
|
onBack?: () => void
|
|
12
12
|
onSelectWalletConnect: () => void
|
|
13
|
-
|
|
13
|
+
onSelectExchangeList: () => void
|
|
14
14
|
onSelectConnectedAccount: () => void
|
|
15
15
|
onSelectQrCode: () => void
|
|
16
16
|
}
|
|
@@ -18,7 +18,7 @@ export interface FundMethodsProps {
|
|
|
18
18
|
const FundMethods: React.FC<FundMethodsProps> = ({
|
|
19
19
|
onBack,
|
|
20
20
|
onSelectWalletConnect,
|
|
21
|
-
|
|
21
|
+
onSelectExchangeList,
|
|
22
22
|
onSelectConnectedAccount,
|
|
23
23
|
onSelectQrCode,
|
|
24
24
|
}) => {
|
|
@@ -158,7 +158,7 @@ const FundMethods: React.FC<FundMethodsProps> = ({
|
|
|
158
158
|
|
|
159
159
|
<button
|
|
160
160
|
type="button"
|
|
161
|
-
onClick={
|
|
161
|
+
onClick={onSelectExchangeList}
|
|
162
162
|
className="w-full flex items-center justify-between cursor-pointer font-semibold py-4 px-6 trails-border-radius-large-button transition-all duration-200 trails-bg-secondary trails-hover-bg trails-text-primary"
|
|
163
163
|
>
|
|
164
164
|
<div className="flex items-center space-x-3 flex-1">
|
|
@@ -20,7 +20,6 @@ import { ErrorDisplay } from "./ErrorDisplay.js"
|
|
|
20
20
|
import { useMode } from "../hooks/useMode.js"
|
|
21
21
|
import { getExplorerUrlForAddress } from "../../explorer.js"
|
|
22
22
|
import { logger } from "../../logger.js"
|
|
23
|
-
import { FeeOptions } from "./FeeOptions.js"
|
|
24
23
|
import { useBalanceVisible } from "../hooks/useBalanceVisible.js"
|
|
25
24
|
|
|
26
25
|
interface FundSendFormProps {
|
|
@@ -138,9 +137,6 @@ export const FundSendForm: React.FC<FundSendFormProps> = ({
|
|
|
138
137
|
quoteErrorPrettified,
|
|
139
138
|
isSameTokenWithoutCustomCalldata,
|
|
140
139
|
destinationTokenAddress,
|
|
141
|
-
feeOptions,
|
|
142
|
-
selectedFeeToken,
|
|
143
|
-
setSelectedFeeToken,
|
|
144
140
|
isRecipientContract,
|
|
145
141
|
} = useSendForm({
|
|
146
142
|
account,
|
|
@@ -825,17 +821,10 @@ export const FundSendForm: React.FC<FundSendFormProps> = ({
|
|
|
825
821
|
chainId={selectedDestinationChain.id}
|
|
826
822
|
/> */}
|
|
827
823
|
|
|
828
|
-
{/* Fee Options */}
|
|
829
|
-
<FeeOptions
|
|
830
|
-
options={feeOptions}
|
|
831
|
-
selectedOption={selectedFeeToken ?? undefined}
|
|
832
|
-
onSelect={setSelectedFeeToken}
|
|
833
|
-
/>
|
|
834
|
-
|
|
835
824
|
{/* Warning Messages - Show only one at a time */}
|
|
836
825
|
{isSameTokenWithoutCustomCalldata ? (
|
|
837
826
|
<ErrorDisplay
|
|
838
|
-
errorPrettified="Cannot swap to the same token on the same chain without custom calldata. Please select a different
|
|
827
|
+
errorPrettified="Cannot swap to the same token on the same chain without custom calldata. Please select a different origin token."
|
|
839
828
|
severity="error"
|
|
840
829
|
/>
|
|
841
830
|
) : (
|
|
@@ -867,28 +856,6 @@ export const FundSendForm: React.FC<FundSendFormProps> = ({
|
|
|
867
856
|
</p>
|
|
868
857
|
</div>
|
|
869
858
|
</div>
|
|
870
|
-
) : prepareSendQuote?.minimumNotMet ? (
|
|
871
|
-
<div className="px-2 py-3 rounded-lg bg-amber-500/10 border border-solid border-amber-500/30">
|
|
872
|
-
<div className="flex items-center space-x-2">
|
|
873
|
-
<svg
|
|
874
|
-
className="w-4 h-4 text-amber-500 flex-shrink-0"
|
|
875
|
-
fill="none"
|
|
876
|
-
stroke="currentColor"
|
|
877
|
-
viewBox="0 0 24 24"
|
|
878
|
-
aria-hidden="true"
|
|
879
|
-
>
|
|
880
|
-
<path
|
|
881
|
-
strokeLinecap="round"
|
|
882
|
-
strokeLinejoin="round"
|
|
883
|
-
strokeWidth={2}
|
|
884
|
-
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"
|
|
885
|
-
/>
|
|
886
|
-
</svg>
|
|
887
|
-
<p className="text-sm text-amber-600 dark:text-amber-400">
|
|
888
|
-
Please enter an amount above $0.15 otherwise transfer may fail
|
|
889
|
-
</p>
|
|
890
|
-
</div>
|
|
891
|
-
</div>
|
|
892
859
|
) : null}
|
|
893
860
|
|
|
894
861
|
{/* Continue Button */}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
|
|
3
|
+
// MetaMask-style hash function
|
|
4
|
+
const hashCode = (str: string): number => {
|
|
5
|
+
let hash = 0
|
|
6
|
+
for (let i = 0; i < str.length; i++) {
|
|
7
|
+
const char = str.charCodeAt(i)
|
|
8
|
+
hash = (hash << 5) - hash + char
|
|
9
|
+
hash = hash & hash
|
|
10
|
+
}
|
|
11
|
+
return Math.abs(hash)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Generate MetaMask-style colors (bright and vibrant)
|
|
15
|
+
const generateMetaMaskColors = (seed: number) => {
|
|
16
|
+
const colors = [
|
|
17
|
+
"#FF6B6B",
|
|
18
|
+
"#4ECDC4",
|
|
19
|
+
"#45B7D1",
|
|
20
|
+
"#96CEB4",
|
|
21
|
+
"#FECA57",
|
|
22
|
+
"#FF9FF3",
|
|
23
|
+
"#54A0FF",
|
|
24
|
+
"#5F27CD",
|
|
25
|
+
"#00D2D3",
|
|
26
|
+
"#FF9F43",
|
|
27
|
+
"#10AC84",
|
|
28
|
+
"#EE5A24",
|
|
29
|
+
"#0ABDE3",
|
|
30
|
+
"#C44569",
|
|
31
|
+
"#F8B500",
|
|
32
|
+
"#6C5CE7",
|
|
33
|
+
"#A3CB38",
|
|
34
|
+
"#FD79A8",
|
|
35
|
+
"#636E72",
|
|
36
|
+
"#00B894",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
const bg = colors[seed % colors.length]
|
|
40
|
+
const spot = colors[(seed + 7) % colors.length]
|
|
41
|
+
|
|
42
|
+
return { backgroundColor: bg, spotColor: spot }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Generate MetaMask-style pattern
|
|
46
|
+
const generateMetaMaskPattern = (address: string) => {
|
|
47
|
+
const cleanAddress = address.replace(/^0x/i, "").toLowerCase()
|
|
48
|
+
|
|
49
|
+
// Use address to generate deterministic values
|
|
50
|
+
const seed = hashCode(cleanAddress)
|
|
51
|
+
const { backgroundColor, spotColor } = generateMetaMaskColors(seed)
|
|
52
|
+
|
|
53
|
+
// Generate a 8x8 grid pattern like MetaMask
|
|
54
|
+
const size = 8
|
|
55
|
+
const pattern: boolean[][] = []
|
|
56
|
+
|
|
57
|
+
// Generate pattern with symmetry (like MetaMask)
|
|
58
|
+
for (let y = 0; y < size; y++) {
|
|
59
|
+
const row: boolean[] = []
|
|
60
|
+
for (let x = 0; x < size; x++) {
|
|
61
|
+
// Create horizontal symmetry
|
|
62
|
+
const actualX = x < 4 ? x : 7 - x
|
|
63
|
+
|
|
64
|
+
// Use different parts of address for different rows/columns
|
|
65
|
+
const addressIndex = (y * 4 + actualX) % cleanAddress.length
|
|
66
|
+
const char = cleanAddress.charCodeAt(addressIndex)
|
|
67
|
+
|
|
68
|
+
// Determine if this cell should be filled
|
|
69
|
+
const shouldFill = (char + seed) % 3 === 0
|
|
70
|
+
row.push(shouldFill)
|
|
71
|
+
}
|
|
72
|
+
pattern.push(row)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
backgroundColor,
|
|
77
|
+
spotColor,
|
|
78
|
+
pattern,
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface IdenticonProps {
|
|
83
|
+
value?: string
|
|
84
|
+
size?: number
|
|
85
|
+
className?: string
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const Identicon: React.FC<IdenticonProps> = ({
|
|
89
|
+
value = "0x0000000000000000000000000000000000000000",
|
|
90
|
+
size = 64,
|
|
91
|
+
className = "",
|
|
92
|
+
}) => {
|
|
93
|
+
if (!value || typeof value !== "string") {
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
className={`inline-block ${className}`}
|
|
97
|
+
style={{
|
|
98
|
+
width: size,
|
|
99
|
+
height: size,
|
|
100
|
+
backgroundColor: "#cccccc",
|
|
101
|
+
borderRadius: "50%",
|
|
102
|
+
}}
|
|
103
|
+
/>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const { backgroundColor, spotColor, pattern } = generateMetaMaskPattern(value)
|
|
108
|
+
|
|
109
|
+
const gridSize = 8
|
|
110
|
+
const cellSize = size / gridSize
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div
|
|
114
|
+
className={`inline-block ${className}`}
|
|
115
|
+
style={{
|
|
116
|
+
width: size,
|
|
117
|
+
height: size,
|
|
118
|
+
borderRadius: "50%",
|
|
119
|
+
overflow: "hidden",
|
|
120
|
+
backgroundColor: backgroundColor,
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<svg
|
|
124
|
+
width={size}
|
|
125
|
+
height={size}
|
|
126
|
+
style={{ display: "block" }}
|
|
127
|
+
aria-label={`Identicon for ${value}`}
|
|
128
|
+
>
|
|
129
|
+
<title>Identicon for {value}</title>
|
|
130
|
+
{/* Background circle */}
|
|
131
|
+
<circle
|
|
132
|
+
cx={size / 2}
|
|
133
|
+
cy={size / 2}
|
|
134
|
+
r={size / 2}
|
|
135
|
+
fill={backgroundColor}
|
|
136
|
+
/>
|
|
137
|
+
|
|
138
|
+
{/* Pattern cells */}
|
|
139
|
+
{pattern.map((row, y) =>
|
|
140
|
+
row.map((shouldFill, x) =>
|
|
141
|
+
shouldFill ? (
|
|
142
|
+
<rect
|
|
143
|
+
key={`cell-${y}-${x}-${value.slice(-8)}`}
|
|
144
|
+
x={x * cellSize}
|
|
145
|
+
y={y * cellSize}
|
|
146
|
+
width={cellSize}
|
|
147
|
+
height={cellSize}
|
|
148
|
+
fill={spotColor}
|
|
149
|
+
/>
|
|
150
|
+
) : null,
|
|
151
|
+
),
|
|
152
|
+
)}
|
|
153
|
+
</svg>
|
|
154
|
+
</div>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export default Identicon
|
|
@@ -11,16 +11,26 @@ import BinanceLogo from "../assets/Binance_Icon_Logo.svg"
|
|
|
11
11
|
import CoinbaseLogo from "../assets/Coinbase_Icon_Logo.svg"
|
|
12
12
|
import { ScreenHeader } from "./ScreenHeader.js"
|
|
13
13
|
import { logger } from "../../logger.js"
|
|
14
|
+
import { useSelectedMeshExchange } from "../hooks/useSelectedMeshExchange.js"
|
|
15
|
+
import { useMode } from "../hooks/useMode.js"
|
|
16
|
+
import { useCurrentScreen } from "../hooks/useCurrentScreen.js"
|
|
17
|
+
import type { Mode } from "../../mode.js"
|
|
18
|
+
import type { Screen } from "../hooks/useCurrentScreen.js"
|
|
14
19
|
|
|
15
20
|
export interface MeshConnectExchangesProps {
|
|
16
|
-
onBack
|
|
17
|
-
onSelectExchange
|
|
21
|
+
onBack?: () => void
|
|
22
|
+
onSelectExchange?: (integrationId: string, exchangeName: string) => void
|
|
23
|
+
getInitialScreenForMode?: (mode: Mode) => Screen
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
export const MeshConnectExchanges: React.FC<MeshConnectExchangesProps> = ({
|
|
21
27
|
onBack,
|
|
22
28
|
onSelectExchange,
|
|
29
|
+
getInitialScreenForMode,
|
|
23
30
|
}) => {
|
|
31
|
+
const { setSelectedExchange } = useSelectedMeshExchange()
|
|
32
|
+
const { mode } = useMode()
|
|
33
|
+
const { setCurrentScreen } = useCurrentScreen()
|
|
24
34
|
const [coinbaseId, setCoinbaseId] = useState<string | null>(null)
|
|
25
35
|
const [binanceId, setBinanceId] = useState<string | null>(null)
|
|
26
36
|
const [bitfinexId, setBitfinexId] = useState<string | null>(null)
|
|
@@ -73,7 +83,26 @@ export const MeshConnectExchanges: React.FC<MeshConnectExchangesProps> = ({
|
|
|
73
83
|
logger.console.log(
|
|
74
84
|
`[trails-sdk] Selected exchange: ${exchangeName} (${integrationId})`,
|
|
75
85
|
)
|
|
76
|
-
|
|
86
|
+
|
|
87
|
+
// If a callback is provided (MeshConnectFlow), use it
|
|
88
|
+
if (onSelectExchange) {
|
|
89
|
+
onSelectExchange(integrationId, exchangeName)
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Otherwise, use the hook-based approach (main widget flow)
|
|
94
|
+
// Store the selected exchange
|
|
95
|
+
setSelectedExchange({ integrationId, exchangeName })
|
|
96
|
+
|
|
97
|
+
// Navigate to the initial screen for the current mode
|
|
98
|
+
if (getInitialScreenForMode) {
|
|
99
|
+
const currentMode = (mode || "pay") as Mode
|
|
100
|
+
const initialScreen = getInitialScreenForMode(currentMode)
|
|
101
|
+
logger.console.log(
|
|
102
|
+
`[trails-sdk] Navigating to initial screen for mode ${currentMode}: ${initialScreen}`,
|
|
103
|
+
)
|
|
104
|
+
setCurrentScreen(initialScreen)
|
|
105
|
+
}
|
|
77
106
|
}
|
|
78
107
|
|
|
79
108
|
if (loading) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type React from "react"
|
|
2
|
-
import { useState } from "react"
|
|
2
|
+
import { useState, useEffect } from "react"
|
|
3
3
|
import { MeshConnectExchanges } from "./MeshConnectExchanges.js"
|
|
4
4
|
import { MeshConnectIframe } from "./MeshConnectIframe.js"
|
|
5
|
+
import type { SelectedMeshExchange } from "../hooks/useSelectedMeshExchange.js"
|
|
5
6
|
|
|
6
7
|
export interface MeshConnectFlowProps {
|
|
7
8
|
onBack?: () => void
|
|
@@ -10,6 +11,7 @@ export interface MeshConnectFlowProps {
|
|
|
10
11
|
toTokenAmount?: string
|
|
11
12
|
toChainId?: number
|
|
12
13
|
toRecipientAddress?: string
|
|
14
|
+
selectedExchange?: SelectedMeshExchange | null
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
type Screen = "exchanges" | "connect"
|
|
@@ -21,10 +23,27 @@ export const MeshConnectFlow: React.FC<MeshConnectFlowProps> = ({
|
|
|
21
23
|
toTokenAmount,
|
|
22
24
|
toChainId,
|
|
23
25
|
toRecipientAddress,
|
|
26
|
+
selectedExchange,
|
|
24
27
|
}) => {
|
|
25
|
-
|
|
26
|
-
const [
|
|
27
|
-
|
|
28
|
+
// If an exchange is already selected, start on the connect screen
|
|
29
|
+
const [currentScreen, setCurrentScreen] = useState<Screen>(
|
|
30
|
+
selectedExchange ? "connect" : "exchanges",
|
|
31
|
+
)
|
|
32
|
+
const [selectedIntegrationId, setSelectedIntegrationId] = useState<string>(
|
|
33
|
+
selectedExchange?.integrationId || "",
|
|
34
|
+
)
|
|
35
|
+
const [selectedExchangeName, setSelectedExchangeName] = useState<string>(
|
|
36
|
+
selectedExchange?.exchangeName || "",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
// Update state when selectedExchange prop changes
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (selectedExchange) {
|
|
42
|
+
setSelectedIntegrationId(selectedExchange.integrationId)
|
|
43
|
+
setSelectedExchangeName(selectedExchange.exchangeName)
|
|
44
|
+
setCurrentScreen("connect")
|
|
45
|
+
}
|
|
46
|
+
}, [selectedExchange])
|
|
28
47
|
|
|
29
48
|
const handleSelectExchange = (
|
|
30
49
|
integrationId: string,
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import { getChainInfo } from "../../chains.js"
|
|
3
|
+
import { TokenImage } from "./TokenImage.js"
|
|
4
|
+
import { getTokenImageUrl } from "../../tokens.js"
|
|
5
|
+
import { zeroAddress } from "viem"
|
|
6
|
+
|
|
7
|
+
interface NativeGasOptionProps {
|
|
8
|
+
isSelected: boolean
|
|
9
|
+
gasCostUsdDisplay?: string
|
|
10
|
+
gasCostNativeDisplay?: string
|
|
11
|
+
onClick: () => void
|
|
12
|
+
chainId?: number
|
|
13
|
+
notEnoughBalance?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const NativeGasOption: React.FC<NativeGasOptionProps> = ({
|
|
17
|
+
isSelected,
|
|
18
|
+
gasCostUsdDisplay,
|
|
19
|
+
gasCostNativeDisplay,
|
|
20
|
+
onClick,
|
|
21
|
+
chainId,
|
|
22
|
+
notEnoughBalance = false,
|
|
23
|
+
}) => {
|
|
24
|
+
// Helper function to get native symbol for a chain
|
|
25
|
+
const getNativeSymbol = (chainId?: number) => {
|
|
26
|
+
if (!chainId) return "ETH"
|
|
27
|
+
const chainInfo = getChainInfo(chainId)
|
|
28
|
+
return chainInfo?.nativeCurrency.symbol || "ETH"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const nativeSymbol = getNativeSymbol(chainId)
|
|
32
|
+
const nativeImageUrl = getTokenImageUrl({
|
|
33
|
+
chainId,
|
|
34
|
+
contractAddress: zeroAddress,
|
|
35
|
+
symbol: nativeSymbol,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
className={`w-full flex items-center justify-between p-1.5 trails-border-radius-input border transition-colors ${
|
|
42
|
+
notEnoughBalance
|
|
43
|
+
? "cursor-not-allowed opacity-50 bg-gray-100 dark:bg-gray-800 border-gray-300 dark:border-gray-600"
|
|
44
|
+
: isSelected
|
|
45
|
+
? "cursor-pointer trails-bg-primary/10 border-blue-500 bg-blue-50 dark:bg-blue-900/20"
|
|
46
|
+
: "cursor-pointer trails-bg-card trails-border-primary hover:trails-hover-bg"
|
|
47
|
+
}`}
|
|
48
|
+
onClick={notEnoughBalance ? undefined : onClick}
|
|
49
|
+
disabled={notEnoughBalance}
|
|
50
|
+
>
|
|
51
|
+
<div className="flex items-center space-x-2">
|
|
52
|
+
<TokenImage
|
|
53
|
+
imageUrl={nativeImageUrl}
|
|
54
|
+
symbol={nativeSymbol}
|
|
55
|
+
chainId={chainId}
|
|
56
|
+
size={16}
|
|
57
|
+
/>
|
|
58
|
+
<div className="text-left">
|
|
59
|
+
<div
|
|
60
|
+
className={`text-xs font-medium ${
|
|
61
|
+
notEnoughBalance
|
|
62
|
+
? "text-gray-400 dark:text-gray-500"
|
|
63
|
+
: "trails-text-primary"
|
|
64
|
+
}`}
|
|
65
|
+
>
|
|
66
|
+
{nativeSymbol}
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<div className="text-right">
|
|
72
|
+
{gasCostNativeDisplay && (
|
|
73
|
+
<div
|
|
74
|
+
className={`text-xs font-medium ${
|
|
75
|
+
notEnoughBalance
|
|
76
|
+
? "text-gray-400 dark:text-gray-500"
|
|
77
|
+
: "trails-text-primary"
|
|
78
|
+
}`}
|
|
79
|
+
>
|
|
80
|
+
{gasCostNativeDisplay}
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
{gasCostUsdDisplay && (
|
|
84
|
+
<div
|
|
85
|
+
className={`text-xs ${
|
|
86
|
+
notEnoughBalance
|
|
87
|
+
? "text-gray-400 dark:text-gray-500"
|
|
88
|
+
: "trails-text-muted"
|
|
89
|
+
}`}
|
|
90
|
+
>
|
|
91
|
+
{gasCostUsdDisplay}
|
|
92
|
+
</div>
|
|
93
|
+
)}
|
|
94
|
+
</div>
|
|
95
|
+
</button>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export default NativeGasOption
|