@one_deploy/sdk 1.0.7 → 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.
Files changed (106) hide show
  1. package/README.md +339 -0
  2. package/dist/ForexPoolDataGenerator--__twRwl.d.mts +76 -0
  3. package/dist/ForexPoolDataGenerator-eUgwsU_B.d.ts +76 -0
  4. package/dist/OneForexTradeHistory-TlKxjbFF.d.ts +250 -0
  5. package/dist/OneForexTradeHistory-iDySMcw0.d.mts +250 -0
  6. package/dist/components/index.d.mts +539 -0
  7. package/dist/components/index.d.ts +539 -0
  8. package/dist/components/index.js +7295 -0
  9. package/dist/components/index.js.map +1 -0
  10. package/dist/components/index.mjs +7243 -0
  11. package/dist/components/index.mjs.map +1 -0
  12. package/dist/config/index.d.mts +1 -0
  13. package/dist/config/index.d.ts +1 -0
  14. package/dist/console-BfTMA7ah.d.mts +504 -0
  15. package/dist/console-BfTMA7ah.d.ts +504 -0
  16. package/dist/hooks/index.d.mts +323 -1
  17. package/dist/hooks/index.d.ts +323 -1
  18. package/dist/hooks/index.js +3223 -0
  19. package/dist/hooks/index.js.map +1 -1
  20. package/dist/hooks/index.mjs +3204 -1
  21. package/dist/hooks/index.mjs.map +1 -1
  22. package/dist/index.d.mts +18 -352
  23. package/dist/index.d.ts +18 -352
  24. package/dist/index.js +8646 -574
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +8449 -432
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/providers/index.d.mts +31 -31
  29. package/dist/providers/index.d.ts +31 -31
  30. package/dist/providers/index.js +140 -153
  31. package/dist/providers/index.js.map +1 -1
  32. package/dist/providers/index.mjs +100 -109
  33. package/dist/providers/index.mjs.map +1 -1
  34. package/dist/react-native.d.mts +8 -144
  35. package/dist/react-native.d.ts +8 -144
  36. package/dist/react-native.js +2640 -689
  37. package/dist/react-native.js.map +1 -1
  38. package/dist/react-native.mjs +2610 -691
  39. package/dist/react-native.mjs.map +1 -1
  40. package/dist/services/index.d.mts +85 -4
  41. package/dist/services/index.d.ts +85 -4
  42. package/dist/services/index.js +1621 -0
  43. package/dist/services/index.js.map +1 -1
  44. package/dist/services/index.mjs +1619 -1
  45. package/dist/services/index.mjs.map +1 -1
  46. package/dist/types/index.d.mts +203 -1
  47. package/dist/types/index.d.ts +203 -1
  48. package/dist/types/index.js +275 -0
  49. package/dist/types/index.js.map +1 -1
  50. package/dist/types/index.mjs +251 -0
  51. package/dist/types/index.mjs.map +1 -1
  52. package/dist/useForexTrading-BleeSor8.d.mts +80 -0
  53. package/dist/useForexTrading-ZgW_G40Q.d.ts +80 -0
  54. package/package.json +9 -2
  55. package/src/components/OneConnectButton.tsx +24 -1
  56. package/src/components/OneNFTGallery.tsx +13 -7
  57. package/src/components/OneOfframpWidget.tsx +4 -3
  58. package/src/components/OnePayWidget.tsx +10 -1
  59. package/src/components/OneSendWidget.tsx +3 -3
  60. package/src/components/OneSwapWidget.tsx +4 -4
  61. package/src/components/OneTransactionButton.tsx +28 -3
  62. package/src/components/OneWalletBalance.tsx +1 -1
  63. package/src/components/ai/OneChainSelector.tsx +63 -336
  64. package/src/components/ai/OneForexCapitalSplit.tsx +112 -0
  65. package/src/components/ai/OneForexConsoleView.tsx +90 -0
  66. package/src/components/ai/OneForexPairSelector.tsx +101 -0
  67. package/src/components/ai/OneForexPoolCard.tsx +105 -0
  68. package/src/components/ai/OneForexTradeHistory.tsx +107 -0
  69. package/src/components/ai/OnePairSelector.tsx +77 -434
  70. package/src/components/ai/console/OneAIQuantConsole.tsx +423 -0
  71. package/src/components/ai/console/OneAgentCard.tsx +383 -0
  72. package/src/components/ai/console/OneAgentConsole.tsx +469 -0
  73. package/src/components/ai/console/OneDecisionTimeline.tsx +433 -0
  74. package/src/components/ai/console/OneMetricsDashboard.tsx +493 -0
  75. package/src/components/ai/console/OnePositionCard.tsx +406 -0
  76. package/src/components/ai/console/OnePositionDetail.tsx +600 -0
  77. package/src/components/ai/console/OneRiskIndicator.tsx +464 -0
  78. package/src/components/ai/console/OneTradingConsole.tsx +660 -0
  79. package/src/components/ai/console/index.ts +17 -0
  80. package/src/components/ai/index.ts +10 -0
  81. package/src/hooks/index.ts +46 -0
  82. package/src/hooks/useAIDecisions.ts +280 -0
  83. package/src/hooks/useAIPositions.ts +349 -0
  84. package/src/hooks/useAIQuantConsole.ts +283 -0
  85. package/src/hooks/useAIRiskStatus.ts +276 -0
  86. package/src/hooks/useAITrading.ts +190 -0
  87. package/src/hooks/useBotSimulation.ts +201 -0
  88. package/src/hooks/useForexTrading.ts +430 -0
  89. package/src/hooks/useTradingConsole.ts +243 -0
  90. package/src/index.ts +123 -5
  91. package/src/providers/OneProvider.tsx +181 -5
  92. package/src/providers/index.ts +22 -8
  93. package/src/react-native.ts +41 -0
  94. package/src/services/forex/BotSimulationEngine.ts +968 -0
  95. package/src/services/forex/ForexPoolDataGenerator.ts +542 -0
  96. package/src/services/forex/ForexSimulationEngine.ts +482 -0
  97. package/src/services/forex/index.ts +21 -0
  98. package/src/services/index.ts +16 -0
  99. package/src/types/aiTrading.ts +151 -0
  100. package/src/types/console.ts +380 -0
  101. package/src/types/forex.ts +282 -0
  102. package/src/types/index.ts +106 -0
  103. package/dist/price-CgqXPnT3.d.ts +0 -13
  104. package/dist/price-ClbLHHjv.d.mts +0 -13
  105. package/dist/supabase-BT0c7q9e.d.mts +0 -82
  106. package/dist/supabase-BT0c7q9e.d.ts +0 -82
