Skip to content

Commit c96c5c9

Browse files
committed
feat: wip override provider
1 parent 1c22066 commit c96c5c9

2 files changed

Lines changed: 26 additions & 9 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,
@@ -139,6 +140,13 @@ export function useWidgetConfig<T extends WidgetType>(
139140
};
140141
}
141142

143+
baseConfig.sdkConfig = {
144+
...(baseConfig.sdkConfig ?? {}),
145+
providers: makeProviders(),
146+
};
147+
148+
console.error('jumper init baseConfig', baseConfig);
149+
142150
return baseConfig;
143151
}, [
144152
sharedBase,

src/utils/instrumentation/lifiSdkConfig.ts

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

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

0 commit comments

Comments
 (0)