-
-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WalletConnect #15803
base: develop
Are you sure you want to change the base?
WalletConnect #15803
Changes from all commits
88f8a12
3288eb9
bbef75b
f9ee0ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -38,18 +38,17 @@ export const ConnectPopupModal = ({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{processName && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Paragraph margin={{ top: spacings.xs }}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Process: <strong>{processName}</strong> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Translation id="TR_CONNECT_MODAL_PROCESS" /> <strong>{processName}</strong> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</Paragraph> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{origin && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Paragraph> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Web Origin: <strong>{origin}</strong> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Translation id="TR_CONNECT_MODAL_WEB_ORIGIN" /> <strong>{origin}</strong> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</Paragraph> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
39
to
48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add origin validation and display warning for untrusted origins. Enhance security by validating and highlighting potentially unsafe origins. +const isUntrustedOrigin = (origin: string) => {
+ // Add origin validation logic
+ return !origin.startsWith('https://');
+};
{origin && (
<Paragraph>
<Translation id="TR_CONNECT_MODAL_WEB_ORIGIN" /> <strong>{origin}</strong>
+ {isUntrustedOrigin(origin) && (
+ <Paragraph color="warning">
+ <Translation id="TR_CONNECT_MODAL_UNTRUSTED_ORIGIN_WARNING" />
+ </Paragraph>
+ )}
</Paragraph>
)} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Paragraph variant="tertiary" margin={{ top: spacings.xs }}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
A 3rd party application is trying to connect to your device. Do you want to allow this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
action? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Translation id="TR_CONNECT_MODAL_REQUEST_DESCRIPTION" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</Paragraph> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</NewModal> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
); |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,95 @@ | ||||||||||||||
import { | ||||||||||||||
selectPendingProposal, | ||||||||||||||
sessionProposalApproveThunk, | ||||||||||||||
sessionProposalRejectThunk, | ||||||||||||||
} from '@suite-common/walletconnect'; | ||||||||||||||
import { Banner, H2, NewModal, Note, Paragraph } from '@trezor/components'; | ||||||||||||||
import { spacings } from '@trezor/theme'; | ||||||||||||||
|
||||||||||||||
import { onCancel } from 'src/actions/suite/modalActions'; | ||||||||||||||
import { Translation } from 'src/components/suite'; | ||||||||||||||
import { useDispatch, useSelector } from 'src/hooks/suite'; | ||||||||||||||
|
||||||||||||||
interface WalletConnectProposalModalProps { | ||||||||||||||
eventId: number; | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export const WalletConnectProposalModal = ({ eventId }: WalletConnectProposalModalProps) => { | ||||||||||||||
const dispatch = useDispatch(); | ||||||||||||||
const pendingProposal = useSelector(selectPendingProposal); | ||||||||||||||
|
||||||||||||||
const handleAccept = () => { | ||||||||||||||
dispatch(sessionProposalApproveThunk({ eventId })); | ||||||||||||||
dispatch(onCancel()); | ||||||||||||||
}; | ||||||||||||||
const handleReject = () => { | ||||||||||||||
dispatch(sessionProposalRejectThunk({ eventId })); | ||||||||||||||
dispatch(onCancel()); | ||||||||||||||
}; | ||||||||||||||
martykan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
|
||||||||||||||
return ( | ||||||||||||||
<NewModal | ||||||||||||||
onCancel={handleReject} | ||||||||||||||
iconName="plugs" | ||||||||||||||
variant="primary" | ||||||||||||||
bottomContent={ | ||||||||||||||
<> | ||||||||||||||
<NewModal.Button variant="tertiary" onClick={handleReject}> | ||||||||||||||
<Translation id="TR_CANCEL" /> | ||||||||||||||
</NewModal.Button> | ||||||||||||||
<NewModal.Button | ||||||||||||||
variant="primary" | ||||||||||||||
onClick={handleAccept} | ||||||||||||||
isDisabled={ | ||||||||||||||
!pendingProposal || pendingProposal.expired || pendingProposal.isScam | ||||||||||||||
} | ||||||||||||||
> | ||||||||||||||
<Translation id="TR_CONFIRM" /> | ||||||||||||||
</NewModal.Button> | ||||||||||||||
</> | ||||||||||||||
} | ||||||||||||||
heading={<Translation id="TR_TREZOR_CONNECT" />} | ||||||||||||||
> | ||||||||||||||
<H2>{pendingProposal?.params.proposer.metadata.name}</H2> | ||||||||||||||
|
||||||||||||||
<Paragraph>{pendingProposal?.params.proposer.metadata.url}</Paragraph> | ||||||||||||||
|
||||||||||||||
Comment on lines
+53
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add null checks for pendingProposal metadata. The metadata access could throw if Apply this diff: - <H2>{pendingProposal?.params.proposer.metadata.name}</H2>
+ <H2>{pendingProposal?.params?.proposer?.metadata?.name}</H2>
- <Paragraph>{pendingProposal?.params.proposer.metadata.url}</Paragraph>
+ <Paragraph>{pendingProposal?.params?.proposer?.metadata?.url}</Paragraph> 📝 Committable suggestion
Suggested change
|
||||||||||||||
{!pendingProposal?.isScam && pendingProposal?.validation === 'VALID' && ( | ||||||||||||||
<Note variant="info" iconName="shieldCheckFilled"> | ||||||||||||||
<Translation id="TR_WALLETCONNECT_SERVICE_VERIFIED" /> | ||||||||||||||
</Note> | ||||||||||||||
)} | ||||||||||||||
{!pendingProposal?.isScam && pendingProposal?.validation === 'UNKNOWN' && ( | ||||||||||||||
<Note variant="warning" iconName="shieldWarningFilled"> | ||||||||||||||
<Translation id="TR_WALLETCONNECT_SERVICE_UNKNOWN" /> | ||||||||||||||
</Note> | ||||||||||||||
)} | ||||||||||||||
{(pendingProposal?.isScam || pendingProposal?.validation === 'INVALID') && ( | ||||||||||||||
<Note variant="destructive" iconName="shieldWarningFilled"> | ||||||||||||||
<Translation id="TR_WALLETCONNECT_SERVICE_DANGEROUS" /> | ||||||||||||||
</Note> | ||||||||||||||
)} | ||||||||||||||
|
||||||||||||||
<Paragraph variant="tertiary" margin={{ top: spacings.xs }}> | ||||||||||||||
<Translation id="TR_WALLETCONNECT_REQUEST" /> | ||||||||||||||
</Paragraph> | ||||||||||||||
|
||||||||||||||
{pendingProposal?.isScam && ( | ||||||||||||||
<Banner variant="destructive" margin={{ top: spacings.xs }}> | ||||||||||||||
<Translation id="TR_WALLETCONNECT_IS_SCAM" /> | ||||||||||||||
</Banner> | ||||||||||||||
)} | ||||||||||||||
{pendingProposal?.validation === 'INVALID' && ( | ||||||||||||||
<Banner variant="destructive" margin={{ top: spacings.xs }}> | ||||||||||||||
<Translation id="TR_WALLETCONNECT_UNABLE_TO_VERIFY" /> | ||||||||||||||
</Banner> | ||||||||||||||
)} | ||||||||||||||
|
||||||||||||||
{pendingProposal?.expired && ( | ||||||||||||||
<Banner variant="warning" margin={{ top: spacings.xs }}> | ||||||||||||||
<Translation id="TR_WALLETCONNECT_REQUEST_EXPIRED" /> | ||||||||||||||
</Banner> | ||||||||||||||
)} | ||||||||||||||
</NewModal> | ||||||||||||||
); | ||||||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance error handling for WalletConnect URIs.
The WalletConnect URI handling could be more robust with proper error handling and user feedback.
📝 Committable suggestion