From cb528c350c2a677afe1affcb4ce3b86e662162b8 Mon Sep 17 00:00:00 2001 From: brusher_ru Date: Mon, 14 Oct 2024 16:08:41 -0300 Subject: [PATCH 1/2] tweak: show instructions after exporting tx --- src/components/sendTx/ExportSuccessModal.tsx | 82 ++++++++++++++++++++ src/components/sendTx/SendTxModal.tsx | 16 ++++ 2 files changed, 98 insertions(+) create mode 100644 src/components/sendTx/ExportSuccessModal.tsx diff --git a/src/components/sendTx/ExportSuccessModal.tsx b/src/components/sendTx/ExportSuccessModal.tsx new file mode 100644 index 0000000..ac4ae9b --- /dev/null +++ b/src/components/sendTx/ExportSuccessModal.tsx @@ -0,0 +1,82 @@ +import { + Button, + List, + ListItem, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + Text, +} from '@chakra-ui/react'; +import { StdPublicKeys, StdTemplateKeys } from '@spacemesh/sm-codec'; + +type Props = { + templateAddress: StdTemplateKeys; + isSigned: boolean; + isOpen: boolean; + onClose: () => void; +}; + +function ExportSuccessModal({ + templateAddress, + isSigned, + isOpen, + onClose, +}: Props) { + return ( + + + + + + Transaction + {isSigned ? ' signed and ' : ' '} + exported successfully + + + To complete the transaction, you need to: + + {templateAddress === StdPublicKeys.MultiSig || + templateAddress === StdPublicKeys.Vesting ? ( + <> + + + if you own one of required keys — import the transaction and + sign + {isSigned ? ' again' : ' it'}, + + send the exported file to other parties, + + collect all the signatures, import them and publish, + + + + Signatures might be collected in sync or async way, so you can + end the signed transaction to all other parties and ask them to + sign it. Once you have collect enough signatures, you can import + all of them at once, the signatures will be combined + automatically. + + + ) : ( + + import the transaction, + {!isSigned && sign it,} + publish the signed transaction. + + )} + + + + + + + ); +} + +export default ExportSuccessModal; diff --git a/src/components/sendTx/SendTxModal.tsx b/src/components/sendTx/SendTxModal.tsx index 2582e5e..1fa6bd8 100644 --- a/src/components/sendTx/SendTxModal.tsx +++ b/src/components/sendTx/SendTxModal.tsx @@ -91,6 +91,7 @@ import TxFileReader from '../TxFileReader'; import ConfirmationModal, { ConfirmationData } from './ConfirmationModal'; import Drain from './Drain'; +import ExportSuccessModal from './ExportSuccessModal'; import MultiSigSpawn from './MultiSigSpawn'; import { DrainPayload, @@ -175,6 +176,8 @@ function SendTxModal({ isOpen, onClose }: SendTxModalProps): JSX.Element { const estimateGas = useEstimateGas(); const { setTransactions } = useAccountData(); + const exportSuccessModal = useDisclosure(); + const [isExportedSigned, setIsExportedSigned] = useState(false); const confirmationModal = useDisclosure(); const [txData, setTxData] = useState(null); const [estimatedGas, setEstimatedGas] = useState(null); @@ -287,6 +290,7 @@ function SendTxModal({ isOpen, onClose }: SendTxModalProps): JSX.Element { setTxData(null); setImportErrors(''); setIsLedgerRejected(false); + setIsExportedSigned(false); clearErrors(); onClose(); }; @@ -755,6 +759,9 @@ function SendTxModal({ isOpen, onClose }: SendTxModalProps): JSX.Element { `tx-${signWith ? 'signed' : 'unsigned'}-${hex.slice(-6)}.hex`, 'text/plain' ); + confirmationModal.onClose(); + setIsExportedSigned(!!signWith); + exportSuccessModal.onOpen(); return true; } return false; @@ -1176,6 +1183,7 @@ function SendTxModal({ isOpen, onClose }: SendTxModalProps): JSX.Element { as="u" color="brand.lightGray" size="xs" + cursor="pointer" p={1} isDisabled={ !!(currerntAccount && isVaultAccount(currerntAccount)) @@ -1319,6 +1327,14 @@ function SendTxModal({ isOpen, onClose }: SendTxModalProps): JSX.Element { insufficientFunds={insufficientFunds} /> )} + {txData && ( + + )}