Skip to content

Commit

Permalink
Merge pull request #32 from gateway-fm/test
Browse files Browse the repository at this point in the history
Upd: default token, tokens list order
  • Loading branch information
UrfinDeuce authored Jul 31, 2024
2 parents 507c510 + 968ff33 commit b0c34bd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push-docker-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
push: true
tags: gatewayfm/zkevm-bridge-ui-generic:0.1.0
tags: gatewayfm/zkevm-bridge-ui-generic:1.0.0
6 changes: 3 additions & 3 deletions src/contexts/tokens.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const TokensProvider: FC<PropsWithChildren> = (props) => {
}
const token = [
...getCustomTokens(),
...(tokens || [getEtherToken(chain)]),
...(tokens || [getGasToken(chain)]),
...fetchedTokens.current,
].find(
(token) =>
Expand Down Expand Up @@ -322,12 +322,12 @@ const TokensProvider: FC<PropsWithChildren> = (props) => {
.map((token) => addWrappedToken({ token }))
)
.then((chainTokens) => {
const tokens = [getEtherToken(ethereumChain)];
const tokens = [];
const gasToken = getGasToken(polygonZkEVMChain)
if (!isTokenEther(gasToken, ethereumChain)) {
tokens.push(gasToken)
}
tokens.push(...chainTokens)
tokens.push(getEtherToken(ethereumChain), ...chainTokens)
cleanupCustomTokens(tokens);
setTokens(tokens);
})
Expand Down
10 changes: 5 additions & 5 deletions src/views/bridge-details/bridge-details.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { parseError } from "src/adapters/error";
import { getTxFeePaid } from "src/adapters/ethereum";
import { getCurrency } from "src/adapters/storage";
import { ReactComponent as NewWindowIcon } from "src/assets/icons/new-window.svg";
import { FIAT_DISPLAY_PRECISION, getEtherToken } from "src/constants";
import { FIAT_DISPLAY_PRECISION, getGasToken } from "src/constants";
import { useBridgeContext } from "src/contexts/bridge.context";
import { useEnvContext } from "src/contexts/env.context";
import { useErrorContext } from "src/contexts/error.context";
Expand Down Expand Up @@ -276,8 +276,8 @@ export const BridgeDetails: FC = () => {
const { step1: step1EthFee, step2: step2EthFee } = ethFees;
const { step1: step1FiatFee, step2: step2FiatFee } = fiatFees;

const ethTokenFrom = getEtherToken(from);
const ethTokenTo = getEtherToken(to)
const gasTokenFrom = getGasToken(from);
const gasTokenTo = getGasToken(to)

if (env === undefined) {
return null;
Expand All @@ -289,12 +289,12 @@ export const BridgeDetails: FC = () => {
? `${currencySymbol}${fiatAmount ? formatFiatAmount(fiatAmount) : "--"}`
: undefined;

const step1FeeString = `${step1EthFee ? formatTokenAmount(step1EthFee, ethTokenFrom) : "--"} ${ethTokenFrom.symbol}`;
const step1FeeString = `${step1EthFee ? formatTokenAmount(step1EthFee, gasTokenFrom) : "--"} ${gasTokenFrom.symbol}`;
const step1FiatFeeString = env.fiatExchangeRates.areEnabled
? `${currencySymbol}${step1FiatFee ? formatFiatAmount(step1FiatFee) : "--"}`
: undefined;

const step2FeeString = `${step2EthFee ? formatTokenAmount(step2EthFee, ethTokenTo) : "--"} ${ethTokenTo.symbol}`;
const step2FeeString = `${step2EthFee ? formatTokenAmount(step2EthFee, gasTokenTo) : "--"} ${gasTokenTo.symbol}`;
const step2FiatFeeString = env.fiatExchangeRates.areEnabled
? `${currencySymbol}${step2FiatFee ? formatFiatAmount(step2FiatFee) : "--"}`
: undefined;
Expand Down
8 changes: 4 additions & 4 deletions src/views/home/components/bridge-form/bridge-form.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FC, useCallback, useEffect, useState } from "react";
import { addCustomToken, getChainCustomTokens, removeCustomToken } from "src/adapters/storage";
import { ReactComponent as ArrowDown } from "src/assets/icons/arrow-down.svg";
import { ReactComponent as CaretDown } from "src/assets/icons/caret-down.svg";
import { getEtherToken } from "src/constants";
import { getGasToken } from "src/constants";
import { useEnvContext } from "src/contexts/env.context";
import { useProvidersContext } from "src/contexts/providers.context";
import { useTokensContext } from "src/contexts/tokens.context";
Expand Down Expand Up @@ -105,7 +105,7 @@ export const BridgeForm: FC<BridgeFormProps> = ({ account, formData, onResetForm
)
);
if (selectedChains && tokenToRemove.address === token?.address) {
setToken(getEtherToken(selectedChains.from));
setToken(getGasToken(selectedChains.from));
}
}
};
Expand Down Expand Up @@ -141,7 +141,7 @@ export const BridgeForm: FC<BridgeFormProps> = ({ account, formData, onResetForm
// Load all the tokens for the selected chain without their balance
if (selectedChains && defaultTokens) {
const { from } = selectedChains;
const chainTokens = [...getChainCustomTokens(from), ...defaultTokens];
const chainTokens = [ ...defaultTokens, ...getChainCustomTokens(from)];

setTokens(
chainTokens.map((token) => ({
Expand Down Expand Up @@ -243,7 +243,7 @@ export const BridgeForm: FC<BridgeFormProps> = ({ account, formData, onResetForm

if (from && to) {
setSelectedChains({ from, to });
setToken(getEtherToken(from));
setToken(getGasToken(from.key === "ethereum" ? to : from));
}
setAmount(undefined);
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/home/components/token-list/token-list.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const TokenList: FC<TokenListProps> = ({

const getTokenBalance = useCallback(
(token: Token, chain: Chain): Promise<BigNumber> => {
if (isTokenEther(token,chain)) {
if (isTokenEther(token, chain)) {
return chain.provider.getBalance(account);
} else {
return getErc20TokenBalance({
Expand Down

0 comments on commit b0c34bd

Please sign in to comment.