From 6bc2e2607d2a9c9fe9ae03b0f093442ce8a31643 Mon Sep 17 00:00:00 2001 From: Korbinian Date: Mon, 27 May 2024 09:12:56 +0200 Subject: [PATCH] feat(bridge-ui): update config (#17347) --- .../configuredCustomTokens.schema.json | 3 ++ packages/bridge-ui/scripts/exportJsonToEnv.js | 3 ++ .../SideNavigation/SideNavigation.svelte | 28 +++++++----- .../WelcomeModal/WelcomeModal.svelte | 45 ------------------- .../src/components/WelcomeModal/index.ts | 1 - packages/bridge-ui/src/i18n/en.json | 8 +--- .../src/libs/fee/recommendProcessingFee.ts | 24 +++++++++- packages/bridge-ui/src/libs/token/tokens.ts | 1 + packages/bridge-ui/src/libs/token/types.ts | 2 + packages/bridge-ui/src/libs/wagmi/watcher.ts | 9 +++- packages/bridge-ui/src/routes/+layout.svelte | 3 -- 11 files changed, 57 insertions(+), 70 deletions(-) delete mode 100644 packages/bridge-ui/src/components/WelcomeModal/WelcomeModal.svelte delete mode 100644 packages/bridge-ui/src/components/WelcomeModal/index.ts diff --git a/packages/bridge-ui/config/schemas/configuredCustomTokens.schema.json b/packages/bridge-ui/config/schemas/configuredCustomTokens.schema.json index f7a13d72ada..d9cc956577a 100644 --- a/packages/bridge-ui/config/schemas/configuredCustomTokens.schema.json +++ b/packages/bridge-ui/config/schemas/configuredCustomTokens.schema.json @@ -42,6 +42,9 @@ "stablecoin": { "type": "boolean" }, + "quotaLimited": { + "type": "boolean" + }, "mintable": { "type": "boolean" } diff --git a/packages/bridge-ui/scripts/exportJsonToEnv.js b/packages/bridge-ui/scripts/exportJsonToEnv.js index 3518426da42..7d8f9ddcb91 100755 --- a/packages/bridge-ui/scripts/exportJsonToEnv.js +++ b/packages/bridge-ui/scripts/exportJsonToEnv.js @@ -25,6 +25,7 @@ const isProd = args.includes('--prod'); const isA7 = args.includes('--a7'); const isA6 = args.includes('--a6'); const isA5 = args.includes('--a5'); +const isMainnet = args.includes('--mainnet'); // Determine the environment let environment = ''; @@ -44,6 +45,8 @@ if (isA6) { version = 'a5'; } else if (isA7) { version = 'a7'; +} else if (isMainnet) { + version = 'mainnet'; } Logger.info(`Detected ${environment} environment and ${version} version.`); diff --git a/packages/bridge-ui/src/components/SideNavigation/SideNavigation.svelte b/packages/bridge-ui/src/components/SideNavigation/SideNavigation.svelte index 0699c446f6c..d86be1f29e3 100644 --- a/packages/bridge-ui/src/components/SideNavigation/SideNavigation.svelte +++ b/packages/bridge-ui/src/components/SideNavigation/SideNavigation.svelte @@ -103,24 +103,28 @@ {$t('nav.bridge')} -
  • - - - {$t('nav.faucet')} - -
  • + {#if testnetName !== ''} +
  • + + + {$t('nav.faucet')} + +
  • + {/if}
  • {$t('nav.transactions')}
  • -
  • - - - {$t('nav.swap')} - -
  • + {#if PUBLIC_DEFAULT_SWAP_URL && PUBLIC_DEFAULT_SWAP_URL !== ''} +
  • + + + {$t('nav.swap')} + +
  • + {/if}
  • - import { onMount } from 'svelte'; - import { t } from 'svelte-i18n'; - - import { ActionButton } from '$components/Button'; - import { Icon } from '$components/Icon'; - - let modalOpen: boolean; - - function closeModal() { - modalOpen = false; - } - - function confirmModal() { - localStorage.setItem('accepted-modal', 'true'); - - closeModal(); - } - - onMount(() => { - modalOpen = localStorage.getItem('accepted-modal') !== 'true'; - }); - - - - - diff --git a/packages/bridge-ui/src/components/WelcomeModal/index.ts b/packages/bridge-ui/src/components/WelcomeModal/index.ts deleted file mode 100644 index be3f1d1f52a..00000000000 --- a/packages/bridge-ui/src/components/WelcomeModal/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as WelcomeModal } from './WelcomeModal.svelte'; diff --git a/packages/bridge-ui/src/i18n/en.json b/packages/bridge-ui/src/i18n/en.json index a48d5125ce9..87dda5f086f 100644 --- a/packages/bridge-ui/src/i18n/en.json +++ b/packages/bridge-ui/src/i18n/en.json @@ -199,12 +199,6 @@ "recipient": "Recipient", "review": "Review" } - }, - "welcome_modal": { - "body": "Welcome to Hekla, our final testnet.
    Strengthening security may cause some delay in L2→L1 bridging, around 24 hours on the testnet. We're striving for shorter delays on the mainnet.", - "confirm": "I understand", - "link": "Find out more", - "title": "Important Update" } }, "chain_selector": { @@ -492,7 +486,7 @@ "title": "What is \"Sufficient funds to claim\"?" }, "quota": { - "description": "Currently there is a daily limit of how much ETH can be bridged to L1. If the quota is reached, please try again the next day.", + "description": "Currently there is a daily limit of how much of this asset can be bridged to L1. If the quota is reached, please try again the next day.", "title": "What is \"Sufficient daily quota\"?" } } diff --git a/packages/bridge-ui/src/libs/fee/recommendProcessingFee.ts b/packages/bridge-ui/src/libs/fee/recommendProcessingFee.ts index c918d1e9669..2232642e929 100644 --- a/packages/bridge-ui/src/libs/fee/recommendProcessingFee.ts +++ b/packages/bridge-ui/src/libs/fee/recommendProcessingFee.ts @@ -1,4 +1,5 @@ import { getPublicClient } from '@wagmi/core'; +import { formatGwei } from 'viem'; import { gasLimitConfig } from '$config'; import { PUBLIC_FEE_MULTIPLIER } from '$env/static/public'; @@ -35,8 +36,13 @@ export async function recommendProcessingFee({ if (!destPublicClient) throw new Error('Could not get public client'); const maxPriorityFee = await destPublicClient.estimateMaxPriorityFeePerGas(); + log(`maxPriorityFee: ${formatGwei(maxPriorityFee)} gwei`); + + const gasPrice = await destPublicClient.getGasPrice(); + log(`gasPrice: ${formatGwei(gasPrice)} gwei`); if (!baseFee) throw new Error('Unable to get base fee'); + log(`baseFee: ${formatGwei(baseFee)} gwei`); if (token.type !== TokenType.ETH) { const tokenInfo = await getTokenAddresses({ token, srcChainId, destChainId }); @@ -82,7 +88,23 @@ export async function recommendProcessingFee({ } if (!estimatedMsgGaslimit) throw new Error('Unable to calculate fee'); - const fee = estimatedMsgGaslimit * (BigInt(PUBLIC_FEE_MULTIPLIER) * (baseFee + maxPriorityFee)); + // Initial fee multiplicator and add fallback + let feeMultiplicator: number = parseInt(PUBLIC_FEE_MULTIPLIER); + + if (gasPrice <= 50000000n) { + feeMultiplicator = 4; + log(`gasPrice ${formatGwei(gasPrice)} is less than 0.5 gwei, setting feeMultiplicator to 4`); + } else if (gasPrice <= 100000000n && gasPrice > 50000000n) { + feeMultiplicator = 3; + log( + `gasPrice ${formatGwei(gasPrice)} is less than 0.1 gwei and more than 0.05 gwei, setting feeMultiplicator to 3`, + ); + } else { + feeMultiplicator = 2; + log(`gasPrice ${formatGwei(gasPrice)} is more than 0.1 gwei, setting feeMultiplicator to 2`); + } + + const fee = estimatedMsgGaslimit * gasPrice * BigInt(feeMultiplicator); return roundWeiTo6DecimalPlaces(fee); } diff --git a/packages/bridge-ui/src/libs/token/tokens.ts b/packages/bridge-ui/src/libs/token/tokens.ts index 880ae86fb4c..36bd225c852 100644 --- a/packages/bridge-ui/src/libs/token/tokens.ts +++ b/packages/bridge-ui/src/libs/token/tokens.ts @@ -35,4 +35,5 @@ const hasAttribute = (token: Token, attribute: TokenAttributeKey): boolean => { export const isWrapped = (token: Token): boolean => hasAttribute(token, TokenAttributeKey.Wrapped); export const isSupported = (token: Token): boolean => hasAttribute(token, TokenAttributeKey.Supported); export const isStablecoin = (token: Token): boolean => hasAttribute(token, TokenAttributeKey.Stablecoin); +export const isQuotaLimited = (token: Token): boolean => hasAttribute(token, TokenAttributeKey.QuotaLimited); export const isMintable = (token: Token): boolean => hasAttribute(token, TokenAttributeKey.Mintable); diff --git a/packages/bridge-ui/src/libs/token/types.ts b/packages/bridge-ui/src/libs/token/types.ts index 392287d6e61..fecb6d66ec4 100644 --- a/packages/bridge-ui/src/libs/token/types.ts +++ b/packages/bridge-ui/src/libs/token/types.ts @@ -18,6 +18,7 @@ export enum TokenAttributeKey { Wrapped = 'wrapped', Stablecoin = 'stablecoin', Supported = 'supported', + QuotaLimited = 'quotaLimited', } export type TokenAttributes = { @@ -25,6 +26,7 @@ export type TokenAttributes = { [TokenAttributeKey.Wrapped]?: boolean; [TokenAttributeKey.Stablecoin]?: boolean; [TokenAttributeKey.Supported]?: boolean; + [TokenAttributeKey.QuotaLimited]?: boolean; }; export type Token = { diff --git a/packages/bridge-ui/src/libs/wagmi/watcher.ts b/packages/bridge-ui/src/libs/wagmi/watcher.ts index 3788f5adb20..3523b253ddf 100644 --- a/packages/bridge-ui/src/libs/wagmi/watcher.ts +++ b/packages/bridge-ui/src/libs/wagmi/watcher.ts @@ -28,7 +28,14 @@ export async function startWatching() { const { chainId, address } = data; if (chainId && address) { - connectedSmartContractWallet.set(await isSmartContractWallet(address, Number(chainId))); + let smartWallet = false; + try { + smartWallet = (await isSmartContractWallet(address, Number(chainId))) || false; + } catch (error) { + console.error('Error checking for smart contract wallet', error); + } finally { + connectedSmartContractWallet.set(smartWallet); + } } // We need to check if the chain is supported, and if not diff --git a/packages/bridge-ui/src/routes/+layout.svelte b/packages/bridge-ui/src/routes/+layout.svelte index fc5d2d91865..2a1865c3636 100644 --- a/packages/bridge-ui/src/routes/+layout.svelte +++ b/packages/bridge-ui/src/routes/+layout.svelte @@ -10,7 +10,6 @@ import { NotificationToast } from '$components/NotificationToast'; import { SideNavigation } from '$components/SideNavigation'; import { SwitchChainModal } from '$components/SwitchChainModal'; - import { WelcomeModal } from '$components/WelcomeModal'; import { startWatching, stopWatching } from '$libs/wagmi'; const syncPointer = ({ x, y }: { x: number; y: number }) => { @@ -51,5 +50,3 @@ - -