Skip to content

Commit 4616efe

Browse files
refactor: replace occurrences of USD with fiat in fee-related approver code
1 parent d860f21 commit 4616efe

File tree

9 files changed

+81
-47
lines changed

9 files changed

+81
-47
lines changed

apps/mobile/ios/Podfile.lock

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ PODS:
275275
- Yoga
276276
- ExpoSecureStore (13.0.2):
277277
- ExpoModulesCore
278+
- ExpoSharing (12.0.1):
279+
- ExpoModulesCore
278280
- ExpoSquircleView (1.1.0):
279281
- ExpoModulesCore
280282
- PocketSVG (~> 2.7.3)
@@ -1402,8 +1404,31 @@ PODS:
14021404
- React-debug
14031405
- react-native-get-random-values (1.11.0):
14041406
- React-Core
1407+
- react-native-keyboard-controller (1.12.7):
1408+
- DoubleConversion
1409+
- glog
1410+
- hermes-engine
1411+
- RCT-Folly (= 2024.01.01.00)
1412+
- RCTRequired
1413+
- RCTTypeSafety
1414+
- React-Codegen
1415+
- React-Core
1416+
- React-debug
1417+
- React-Fabric
1418+
- React-featureflags
1419+
- React-graphics
1420+
- React-ImageManager
1421+
- React-NativeModulesApple
1422+
- React-RCTFabric
1423+
- React-rendererdebug
1424+
- React-utils
1425+
- ReactCommon/turbomodule/bridging
1426+
- ReactCommon/turbomodule/core
1427+
- Yoga
14051428
- react-native-safe-area-context (4.10.1):
14061429
- React-Core
1430+
- react-native-view-shot (3.8.0):
1431+
- React-Core
14071432
- react-native-webview (13.8.6):
14081433
- DoubleConversion
14091434
- glog
@@ -1781,6 +1806,7 @@ DEPENDENCIES:
17811806
- "ExpoLocalAuthentication (from `../../../node_modules/.pnpm/[email protected][email protected]/node_modules/expo-local-authentication/ios`)"
17821807
- "ExpoModulesCore (from `../../../node_modules/.pnpm/[email protected]/node_modules/expo-modules-core`)"
17831808
- "ExpoSecureStore (from `../../../node_modules/.pnpm/[email protected]_patch_hash=b2753e05d2293ca1584f223c366d82904c6efe44d9efd76d610b7080fe816754_expo@51.0.26/node_modules/expo-secure-store/ios`)"
1809+
- "ExpoSharing (from `../../../node_modules/.pnpm/[email protected][email protected]/node_modules/expo-sharing/ios`)"
17841810
- "ExpoSquircleView (from `../../../node_modules/.pnpm/[email protected][email protected][email protected]_@[email protected]_@babel+pre_29058e40f55c91b6ad73a602246f895b/node_modules/expo-squircle-view/ios`)"
17851811
- "ExpoSystemUI (from `../../../node_modules/.pnpm/[email protected][email protected]/node_modules/expo-system-ui/ios`)"
17861812
- "ExpoWebBrowser (from `../../../node_modules/.pnpm/[email protected][email protected]/node_modules/expo-web-browser/ios`)"
@@ -1822,7 +1848,9 @@ DEPENDENCIES:
18221848
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
18231849
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
18241850
- react-native-get-random-values (from `../node_modules/react-native-get-random-values`)
1851+
- react-native-keyboard-controller (from `../node_modules/react-native-keyboard-controller`)
18251852
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
1853+
- react-native-view-shot (from `../node_modules/react-native-view-shot`)
18261854
- react-native-webview (from `../node_modules/react-native-webview`)
18271855
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
18281856
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
@@ -1940,6 +1968,8 @@ EXTERNAL SOURCES:
19401968
:path: "../../../node_modules/.pnpm/[email protected]/node_modules/expo-modules-core"
19411969
ExpoSecureStore:
19421970
:path: "../../../node_modules/.pnpm/[email protected]_patch_hash=b2753e05d2293ca1584f223c366d82904c6efe44d9efd76d610b7080fe816754_expo@51.0.26/node_modules/expo-secure-store/ios"
1971+
ExpoSharing:
1972+
:path: "../../../node_modules/.pnpm/[email protected][email protected]/node_modules/expo-sharing/ios"
19431973
ExpoSquircleView:
19441974
:path: "../../../node_modules/.pnpm/[email protected][email protected][email protected]_@[email protected]_@babel+pre_29058e40f55c91b6ad73a602246f895b/node_modules/expo-squircle-view/ios"
19451975
ExpoSystemUI:
@@ -2011,8 +2041,12 @@ EXTERNAL SOURCES:
20112041
:path: "../node_modules/react-native/ReactCommon"
20122042
react-native-get-random-values:
20132043
:path: "../node_modules/react-native-get-random-values"
2044+
react-native-keyboard-controller:
2045+
:path: "../node_modules/react-native-keyboard-controller"
20142046
react-native-safe-area-context:
20152047
:path: "../node_modules/react-native-safe-area-context"
2048+
react-native-view-shot:
2049+
:path: "../node_modules/react-native-view-shot"
20162050
react-native-webview:
20172051
:path: "../node_modules/react-native-webview"
20182052
React-nativeconfig:
@@ -2114,6 +2148,7 @@ SPEC CHECKSUMS:
21142148
ExpoLocalAuthentication: 9e02a56a4cf9868f0052656a93d4c94101a42ed7
21152149
ExpoModulesCore: 5440e96a8ee014f4fd88e77264985fd0a65f5f8c
21162150
ExpoSecureStore: 060cebcb956b80ddae09821610ac1aa9e1ac74cd
2151+
ExpoSharing: 8db05dd85081219f75989a3db2c92fe5e9741033
21172152
ExpoSquircleView: ab74c87a366c8058b846a91de679331159cc64ae
21182153
ExpoSystemUI: d4f065a016cae6721b324eb659cdee4d4cf0cb26
21192154
ExpoWebBrowser: 7595ccac6938eb65b076385fd23d035db9ecdc8e
@@ -2166,7 +2201,9 @@ SPEC CHECKSUMS:
21662201
React-logger: 7e7403a2b14c97f847d90763af76b84b152b6fce
21672202
React-Mapbuffer: 11029dcd47c5c9e057a4092ab9c2a8d10a496a33
21682203
react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06
2204+
react-native-keyboard-controller: 07a457e3a882f85591f98034e6fcc930df9a8865
21692205
react-native-safe-area-context: dcab599c527c2d7de2d76507a523d20a0b83823d
2206+
react-native-view-shot: 6b7ed61d77d88580fed10954d45fad0eb2d47688
21702207
react-native-webview: 05bae3a03a1e4f59568dfc05286c0ebf8954106c
21712208
React-nativeconfig: b0073a590774e8b35192fead188a36d1dca23dec
21722209
React-NativeModulesApple: df46ff3e3de5b842b30b4ca8a6caae6d7c8ab09f

