Skip to content

Commit

Permalink
fix: revise ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiHaoLu committed Nov 6, 2024
1 parent 262c306 commit 6ee3755
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 13 deletions.
5 changes: 4 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// next.config.js
module.exports = {
reactStrictMode: true
reactStrictMode: true,
images: {
unoptimized: true,
}
};
11 changes: 2 additions & 9 deletions pages/explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ import {
INFRA_ADDRESS,
BundlerMode,
BundlerProvider,
BundlerUserOperationData,
PackedUserOperation,
wrap,
} from "@consenlabs/imaccount-sdk";
import { UserOpReceipt } from "../types/receipt";
import { DataType, UserOpReceipt } from "../types";
import Header from "./header";

enum DataType {
Address = "/address/",
Transaction = "/tx/",
Block = "/block/",
}

const Explorer = () => {
const [userOpHash, setUserOpHash] = useState<Hex>(
"0x95193f1f7d7cac1caa3385a33ce7a63dc3b66d3ba91059addfcaaf1091834fcc"
Expand All @@ -26,7 +19,7 @@ const Explorer = () => {
process.env.NEXT_PUBLIC_RPC_URL ??
"https://<chain_prefix>.g.alchemy.com/v2/<your_api_key>"
);
const [chainName, setChainName] = useState<string|null>()
const [chainName, setChainName] = useState<string | null>();
const [userOpReceipt, setUserOpReceipt] = useState<UserOpReceipt | null>(
null
);
Expand Down
74 changes: 72 additions & 2 deletions pages/imaccount-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ import {
InfoType,
} from "@consenlabs/imaccount-sdk";
import { Address } from "viem";
import { DataType } from "../types";
import Header from "./header";

enum AddressType {
Entry = "Entry",
Account = "Account",
}

type FullInfoType = {
BasicInfo: InfoType,
DeploymentInfo: {
EntryFactory: Address,
AccountFactory: Address,
Version: string
}
}

const AccountInfo = () => {
const [address, setAddress] = useState<Address>(
"0xea67ba18ab79c208369f7f40cf21a27c41f605f2"
Expand All @@ -22,11 +32,27 @@ const AccountInfo = () => {
process.env.NEXT_PUBLIC_RPC_URL ??
"https://<chain_prefix>.g.alchemy.com/v2/<your_api_key>"
);
const [chainName, setChainName] = useState<string | null>();
const [fetching, setFetching] = useState(false);
const [info, setInfo] = useState<InfoType | null>();

const isFetchDisabled = !address || !type || !ALCHEMY_RPC_URL;

const getExplorerLink = (address: string, type: DataType): string => {
if (!ALCHEMY_RPC_URL) return "https://";

const provider = getPublicClient(ALCHEMY_RPC_URL);
if (!chainName || chainName === "") {
setChainName(provider.chain?.name);
}
const explorerLink = provider.chain?.blockExplorers?.default.url;

if (!explorerLink) return "https://";

const dataLink = explorerLink + type + address;
return dataLink;
};

const getWalletInfo = async () => {
if (!address || !type || !ALCHEMY_RPC_URL) {
alert("Please fill in all required fields.");
Expand Down Expand Up @@ -56,10 +82,11 @@ const AccountInfo = () => {
return (
<div>
<Header />
<h2>imToken AA Wallet Infomation</h2>
<h2>imToken AA Wallet Watcher</h2>
<div className="warning-banner">
<p>It is an experimental feature. Please use it cautiously.</p>
</div>
<h3>Infomation</h3>
<div>
<h4>Contract Type</h4>
<label>
Expand Down Expand Up @@ -100,7 +127,50 @@ const AccountInfo = () => {
{info && (
<div>
<h3>Wallet Infomation</h3>
<pre>{JSON.stringify(info, null, 2)}</pre>
<div className="data-section">
<div>
<span className="label">Entry Address</span>{" "}
<a
href={getExplorerLink(info.entryAddr, DataType.Address)}
target="_blank"
>
{info.entryAddr}
</a>
</div>
<div>
<span className="label">Validator</span>{" "}
{info.currentOwnerValidator}
</div>
<div>
<span className="label">Validator Address</span>{" "}
<a
href={getExplorerLink(
info.currentOwnerValidatorAddr,
DataType.Address
)}
target="_blank"
>
{info.currentOwnerValidatorAddr}
</a>
</div>
<div>
<span className="label">Accounts Addresses</span>{" "}
<div>
{info.accountAddrs.map((acc: any, index: any) => (
<span key={index}>
<a
href={getExplorerLink(acc, DataType.Address)}
target="_blank"
>
{acc}
</a>

<br />
</span>
))}
</div>
</div>
</div>
</div>
)}
</div>
Expand Down
10 changes: 9 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ import Link from "next/link";

import Header from "./header";
import Footer from "./footer";
import Image from "next/image";

const Home = () => {
return (
<div className="container">
<Header />
<div className="gif-container">
<img src="/chiikawa.GIF" alt="GIF" className="gif" />
<Image
src="/chiikawa.gif"
alt="Usagi"
width={0}
height={0}
sizes="100vw"
style={{ width: "50%", height: "auto" }}
/>
</div>
<div className="link-container">
<Link href="/explorer">
Expand Down
Binary file added public/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/favicon.ico
Binary file not shown.
19 changes: 19 additions & 0 deletions public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "AA Debugger",
"short_name": "AA Debugger",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
30 changes: 30 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,34 @@ footer {
border: 1px solid #3e3e3e;
border-radius: 4px;
overflow-x: auto;
}

select {
width: 100%;
padding: 10px;
margin-top: 5px;
margin-bottom: 20px;
border: 1px solid #3e3e3e;
border-radius: 4px;
background-color: #2e2e2e;
color: #dcdcdc;
font-family: 'Ubuntu Mono', monospace;
appearance: none;
/* Removes default arrow */
cursor: pointer;
transition: border-color 0.3s ease, background-color 0.3s ease;
}

select:hover {
border-color: #4ec9b0;
}

select:focus {
outline: none;
border-color: #4ec9b0;
}

select option {
background-color: #2e2e2e;
color: #dcdcdc;
}
6 changes: 6 additions & 0 deletions types/receipt.ts → types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Address } from "viem";

export enum DataType {
Address = "/address/",
Transaction = "/tx/",
Block = "/block/",
}

export type Log = {
address: Address;
topics: string[];
Expand Down

0 comments on commit 6ee3755

Please sign in to comment.