From ffedca73da62d6640111ba412c74bcf988c581ad Mon Sep 17 00:00:00 2001 From: Keith Date: Sun, 10 Nov 2019 13:35:51 +0800 Subject: [PATCH] fix(neuron-ui): fix the address prefix on tx view according to the chain type. --- packages/neuron-ui/src/components/Addresses/index.tsx | 4 ++-- packages/neuron-ui/src/components/Transaction/index.tsx | 6 ++---- packages/neuron-ui/src/utils/const.ts | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/neuron-ui/src/components/Addresses/index.tsx b/packages/neuron-ui/src/components/Addresses/index.tsx index 2ef12764cb..0afdffb770 100644 --- a/packages/neuron-ui/src/components/Addresses/index.tsx +++ b/packages/neuron-ui/src/components/Addresses/index.tsx @@ -20,6 +20,7 @@ import { StateWithDispatch } from 'states/stateProvider/reducer' import { useLocalDescription } from 'utils/hooks' import { localNumberFormatter, shannonToCKBFormatter } from 'utils/formatters' import { onRenderRow } from 'utils/fabricUIRender' +import { MAINNET_TAG } from 'utils/const' const Addresses = ({ app: { @@ -30,8 +31,7 @@ const Addresses = ({ settings: { networks = [] }, dispatch, }: React.PropsWithoutRef) => { - const isMainnet = - (networks.find(n => n.id === networkID) || {}).chain === (process.env.REACT_APP_MAINNET_TAG || 'ckb') + const isMainnet = (networks.find(n => n.id === networkID) || {}).chain === MAINNET_TAG const [showMainnetAddress, setShowMainnetAddress] = useState(false) const [t] = useTranslation() diff --git a/packages/neuron-ui/src/components/Transaction/index.tsx b/packages/neuron-ui/src/components/Transaction/index.tsx index 54b83c0b54..7e8287d8a0 100644 --- a/packages/neuron-ui/src/components/Transaction/index.tsx +++ b/packages/neuron-ui/src/components/Transaction/index.tsx @@ -8,7 +8,7 @@ import { ckbCore } from 'services/chain' import { transactionState } from 'states/initStates/chain' import { localNumberFormatter, uniformTimeFormatter, shannonToCKBFormatter } from 'utils/formatters' -import { ErrorCode } from 'utils/const' +import { ErrorCode, MAINNET_TAG } from 'utils/const' import { explorerNavButton } from './style.module.scss' const MIN_CELL_WIDTH = 70 @@ -199,9 +199,7 @@ const Transaction = () => { } setAddressPrefix( - network.chain === process.env.REACT_APP_MAINNET_TAG - ? ckbCore.utils.AddressPrefix.Mainnet - : ckbCore.utils.AddressPrefix.Testnet + network.chain === MAINNET_TAG ? ckbCore.utils.AddressPrefix.Mainnet : ckbCore.utils.AddressPrefix.Testnet ) } }) diff --git a/packages/neuron-ui/src/utils/const.ts b/packages/neuron-ui/src/utils/const.ts index 135ae4ab4f..f6d812a7d7 100644 --- a/packages/neuron-ui/src/utils/const.ts +++ b/packages/neuron-ui/src/utils/const.ts @@ -10,6 +10,7 @@ export const UNREMOVABLE_NETWORK_ID = '0' export const CONFIRMATION_THRESHOLD = 30 export const MAX_DECIMAL_DIGITS = 8 +export const MAINNET_TAG = 'ckb' export enum ConnectionStatus { Online = 'online',