Skip to content

feat: Validate signatures in Solana connector #502

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

Merged
merged 32 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
39cc082
feat: enhance SolanaConnector with signature validation and local sto…
nelitow Mar 24, 2025
1afd433
refactor: streamline signature validation process in SolanaConnector
nelitow Mar 24, 2025
39fa3c1
refactor: streamline signature validation process in SolanaConnector
nelitow Mar 24, 2025
0f19445
Merge branch 'nj/feat/presign-on-solana' of https://github.com/FuelLa…
nelitow Mar 24, 2025
5d98780
Create polite-foxes-wonder.md
nelitow Mar 24, 2025
d021348
Revert "Create polite-foxes-wonder.md"
nelitow Mar 24, 2025
160de04
Reapply "Create polite-foxes-wonder.md"
nelitow Mar 24, 2025
a3c23b3
refactor: enhance signature validation in SolanaConnector
nelitow Mar 28, 2025
3f07a5c
fix: improve signature verification in SolanaConnector
nelitow Mar 28, 2025
d90ec5f
feat: implement direct signature validation in SolanaConnector
nelitow Mar 31, 2025
13d0706
chore: update package dependencies in package.json and pnpm-lock.yaml
nelitow Mar 31, 2025
e024648
Merge branch 'main' into nj/feat/presign-on-solana
nelitow Apr 15, 2025
49db893
audit: large fixes
nelitow Apr 15, 2025
8c47148
audit
nelitow Apr 15, 2025
15a1da0
Update polite-foxes-wonder.md
nelitow Apr 15, 2025
30988ac
Merge branch 'main' into nj/feat/presign-on-solana
nelitow Apr 21, 2025
e470da0
pnpm lock
nelitow Apr 21, 2025
013dce3
chore: downgrade fuels package version to 0.100.0 across multiple pac…
nelitow Apr 21, 2025
e20926b
use package from main
nelitow Apr 21, 2025
d0a587a
Merge branch 'main' into nj/feat/presign-on-solana
nelitow Apr 24, 2025
2bd5e6e
feat: Add SignatureError component and update routing for error handling
nelitow Apr 25, 2025
e05591d
refactor: Standardize import statements and update type definition in…
nelitow Apr 25, 2025
baf8721
chore: Remove jsdom test environment configuration from Vite config f…
nelitow Apr 25, 2025
d31a4c6
Revert "chore: Remove jsdom test environment configuration from Vite …
nelitow Apr 25, 2025
64f9fcf
revert
nelitow Apr 25, 2025
8cd44c9
refactor: Update CopyIcon component to use camelCase for SVG attributes
nelitow Apr 30, 2025
b512fe7
feat: Enhance SolanaConnector with signature validation and connectio…
nelitow Apr 30, 2025
e43294d
chore: clean pr
nelitow Apr 30, 2025
60aaeb1
refactor: Simplify signature validation logic in SolanaConnector
nelitow Apr 30, 2025
bb2c238
fix: Add delay before creating web3Modal to improve connection reliab…
nelitow May 1, 2025
7c5d2cf
fix: Remove unnecessary delay in web3Modal connection process
nelitow May 1, 2025
8ca85e5
chore
LuizAsFight May 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-foxes-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-connectors/solana-connector": minor
---