apps/mobile/src/features/approver/components/fees/base-fee-card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface BaseFeeCardProps {
1818
}
1919

2020
export function BaseFeeCard({ amount, onPress, marketData, icon, title, time }: BaseFeeCardProps) {
21-
const fiatBalance = baseCurrencyAmountInQuoteWithFallback(amount, marketData);
21+
const fiatAmount = baseCurrencyAmountInQuoteWithFallback(amount, marketData);
2222

2323
return (
2424
<>
@@ -44,7 +44,7 @@ export function BaseFeeCard({ amount, onPress, marketData, icon, title, time }:
4444
<Box flexDirection="row" alignItems="center" gap="2">
4545
<Box alignItems="flex-end">
4646
<Balance balance={amount} variant="label02" />
47-
<Balance balance={fiatBalance} variant="label02" color="ink.text-subdued" />
47+
<Balance balance={fiatAmount} variant="label02" color="ink.text-subdued" />
4848
</Box>
4949
<ChevronRightIcon variant="small" />
5050
</Box>

apps/mobile/src/features/approver/components/fees/base-fee-option.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ interface BaseFeeOptionProps {
99
icon: ReactElement;
1010
title: string;
1111
time: string;
12-
balance: string;
13-
balanceUsd: string;
12+
formattedFeeAmount: string;
13+
formattedFiatFeeAmount: string;
1414
}
1515

1616
export function BaseFeeOption({
@@ -20,8 +20,8 @@ export function BaseFeeOption({
2020
icon,
2121
title,
2222
time,
23-
balance,
24-
balanceUsd,
23+
formattedFeeAmount,
24+
formattedFiatFeeAmount,
2525
}: BaseFeeOptionProps) {
2626
return (
2727
<>
@@ -40,8 +40,8 @@ export function BaseFeeOption({
4040
<ItemLayout
4141
titleLeft={title}
4242
captionLeft={time}
43-
titleRight={balance}
44-
captionRight={balanceUsd}
43+
titleRight={formattedFeeAmount}
44+
captionRight={formattedFiatFeeAmount}
4545
/>
4646
{disabled && (
4747
<Box

apps/mobile/src/features/approver/components/fees/bitcoin-fee-option.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface BitcoinFeeOptionProps {
1111
feeType: FeeTypes;
1212
fee: number;
1313
feeRate: number;
14-
usd: Money;
14+
fiatFee: Money;
1515
onPress(): void;
1616
isSelected: boolean;
1717
disabled: boolean;
@@ -21,7 +21,7 @@ export function BitcoinFeeOption({
2121
feeType,
2222
fee,
2323
feeRate,
24-
usd,
24+
fiatFee,
2525
onPress,
2626
isSelected,
2727
disabled,
@@ -36,11 +36,11 @@ export function BitcoinFeeOption({
3636
time={getBitcoinFeeData(feeType).time}
3737
isSelected={isSelected}
3838
disabled={disabled}
39-
balance={formatBalance({ balance: sats, isFiat: false })}
40-
balanceUsd={i18n._({
39+
formattedFeeAmount={formatBalance({ balance: sats, isFiat: false })}
40+
formattedFiatFeeAmount={i18n._({
4141
id: 'fees-sheet.fee-rate-caption',
42-
message: '{feeRate} sats/B · {balanceUsd}',
43-
values: { feeRate, balanceUsd: formatBalance({ balance: usd, isFiat: true }) },
42+
message: '{feeRate} sats/B · {fiatFee}',
43+
values: { feeRate, fiatFee: formatBalance({ balance: fiatFee, isFiat: true }) },
4444
})}
4545
/>
4646
);

apps/mobile/src/features/approver/components/fees/bitcoin-fee-sheet.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ export function FeesSheet({
3333
}: FeesSheetProps) {
3434
const { data: btcMarketData } = useBtcMarketDataQuery();
3535

36-
function getUsd(fee: number) {
37-
if (!fee) return createMoney(0, 'USD');
38-
const btcBalance = createMoney(fee, 'BTC');
39-
return baseCurrencyAmountInQuoteWithFallback(btcBalance, btcMarketData);
36+
function convertFeeToFiat(fee: number) {
37+
return baseCurrencyAmountInQuoteWithFallback(createMoney(fee, 'BTC'), btcMarketData);
4038
}
4139

4240
function getFee(feeType: FeeTypes) {
@@ -67,7 +65,7 @@ export function FeesSheet({
6765
feeType={feeType}
6866
feeRate={feeRate.toNumber()}
6967
fee={fee}
70-
usd={getUsd(fee)}
68+
fiatFee={convertFeeToFiat(fee)}
7169
/>
7270
);
7371
})}

apps/mobile/src/features/approver/components/fees/stacks-fee-option.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { BaseFeeOption } from './base-fee-option';
88
interface StacksFeeOptionProps {
99
feeType: FeeTypes;
1010
fee: Money;
11-
usd: Money;
11+
fiatFee: Money;
1212
onPress(): void;
1313
isSelected: boolean;
1414
disabled: boolean;
@@ -17,7 +17,7 @@ interface StacksFeeOptionProps {
1717
export function StacksFeeOption({
1818
feeType,
1919
fee,
20-
usd,
20+
fiatFee,
2121
onPress,
2222
isSelected,
2323
disabled,
@@ -30,8 +30,8 @@ export function StacksFeeOption({
3030
icon={getStacksFeeData(feeType).icon}
3131
title={getStacksFeeData(feeType).title}
3232
time={getStacksFeeData(feeType).time}
33-
balance={formatBalance({ balance: fee, isFiat: false })}
34-
balanceUsd={formatBalance({ balance: usd, isFiat: true })}
33+
formattedFeeAmount={formatBalance({ balance: fee, isFiat: false })}
34+
formattedFiatFeeAmount={formatBalance({ balance: fiatFee, isFiat: true })}
3535
/>
3636
);
3737
}

apps/mobile/src/features/approver/components/fees/stacks-fee-sheet.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ export function StacksFeesSheet({
3030
}: FeesSheetProps) {
3131
const { data: stxMarketData } = useStxMarketDataQuery();
3232

33-
function getUsd(fee: Money) {
34-
const usdBalance = baseCurrencyAmountInQuoteWithFallback(fee, stxMarketData);
35-
return usdBalance;
33+
function convertFeeToFiat(fee: Money) {
34+
return baseCurrencyAmountInQuoteWithFallback(fee, stxMarketData);
3635
}
3736

3837
return (
@@ -50,7 +49,7 @@ export function StacksFeesSheet({
5049
key={feeType}
5150
feeType={feeType}
5251
fee={fee}
53-
usd={getUsd(fee)}
52+
fiatFee={convertFeeToFiat(fee)}
5453
/>
5554
);
5655
})}

apps/mobile/src/features/approver/components/inputs-outputs-card.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ interface InputsAndOutputsCardProps {
1515
export function InputsAndOutputsCard({ inputs, outputs }: InputsAndOutputsCardProps) {
1616
const { data: btcMarketData } = useBtcMarketDataQuery();
1717

18-
function addBalance<T extends PsbtInput | PsbtOutput>(inputOutput: T) {
19-
const btcBalance = createMoney(Number(inputOutput.value), 'BTC');
20-
const usdBalance = baseCurrencyAmountInQuoteWithFallback(btcBalance, btcMarketData);
18+
function annotateWithMoney<T extends PsbtInput | PsbtOutput>(inputOutput: T) {
19+
const btcAmount = createMoney(Number(inputOutput.value), 'BTC');
20+
const fiatAmount = baseCurrencyAmountInQuoteWithFallback(btcAmount, btcMarketData);
2121
return {
2222
...inputOutput,
23-
btcBalance,
24-
usdBalance,
23+
btcAmount,
24+
fiatAmount,
2525
};
2626
}
2727

28-
const inputsWithBalance = inputs.map(addBalance);
28+
const inputsWithMoney = inputs.map(annotateWithMoney);
29+
const outputsWithMoney = outputs.map(annotateWithMoney);
2930

30-
const outputsWithBalance = outputs.map(addBalance);
3131
return (
3232
<Box gap="5">
3333
<Text variant="label02">
@@ -44,13 +44,13 @@ export function InputsAndOutputsCard({ inputs, outputs }: InputsAndOutputsCardPr
4444
})}
4545
</Text>
4646
<Box mx="-5">
47-
{inputsWithBalance.map(input => (
47+
{inputsWithMoney.map(annotateWithMoney).map(input => (
4848
<UtxoRow
49-
key={input.txid + input.address + input.btcBalance.amount.valueOf()}
49+
key={input.txid + input.address + input.btcAmount.amount.valueOf()}
5050
txid={input.txid}
5151
address={input.address}
52-
btcBalance={input.btcBalance}
53-
usdBalance={input.usdBalance}
52+
btcAmount={input.btcAmount}
53+
fiatAmount={input.fiatAmount}
5454
isLocked
5555
/>
5656
))}
@@ -64,12 +64,12 @@ export function InputsAndOutputsCard({ inputs, outputs }: InputsAndOutputsCardPr
6464
})}
6565
</Text>
6666
<Box mx="-5">
67-
{outputsWithBalance.map(output => (
67+
{outputsWithMoney.map(output => (
6868
<UtxoRow
69-
key={output.address + output.btcBalance.amount.valueOf()}
69+
key={output.address + output.btcAmount.amount.valueOf()}
7070
address={output.address}
71-
btcBalance={output.btcBalance}
72-
usdBalance={output.usdBalance}
71+
btcAmount={output.btcAmount}
72+
fiatAmount={output.fiatAmount}
7373
isLocked
7474
/>
7575
))}

apps/mobile/src/features/approver/components/utxo-row.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import { truncateMiddle } from '@leather.io/utils';
77
interface UtxoRowProps {
88
isLocked: boolean;
99
address: string;
10-
btcBalance: Money;
11-
usdBalance: Money;
10+
btcAmount: Money;
11+
fiatAmount: Money;
1212
txid?: string;
1313
}
1414

15-
export function UtxoRow({ isLocked, address, btcBalance, usdBalance, txid }: UtxoRowProps) {
15+
export function UtxoRow({ isLocked, address, btcAmount, fiatAmount, txid }: UtxoRowProps) {
1616
const icon = isLocked ? <LockIcon /> : <UnlockIcon color="red.action-primary-default" />;
1717

1818
return (
@@ -25,8 +25,8 @@ export function UtxoRow({ isLocked, address, btcBalance, usdBalance, txid }: Utx
2525
{txid && <Cell.Label variant="secondary">{truncateMiddle(txid)}</Cell.Label>}
2626
</Cell.Content>
2727
<Cell.Aside>
28-
<Balance balance={btcBalance} variant="label02" />
29-
<Balance balance={usdBalance} variant="label02" color="ink.text-subdued" />
28+
<Balance balance={btcAmount} variant="label02" />
29+
<Balance balance={fiatAmount} variant="label02" color="ink.text-subdued" />
3030
</Cell.Aside>
3131
</Cell.Root>
3232
);

0 commit comments

Comments
 (0)