diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..b4bfed3 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "plugins": ["prettier-plugin-tailwindcss"] +} diff --git a/global.d.ts b/global.d.ts index c527de0..c3ad188 100644 --- a/global.d.ts +++ b/global.d.ts @@ -4,4 +4,4 @@ declare global { interface Window { ethereum?: MetaMaskInpageProvider; } -} \ No newline at end of file +} diff --git a/hardhat.config.js b/hardhat.config.js index 9c74896..781615b 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -7,7 +7,7 @@ module.exports = { networks: { sepolia: { url: `${process.env.NEXT_PUBLIC_SEPOLIA_RPC}`, - accounts: [`${process.env.ACCOUNT_PRIVATE_KEY}`] - }, + accounts: [`${process.env.ACCOUNT_PRIVATE_KEY}`], + }, }, }; diff --git a/next.config.mjs b/next.config.mjs index cb621bf..b93cbb1 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -7,5 +7,5 @@ const nextConfig = { return config; }, }; - -export default nextConfig; \ No newline at end of file + +export default nextConfig; diff --git a/package-lock.json b/package-lock.json index 201bc5f..b6fbeb6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,6 +46,8 @@ "eslint": "^8", "eslint-config-next": "14.2.4", "postcss": "^8", + "prettier": "3.3.3", + "prettier-plugin-tailwindcss": "^0.6.5", "prisma": "^5.17.0", "tailwindcss": "^3.4.1", "typescript": "^5.5.2" @@ -12291,21 +12293,94 @@ } }, "node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true, - "peer": true, "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-plugin-tailwindcss": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.5.tgz", + "integrity": "sha512-axfeOArc/RiGHjOIy9HytehlC0ZLeMaqY09mm8YCkMzznKiDkwFzOpBvtuhuv3xG5qB73+Mj7OCe2j/L1ryfuQ==", + "dev": true, + "engines": { + "node": ">=14.21.3" + }, + "peerDependencies": { + "@ianvs/prettier-plugin-sort-imports": "*", + "@prettier/plugin-pug": "*", + "@shopify/prettier-plugin-liquid": "*", + "@trivago/prettier-plugin-sort-imports": "*", + "@zackad/prettier-plugin-twig-melody": "*", + "prettier": "^3.0", + "prettier-plugin-astro": "*", + "prettier-plugin-css-order": "*", + "prettier-plugin-import-sort": "*", + "prettier-plugin-jsdoc": "*", + "prettier-plugin-marko": "*", + "prettier-plugin-organize-attributes": "*", + "prettier-plugin-organize-imports": "*", + "prettier-plugin-sort-imports": "*", + "prettier-plugin-style-order": "*", + "prettier-plugin-svelte": "*" + }, + "peerDependenciesMeta": { + "@ianvs/prettier-plugin-sort-imports": { + "optional": true + }, + "@prettier/plugin-pug": { + "optional": true + }, + "@shopify/prettier-plugin-liquid": { + "optional": true + }, + "@trivago/prettier-plugin-sort-imports": { + "optional": true + }, + "@zackad/prettier-plugin-twig-melody": { + "optional": true + }, + "prettier-plugin-astro": { + "optional": true + }, + "prettier-plugin-css-order": { + "optional": true + }, + "prettier-plugin-import-sort": { + "optional": true + }, + "prettier-plugin-jsdoc": { + "optional": true + }, + "prettier-plugin-marko": { + "optional": true + }, + "prettier-plugin-organize-attributes": { + "optional": true + }, + "prettier-plugin-organize-imports": { + "optional": true + }, + "prettier-plugin-sort-imports": { + "optional": true + }, + "prettier-plugin-style-order": { + "optional": true + }, + "prettier-plugin-svelte": { + "optional": true + } + } + }, "node_modules/prisma": { "version": "5.17.0", "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.17.0.tgz", @@ -14625,6 +14700,22 @@ "node": ">=10" } }, + "node_modules/typechain/node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "peer": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/typed-array-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.2.tgz", diff --git a/package.json b/package.json index 42c074e..d3ca331 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,8 @@ "eslint": "^8", "eslint-config-next": "14.2.4", "postcss": "^8", + "prettier": "3.3.3", + "prettier-plugin-tailwindcss": "^0.6.5", "prisma": "^5.17.0", "tailwindcss": "^3.4.1", "typescript": "^5.5.2" diff --git a/scripts/deploy.js b/scripts/deploy.js index bb4530e..6c8a4da 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -1,23 +1,23 @@ const { ethers } = require("hardhat"); async function main() { - const Factory = await ethers.getContractFactory("WalletFactory"); + const Factory = await ethers.getContractFactory("WalletFactory"); - // Deploy the contract - const factory = await Factory.deploy( - "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" - ); + // Deploy the contract + const factory = await Factory.deploy( + "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", + ); - await factory.waitForDeployment(); + await factory.waitForDeployment(); - const deployedAddress = await factory.getAddress(); + const deployedAddress = await factory.getAddress(); - console.log(`Factory deployed to: ${deployedAddress}`); + console.log(`Factory deployed to: ${deployedAddress}`); } main() -.then(() => process.exit(0)) -.catch((error) => { + .then(() => process.exit(0)) + .catch((error) => { console.error(error); process.exit(1); -}); + }); diff --git a/src/app/[walletAddress]/page.tsx b/src/app/[walletAddress]/page.tsx index 1ad2540..d01022f 100644 --- a/src/app/[walletAddress]/page.tsx +++ b/src/app/[walletAddress]/page.tsx @@ -17,7 +17,7 @@ function biginttostring(userOpFinal: UserOperationStruct) { Object.entries(userOpFinal).map(([key, value]) => [ key, typeof value === "bigint" ? value.toString() : value, - ]) + ]), ) as UserOperationStruct; } @@ -35,7 +35,7 @@ export default function WalletPage({ const fetchUserOp = async () => { try { const response = await fetch( - `/routes/fetchWallet?walletAddress=${walletAddress}` + `/routes/fetchWallet?walletAddress=${walletAddress}`, ); const data = await response.json(); @@ -53,7 +53,7 @@ export default function WalletPage({ data.salt, toAddress, amountBigInt, - data.isDeployed + data.isDeployed, ); if (!userOp) throw new Error("Could not fetch user operation"); @@ -62,7 +62,7 @@ export default function WalletPage({ return userOp; } catch (e) { toast.error( - "Could not fetch user operation, check console for more details" + "Could not fetch user operation, check console for more details", ); console.log(e); } @@ -83,7 +83,7 @@ export default function WalletPage({ } const userOpHash = await entryPointContract.getUserOpHash( - userOp as UserOperationStruct + userOp as UserOperationStruct, ); if (!window.ethereum) throw new Error("Metamask not found"); @@ -110,26 +110,25 @@ export default function WalletPage({ }); const userOpHashFinal = await entryPointContract.getUserOpHash( - userOp as UserOperationStruct + userOp as UserOperationStruct, ); const signatureFinal = await signer.signMessage( - ethers.getBytes(userOpHashFinal) + ethers.getBytes(userOpHashFinal), ); userOp.signature = signatureFinal as Hex; - + const balance = await metamaskProvider.getBalance(userOp.sender); const requiredFunds = BigInt(userOp.callGasLimit) * BigInt(userOp.maxFeePerGas) + - BigInt(userOp.verificationGasLimit) * - BigInt(userOp.maxFeePerGas) + - BigInt(userOp.preVerificationGas) * - BigInt(userOp.maxFeePerGas) + BigInt(ethers.parseEther(amount.toString())); + BigInt(userOp.verificationGasLimit) * BigInt(userOp.maxFeePerGas) + + BigInt(userOp.preVerificationGas) * BigInt(userOp.maxFeePerGas) + + BigInt(ethers.parseEther(amount.toString())); if (balance < requiredFunds) { const amountToFund = requiredFunds - balance; toast.warn( - `Account needs funding of ${ethers.formatEther(amountToFund)} ETH` + `Account needs funding of ${ethers.formatEther(amountToFund)} ETH`, ); if (!window.ethereum) throw new Error("Metamask not found"); @@ -154,7 +153,8 @@ export default function WalletPage({ signature, signerAddress: userAddress, }, - (key, value) => (typeof value === "bigint" ? value.toString() : value) + (key, value) => + typeof value === "bigint" ? value.toString() : value, ), headers: { "Content-Type": "application/json", @@ -183,7 +183,7 @@ export default function WalletPage({ }, [newTransactionCreated]); return ( -
+

Manage Wallet

{walletAddress}

@@ -207,11 +207,11 @@ export default function WalletPage({ }} />