diff --git a/packages/bridge-ui-v2/.env.example b/packages/bridge-ui-v2/.env.example index 76cd1143202..20f4b53ee4e 100644 --- a/packages/bridge-ui-v2/.env.example +++ b/packages/bridge-ui-v2/.env.example @@ -20,6 +20,6 @@ export SENTRY_AUTH_TOKEN= # Config jsons in base64 (see ReadMe, these are generated via a script) export CONFIGURED_BRIDGES= export CONFIGURED_CHAINS= -export CONFIGURED_CUSTOM_TOKEN= +export CONFIGURED_CUSTOM_TOKENS= export CONFIGURED_RELAYER= export CONFIGURED_EVENT_INDEXER= \ No newline at end of file diff --git a/packages/bridge-ui-v2/__mocks__/$env/static/public.ts b/packages/bridge-ui-v2/__mocks__/$env/static/public.ts index 247539b0269..6ec4ece4e74 100644 --- a/packages/bridge-ui-v2/__mocks__/$env/static/public.ts +++ b/packages/bridge-ui-v2/__mocks__/$env/static/public.ts @@ -6,5 +6,5 @@ export const PUBLIC_WALLETCONNECT_PROJECT_ID = '123'; export const PUBLIC_SENTRY_DSN = 'https://sentry.com'; export const CONFIGURED_BRIDGES = ''; export const CONFIGURED_CHAINS = ''; -export const CONFIGURED_CUSTOM_TOKEN = ''; +export const CONFIGURED_CUSTOM_TOKENS = ''; export const CONFIGURED_RELAYER = ''; diff --git a/packages/bridge-ui-v2/__mocks__/@wagmi/core.ts b/packages/bridge-ui-v2/__mocks__/@wagmi/core.ts index 0700d6c0cd0..bd257aabc46 100644 --- a/packages/bridge-ui-v2/__mocks__/@wagmi/core.ts +++ b/packages/bridge-ui-v2/__mocks__/@wagmi/core.ts @@ -14,8 +14,30 @@ export const fetchToken = vi.fn(); export const readContract = vi.fn(); -export const configureChains = vi.fn(() => { - return { publicClient: 'mockPublicClient' }; +const mockChains = [ + { + id: 0, + name: 'Debug', + network: 'Debug', + nativeCurrency: { + name: 'ETH', + symbol: 'ETH', + decimals: 18, + }, + rpcUrls: { + public: { http: ['some/url/'] }, + default: { http: ['some/url/'] }, + }, + }, +]; + +const mockPublicClient = () => { + return {}; +}; + +export const configureChains = vi.fn().mockReturnValue({ + chains: mockChains, + publicClient: mockPublicClient, }); export const createConfig = vi.fn(() => { diff --git a/packages/bridge-ui-v2/config/schemas/configuredCustomToken.schema.json b/packages/bridge-ui-v2/config/schemas/configuredCustomToken.schema.json index 8d0beabc48a..044be0aff9d 100644 --- a/packages/bridge-ui-v2/config/schemas/configuredCustomToken.schema.json +++ b/packages/bridge-ui-v2/config/schemas/configuredCustomToken.schema.json @@ -1,5 +1,5 @@ { - "$id": "configuredCustomToken.json", + "$id": "configuredCustomTokens.json", "type": "array", "items": { "type": "object", diff --git a/packages/bridge-ui-v2/package.json b/packages/bridge-ui-v2/package.json index b7f605ef0c6..9eef910b6cb 100644 --- a/packages/bridge-ui-v2/package.json +++ b/packages/bridge-ui-v2/package.json @@ -27,8 +27,8 @@ "@sveltejs/kit": "^1.27.4", "@types/debug": "^4.1.12", "@types/object-hash": "^3.0.6", - "@typescript-eslint/eslint-plugin": "^6.10.0", - "@typescript-eslint/parser": "^6.10.0", + "@typescript-eslint/eslint-plugin": "^6.13.2", + "@typescript-eslint/parser": "^6.13.2", "@vitest/coverage-v8": "^0.33.0", "@wagmi/cli": "^1.5.2", "abitype": "^0.8.11", diff --git a/packages/bridge-ui-v2/scripts/exportJsonToEnv.js b/packages/bridge-ui-v2/scripts/exportJsonToEnv.js index 28cbb8fb8e2..9ab0ce051ea 100755 --- a/packages/bridge-ui-v2/scripts/exportJsonToEnv.js +++ b/packages/bridge-ui-v2/scripts/exportJsonToEnv.js @@ -11,7 +11,7 @@ const envFile = './.env'; const bridgesPath = 'config/configuredBridges.json'; const chainsPath = 'config/configuredChains.json'; -const tokensPath = 'config/configuredCustomToken.json'; +const tokensPath = 'config/configuredCustomTokens.json'; const relayerPath = 'config/configuredRelayer.json'; const eventIndexerPath = 'config/configuredEventIndexer.json'; diff --git a/packages/bridge-ui-v2/scripts/vite-plugins/generateCustomTokenConfig.ts b/packages/bridge-ui-v2/scripts/vite-plugins/generateCustomTokenConfig.ts index cdaedac1f5b..e20c1c0fc4b 100644 --- a/packages/bridge-ui-v2/scripts/vite-plugins/generateCustomTokenConfig.ts +++ b/packages/bridge-ui-v2/scripts/vite-plugins/generateCustomTokenConfig.ts @@ -30,14 +30,14 @@ export function generateCustomTokenConfig() { if (skip) { configuredTokenConfigFile = ''; } else { - if (!process.env.CONFIGURED_CUSTOM_TOKEN) { + if (!process.env.CONFIGURED_CUSTOM_TOKENS) { throw new Error( - 'CONFIGURED_CUSTOM_TOKEN is not defined in environment. Make sure to run the export step in the documentation.', + 'CONFIGURED_CUSTOM_TOKENS is not defined in environment. Make sure to run the export step in the documentation.', ); } // Decode base64 encoded JSON string - configuredTokenConfigFile = decodeBase64ToJson(process.env.CONFIGURED_CUSTOM_TOKEN || ''); + configuredTokenConfigFile = decodeBase64ToJson(process.env.CONFIGURED_CUSTOM_TOKENS || ''); // Valide JSON against schema const isValid = validateJsonAgainstSchema(configuredTokenConfigFile, configuredChainsSchema); diff --git a/packages/bridge-ui-v2/src/components/AccountConnectionToast/AccountConnectionToast.svelte b/packages/bridge-ui-v2/src/components/AccountConnectionToast/AccountConnectionToast.svelte index 649e43a9fed..34be1eca943 100644 --- a/packages/bridge-ui-v2/src/components/AccountConnectionToast/AccountConnectionToast.svelte +++ b/packages/bridge-ui-v2/src/components/AccountConnectionToast/AccountConnectionToast.svelte @@ -9,12 +9,12 @@ // when the account is connected or disconnected via toast function onAccountChange(newAccount: Account, oldAccount?: Account) { if (newAccount?.isConnected) { - successToast({title: $t('messages.account.connected')}); + successToast({ title: $t('messages.account.connected') }); } else if (oldAccount && newAccount?.isDisconnected) { // We check if there was previous account, if not // the user just hit the app, and there is no need // to show the message. - warningToast({title: $t('messages.account.disconnected')}); + warningToast({ title: $t('messages.account.disconnected') }); } } diff --git a/packages/bridge-ui-v2/src/components/Bridge/Actions.svelte b/packages/bridge-ui-v2/src/components/Bridge/Actions.svelte index 2ddf6504f4d..7b8b8243be9 100644 --- a/packages/bridge-ui-v2/src/components/Bridge/Actions.svelte +++ b/packages/bridge-ui-v2/src/components/Bridge/Actions.svelte @@ -132,8 +132,8 @@ ? typeof $tokenBalance === 'bigint' ? $tokenBalance > BigInt(0) // ERC721/1155 : 'value' in $tokenBalance - ? $tokenBalance.value > BigInt(0) - : false // ERC20 + ? $tokenBalance.value > BigInt(0) + : false // ERC20 : false); $: canDoNothing = !hasAddress || !hasNetworks || !hasBalance || !$selectedToken; @@ -144,10 +144,10 @@ $selectedToken?.type === TokenType.ERC20 ? isSelectedERC20 && $enteredAmount && !$insufficientAllowance && !$validatingAmount : $selectedToken?.type === TokenType.ERC721 - ? allTokensApproved - : $selectedToken?.type === TokenType.ERC1155 - ? allTokensApproved - : false; + ? allTokensApproved + : $selectedToken?.type === TokenType.ERC1155 + ? allTokensApproved + : false; $: { checkTokensApproved(); @@ -158,10 +158,10 @@ $selectedToken?.type === TokenType.ERC20 ? canDoNothing || $insufficientBalance || $validatingAmount || approving || isTokenApproved || !$enteredAmount : $selectedToken?.type === TokenType.ERC721 - ? allTokensApproved || approving - : $selectedToken?.type === TokenType.ERC1155 - ? allTokensApproved || approving - : approving; + ? allTokensApproved || approving + : $selectedToken?.type === TokenType.ERC1155 + ? allTokensApproved || approving + : approving; $: isERC20 = $selectedToken?.type === TokenType.ERC20; $: isERC721 = $selectedToken?.type === TokenType.ERC721; @@ -187,12 +187,12 @@ $: disableBridge = isERC20 ? !erc20ConditionsSatisfied : isERC721 - ? !erc721ConditionsSatisfied - : isERC1155 - ? !erc1155ConditionsSatisfied - : isETH - ? !ethConditionsSatisfied - : commonConditions; + ? !erc721ConditionsSatisfied + : isERC1155 + ? !erc1155ConditionsSatisfied + : isETH + ? !ethConditionsSatisfied + : commonConditions; {#if oldStyle} diff --git a/packages/bridge-ui-v2/src/components/Bridge/Amount.svelte b/packages/bridge-ui-v2/src/components/Bridge/Amount.svelte index b88fefb2ee3..e22c33eea79 100644 --- a/packages/bridge-ui-v2/src/components/Bridge/Amount.svelte +++ b/packages/bridge-ui-v2/src/components/Bridge/Amount.svelte @@ -233,8 +233,8 @@ ? $tokenBalance : BigInt(0) // ERC721/1155 : 'value' in $tokenBalance && $tokenBalance.value > BigInt(0) - ? $tokenBalance.value - : BigInt(0) // ERC20 + ? $tokenBalance.value + : BigInt(0) // ERC20 : BigInt(0); $: if (inputBox && sanitizedValue !== inputBox.getValue()) { diff --git a/packages/bridge-ui-v2/src/components/Bridge/SwitchChainsButton.svelte b/packages/bridge-ui-v2/src/components/Bridge/SwitchChainsButton.svelte index 9a59fd04510..a3c27941b77 100644 --- a/packages/bridge-ui-v2/src/components/Bridge/SwitchChainsButton.svelte +++ b/packages/bridge-ui-v2/src/components/Bridge/SwitchChainsButton.svelte @@ -16,9 +16,9 @@ } catch (err) { console.error(err); if (err instanceof SwitchChainError) { - warningToast({title: $t('messages.network.pending')}); + warningToast({ title: $t('messages.network.pending') }); } else if (err instanceof UserRejectedRequestError) { - warningToast({title: $t('messages.network.rejected')}); + warningToast({ title: $t('messages.network.rejected') }); } } } diff --git a/packages/bridge-ui-v2/src/components/ConnectButton/ConnectButton.svelte b/packages/bridge-ui-v2/src/components/ConnectButton/ConnectButton.svelte index 5d4f47547c7..e0c26f7cdd7 100644 --- a/packages/bridge-ui-v2/src/components/ConnectButton/ConnectButton.svelte +++ b/packages/bridge-ui-v2/src/components/ConnectButton/ConnectButton.svelte @@ -16,7 +16,7 @@ function connectWallet() { if (web3modalOpen) return; - web3modal.openModal(); + web3modal.openModal(); } function onWeb3Modal(state: { open: boolean }) { @@ -31,7 +31,10 @@ {#if connected} -