From 8bbf73de0c61fd927b7975acb377370099ccb0df Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 24 Jul 2023 11:27:28 +0200 Subject: [PATCH] fix ts --- packages/bridge-ui-v2/src/components/Bridge/Actions.svelte | 4 ++-- packages/bridge-ui-v2/src/libs/bridge/checkBalanceToBridge.ts | 2 +- packages/bridge-ui-v2/src/libs/bridge/getMaxAmountToBridge.ts | 2 +- packages/bridge-ui-v2/src/libs/fee/recommendProcessingFee.ts | 4 ++-- packages/bridge-ui-v2/src/libs/token/getAddress.ts | 2 +- packages/bridge-ui-v2/src/libs/token/getBalance.ts | 2 +- packages/bridge-ui-v2/src/libs/token/getCrossChainAddress.ts | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/bridge-ui-v2/src/components/Bridge/Actions.svelte b/packages/bridge-ui-v2/src/components/Bridge/Actions.svelte index 9af1ab6894e..f85087a3270 100644 --- a/packages/bridge-ui-v2/src/components/Bridge/Actions.svelte +++ b/packages/bridge-ui-v2/src/components/Bridge/Actions.svelte @@ -3,7 +3,6 @@ import { Button } from '$components/Button'; import { Icon } from '$components/Icon'; - import { isERC20 } from '$libs/token'; import { account, network } from '$stores'; import { @@ -17,6 +16,7 @@ selectedToken, tokenBalance, } from './state'; + import { TokenType } from '$libs/token'; export let approve: () => Promise; export let bridge: () => Promise; @@ -48,7 +48,7 @@ $: canDoNothing = !hasAddress || !hasNetworks || !hasBalance || !$selectedToken || !$enteredAmount; // Conditions for approve/bridge steps - $: isSelectedERC20 = $selectedToken && isERC20($selectedToken); + $: isSelectedERC20 = $selectedToken && $selectedToken.type === TokenType.ERC20; $: isTokenApproved = isSelectedERC20 && $enteredAmount && !$insufficientAllowance; // Conditions to disable/enable buttons diff --git a/packages/bridge-ui-v2/src/libs/bridge/checkBalanceToBridge.ts b/packages/bridge-ui-v2/src/libs/bridge/checkBalanceToBridge.ts index b91d5356792..b21addfe4b7 100644 --- a/packages/bridge-ui-v2/src/libs/bridge/checkBalanceToBridge.ts +++ b/packages/bridge-ui-v2/src/libs/bridge/checkBalanceToBridge.ts @@ -2,7 +2,7 @@ import { type Address, zeroAddress } from 'viem'; import { chainContractsMap } from '$libs/chain'; import { InsufficientAllowanceError, InsufficientBalanceError, RevertedWithFailedError } from '$libs/error'; -import { getAddress, type Token,TokenType } from '$libs/token'; +import { getAddress, type Token, TokenType } from '$libs/token'; import { isDeployedCrossChain } from '$libs/token/isDeployedCrossChain'; import { getConnectedWallet } from '$libs/util/getConnectedWallet'; diff --git a/packages/bridge-ui-v2/src/libs/bridge/getMaxAmountToBridge.ts b/packages/bridge-ui-v2/src/libs/bridge/getMaxAmountToBridge.ts index 38651073a36..06e9bc88c06 100644 --- a/packages/bridge-ui-v2/src/libs/bridge/getMaxAmountToBridge.ts +++ b/packages/bridge-ui-v2/src/libs/bridge/getMaxAmountToBridge.ts @@ -1,7 +1,7 @@ import type { Address } from 'viem'; import { chainContractsMap } from '$libs/chain'; -import { type Token,TokenType } from '$libs/token'; +import { type Token, TokenType } from '$libs/token'; import { getConnectedWallet } from '$libs/util/getConnectedWallet'; import { getLogger } from '$libs/util/logger'; diff --git a/packages/bridge-ui-v2/src/libs/fee/recommendProcessingFee.ts b/packages/bridge-ui-v2/src/libs/fee/recommendProcessingFee.ts index af8793c8826..cd49bd7262f 100644 --- a/packages/bridge-ui-v2/src/libs/fee/recommendProcessingFee.ts +++ b/packages/bridge-ui-v2/src/libs/fee/recommendProcessingFee.ts @@ -2,7 +2,7 @@ import { getPublicClient } from '@wagmi/core'; import { zeroAddress } from 'viem'; import { recommentProcessingFee } from '$config'; -import { getAddress, isERC20, type Token } from '$libs/token'; +import { getAddress, type Token,TokenType } from '$libs/token'; type RecommendProcessingFeeArgs = { token: Token; @@ -20,7 +20,7 @@ export async function recommendProcessingFee({ token, destChainId, srcChainId }: // To make it enticing, we say 900k let gasLimit = ethGasLimit; - if (isERC20(token)) { + if (token.type === TokenType.ERC20) { if (!srcChainId) { throw Error('missing required source chain for ERC20 token'); } diff --git a/packages/bridge-ui-v2/src/libs/token/getAddress.ts b/packages/bridge-ui-v2/src/libs/token/getAddress.ts index 988981c67dc..42baeced17b 100644 --- a/packages/bridge-ui-v2/src/libs/token/getAddress.ts +++ b/packages/bridge-ui-v2/src/libs/token/getAddress.ts @@ -4,7 +4,7 @@ import { NoTokenAddressError } from '$libs/error'; import { getLogger } from '$libs/util/logger'; import { getCrossChainAddress } from './getCrossChainAddress'; -import { type Token,TokenType } from './types'; +import { type Token, TokenType } from './types'; type GetAddressArgs = { token: Token; diff --git a/packages/bridge-ui-v2/src/libs/token/getBalance.ts b/packages/bridge-ui-v2/src/libs/token/getBalance.ts index d8c69f03aef..1c26c9f93df 100644 --- a/packages/bridge-ui-v2/src/libs/token/getBalance.ts +++ b/packages/bridge-ui-v2/src/libs/token/getBalance.ts @@ -4,7 +4,7 @@ import { type Address, zeroAddress } from 'viem'; import { getLogger } from '$libs/util/logger'; import { getAddress } from './getAddress'; -import { type Token,TokenType } from './types'; +import { type Token, TokenType } from './types'; type GetBalanceArgs = { userAddress: Address; diff --git a/packages/bridge-ui-v2/src/libs/token/getCrossChainAddress.ts b/packages/bridge-ui-v2/src/libs/token/getCrossChainAddress.ts index eaa5e35b040..b282a68432c 100644 --- a/packages/bridge-ui-v2/src/libs/token/getCrossChainAddress.ts +++ b/packages/bridge-ui-v2/src/libs/token/getCrossChainAddress.ts @@ -3,7 +3,7 @@ import { getContract } from '@wagmi/core'; import { tokenVaultABI } from '$abi'; import { chainContractsMap } from '$libs/chain'; -import { type Token,TokenType } from './types'; +import { type Token, TokenType } from './types'; type GetCrossChainAddressArgs = { token: Token;