Skip to content

Commit

Permalink
feat(bridge-ui): update config (#17347)
Browse files Browse the repository at this point in the history
  • Loading branch information
KorbinianK authored May 27, 2024
1 parent d62f193 commit 6bc2e26
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"stablecoin": {
"type": "boolean"
},
"quotaLimited": {
"type": "boolean"
},
"mintable": {
"type": "boolean"
}
Expand Down
3 changes: 3 additions & 0 deletions packages/bridge-ui/scripts/exportJsonToEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand All @@ -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.`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,28 @@
<span>{$t('nav.bridge')}</span>
</LinkButton>
</li>
<li>
<LinkButton href="/faucet" active={isFaucetPage}>
<Icon type="faucet" fillClass={getIconFillClass(isFaucetPage)} />
<span>{$t('nav.faucet')}</span>
</LinkButton>
</li>
{#if testnetName !== ''}
<li>
<LinkButton href="/faucet" active={isFaucetPage}>
<Icon type="faucet" fillClass={getIconFillClass(isFaucetPage)} />
<span>{$t('nav.faucet')}</span>
</LinkButton>
</li>
{/if}
<li>
<LinkButton href="/transactions" active={isTransactionsPage}>
<Icon type="transactions" fillClass={getIconFillClass(isTransactionsPage)} />
<span>{$t('nav.transactions')}</span>
</LinkButton>
</li>
<li class="border-t border-t-divider-border pt-2">
<LinkButton href={PUBLIC_DEFAULT_SWAP_URL} external>
<Icon type="swap" />
<span>{$t('nav.swap')}</span>
</LinkButton>
</li>
{#if PUBLIC_DEFAULT_SWAP_URL && PUBLIC_DEFAULT_SWAP_URL !== ''}
<li class="border-t border-t-divider-border pt-2">
<LinkButton href={PUBLIC_DEFAULT_SWAP_URL} external>
<Icon type="swap" />
<span>{$t('nav.swap')}</span>
</LinkButton>
</li>
{/if}
<li>
<LinkButton
href={$connectedSourceChain
Expand Down
45 changes: 0 additions & 45 deletions packages/bridge-ui/src/components/WelcomeModal/WelcomeModal.svelte

This file was deleted.

1 change: 0 additions & 1 deletion packages/bridge-ui/src/components/WelcomeModal/index.ts

This file was deleted.

8 changes: 1 addition & 7 deletions packages/bridge-ui/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,6 @@
"recipient": "Recipient",
"review": "Review"
}
},
"welcome_modal": {
"body": "Welcome to <span class='font-bold text-primary-brand'>Hekla, our final testnet</span>.<br/>Strengthening security may cause some delay in L2→L1 bridging, <span class='font-bold text-primary-brand'>around 24 hours</span> on the testnet. We're striving for shorter delays on the mainnet.",
"confirm": "I understand",
"link": "Find out more",
"title": "Important Update"
}
},
"chain_selector": {
Expand Down Expand Up @@ -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\"?"
}
}
Expand Down
24 changes: 23 additions & 1 deletion packages/bridge-ui/src/libs/fee/recommendProcessingFee.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions packages/bridge-ui/src/libs/token/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 2 additions & 0 deletions packages/bridge-ui/src/libs/token/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ export enum TokenAttributeKey {
Wrapped = 'wrapped',
Stablecoin = 'stablecoin',
Supported = 'supported',
QuotaLimited = 'quotaLimited',
}

export type TokenAttributes = {
[TokenAttributeKey.Mintable]?: boolean;
[TokenAttributeKey.Wrapped]?: boolean;
[TokenAttributeKey.Stablecoin]?: boolean;
[TokenAttributeKey.Supported]?: boolean;
[TokenAttributeKey.QuotaLimited]?: boolean;
};

export type Token = {
Expand Down
9 changes: 8 additions & 1 deletion packages/bridge-ui/src/libs/wagmi/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions packages/bridge-ui/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -51,5 +50,3 @@
<SwitchChainModal />

<BridgePausedModal />

<WelcomeModal />

0 comments on commit 6bc2e26

Please sign in to comment.