Skip to content
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

XAccount V2 #24

Merged
merged 34 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9fc3f23
init v2 version
snoopy1412 Jan 2, 2025
863350c
update styles
snoopy1412 Jan 2, 2025
1c4f05c
Add ConnectTabs component
snoopy1412 Jan 3, 2025
6db3bd6
Enhance configuration and UI components
snoopy1412 Jan 5, 2025
0d8634a
Add Impersonator Iframe functionality
snoopy1412 Jan 5, 2025
2bf088a
enhance UI components
snoopy1412 Jan 7, 2025
48da5a4
Refactor GenerateAction component to include isRefetching state and i…
snoopy1412 Jan 8, 2025
11bf9ad
Enhance cross-chain functionality and UI components
snoopy1412 Jan 9, 2025
64ea913
Refactor Impersonator Iframe integration and enhance loading state ma…
snoopy1412 Jan 9, 2025
df27dcc
Enhance ConnectIframe and ConnectURI components with improved loading…
snoopy1412 Jan 9, 2025
db4c53d
Refactor GenerateAction component to utilize Next.js routing for acti…
snoopy1412 Jan 9, 2025
2905d59
Enhance action generation and preview components with new content dis…
snoopy1412 Jan 10, 2025
4c11403
Refactor GenerateAction component to use dynamic targetAccount and ta…
snoopy1412 Jan 10, 2025
d4e9a96
Refactor DaoPanel component to separate content logic into DaoPanelCo…
snoopy1412 Jan 10, 2025
299282f
Refactor GenerateAction component to improve structure and loading st…
snoopy1412 Jan 10, 2025
baccba2
remove commented-out code
snoopy1412 Jan 10, 2025
c29a24c
Update Next.js configuration and enhance CreateXAccount component wit…
snoopy1412 Jan 10, 2025
fc95be6
CI
fewensa Jan 10, 2025
92cc2cb
rewrite index
fewensa Jan 10, 2025
d0535f3
improved animations
snoopy1412 Jan 10, 2025
77ad5dc
Merge branch 'v2' of github.com:ringecosystem/xaccount-ui into v2
snoopy1412 Jan 10, 2025
66f5641
fix wallet connection
snoopy1412 Jan 12, 2025
d106930
Update default activeTab in GenerateActionContent to 'wallet' for imp…
snoopy1412 Jan 12, 2025
9276b13
Refactor arbitrumSepolia configuration by removing unused rpcUrls
snoopy1412 Jan 13, 2025
a03bef2
enhance action generation logic
snoopy1412 Jan 14, 2025
bcadd5e
Enhance CreateXAccount component with default recovery account value …
snoopy1412 Jan 14, 2025
043ff28
Update package dependencies: bump 'viem' to version 2.22.8 and 'wagmi…
snoopy1412 Jan 14, 2025
37e64e4
Update '@rainbow-me/rainbowkit'
snoopy1412 Jan 14, 2025
5ad828b
Enhance CreateXAccount component by adding links to block explorers f…
snoopy1412 Jan 14, 2025
4b7273d
ui fix
snoopy1412 Jan 15, 2025
ee006e6
feat: add SupportDapps component and integrate with ConnectIframe for…
snoopy1412 Jan 15, 2025
b901115
Merge remote-tracking branch 'origin/main' into v2
snoopy1412 Jan 16, 2025
184ead5
Enhance UI components by integrating JetBrains Mono font for improved…
snoopy1412 Jan 16, 2025
3b731d6
Refactor ConnectIframe component to improve URL connection handling a…
snoopy1412 Jan 16, 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
Prev Previous commit
Refactor ConnectIframe component to improve URL connection handling a…
…nd error management; add onError prop to ImpersonatorIframe and integrate dapp selection functionality in SupportDapps component.
  • Loading branch information
snoopy1412 committed Jan 16, 2025
commit 3b731d6883c266e834c162787dc23dd7b0c95ca6
65 changes: 46 additions & 19 deletions src/app/_components/connect-iframe.tsx
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import useGenerateAction from '@/hooks/useGenerateAction';
import { useImpersonatorIframe } from '@/contexts/ImpersonatorIframeContext';
import { useLocalStorageState } from '@/hooks/useLocalStorageState';
import { SupportDapps } from '@/components/support-dapps';
import { SafeDappInfo } from '@/types/communicator';

