@one_deploy/sdk 1.0.0
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/.turbo/turbo-build.log +0 -0
- package/.turbo/turbo-type-check.log +0 -0
- package/dist/config/index.d.mts +74 -0
- package/dist/config/index.d.ts +74 -0
- package/dist/config/index.js +242 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/index.mjs +224 -0
- package/dist/config/index.mjs.map +1 -0
- package/dist/engine-5ndtBaCr.d.ts +1039 -0
- package/dist/engine-CrlhH0nw.d.mts +1039 -0
- package/dist/hooks/index.d.mts +56 -0
- package/dist/hooks/index.d.ts +56 -0
- package/dist/hooks/index.js +1360 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +1356 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +356 -0
- package/dist/index.d.ts +356 -0
- package/dist/index.js +5068 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4949 -0
- package/dist/index.mjs.map +1 -0
- package/dist/price-CgqXPnT3.d.ts +13 -0
- package/dist/price-ClbLHHjv.d.mts +13 -0
- package/dist/providers/index.d.mts +121 -0
- package/dist/providers/index.d.ts +121 -0
- package/dist/providers/index.js +1642 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/index.mjs +1600 -0
- package/dist/providers/index.mjs.map +1 -0
- package/dist/react-native.d.mts +120 -0
- package/dist/react-native.d.ts +120 -0
- package/dist/react-native.js +1792 -0
- package/dist/react-native.js.map +1 -0
- package/dist/react-native.mjs +1755 -0
- package/dist/react-native.mjs.map +1 -0
- package/dist/services/index.d.mts +85 -0
- package/dist/services/index.d.ts +85 -0
- package/dist/services/index.js +1466 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/index.mjs +1458 -0
- package/dist/services/index.mjs.map +1 -0
- package/dist/types/index.d.mts +759 -0
- package/dist/types/index.d.ts +759 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +3 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/utils/index.d.mts +36 -0
- package/dist/utils/index.d.ts +36 -0
- package/dist/utils/index.js +164 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +142 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +101 -0
- package/src/components/OneConnectButton.tsx +143 -0
- package/src/components/OneNFTGallery.tsx +324 -0
- package/src/components/OneOfframpWidget.tsx +660 -0
- package/src/components/OneOnrampWidget.tsx +596 -0
- package/src/components/OnePayWidget.tsx +160 -0
- package/src/components/OneReceiveWidget.tsx +272 -0
- package/src/components/OneSendWidget.tsx +248 -0
- package/src/components/OneSwapWidget.tsx +715 -0
- package/src/components/OneTransactionButton.tsx +150 -0
- package/src/components/OneWalletBalance.tsx +354 -0
- package/src/components/index.ts +24 -0
- package/src/config/index.ts +299 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useTokenPrice.ts +162 -0
- package/src/hooks/useWalletBalance.ts +98 -0
- package/src/index.ts +193 -0
- package/src/providers/OneProvider.tsx +452 -0
- package/src/providers/ThirdwebProvider.tsx +203 -0
- package/src/providers/index.ts +26 -0
- package/src/react-native.ts +378 -0
- package/src/services/engine.ts +1854 -0
- package/src/services/index.ts +30 -0
- package/src/services/price.ts +164 -0
- package/src/services/supabase.ts +180 -0
- package/src/types/index.ts +887 -0
- package/src/utils/index.ts +200 -0
- package/tsconfig.json +22 -0
- package/tsup.config.ts +25 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { TransactionButton, type TransactionButtonProps } from 'thirdweb/react';
|
|
5
|
+
import { prepareTransaction, type PreparedTransaction } from 'thirdweb';
|
|
6
|
+
import type { Chain } from 'thirdweb/chains';
|
|
7
|
+
import { useThirdwebClient } from '../providers/ThirdwebProvider';
|
|
8
|
+
|
|
9
|
+
// ===== Types =====
|
|
10
|
+
|
|
11
|
+
export interface OneTransactionButtonProps {
|
|
12
|
+
// Transaction config
|
|
13
|
+
to: string;
|
|
14
|
+
value?: bigint;
|
|
15
|
+
data?: `0x${string}`;
|
|
16
|
+
chain: Chain;
|
|
17
|
+
|
|
18
|
+
// Or use prepared transaction directly
|
|
19
|
+
transaction?: PreparedTransaction;
|
|
20
|
+
|
|
21
|
+
// Appearance
|
|
22
|
+
label?: string;
|
|
23
|
+
loadingLabel?: string;
|
|
24
|
+
theme?: 'light' | 'dark';
|
|
25
|
+
className?: string;
|
|
26
|
+
style?: React.CSSProperties;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
|
|
29
|
+
// Callbacks
|
|
30
|
+
onSuccess?: (result: { transactionHash: string }) => void;
|
|
31
|
+
onError?: (error: Error) => void;
|
|
32
|
+
onSubmitted?: (txHash: string) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ===== ONE Theme Styles =====
|
|
36
|
+
|
|
37
|
+
const ONE_BUTTON_STYLE: React.CSSProperties = {
|
|
38
|
+
backgroundColor: '#10b981',
|
|
39
|
+
color: '#ffffff',
|
|
40
|
+
fontFamily: 'Inter, system-ui, sans-serif',
|
|
41
|
+
fontWeight: 600,
|
|
42
|
+
borderRadius: '12px',
|
|
43
|
+
padding: '12px 24px',
|
|
44
|
+
border: 'none',
|
|
45
|
+
cursor: 'pointer',
|
|
46
|
+
transition: 'background-color 0.2s',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const ONE_BUTTON_DISABLED_STYLE: React.CSSProperties = {
|
|
50
|
+
...ONE_BUTTON_STYLE,
|
|
51
|
+
backgroundColor: '#6b7280',
|
|
52
|
+
cursor: 'not-allowed',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// ===== Component =====
|
|
56
|
+
|
|
57
|
+
export function OneTransactionButton({
|
|
58
|
+
to,
|
|
59
|
+
value,
|
|
60
|
+
data,
|
|
61
|
+
chain,
|
|
62
|
+
transaction: preparedTx,
|
|
63
|
+
label = 'Send Transaction',
|
|
64
|
+
loadingLabel = 'Processing...',
|
|
65
|
+
theme = 'dark',
|
|
66
|
+
className,
|
|
67
|
+
style,
|
|
68
|
+
disabled = false,
|
|
69
|
+
onSuccess,
|
|
70
|
+
onError,
|
|
71
|
+
onSubmitted,
|
|
72
|
+
}: OneTransactionButtonProps) {
|
|
73
|
+
const client = useThirdwebClient();
|
|
74
|
+
|
|
75
|
+
// Prepare transaction if not already provided
|
|
76
|
+
const transaction = preparedTx || prepareTransaction({
|
|
77
|
+
to,
|
|
78
|
+
value,
|
|
79
|
+
data,
|
|
80
|
+
chain,
|
|
81
|
+
client,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const buttonStyle = disabled
|
|
85
|
+
? { ...ONE_BUTTON_DISABLED_STYLE, ...style }
|
|
86
|
+
: { ...ONE_BUTTON_STYLE, ...style };
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<TransactionButton
|
|
90
|
+
transaction={() => transaction}
|
|
91
|
+
onTransactionSent={(result) => onSubmitted?.(result.transactionHash)}
|
|
92
|
+
onTransactionConfirmed={(result) => onSuccess?.({ transactionHash: result.transactionHash })}
|
|
93
|
+
onError={onError}
|
|
94
|
+
disabled={disabled}
|
|
95
|
+
style={buttonStyle}
|
|
96
|
+
className={className}
|
|
97
|
+
theme={theme}
|
|
98
|
+
>
|
|
99
|
+
{label}
|
|
100
|
+
</TransactionButton>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ===== Presets =====
|
|
105
|
+
|
|
106
|
+
export interface OneSendETHButtonProps extends Omit<OneTransactionButtonProps, 'data'> {
|
|
107
|
+
amount: string; // in ETH
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function OneSendETHButton({
|
|
111
|
+
amount,
|
|
112
|
+
...props
|
|
113
|
+
}: OneSendETHButtonProps) {
|
|
114
|
+
const valueInWei = BigInt(Math.floor(parseFloat(amount) * 1e18));
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<OneTransactionButton
|
|
118
|
+
{...props}
|
|
119
|
+
value={valueInWei}
|
|
120
|
+
label={props.label || `Send ${amount} ETH`}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface OneApproveButtonProps extends Omit<OneTransactionButtonProps, 'to' | 'data' | 'value'> {
|
|
126
|
+
tokenAddress: string;
|
|
127
|
+
spenderAddress: string;
|
|
128
|
+
amount?: bigint; // Max uint256 by default
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function OneApproveButton({
|
|
132
|
+
tokenAddress,
|
|
133
|
+
spenderAddress,
|
|
134
|
+
amount = BigInt('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'),
|
|
135
|
+
chain,
|
|
136
|
+
...props
|
|
137
|
+
}: OneApproveButtonProps) {
|
|
138
|
+
// ERC20 approve function selector + encoded params
|
|
139
|
+
const approveData = `0x095ea7b3${spenderAddress.slice(2).padStart(64, '0')}${amount.toString(16).padStart(64, '0')}` as `0x${string}`;
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<OneTransactionButton
|
|
143
|
+
{...props}
|
|
144
|
+
to={tokenAddress}
|
|
145
|
+
data={approveData}
|
|
146
|
+
chain={chain}
|
|
147
|
+
label={props.label || 'Approve Token'}
|
|
148
|
+
/>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
4
|
+
import { useActiveAccount, useWalletBalance as useThirdwebBalance } from 'thirdweb/react';
|
|
5
|
+
import type { Chain } from 'thirdweb/chains';
|
|
6
|
+
import { base, ethereum, polygon, arbitrum, optimism } from 'thirdweb/chains';
|
|
7
|
+
import { useThirdwebClient } from '../providers/ThirdwebProvider';
|
|
8
|
+
|
|
9
|
+
// ===== Types =====
|
|
10
|
+
|
|
11
|
+
export interface TokenBalance {
|
|
12
|
+
symbol: string;
|
|
13
|
+
name: string;
|
|
14
|
+
balance: string;
|
|
15
|
+
balanceFormatted: string;
|
|
16
|
+
balanceUsd: number;
|
|
17
|
+
price: number;
|
|
18
|
+
priceChange24h: number;
|
|
19
|
+
chainId: number;
|
|
20
|
+
chain: string;
|
|
21
|
+
contractAddress?: string;
|
|
22
|
+
logoURI?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface OneWalletBalanceProps {
|
|
26
|
+
// Display options
|
|
27
|
+
showTotalBalance?: boolean;
|
|
28
|
+
showTokenList?: boolean;
|
|
29
|
+
showChainFilter?: boolean;
|
|
30
|
+
showPriceChange?: boolean;
|
|
31
|
+
|
|
32
|
+
// Chains to show
|
|
33
|
+
chains?: Chain[];
|
|
34
|
+
|
|
35
|
+
// API endpoint for fetching balances
|
|
36
|
+
balanceEndpoint?: string;
|
|
37
|
+
|
|
38
|
+
// Appearance
|
|
39
|
+
theme?: 'light' | 'dark';
|
|
40
|
+
className?: string;
|
|
41
|
+
style?: React.CSSProperties;
|
|
42
|
+
compact?: boolean;
|
|
43
|
+
|
|
44
|
+
// Callbacks
|
|
45
|
+
onTokenClick?: (token: TokenBalance) => void;
|
|
46
|
+
onRefresh?: () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ===== Styles =====
|
|
50
|
+
|
|
51
|
+
const containerStyle: React.CSSProperties = {
|
|
52
|
+
display: 'flex',
|
|
53
|
+
flexDirection: 'column',
|
|
54
|
+
gap: '16px',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const balanceCardStyle: React.CSSProperties = {
|
|
58
|
+
padding: '24px',
|
|
59
|
+
backgroundColor: '#1f2937',
|
|
60
|
+
borderRadius: '16px',
|
|
61
|
+
border: '1px solid #374151',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const tokenRowStyle: React.CSSProperties = {
|
|
65
|
+
display: 'flex',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
justifyContent: 'space-between',
|
|
68
|
+
padding: '12px 16px',
|
|
69
|
+
borderRadius: '12px',
|
|
70
|
+
cursor: 'pointer',
|
|
71
|
+
transition: 'background-color 0.2s',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// ===== Utilities =====
|
|
75
|
+
|
|
76
|
+
const formatUSD = (value: number): string => {
|
|
77
|
+
return new Intl.NumberFormat('en-US', {
|
|
78
|
+
style: 'currency',
|
|
79
|
+
currency: 'USD',
|
|
80
|
+
minimumFractionDigits: 2,
|
|
81
|
+
maximumFractionDigits: 2,
|
|
82
|
+
}).format(value);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const formatBalance = (value: string, decimals: number = 4): string => {
|
|
86
|
+
const num = parseFloat(value);
|
|
87
|
+
if (num === 0) return '0';
|
|
88
|
+
if (num < 0.0001) return '<0.0001';
|
|
89
|
+
return num.toFixed(decimals);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const CHAIN_INFO: Record<number, { name: string; icon: string }> = {
|
|
93
|
+
1: { name: 'Ethereum', icon: '⟠' },
|
|
94
|
+
8453: { name: 'Base', icon: '🔵' },
|
|
95
|
+
137: { name: 'Polygon', icon: '🟣' },
|
|
96
|
+
42161: { name: 'Arbitrum', icon: '🔷' },
|
|
97
|
+
10: { name: 'Optimism', icon: '🔴' },
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// ===== Component =====
|
|
101
|
+
|
|
102
|
+
export function OneWalletBalance({
|
|
103
|
+
showTotalBalance = true,
|
|
104
|
+
showTokenList = true,
|
|
105
|
+
showChainFilter = true,
|
|
106
|
+
showPriceChange = true,
|
|
107
|
+
chains = [base, ethereum, polygon, arbitrum, optimism],
|
|
108
|
+
balanceEndpoint = '/api/v1/assets',
|
|
109
|
+
theme = 'dark',
|
|
110
|
+
className,
|
|
111
|
+
style,
|
|
112
|
+
compact = false,
|
|
113
|
+
onTokenClick,
|
|
114
|
+
onRefresh,
|
|
115
|
+
}: OneWalletBalanceProps) {
|
|
116
|
+
const client = useThirdwebClient();
|
|
117
|
+
const account = useActiveAccount();
|
|
118
|
+
|
|
119
|
+
const [tokens, setTokens] = useState<TokenBalance[]>([]);
|
|
120
|
+
const [totalBalance, setTotalBalance] = useState(0);
|
|
121
|
+
const [totalChange24h, setTotalChange24h] = useState(0);
|
|
122
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
123
|
+
const [selectedChain, setSelectedChain] = useState<number | null>(null);
|
|
124
|
+
const [error, setError] = useState<string | null>(null);
|
|
125
|
+
|
|
126
|
+
// Fetch balances from ONE Engine
|
|
127
|
+
const fetchBalances = useCallback(async () => {
|
|
128
|
+
if (!account?.address) return;
|
|
129
|
+
|
|
130
|
+
setIsLoading(true);
|
|
131
|
+
setError(null);
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
const chainIds = chains.map(c => c.id).join(',');
|
|
135
|
+
const response = await fetch(`${balanceEndpoint}?address=${account.address}&chains=${chainIds}`);
|
|
136
|
+
const data = await response.json();
|
|
137
|
+
|
|
138
|
+
if (data.success && data.data) {
|
|
139
|
+
const balanceData = data.data;
|
|
140
|
+
setTokens(balanceData.tokens || []);
|
|
141
|
+
setTotalBalance(balanceData.totalUsd || 0);
|
|
142
|
+
setTotalChange24h(balanceData.change24hPercent || 0);
|
|
143
|
+
} else {
|
|
144
|
+
setError(data.error?.message || 'Failed to fetch balances');
|
|
145
|
+
}
|
|
146
|
+
} catch (err) {
|
|
147
|
+
setError('Failed to load balances');
|
|
148
|
+
} finally {
|
|
149
|
+
setIsLoading(false);
|
|
150
|
+
}
|
|
151
|
+
}, [account?.address, balanceEndpoint, chains]);
|
|
152
|
+
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
fetchBalances();
|
|
155
|
+
}, [fetchBalances]);
|
|
156
|
+
|
|
157
|
+
const handleRefresh = () => {
|
|
158
|
+
fetchBalances();
|
|
159
|
+
onRefresh?.();
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const filteredTokens = selectedChain
|
|
163
|
+
? tokens.filter(t => t.chainId === selectedChain)
|
|
164
|
+
: tokens;
|
|
165
|
+
|
|
166
|
+
const isDark = theme === 'dark';
|
|
167
|
+
|
|
168
|
+
if (!account) {
|
|
169
|
+
return (
|
|
170
|
+
<div className={className} style={{ ...style, textAlign: 'center', padding: '24px', color: isDark ? '#9ca3af' : '#6b7280' }}>
|
|
171
|
+
Connect your wallet to view balances
|
|
172
|
+
</div>
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div className={className} style={{ ...containerStyle, ...style }}>
|
|
178
|
+
{/* Total Balance Card */}
|
|
179
|
+
{showTotalBalance && (
|
|
180
|
+
<div style={{ ...balanceCardStyle, backgroundColor: isDark ? '#1f2937' : '#ffffff', border: `1px solid ${isDark ? '#374151' : '#e5e7eb'}` }}>
|
|
181
|
+
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
|
|
182
|
+
<div>
|
|
183
|
+
<p style={{ margin: '0 0 4px 0', color: isDark ? '#9ca3af' : '#6b7280', fontSize: '14px' }}>Total Balance</p>
|
|
184
|
+
{isLoading ? (
|
|
185
|
+
<div style={{ height: '36px', width: '120px', backgroundColor: isDark ? '#374151' : '#e5e7eb', borderRadius: '8px', animation: 'pulse 2s infinite' }} />
|
|
186
|
+
) : (
|
|
187
|
+
<h2 style={{ margin: 0, color: isDark ? '#ffffff' : '#111827', fontSize: compact ? '24px' : '32px', fontWeight: 700 }}>
|
|
188
|
+
{formatUSD(totalBalance)}
|
|
189
|
+
</h2>
|
|
190
|
+
)}
|
|
191
|
+
{showPriceChange && !isLoading && (
|
|
192
|
+
<p style={{ margin: '4px 0 0 0', fontSize: '14px', color: totalChange24h >= 0 ? '#10b981' : '#ef4444' }}>
|
|
193
|
+
{totalChange24h >= 0 ? '+' : ''}{totalChange24h.toFixed(2)}% (24h)
|
|
194
|
+
</p>
|
|
195
|
+
)}
|
|
196
|
+
</div>
|
|
197
|
+
<button
|
|
198
|
+
onClick={handleRefresh}
|
|
199
|
+
disabled={isLoading}
|
|
200
|
+
style={{
|
|
201
|
+
padding: '8px 12px',
|
|
202
|
+
backgroundColor: isDark ? '#374151' : '#e5e7eb',
|
|
203
|
+
border: 'none',
|
|
204
|
+
borderRadius: '8px',
|
|
205
|
+
color: isDark ? '#ffffff' : '#111827',
|
|
206
|
+
cursor: isLoading ? 'not-allowed' : 'pointer',
|
|
207
|
+
fontSize: '14px',
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
{isLoading ? '...' : '↻'}
|
|
211
|
+
</button>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
)}
|
|
215
|
+
|
|
216
|
+
{/* Chain Filter */}
|
|
217
|
+
{showChainFilter && chains.length > 1 && (
|
|
218
|
+
<div style={{ display: 'flex', gap: '8px', flexWrap: 'wrap' }}>
|
|
219
|
+
<button
|
|
220
|
+
onClick={() => setSelectedChain(null)}
|
|
221
|
+
style={{
|
|
222
|
+
padding: '8px 16px',
|
|
223
|
+
backgroundColor: selectedChain === null ? '#10b981' : (isDark ? '#374151' : '#e5e7eb'),
|
|
224
|
+
border: 'none',
|
|
225
|
+
borderRadius: '20px',
|
|
226
|
+
color: selectedChain === null ? '#ffffff' : (isDark ? '#9ca3af' : '#6b7280'),
|
|
227
|
+
cursor: 'pointer',
|
|
228
|
+
fontSize: '14px',
|
|
229
|
+
}}
|
|
230
|
+
>
|
|
231
|
+
All
|
|
232
|
+
</button>
|
|
233
|
+
{chains.map(chain => (
|
|
234
|
+
<button
|
|
235
|
+
key={chain.id}
|
|
236
|
+
onClick={() => setSelectedChain(chain.id)}
|
|
237
|
+
style={{
|
|
238
|
+
padding: '8px 16px',
|
|
239
|
+
backgroundColor: selectedChain === chain.id ? '#10b981' : (isDark ? '#374151' : '#e5e7eb'),
|
|
240
|
+
border: 'none',
|
|
241
|
+
borderRadius: '20px',
|
|
242
|
+
color: selectedChain === chain.id ? '#ffffff' : (isDark ? '#9ca3af' : '#6b7280'),
|
|
243
|
+
cursor: 'pointer',
|
|
244
|
+
fontSize: '14px',
|
|
245
|
+
}}
|
|
246
|
+
>
|
|
247
|
+
{CHAIN_INFO[chain.id]?.icon} {CHAIN_INFO[chain.id]?.name || `Chain ${chain.id}`}
|
|
248
|
+
</button>
|
|
249
|
+
))}
|
|
250
|
+
</div>
|
|
251
|
+
)}
|
|
252
|
+
|
|
253
|
+
{/* Token List */}
|
|
254
|
+
{showTokenList && (
|
|
255
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: '4px' }}>
|
|
256
|
+
{isLoading ? (
|
|
257
|
+
Array(3).fill(0).map((_, i) => (
|
|
258
|
+
<div key={i} style={{ ...tokenRowStyle, backgroundColor: isDark ? '#374151' : '#f3f4f6', height: '60px', animation: 'pulse 2s infinite' }} />
|
|
259
|
+
))
|
|
260
|
+
) : error ? (
|
|
261
|
+
<div style={{ textAlign: 'center', padding: '24px', color: '#ef4444' }}>{error}</div>
|
|
262
|
+
) : filteredTokens.length === 0 ? (
|
|
263
|
+
<div style={{ textAlign: 'center', padding: '24px', color: isDark ? '#9ca3af' : '#6b7280' }}>No tokens found</div>
|
|
264
|
+
) : (
|
|
265
|
+
filteredTokens.map((token, index) => (
|
|
266
|
+
<div
|
|
267
|
+
key={`${token.chainId}-${token.symbol}-${index}`}
|
|
268
|
+
style={{
|
|
269
|
+
...tokenRowStyle,
|
|
270
|
+
backgroundColor: 'transparent',
|
|
271
|
+
}}
|
|
272
|
+
onClick={() => onTokenClick?.(token)}
|
|
273
|
+
onMouseEnter={(e) => {
|
|
274
|
+
e.currentTarget.style.backgroundColor = isDark ? '#374151' : '#f3f4f6';
|
|
275
|
+
}}
|
|
276
|
+
onMouseLeave={(e) => {
|
|
277
|
+
e.currentTarget.style.backgroundColor = 'transparent';
|
|
278
|
+
}}
|
|
279
|
+
>
|
|
280
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
|
|
281
|
+
<div style={{
|
|
282
|
+
width: '40px',
|
|
283
|
+
height: '40px',
|
|
284
|
+
borderRadius: '50%',
|
|
285
|
+
backgroundColor: isDark ? '#374151' : '#e5e7eb',
|
|
286
|
+
display: 'flex',
|
|
287
|
+
alignItems: 'center',
|
|
288
|
+
justifyContent: 'center',
|
|
289
|
+
fontSize: '16px',
|
|
290
|
+
fontWeight: 600,
|
|
291
|
+
color: isDark ? '#ffffff' : '#111827',
|
|
292
|
+
}}>
|
|
293
|
+
{token.logoURI ? (
|
|
294
|
+
<img src={token.logoURI} alt={token.symbol} style={{ width: '100%', height: '100%', borderRadius: '50%' }} />
|
|
295
|
+
) : (
|
|
296
|
+
token.symbol.slice(0, 2)
|
|
297
|
+
)}
|
|
298
|
+
</div>
|
|
299
|
+
<div>
|
|
300
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
|
301
|
+
<span style={{ color: isDark ? '#ffffff' : '#111827', fontWeight: 600 }}>{token.symbol}</span>
|
|
302
|
+
<span style={{
|
|
303
|
+
fontSize: '10px',
|
|
304
|
+
padding: '2px 6px',
|
|
305
|
+
backgroundColor: isDark ? '#374151' : '#e5e7eb',
|
|
306
|
+
borderRadius: '4px',
|
|
307
|
+
color: isDark ? '#9ca3af' : '#6b7280',
|
|
308
|
+
}}>
|
|
309
|
+
{CHAIN_INFO[token.chainId]?.name || token.chain}
|
|
310
|
+
</span>
|
|
311
|
+
</div>
|
|
312
|
+
<span style={{ color: isDark ? '#9ca3af' : '#6b7280', fontSize: '14px' }}>
|
|
313
|
+
{formatBalance(token.balanceFormatted)} {token.symbol}
|
|
314
|
+
</span>
|
|
315
|
+
</div>
|
|
316
|
+
</div>
|
|
317
|
+
<div style={{ textAlign: 'right' }}>
|
|
318
|
+
<div style={{ color: isDark ? '#ffffff' : '#111827', fontWeight: 600 }}>
|
|
319
|
+
{formatUSD(token.balanceUsd)}
|
|
320
|
+
</div>
|
|
321
|
+
{showPriceChange && (
|
|
322
|
+
<div style={{ fontSize: '14px', color: token.priceChange24h >= 0 ? '#10b981' : '#ef4444' }}>
|
|
323
|
+
{token.priceChange24h >= 0 ? '+' : ''}{token.priceChange24h.toFixed(2)}%
|
|
324
|
+
</div>
|
|
325
|
+
)}
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
))
|
|
329
|
+
)}
|
|
330
|
+
</div>
|
|
331
|
+
)}
|
|
332
|
+
</div>
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// ===== Compact Balance Display =====
|
|
337
|
+
|
|
338
|
+
export function OneBalanceDisplay({
|
|
339
|
+
theme = 'dark',
|
|
340
|
+
className,
|
|
341
|
+
style,
|
|
342
|
+
}: Pick<OneWalletBalanceProps, 'theme' | 'className' | 'style'>) {
|
|
343
|
+
return (
|
|
344
|
+
<OneWalletBalance
|
|
345
|
+
theme={theme}
|
|
346
|
+
className={className}
|
|
347
|
+
style={style}
|
|
348
|
+
showTotalBalance={true}
|
|
349
|
+
showTokenList={false}
|
|
350
|
+
showChainFilter={false}
|
|
351
|
+
compact={true}
|
|
352
|
+
/>
|
|
353
|
+
);
|
|
354
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// ONE Ecosystem UI Components
|
|
2
|
+
// Wrapped Thirdweb components with ONE branding and configuration
|
|
3
|
+
|
|
4
|
+
// Wallet Connection
|
|
5
|
+
export * from './OneConnectButton';
|
|
6
|
+
|
|
7
|
+
// Payment & Transactions
|
|
8
|
+
export * from './OnePayWidget';
|
|
9
|
+
export * from './OneTransactionButton';
|
|
10
|
+
export * from './OneSendWidget';
|
|
11
|
+
|
|
12
|
+
// Fiat On/Off Ramp
|
|
13
|
+
export * from './OneOnrampWidget';
|
|
14
|
+
export * from './OneOfframpWidget';
|
|
15
|
+
|
|
16
|
+
// Swap
|
|
17
|
+
export * from './OneSwapWidget';
|
|
18
|
+
|
|
19
|
+
// Assets & Balance
|
|
20
|
+
export * from './OneWalletBalance';
|
|
21
|
+
export * from './OneNFTGallery';
|
|
22
|
+
|
|
23
|
+
// Receive
|
|
24
|
+
export * from './OneReceiveWidget';
|