From ff992d18f165d1fe424a7f2166bee6acf909d638 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Fri, 7 Jul 2023 21:51:10 +0200 Subject: [PATCH] Store only id, timestamp and txDetails --- src/components/common/BatchSidebar/index.tsx | 28 +++++++++++-------- .../DecodedData/SingleTxDecoded/index.tsx | 2 +- src/components/tx/SignOrExecuteForm/hooks.ts | 3 +- src/hooks/useDraftBatch.ts | 13 +-------- src/store/batchSlice.ts | 3 -- 5 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/components/common/BatchSidebar/index.tsx b/src/components/common/BatchSidebar/index.tsx index 10e7587dab..c54e000390 100644 --- a/src/components/common/BatchSidebar/index.tsx +++ b/src/components/common/BatchSidebar/index.tsx @@ -1,4 +1,6 @@ import type { SyntheticEvent } from 'react' +import type { TransactionDetails } from '@safe-global/safe-gateway-typescript-sdk' +import { type MetaTransactionData, OperationType } from '@safe-global/safe-core-sdk-types' import { useCallback, useContext } from 'react' import { Button, Divider, Drawer, SvgIcon, Typography } from '@mui/material' import { useDraftBatch, useUpdateBatch } from '@/hooks/useDraftBatch' @@ -9,6 +11,15 @@ import BatchTxItem from './BatchTxItem' import ConfirmBatchFlow from '@/components/tx-flow/flows/ConfirmBatch' import PlusIcon from '@/public/images/common/plus.svg' +const getData = (txDetails: TransactionDetails): MetaTransactionData => { + return { + to: txDetails.txData?.to.value ?? '', + value: txDetails.txData?.value ?? '0', + data: txDetails.txData?.hexData ?? '0x', + operation: OperationType.Call, // only calls can be batched + } +} + const BatchSidebar = ({ isOpen, onToggle }: { isOpen: boolean; onToggle: (open: boolean) => void }) => { const { setTxFlow } = useContext(TxModalContext) const batchTxs = useDraftBatch() @@ -29,7 +40,7 @@ const BatchSidebar = ({ isOpen, onToggle }: { isOpen: boolean; onToggle: (open: e.preventDefault() if (!batchTxs.length) return closeSidebar() - setTxFlow( item.txData)} />) + setTxFlow( getData(item.txDetails))} />) }, [setTxFlow, batchTxs, closeSidebar], ) @@ -48,16 +59,11 @@ const BatchSidebar = ({ isOpen, onToggle }: { isOpen: boolean; onToggle: (open:
- {batchTxs.length - ? batchTxs.map((item, index) => ( - onDeleteClick(item.txDetails.txId)} - /> - )) - : 'No transactions added yet'} + {!batchTxs.length && 'No transactions added yet'} + + {batchTxs.map((item, index) => ( + onDeleteClick(item.txDetails.txId)} /> + ))}