export const ConnectIframe = ({
timeLockContractAddress,
@@ -37,28 +38,47 @@ export const ConnectIframe = ({
// const rpc = 'https://eth.llamarpc.com';
const { latestTransaction, iframeRef } = useImpersonatorIframe();

const handleConnect = useCallback(() => {
if (!iframeConnectUri || !isValidUrl(iframeConnectUri)) {
toast.error('Invalid URL');
return;
}
const connectToUrl = useCallback(
(url: string) => {
if (!url || !isValidUrl(url)) {
toast.error('Invalid URL');
return false;
}

if (!targetAccount) {
toast.error('Address is not an ENS or Ethereum address');
return;
}
if (!targetAccount) {
toast.error('Address is not an ENS or Ethereum address');
return false;
}

if (!rpc) {
toast.error('RPC is not available');
return;
}
if (!rpc) {
toast.error('RPC is not available');
return false;
}

setUri('');
setTimeout(() => {
setUri(iframeConnectUri);
}, 100);
setIsIframeLoading(true);
}, [iframeConnectUri, targetAccount, setIsIframeLoading, rpc]);
setUri('');
setTimeout(() => {
setUri(url);
}, 100);
setIsIframeLoading(true);
return true;
},
[targetAccount, rpc, setUri, setIsIframeLoading]
);

const handleConnect = useCallback(() => {
connectToUrl(iframeConnectUri);
}, [iframeConnectUri, connectToUrl]);

const handleSelectDapp = useCallback(
(dapp: SafeDappInfo) => {
const url = dapp.url;
setIframeConnectUri(url);
if (connectToUrl(url)) {
setIsSupportDappsOpen(false);
}
},
[setIframeConnectUri, connectToUrl, setIsSupportDappsOpen]
);

const handleIframeLoad = useCallback(() => {
setIsIframeLoading(false);
@@ -72,6 +92,11 @@ export const ConnectIframe = ({
}
}, [setIsIframeLoading, iframeRef]);

const handleIframeError = useCallback(() => {
toast.error('Failed to load iframe');
setIsIframeLoading(false);
}, [setIsIframeLoading]);

const { generateAction, sourcePort, actionState, reset, isLoading } = useGenerateAction({
timeLockContractAddress: timeLockContractAddress as `0x${string}`,
moduleAddress: moduleAddress as `0x${string}`,
@@ -158,6 +183,7 @@ export const ConnectIframe = ({
height={'510px'}
src={uri}
onLoad={handleIframeLoad}
onError={handleIframeError}
address={targetAccount}
rpcUrl={rpc}
/>
@@ -187,6 +213,7 @@ export const ConnectIframe = ({
networkId={Number(targetChainId)}
open={isSupportDappsOpen}
onOpenChange={setIsSupportDappsOpen}
onSelect={handleSelectDapp}
/>
</div>
);
3 changes: 3 additions & 0 deletions src/components/ImpersonatorIframe.tsx
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ interface Props {
address: string;
rpcUrl: string;
onLoad?: () => void;
onError?: () => void;
}

export const ImpersonatorIframe = ({
@@ -20,6 +21,7 @@ export const ImpersonatorIframe = ({
address,
rpcUrl,
onLoad,
onError,
targetChainId
}: Props) => {
const { iframeRef, setAddress, setAppUrl, setRpcUrl, setTargetChainId, isReady } =
@@ -42,6 +44,7 @@ export const ImpersonatorIframe = ({
id={`iframe-${src}`}
className="rounded-[10px] border border-[#666] bg-[#141414]"
onLoad={onLoad}
onError={onError}
src={src}
sandbox={IFRAME_SANDBOX_ALLOWED_FEATURES}
/>
16 changes: 12 additions & 4 deletions src/components/support-dapps.tsx
Original file line number Diff line number Diff line change
@@ -8,11 +8,15 @@ import { Skeleton } from '@/components/ui/skeleton';

interface DappCardProps {
dapp: SafeDappInfo;
onSelect: (dapp: SafeDappInfo) => void;
}

const DappCard = ({ dapp }: DappCardProps) => {
const DappCard = ({ dapp, onSelect }: DappCardProps) => {
return (
<div className="flex h-full w-full flex-col items-center justify-center space-y-2 rounded-lg p-4 transition-all duration-200 hover:scale-105 hover:opacity-80">
<div
className="flex h-full w-full cursor-pointer flex-col items-center justify-center space-y-2 rounded-lg p-4 transition-all duration-200 hover:scale-105 hover:opacity-80"
onClick={() => onSelect(dapp)}
>
<Image
src={dapp.iconUrl}
alt={`${dapp.name} logo`}
@@ -37,11 +41,13 @@ const DappCardSkeleton = () => {
export function SupportDapps({
networkId,
open,
onOpenChange
onOpenChange,
onSelect
}: {
networkId: number;
open: boolean;
onOpenChange: (open: boolean) => void;
onSelect: (dapp: SafeDappInfo) => void;
}) {
const [searchQuery, setSearchQuery] = useState('');
const [safeDapps, setSafeDapps] = useState<Record<number, SafeDappInfo[]>>({});
@@ -104,7 +110,9 @@ export function SupportDapps({
.fill(0)
.map((_, i) => <DappCardSkeleton key={i} />)
) : filteredDapps.length > 0 ? (
filteredDapps.map((dapp) => <DappCard key={dapp.id} dapp={dapp} />)
filteredDapps.map((dapp) => (
<DappCard key={dapp.id} dapp={dapp} onSelect={onSelect} />
))
) : (
<div className="col-span-full mt-8 text-center text-gray-500">No dapps found</div>
)}
4 changes: 2 additions & 2 deletions src/contexts/ImpersonatorIframeContext.tsx
Original file line number Diff line number Diff line change
@@ -142,11 +142,11 @@ export const ImpersonatorIframeProvider: React.FunctionComponent<FCProps> = ({ c
communicator?.on(Methods.getSafeInfo, async () => {
return {
safeAddress: address,
chainId: targetChainId,
chainId: Number(targetChainId),
owners: [],
threshold: 1,
isReadOnly: false,
network: targetChainId
network: Number(targetChainId)
};
});

Loading