From 433e1031e3e750ca6e75f24d7d5ef4e5eee56638 Mon Sep 17 00:00:00 2001
From: Juliano Lazzarotto <30806844+stackchain@users.noreply.github.com>
Date: Mon, 2 Sep 2024 13:54:49 +0100
Subject: [PATCH] refactor(wallet-mobile): portfolio token
---
apps/wallet-mobile/package.json | 2 +-
.../AmountItem/AmountItem.stories.tsx | 2 +-
.../src/components/AmountItem/AmountItem.tsx | 7 +-
.../TokenIcon/TokenIcon.stories.tsx | 2 +-
.../src/components/TokenIcon/TokenIcon.tsx | 2 +-
.../Claim/useCases/ShowSuccessScreen.tsx | 2 +-
.../common/ShowBuyBanner/ShowBuyBanner.tsx | 2 +-
.../Exchange/common/useShowBuyBannerSmall.tsx | 2 +-
.../useCases/RequestSpecificAmountScreen.tsx | 2 +-
.../ConfirmTx/Summary/SecondaryTotals.tsx | 2 +-
.../ConfirmTx/Summary/SecondaryTotals.tsx | 2 +-
.../ManageCollateralScreen.stories.tsx | 6 +-
.../Settings/ManageCollateral/helpers.ts | 2 +-
.../src/features/Settings/SettingsItems.tsx | 27 ++++--
.../SelectPoolFromList/SelectPoolFromList.tsx | 3 +-
.../features/Swap/common/SwapFormProvider.tsx | 2 +-
.../src/features/Swap/common/helpers.ts | 14 +--
.../ConfirmTxScreen/TransactionSummary.tsx | 6 +-
.../CreateOrder/EditPool/ShowPoolActions.tsx | 15 ++--
.../CreateOrder/StartSwapOrderScreen.tsx | 2 +-
.../ListOrders/CompletedOrders.tsx | 2 +-
.../ListOrders/OpenOrders.tsx | 2 +-
.../Transactions/TxHistoryNavigator.tsx | 4 +-
.../useCases/TxDetails/AssetList.tsx | 5 +-
.../src/hooks/useTokenInfoLegacy.tsx | 21 -----
.../src/legacy/Dashboard/Dashboard.tsx | 2 +-
.../TransferSummary/TransferSummary.tsx | 2 +-
.../DelegationConfirmation.tsx | 2 +-
.../yoroi-wallets/cardano/cardano-wallet.ts | 22 +++--
.../src/yoroi-wallets/cardano/cip30/cip30.ts | 15 ++--
.../src/yoroi-wallets/cardano/types.ts | 2 -
.../src/yoroi-wallets/hooks/index.ts | 2 +-
.../src/yoroi-wallets/mocks/wallet.ts | 8 +-
.../src/yoroi-wallets/utils/sorting.ts | 13 +--
.../Transactions/TxHistoryNavigator.json | 88 +++++++++----------
.../src/legacy/Dashboard/Dashboard.json | 4 +-
.../TransferSummary/TransferSummary.json | 16 ++--
.../DelegationConfirmation.json | 16 ++--
packages/swap/package.json | 4 +-
packages/transfer/package.json | 3 +-
40 files changed, 161 insertions(+), 176 deletions(-)
delete mode 100644 apps/wallet-mobile/src/hooks/useTokenInfoLegacy.tsx
diff --git a/apps/wallet-mobile/package.json b/apps/wallet-mobile/package.json
index 46da6db6b3..7800ad466e 100644
--- a/apps/wallet-mobile/package.json
+++ b/apps/wallet-mobile/package.json
@@ -130,7 +130,7 @@
"@yoroi/explorers": "^1.0.2",
"@yoroi/identicon": "^1.0.1",
"@yoroi/links": "^1.5.7",
- "@yoroi/portfolio": "^1.0.2",
+ "@yoroi/portfolio": "1.0.3",
"@yoroi/resolver": "^2.0.6",
"@yoroi/setup-wallet": "^1.0.1",
"@yoroi/staking": "^1.5.2",
diff --git a/apps/wallet-mobile/src/components/AmountItem/AmountItem.stories.tsx b/apps/wallet-mobile/src/components/AmountItem/AmountItem.stories.tsx
index 0ff3daa5d9..d91af12ac6 100644
--- a/apps/wallet-mobile/src/components/AmountItem/AmountItem.stories.tsx
+++ b/apps/wallet-mobile/src/components/AmountItem/AmountItem.stories.tsx
@@ -9,7 +9,7 @@ import {Amounts} from '../../yoroi-wallets/utils'
import {Spacer} from '..'
import {AmountItem} from './AmountItem'
-const primaryAmount = Amounts.getAmount(mocks.balances, mocks.wallet.primaryTokenInfo.id)
+const primaryAmount = Amounts.getAmount(mocks.balances, mocks.wallet.portfolioPrimaryTokenInfo.id)
const secondaryAmount = Amounts.getAmount(
mocks.balances,
'698a6ea0ca99f315034072af31eaac6ec11fe8558d3f48e9775aab9d.7444524950',
diff --git a/apps/wallet-mobile/src/components/AmountItem/AmountItem.tsx b/apps/wallet-mobile/src/components/AmountItem/AmountItem.tsx
index b2c3e12d19..a1b9c7391a 100644
--- a/apps/wallet-mobile/src/components/AmountItem/AmountItem.tsx
+++ b/apps/wallet-mobile/src/components/AmountItem/AmountItem.tsx
@@ -1,6 +1,6 @@
+import {isPrimaryToken} from '@yoroi/portfolio'
import {useTheme} from '@yoroi/theme'
-import {Balance} from '@yoroi/types'
-import {Swap} from '@yoroi/types'
+import {Balance, Swap} from '@yoroi/types'
import * as React from 'react'
import {StyleSheet, View, ViewProps} from 'react-native'
@@ -17,7 +17,6 @@ export type AmountItemProps = {
amount: Balance.Amount
style?: ViewProps['style']
isPrivacyActive?: boolean
- status?: string
inWallet?: boolean
variant?: 'swap'
priceImpactRisk?: SwapPriceImpactRisk
@@ -38,7 +37,7 @@ export const AmountItem = ({
const {quantity, tokenId} = amount
const tokenInfo = useTokenInfo({wallet, tokenId})
- const isPrimary = tokenInfo.id === wallet.primaryTokenInfo.id
+ const isPrimary = isPrimaryToken(tokenInfo.id)
const name = tokenInfo.ticker ?? tokenInfo.name
const nameLabel = isEmptyString(name) ? '-' : name
const detail = isPrimary ? tokenInfo.description : tokenInfo.fingerprint
diff --git a/apps/wallet-mobile/src/components/TokenIcon/TokenIcon.stories.tsx b/apps/wallet-mobile/src/components/TokenIcon/TokenIcon.stories.tsx
index f9c07ee663..e76352d1e1 100644
--- a/apps/wallet-mobile/src/components/TokenIcon/TokenIcon.stories.tsx
+++ b/apps/wallet-mobile/src/components/TokenIcon/TokenIcon.stories.tsx
@@ -7,7 +7,7 @@ import {TokenIcon} from './TokenIcon'
storiesOf('TokenIcon', module)
.add('PrimaryToken', () => {
const wallet = mocks.wallet
- return
+ return
})
.add('Nft', () => {
const wallet = {
diff --git a/apps/wallet-mobile/src/components/TokenIcon/TokenIcon.tsx b/apps/wallet-mobile/src/components/TokenIcon/TokenIcon.tsx
index 7e5ba8dfa2..f67c3d432c 100644
--- a/apps/wallet-mobile/src/components/TokenIcon/TokenIcon.tsx
+++ b/apps/wallet-mobile/src/components/TokenIcon/TokenIcon.tsx
@@ -12,7 +12,7 @@ import {ModeratedNftIcon} from './ModeratedNftIcon'
export const TokenIcon = ({wallet, tokenId, variant}: {wallet: YoroiWallet; tokenId: string; variant?: 'swap'}) => {
const {styles} = useStyles()
const tokenInfo = useTokenInfo({wallet, tokenId})
- const isPrimary = tokenInfo.id === wallet.primaryTokenInfo.id
+ const isPrimary = tokenInfo.id === wallet.portfolioPrimaryTokenInfo.id
if (isPrimary) return
if (tokenInfo.kind === 'ft') {
diff --git a/apps/wallet-mobile/src/features/Claim/useCases/ShowSuccessScreen.tsx b/apps/wallet-mobile/src/features/Claim/useCases/ShowSuccessScreen.tsx
index 8543ab0ddc..7feeafe0fb 100644
--- a/apps/wallet-mobile/src/features/Claim/useCases/ShowSuccessScreen.tsx
+++ b/apps/wallet-mobile/src/features/Claim/useCases/ShowSuccessScreen.tsx
@@ -135,7 +135,7 @@ export const AmountList = ({amounts}: {amounts: Balance.Amounts}) => {
return (
(
)}
diff --git a/apps/wallet-mobile/src/features/Exchange/common/ShowBuyBanner/ShowBuyBanner.tsx b/apps/wallet-mobile/src/features/Exchange/common/ShowBuyBanner/ShowBuyBanner.tsx
index c61d63373d..be5d3b5c2e 100644
--- a/apps/wallet-mobile/src/features/Exchange/common/ShowBuyBanner/ShowBuyBanner.tsx
+++ b/apps/wallet-mobile/src/features/Exchange/common/ShowBuyBanner/ShowBuyBanner.tsx
@@ -18,7 +18,7 @@ export const ShowBuyBanner = () => {
selected: {network},
} = useWalletManager()
const balances = useBalances(wallet)
- const primaryAmount = Amounts.getAmount(balances, wallet.primaryTokenInfo.id)
+ const primaryAmount = Amounts.getAmount(balances, wallet.portfolioPrimaryTokenInfo.id)
const hasZeroPt = Quantities.isZero(primaryAmount.quantity)
const showSmallBanner = useShowBuyBannerSmall()
diff --git a/apps/wallet-mobile/src/features/Exchange/common/useShowBuyBannerSmall.tsx b/apps/wallet-mobile/src/features/Exchange/common/useShowBuyBannerSmall.tsx
index b281da5a59..e45d01e884 100644
--- a/apps/wallet-mobile/src/features/Exchange/common/useShowBuyBannerSmall.tsx
+++ b/apps/wallet-mobile/src/features/Exchange/common/useShowBuyBannerSmall.tsx
@@ -10,7 +10,7 @@ export const useShowBuyBannerSmall = (options?: UseQueryOptions {
const handleOnChangeAmount = (amount: string) => {
const edited = editedFormatter(amount)
const numberOfDecimals = (edited.split('.')[1] ?? []).length
- if (Number(edited) <= Number.MAX_SAFE_INTEGER && numberOfDecimals <= (wallet.primaryTokenInfo.decimals ?? 0)) {
+ if (Number(edited) <= Number.MAX_SAFE_INTEGER && numberOfDecimals <= wallet.portfolioPrimaryTokenInfo.decimals) {
setAmount(edited)
}
}
diff --git a/apps/wallet-mobile/src/features/Send/useCases/ConfirmTx/Summary/SecondaryTotals.tsx b/apps/wallet-mobile/src/features/Send/useCases/ConfirmTx/Summary/SecondaryTotals.tsx
index 6a35e0e51a..0bed122b6a 100644
--- a/apps/wallet-mobile/src/features/Send/useCases/ConfirmTx/Summary/SecondaryTotals.tsx
+++ b/apps/wallet-mobile/src/features/Send/useCases/ConfirmTx/Summary/SecondaryTotals.tsx
@@ -15,7 +15,7 @@ import {useSelectedWallet} from '../../../../WalletManager/common/hooks/useSelec
export const SecondaryTotals = ({yoroiUnsignedTx}: {yoroiUnsignedTx: YoroiUnsignedTx}) => {
const {wallet} = useSelectedWallet()
const secondaryAmounts = Amounts.remove(Amounts.getAmountsFromEntries(yoroiUnsignedTx.entries), [
- wallet.primaryTokenInfo.id,
+ wallet.portfolioPrimaryTokenInfo.id,
])
const sortedAmounts = Amounts.toArray(secondaryAmounts).sort((a, b) =>
Quantities.isGreaterThan(a.quantity, b.quantity) ? -1 : 1,
diff --git a/apps/wallet-mobile/src/features/Settings/ManageCollateral/ConfirmTx/Summary/SecondaryTotals.tsx b/apps/wallet-mobile/src/features/Settings/ManageCollateral/ConfirmTx/Summary/SecondaryTotals.tsx
index dfc43bfb63..81fbf7c10b 100644
--- a/apps/wallet-mobile/src/features/Settings/ManageCollateral/ConfirmTx/Summary/SecondaryTotals.tsx
+++ b/apps/wallet-mobile/src/features/Settings/ManageCollateral/ConfirmTx/Summary/SecondaryTotals.tsx
@@ -15,7 +15,7 @@ import {useSelectedWallet} from '../../../../WalletManager/common/hooks/useSelec
export const SecondaryTotals = ({yoroiUnsignedTx}: {yoroiUnsignedTx: YoroiUnsignedTx}) => {
const {wallet} = useSelectedWallet()
const secondaryAmounts = Amounts.remove(Amounts.getAmountsFromEntries(yoroiUnsignedTx.entries), [
- wallet.primaryTokenInfo.id,
+ wallet.portfolioPrimaryTokenInfo.id,
])
const sortedAmounts = Amounts.toArray(secondaryAmounts).sort((a, b) =>
Quantities.isGreaterThan(a.quantity, b.quantity) ? -1 : 1,
diff --git a/apps/wallet-mobile/src/features/Settings/ManageCollateral/ManageCollateralScreen.stories.tsx b/apps/wallet-mobile/src/features/Settings/ManageCollateral/ManageCollateralScreen.stories.tsx
index 5264aa6870..6e63f07388 100644
--- a/apps/wallet-mobile/src/features/Settings/ManageCollateral/ManageCollateralScreen.stories.tsx
+++ b/apps/wallet-mobile/src/features/Settings/ManageCollateral/ManageCollateralScreen.stories.tsx
@@ -21,7 +21,7 @@ const goneCollateral: YoroiWallet = {
return {
amount: {
quantity: '0',
- tokenId: mocks.wallet.primaryTokenInfo.id,
+ tokenId: mocks.wallet.portfolioPrimaryTokenInfo.id,
},
collateralId: mocks.wallet.collateralId,
utxo: undefined,
@@ -37,7 +37,7 @@ const noCollateral: YoroiWallet = {
return {
amount: {
quantity: '0',
- tokenId: mocks.wallet.primaryTokenInfo.id,
+ tokenId: mocks.wallet.portfolioPrimaryTokenInfo.id,
},
collateralId: '',
utxo: undefined,
@@ -54,7 +54,7 @@ const noFundsWallet: YoroiWallet = {
return {
amount: {
quantity: '0',
- tokenId: mocks.wallet.primaryTokenInfo.id,
+ tokenId: mocks.wallet.portfolioPrimaryTokenInfo.id,
},
collateralId: '',
utxo: undefined,
diff --git a/apps/wallet-mobile/src/features/Settings/ManageCollateral/helpers.ts b/apps/wallet-mobile/src/features/Settings/ManageCollateral/helpers.ts
index 02a5270ac4..47232671eb 100644
--- a/apps/wallet-mobile/src/features/Settings/ManageCollateral/helpers.ts
+++ b/apps/wallet-mobile/src/features/Settings/ManageCollateral/helpers.ts
@@ -14,7 +14,7 @@ export const createCollateralEntry = (wallet: YoroiWallet): YoroiEntry => {
return {
address: getCollateralAddress(wallet),
amounts: {
- [wallet.primaryTokenInfo.id]: getCollateralAmountInLovelace(),
+ [wallet.portfolioPrimaryTokenInfo.id]: getCollateralAmountInLovelace(),
},
}
}
diff --git a/apps/wallet-mobile/src/features/Settings/SettingsItems.tsx b/apps/wallet-mobile/src/features/Settings/SettingsItems.tsx
index dac9d8d589..e1dae498b1 100644
--- a/apps/wallet-mobile/src/features/Settings/SettingsItems.tsx
+++ b/apps/wallet-mobile/src/features/Settings/SettingsItems.tsx
@@ -1,12 +1,13 @@
+import {amountFormatter} from '@yoroi/portfolio'
import {useTheme} from '@yoroi/theme'
-import _ from 'lodash'
import React, {ReactElement} from 'react'
import {StyleSheet, TouchableOpacity, TouchableOpacityProps, View} from 'react-native'
import {Hr, Icon, Spacer, Text} from '../../components'
+import {isEmptyString} from '../../kernel/utils'
import {useCollateralInfo} from '../../yoroi-wallets/cardano/utxoManager/useCollateralInfo'
-import {formatTokenWithSymbol} from '../../yoroi-wallets/utils/format'
import {useSelectedWallet} from '../WalletManager/common/hooks/useSelectedWallet'
+import {usePrivacyMode} from './PrivacyMode/PrivacyMode'
const Touchable = (props: TouchableOpacityProps) =>
@@ -58,7 +59,7 @@ export const SettingsItem = ({label, children, disabled, icon, info}: SettingsIt
{children}
- {!_.isNil(info) && (
+ {!isEmptyString(info) && (
<>
@@ -85,7 +86,7 @@ export const NavigatedSettingsItem = ({label, onNavigate, icon, disabled, select
- {!_.isNil(selected) && {selected}}
+ {!isEmptyString(selected) && {selected}}
@@ -111,16 +112,26 @@ export const SettingsCollateralItem = ({label, onNavigate, icon, disabled}: Navi
const {styles, colors} = useStyles()
const {wallet} = useSelectedWallet()
const {amount} = useCollateralInfo(wallet)
+ const {isPrivacyActive, privacyPlaceholder} = usePrivacyMode()
- const formattedAmount = formatTokenWithSymbol(amount.quantity, wallet.primaryTokenInfo)
+ const formattedCollateral = React.useMemo(() => {
+ const amountCollateral = {
+ info: wallet.portfolioPrimaryTokenInfo,
+ quantity: BigInt(amount.quantity),
+ }
+
+ return !isPrivacyActive
+ ? amountFormatter({template: '{{value}} {{ticker}}'})(amountCollateral)
+ : amountFormatter({template: `${privacyPlaceholder} {{ticker}}`})(amountCollateral)
+ }, [amount.quantity, isPrivacyActive, privacyPlaceholder, wallet.portfolioPrimaryTokenInfo])
return (
- {formattedAmount}
+ {formattedCollateral}
-
+
@@ -169,7 +180,7 @@ const useStyles = () => {
})
const colors = {
- iconColor: color.gray_600,
+ icon: color.el_gray_medium,
}
return {styles, colors, color}
}
diff --git a/apps/wallet-mobile/src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.tsx b/apps/wallet-mobile/src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.tsx
index 72f2b9428c..7c62b25d16 100644
--- a/apps/wallet-mobile/src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.tsx
+++ b/apps/wallet-mobile/src/features/Swap/common/SelectPool/SelectPoolFromList/SelectPoolFromList.tsx
@@ -67,8 +67,7 @@ export const SelectPoolFromList = ({pools = []}: Props) => {
navigate.startSwap()
}
- const decimals = wallet.primaryTokenInfo.decimals ?? 0
- const ticker = wallet.primaryTokenInfo.ticker
+ const {decimals, ticker} = wallet.portfolioPrimaryTokenInfo
const protocolCapitalize = (protocol: string): string => protocol[0].toUpperCase() + protocol.substring(1)
diff --git a/apps/wallet-mobile/src/features/Swap/common/SwapFormProvider.tsx b/apps/wallet-mobile/src/features/Swap/common/SwapFormProvider.tsx
index 2f855f908e..54b97980c4 100644
--- a/apps/wallet-mobile/src/features/Swap/common/SwapFormProvider.tsx
+++ b/apps/wallet-mobile/src/features/Swap/common/SwapFormProvider.tsx
@@ -58,7 +58,7 @@ export const SwapFormProvider = ({
const hasBuyTokenSupply = poolSupply >= buyQuantity
const hasSellBalance = sellBalance >= sellQuantity
- const isSellPt = orderData.amounts.sell?.info.id === wallet.primaryTokenInfo.id
+ const isSellPt = orderData.amounts.sell?.info.id === wallet.portfolioPrimaryTokenInfo.id
const ptTotalRequired = orderData.selectedPoolCalculation?.cost.ptTotalRequired.quantity ?? 0n
const hasPtBalance = primaryTokenBalance >= (!isSellPt ? 0n : sellQuantity + ptTotalRequired)
diff --git a/apps/wallet-mobile/src/features/Swap/common/helpers.ts b/apps/wallet-mobile/src/features/Swap/common/helpers.ts
index cb1cd172ce..f9a374cdbe 100644
--- a/apps/wallet-mobile/src/features/Swap/common/helpers.ts
+++ b/apps/wallet-mobile/src/features/Swap/common/helpers.ts
@@ -1,4 +1,5 @@
import {createTypeGuardFromSchema, parseSafe} from '@yoroi/common'
+import {isPrimaryToken, primaryTokenId as ptId} from '@yoroi/portfolio'
import {useTheme} from '@yoroi/theme'
import {Balance, HW} from '@yoroi/types'
import {SwapApi} from '@yoroi/types/src/swap/api'
@@ -6,7 +7,6 @@ import {useMutation, UseMutationOptions} from 'react-query'
import {z} from 'zod'
import {convertBech32ToHex} from '../../../yoroi-wallets/cardano/common/signatureUtils'
-import {YoroiWallet} from '../../../yoroi-wallets/cardano/types'
import {generateCIP30UtxoCbor} from '../../../yoroi-wallets/cardano/utils'
import {useSelectedWallet} from '../../WalletManager/common/hooks/useSelectedWallet'
import {PRICE_IMPACT_HIGH_RISK, PRICE_IMPACT_MODERATE_RISK} from './constants'
@@ -80,7 +80,7 @@ export const parseOrderTxMetadata = (metadataJson: string, primaryTokenId: strin
}
const normalisePrimaryTokenId = (tokenId: string, primaryTokenId: string) => {
- return tokenId === '.' || tokenId === '' ? primaryTokenId : tokenId
+ return tokenId === ptId || tokenId === '' ? primaryTokenId : tokenId
}
function containsOnlyValidChars(str?: string): boolean {
@@ -88,7 +88,7 @@ function containsOnlyValidChars(str?: string): boolean {
return typeof str === 'string' && validCharsRegex.test(str)
}
-export const sortTokensByName = (a: Balance.TokenInfo, b: Balance.TokenInfo, wallet: YoroiWallet) => {
+export const sortTokensByName = (a: Balance.TokenInfo, b: Balance.TokenInfo) => {
const isValidNameA = containsOnlyValidChars(a.name)
const isValidNameB = containsOnlyValidChars(b.name)
const isValidTickerA = containsOnlyValidChars(a.ticker)
@@ -100,10 +100,10 @@ export const sortTokensByName = (a: Balance.TokenInfo, b: Balance.TokenInfo, wal
const nameB =
b.ticker?.toLocaleLowerCase() && isValidTickerB ? b.ticker?.toLocaleLowerCase() : b.name.toLocaleLowerCase()
- const isBPrimary = b.ticker === wallet.primaryTokenInfo.ticker
+ const isBPrimary = isPrimaryToken(b.id)
if (isBPrimary) return 1
- const isAPrimary = a.ticker === wallet.primaryTokenInfo.ticker
+ const isAPrimary = isPrimaryToken(a.id)
if (isAPrimary) return -1
if (!isValidNameA && isValidNameB) {
@@ -129,7 +129,9 @@ export const usePriceImpactRiskTheme = (risk: SwapPriceImpactRisk) => {
text: color.sys_magenta_500,
background: color.sys_magenta_100,
}
- } else if (risk === 'moderate') {
+ }
+
+ if (risk === 'moderate') {
return {
text: color.sys_orange_500,
background: color.sys_orange_100,
diff --git a/apps/wallet-mobile/src/features/Swap/useCases/ConfirmTxScreen/TransactionSummary.tsx b/apps/wallet-mobile/src/features/Swap/useCases/ConfirmTxScreen/TransactionSummary.tsx
index c794805387..30869702ea 100644
--- a/apps/wallet-mobile/src/features/Swap/useCases/ConfirmTxScreen/TransactionSummary.tsx
+++ b/apps/wallet-mobile/src/features/Swap/useCases/ConfirmTxScreen/TransactionSummary.tsx
@@ -60,8 +60,8 @@ export const TransactionSummary = () => {
)} ${tokenToSellName}`
const formattedFeeText = `${Quantities.format(
asQuantity((cost.batcherFee.quantity + cost.frontendFeeInfo.fee.quantity).toString()),
- wallet.primaryTokenInfo.decimals ?? 0,
- )} ${wallet.primaryTokenInfo.ticker}`
+ wallet.portfolioPrimaryTokenInfo.decimals,
+ )} ${wallet.portfolioPrimaryTokenInfo.ticker}`
const poolProviderFormatted = capitalize(pool.provider)
const poolUrl = getPoolUrlByProvider(pool.provider)
@@ -74,7 +74,7 @@ export const TransactionSummary = () => {
const minAdaInfoValue = `${Quantities.format(
asQuantity(cost.deposit.quantity.toString()),
wallet.portfolioPrimaryTokenInfo.decimals,
- )} ${wallet.primaryTokenInfo.ticker}`
+ )} ${wallet.portfolioPrimaryTokenInfo.ticker}`
const minReceivedInfoValue = `${Quantities.format(
asQuantity(calculation.buyAmountWithSlippage.quantity.toString()),
buyTokenInfo.decimals,
diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/CreateOrder/EditPool/ShowPoolActions.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/CreateOrder/EditPool/ShowPoolActions.tsx
index 04e7828db2..685d8cb2c2 100644
--- a/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/CreateOrder/EditPool/ShowPoolActions.tsx
+++ b/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/CreateOrder/EditPool/ShowPoolActions.tsx
@@ -38,15 +38,16 @@ export const ShowPoolActions = () => {
if (!isBuyTouched || !isSellTouched || calculation === undefined) return null
const {cost, pool} = calculation
+ const {decimals, ticker} = wallet.portfolioPrimaryTokenInfo
const totalFees = Quantities.format(
asQuantity((cost.batcherFee.quantity + cost.frontendFeeInfo.fee.quantity).toString()),
- wallet.primaryTokenInfo.decimals ?? 0,
+ decimals,
)
const titleTotalFeesFormatted = `${strings.total}: ${Quantities.format(
asQuantity(amounts.sell?.quantity.toString() ?? '0'),
sellTokenInfo?.decimals ?? 0,
- )} ${sellTokenName} + ${totalFees} ${wallet.primaryTokenInfo.ticker}`
+ )} ${sellTokenName} + ${totalFees} ${ticker}`
const handleOnExpand = () => setIsExpanded((state) => !state)
const totalFeesTitle = (
@@ -121,8 +122,9 @@ const ShowLimitOrderFeeBreakdown = ({totalFees}: {totalFees: string}) => {
wallet.portfolioPrimaryTokenInfo.decimals,
)
- const depositFormatted = `${deposit} ${wallet.primaryTokenInfo.ticker}`
- const totalFeesFormatted = `${totalFees} ${wallet.primaryTokenInfo.ticker}`
+ const ticker = wallet.portfolioPrimaryTokenInfo.ticker
+ const depositFormatted = `${deposit} ${ticker}`
+ const totalFeesFormatted = `${totalFees} ${ticker}`
const minReceivedFormatted = `${minReceived} ${buyTokenName}`
const feeStructure = [
@@ -210,8 +212,9 @@ const ShowMarketOrderFeeBreakdown = ({totalFees}: {totalFees: string}) => {
)
const liqFeePerc = pool.fee
- const depositFormatted = `${deposit} ${wallet.primaryTokenInfo.ticker}`
- const totalFeesFormatted = `${totalFees} ${wallet.primaryTokenInfo.ticker}`
+ const ticker = wallet.portfolioPrimaryTokenInfo.ticker
+ const depositFormatted = `${deposit} ${ticker}`
+ const totalFeesFormatted = `${totalFees} ${ticker}`
const minReceivedFormatted = `${minReceived} ${buyTokenName}`
const liqFeeQuantityFormatted = `${liqFeeQuantity} ${sellTokenName}`
const liqFeePercFormatted = strings.swapLiquidityFeeInfo(liqFeePerc, bold)
diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/CreateOrder/StartSwapOrderScreen.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/CreateOrder/StartSwapOrderScreen.tsx
index 57bc46f23c..d1c4bc93eb 100644
--- a/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/CreateOrder/StartSwapOrderScreen.tsx
+++ b/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/CreateOrder/StartSwapOrderScreen.tsx
@@ -188,7 +188,7 @@ export const StartSwapOrderScreen = () => {
swap_fees: Number(
Quantities.denominated(
asQuantity(orderData.selectedPoolCalculation.pool.batcherFee.quantity.toString()),
- Number(wallet.primaryTokenInfo.decimals),
+ Number(wallet.portfolioPrimaryTokenInfo.decimals),
),
),
})
diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/ListOrders/CompletedOrders.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/ListOrders/CompletedOrders.tsx
index 0eadcdd6b2..808b4d0ea3 100644
--- a/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/ListOrders/CompletedOrders.tsx
+++ b/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/ListOrders/CompletedOrders.tsx
@@ -111,7 +111,7 @@ export const CompletedOrders = () => {
}, [])
const transactionsInfos = useTransactionInfos({wallet})
- const completeOrders = findCompletedOrderTx(Object.values(transactionsInfos), wallet.primaryTokenInfo.id)
+ const completeOrders = findCompletedOrderTx(Object.values(transactionsInfos), wallet.portfolioPrimaryTokenInfo.id)
const tokenIds = React.useMemo(
() => _.uniq(completeOrders?.flatMap((o) => [o.metadata.sellTokenId, o.metadata.buyTokenId])),
[completeOrders],
diff --git a/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/ListOrders/OpenOrders.tsx b/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/ListOrders/OpenOrders.tsx
index a2362448af..f50a64446c 100644
--- a/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/ListOrders/OpenOrders.tsx
+++ b/apps/wallet-mobile/src/features/Swap/useCases/StartOrderSwapScreen/ListOrders/OpenOrders.tsx
@@ -163,7 +163,7 @@ export const OpenOrders = () => {
const hasCollateral = () => {
const info = wallet.getCollateralInfo()
- const primaryTokenDecimals = wallet.primaryTokenInfo.decimals ?? 0
+ const primaryTokenDecimals = wallet.portfolioPrimaryTokenInfo.decimals
return (
!!info.utxo &&
Quantities.integer(info.amount.quantity, primaryTokenDecimals) >=
diff --git a/apps/wallet-mobile/src/features/Transactions/TxHistoryNavigator.tsx b/apps/wallet-mobile/src/features/Transactions/TxHistoryNavigator.tsx
index 8764f5076b..86044bc87c 100644
--- a/apps/wallet-mobile/src/features/Transactions/TxHistoryNavigator.tsx
+++ b/apps/wallet-mobile/src/features/Transactions/TxHistoryNavigator.tsx
@@ -82,9 +82,9 @@ export const TxHistoryNavigator = () => {
const claimApi = React.useMemo(() => {
return claimApiMaker({
address: wallet.externalAddresses[0],
- primaryTokenId: wallet.primaryTokenInfo.id,
+ primaryTokenId: wallet.portfolioPrimaryTokenInfo.id,
})
- }, [wallet.externalAddresses, wallet.primaryTokenInfo.id])
+ }, [wallet.externalAddresses, wallet.portfolioPrimaryTokenInfo.id])
// navigator components
const headerRightHistory = React.useCallback(() => , [])
diff --git a/apps/wallet-mobile/src/features/Transactions/useCases/TxDetails/AssetList.tsx b/apps/wallet-mobile/src/features/Transactions/useCases/TxDetails/AssetList.tsx
index a9c3d6b3d5..3b169b2ba2 100644
--- a/apps/wallet-mobile/src/features/Transactions/useCases/TxDetails/AssetList.tsx
+++ b/apps/wallet-mobile/src/features/Transactions/useCases/TxDetails/AssetList.tsx
@@ -1,3 +1,4 @@
+import {isPrimaryToken} from '@yoroi/portfolio'
import React from 'react'
import {useIntl} from 'react-intl'
import {FlatList, Text, TouchableOpacity, View} from 'react-native'
@@ -58,8 +59,8 @@ const AssetRow = ({styles, entry, backColor, onSelect}: AssetRowProps) => {
const {wallet} = useSelectedWallet()
const {isPrivacyActive, privacyPlaceholder} = usePrivacyMode()
const tokenInfo = useTokenInfo({wallet, tokenId: entry.identifier})
- const isPrimary = tokenInfo.id === wallet.primaryTokenInfo.id
- const primaryTicker = wallet.primaryTokenInfo.ticker
+ const isPrimary = isPrimaryToken(tokenInfo.id)
+ const primaryTicker = wallet.portfolioPrimaryTokenInfo.ticker
const strings = useStrings()
const name = isEmptyString(tokenInfo.name) ? strings.unknownAssetName : tokenInfo.name
diff --git a/apps/wallet-mobile/src/hooks/useTokenInfoLegacy.tsx b/apps/wallet-mobile/src/hooks/useTokenInfoLegacy.tsx
deleted file mode 100644
index be7fba86ac..0000000000
--- a/apps/wallet-mobile/src/hooks/useTokenInfoLegacy.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-// import { isTokenId } from "@yoroi/portfolio";
-// import { Portfolio } from "@yoroi/types";
-// import { useQuery } from "react-query";
-
-/**
- * @deprecated
- *
- * It should be used when the token info is needed for a token that is not in the user's wallet
- */
-// export const useTokenInfoLegacy = ({id}: {id: Portfolio.Token.Id | string}) => {
-// const query = useQuery({
-// queryFn() {
-// if (isTokenId(id)) {
-// } else {
-
-// }
-// }
-// })
-// }
-
-export {}
diff --git a/apps/wallet-mobile/src/legacy/Dashboard/Dashboard.tsx b/apps/wallet-mobile/src/legacy/Dashboard/Dashboard.tsx
index ee4fe67c78..eb381d860e 100644
--- a/apps/wallet-mobile/src/legacy/Dashboard/Dashboard.tsx
+++ b/apps/wallet-mobile/src/legacy/Dashboard/Dashboard.tsx
@@ -51,7 +51,7 @@ export const Dashboard = () => {
const {openModal, closeModal} = useModal()
const balances = useBalances(wallet)
- const primaryAmount = Amounts.getAmount(balances, wallet.primaryTokenInfo.id)
+ const primaryAmount = Amounts.getAmount(balances, wallet.portfolioPrimaryTokenInfo.id)
const {stakingInfo, refetch: refetchStakingInfo, error, isLoading} = useStakingInfo(wallet)
const isGovernanceFeatureEnabled = useIsGovernanceFeatureEnabled(wallet)
diff --git a/apps/wallet-mobile/src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.tsx b/apps/wallet-mobile/src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.tsx
index 9cbe1075d6..ab0091864c 100644
--- a/apps/wallet-mobile/src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.tsx
+++ b/apps/wallet-mobile/src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.tsx
@@ -116,7 +116,7 @@ const Deregistrations = ({
const explorers = useExplorers(wallet.networkManager.network)
const refundAmounts = Entries.toAmounts(deregistrations)
- const primaryAmount = Amounts.getAmount(refundAmounts, wallet.primaryTokenInfo.id)
+ const primaryAmount = Amounts.getAmount(refundAmounts, wallet.portfolioPrimaryTokenInfo.id)
const addresses = Entries.toAddresses(deregistrations)
if (addresses.length < 1) return null
diff --git a/apps/wallet-mobile/src/legacy/Staking/DelegationConfirmation/DelegationConfirmation.tsx b/apps/wallet-mobile/src/legacy/Staking/DelegationConfirmation/DelegationConfirmation.tsx
index 8b4635c26b..0ac74cfa02 100644
--- a/apps/wallet-mobile/src/legacy/Staking/DelegationConfirmation/DelegationConfirmation.tsx
+++ b/apps/wallet-mobile/src/legacy/Staking/DelegationConfirmation/DelegationConfirmation.tsx
@@ -43,7 +43,7 @@ export const DelegationConfirmation = () => {
if (!yoroiUnsignedTx.staking?.delegations) throw new Error('invalid transaction')
const stakingAmount = Amounts.getAmount(
Entries.toAmounts(yoroiUnsignedTx.staking.delegations),
- wallet.primaryTokenInfo.id,
+ wallet.portfolioPrimaryTokenInfo.id,
)
const reward = approximateReward(stakingAmount.quantity)
diff --git a/apps/wallet-mobile/src/yoroi-wallets/cardano/cardano-wallet.ts b/apps/wallet-mobile/src/yoroi-wallets/cardano/cardano-wallet.ts
index 085a085056..e9587b842c 100644
--- a/apps/wallet-mobile/src/yoroi-wallets/cardano/cardano-wallet.ts
+++ b/apps/wallet-mobile/src/yoroi-wallets/cardano/cardano-wallet.ts
@@ -118,7 +118,7 @@ export const makeCardanoWallet = (
// legacy
readonly primaryToken: DefaultAsset = PRIMARY_TOKEN
- readonly primaryTokenInfo: Balance.TokenInfo = PRIMARY_TOKEN_INFO
+ // readonly primaryTokenInfo: Balance.TokenInfo = PRIMARY_TOKEN_INFO
// =================== create =================== //
static readonly build = async ({
@@ -388,7 +388,7 @@ export const makeCardanoWallet = (
const time = await this.checkServerStatus()
.then(({serverTime}) => serverTime || Date.now())
.catch(() => Date.now())
- const primaryTokenId = this.primaryTokenInfo.id
+ const primaryTokenId = this.portfolioPrimaryTokenInfo.id
const absSlotNumber = new BigNumber(getTime(time).absoluteSlot)
const changeAddr = this.getAddressedChangeAddress(addressMode)
@@ -400,7 +400,11 @@ export const makeCardanoWallet = (
: RegistrationStatus.RegisterAndDelegate
const delegatedAmountMT = {
values: [
- {identifier: this.primaryTokenInfo.id, amount: delegatedAmount, networkId: this.networkManager.chainId},
+ {
+ identifier: this.portfolioPrimaryTokenInfo.id,
+ amount: delegatedAmount,
+ networkId: this.networkManager.chainId,
+ },
],
defaults: this.primaryToken,
}
@@ -444,7 +448,7 @@ export const makeCardanoWallet = (
catalystKeyHex: string
}) {
if (implementationConfig.features.staking) {
- const primaryTokenId = this.primaryTokenInfo.id
+ const primaryTokenId = this.portfolioPrimaryTokenInfo.id
try {
const time = await this.checkServerStatus()
@@ -540,7 +544,7 @@ export const makeCardanoWallet = (
const time = await this.checkServerStatus()
.then(({serverTime}) => serverTime || Date.now())
.catch(() => Date.now())
- const primaryTokenId = this.primaryTokenInfo.id
+ const primaryTokenId = this.portfolioPrimaryTokenInfo.id
const absSlotNumber = new BigNumber(getTime(time).absoluteSlot)
const changeAddr = this.getAddressedChangeAddress(addressMode)
@@ -600,7 +604,7 @@ export const makeCardanoWallet = (
const time = await this.checkServerStatus()
.then(({serverTime}) => serverTime || Date.now())
.catch(() => Date.now())
- const primaryTokenId = this.primaryTokenInfo.id
+ const primaryTokenId = this.portfolioPrimaryTokenInfo.id
const absSlotNumber = new BigNumber(getTime(time).absoluteSlot)
const changeAddr = this.getAddressedChangeAddress(addressMode)
const addressedUtxos = await this.getAddressedUtxos()
@@ -777,7 +781,7 @@ export const makeCardanoWallet = (
const time = await this.checkServerStatus()
.then(({serverTime}) => serverTime || Date.now())
.catch(() => Date.now())
- const primaryTokenId = this.primaryTokenInfo.id
+ const primaryTokenId = this.portfolioPrimaryTokenInfo.id
const absSlotNumber = new BigNumber(getTime(time).absoluteSlot)
const changeAddr = this.getAddressedChangeAddress(addressMode)
const addressedUtxos = await this.getAddressedUtxos()
@@ -1039,7 +1043,7 @@ export const makeCardanoWallet = (
return {
utxo: collateralUtxo,
- amount: {quantity, tokenId: this.primaryTokenInfo.id},
+ amount: {quantity, tokenId: this.portfolioPrimaryTokenInfo.id},
collateralId,
isConfirmed,
}
@@ -1076,7 +1080,7 @@ export const makeCardanoWallet = (
}
fetchTokenInfo(tokenId: string) {
- return tokenId === '' || tokenId === 'ADA' || tokenId === '.' || tokenId === this.primaryTokenInfo.id
+ return tokenId === '' || tokenId === 'ADA' || tokenId === '.' || tokenId === this.portfolioPrimaryTokenInfo.id
? Promise.resolve(PRIMARY_TOKEN_INFO)
: legacyApi.getTokenInfo(tokenId, `${TOKEN_INFO_SERVICE}/metadata`, BACKEND)
}
diff --git a/apps/wallet-mobile/src/yoroi-wallets/cardano/cip30/cip30.ts b/apps/wallet-mobile/src/yoroi-wallets/cardano/cip30/cip30.ts
index 3ad81278a4..92554f8d52 100644
--- a/apps/wallet-mobile/src/yoroi-wallets/cardano/cip30/cip30.ts
+++ b/apps/wallet-mobile/src/yoroi-wallets/cardano/cip30/cip30.ts
@@ -26,6 +26,7 @@ import {
} from '../utils'
import {collateralConfig, findCollateralCandidates, utxosMaker} from '../utxoManager/utxos'
import {wrappedCsl as getCSL} from '../wrappedCsl'
+import {logger} from '../../../kernel/logger/logger'
const MSL = init('msl')
@@ -43,7 +44,7 @@ class CIP30Extension {
async getBalance(tokenId = '*'): Promise {
const {csl, release} = getCSL()
try {
- const value = await _getBalance(csl, tokenId, this.wallet.utxos, this.wallet.primaryTokenInfo.id)
+ const value = await _getBalance(csl, tokenId, this.wallet.utxos, this.wallet.portfolioPrimaryTokenInfo.id)
return copyFromCSL(CardanoMobile.Value, value)
} finally {
release()
@@ -178,7 +179,7 @@ class CIP30Extension {
assertCollateralValue(valueNum)
const bech32Address = this.wallet.externalAddresses[0]
- const amounts = {[this.wallet.primaryTokenInfo.id]: asQuantity(valueStr)}
+ const amounts = {[this.wallet.portfolioPrimaryTokenInfo.id]: asQuantity(valueStr)}
const yoroiUnsignedTx = await this.wallet.createUnsignedTx({
entries: [{address: bech32Address, amounts}],
addressMode: this.meta.addressMode,
@@ -317,12 +318,12 @@ export const _getUtxos = async (
const isValueNumber = !isNaN(Number(valueStr))
if (isValueNumber) {
- amounts[wallet.primaryTokenInfo.id] = asQuantity(valueStr)
+ amounts[wallet.portfolioPrimaryTokenInfo.id] = asQuantity(valueStr)
} else {
try {
- Object.assign(amounts, getAmountsFromValue(csl, valueStr, wallet.primaryTokenInfo.id))
- } catch (e) {
- //
+ Object.assign(amounts, getAmountsFromValue(csl, valueStr, wallet.portfolioPrimaryTokenInfo.id))
+ } catch (error) {
+ logger.error('cip30 Failed to parse value _getUtxos', {error})
}
}
@@ -419,7 +420,7 @@ const _drawCollateralInMultipleUtxos = async (
const utxos = await _getRequiredUtxos(
csl,
wallet,
- {[wallet.primaryTokenInfo.id]: quantity},
+ {[wallet.portfolioPrimaryTokenInfo.id]: quantity},
utxosWithLimitAccounted,
meta,
)
diff --git a/apps/wallet-mobile/src/yoroi-wallets/cardano/types.ts b/apps/wallet-mobile/src/yoroi-wallets/cardano/types.ts
index afc3df8a34..3978283f55 100644
--- a/apps/wallet-mobile/src/yoroi-wallets/cardano/types.ts
+++ b/apps/wallet-mobile/src/yoroi-wallets/cardano/types.ts
@@ -63,7 +63,6 @@ export interface YoroiWallet {
id: string
publicKeyHex: string
primaryToken: Readonly
- primaryTokenInfo: Readonly
readonly portfolioPrimaryTokenInfo: Readonly
// ---------------------------------------------------------------------------------------
@@ -193,7 +192,6 @@ const yoroiWalletKeys: Array = [
'id',
'publicKeyHex',
'primaryToken',
- 'primaryTokenInfo',
// Portfolio
'balance$',
diff --git a/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts b/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts
index 92a6902a53..ffe38c81a5 100644
--- a/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts
+++ b/apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts
@@ -630,7 +630,7 @@ export const useTipStatus = ({
export const useBalances = (wallet: YoroiWallet): Balance.Amounts => {
const utxos = useUtxos(wallet)
- return Utxos.toAmounts(utxos, wallet.primaryTokenInfo.id)
+ return Utxos.toAmounts(utxos, wallet.portfolioPrimaryTokenInfo.id)
}
export const useBalance = ({wallet, tokenId}: {wallet: YoroiWallet; tokenId: string | undefined}) => {
diff --git a/apps/wallet-mobile/src/yoroi-wallets/mocks/wallet.ts b/apps/wallet-mobile/src/yoroi-wallets/mocks/wallet.ts
index c6551a1a7a..eca15eace6 100644
--- a/apps/wallet-mobile/src/yoroi-wallets/mocks/wallet.ts
+++ b/apps/wallet-mobile/src/yoroi-wallets/mocks/wallet.ts
@@ -13,12 +13,7 @@ import {buildPortfolioTokenManagers} from '../../features/Portfolio/common/helpe
import {buildNetworkManagers} from '../../features/WalletManager/network-manager/network-manager'
import {fallbackTokenInfo, toTokenInfo, utf8ToHex} from '../cardano/api/utils'
import * as HASKELL_SHELLEY_TESTNET from '../cardano/constants/testnet/constants'
-import {
- CHIMERIC_ACCOUNT,
- PRIMARY_TOKEN,
- PRIMARY_TOKEN_INFO,
- STAKING_KEY_INDEX,
-} from '../cardano/constants/testnet/constants'
+import {CHIMERIC_ACCOUNT, PRIMARY_TOKEN, STAKING_KEY_INDEX} from '../cardano/constants/testnet/constants'
import {CardanoTypes, YoroiWallet} from '../cardano/types'
import {
RemotePoolMetaSuccess,
@@ -77,7 +72,6 @@ const wallet: YoroiWallet = {
id: 'wallet-id',
api: AppApi.mockAppApi,
primaryToken: PRIMARY_TOKEN,
- primaryTokenInfo: PRIMARY_TOKEN_INFO,
rewardAddressHex: 'reward-address-hex',
publicKeyHex: 'publicKeyHex',
utxos,
diff --git a/apps/wallet-mobile/src/yoroi-wallets/utils/sorting.ts b/apps/wallet-mobile/src/yoroi-wallets/utils/sorting.ts
index 30bd73b928..d3f5aae63d 100644
--- a/apps/wallet-mobile/src/yoroi-wallets/utils/sorting.ts
+++ b/apps/wallet-mobile/src/yoroi-wallets/utils/sorting.ts
@@ -1,14 +1,7 @@
+import {isPrimaryToken} from '@yoroi/portfolio'
import {Balance} from '@yoroi/types'
-import {YoroiWallet} from '../cardano/types'
-
-export const sortTokenInfos = ({
- wallet,
- tokenInfos,
-}: {
- wallet: YoroiWallet
- tokenInfos: Balance.TokenInfo[]
-}): Balance.TokenInfo[] =>
+export const sortTokenInfos = ({tokenInfos}: {tokenInfos: Balance.TokenInfo[]}): Balance.TokenInfo[] =>
tokenInfos
.sort(
alpha((tokenInfo) => {
@@ -30,7 +23,7 @@ export const sortTokenInfos = ({
}
}),
)
- .sort(toStart((tokenInfo) => tokenInfo.id === wallet.primaryTokenInfo.id))
+ .sort(toStart((tokenInfo) => isPrimaryToken(tokenInfo.id)))
// prettier-ignore
export const alpha = (transform: Transform)=>(a: T, b: T) => transform(a).localeCompare(transform(b))
diff --git a/apps/wallet-mobile/translations/messages/src/features/Transactions/TxHistoryNavigator.json b/apps/wallet-mobile/translations/messages/src/features/Transactions/TxHistoryNavigator.json
index 65c45ef6b7..24de1fcd81 100644
--- a/apps/wallet-mobile/translations/messages/src/features/Transactions/TxHistoryNavigator.json
+++ b/apps/wallet-mobile/translations/messages/src/features/Transactions/TxHistoryNavigator.json
@@ -6,12 +6,12 @@
"start": {
"line": 417,
"column": 16,
- "index": 15150
+ "index": 15168
},
"end": {
"line": 420,
"column": 3,
- "index": 15239
+ "index": 15257
}
},
{
@@ -21,12 +21,12 @@
"start": {
"line": 421,
"column": 32,
- "index": 15273
+ "index": 15291
},
"end": {
"line": 424,
"column": 3,
- "index": 15386
+ "index": 15404
}
},
{
@@ -36,12 +36,12 @@
"start": {
"line": 425,
"column": 13,
- "index": 15401
+ "index": 15419
},
"end": {
"line": 428,
"column": 3,
- "index": 15474
+ "index": 15492
}
},
{
@@ -51,12 +51,12 @@
"start": {
"line": 429,
"column": 17,
- "index": 15493
+ "index": 15511
},
"end": {
"line": 432,
"column": 3,
- "index": 15570
+ "index": 15588
}
},
{
@@ -66,12 +66,12 @@
"start": {
"line": 433,
"column": 15,
- "index": 15587
+ "index": 15605
},
"end": {
"line": 436,
"column": 3,
- "index": 15660
+ "index": 15678
}
},
{
@@ -81,12 +81,12 @@
"start": {
"line": 437,
"column": 21,
- "index": 15683
+ "index": 15701
},
"end": {
"line": 440,
"column": 3,
- "index": 15778
+ "index": 15796
}
},
{
@@ -96,12 +96,12 @@
"start": {
"line": 441,
"column": 14,
- "index": 15794
+ "index": 15812
},
"end": {
"line": 444,
"column": 3,
- "index": 15875
+ "index": 15893
}
},
{
@@ -111,12 +111,12 @@
"start": {
"line": 445,
"column": 13,
- "index": 15890
+ "index": 15908
},
"end": {
"line": 448,
"column": 3,
- "index": 15970
+ "index": 15988
}
},
{
@@ -126,12 +126,12 @@
"start": {
"line": 449,
"column": 18,
- "index": 15990
+ "index": 16008
},
"end": {
"line": 452,
"column": 3,
- "index": 16091
+ "index": 16109
}
},
{
@@ -141,12 +141,12 @@
"start": {
"line": 453,
"column": 20,
- "index": 16113
+ "index": 16131
},
"end": {
"line": 456,
"column": 3,
- "index": 16202
+ "index": 16220
}
},
{
@@ -156,12 +156,12 @@
"start": {
"line": 457,
"column": 26,
- "index": 16230
+ "index": 16248
},
"end": {
"line": 460,
"column": 3,
- "index": 16331
+ "index": 16349
}
},
{
@@ -171,12 +171,12 @@
"start": {
"line": 461,
"column": 19,
- "index": 16352
+ "index": 16370
},
"end": {
"line": 464,
"column": 3,
- "index": 16445
+ "index": 16463
}
},
{
@@ -186,12 +186,12 @@
"start": {
"line": 465,
"column": 16,
- "index": 16463
+ "index": 16481
},
"end": {
"line": 468,
"column": 3,
- "index": 16549
+ "index": 16567
}
},
{
@@ -201,12 +201,12 @@
"start": {
"line": 469,
"column": 19,
- "index": 16570
+ "index": 16588
},
"end": {
"line": 475,
"column": 3,
- "index": 16808
+ "index": 16826
}
},
{
@@ -216,12 +216,12 @@
"start": {
"line": 476,
"column": 27,
- "index": 16837
+ "index": 16855
},
"end": {
"line": 479,
"column": 3,
- "index": 16930
+ "index": 16948
}
},
{
@@ -231,12 +231,12 @@
"start": {
"line": 480,
"column": 13,
- "index": 16945
+ "index": 16963
},
"end": {
"line": 483,
"column": 3,
- "index": 17020
+ "index": 17038
}
},
{
@@ -246,12 +246,12 @@
"start": {
"line": 484,
"column": 25,
- "index": 17047
+ "index": 17065
},
"end": {
"line": 487,
"column": 3,
- "index": 17121
+ "index": 17139
}
},
{
@@ -261,12 +261,12 @@
"start": {
"line": 488,
"column": 18,
- "index": 17141
+ "index": 17159
},
"end": {
"line": 491,
"column": 3,
- "index": 17255
+ "index": 17273
}
},
{
@@ -276,12 +276,12 @@
"start": {
"line": 492,
"column": 28,
- "index": 17285
+ "index": 17303
},
"end": {
"line": 495,
"column": 3,
- "index": 17381
+ "index": 17399
}
},
{
@@ -291,12 +291,12 @@
"start": {
"line": 496,
"column": 29,
- "index": 17412
+ "index": 17430
},
"end": {
"line": 499,
"column": 3,
- "index": 17520
+ "index": 17538
}
},
{
@@ -306,12 +306,12 @@
"start": {
"line": 500,
"column": 30,
- "index": 17552
+ "index": 17570
},
"end": {
"line": 503,
"column": 3,
- "index": 17662
+ "index": 17680
}
},
{
@@ -321,12 +321,12 @@
"start": {
"line": 504,
"column": 18,
- "index": 17682
+ "index": 17700
},
"end": {
"line": 507,
"column": 3,
- "index": 17776
+ "index": 17794
}
}
]
\ No newline at end of file
diff --git a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/Dashboard.json b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/Dashboard.json
index 6d03204e9b..0cc05e4962 100644
--- a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/Dashboard.json
+++ b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/Dashboard.json
@@ -6,12 +6,12 @@
"start": {
"line": 249,
"column": 23,
- "index": 8118
+ "index": 8127
},
"end": {
"line": 252,
"column": 3,
- "index": 8251
+ "index": 8260
}
}
]
\ No newline at end of file
diff --git a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.json b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.json
index e2e7991556..da4e31cab6 100644
--- a/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.json
+++ b/apps/wallet-mobile/translations/messages/src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.json
@@ -6,12 +6,12 @@
"start": {
"line": 182,
"column": 13,
- "index": 5829
+ "index": 5838
},
"end": {
"line": 185,
"column": 3,
- "index": 5942
+ "index": 5951
}
},
{
@@ -21,12 +21,12 @@
"start": {
"line": 186,
"column": 16,
- "index": 5960
+ "index": 5969
},
"end": {
"line": 189,
"column": 3,
- "index": 6089
+ "index": 6098
}
},
{
@@ -36,12 +36,12 @@
"start": {
"line": 190,
"column": 21,
- "index": 6112
+ "index": 6121
},
"end": {
"line": 193,
"column": 3,
- "index": 6242
+ "index": 6251
}
},
{
@@ -51,12 +51,12 @@
"start": {
"line": 194,
"column": 25,
- "index": 6269
+ "index": 6278
},
"end": {
"line": 199,
"column": 3,
- "index": 6504
+ "index": 6513
}
}
]
\ No newline at end of file
diff --git a/apps/wallet-mobile/translations/messages/src/legacy/Staking/DelegationConfirmation/DelegationConfirmation.json b/apps/wallet-mobile/translations/messages/src/legacy/Staking/DelegationConfirmation/DelegationConfirmation.json
index 513f8c34df..0ab336ea48 100644
--- a/apps/wallet-mobile/translations/messages/src/legacy/Staking/DelegationConfirmation/DelegationConfirmation.json
+++ b/apps/wallet-mobile/translations/messages/src/legacy/Staking/DelegationConfirmation/DelegationConfirmation.json
@@ -6,12 +6,12 @@
"start": {
"line": 194,
"column": 23,
- "index": 6291
+ "index": 6300
},
"end": {
"line": 197,
"column": 3,
- "index": 6405
+ "index": 6414
}
},
{
@@ -21,12 +21,12 @@
"start": {
"line": 198,
"column": 10,
- "index": 6417
+ "index": 6426
},
"end": {
"line": 201,
"column": 3,
- "index": 6517
+ "index": 6526
}
},
{
@@ -36,12 +36,12 @@
"start": {
"line": 202,
"column": 22,
- "index": 6541
+ "index": 6550
},
"end": {
"line": 205,
"column": 3,
- "index": 6711
+ "index": 6720
}
},
{
@@ -51,12 +51,12 @@
"start": {
"line": 206,
"column": 15,
- "index": 6728
+ "index": 6737
},
"end": {
"line": 209,
"column": 3,
- "index": 6847
+ "index": 6856
}
}
]
\ No newline at end of file
diff --git a/packages/swap/package.json b/packages/swap/package.json
index c284286aa1..b0b8f0c6e1 100644
--- a/packages/swap/package.json
+++ b/packages/swap/package.json
@@ -151,7 +151,7 @@
"@types/react-test-renderer": "^18.0.7",
"@yoroi/api": "^1.5.2",
"@yoroi/common": "^1.5.4",
- "@yoroi/portfolio": "^1.0.2",
+ "@yoroi/portfolio": "1.0.3",
"@yoroi/types": "^1.5.7",
"bignumber.js": "^9.0.1",
"commitlint": "^17.0.2",
@@ -179,7 +179,7 @@
"@react-native-async-storage/async-storage": ">= 1.19.3 <= 1.20.0",
"@yoroi/api": "1.5.2",
"@yoroi/common": "1.5.4",
- "@yoroi/portfolio": "1.0.2",
+ "@yoroi/portfolio": "1.0.3",
"bignumber.js": "^9.0.1",
"immer": "^10.0.2",
"react": ">= 16.8.0 <= 19.0.0",
diff --git a/packages/transfer/package.json b/packages/transfer/package.json
index 4179456abf..41449b5f9c 100644
--- a/packages/transfer/package.json
+++ b/packages/transfer/package.json
@@ -138,6 +138,7 @@
"@types/jest": "^29.5.12",
"@types/react": "^18.2.55",
"@types/react-test-renderer": "^18.0.7",
+ "@yoroi/portfolio": "1.0.3",
"@yoroi/types": "^1.5.7",
"commitlint": "^17.0.2",
"del-cli": "^5.0.0",
@@ -161,7 +162,7 @@
},
"peerDependencies": {
"@tanstack/react-query": "4.36.1",
- "@yoroi/portfolio": "1.0.2",
+ "@yoroi/portfolio": "1.0.3",
"@yoroi/resolver": "2.0.6",
"immer": "^10.0.2",
"react": ">= 16.8.0 <= 19.0.0",