Skip to content

Commit 870404b

Browse files
committed
feat: wip override provider
1 parent 1ebc95e commit 870404b

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

src/components/Widgets/variants/widgetConfig/useWidgetConfig.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { AB_TEST_NAME } from '@/const/abtests';
2+
import { useABTest } from '@/hooks/useABTest';
3+
import { makeProviders } from '@/utils/instrumentation/lifiSdkConfig';
14
import { useAccount } from '@lifi/wallet-management';
2-
import { ChainType, HiddenUI, type WidgetConfig } from '@lifi/widget';
5+
import { HiddenUI, type WidgetConfig } from '@lifi/widget';
36
import merge from 'lodash/merge';
47
import { useMemo } from 'react';
5-
import { AB_TEST_NAME } from '@/const/abtests';
6-
import { useABTest } from '@/hooks/useABTest';
78
import type {
89
MainWidgetContext,
910
MissionWidgetContext,
@@ -143,6 +144,13 @@ export function useWidgetConfig<T extends WidgetType>(
143144
};
144145
}
145146

147+
baseConfig.sdkConfig = {
148+
...(baseConfig.sdkConfig ?? {}),
149+
providers: makeProviders(),
150+
};
151+
152+
console.error('jumper init baseConfig', baseConfig);
153+
146154
return baseConfig;
147155
}, [
148156
sharedBase,

src/utils/instrumentation/lifiSdkConfig.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,27 @@ export const GLOBAL_HEADERS = {
1818
// (injected by the layout <script> tag) is available when getApiUrl() runs.
1919
let _client: ReturnType<typeof createClient>;
2020

21+
/**
22+
* Define our custom providers in a function
23+
* used by the widget and our jumper sdk client.
24+
* This ensures the configuration is consistent accross the UI.
25+
*/
26+
export const makeProviders = () => {
27+
return [
28+
EthereumProvider(),
29+
JumperSolanaProvider(),
30+
BitcoinProvider(),
31+
SuiProvider(),
32+
TronProvider(),
33+
];
34+
};
35+
2136
function initClient() {
2237
if (!_client) {
2338
_client = createClient({
2439
apiKey: config.NEXT_PUBLIC_LIFI_API_KEY,
2540
apiUrl: getApiUrl(),
26-
providers: [
27-
EthereumProvider(),
28-
JumperSolanaProvider(),
29-
BitcoinProvider(),
30-
SuiProvider(),
31-
TronProvider(),
32-
],
41+
providers: makeProviders(),
3342
integrator: config.NEXT_PUBLIC_WIDGET_INTEGRATOR || 'jumper.exchange',
3443
rpcUrls: {
3544
...JSON.parse(config.NEXT_PUBLIC_CUSTOM_RPCS ?? '{}'),

0 commit comments

Comments
 (0)