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

added USD asset price next to currency rows (send) in tx sim #5374

Merged
merged 8 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/graphql/queries/metadata.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ fragment change on TransactionSimulationChange {
asset {
...asset
}
price
quantity
}
fragment target on TransactionSimulationTarget {
Expand Down
14 changes: 12 additions & 2 deletions src/screens/SignTransactionSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import {
TransactionSimulationAsset,
TransactionSimulationMeta,
TransactionSimulationResult,
TransactionSimulationChange,
TransactionScanResultType,
} from '@/graphql/__generated__/metadataPOST';
import { Network } from '@/networks/types';
Expand Down Expand Up @@ -1514,7 +1515,7 @@ const SimulationCard = ({
},
[isLoading, simulationUnavailable]
);

console.log('simulation out', simulation?.out?.price);
dereknelson marked this conversation as resolved.
Show resolved Hide resolved
const renderSimulationEventRows = useMemo(() => {
if (isBalanceEnough === false) return null;

Expand All @@ -1536,6 +1537,7 @@ const SimulationCard = ({
key={`${change?.asset?.assetCode}-${change?.quantity}`}
amount={change?.quantity || '10'}
asset={change?.asset}
price={change?.price}
eventType="send"
/>
);
Expand Down Expand Up @@ -2057,10 +2059,12 @@ const SimulatedEventRow = ({
amount,
asset,
eventType,
price,
}: {
amount: string | 'unlimited';
asset: TransactionSimulationAsset | undefined;
eventType: EventType;
price?: number | undefined;
}) => {
const { colors } = useTheme();

Expand Down Expand Up @@ -2108,7 +2112,8 @@ const SimulatedEventRow = ({
if (asset?.type === TransactionAssetType.Native) {
assetCode = ETH_ADDRESS;
}

const showUSD = eventType === 'send';
dereknelson marked this conversation as resolved.
Show resolved Hide resolved
const formattedPrice = `$${price?.toFixed?.(2)}`;
dereknelson marked this conversation as resolved.
Show resolved Hide resolved
return (
<Box
justifyContent="center"
Expand All @@ -2126,6 +2131,11 @@ const SimulatedEventRow = ({
<Text color="label" size="17pt" weight="bold">
{eventInfo.label}
</Text>
{showUSD && (
<Text color="labelTertiary" size="15pt" weight="bold">
{formattedPrice}
</Text>
)}
dereknelson marked this conversation as resolved.
Show resolved Hide resolved
</Inline>
<Inline alignVertical="center" space={{ custom: 7 }} wrap={false}>
<Bleed vertical="6px">
Expand Down