Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(common): privacy mode #3273

Merged
merged 4 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ export const PairedBalance = React.forwardRef<ResetErrorRef, Props>(({amount, te
const Price = ({amount, textStyle, ignorePrivacy}: Props) => {
const styles = useStyles()
const wallet = useSelectedWallet()
const {isPrivacyOff, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const {currency, config} = useCurrencyContext()
const rate = useExchangeRate({wallet, to: currency})

const price = React.useMemo(() => {
if (rate == null) return `... ${currency}`

return isPrivacyOff || ignorePrivacy
return isPrivacyOn || !ignorePrivacy
? `${amountBreakdown(amount).bn.times(rate).toFormat(config.decimals)} ${currency}`
: `${privacyPlaceholder} ${currency}`
}, [amount, config.decimals, currency, ignorePrivacy, isPrivacyOff, privacyPlaceholder, rate])
}, [amount, config.decimals, currency, ignorePrivacy, isPrivacyOn, privacyPlaceholder, rate])

return (
<Text style={[styles.pairedBalanceText, textStyle]} testID="pairedTotalText">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export const TokenAmountItem = ({
orderType,
}: TokenAmountItemProps) => {
const {styles, colors} = useStyles()
const {privacyPlaceholder, isPrivacyOff} = usePrivacyMode()
const {privacyPlaceholder, isPrivacyOn} = usePrivacyMode()
const priceImpactRiskTheme = usePriceImpactRiskTheme(priceImpactRisk ?? 'none')

const {info} = amount
const isPrimary = isPrimaryToken(info)
const detail = isPrimary ? info.description : info.fingerprint
const name = infoExtractName(info)

const formattedQuantity = isPrivacyOff || ignorePrivacy ? amountFormatter()(amount) : privacyPlaceholder
const formattedQuantity = isPrivacyOn || !ignorePrivacy ? amountFormatter()(amount) : privacyPlaceholder

const showSwapDetails = !isPrimary && variant === 'swap'
const priceImpactRiskTextColor = orderType === 'market' ? priceImpactRiskTheme.text : colors.text
Expand Down
6 changes: 3 additions & 3 deletions apps/wallet-mobile/src/legacy/TxHistory/BalanceBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ export const BalanceBanner = React.forwardRef<ResetErrorRef>((_, ref) => {

type BalanceProps = {amount: Portfolio.Token.Amount; ignorePrivacy?: boolean}
const Balance = ({amount, ignorePrivacy}: BalanceProps) => {
const {isPrivacyOff, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const styles = useStyles()

const balance = React.useMemo(
() =>
isPrivacyOff || ignorePrivacy
isPrivacyOn || !ignorePrivacy
? amountFormatter({template: '{{value}} {{ticker}}'})(amount)
: amountFormatter({template: `${privacyPlaceholder} {{ticker}}`})(amount),
[amount, ignorePrivacy, isPrivacyOff, privacyPlaceholder],
[amount, ignorePrivacy, isPrivacyOn, privacyPlaceholder],
)

return (
Expand Down
6 changes: 3 additions & 3 deletions apps/wallet-mobile/src/legacy/TxHistory/LockedDeposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import globalMessages from '../../kernel/i18n/global-messages'

export const LockedDeposit = ({ignorePrivacy = false}: {ignorePrivacy?: boolean}) => {
const wallet = useSelectedWallet()
const {isPrivacyOff, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const {lockedAsStorageCost} = usePortfolioPrimaryBreakdown({wallet})

const amount = React.useMemo(
() =>
isPrivacyOff || ignorePrivacy
isPrivacyOn || !ignorePrivacy
? amountFormatter({template: '{{value}} {{ticker}}'})({
quantity: lockedAsStorageCost,
info: wallet.portfolioPrimaryTokenInfo,
Expand All @@ -26,7 +26,7 @@ export const LockedDeposit = ({ignorePrivacy = false}: {ignorePrivacy?: boolean}
quantity: 0n,
info: wallet.portfolioPrimaryTokenInfo,
}),
[ignorePrivacy, isPrivacyOff, lockedAsStorageCost, privacyPlaceholder, wallet.portfolioPrimaryTokenInfo],
[ignorePrivacy, isPrivacyOn, lockedAsStorageCost, privacyPlaceholder, wallet.portfolioPrimaryTokenInfo],
)

return <FormattedAmount amount={amount} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const Middle = ({style, ...props}: ViewProps) => (
const Right = ({style, ...props}: ViewProps) => <View style={[style, {padding: 4}]} {...props} />
const Amount = ({wallet, transaction}: {wallet: YoroiWallet; transaction: TransactionInfo}) => {
const {styles} = useStyles()
const {isPrivacyOff, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const amountAsMT = MultiToken.fromArray(transaction.amount)
const amount: BigNumber = amountAsMT.getDefault()
const fee = transaction.fee ? transaction.fee[0] : null
Expand All @@ -129,10 +129,10 @@ const Amount = ({wallet, transaction}: {wallet: YoroiWallet; transaction: Transa
return (
<View style={styles.amount} testID="transactionAmount">
<Text style={style} secondary={transaction.assurance === 'PENDING'}>
<Text>{isPrivacyOff && formatTokenInteger(asQuantity(amount), wallet.primaryToken)}</Text>
<Text>{isPrivacyOn && formatTokenInteger(asQuantity(amount), wallet.primaryToken)}</Text>

<Text small>
{isPrivacyOff ? formatTokenFractional(asQuantity(amount), wallet.primaryToken) : privacyPlaceholder}
{isPrivacyOn ? formatTokenFractional(asQuantity(amount), wallet.primaryToken) : privacyPlaceholder}
</Text>
</Text>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"start": {
"line": 74,
"column": 22,
"index": 2559
"index": 2557
},
"end": {
"line": 77,
"column": 3,
"index": 2691
"index": 2689
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,179 +4,179 @@
"defaultMessage": "!!!Add new wallet",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 144,
"line": 145,
"column": 21,
"index": 5055
"index": 5122
},
"end": {
"line": 147,
"line": 148,
"column": 3,
"index": 5157
"index": 5224
}
},
{
"id": "components.walletinit.createwallet.createwalletscreen.title",
"defaultMessage": "!!!Create wallet",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 148,
"line": 149,
"column": 21,
"index": 5180
"index": 5247
},
"end": {
"line": 151,
"line": 152,
"column": 3,
"index": 5296
"index": 5363
}
},
{
"id": "components.walletinit.restorewallet.restorewalletscreen.title",
"defaultMessage": "!!!Restore wallet",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 152,
"line": 153,
"column": 22,
"index": 5320
"index": 5387
},
"end": {
"line": 155,
"line": 156,
"column": 3,
"index": 5439
"index": 5506
}
},
{
"id": "components.walletinit.importreadonlywalletscreen.title",
"defaultMessage": "!!!Read-only Wallet",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 156,
"line": 157,
"column": 23,
"index": 5464
"index": 5531
},
"end": {
"line": 159,
"line": 160,
"column": 3,
"index": 5578
"index": 5645
}
},
{
"id": "components.walletinit.savereadonlywalletscreen.title",
"defaultMessage": "!!!Verify read-only wallet",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 160,
"line": 161,
"column": 27,
"index": 5607
"index": 5674
},
"end": {
"line": 163,
"line": 164,
"column": 3,
"index": 5726
"index": 5793
}
},
{
"id": "components.walletinit.createwallet.mnemonicshowscreen.title",
"defaultMessage": "!!!Recovery phrase",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 164,
"line": 165,
"column": 21,
"index": 5749
"index": 5816
},
"end": {
"line": 167,
"line": 168,
"column": 3,
"index": 5867
"index": 5934
}
},
{
"id": "components.walletinit.createwallet.mnemoniccheckscreen.title",
"defaultMessage": "!!!Recovery phrase",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 168,
"line": 169,
"column": 22,
"index": 5891
"index": 5958
},
"end": {
"line": 171,
"line": 172,
"column": 3,
"index": 6010
"index": 6077
}
},
{
"id": "components.walletinit.verifyrestoredwallet.title",
"defaultMessage": "!!!Verify restored wallet",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 172,
"line": 173,
"column": 29,
"index": 6041
"index": 6108
},
"end": {
"line": 175,
"line": 176,
"column": 3,
"index": 6155
"index": 6222
}
},
{
"id": "components.walletinit.restorewallet.walletcredentialsscreen.title",
"defaultMessage": "!!!Wallet credentials",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 176,
"line": 177,
"column": 26,
"index": 6183
"index": 6250
},
"end": {
"line": 179,
"line": 180,
"column": 3,
"index": 6310
"index": 6377
}
},
{
"id": "components.walletinit.connectnanox.connectnanoxscreen.title",
"defaultMessage": "!!!Connect to Ledger Device",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 180,
"line": 181,
"column": 21,
"index": 6333
"index": 6400
},
"end": {
"line": 183,
"line": 184,
"column": 3,
"index": 6460
"index": 6527
}
},
{
"id": "components.walletinit.connectnanox.checknanoxscreen.title",
"defaultMessage": "!!!Connect to Ledger Device",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 184,
"line": 185,
"column": 19,
"index": 6481
"index": 6548
},
"end": {
"line": 187,
"line": 188,
"column": 3,
"index": 6606
"index": 6673
}
},
{
"id": "components.walletinit.connectnanox.savenanoxscreen.title",
"defaultMessage": "!!!Save wallet",
"file": "src/features/SetupWallet/SetupWalletNavigator.tsx",
"start": {
"line": 188,
"line": 189,
"column": 18,
"index": 6626
"index": 6693
},
"end": {
"line": 191,
"line": 192,
"column": 3,
"index": 6737
"index": 6804
}
}
]
Loading
Loading