@@ -1,13 +1,33 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React, { ReactNode } from 'react';
3
+ import { ThirdwebClient } from 'thirdweb';
4
+ export { ThirdwebClient } from 'thirdweb';
5
+ import { Chain } from 'thirdweb/chains';
6
+ export { Chain, arbitrum, base, ethereum, optimism, polygon } from 'thirdweb/chains';
3
7
  import { OneConfig } from '../config/index.mjs';
4
8
  import { O as OneEngineClient, a as EngineWalletBalance, e as OnrampSessionRequest, S as SwapQuoteRequest, i as SwapQuote } from '../engine-BeVuHpVx.mjs';
5
9
  import { User, Token, AIStrategy, AIOrder } from '../types/index.mjs';
6
- import { ThirdwebClient } from 'thirdweb';
7
- import { Chain } from 'thirdweb/chains';
8
- export { arbitrum, base, ethereum, optimism, polygon } from 'thirdweb/chains';
9
10
  export { inAppWallet, smartWallet } from 'thirdweb/wallets';
11
+ import '../console-BfTMA7ah.mjs';
10
12
 
13
+ interface ThirdwebAuthOptions {
14
+ email?: boolean;
15
+ phone?: boolean;
16
+ google?: boolean;
17
+ apple?: boolean;
18
+ facebook?: boolean;
19
+ discord?: boolean;
20
+ passkey?: boolean;
21
+ guest?: boolean;
22
+ }
23
+ interface ThirdwebWalletConfig {
24
+ appName?: string;
25
+ appIcon?: string;
26
+ defaultChain?: Chain;
27
+ supportedChains?: Chain[];
28
+ sponsorGas?: boolean;
29
+ authOptions?: ThirdwebAuthOptions;
30
+ }
11
31
  interface AuthContextValue {
12
32
  user: User | null;
13
33
  isAuthenticated: boolean;
@@ -26,14 +46,16 @@ interface AuthContextValue {
26
46
  }
27
47
  interface WalletContextValue {
28
48
  address: string | null;
49
+ setAddress: (address: string | null) => void;
29
50
  balance: EngineWalletBalance | null;
30
51
  tokens: Token[];
31
52
  totalUsd: number;
32
53
  isLoading: boolean;
33
54
  error: string | null;
34
- setAddress: (address: string | null) => void;
35
55
  fetchBalance: (chains?: number[]) => Promise<void>;
36
56
  refreshBalance: () => Promise<void>;
57
+ thirdwebClient: ThirdwebClient | null;
58
+ isThirdwebReady: boolean;
37
59
  }
38
60
  interface OnrampContextValue {
39
61
  isOpen: boolean;
@@ -77,14 +99,16 @@ interface OneContextValue {
77
99
  onramp: OnrampContextValue;
78
100
  swap: SwapContextValue;
79
101
  trading: TradingContextValue;
102
+ thirdwebClient: ThirdwebClient | null;
80
103
  }
81
104
  declare const OneContext: React.Context<OneContextValue | null>;
82
105
  interface OneProviderProps {
83
106
  children: ReactNode;
84
107
  config: OneConfig;
108
+ thirdweb?: ThirdwebWalletConfig;
85
109
  autoFetchBalance?: boolean;
86
110
  }
87
- declare function OneProvider({ children, config, autoFetchBalance, }: OneProviderProps): react_jsx_runtime.JSX.Element;
111
+ declare function OneProvider({ children, config, thirdweb: thirdwebConfig, autoFetchBalance, }: OneProviderProps): react_jsx_runtime.JSX.Element;
88
112
  declare function useOne(): OneContextValue;
89
113
  declare function useOneAuth(): AuthContextValue;
90
114
  declare function useOneWallet(): WalletContextValue;
@@ -92,30 +116,6 @@ declare function useOneOnramp(): OnrampContextValue;
92
116
  declare function useOneSwap(): SwapContextValue;
93
117
  declare function useOneTrading(): TradingContextValue;
94
118
  declare function useOneEngine(): OneEngineClient;
119
+ declare function useThirdwebClient(): ThirdwebClient | null;
95
120
 
96
- interface OneThirdwebConfig {
97
- engineUrl?: string;
98
- appName?: string;
99
- appIcon?: string;
100
- defaultChain?: Chain;
101
- supportedChains?: Chain[];
102
- sponsorGas?: boolean;
103
- authOptions?: {
104
- email?: boolean;
105
- phone?: boolean;
106
- google?: boolean;
107
- apple?: boolean;
108
- facebook?: boolean;
109
- discord?: boolean;
110
- passkey?: boolean;
111
- guest?: boolean;
112
- };
113
- }
114
- interface OneThirdwebProviderProps {
115
- children: ReactNode;
116
- config?: OneThirdwebConfig;
117
- }
118
- declare function useThirdwebClient(): ThirdwebClient;
119
- declare function OneThirdwebProvider({ children, config, }: OneThirdwebProviderProps): react_jsx_runtime.JSX.Element;
120
-
121
- export { OneContext, OneProvider, type OneThirdwebConfig, OneThirdwebProvider, type OneThirdwebProviderProps, useOne, useOneAuth, useOneEngine, useOneOnramp, useOneSwap, useOneTrading, useOneWallet, useThirdwebClient };
121
+ export { OneContext, OneProvider, type ThirdwebWalletConfig as OneThirdwebConfig, OneProvider as OneThirdwebProvider, type ThirdwebAuthOptions, type ThirdwebWalletConfig, useOne, useOneAuth, useOneEngine, useOneOnramp, useOneSwap, useOneTrading, useOneWallet, useThirdwebClient };
@@ -1,13 +1,33 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React, { ReactNode } from 'react';
3
+ import { ThirdwebClient } from 'thirdweb';
4
+ export { ThirdwebClient } from 'thirdweb';
5
+ import { Chain } from 'thirdweb/chains';
6
+ export { Chain, arbitrum, base, ethereum, optimism, polygon } from 'thirdweb/chains';
3
7
  import { OneConfig } from '../config/index.js';
4
8
  import { O as OneEngineClient, a as EngineWalletBalance, e as OnrampSessionRequest, S as SwapQuoteRequest, i as SwapQuote } from '../engine-DSc1Em4V.js';
5
9
  import { User, Token, AIStrategy, AIOrder } from '../types/index.js';
6
- import { ThirdwebClient } from 'thirdweb';
7
- import { Chain } from 'thirdweb/chains';
8
- export { arbitrum, base, ethereum, optimism, polygon } from 'thirdweb/chains';
9
10
  export { inAppWallet, smartWallet } from 'thirdweb/wallets';
11
+ import '../console-BfTMA7ah.js';
10
12
 
13
+ interface ThirdwebAuthOptions {
14
+ email?: boolean;
15
+ phone?: boolean;
16
+ google?: boolean;
17
+ apple?: boolean;
18
+ facebook?: boolean;
19
+ discord?: boolean;
20
+ passkey?: boolean;
21
+ guest?: boolean;
22
+ }
23
+ interface ThirdwebWalletConfig {
24
+ appName?: string;
25
+ appIcon?: string;
26
+ defaultChain?: Chain;
27
+ supportedChains?: Chain[];
28
+ sponsorGas?: boolean;
29
+ authOptions?: ThirdwebAuthOptions;
30
+ }
11
31
  interface AuthContextValue {
12
32
  user: User | null;
13
33
  isAuthenticated: boolean;
@@ -26,14 +46,16 @@ interface AuthContextValue {
26
46
  }
27
47
  interface WalletContextValue {
28
48
  address: string | null;
49
+ setAddress: (address: string | null) => void;
29
50
  balance: EngineWalletBalance | null;
30
51
  tokens: Token[];
31
52
  totalUsd: number;
32
53
  isLoading: boolean;
33
54
  error: string | null;
34
- setAddress: (address: string | null) => void;
35
55
  fetchBalance: (chains?: number[]) => Promise<void>;
36
56
  refreshBalance: () => Promise<void>;
57
+ thirdwebClient: ThirdwebClient | null;
58
+ isThirdwebReady: boolean;
37
59
  }
38
60
  interface OnrampContextValue {
39
61
  isOpen: boolean;
@@ -77,14 +99,16 @@ interface OneContextValue {
77
99
  onramp: OnrampContextValue;
78
100
  swap: SwapContextValue;
79
101
  trading: TradingContextValue;
102
+ thirdwebClient: ThirdwebClient | null;
80
103
  }
81
104
  declare const OneContext: React.Context<OneContextValue | null>;
82
105
  interface OneProviderProps {
83
106
  children: ReactNode;
84
107
  config: OneConfig;
108
+ thirdweb?: ThirdwebWalletConfig;
85
109
  autoFetchBalance?: boolean;
86
110
  }
87
- declare function OneProvider({ children, config, autoFetchBalance, }: OneProviderProps): react_jsx_runtime.JSX.Element;
111
+ declare function OneProvider({ children, config, thirdweb: thirdwebConfig, autoFetchBalance, }: OneProviderProps): react_jsx_runtime.JSX.Element;
88
112
  declare function useOne(): OneContextValue;
89
113
  declare function useOneAuth(): AuthContextValue;
90
114
  declare function useOneWallet(): WalletContextValue;
@@ -92,30 +116,6 @@ declare function useOneOnramp(): OnrampContextValue;
92
116
  declare function useOneSwap(): SwapContextValue;
93
117
  declare function useOneTrading(): TradingContextValue;
94
118
  declare function useOneEngine(): OneEngineClient;
119
+ declare function useThirdwebClient(): ThirdwebClient | null;
95
120
 
96
- interface OneThirdwebConfig {
97
- engineUrl?: string;
98
- appName?: string;
99
- appIcon?: string;
100
- defaultChain?: Chain;
101
- supportedChains?: Chain[];
102
- sponsorGas?: boolean;
103
- authOptions?: {
104
- email?: boolean;
105
- phone?: boolean;
106
- google?: boolean;
107
- apple?: boolean;
108
- facebook?: boolean;
109
- discord?: boolean;
110
- passkey?: boolean;
111
- guest?: boolean;
112
- };
113
- }
114
- interface OneThirdwebProviderProps {
115
- children: ReactNode;
116
- config?: OneThirdwebConfig;
117
- }
118
- declare function useThirdwebClient(): ThirdwebClient;
119
- declare function OneThirdwebProvider({ children, config, }: OneThirdwebProviderProps): react_jsx_runtime.JSX.Element;
120
-
121
- export { OneContext, OneProvider, type OneThirdwebConfig, OneThirdwebProvider, type OneThirdwebProviderProps, useOne, useOneAuth, useOneEngine, useOneOnramp, useOneSwap, useOneTrading, useOneWallet, useThirdwebClient };
121
+ export { OneContext, OneProvider, type ThirdwebWalletConfig as OneThirdwebConfig, OneProvider as OneThirdwebProvider, type ThirdwebAuthOptions, type ThirdwebWalletConfig, useOne, useOneAuth, useOneEngine, useOneOnramp, useOneSwap, useOneTrading, useOneWallet, useThirdwebClient };
@@ -1,15 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var React2 = require('react');
4
- var jsxRuntime = require('react/jsx-runtime');
3
+ var react = require('react');
5
4
  var thirdweb = require('thirdweb');
6
- var react = require('thirdweb/react');
5
+ var react$1 = require('thirdweb/react');
7
6
  var wallets = require('thirdweb/wallets');
8
7
  var chains = require('thirdweb/chains');
9
-
10
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
-
12
- var React2__default = /*#__PURE__*/_interopDefault(React2);
8
+ var jsxRuntime = require('react/jsx-runtime');
13
9
 
14
10
  // src/config/index.ts
15
11
  var DEFAULT_ENGINE_URL = "https://api.one23.io";
@@ -1309,32 +1305,116 @@ var OneEngineClient = class {
1309
1305
  function createOneEngineClient(options) {
1310
1306
  return new OneEngineClient(options);
1311
1307
  }
1312
- var OneContext = React2.createContext(null);
1308
+ var OneContext = react.createContext(null);
1309
+ var DEFAULT_AUTH_OPTIONS = {
1310
+ email: true,
1311
+ phone: false,
1312
+ google: true,
1313
+ apple: true,
1314
+ facebook: false,
1315
+ discord: false,
1316
+ passkey: true,
1317
+ guest: false
1318
+ };
1319
+ function createWalletConfig(config2) {
1320
+ const authOptions = { ...DEFAULT_AUTH_OPTIONS, ...config2.authOptions };
1321
+ const authMethods = [];
1322
+ if (authOptions.google) authMethods.push("google");
1323
+ if (authOptions.apple) authMethods.push("apple");
1324
+ if (authOptions.facebook) authMethods.push("facebook");
1325
+ if (authOptions.discord) authMethods.push("discord");
1326
+ if (authOptions.passkey) authMethods.push("passkey");
1327
+ const inApp = wallets.inAppWallet({
1328
+ auth: {
1329
+ options: authMethods
1330
+ },
1331
+ metadata: config2.appName ? {
1332
+ name: config2.appName,
1333
+ image: config2.appIcon ? { src: config2.appIcon, width: 100, height: 100 } : void 0
1334
+ } : void 0
1335
+ });
1336
+ if (config2.sponsorGas) {
1337
+ const chain = config2.defaultChain || chains.base;
1338
+ return [
1339
+ wallets.smartWallet({
1340
+ chain,
1341
+ sponsorGas: true
1342
+ })
1343
+ ];
1344
+ }
1345
+ return [inApp];
1346
+ }
1313
1347
  function OneProvider({
1314
1348
  children,
1315
1349
  config: config2,
1350
+ thirdweb: thirdwebConfig = {},
1316
1351
  autoFetchBalance = true
1317
1352
  }) {
1318
- React2.useMemo(() => {
1353
+ react.useMemo(() => {
1319
1354
  initOneSDK(config2);
1320
1355
  }, [config2]);
1321
- const [isInitialized, setIsInitialized] = React2.useState(true);
1322
- const engine = React2.useMemo(() => createOneEngineClient({
1356
+ const [isInitialized, setIsInitialized] = react.useState(true);
1357
+ const engine = react.useMemo(() => createOneEngineClient({
1323
1358
  baseUrl: config2.oneEngineUrl,
1324
1359
  clientId: config2.oneClientId,
1325
1360
  secretKey: config2.oneSecretKey
1326
1361
  }), [config2]);
1327
- const [user, setUser] = React2.useState(null);
1328
- const [accessToken, setAccessToken] = React2.useState(null);
1329
- const [authLoading, setAuthLoading] = React2.useState(true);
1330
- const sendOtp = React2.useCallback(async (email) => {
1362
+ const [thirdwebClientId, setThirdwebClientId] = react.useState(null);
1363
+ const [thirdwebLoading, setThirdwebLoading] = react.useState(true);
1364
+ const [thirdwebError, setThirdwebError] = react.useState(null);
1365
+ react.useEffect(() => {
1366
+ const fetchClientConfig = async () => {
1367
+ try {
1368
+ const response = await fetch(`${config2.oneEngineUrl}/v1/config/thirdweb`);
1369
+ if (response.ok) {
1370
+ const data = await response.json();
1371
+ if (data.success && data.data?.clientId) {
1372
+ setThirdwebClientId(data.data.clientId);
1373
+ } else {
1374
+ const envClientId = typeof window !== "undefined" ? window.__NEXT_PUBLIC_THIRDWEB_CLIENT_ID : process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID;
1375
+ if (envClientId) {
1376
+ setThirdwebClientId(envClientId);
1377
+ } else {
1378
+ setThirdwebError("Failed to load wallet configuration");
1379
+ }
1380
+ }
1381
+ } else {
1382
+ const envClientId = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID;
1383
+ if (envClientId) {
1384
+ setThirdwebClientId(envClientId);
1385
+ } else {
1386
+ setThirdwebError("Wallet service unavailable");
1387
+ }
1388
+ }
1389
+ } catch (err) {
1390
+ const envClientId = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID;
1391
+ if (envClientId) {
1392
+ setThirdwebClientId(envClientId);
1393
+ } else {
1394
+ console.warn("Failed to fetch thirdweb config:", err);
1395
+ }
1396
+ } finally {
1397
+ setThirdwebLoading(false);
1398
+ }
1399
+ };
1400
+ fetchClientConfig();
1401
+ }, [config2.oneEngineUrl]);
1402
+ const thirdwebClient = react.useMemo(() => {
1403
+ if (!thirdwebClientId) return null;
1404
+ return thirdweb.createThirdwebClient({ clientId: thirdwebClientId });
1405
+ }, [thirdwebClientId]);
1406
+ react.useMemo(() => createWalletConfig(thirdwebConfig), [thirdwebConfig]);
1407
+ const [user, setUser] = react.useState(null);
1408
+ const [accessToken, setAccessToken] = react.useState(null);
1409
+ const [authLoading, setAuthLoading] = react.useState(true);
1410
+ const sendOtp = react.useCallback(async (email) => {
1331
1411
  const result = await engine.sendEmailOtp(email);
1332
1412
  if (!result.success) {
1333
1413
  return { success: false, error: result.error?.message };
1334
1414
  }
1335
1415
  return { success: true };
1336
1416
  }, [engine]);
1337
- const verifyOtp = React2.useCallback(async (email, otp) => {
1417
+ const verifyOtp = react.useCallback(async (email, otp) => {
1338
1418
  const result = await engine.verifyEmailOtp(email, otp);
1339
1419
  if (!result.success || !result.data) {
1340
1420
  return { success: false, error: result.error?.message };
@@ -1345,13 +1425,13 @@ function OneProvider({
1345
1425
  engine.setAccessToken(token);
1346
1426
  return { success: true };
1347
1427
  }, [engine]);
1348
- const signOut = React2.useCallback(async () => {
1428
+ const signOut = react.useCallback(async () => {
1349
1429
  await engine.signOut();
1350
1430
  setUser(null);
1351
1431
  setAccessToken(null);
1352
1432
  engine.clearAccessToken();
1353
1433
  }, [engine]);
1354
- const refreshUser = React2.useCallback(async () => {
1434
+ const refreshUser = react.useCallback(async () => {
1355
1435
  try {
1356
1436
  if (accessToken) {
1357
1437
  engine.setAccessToken(accessToken);
@@ -1364,14 +1444,14 @@ function OneProvider({
1364
1444
  setAuthLoading(false);
1365
1445
  }
1366
1446
  }, [engine, accessToken]);
1367
- React2.useEffect(() => {
1447
+ react.useEffect(() => {
1368
1448
  refreshUser();
1369
1449
  }, []);
1370
- const [walletAddress, setWalletAddress] = React2.useState(null);
1371
- const [walletBalance, setWalletBalance] = React2.useState(null);
1372
- const [walletLoading, setWalletLoading] = React2.useState(false);
1373
- const [walletError, setWalletError] = React2.useState(null);
1374
- const fetchBalance = React2.useCallback(async (chains) => {
1450
+ const [walletAddress, setWalletAddress] = react.useState(null);
1451
+ const [walletBalance, setWalletBalance] = react.useState(null);
1452
+ const [walletLoading, setWalletLoading] = react.useState(false);
1453
+ const [walletError, setWalletError] = react.useState(null);
1454
+ const fetchBalance = react.useCallback(async (chains) => {
1375
1455
  if (!walletAddress) return;
1376
1456
  setWalletLoading(true);
1377
1457
  setWalletError(null);
@@ -1388,18 +1468,18 @@ function OneProvider({
1388
1468
  setWalletLoading(false);
1389
1469
  }
1390
1470
  }, [walletAddress, engine]);
1391
- const refreshBalance = React2.useCallback(async () => {
1471
+ const refreshBalance = react.useCallback(async () => {
1392
1472
  await fetchBalance();
1393
1473
  }, [fetchBalance]);
1394
- React2.useEffect(() => {
1474
+ react.useEffect(() => {
1395
1475
  if (autoFetchBalance && walletAddress && isInitialized) {
1396
1476
  fetchBalance();
1397
1477
  }
1398
1478
  }, [walletAddress, autoFetchBalance, isInitialized, fetchBalance]);
1399
- const [onrampOpen, setOnrampOpen] = React2.useState(false);
1400
- const [onrampUrl, setOnrampUrl] = React2.useState(null);
1401
- const [onrampSessionId, setOnrampSessionId] = React2.useState(null);
1402
- const openOnramp = React2.useCallback(async (options) => {
1479
+ const [onrampOpen, setOnrampOpen] = react.useState(false);
1480
+ const [onrampUrl, setOnrampUrl] = react.useState(null);
1481
+ const [onrampSessionId, setOnrampSessionId] = react.useState(null);
1482
+ const openOnramp = react.useCallback(async (options) => {
1403
1483
  if (!walletAddress) return;
1404
1484
  const result = await engine.createOnrampSession({
1405
1485
  walletAddress,
@@ -1413,36 +1493,36 @@ function OneProvider({
1413
1493
  setOnrampOpen(true);
1414
1494
  }
1415
1495
  }, [walletAddress, engine]);
1416
- const closeOnramp = React2.useCallback(() => {
1496
+ const closeOnramp = react.useCallback(() => {
1417
1497
  setOnrampOpen(false);
1418
1498
  setOnrampUrl(null);
1419
1499
  }, []);
1420
- const getOnrampQuote = React2.useCallback(async (fiatCurrency, fiatAmount, cryptoCurrency) => {
1500
+ const getOnrampQuote = react.useCallback(async (fiatCurrency, fiatAmount, cryptoCurrency) => {
1421
1501
  const result = await engine.getOnrampQuote(fiatCurrency, fiatAmount, cryptoCurrency);
1422
1502
  return result.success ? result.data : null;
1423
1503
  }, [engine]);
1424
- const getSwapQuote = React2.useCallback(async (request) => {
1504
+ const getSwapQuote = react.useCallback(async (request) => {
1425
1505
  const result = await engine.getSwapQuote(request);
1426
1506
  return result.success ? result.data || null : null;
1427
1507
  }, [engine]);
1428
- const executeSwap = React2.useCallback(async (quoteId) => {
1508
+ const executeSwap = react.useCallback(async (quoteId) => {
1429
1509
  if (!walletAddress) return null;
1430
1510
  const result = await engine.executeSwap({ quoteId, walletAddress });
1431
1511
  return result.success ? result.data : null;
1432
1512
  }, [engine, walletAddress]);
1433
- const getSupportedTokens = React2.useCallback(async (chainId) => {
1513
+ const getSupportedTokens = react.useCallback(async (chainId) => {
1434
1514
  const result = await engine.getSupportedSwapTokens(chainId);
1435
1515
  return result.success && result.data ? result.data.tokens : [];
1436
1516
  }, [engine]);
1437
- const getSupportedChains = React2.useCallback(async () => {
1517
+ const getSupportedChains = react.useCallback(async () => {
1438
1518
  const result = await engine.getSupportedSwapChains();
1439
1519
  return result.success && result.data ? result.data.chains : [];
1440
1520
  }, [engine]);
1441
- const [strategies, setStrategies] = React2.useState([]);
1442
- const [orders, setOrders] = React2.useState([]);
1443
- const [portfolioStats, setPortfolioStats] = React2.useState(null);
1444
- const [tradingLoading, setTradingLoading] = React2.useState(false);
1445
- const fetchStrategies = React2.useCallback(async () => {
1521
+ const [strategies, setStrategies] = react.useState([]);
1522
+ const [orders, setOrders] = react.useState([]);
1523
+ const [portfolioStats, setPortfolioStats] = react.useState(null);
1524
+ const [tradingLoading, setTradingLoading] = react.useState(false);
1525
+ const fetchStrategies = react.useCallback(async () => {
1446
1526
  setTradingLoading(true);
1447
1527
  try {
1448
1528
  const result = await engine.getStrategies();
@@ -1453,19 +1533,19 @@ function OneProvider({
1453
1533
  setTradingLoading(false);
1454
1534
  }
1455
1535
  }, [engine]);
1456
- const fetchOrders = React2.useCallback(async () => {
1536
+ const fetchOrders = react.useCallback(async () => {
1457
1537
  const result = await engine.getUserOrders();
1458
1538
  if (result.success && result.data) {
1459
1539
  setOrders(result.data);
1460
1540
  }
1461
1541
  }, [engine]);
1462
- const fetchPortfolio = React2.useCallback(async () => {
1542
+ const fetchPortfolio = react.useCallback(async () => {
1463
1543
  const result = await engine.getPortfolioStats();
1464
1544
  if (result.success && result.data) {
1465
1545
  setPortfolioStats(result.data);
1466
1546
  }
1467
1547
  }, [engine]);
1468
- const createOrder = React2.useCallback(async (strategyId, amount, currency) => {
1548
+ const createOrder = react.useCallback(async (strategyId, amount, currency) => {
1469
1549
  const result = await engine.createOrder(strategyId, amount, currency);
1470
1550
  if (result.success) {
1471
1551
  await fetchOrders();
@@ -1473,10 +1553,11 @@ function OneProvider({
1473
1553
  }
1474
1554
  return result;
1475
1555
  }, [engine, fetchOrders, fetchPortfolio]);
1476
- const contextValue = React2.useMemo(() => ({
1556
+ const contextValue = react.useMemo(() => ({
1477
1557
  isInitialized,
1478
1558
  config: isInitialized ? config2 : null,
1479
1559
  engine,
1560
+ thirdwebClient,
1480
1561
  auth: {
1481
1562
  user,
1482
1563
  isAuthenticated: !!user,
@@ -1496,7 +1577,9 @@ function OneProvider({
1496
1577
  error: walletError,
1497
1578
  setAddress: setWalletAddress,
1498
1579
  fetchBalance,
1499
- refreshBalance
1580
+ refreshBalance,
1581
+ thirdwebClient,
1582
+ isThirdwebReady: !thirdwebLoading && !!thirdwebClient
1500
1583
  },
1501
1584
  onramp: {
1502
1585
  isOpen: onrampOpen,
@@ -1526,6 +1609,8 @@ function OneProvider({
1526
1609
  isInitialized,
1527
1610
  config2,
1528
1611
  engine,
1612
+ thirdwebClient,
1613
+ thirdwebLoading,
1529
1614
  user,
1530
1615
  authLoading,
1531
1616
  accessToken,
@@ -1558,10 +1643,14 @@ function OneProvider({
1558
1643
  fetchPortfolio,
1559
1644
  createOrder
1560
1645
  ]);
1561
- return /* @__PURE__ */ jsxRuntime.jsx(OneContext.Provider, { value: contextValue, children });
1646
+ const content = /* @__PURE__ */ jsxRuntime.jsx(OneContext.Provider, { value: contextValue, children });
1647
+ if (thirdwebClient) {
1648
+ return /* @__PURE__ */ jsxRuntime.jsx(react$1.ThirdwebProvider, { children: content });
1649
+ }
1650
+ return content;
1562
1651
  }
1563
1652
  function useOne() {
1564
- const context = React2.useContext(OneContext);
1653
+ const context = react.useContext(OneContext);
1565
1654
  if (!context) {
1566
1655
  throw new Error("useOne must be used within a OneProvider");
1567
1656
  }
@@ -1591,111 +1680,9 @@ function useOneEngine() {
1591
1680
  const { engine } = useOne();
1592
1681
  return engine;
1593
1682
  }
1594
- var DEFAULT_AUTH_OPTIONS = {
1595
- email: true,
1596
- phone: false,
1597
- google: true,
1598
- apple: true,
1599
- facebook: false,
1600
- discord: false,
1601
- passkey: true,
1602
- guest: false
1603
- };
1604
- var ThirdwebClientContext = React2__default.default.createContext(null);
1605
1683
  function useThirdwebClient() {
1606
- const client = React2__default.default.useContext(ThirdwebClientContext);
1607
- if (!client) {
1608
- throw new Error("useThirdwebClient must be used within OneThirdwebProvider");
1609
- }
1610
- return client;
1611
- }
1612
- function createWalletConfig(config2) {
1613
- const authOptions = { ...DEFAULT_AUTH_OPTIONS, ...config2.authOptions };
1614
- const authMethods = [];
1615
- if (authOptions.google) authMethods.push("google");
1616
- if (authOptions.apple) authMethods.push("apple");
1617
- if (authOptions.facebook) authMethods.push("facebook");
1618
- if (authOptions.discord) authMethods.push("discord");
1619
- if (authOptions.passkey) authMethods.push("passkey");
1620
- const inApp = wallets.inAppWallet({
1621
- auth: {
1622
- options: authMethods
1623
- },
1624
- metadata: config2.appName ? {
1625
- name: config2.appName,
1626
- image: config2.appIcon ? { src: config2.appIcon, width: 100, height: 100 } : void 0
1627
- } : void 0
1628
- });
1629
- if (config2.sponsorGas) {
1630
- const chain = config2.defaultChain || chains.base;
1631
- return [
1632
- wallets.smartWallet({
1633
- chain,
1634
- sponsorGas: true
1635
- })
1636
- ];
1637
- }
1638
- return [inApp];
1639
- }
1640
- var DEFAULT_ENGINE_URL2 = process.env.NEXT_PUBLIC_ONE_ENGINE_URL || "/api";
1641
- function OneThirdwebProvider({
1642
- children,
1643
- config: config2 = {}
1644
- }) {
1645
- const [clientId, setClientId] = React2.useState(null);
1646
- const [isLoading, setIsLoading] = React2.useState(true);
1647
- const [error, setError] = React2.useState(null);
1648
- React2.useEffect(() => {
1649
- const fetchClientConfig = async () => {
1650
- try {
1651
- const engineUrl = config2.engineUrl || DEFAULT_ENGINE_URL2;
1652
- const response = await fetch(`${engineUrl}/v1/config/thirdweb`);
1653
- if (response.ok) {
1654
- const data = await response.json();
1655
- if (data.success && data.data?.clientId) {
1656
- setClientId(data.data.clientId);
1657
- } else {
1658
- const envClientId = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID;
1659
- if (envClientId) {
1660
- setClientId(envClientId);
1661
- } else {
1662
- setError("Failed to load wallet configuration");
1663
- }
1664
- }
1665
- } else {
1666
- const envClientId = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID;
1667
- if (envClientId) {
1668
- setClientId(envClientId);
1669
- } else {
1670
- setError("Wallet service unavailable");
1671
- }
1672
- }
1673
- } catch (err) {
1674
- const envClientId = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID;
1675
- if (envClientId) {
1676
- setClientId(envClientId);
1677
- } else {
1678
- console.error("Failed to fetch thirdweb config:", err);
1679
- setError("Failed to initialize wallet");
1680
- }
1681
- } finally {
1682
- setIsLoading(false);
1683
- }
1684
- };
1685
- fetchClientConfig();
1686
- }, [config2.engineUrl]);
1687
- const client = React2.useMemo(() => {
1688
- if (!clientId) return null;
1689
- return thirdweb.createThirdwebClient({ clientId });
1690
- }, [clientId]);
1691
- React2.useMemo(() => createWalletConfig(config2), [config2]);
1692
- if (isLoading) {
1693
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", minHeight: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#9ca3af" }, children: "Initializing wallet..." }) });
1694
- }
1695
- if (error || !client) {
1696
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", minHeight: "100px" }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: { color: "#ef4444" }, children: error || "Wallet initialization failed" }) });
1697
- }
1698
- return /* @__PURE__ */ jsxRuntime.jsx(ThirdwebClientContext.Provider, { value: client, children: /* @__PURE__ */ jsxRuntime.jsx(react.ThirdwebProvider, { children }) });
1684
+ const { thirdwebClient } = useOne();
1685
+ return thirdwebClient;
1699
1686
  }
1700
1687
 
1701
1688
  Object.defineProperty(exports, "inAppWallet", {
@@ -1728,7 +1715,7 @@ Object.defineProperty(exports, "polygon", {
1728
1715
  });
1729
1716
  exports.OneContext = OneContext;
1730
1717
  exports.OneProvider = OneProvider;
1731
- exports.OneThirdwebProvider = OneThirdwebProvider;
1718
+ exports.OneThirdwebProvider = OneProvider;
1732
1719
  exports.useOne = useOne;
1733
1720
  exports.useOneAuth = useOneAuth;
1734
1721
  exports.useOneEngine = useOneEngine;