diff --git a/README.md b/README.md index d497f053c..7ae5e9cfc 100644 --- a/README.md +++ b/README.md @@ -248,10 +248,9 @@ The file `common.ts` with type [`AppConfig`](src/config/types.ts) contains impor - `appUrl`: The URL of the app. - `carbonApi`: The URL of the API. -- `walletConnectProjectId`: The WalletConnect project ID If you wish to add walletConnect, make sure to add it to `selectableConnectionTypes` as well. -- `selectedConnectors`: List of connectors to make available by default in the wallet selection modal that will be shown even if the connector is not injected. +- `selectedConnectors`: List of connectors to make available by default in the wallet selection modal that will be shown even if the connector is not injected. ex ['MetaMask', 'WalletConnect', 'Coinbase Wallet', 'Safe'] - `blockedConnectors`: List of EIP-6963 injected connectors names to block in the wallet selection modal. -- `isSimulatorEnabled`: Flag to enable the simulation page. +- `walletConnectProjectId`: The WalletConnect project ID If you wish to add walletConnect, make sure to add it to `selectableConnectionTypes` as well. - `network` - `name`: Network name. - `logoUrl`: Network logo URL. @@ -263,11 +262,24 @@ The file `common.ts` with type [`AppConfig`](src/config/types.ts) contains impor - `defaultTokenPair`: Default token pair to be used in the app when opening the trade, explore, and simulation pages. - `popularPairs`: List of popular pairs to be used in the app when opening the token selection modal. - `popularTokens`: List of popular tokens to be used in the app when opening the token selection modal. -- `addresses`/`carbon` and `addresses/utils`: CarbonController, Voucher and multicall3 contract addresses. +- `addresses` + - `tokens`: + - `ZERO`: Address of the zero token + - `carbon`: + - `carbonController`: Address of CarbonController contract + - `voucher`: Address of Voucher contract + - `utils`: + - `multicall3` + - `address`: Address of the multicall3 contract + - `blockCreated`: Block of the creation of the multicall3 - `tokenListOverride`: Token list override to be used in the app when fetching the token list. Tokens in the list will override any other token with the same address. - `tokenLists`: List of token lists including the uri and the parser name to be used to parse the token list. Please update the tokenParserMap in the `src/config/utils.ts` file to include the parser name and the parser function. -- `sdk`/`cacheTTL`: When the app loads, it will ignore any cached data if it is older than the cacheTTL time in milliseconds. If set to 0, the app will always ignore the cache data and fetch new data on load. +- `sdk`: + - `cacheTTL`: When the app loads, it will ignore any cached data if it is older than the cacheTTL time in milliseconds. If set to 0, the app will always ignore the cache data and fetch new data on load. +- `tenderly` + - `faucetTokens`: List of address to get tokens from in the debug page - `ui` + - `showSimulator`: Flag to enable the simulation page. - `priceChart`: use `tradingView` chart or `native` chart for token pair price history. You need to provide a backend with price history endpoint to support `native` view. - `useGradientBranding`: Flag to enable gradient styles for buttons. - `tradeCount`: Display the amount of trades in the explorer page. diff --git a/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png b/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png index 6829b3aa2..21186cabc 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png and b/e2e/screenshots/simulator/recurring/Recurring_range_limit/simulator-input-price.png differ diff --git a/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-results-animation.png b/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-results-animation.png index 9d36b78da..4400e81ba 100644 Binary files a/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-results-animation.png and b/e2e/screenshots/simulator/recurring/Recurring_range_range/simulator-results-animation.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png index 7c3c27db6..70d1bb744 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/my-strategy.png b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/my-strategy.png index 655a6dec5..43bad0126 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/my-strategy.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/deposit/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/deposit/form.png index 20c921452..ac5d38ff2 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_limit/deposit/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_limit/deposit/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_buy_range/deposit/form.png b/e2e/screenshots/strategy/disposable/Disposable_buy_range/deposit/form.png index 1164ba92f..dae52990f 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_buy_range/deposit/form.png and b/e2e/screenshots/strategy/disposable/Disposable_buy_range/deposit/form.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_sell_limit/create/my-strategy.png b/e2e/screenshots/strategy/disposable/Disposable_sell_limit/create/my-strategy.png index 8b8940a04..fee17fffd 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_sell_limit/create/my-strategy.png and b/e2e/screenshots/strategy/disposable/Disposable_sell_limit/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/disposable/Disposable_sell_range/create/my-strategy.png b/e2e/screenshots/strategy/disposable/Disposable_sell_range/create/my-strategy.png index 776f9cc03..1548797fa 100644 Binary files a/e2e/screenshots/strategy/disposable/Disposable_sell_range/create/my-strategy.png and b/e2e/screenshots/strategy/disposable/Disposable_sell_range/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/overlapping/Overlapping/deposit/form.png b/e2e/screenshots/strategy/overlapping/Overlapping/deposit/form.png index 906d385b5..48f025023 100644 Binary files a/e2e/screenshots/strategy/overlapping/Overlapping/deposit/form.png and b/e2e/screenshots/strategy/overlapping/Overlapping/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_range/create/my-strategy.png b/e2e/screenshots/strategy/recurring/Recurring_limit_range/create/my-strategy.png index 3c006f5ba..293670ad3 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_range/create/my-strategy.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_range/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png index 28ce48a03..543831b2d 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_limit_range/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/form.png index b832884cd..78cdd4d14 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/my-strategy.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/my-strategy.png index 9172cadac..57eced296 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/my-strategy.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png index af13f6508..36ca07eb5 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_limit/deposit/form.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_range/create/my-strategy.png b/e2e/screenshots/strategy/recurring/Recurring_range_range/create/my-strategy.png index c53f9b237..79b68b258 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_range/create/my-strategy.png and b/e2e/screenshots/strategy/recurring/Recurring_range_range/create/my-strategy.png differ diff --git a/e2e/screenshots/strategy/recurring/Recurring_range_range/deposit/form.png b/e2e/screenshots/strategy/recurring/Recurring_range_range/deposit/form.png index b101b3a0e..ebcc5628d 100644 Binary files a/e2e/screenshots/strategy/recurring/Recurring_range_range/deposit/form.png and b/e2e/screenshots/strategy/recurring/Recurring_range_range/deposit/form.png differ diff --git a/src/components/core/menu/menuItems.ts b/src/components/core/menu/menuItems.ts index b9ed6af80..1e02bfec5 100644 --- a/src/components/core/menu/menuItems.ts +++ b/src/components/core/menu/menuItems.ts @@ -24,7 +24,7 @@ export const menuItems: MenuItem[] = [ href: '/explore', testid: 'explore-page', }, - ...(!config.isSimulatorEnabled + ...(!config.ui.showSimulator ? [] : [ { diff --git a/src/components/debug/DebugConfig.tsx b/src/components/debug/DebugConfig.tsx index def02243d..21cec4f5e 100644 --- a/src/components/debug/DebugConfig.tsx +++ b/src/components/debug/DebugConfig.tsx @@ -24,12 +24,28 @@ export const DebugConfig = () => { lsService.removeItem('configOverride'); } else { const parsedConfig = JSON.parse(configOverride || ''); - v.parse(v.partial(AppConfigSchema), parsedConfig); - lsService.setItem('configOverride', parsedConfig); + const result = v.safeParse(v.partial(AppConfigSchema), parsedConfig); + if (result.success) { + for (let i = 0; i < localStorage.length; i++) { + localStorage.removeItem(localStorage.key(i)!); + } + lsService.setItem('configOverride', parsedConfig); + window?.location.reload(); + } else { + const errors = result.issues + .map((issue) => { + const path = issue.path + ?.map((p) => p.type === 'object' && p.key) + .join('.'); + return `[${path}]: ${issue.message}`; + }) + .join('\n'); + console.error(result.issues); + setError(errors); + } } - setError(''); - window?.location.reload(); } catch (error) { + console.log(error); setError(errorMessage); } }; diff --git a/src/components/strategies/overview/strategyBlock/StrategyBlockManage.tsx b/src/components/strategies/overview/strategyBlock/StrategyBlockManage.tsx index 554ca8b2c..3f65cf628 100644 --- a/src/components/strategies/overview/strategyBlock/StrategyBlockManage.tsx +++ b/src/components/strategies/overview/strategyBlock/StrategyBlockManage.tsx @@ -83,7 +83,7 @@ export const StrategyBlockManage: FC = (props) => { const isDisposable = isDisposableStrategy(strategy); - if (!isDisposable && config.isSimulatorEnabled) { + if (!isDisposable && config.ui.showSimulator) { items.push({ id: 'simulate', name: 'Simulate Strategy', diff --git a/src/config/blast/common.ts b/src/config/blast/common.ts index 597e14f02..dac73acc3 100644 --- a/src/config/blast/common.ts +++ b/src/config/blast/common.ts @@ -25,7 +25,6 @@ export const commonConfig: AppConfig = { selectedConnectors: ['MetaMask', 'Coinbase Wallet', 'Safe'], blockedConnectors: ['Tailwind', 'Compass Wallet', 'Seif'], walletConnectProjectId: '', - isSimulatorEnabled: false, policiesLastUpdated: '31 Jul, 2024', network: { name: 'Blast Network', @@ -104,8 +103,6 @@ export const commonConfig: AppConfig = { }, ], tenderly: { - nativeTokenDonorAccount: '0xf89d7b9c864f589bbF53a82105107622B35EaA40', - faucetAmount: 1000, faucetTokens: [ { donorAccount: '0xD533Ca259b330c7A88f74E000a3FaEa2d63B7972', @@ -128,6 +125,7 @@ export const commonConfig: AppConfig = { ], }, ui: { + showSimulator: false, priceChart: 'tradingView', useGradientBranding: true, tradeCount: false, diff --git a/src/config/celo/common.ts b/src/config/celo/common.ts index 497fab242..183e95e33 100644 --- a/src/config/celo/common.ts +++ b/src/config/celo/common.ts @@ -22,7 +22,6 @@ export const commonConfig: AppConfig = { selectedConnectors: ['MetaMask', 'Coinbase Wallet', 'Safe', 'WalletConnect'], blockedConnectors: ['Tailwind', 'Compass Wallet', 'Seif'], walletConnectProjectId: 'f9d8863ab6c03f2293d7d56d7c0c0853', - isSimulatorEnabled: true, policiesLastUpdated: '31 Jul, 2024', network: { name: 'Celo Network', @@ -115,8 +114,6 @@ export const commonConfig: AppConfig = { }, ], tenderly: { - nativeTokenDonorAccount: '0xf89d7b9c864f589bbF53a82105107622B35EaA40', - faucetAmount: 1000, faucetTokens: [ { donorAccount: '0xD533Ca259b330c7A88f74E000a3FaEa2d63B7972', @@ -139,6 +136,7 @@ export const commonConfig: AppConfig = { ], }, ui: { + showSimulator: true, priceChart: 'native', useGradientBranding: true, tradeCount: true, diff --git a/src/config/configSchema.ts b/src/config/configSchema.ts index 6b8b0f8db..89aa2e796 100644 --- a/src/config/configSchema.ts +++ b/src/config/configSchema.ts @@ -17,7 +17,6 @@ export const AppConfigSchema = v.object({ selectedConnectors: ConnectorSchema, blockedConnectors: v.optional(ConnectorSchema), walletConnectProjectId: v.string(), - isSimulatorEnabled: v.boolean(), sentryDSN: v.optional(v.string()), policiesLastUpdated: v.optional(v.string()), network: v.object({ @@ -93,8 +92,6 @@ export const AppConfigSchema = v.object({ ), ]), tenderly: v.object({ - nativeTokenDonorAccount: v.string(), - faucetAmount: v.number(), faucetTokens: v.array( v.object({ decimals: v.number(), @@ -105,6 +102,7 @@ export const AppConfigSchema = v.object({ ), }), ui: v.object({ + showSimulator: v.boolean(), priceChart: v.union([v.literal('native'), v.literal('tradingView')]), useGradientBranding: v.optional(v.boolean()), tradeCount: v.optional(v.boolean()), diff --git a/src/config/demo/common.ts b/src/config/demo/common.ts index 9d425228d..e93e9758e 100644 --- a/src/config/demo/common.ts +++ b/src/config/demo/common.ts @@ -1,11 +1,6 @@ import { AppConfig } from 'config/types'; -const addresses = { - ZERO: '0x0000000000000000000000000000000000000000', -}; - export const commonConfig: AppConfig = { - hidden: true, mode: 'development', appName: '', appUrl: '', @@ -13,7 +8,6 @@ export const commonConfig: AppConfig = { selectedConnectors: ['MetaMask'], blockedConnectors: [], walletConnectProjectId: '', - isSimulatorEnabled: false, policiesLastUpdated: '', network: { name: 'Demo Network', @@ -24,7 +18,7 @@ export const commonConfig: AppConfig = { url: '', }, rpc: { - url: import.meta.env.VITE_CHAIN_RPC_URL, + url: import.meta.env.VITE_CHAIN_RPC_URL ?? '', }, defaultLimitedApproval: true, gasToken: { @@ -45,7 +39,9 @@ export const commonConfig: AppConfig = { quote: [], }, addresses: { - tokens: addresses, + tokens: { + ZERO: '0x0000000000000000000000000000000000000000', + }, carbon: { carbonController: '', voucher: '', @@ -60,30 +56,10 @@ export const commonConfig: AppConfig = { tokenListOverride: [], tokenLists: [], tenderly: { - nativeTokenDonorAccount: '', - faucetAmount: 1000, - faucetTokens: [ - { - donorAccount: '', - tokenContract: '', - decimals: 18, - symbol: '', - }, - { - donorAccount: '', - tokenContract: '', - decimals: 6, - symbol: '', - }, - { - donorAccount: '', - tokenContract: '', - decimals: 6, - symbol: '', - }, - ], + faucetTokens: [], }, ui: { + showSimulator: false, priceChart: 'tradingView', useGradientBranding: false, tradeCount: false, diff --git a/src/config/ethereum/common.ts b/src/config/ethereum/common.ts index b243f4db2..4ab8098fc 100644 --- a/src/config/ethereum/common.ts +++ b/src/config/ethereum/common.ts @@ -35,7 +35,6 @@ export const commonConfig: AppConfig = { selectedConnectors: ['MetaMask', 'WalletConnect', 'Coinbase Wallet', 'Safe'], blockedConnectors: ['Tailwind', 'Compass Wallet', 'Seif'], walletConnectProjectId: 'f9d8863ab6c03f2293d7d56d7c0c0853', - isSimulatorEnabled: true, policiesLastUpdated: '18 April, 2023', network: { name: 'Ethereum Network', @@ -148,8 +147,6 @@ export const commonConfig: AppConfig = { }, ], tenderly: { - nativeTokenDonorAccount: '0x00000000219ab540356cbb839cbe05303d7705fa', - faucetAmount: 1000, faucetTokens: [ { donorAccount: '0x0a59649758aa4d66e25f08dd01271e891fe52199', @@ -214,6 +211,7 @@ export const commonConfig: AppConfig = { ], }, ui: { + showSimulator: true, priceChart: 'native', useGradientBranding: true, tradeCount: false, diff --git a/src/config/sei/common.ts b/src/config/sei/common.ts index 1858fb2f6..7d5de61b5 100644 --- a/src/config/sei/common.ts +++ b/src/config/sei/common.ts @@ -23,7 +23,6 @@ export const commonConfig: AppConfig = { ], blockedConnectors: ['Tailwind'], walletConnectProjectId: '', - isSimulatorEnabled: true, policiesLastUpdated: '27 May, 2024', network: { name: 'Sei Network', @@ -91,8 +90,6 @@ export const commonConfig: AppConfig = { }, ], tenderly: { - nativeTokenDonorAccount: '0x3a7AB16485770c21B7543058De545E986284d0D3', - faucetAmount: 1000, faucetTokens: [ { donorAccount: '0x06b49C508f278a9219a6e45A7bcEbBC0aA1E2e7b', @@ -115,6 +112,7 @@ export const commonConfig: AppConfig = { ], }, ui: { + showSimulator: true, priceChart: 'native', useGradientBranding: true, tradeCount: true, diff --git a/src/libs/routing/routes/sim.tsx b/src/libs/routing/routes/sim.tsx index 84fdee106..d6b8e3d7a 100644 --- a/src/libs/routing/routes/sim.tsx +++ b/src/libs/routing/routes/sim.tsx @@ -32,7 +32,7 @@ export const simulatorInputRootRoute = createRoute({ path: '/', component: SimulatorPage, beforeLoad: ({ location }) => { - if (!config.isSimulatorEnabled) { + if (!config.ui.showSimulator) { throw redirect({ to: '/', replace: true }); } if ( diff --git a/src/libs/wagmi/wagmi.constants.ts b/src/libs/wagmi/wagmi.constants.ts index 2a084edc6..ab6e65154 100644 --- a/src/libs/wagmi/wagmi.constants.ts +++ b/src/libs/wagmi/wagmi.constants.ts @@ -4,7 +4,7 @@ import { tenderlyRpc } from 'utils/tenderly'; const IS_ENV_RPC = !!import.meta.env.VITE_CHAIN_RPC_URL; const CHAIN_RPC_URL = - tenderlyRpc || import.meta.env.VITE_CHAIN_RPC_URL || config.network.rpc.url; + tenderlyRpc || config.network.rpc.url || import.meta.env.VITE_CHAIN_RPC_URL; const CHAIN_RPC_HEADERS = tenderlyRpc || IS_ENV_RPC ? {} : config.network.rpc?.headers || {}; export const CHAIN_ID = config.network.chainId;