diff --git a/src/components/FormInput.tsx b/src/components/FormInput.tsx index 24acb3c..43f2394 100644 --- a/src/components/FormInput.tsx +++ b/src/components/FormInput.tsx @@ -24,7 +24,7 @@ type Props = PropsWithChildren<{ isSubmitted?: boolean; inputAddon?: ReactNode; inputProps?: InputProps; - hint?: string; + hint?: ReactNode; }>; function FormInput({ diff --git a/src/components/TxListItem.tsx b/src/components/TxListItem.tsx index 3906093..6b54724 100644 --- a/src/components/TxListItem.tsx +++ b/src/components/TxListItem.tsx @@ -1,5 +1,7 @@ import { CheckCircleIcon } from '@chakra-ui/icons'; -import { Box, Card, CardBody, Flex, Text } from '@chakra-ui/react'; +import { Box, Card, CardBody, Flex, Icon, Text } from '@chakra-ui/react'; +import { StdMethods } from '@spacemesh/sm-codec'; +import { IconArrowBigDownFilled, IconArrowBigLeftFilled, IconArrowBigLeftLinesFilled, IconArrowBigRightFilled, IconQuestionMark } from '@tabler/icons-react'; import { Bech32Address } from '../types/common'; import { Transaction } from '../types/tx'; @@ -7,7 +9,7 @@ import { getAbbreviatedHexString } from '../utils/abbr'; import { formatTimestamp } from '../utils/datetime'; import { epochByLayer, timestampByLayer } from '../utils/layers'; import { formatSmidge } from '../utils/smh'; -import { getStatusColor, getTxBalance } from '../utils/tx'; +import { getStatusColor, getTxBalance, getTxType, TxType } from '../utils/tx'; type TxListItemProps = { tx: Transaction; @@ -18,6 +20,41 @@ type TxListItemProps = { layersPerEpoch: number; }; +function TxIcon({ tx, host }: { tx: Transaction; host: Bech32Address }) { + const color = getStatusColor(tx.state); + const IconComponent = (() => { + switch (tx.template.method) { + case StdMethods.Spawn: + return IconArrowBigDownFilled; + case StdMethods.Spend: { + switch (getTxType(tx, host)) { + case TxType.Received: + return IconArrowBigRightFilled; + case TxType.Spent: + case TxType.Self: + default: + return IconArrowBigLeftFilled; + } + } + case StdMethods.Drain: + return IconArrowBigLeftLinesFilled; + default: + return IconQuestionMark; + } + })(); + + return ( + + ); +} + function TxListItem({ tx, host, @@ -42,11 +79,17 @@ function TxListItem({ + {getAbbreviatedHexString(tx.id)} - - - - {tx.template.methodName} + + {tx.template.methodName} + {tx.layer ? ( diff --git a/src/components/sendTx/SendTxModal.tsx b/src/components/sendTx/SendTxModal.tsx index 4fcb3b3..b4ec0c5 100644 --- a/src/components/sendTx/SendTxModal.tsx +++ b/src/components/sendTx/SendTxModal.tsx @@ -1153,13 +1153,24 @@ function SendTxModal({ isOpen, onClose }: SendTxModalProps): JSX.Element { errors={errors} isSubmitted={isSubmitted} inputAddon={ - - Smidge + + Smidge per unit } - // eslint-disable-next-line max-len - hint="How much to pay for gas: During high network traffic, - transactions with higher gas fees are prioritized." + hint={ + <> + + How much to pay per gas unit +
+ During high network traffic, transactions with higher + gas prices are prioritized. +
+ + Example: transaction costs 25,000 gas units, gas price + is 2 smidges, the total fee will be 50,000 smidges. + + + } />
@@ -1178,10 +1189,17 @@ function SendTxModal({ isOpen, onClose }: SendTxModalProps): JSX.Element { })} errors={errors} isSubmitted={isSubmitted} - // eslint-disable-next-line max-len - hint="The number is used only once to ensure each transaction is unique. - It increments automatically, - but can also be set manually if needed." + hint={ + + The transaction counter +
+ The number is used only to ensure each transaction is + unique. +
+ It increments automatically, but can be set manually if + needed. +
+ } />
diff --git a/src/store/useAccountData.ts b/src/store/useAccountData.ts index 1f270e5..c5dd037 100644 --- a/src/store/useAccountData.ts +++ b/src/store/useAccountData.ts @@ -68,6 +68,11 @@ const getAccountRewards = (net: NetworkState, address: Bech32Address) => const getAccountTransactions = (net: NetworkState, address: Bech32Address) => (net.txIds?.[address] || []) .map((txId) => net.transactions?.[txId]) + .sort((a, b) => { + if (!a?.layer) return 1; + if (!b?.layer) return -1; + return a.layer - b.layer; + }) .filter(Boolean) as Transaction[]; // Store