Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/config/celo/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const commonConfig: AppConfig = {
},
// walkthroughId: 'uouygtywoj3c',
useOpenocean: false,
useSeedData: true,
useEIP7702: true,
},
};
1 change: 1 addition & 0 deletions src/config/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,6 @@ export const AppConfigSchema = v.object({
walkthroughId: v.optional(v.string()),
useOpenocean: v.optional(v.boolean()),
useEIP7702: v.optional(v.boolean()),
useSeedData: v.optional(v.boolean()),
}),
});
1 change: 1 addition & 0 deletions src/config/coti/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const commonConfig: AppConfig = {
'0xfA6f73446b17A97a56e464256DA54AD43c2Cbc3E',
],
},
useSeedData: true,
// walkthroughId: 'd2a5isof88vg',
},
};
1 change: 1 addition & 0 deletions src/config/ethereum/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,6 @@ export const commonConfig: AppConfig = {
// walkthroughId: 'i2ok96zcpzqw',
useOpenocean: false, // !navigator.webdriver, // use sdk in E2E
useEIP7702: true,
useSeedData: true,
},
};
1 change: 1 addition & 0 deletions src/config/sei/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const commonConfig: AppConfig = {
// rewardUrl: 'https://app.merkl.xyz/?chain=1329&protocol=carbon',
// walkthroughId: '51xep69sd3io',
useOpenocean: false, // true,
useSeedData: true,
useEIP7702: true,
},
};
1 change: 1 addition & 0 deletions src/config/tac/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ export const commonConfig: AppConfig = {
//},
// walkthroughId: 'vjbcftqceykr',
useOpenocean: false,
useSeedData: true,
},
};
1 change: 1 addition & 0 deletions src/config/ton/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ export const commonConfig: AppConfig = {
showTerms: true,
showPrivacy: true,
showCart: true,
useSeedData: true,
},
};
15 changes: 11 additions & 4 deletions src/libs/sdk/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { QueryKey } from 'libs/queries';
import { CHAIN_ID, RPC_URLS, RPC_HEADERS } from 'libs/wagmi';
import { buildTokenPairKey, setIntervalUsingTimeout } from 'utils/helpers';
import { ONE_HOUR_IN_MS } from 'utils/time';
import { carbonApi } from 'services/carbonApi';
import config from 'config';

const contractsConfig: ContractsConfig = {
Expand Down Expand Up @@ -51,10 +52,15 @@ export const SDKProvider: FC<Props> = ({ children }) => {
const initSDK = async () => {
try {
setIsLoading(true);
const { timestamp, ttl } = lsService.getItem('lastSdkCache') ?? {};
let cacheData: string | undefined;
if (timestamp && ttl && timestamp + ttl > Date.now()) {
cacheData = lsService.getItem('sdkCompressedCacheData');
if (import.meta.env.PROD && config.ui.useSeedData) {
const seed = await carbonApi.getSeedData();
cacheData = JSON.stringify(seed);
} else {
const { timestamp, ttl } = lsService.getItem('lastSdkCache') ?? {};
if (timestamp && ttl && timestamp + ttl > Date.now()) {
cacheData = lsService.getItem('sdkCompressedCacheData');
}
}
const initializer = carbonSDK.init(
CHAIN_ID,
Expand Down Expand Up @@ -86,6 +92,7 @@ export const SDKProvider: FC<Props> = ({ children }) => {
}, []);

useEffect(() => {
if (!isInitialized) return;
const invalidateQueriesByPair = (pair: TokenPair) => {
cache.invalidateQueries({
predicate: (query) =>
Expand Down Expand Up @@ -128,7 +135,7 @@ export const SDKProvider: FC<Props> = ({ children }) => {
Comlink.proxy(onCacheClearedCallback),
);
};
}, [cache]);
}, [cache, isInitialized]);

return (
<SdkContext.Provider
Expand Down
1 change: 1 addition & 0 deletions src/services/carbonApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const carbonApi = {
getTrending: () => get<Trending>('analytics/trending'),
getReward: (pair: string) => get<Reward>('merkle/data', { pair }),
getAllRewards: () => get<Reward[]>('merkle/all-data'),
getSeedData: () => get('seed-data'),
};

export { carbonApi };
Loading