Skip to content

Commit

Permalink
display qrcode on cold transaction signing
Browse files Browse the repository at this point in the history
  • Loading branch information
vorujack committed Mar 7, 2024
1 parent 6b48992 commit 4846cee
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import TransactionBoxes from '@/components/sign/transaction-boxes/TransactionBox
import { TxDataContext } from '@/components/sign/context/TxDataContext';
import { Button, IconButton } from '@mui/material';
import { Inventory2Outlined } from '@mui/icons-material';
import { getSignButtonLabel } from '@/utils/functions';
import { SelectableWalletContext } from '@/components/sign/context/SelectableWalletContext';
import getChain from '@/utils/networks';
import CenterMessage from '@/components/state-message/CenterMessage';
import SvgIcon from '@/icons/SvgIcon';
import SignButtonLabel from '@/components/sign-button-label/SignButtonLabel';

interface ColdSigningRequestPropsType {
scanned: string;
Expand Down Expand Up @@ -104,7 +104,7 @@ const ColdSigningRequest = (props: ColdSigningRequestPropsType) => {
error === '' &&
txSignContext.signed === '' ? (
<Button disabled={hasError} onClick={() => txSignContext.handle()}>
{getSignButtonLabel(walletContext.wallet.type)}
<SignButtonLabel wallet={walletContext.wallet}/>
</Button>
) : undefined
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BackButton from '@/components/back-button/BackButton';
import SignButtonLabel from '@/components/sign-button-label/SignButtonLabel';
import { TxDataContext } from '@/components/sign/context/TxDataContext';
import TxSignContext from '@/components/sign/context/TxSignContext';
import TransactionBoxes from '@/components/sign/transaction-boxes/TransactionBoxes';
Expand All @@ -9,7 +10,6 @@ import AppFrame from '@/layouts/AppFrame';
import SignTx from '@/pages/wallet-page/send/sign-tx/SignTx';
import { StateWallet } from '@/store/reducer/wallet';
import { QrCodeScannedComponentPropsType } from '@/types/qrcode';
import { getSignButtonLabel } from '@/utils/functions';
import { Inventory2Outlined } from '@mui/icons-material';
import {
Button,
Expand Down Expand Up @@ -78,7 +78,7 @@ const ErgoPay = (props: QrCodeScannedComponentPropsType) => {
</Button>
) : context.tx && wallet ? (
<Button disabled={hasError} onClick={() => signContext.handle()}>
{getSignButtonLabel(wallet.type)}
<SignButtonLabel wallet={wallet}/>
</Button>
) : undefined
}
Expand Down
17 changes: 17 additions & 0 deletions src/components/sign-button-label/SignButtonLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { WalletType } from "@/db/entities/Wallet";
import { useSignerWallet } from "@/hooks/multi-sig/useSignerWallet";
import { StateWallet } from "@/store/reducer/wallet"

interface SignButtonLabelPropsType {
wallet: StateWallet
}

const SignButtonLabel = (props: SignButtonLabelPropsType) => {
const signer = useSignerWallet(props.wallet);
if (props.wallet.type === WalletType.ReadOnly || (signer !== undefined && signer.type == WalletType.ReadOnly)) return 'Scan Signed';
if (props.wallet.type === WalletType.Normal) return 'Sign';
if (props.wallet.type === WalletType.MultiSig) return 'Start Signing';
}


export default SignButtonLabel;
3 changes: 2 additions & 1 deletion src/pages/wallet-page/dapps/WalletDAppView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { StateWallet } from '@/store/reducer/wallet';
import PrevIcon from '@mui/icons-material/ArrowBackIos';
import TxSignContext from '@/components/sign/context/TxSignContext';
import SignTx from '../send/sign-tx/SignTx';
import SignButtonLabel from '@/components/sign-button-label/SignButtonLabel';

interface WalletDAppViewPropsType {
wallet: StateWallet;
Expand Down Expand Up @@ -71,7 +72,7 @@ const WalletDAppView = (props: WalletDAppViewPropsType) => {
disabled={hasError}
onClick={() => txSignContext.handle()}
>
Sign and Publish
<SignButtonLabel wallet={props.wallet}/>
</Button>
</Grid>
</Grid>
Expand Down
1 change: 1 addition & 0 deletions src/pages/wallet-page/home/WalletHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface WalletHomePropsType {

const WalletHome = (props: WalletHomePropsType) => {
const signer = useSignerWallet(props.wallet);
console.log(signer)
return (
<HomeFrame title={props.wallet.name} id={props.wallet.id}>
<WalletCard wallet={props.wallet} />
Expand Down
3 changes: 2 additions & 1 deletion src/pages/wallet-page/send/WalletSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { StateWallet } from '@/store/reducer/wallet';
import SendAmount from './send-amount/SendAmount';
import SignTx from './sign-tx/SignTx';
import { getSignButtonLabel } from '@/utils/functions';
import SignButtonLabel from '@/components/sign-button-label/SignButtonLabel';

interface WalletSendPropsType {
wallet: StateWallet;
Expand Down Expand Up @@ -79,7 +80,7 @@ const WalletSend = (props: WalletSendPropsType) => {
onClick={handleNext}
endIcon={step === STEPS_COUNTS ? undefined : <NextIcon />}
>
{getNextLabel()}
<SignButtonLabel wallet={props.wallet}/>
</Button>
</Grid>
</Grid>
Expand Down
12 changes: 12 additions & 0 deletions src/pages/wallet-page/send/sign-tx/WalletSignMultiSig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Box, Typography } from '@mui/material';
import { useEffect } from 'react';
import useReducedTx from '@/hooks/useReducedTx';
import { StateWallet } from '@/store/reducer/wallet';
import { useSignerWallet } from '@/hooks/multi-sig/useSignerWallet';
import { WalletType } from '@/db/entities/Wallet';
import WalletSignReadonly from './WalletSignReadonly';

interface WalletSignMultiSigPropsType {
networkType: string;
Expand All @@ -14,6 +17,15 @@ const WalletSignMultiSig = (props: WalletSignMultiSigPropsType) => {
useEffect(() => {
props.setHasError(isValid);
});
const signer = useSignerWallet(props.wallet);
if(signer?.type === WalletType.ReadOnly){
return (
<WalletSignReadonly
wallet={props.wallet}
setHasError={props.setHasError}
/>
)
}
return (
<Box>
<Typography>
Expand Down

0 comments on commit 4846cee

Please sign in to comment.