@silentswap/react 0.0.45 → 0.0.47
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.
|
@@ -22,7 +22,7 @@ export const useWalletFacilitatorGroups = (wallet, setFacilitatorGroups) => {
|
|
|
22
22
|
}, [wallet, setFacilitatorGroups]);
|
|
23
23
|
};
|
|
24
24
|
const OrdersContext = createContext(undefined);
|
|
25
|
-
export const OrdersProvider = ({ children }) => {
|
|
25
|
+
export const OrdersProvider = ({ children, baseUrl: baseUrlProp }) => {
|
|
26
26
|
const [orders, setOrders] = useState([]);
|
|
27
27
|
const [loading, setLoading] = useState(false);
|
|
28
28
|
const [facilitatorGroups, setFacilitatorGroupsState] = useState([]);
|
|
@@ -42,12 +42,30 @@ export const OrdersProvider = ({ children }) => {
|
|
|
42
42
|
return '';
|
|
43
43
|
}
|
|
44
44
|
}, []);
|
|
45
|
-
// Get baseUrl from
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
// Get baseUrl from prop or from context (prefer prop for SSR compatibility)
|
|
46
|
+
let baseUrl = baseUrlProp;
|
|
47
|
+
if (!baseUrl) {
|
|
48
|
+
try {
|
|
49
|
+
const { config } = useSilentSwap();
|
|
50
|
+
baseUrl = config.baseUrl;
|
|
51
|
+
console.log('[OrdersContext] Using baseUrl from context:', baseUrl);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
// Context not available (e.g., during SSR)
|
|
55
|
+
// Orders won't be fetched until context is available
|
|
56
|
+
baseUrl = undefined;
|
|
57
|
+
console.warn('[OrdersContext] Context not available, skipping order fetching');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.log('[OrdersContext] Using baseUrl from prop:', baseUrl);
|
|
62
|
+
}
|
|
49
63
|
// Fetch recent orders from API (matches Svelte implementation)
|
|
50
64
|
const request_recent_orders = useCallback(async (sb58_auth_view) => {
|
|
65
|
+
if (!baseUrl) {
|
|
66
|
+
console.warn('[OrdersContext] baseUrl not available, skipping order fetch');
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
51
69
|
try {
|
|
52
70
|
// Request current orders from backend using facilitator auth
|
|
53
71
|
const d_res = await fetch(`${baseUrl}/recent?${new URLSearchParams({
|
|
@@ -95,6 +113,10 @@ export const OrdersProvider = ({ children }) => {
|
|
|
95
113
|
const currentGroups = facilitatorGroupsRef.current;
|
|
96
114
|
if (currentGroups.length === 0)
|
|
97
115
|
return;
|
|
116
|
+
if (!baseUrl) {
|
|
117
|
+
// Skip if baseUrl not available (e.g., during SSR)
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
98
120
|
setLoading(true);
|
|
99
121
|
try {
|
|
100
122
|
const a_all_orders = [];
|
|
@@ -205,5 +205,5 @@ export function SilentSwapProvider({ children, client, evmAddress, solAddress, c
|
|
|
205
205
|
baseUrl: computedBaseUrl,
|
|
206
206
|
};
|
|
207
207
|
}, [environment, baseUrl]);
|
|
208
|
-
return (_jsx(AssetsProvider, { children: _jsx(PricesProvider, { children: _jsx(BalancesProvider, { evmAddress: evmAddress, solAddress: solAddress, solanaRpcUrl: solanaRpcUrl, children: _jsx(SilentSwapInnerProvider, { client: client, connector: connector, isConnected: isConnected, evmAddress: evmAddress, solAddress: solAddress, solanaConnector: solanaConnector, solanaConnection: solanaConnection, environment: environment, config: config, solanaRpcUrl: solanaRpcUrl, walletClient: walletClient, children:
|
|
208
|
+
return (_jsx(AssetsProvider, { children: _jsx(PricesProvider, { children: _jsx(BalancesProvider, { evmAddress: evmAddress, solAddress: solAddress, solanaRpcUrl: solanaRpcUrl, children: _jsx(OrdersProvider, { baseUrl: config.baseUrl, children: _jsx(SilentSwapInnerProvider, { client: client, connector: connector, isConnected: isConnected, evmAddress: evmAddress, solAddress: solAddress, solanaConnector: solanaConnector, solanaConnection: solanaConnection, environment: environment, config: config, solanaRpcUrl: solanaRpcUrl, walletClient: walletClient, children: children }) }) }) }) }));
|
|
209
209
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silentswap/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.47",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ensdomains/ensjs": "^4.2.0",
|
|
26
|
-
"@silentswap/sdk": "0.0.
|
|
27
|
-
"@silentswap/ui-kit": "0.0.
|
|
26
|
+
"@silentswap/sdk": "0.0.47",
|
|
27
|
+
"@silentswap/ui-kit": "0.0.47",
|
|
28
28
|
"@solana/codecs-strings": "^5.1.0",
|
|
29
29
|
"@solana/kit": "^5.1.0",
|
|
30
30
|
"@solana/rpc": "^5.1.0",
|