Skip to content

Commit

Permalink
refactor(wallet-mobile): tx review
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss committed Oct 9, 2024
1 parent 31693aa commit 00d58c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import {CopiableText} from '../../../common/CopiableText'
import {Divider} from '../../../common/Divider'
import {useAddressType} from '../../../common/hooks/useAddressType'
import {useStrings} from '../../../common/hooks/useStrings'
import {useReviewTx} from '../../../common/ReviewTxProvider'
import {ReviewTxState} from '../../../common/ReviewTxProvider'
import {TokenItem} from '../../../common/TokenItem'
import {FormattedOutputs, FormattedTx} from '../../../common/types'

export const OverviewTab = ({tx}: {tx: FormattedTx}) => {
export const OverviewTab = ({tx, operations}: {tx: FormattedTx; operations: ReviewTxState['operations']}) => {
const {styles} = useStyles()

const notOwnedOutputs = React.useMemo(() => tx.outputs.filter((output) => !output.ownAddress), [tx.outputs])
Expand All @@ -36,7 +36,7 @@ export const OverviewTab = ({tx}: {tx: FormattedTx}) => {

<SenderSection tx={tx} notOwnedOutputs={notOwnedOutputs} ownedOutputs={ownedOutputs} />

<OperationsSection />
<OperationsSection operations={operations} />
</View>
)
}
Expand Down Expand Up @@ -186,9 +186,7 @@ const ReceiverSection = ({notOwnedOutputs}: {notOwnedOutputs: FormattedOutputs})
)
}

const OperationsSection = () => {
const {operations} = useReviewTx()

const OperationsSection = ({operations}: {operations: ReviewTxState['operations']}) => {
if (operations === null || (Array.isArray(operations) && operations.length === 0)) return null

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const MaterialTab = createMaterialTopTabNavigator()
export const ReviewTxScreen = () => {
const {styles} = useStyles()
const strings = useStrings()
const {unsignedTx, onSuccess, onError} = useReviewTx()
const {unsignedTx, operations, onSuccess, onError} = useReviewTx()

if (unsignedTx === null) throw new Error('ReviewTxScreen: missing unsignedTx')

Expand All @@ -32,9 +32,7 @@ export const ReviewTxScreen = () => {
const txBody = useTxBody({unsignedTx})
const formatedTx = useFormattedTx(txBody)

console.log('txBody', JSON.stringify(txBody, null, 2))

const OverViewTabMemo = React.memo(() => <OverviewTab tx={formatedTx} />)
const OverViewTabMemo = React.memo(() => <OverviewTab tx={formatedTx} operations={operations} />)
const UTxOsTabMemo = React.memo(() => <UTxOsTab tx={formatedTx} />)

return (
Expand Down

0 comments on commit 00d58c7

Please sign in to comment.