feat: Added signature validation for the Solana Connector.
6 changes: 3 additions & 3 deletions packages/react/src/icons/CopyIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export function CopyIcon({ size, ...props }: SvgIconProps) {
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
{...props}
>
<title>Copy Icon</title>
Expand Down
24 changes: 24 additions & 0 deletions packages/react/src/icons/ErrorIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { SvgIconProps } from '../types';

export function ErrorIcon({ size = 24, theme = 'light' }: SvgIconProps) {
const color = theme === 'light' ? '#f25a68' : '#ff6b7a';

return (
<svg
width={size}
height={size}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
aria-label="Error Icon"
role="img"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM11 17V15H13V17H11ZM11 7V13H13V7H11Z"
fill={color}
/>
</svg>
);
}
5 changes: 2 additions & 3 deletions packages/react/src/providers/FuelUIProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export enum Routes {
Connecting = 'CONNECTING',
PredicateExternalDisclaimer = 'PREDICATE_EXTERNAL_DISCLAIMER',
PredicateAddressDisclaimer = 'PREDICATE_ADDRESS_DISCLAIMER',
SignatureError = 'SIGNATURE_ERROR',
}

export type FuelUIContextType = {
Expand All @@ -42,9 +43,7 @@ export type FuelUIContextType = {
isConnecting: boolean;
isError: boolean;
connect: () => void;
cancel: (params?: {
clean?: boolean;
}) => void;
cancel: (params?: { clean?: boolean }) => void;
setError: (error: Error | null) => void;
error: Error | null;
dialog: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ export function Connecting({ className }: ConnectorProps) {
};
}, [fuel]);

useEffect(() => {
if (error) {
if (error.message.includes('Failed to sign message')) {
setRoute(Routes.SignatureError);
}
}
}, [error, setRoute]);

if (!connector) return null;

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import * as Dialog from '@radix-ui/react-dialog';
import { ErrorIcon } from '../../../../icons/ErrorIcon';
import { useConnectUI } from '../../../../providers/FuelUIProvider';
import {
BackIcon,
CloseIcon,
DialogHeader,
DialogMain,
DialogTitle,
Divider,
} from '../../styles';
import {
ConnectorButton,
ConnectorButtonPrimary,
ConnectorContent,
ConnectorDescription,
ConnectorImage,
ConnectorTitle,
} from '../Connector/styles';
import { DialogContent } from '../Core/DialogContent';
import { DialogFuel } from '../Core/DialogFuel';

type SignatureErrorProps = {
theme: 'dark' | 'light';
};

export function SignatureError({ theme }: SignatureErrorProps) {
const { cancel } = useConnectUI();

return (
<DialogFuel open={true} theme={theme} onOpenChange={() => cancel()}>
<DialogContent data-connector={true}>
<DialogHeader>
<BackIcon size={32} data-connector={false} />
<DialogTitle>Signature Error</DialogTitle>
<Dialog.Close asChild>
<CloseIcon size={32} onClick={() => cancel()} />
</Dialog.Close>
</DialogHeader>
<Divider />
<DialogMain>
<div>
<ConnectorImage>
<ErrorIcon size={100} theme={theme} />
</ConnectorImage>
<ConnectorContent>
<ConnectorTitle>Failed to Sign Message</ConnectorTitle>
<ConnectorDescription>
If you are using a Ledger device, please check the
troubleshooting guide below.
</ConnectorDescription>
</ConnectorContent>
<ConnectorButtonPrimary
href="https://docs.fuel.network/guides/fuel-connectors/solana-ledger-connection"
target="_blank"
>
View Troubleshooting Guide
</ConnectorButtonPrimary>
<ConnectorButton onClick={() => cancel()}>Close</ConnectorButton>
</div>
</DialogMain>
</DialogContent>
</DialogFuel>
);
}
5 changes: 5 additions & 0 deletions packages/react/src/ui/Connect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import { DialogContent } from './components/Core/DialogContent';
import { DialogFuel } from './components/Core/DialogFuel';
import { PredicateAddressDisclaimer } from './components/PredicateAddressDisclaimer/PredicateAddressDisclaimer';
import { PredicateExternalDisclaimer } from './components/PredicateExternalDisclaimer/PredicateExternalDisclaimer';
import { SignatureError } from './components/SignatureError/SignatureError';

const ConnectRoutes = ({ route }: { route: Routes }) => {
const { theme } = useConnectUI();

switch (route) {
case Routes.List:
return <Connectors />;
Expand All @@ -30,6 +33,8 @@ const ConnectRoutes = ({ route }: { route: Routes }) => {
return <PredicateAddressDisclaimer />;
case Routes.Connecting:
return <Connecting />;
case Routes.SignatureError:
return <SignatureError theme={theme} />;
default:
return null;
}
Expand Down
Loading
Loading