diff --git a/package.json b/package.json index 4ea16de6..3a149969 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "extension", - "version": "1.21.0", + "version": "1.22.0", "description": "extension", "private": false, "repository": "https://github.com/SimpleHold/extension.git", @@ -45,6 +45,7 @@ "detect-browser": "^5.2.0", "digibyte-lib": "https://github.com/DigiByte-Core/digibyte-lib", "lodash": "^4.17.21", + "nanocurrency": "^2.5.0", "neblio-lib": "https://github.com/NeblioTeam/bitcore-lib#neblcore-lib", "nerve-sdk-js": "^1.0.8", "nuls-sdk-js": "^2.5.0", diff --git a/src/assets/currencies/xno.svg b/src/assets/currencies/xno.svg new file mode 100644 index 00000000..9c7a0d6a --- /dev/null +++ b/src/assets/currencies/xno.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/components/CurrencyAddress/CurrencyAddress.tsx b/src/components/CurrencyAddress/CurrencyAddress.tsx index d8ddb5ef..04d5976a 100644 --- a/src/components/CurrencyAddress/CurrencyAddress.tsx +++ b/src/components/CurrencyAddress/CurrencyAddress.tsx @@ -7,7 +7,7 @@ import CheckBox from '@components/CheckBox' // Utils import { short, toUpper } from '@utils/format' -import { getBalance } from '@utils/api' +import { getBalance } from '@utils/currencies' import { getCurrency } from '@config/currencies' // Styles @@ -33,7 +33,7 @@ const CurrencyAddress: React.FC = (props) => { const currency = getCurrency(symbol) const onGetBalance = async (): Promise => { - const request = await getBalance(address, currency?.chain) + const request = await getBalance(symbol, address, currency?.chain) setBalance(request.balance) } diff --git a/src/components/CurrencyLogo/CurrencyLogo.tsx b/src/components/CurrencyLogo/CurrencyLogo.tsx index 806cd0e9..70752a18 100644 --- a/src/components/CurrencyLogo/CurrencyLogo.tsx +++ b/src/components/CurrencyLogo/CurrencyLogo.tsx @@ -25,7 +25,7 @@ const CurrencyLogo: React.FC = (props) => { const [logo, setLogo] = React.useState(null) - const getChainogo = chain ? getCurrencyByChain(chain) : null + const getChainLogo = chain ? getCurrencyByChain(chain) : null const currency = chain ? getToken(symbol, chain) : getCurrency(symbol) React.useEffect(() => { @@ -47,7 +47,7 @@ const CurrencyLogo: React.FC = (props) => { {currency || logo ? ( @@ -57,9 +57,9 @@ const CurrencyLogo: React.FC = (props) => { {toUpper(name[0])} ) : null} - {getChainogo ? ( + {getChainLogo ? ( - + ) : null} diff --git a/src/components/WalletCard/WalletCard.tsx b/src/components/WalletCard/WalletCard.tsx index f47b4eb4..0771432e 100644 --- a/src/components/WalletCard/WalletCard.tsx +++ b/src/components/WalletCard/WalletCard.tsx @@ -7,7 +7,8 @@ import CurrencyLogo from '@components/CurrencyLogo' import Skeleton from '@components/Skeleton' // Utils -import { getBalance } from '@utils/api' +import { updateWalletActivationStatus } from '@utils/currencies/nano' +import { getBalance } from '@utils/currencies' import { toUpper, numberFriendly, formatEstimated, getFormatBalance } from '@utils/format' import { updateBalance, @@ -94,6 +95,7 @@ const WalletCard: React.FC = React.memo((props) => { const [balance, setBalance] = React.useState(null) const [estimated, setEstimated] = React.useState(null) const [pendingBalance, setPendingBalance] = React.useState(0) + const [notActivatedStatus, setActivationStatus] = React.useState(!!isNotActivated) const walletData: TTxWallet = { chain: getWalletChain(symbol, chain), @@ -104,23 +106,34 @@ const WalletCard: React.FC = React.memo((props) => { } React.useEffect(() => { + checkActivatedStatus() loadBalance() }, []) + const checkActivatedStatus = () => { + if (symbol === 'xno') { + updateWalletActivationStatus(address).then(res => { + if (res) { + setActivationStatus(true) + } + }) + } + } + const loadBalance = async (): Promise => { const savedData = getLatestBalance(address, chain, symbol) const isFetchReady = checkIfTimePassed(savedData.lastBalanceCheck || 0, { seconds: 20 }) const isFullData = !Object.entries(savedData).find(v => v[1] === null) - let data = isNotActivated ? emptyData : savedData + let data = notActivatedStatus ? emptyData : savedData - const isFetchRequired = !isNotActivated && (isFetchReady || !isFullData) + const isFetchRequired = !notActivatedStatus && (isFetchReady || !isFullData) if (isFetchRequired) { updateLast('lastBalanceCheck', address, chain) - const fetchedData = await getBalance(address, currency?.chain || chain, tokenSymbol, contractAddress) + const fetchedData = await getBalance(symbol, address, currency?.chain || chain, tokenSymbol, contractAddress) data = { ...data, ...fetchedData } } @@ -185,7 +198,7 @@ const WalletCard: React.FC = React.memo((props) => { - + {hardware ? ( @@ -199,9 +212,9 @@ const WalletCard: React.FC = React.memo((props) => { ) : null} {walletName} - {isNotActivated ? ( + {notActivatedStatus ? ( - Need activation + Activation is required ) : ( @@ -209,7 +222,7 @@ const WalletCard: React.FC = React.memo((props) => { )} - {!isNotActivated ? ( + {!notActivatedStatus ? ( diff --git a/src/config/currencies.ts b/src/config/currencies.ts index 30d62c06..4a164d27 100644 --- a/src/config/currencies.ts +++ b/src/config/currencies.ts @@ -30,6 +30,7 @@ import toncoinLogo from '@assets/currencies/toncoin.svg' import ravencoinLogo from '@assets/currencies/rvn.svg' import digibyteLogo from '@assets/currencies/dgb.svg' import ftmLogo from '@assets/currencies/ftm.svg' +import xnoLogo from '@assets/currencies/xno.svg' // Utils import { toLower } from '@utils/format' @@ -314,6 +315,15 @@ const currencies: ICurrency[] = [ chain: 'ftm', minSendAmount: 1000, isCustomFee: true, + }, + { + name: 'Nano', + symbol: 'xno', + logo: xnoLogo, + background: '#209CE9', + chain: 'xno', + minSendAmount: 1000000000000000, + isCustomFee: false, } ] diff --git a/src/drawers/Wallets/components/Wallet/Wallet.tsx b/src/drawers/Wallets/components/Wallet/Wallet.tsx index fbacb8ff..bfff1fff 100644 --- a/src/drawers/Wallets/components/Wallet/Wallet.tsx +++ b/src/drawers/Wallets/components/Wallet/Wallet.tsx @@ -7,7 +7,7 @@ import CurrencyLogo from '@components/CurrencyLogo' import Skeleton from '@components/Skeleton' // Utils -import { getBalance } from '@utils/api' +import { getBalance } from '@utils/currencies' import { toUpper, numberFriendly, short, formatEstimated } from '@utils/format' import { updateBalance, THardware } from '@utils/wallet' @@ -58,6 +58,7 @@ const Wallet: React.FC = (props) => { const fetchBalance = async (): Promise => { const { balance, balance_usd, balance_btc, pending } = await getBalance( + symbol, address, currency?.chain || chain, chain ? symbol : undefined, diff --git a/src/externalPages/RestoreBackup/RestoreBackup.tsx b/src/externalPages/RestoreBackup/RestoreBackup.tsx index 1a6c50ed..bfc73396 100644 --- a/src/externalPages/RestoreBackup/RestoreBackup.tsx +++ b/src/externalPages/RestoreBackup/RestoreBackup.tsx @@ -47,7 +47,7 @@ const initialState: IState = { activeDrawer: null, password: '', passwordErrorLabel: null, - isPageActive: false, + isPageActive: false } const RestoreBackup: React.FC = () => { @@ -77,7 +77,7 @@ const RestoreBackup: React.FC = () => { const onConfirm = (): void => { logEvent({ - name: START_RESTORE_CONFIRM, + name: START_RESTORE_CONFIRM }) updateState({ activeDrawer: 'confirm' }) @@ -85,7 +85,7 @@ const RestoreBackup: React.FC = () => { const onConfirmRestore = (): void => { logEvent({ - name: START_RESTORE_PASSWORD, + name: START_RESTORE_PASSWORD }) if (state.passwordErrorLabel) { @@ -137,7 +137,7 @@ const RestoreBackup: React.FC = () => { } return ( - + <> Restore @@ -151,9 +151,9 @@ const RestoreBackup: React.FC = () => { -