Skip to content

Commit

Permalink
Display QRCode on publish multi-sig transaction
Browse files Browse the repository at this point in the history
typo error in create multi-sig wallet
  • Loading branch information
vorujack committed Mar 6, 2024
1 parent 971127f commit e0757df
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
39 changes: 39 additions & 0 deletions src/components/display-signed-tx/DisplaySignedTx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as wasm from 'ergo-lib-wasm-browser';
import { useEffect, useState } from 'react';
import StateMessage from '../state-message/StateMessage';
import { CircularProgress } from '@mui/material';
import DisplayQRCode from '../display-qrcode/DisplayQRCode';
import { QrCodeTypeEnum } from '@/types/qrcode';

interface DisplaySignedTxPropsType {
tx?: wasm.Transaction;
}

export const DisplaySignedTx = (props: DisplaySignedTxPropsType) => {
const [loading, setLoading] = useState(false);
const [tx, setTx] = useState('');
const [txId, setTxId] = useState('');
useEffect(() => {
if (!loading && props.tx) {
const tx = props.tx;
const id = tx.id().to_str();
if (id !== txId) {
setLoading(true);
setTx(Buffer.from(tx.sigma_serialize_bytes()).toString('base64'));
setTxId(id);
setLoading(false);
}
}
}, [loading, props.tx, txId]);
if (loading || props.tx === undefined) {
return (
<StateMessage
title={''}
description="Loading"
icon={<CircularProgress />}
color="default"
/>
);
}
return <DisplayQRCode type={QrCodeTypeEnum.ColdSignTransaction} value={tx} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const AddressConfirmMultiSig = (props: AddressConfirmMultiSigPropsType) => {
</Box>
<Typography variant="subtitle2" sx={{ mt: 1, p: 1 }}>
This is a multi-signature wallet. In order to send funds from it you
need at least {props.signers}&nbsp; signatures out of {props.threshold}{' '}
need at least {props.threshold}&nbsp; signatures out of {props.signers}{' '}
cosigning signatures.
</Typography>
</Box>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/wallet-page/multi-sig/MultiSigTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { MultiSigContext } from '@/components/sign/context/MultiSigContext';
import MultiSigToolbar from './components/MultiSigToolbar';
import ShareTransaction from './components/ShareTransaction';
import BackButtonRouter from '@/components/back-button/BackButtonRouter';
import { DisplaySignedTx } from '@/components/display-signed-tx/DisplaySignedTx';

interface MultiSigTransactionPropsType {
wallet: StateWallet;
Expand Down Expand Up @@ -71,7 +72,9 @@ const MultiSigTransaction = (props: MultiSigTransactionPropsType) => {
helperText="Please enter your mnemonics passphrase to send transaction."
/>
) : null
) : multiDataContext.state === MultiSigStateEnum.COMPLETED ? null : (
) : multiDataContext.state === MultiSigStateEnum.COMPLETED ? (
<DisplaySignedTx tx={txContext.data.partial} />
) : (
<ShareTransaction />
)}
<TransactionBoxes
Expand Down

0 comments on commit e0757df

Please sign in to comment.