@one_deploy/sdk 1.0.6 → 1.2.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/README.md +339 -0
- package/dist/ForexPoolDataGenerator--__twRwl.d.mts +76 -0
- package/dist/ForexPoolDataGenerator-eUgwsU_B.d.ts +76 -0
- package/dist/OneForexTradeHistory-TlKxjbFF.d.ts +250 -0
- package/dist/OneForexTradeHistory-iDySMcw0.d.mts +250 -0
- package/dist/components/index.d.mts +539 -0
- package/dist/components/index.d.ts +539 -0
- package/dist/components/index.js +7295 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +7243 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/config/index.d.mts +1 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/console-BfTMA7ah.d.mts +504 -0
- package/dist/console-BfTMA7ah.d.ts +504 -0
- package/dist/hooks/index.d.mts +323 -1
- package/dist/hooks/index.d.ts +323 -1
- package/dist/hooks/index.js +3223 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +3204 -1
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +18 -352
- package/dist/index.d.ts +18 -352
- package/dist/index.js +8646 -574
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8449 -432
- package/dist/index.mjs.map +1 -1
- package/dist/providers/index.d.mts +31 -31
- package/dist/providers/index.d.ts +31 -31
- package/dist/providers/index.js +140 -153
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/index.mjs +100 -109
- package/dist/providers/index.mjs.map +1 -1
- package/dist/react-native.d.mts +8 -140
- package/dist/react-native.d.ts +8 -140
- package/dist/react-native.js +2527 -0
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +2497 -2
- package/dist/react-native.mjs.map +1 -1
- package/dist/services/index.d.mts +85 -4
- package/dist/services/index.d.ts +85 -4
- package/dist/services/index.js +1621 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +1619 -1
- package/dist/services/index.mjs.map +1 -1
- package/dist/types/index.d.mts +203 -1
- package/dist/types/index.d.ts +203 -1
- package/dist/types/index.js +275 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs +251 -0
- package/dist/types/index.mjs.map +1 -1
- package/dist/useForexTrading-BleeSor8.d.mts +80 -0
- package/dist/useForexTrading-ZgW_G40Q.d.ts +80 -0
- package/package.json +9 -2
- package/src/components/OneConnectButton.tsx +24 -1
- package/src/components/OneNFTGallery.tsx +13 -7
- package/src/components/OneOfframpWidget.tsx +4 -3
- package/src/components/OnePayWidget.tsx +10 -1
- package/src/components/OneSendWidget.tsx +3 -3
- package/src/components/OneSwapWidget.tsx +4 -4
- package/src/components/OneTransactionButton.tsx +28 -3
- package/src/components/OneWalletBalance.tsx +1 -1
- package/src/components/ai/OneForexCapitalSplit.tsx +112 -0
- package/src/components/ai/OneForexConsoleView.tsx +90 -0
- package/src/components/ai/OneForexPairSelector.tsx +101 -0
- package/src/components/ai/OneForexPoolCard.tsx +105 -0
- package/src/components/ai/OneForexTradeHistory.tsx +107 -0
- package/src/components/ai/console/OneAIQuantConsole.tsx +423 -0
- package/src/components/ai/console/OneAgentCard.tsx +383 -0
- package/src/components/ai/console/OneAgentConsole.tsx +469 -0
- package/src/components/ai/console/OneDecisionTimeline.tsx +433 -0
- package/src/components/ai/console/OneMetricsDashboard.tsx +493 -0
- package/src/components/ai/console/OnePositionCard.tsx +406 -0
- package/src/components/ai/console/OnePositionDetail.tsx +600 -0
- package/src/components/ai/console/OneRiskIndicator.tsx +464 -0
- package/src/components/ai/console/OneTradingConsole.tsx +660 -0
- package/src/components/ai/console/index.ts +17 -0
- package/src/components/ai/index.ts +10 -0
- package/src/hooks/index.ts +46 -0
- package/src/hooks/useAIDecisions.ts +280 -0
- package/src/hooks/useAIPositions.ts +349 -0
- package/src/hooks/useAIQuantConsole.ts +283 -0
- package/src/hooks/useAIRiskStatus.ts +276 -0
- package/src/hooks/useAITrading.ts +190 -0
- package/src/hooks/useBotSimulation.ts +201 -0
- package/src/hooks/useForexTrading.ts +430 -0
- package/src/hooks/useTradingConsole.ts +243 -0
- package/src/index.ts +123 -5
- package/src/providers/OneProvider.tsx +181 -5
- package/src/providers/index.ts +22 -8
- package/src/react-native.ts +41 -0
- package/src/services/forex/BotSimulationEngine.ts +968 -0
- package/src/services/forex/ForexPoolDataGenerator.ts +542 -0
- package/src/services/forex/ForexSimulationEngine.ts +482 -0
- package/src/services/forex/index.ts +21 -0
- package/src/services/index.ts +16 -0
- package/src/types/aiTrading.ts +151 -0
- package/src/types/console.ts +380 -0
- package/src/types/forex.ts +282 -0
- package/src/types/index.ts +106 -0
- package/dist/price-CgqXPnT3.d.ts +0 -13
- package/dist/price-ClbLHHjv.d.mts +0 -13
- package/dist/supabase-BT0c7q9e.d.mts +0 -82
- package/dist/supabase-BT0c7q9e.d.ts +0 -82
package/src/index.ts
CHANGED
|
@@ -36,6 +36,14 @@ export {
|
|
|
36
36
|
// Price (for offline/cache)
|
|
37
37
|
PriceService,
|
|
38
38
|
priceService,
|
|
39
|
+
// Usage Tracking
|
|
40
|
+
UsageService,
|
|
41
|
+
getUsageService,
|
|
42
|
+
createUsageService,
|
|
43
|
+
// Forex Services
|
|
44
|
+
forexSimulationEngine,
|
|
45
|
+
ForexPoolDataGenerator,
|
|
46
|
+
botSimulationEngine,
|
|
39
47
|
} from './services';
|
|
40
48
|
|
|
41
49
|
// Export all Engine types
|
|
@@ -56,11 +64,25 @@ export type {
|
|
|
56
64
|
SwapQuote,
|
|
57
65
|
SwapExecuteRequest,
|
|
58
66
|
SwapResult,
|
|
67
|
+
// Usage
|
|
68
|
+
UsageCategory,
|
|
69
|
+
DisplayCategory,
|
|
70
|
+
UsageRecord,
|
|
71
|
+
UsageSummary,
|
|
72
|
+
UsageActivity,
|
|
73
|
+
UsageResponse,
|
|
74
|
+
// Forex Services
|
|
75
|
+
PairState,
|
|
76
|
+
BotLogType,
|
|
77
|
+
BotLogEntry,
|
|
78
|
+
IndicatorSnapshot,
|
|
79
|
+
BotState,
|
|
80
|
+
StrategyPersonality,
|
|
59
81
|
} from './services';
|
|
60
82
|
|
|
61
83
|
// ===== React Providers & Hooks =====
|
|
62
84
|
export {
|
|
63
|
-
//
|
|
85
|
+
// Unified ONE Provider (with integrated thirdweb wallet support)
|
|
64
86
|
OneProvider,
|
|
65
87
|
useOne,
|
|
66
88
|
useOneAuth,
|
|
@@ -69,10 +91,9 @@ export {
|
|
|
69
91
|
useOneSwap,
|
|
70
92
|
useOneTrading,
|
|
71
93
|
useOneEngine,
|
|
72
|
-
OneContext,
|
|
73
|
-
// Thirdweb Integration Provider
|
|
74
|
-
OneThirdwebProvider,
|
|
75
94
|
useThirdwebClient,
|
|
95
|
+
OneContext,
|
|
96
|
+
// Thirdweb utilities (re-exported for convenience)
|
|
76
97
|
inAppWallet,
|
|
77
98
|
smartWallet,
|
|
78
99
|
base,
|
|
@@ -80,9 +101,18 @@ export {
|
|
|
80
101
|
polygon,
|
|
81
102
|
arbitrum,
|
|
82
103
|
optimism,
|
|
104
|
+
// @deprecated - Use OneProvider instead
|
|
105
|
+
OneThirdwebProvider,
|
|
83
106
|
} from './providers';
|
|
84
107
|
|
|
85
|
-
export type {
|
|
108
|
+
export type {
|
|
109
|
+
ThirdwebAuthOptions,
|
|
110
|
+
ThirdwebWalletConfig,
|
|
111
|
+
Chain,
|
|
112
|
+
ThirdwebClient,
|
|
113
|
+
// @deprecated - Use ThirdwebWalletConfig instead
|
|
114
|
+
OneThirdwebConfig,
|
|
115
|
+
} from './providers';
|
|
86
116
|
|
|
87
117
|
// ===== UI Components (Wrapped Thirdweb) =====
|
|
88
118
|
export {
|
|
@@ -125,6 +155,27 @@ export {
|
|
|
125
155
|
OneNFTGallery,
|
|
126
156
|
// Receive Widget
|
|
127
157
|
OneReceiveWidget,
|
|
158
|
+
// AI Trading Components
|
|
159
|
+
OneChainSelector,
|
|
160
|
+
OneTierSelector,
|
|
161
|
+
OneCycleSelector,
|
|
162
|
+
OnePairSelector,
|
|
163
|
+
// StableFX Forex Components
|
|
164
|
+
OneForexPoolCard,
|
|
165
|
+
OneForexCapitalSplit,
|
|
166
|
+
OneForexConsoleView,
|
|
167
|
+
OneForexPairSelector,
|
|
168
|
+
OneForexTradeHistory,
|
|
169
|
+
// Trading Console Components
|
|
170
|
+
OneTradingConsole,
|
|
171
|
+
OneAIQuantConsole,
|
|
172
|
+
OneAgentConsole,
|
|
173
|
+
OnePositionDetail,
|
|
174
|
+
OneAgentCard,
|
|
175
|
+
OnePositionCard,
|
|
176
|
+
OneRiskIndicator,
|
|
177
|
+
OneMetricsDashboard,
|
|
178
|
+
OneDecisionTimeline,
|
|
128
179
|
} from './components';
|
|
129
180
|
|
|
130
181
|
export type {
|
|
@@ -150,6 +201,27 @@ export type {
|
|
|
150
201
|
OneNFTGalleryProps,
|
|
151
202
|
NFTItem,
|
|
152
203
|
OneReceiveWidgetProps,
|
|
204
|
+
// AI Trading Component Types
|
|
205
|
+
OneChainSelectorProps,
|
|
206
|
+
OneTierSelectorProps,
|
|
207
|
+
OneCycleSelectorProps,
|
|
208
|
+
OnePairSelectorProps,
|
|
209
|
+
// Forex Component Types
|
|
210
|
+
OneForexPoolCardProps,
|
|
211
|
+
OneForexCapitalSplitProps,
|
|
212
|
+
OneForexConsoleViewProps,
|
|
213
|
+
OneForexPairSelectorProps,
|
|
214
|
+
OneForexTradeHistoryProps,
|
|
215
|
+
// Trading Console Component Types
|
|
216
|
+
OneTradingConsoleProps,
|
|
217
|
+
OneAIQuantConsoleProps,
|
|
218
|
+
OneAgentConsoleProps,
|
|
219
|
+
OnePositionDetailProps,
|
|
220
|
+
OneAgentCardProps,
|
|
221
|
+
OnePositionCardProps,
|
|
222
|
+
OneRiskIndicatorProps,
|
|
223
|
+
OneMetricsDashboardProps,
|
|
224
|
+
OneDecisionTimelineProps,
|
|
153
225
|
} from './components';
|
|
154
226
|
|
|
155
227
|
// ===== Standalone Hooks (for use outside OneProvider) =====
|
|
@@ -166,6 +238,29 @@ export {
|
|
|
166
238
|
useAITrading,
|
|
167
239
|
setAITradingAccessToken,
|
|
168
240
|
clearAITradingAccessToken,
|
|
241
|
+
// AI Agent Hooks
|
|
242
|
+
useAIAgents,
|
|
243
|
+
useAIAgent,
|
|
244
|
+
useAIAgentSubscription,
|
|
245
|
+
// Forex Trading Hooks
|
|
246
|
+
useForexPools,
|
|
247
|
+
useForexInvestments,
|
|
248
|
+
useForexSimulation,
|
|
249
|
+
useForexPoolData,
|
|
250
|
+
useForexTrading,
|
|
251
|
+
setForexAccessToken,
|
|
252
|
+
clearForexAccessToken,
|
|
253
|
+
setForexEngineUrl,
|
|
254
|
+
// Trading Console Hooks
|
|
255
|
+
useTradingConsole,
|
|
256
|
+
useAIQuantConsole,
|
|
257
|
+
useBotSimulation,
|
|
258
|
+
useAIPositions,
|
|
259
|
+
useAIDecisions,
|
|
260
|
+
useAIRiskStatus,
|
|
261
|
+
setConsoleAccessToken,
|
|
262
|
+
clearConsoleAccessToken,
|
|
263
|
+
setConsoleEngineUrl,
|
|
169
264
|
} from './hooks';
|
|
170
265
|
|
|
171
266
|
export type {
|
|
@@ -177,6 +272,29 @@ export type {
|
|
|
177
272
|
UseAIPortfolioResult,
|
|
178
273
|
UseAIMarketDataResult,
|
|
179
274
|
UseAITradingResult,
|
|
275
|
+
// AI Agent Hook Types
|
|
276
|
+
UseAIAgentsResult,
|
|
277
|
+
UseAIAgentResult,
|
|
278
|
+
UseAIAgentSubscriptionResult,
|
|
279
|
+
AIAgent as AIAgentHook,
|
|
280
|
+
AIAgentParams,
|
|
281
|
+
// Forex Hook Types
|
|
282
|
+
UseForexPoolsResult,
|
|
283
|
+
UseForexInvestmentsResult,
|
|
284
|
+
UseForexSimulationResult,
|
|
285
|
+
UseForexPoolDataResult,
|
|
286
|
+
UseForexTradingResult,
|
|
287
|
+
// Trading Console Hook Types
|
|
288
|
+
UseBotSimulationOptions,
|
|
289
|
+
UseBotSimulationResult,
|
|
290
|
+
UseAIPositionsOptions,
|
|
291
|
+
UseAIPositionsResult,
|
|
292
|
+
UseAIDecisionsOptions,
|
|
293
|
+
UseAIDecisionsResult,
|
|
294
|
+
UseAIRiskStatusOptions,
|
|
295
|
+
UseAIRiskStatusResult,
|
|
296
|
+
UseAIQuantConsoleResult,
|
|
297
|
+
UseTradingConsoleResult,
|
|
180
298
|
} from './hooks';
|
|
181
299
|
|
|
182
300
|
// ===== Utilities =====
|
|
@@ -9,19 +9,45 @@ import React, {
|
|
|
9
9
|
useMemo,
|
|
10
10
|
type ReactNode,
|
|
11
11
|
} from 'react';
|
|
12
|
+
import { createThirdwebClient, type ThirdwebClient } from 'thirdweb';
|
|
13
|
+
import { ThirdwebProvider as BaseThirdwebProvider } from 'thirdweb/react';
|
|
14
|
+
import { inAppWallet, smartWallet } from 'thirdweb/wallets';
|
|
15
|
+
import type { Chain } from 'thirdweb/chains';
|
|
16
|
+
import { base, ethereum, polygon, arbitrum, optimism } from 'thirdweb/chains';
|
|
17
|
+
|
|
12
18
|
import { initOneSDK, type OneConfig } from '../config';
|
|
13
19
|
import {
|
|
14
20
|
OneEngineClient,
|
|
15
21
|
createOneEngineClient,
|
|
16
|
-
type EngineAuthResponse,
|
|
17
22
|
type EngineWalletBalance,
|
|
18
|
-
type OnrampSession,
|
|
19
23
|
type OnrampSessionRequest,
|
|
20
24
|
type SwapQuote,
|
|
21
25
|
type SwapQuoteRequest,
|
|
22
26
|
} from '../services/engine';
|
|
23
27
|
import type { User, Token, AIStrategy, AIOrder } from '../types';
|
|
24
28
|
|
|
29
|
+
// ===== Thirdweb Config Types =====
|
|
30
|
+
|
|
31
|
+
export interface ThirdwebAuthOptions {
|
|
32
|
+
email?: boolean;
|
|
33
|
+
phone?: boolean;
|
|
34
|
+
google?: boolean;
|
|
35
|
+
apple?: boolean;
|
|
36
|
+
facebook?: boolean;
|
|
37
|
+
discord?: boolean;
|
|
38
|
+
passkey?: boolean;
|
|
39
|
+
guest?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ThirdwebWalletConfig {
|
|
43
|
+
appName?: string;
|
|
44
|
+
appIcon?: string;
|
|
45
|
+
defaultChain?: Chain;
|
|
46
|
+
supportedChains?: Chain[];
|
|
47
|
+
sponsorGas?: boolean;
|
|
48
|
+
authOptions?: ThirdwebAuthOptions;
|
|
49
|
+
}
|
|
50
|
+
|
|
25
51
|
// ===== Context Types =====
|
|
26
52
|
|
|
27
53
|
interface AuthContextValue {
|
|
@@ -36,15 +62,20 @@ interface AuthContextValue {
|
|
|
36
62
|
}
|
|
37
63
|
|
|
38
64
|
interface WalletContextValue {
|
|
65
|
+
// Address management
|
|
39
66
|
address: string | null;
|
|
67
|
+
setAddress: (address: string | null) => void;
|
|
68
|
+
// Balance from Engine API
|
|
40
69
|
balance: EngineWalletBalance | null;
|
|
41
70
|
tokens: Token[];
|
|
42
71
|
totalUsd: number;
|
|
43
72
|
isLoading: boolean;
|
|
44
73
|
error: string | null;
|
|
45
|
-
setAddress: (address: string | null) => void;
|
|
46
74
|
fetchBalance: (chains?: number[]) => Promise<void>;
|
|
47
75
|
refreshBalance: () => Promise<void>;
|
|
76
|
+
// Thirdweb client for wallet connection
|
|
77
|
+
thirdwebClient: ThirdwebClient | null;
|
|
78
|
+
isThirdwebReady: boolean;
|
|
48
79
|
}
|
|
49
80
|
|
|
50
81
|
interface OnrampContextValue {
|
|
@@ -89,14 +120,70 @@ interface OneContextValue {
|
|
|
89
120
|
onramp: OnrampContextValue;
|
|
90
121
|
swap: SwapContextValue;
|
|
91
122
|
trading: TradingContextValue;
|
|
123
|
+
// Direct thirdweb access
|
|
124
|
+
thirdwebClient: ThirdwebClient | null;
|
|
92
125
|
}
|
|
93
126
|
|
|
94
127
|
const OneContext = createContext<OneContextValue | null>(null);
|
|
95
128
|
|
|
129
|
+
// ===== Default Thirdweb Configuration =====
|
|
130
|
+
|
|
131
|
+
const DEFAULT_CHAINS: Chain[] = [base, ethereum, polygon, arbitrum, optimism];
|
|
132
|
+
|
|
133
|
+
const DEFAULT_AUTH_OPTIONS: ThirdwebAuthOptions = {
|
|
134
|
+
email: true,
|
|
135
|
+
phone: false,
|
|
136
|
+
google: true,
|
|
137
|
+
apple: true,
|
|
138
|
+
facebook: false,
|
|
139
|
+
discord: false,
|
|
140
|
+
passkey: true,
|
|
141
|
+
guest: false,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// ===== Create Wallets Configuration =====
|
|
145
|
+
|
|
146
|
+
function createWalletConfig(config: ThirdwebWalletConfig) {
|
|
147
|
+
const authOptions = { ...DEFAULT_AUTH_OPTIONS, ...config.authOptions };
|
|
148
|
+
|
|
149
|
+
// Build auth options array
|
|
150
|
+
const authMethods: string[] = [];
|
|
151
|
+
if (authOptions.google) authMethods.push('google');
|
|
152
|
+
if (authOptions.apple) authMethods.push('apple');
|
|
153
|
+
if (authOptions.facebook) authMethods.push('facebook');
|
|
154
|
+
if (authOptions.discord) authMethods.push('discord');
|
|
155
|
+
if (authOptions.passkey) authMethods.push('passkey');
|
|
156
|
+
|
|
157
|
+
// Create in-app wallet with email and social logins
|
|
158
|
+
const inApp = inAppWallet({
|
|
159
|
+
auth: {
|
|
160
|
+
options: authMethods as any[],
|
|
161
|
+
},
|
|
162
|
+
metadata: config.appName ? {
|
|
163
|
+
name: config.appName,
|
|
164
|
+
image: config.appIcon ? { src: config.appIcon, width: 100, height: 100 } : undefined,
|
|
165
|
+
} : undefined,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// If gas sponsorship is enabled, wrap in smart wallet
|
|
169
|
+
if (config.sponsorGas) {
|
|
170
|
+
const chain = config.defaultChain || base;
|
|
171
|
+
return [
|
|
172
|
+
smartWallet({
|
|
173
|
+
chain,
|
|
174
|
+
sponsorGas: true,
|
|
175
|
+
}),
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return [inApp];
|
|
180
|
+
}
|
|
181
|
+
|
|
96
182
|
// ===== Provider Props =====
|
|
97
183
|
interface OneProviderProps {
|
|
98
184
|
children: ReactNode;
|
|
99
185
|
config: OneConfig;
|
|
186
|
+
thirdweb?: ThirdwebWalletConfig;
|
|
100
187
|
autoFetchBalance?: boolean;
|
|
101
188
|
}
|
|
102
189
|
|
|
@@ -104,10 +191,10 @@ interface OneProviderProps {
|
|
|
104
191
|
export function OneProvider({
|
|
105
192
|
children,
|
|
106
193
|
config,
|
|
194
|
+
thirdweb: thirdwebConfig = {},
|
|
107
195
|
autoFetchBalance = true,
|
|
108
196
|
}: OneProviderProps) {
|
|
109
197
|
// Initialize SDK synchronously before creating engine client
|
|
110
|
-
// This must happen before useMemo so getConfig() works in the constructor
|
|
111
198
|
useMemo(() => {
|
|
112
199
|
initOneSDK(config);
|
|
113
200
|
}, [config]);
|
|
@@ -119,6 +206,67 @@ export function OneProvider({
|
|
|
119
206
|
secretKey: config.oneSecretKey,
|
|
120
207
|
}), [config]);
|
|
121
208
|
|
|
209
|
+
// ===== Thirdweb State =====
|
|
210
|
+
const [thirdwebClientId, setThirdwebClientId] = useState<string | null>(null);
|
|
211
|
+
const [thirdwebLoading, setThirdwebLoading] = useState(true);
|
|
212
|
+
const [thirdwebError, setThirdwebError] = useState<string | null>(null);
|
|
213
|
+
|
|
214
|
+
// Fetch thirdweb clientId from Engine on mount
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
const fetchClientConfig = async () => {
|
|
217
|
+
try {
|
|
218
|
+
const response = await fetch(`${config.oneEngineUrl}/v1/config/thirdweb`);
|
|
219
|
+
|
|
220
|
+
if (response.ok) {
|
|
221
|
+
const data = await response.json();
|
|
222
|
+
if (data.success && data.data?.clientId) {
|
|
223
|
+
setThirdwebClientId(data.data.clientId);
|
|
224
|
+
} else {
|
|
225
|
+
// Fallback to environment variable
|
|
226
|
+
const envClientId = typeof window !== 'undefined'
|
|
227
|
+
? (window as any).__NEXT_PUBLIC_THIRDWEB_CLIENT_ID
|
|
228
|
+
: process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID;
|
|
229
|
+
if (envClientId) {
|
|
230
|
+
setThirdwebClientId(envClientId);
|
|
231
|
+
} else {
|
|
232
|
+
setThirdwebError('Failed to load wallet configuration');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
// Fallback to environment variable
|
|
237
|
+
const envClientId = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID;
|
|
238
|
+
if (envClientId) {
|
|
239
|
+
setThirdwebClientId(envClientId);
|
|
240
|
+
} else {
|
|
241
|
+
setThirdwebError('Wallet service unavailable');
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (err) {
|
|
245
|
+
// Fallback to environment variable on network error
|
|
246
|
+
const envClientId = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID;
|
|
247
|
+
if (envClientId) {
|
|
248
|
+
setThirdwebClientId(envClientId);
|
|
249
|
+
} else {
|
|
250
|
+
console.warn('Failed to fetch thirdweb config:', err);
|
|
251
|
+
// Don't set error - thirdweb is optional
|
|
252
|
+
}
|
|
253
|
+
} finally {
|
|
254
|
+
setThirdwebLoading(false);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
fetchClientConfig();
|
|
259
|
+
}, [config.oneEngineUrl]);
|
|
260
|
+
|
|
261
|
+
// Create thirdweb client once we have clientId
|
|
262
|
+
const thirdwebClient = useMemo(() => {
|
|
263
|
+
if (!thirdwebClientId) return null;
|
|
264
|
+
return createThirdwebClient({ clientId: thirdwebClientId });
|
|
265
|
+
}, [thirdwebClientId]);
|
|
266
|
+
|
|
267
|
+
// Create wallet configuration
|
|
268
|
+
const wallets = useMemo(() => createWalletConfig(thirdwebConfig), [thirdwebConfig]);
|
|
269
|
+
|
|
122
270
|
// ===== Auth State =====
|
|
123
271
|
const [user, setUser] = useState<User | null>(null);
|
|
124
272
|
const [accessToken, setAccessToken] = useState<string | null>(null);
|
|
@@ -315,6 +463,7 @@ export function OneProvider({
|
|
|
315
463
|
isInitialized,
|
|
316
464
|
config: isInitialized ? config : null,
|
|
317
465
|
engine,
|
|
466
|
+
thirdwebClient,
|
|
318
467
|
|
|
319
468
|
auth: {
|
|
320
469
|
user,
|
|
@@ -337,6 +486,8 @@ export function OneProvider({
|
|
|
337
486
|
setAddress: setWalletAddress,
|
|
338
487
|
fetchBalance,
|
|
339
488
|
refreshBalance,
|
|
489
|
+
thirdwebClient,
|
|
490
|
+
isThirdwebReady: !thirdwebLoading && !!thirdwebClient,
|
|
340
491
|
},
|
|
341
492
|
|
|
342
493
|
onramp: {
|
|
@@ -369,6 +520,8 @@ export function OneProvider({
|
|
|
369
520
|
isInitialized,
|
|
370
521
|
config,
|
|
371
522
|
engine,
|
|
523
|
+
thirdwebClient,
|
|
524
|
+
thirdwebLoading,
|
|
372
525
|
user,
|
|
373
526
|
authLoading,
|
|
374
527
|
accessToken,
|
|
@@ -402,11 +555,23 @@ export function OneProvider({
|
|
|
402
555
|
createOrder,
|
|
403
556
|
]);
|
|
404
557
|
|
|
405
|
-
|
|
558
|
+
// Wrap with ThirdwebProvider if client is available
|
|
559
|
+
const content = (
|
|
406
560
|
<OneContext.Provider value={contextValue}>
|
|
407
561
|
{children}
|
|
408
562
|
</OneContext.Provider>
|
|
409
563
|
);
|
|
564
|
+
|
|
565
|
+
// If thirdweb is ready, wrap with ThirdwebProvider
|
|
566
|
+
if (thirdwebClient) {
|
|
567
|
+
return (
|
|
568
|
+
<BaseThirdwebProvider>
|
|
569
|
+
{content}
|
|
570
|
+
</BaseThirdwebProvider>
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return content;
|
|
410
575
|
}
|
|
411
576
|
|
|
412
577
|
// ===== Hooks =====
|
|
@@ -448,5 +613,16 @@ export function useOneEngine() {
|
|
|
448
613
|
return engine;
|
|
449
614
|
}
|
|
450
615
|
|
|
616
|
+
export function useThirdwebClient(): ThirdwebClient | null {
|
|
617
|
+
const { thirdwebClient } = useOne();
|
|
618
|
+
return thirdwebClient;
|
|
619
|
+
}
|
|
620
|
+
|
|
451
621
|
// Export context for advanced usage
|
|
452
622
|
export { OneContext };
|
|
623
|
+
|
|
624
|
+
// Export thirdweb utilities for convenience
|
|
625
|
+
export { inAppWallet, smartWallet } from 'thirdweb/wallets';
|
|
626
|
+
export { base, ethereum, polygon, arbitrum, optimism } from 'thirdweb/chains';
|
|
627
|
+
export type { Chain } from 'thirdweb/chains';
|
|
628
|
+
export type { ThirdwebClient } from 'thirdweb';
|
package/src/providers/index.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
// ONE SDK Unified Provider
|
|
2
|
+
// All wallet functionality (including thirdweb) is integrated into OneProvider
|
|
3
|
+
|
|
1
4
|
export {
|
|
5
|
+
// Main Provider
|
|
2
6
|
OneProvider,
|
|
7
|
+
|
|
8
|
+
// Core Hooks
|
|
3
9
|
useOne,
|
|
4
10
|
useOneAuth,
|
|
5
11
|
useOneWallet,
|
|
@@ -7,13 +13,12 @@ export {
|
|
|
7
13
|
useOneSwap,
|
|
8
14
|
useOneTrading,
|
|
9
15
|
useOneEngine,
|
|
16
|
+
useThirdwebClient,
|
|
17
|
+
|
|
18
|
+
// Context
|
|
10
19
|
OneContext,
|
|
11
|
-
} from './OneProvider';
|
|
12
20
|
|
|
13
|
-
// Thirdweb
|
|
14
|
-
export {
|
|
15
|
-
OneThirdwebProvider,
|
|
16
|
-
useThirdwebClient,
|
|
21
|
+
// Thirdweb utilities (re-exported for convenience)
|
|
17
22
|
inAppWallet,
|
|
18
23
|
smartWallet,
|
|
19
24
|
base,
|
|
@@ -21,6 +26,15 @@ export {
|
|
|
21
26
|
polygon,
|
|
22
27
|
arbitrum,
|
|
23
28
|
optimism,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
// Types
|
|
31
|
+
type ThirdwebAuthOptions,
|
|
32
|
+
type ThirdwebWalletConfig,
|
|
33
|
+
type Chain,
|
|
34
|
+
type ThirdwebClient,
|
|
35
|
+
} from './OneProvider';
|
|
36
|
+
|
|
37
|
+
// Legacy re-export for backwards compatibility
|
|
38
|
+
// @deprecated Use OneProvider instead
|
|
39
|
+
export { OneProvider as OneThirdwebProvider } from './OneProvider';
|
|
40
|
+
export type { ThirdwebWalletConfig as OneThirdwebConfig } from './OneProvider';
|
package/src/react-native.ts
CHANGED
|
@@ -90,6 +90,47 @@ export {
|
|
|
90
90
|
} from './components/ai/OnePairSelector';
|
|
91
91
|
export type { OnePairSelectorProps } from './components/ai/OnePairSelector';
|
|
92
92
|
|
|
93
|
+
// ===== StableFX Forex Components =====
|
|
94
|
+
export { OneForexPoolCard } from './components/ai/OneForexPoolCard';
|
|
95
|
+
export type { OneForexPoolCardProps } from './components/ai/OneForexPoolCard';
|
|
96
|
+
|
|
97
|
+
export { OneForexCapitalSplit } from './components/ai/OneForexCapitalSplit';
|
|
98
|
+
export type { OneForexCapitalSplitProps } from './components/ai/OneForexCapitalSplit';
|
|
99
|
+
|
|
100
|
+
export { OneForexConsoleView } from './components/ai/OneForexConsoleView';
|
|
101
|
+
export type { OneForexConsoleViewProps } from './components/ai/OneForexConsoleView';
|
|
102
|
+
|
|
103
|
+
export { OneForexPairSelector } from './components/ai/OneForexPairSelector';
|
|
104
|
+
export type { OneForexPairSelectorProps } from './components/ai/OneForexPairSelector';
|
|
105
|
+
|
|
106
|
+
export { OneForexTradeHistory } from './components/ai/OneForexTradeHistory';
|
|
107
|
+
export type { OneForexTradeHistoryProps } from './components/ai/OneForexTradeHistory';
|
|
108
|
+
|
|
109
|
+
// ===== Forex Hooks =====
|
|
110
|
+
export {
|
|
111
|
+
useForexPools,
|
|
112
|
+
useForexInvestments,
|
|
113
|
+
useForexSimulation,
|
|
114
|
+
useForexPoolData,
|
|
115
|
+
useForexTrading,
|
|
116
|
+
setForexAccessToken,
|
|
117
|
+
clearForexAccessToken,
|
|
118
|
+
setForexEngineUrl,
|
|
119
|
+
} from './hooks/useForexTrading';
|
|
120
|
+
|
|
121
|
+
export type {
|
|
122
|
+
UseForexPoolsResult,
|
|
123
|
+
UseForexInvestmentsResult,
|
|
124
|
+
UseForexSimulationResult,
|
|
125
|
+
UseForexPoolDataResult,
|
|
126
|
+
UseForexTradingResult,
|
|
127
|
+
} from './hooks/useForexTrading';
|
|
128
|
+
|
|
129
|
+
// ===== Forex Services =====
|
|
130
|
+
export { forexSimulationEngine } from './services/forex/ForexSimulationEngine';
|
|
131
|
+
export { ForexPoolDataGenerator } from './services/forex/ForexPoolDataGenerator';
|
|
132
|
+
export { botSimulationEngine } from './services/forex/BotSimulationEngine';
|
|
133
|
+
|
|
93
134
|
// ===== React Native Specific Utilities =====
|
|
94
135
|
|
|
95
136
|
/**
|