From ce4a1697a3fc7e41a61e5a2586749e35cf90237d Mon Sep 17 00:00:00 2001 From: eerkaijun Date: Sun, 7 Jan 2024 23:08:09 +0000 Subject: [PATCH 1/5] initial integration of permissionlessjs --- packages/webapp/package.json | 1 + packages/webapp/src/pages/index.tsx | 9 +++++ packages/webapp/src/utils/accounts.ts | 51 +++++++++++++++++++++++++++ pnpm-lock.yaml | 11 ++++++ 4 files changed, 72 insertions(+) create mode 100644 packages/webapp/src/utils/accounts.ts diff --git a/packages/webapp/package.json b/packages/webapp/package.json index 9aad494d..51b8c94d 100644 --- a/packages/webapp/package.json +++ b/packages/webapp/package.json @@ -19,6 +19,7 @@ "lodash": "^4.17.21", "next": "^13.5.6", "next-transpile-modules": "^10.0.1", + "permissionless": "^0.0.20", "react": "18.2.0", "react-dom": "18.2.0", "react-icons": "^4.11.0", diff --git a/packages/webapp/src/pages/index.tsx b/packages/webapp/src/pages/index.tsx index bcabd643..875e1b63 100644 --- a/packages/webapp/src/pages/index.tsx +++ b/packages/webapp/src/pages/index.tsx @@ -10,6 +10,7 @@ import { MintDeckModal } from "src/components/modals/mintDeckModal" import { useGameInGame } from "src/generated" import { FablePage } from "src/pages/_app" import { useGameID } from "src/store/hooks" +import { createAccount } from "src/utils/accounts" const Home: FablePage = ({ isHydrated }) => { const { address } = useAccount() @@ -51,6 +52,14 @@ const Home: FablePage = ({ isHydrated }) => { > Connect Wallet + } diff --git a/packages/webapp/src/utils/accounts.ts b/packages/webapp/src/utils/accounts.ts new file mode 100644 index 00000000..3585cc44 --- /dev/null +++ b/packages/webapp/src/utils/accounts.ts @@ -0,0 +1,51 @@ +/** + * Utilities to deal with burner accounts. + * + * @module utils/accounts + */ + +import { http, parseEther} from 'viem' +import { localhost } from 'viem/chains' +import { getPublicClient } from "wagmi/actions" +import { generatePrivateKey } from 'viem/accounts' +import { createBundlerClient, createSmartAccountClient } from 'permissionless' +import { privateKeyToSimpleSmartAccount } from 'permissionless/accounts' + +const publicClient = getPublicClient() + +// TODO: we need to initialize paymaster contract? + +export async function createAccount() { + + // generate an in browser private key + const privateKey = generatePrivateKey() + + // TODO: store this private key in atom + + // create a simple account where the private key is the signer + const simpleAccount = await privateKeyToSimpleSmartAccount(publicClient, { + privateKey: privateKey, + factoryAddress: "0x9406Cc6185a346906296840746125a0E44976454", + entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", // global entrypoint + }); + console.log("Simple account: ", simpleAccount) + + // create a smart account client (equivalent to a walletClient) + const smartAccountClient = createSmartAccountClient({ + account: simpleAccount, + chain: localhost, + transport: http( + "http://localhost:4337", + ), + // sponsorUserOperation: paymasterClient.sponsorUserOperation, // optional + }); + console.log("Smart account client: ", smartAccountClient); + + // Generalize sending transaction + + // const txHash = await smartAccountClient.sendTransaction({ + // to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", + // value: parseEther("0.1"), + // }); + // console.log("Transaction hash: ", txHash); +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e64d13eb..880c095f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,6 +96,9 @@ importers: next-transpile-modules: specifier: ^10.0.1 version: 10.0.1 + permissionless: + specifier: ^0.0.20 + version: 0.0.20(viem@1.16.6) react: specifier: 18.2.0 version: 18.2.0 @@ -10698,6 +10701,14 @@ packages: resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==} dev: true + /permissionless@0.0.20(viem@1.16.6): + resolution: {integrity: sha512-vTlefC0I9Z41kxhpmyliaFLpqFqaD6xQU1DCedbL2xniXp2uHdCUiUAplKyv8FXAfyVoWeGkd5b8wU//iHxDDw==} + peerDependencies: + viem: ^1.19.4 + dependencies: + viem: 1.16.6(typescript@5.2.2)(zod@3.22.2) + dev: false + /picocolors@1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} From 30989a14af0cd9af43d12b3c205fdec3b1be798c Mon Sep 17 00:00:00 2001 From: eerkaijun Date: Sat, 13 Jan 2024 22:51:15 +0000 Subject: [PATCH 2/5] paymaster signature validation works --- packages/webapp/package.json | 1 + packages/webapp/src/utils/accounts.ts | 75 ++++++++++++++++++++------- 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/packages/webapp/package.json b/packages/webapp/package.json index 51b8c94d..af1ebeba 100644 --- a/packages/webapp/package.json +++ b/packages/webapp/package.json @@ -12,6 +12,7 @@ "@dnd-kit/sortable": "^7.0.2", "@dnd-kit/utilities": "^3.2.1", "@emotion/react": "^11.11.1", + "axios": "^1.6.5", "circomlibjs": "^0.1.7", "connectkit": "^1.5.3", "jotai": "^2.4.3", diff --git a/packages/webapp/src/utils/accounts.ts b/packages/webapp/src/utils/accounts.ts index 3585cc44..5ed56c72 100644 --- a/packages/webapp/src/utils/accounts.ts +++ b/packages/webapp/src/utils/accounts.ts @@ -4,22 +4,31 @@ * @module utils/accounts */ -import { http, parseEther} from 'viem' +import axios from 'axios' +import { Address, http, parseEther, defineChain, toHex, concat } from 'viem' import { localhost } from 'viem/chains' import { getPublicClient } from "wagmi/actions" import { generatePrivateKey } from 'viem/accounts' -import { createBundlerClient, createSmartAccountClient } from 'permissionless' +import { createSmartAccountClient, UserOperation } from 'permissionless' import { privateKeyToSimpleSmartAccount } from 'permissionless/accounts' const publicClient = getPublicClient() -// TODO: we need to initialize paymaster contract? - export async function createAccount() { + const rollop = defineChain({ + ...localhost, + id: 1201101712, + name: 'Rollop', + nativeCurrency: { + decimals: 18, + name: 'Ether', + symbol: 'ETH', + }, + }); + // generate an in browser private key const privateKey = generatePrivateKey() - // TODO: store this private key in atom // create a simple account where the private key is the signer @@ -28,24 +37,52 @@ export async function createAccount() { factoryAddress: "0x9406Cc6185a346906296840746125a0E44976454", entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", // global entrypoint }); - console.log("Simple account: ", simpleAccount) // create a smart account client (equivalent to a walletClient) const smartAccountClient = createSmartAccountClient({ + chain: rollop, account: simpleAccount, - chain: localhost, - transport: http( - "http://localhost:4337", - ), - // sponsorUserOperation: paymasterClient.sponsorUserOperation, // optional + transport: http("http://localhost:4337"), + sponsorUserOperation: async (args: { userOperation: UserOperation, entryPoint: Address }) => { + // console.log("Breakpoint1") + const userOp = { + sender: args.userOperation.sender, + nonce: toHex(args.userOperation.nonce), + initCode: args.userOperation.initCode, + callData: args.userOperation.callData, + paymasterAndData: concat([ + '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9', + '0x' + '00'.repeat(64) as `0x${string}`, + '0x' + '00'.repeat(65) as `0x${string}` + ]), + signature: args.userOperation.signature, + maxFeePerGas: toHex(2_000_000_000), + maxPriorityFeePerGas: toHex(1_000_000_000), + callGasLimit: toHex(3_000_000), + verificationGasLimit: toHex(3_000_000), + preVerificationGas: toHex(2_000_000) + } + const jsonRpcRequest = { + jsonrpc: '2.0', + method: 'pm_sponsorUserOperation', + params: userOp, + id: 1 + }; + const response = await axios.post("http://localhost:3000", jsonRpcRequest, { + headers: { + 'Content-Type': 'application/json', + }, + }); + return response.data.result; + } }); - console.log("Smart account client: ", smartAccountClient); - - // Generalize sending transaction - // const txHash = await smartAccountClient.sendTransaction({ - // to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", - // value: parseEther("0.1"), - // }); - // console.log("Transaction hash: ", txHash); + // to send a transaction, it will be similar to using walletClient, example below + /** + const txHash3 = await smartAccountClient.sendTransaction({ + to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", + value: BigInt(0), + data: "0x68656c6c6f" + }); + */ } \ No newline at end of file From 013f4cb7f40e9b04245d7ac6aee780d8f57b74e7 Mon Sep 17 00:00:00 2001 From: eerkaijun Date: Sun, 14 Jan 2024 12:23:48 +0000 Subject: [PATCH 3/5] update makefile to start rollop --- .gitignore | 3 +++ Makefile | 11 +++++++++++ package.json | 3 +-- pnpm-lock.yaml | 30 +++++++++++++++++++++++------- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index b2d4a128..8a804034 100755 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ packages/circuits/out packages/circuits/trusted_setup packages/circuits/zkeys packages/webapp/public/proofs + +# Roll-op files +roll-op/ \ No newline at end of file diff --git a/Makefile b/Makefile index 35efac09..8c4f68ae 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,17 @@ anvil: cd packages/contracts && make anvil .PHONY: anvil +# Runs rollop +rollop: + @if [ ! -d "roll-op" ]; then \ + git clone https://github.com/0xFableOrg/roll-op.git; \ + fi + cd roll-op && ./rollop setup && ./rollop devnet + +# Runs account abstraction bundler and paymaster +account-abstraction: + cd roll-op && ./rollop aa + # Runs the webapp in dev mode. webdev: cd packages/webapp && make dev diff --git a/package.json b/package.json index c1692273..af151508 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,5 @@ "author": "0xFable Team", "license": "BSD-3-Clause-Clear", "version": "1.0.0", - "private": true, - "packageManager": "pnpm@8.8.0" + "private": true } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 880c095f..76d504d2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,6 +75,9 @@ importers: '@emotion/react': specifier: ^11.11.1 version: 11.11.1(@types/react@18.2.31)(react@18.2.0) + axios: + specifier: ^1.6.5 + version: 1.6.5 circomlibjs: specifier: ^0.1.7 version: 0.1.7 @@ -4944,7 +4947,6 @@ packages: /asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} - dev: true /at-least-node@1.0.0: resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==} @@ -5017,6 +5019,16 @@ packages: - debug dev: true + /axios@1.6.5: + resolution: {integrity: sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==} + dependencies: + follow-redirects: 1.15.5 + form-data: 4.0.0 + proxy-from-env: 1.1.0 + transitivePeerDependencies: + - debug + dev: false + /axobject-query@3.2.1: resolution: {integrity: sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==} dependencies: @@ -5846,7 +5858,6 @@ packages: engines: {node: '>= 0.8'} dependencies: delayed-stream: 1.0.0 - dev: true /command-exists@1.2.9: resolution: {integrity: sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==} @@ -6435,7 +6446,6 @@ packages: /delayed-stream@1.0.0: resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} - dev: true /depd@1.1.2: resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==} @@ -7744,6 +7754,16 @@ packages: debug: 4.3.4(supports-color@5.5.0) dev: true + /follow-redirects@1.15.5: + resolution: {integrity: sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dev: false + /for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} dependencies: @@ -7777,7 +7797,6 @@ packages: asynckit: 0.4.0 combined-stream: 1.0.8 mime-types: 2.1.35 - dev: true /formdata-polyfill@4.0.10: resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} @@ -10023,14 +10042,12 @@ packages: /mime-db@1.52.0: resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} engines: {node: '>= 0.6'} - dev: true /mime-types@2.1.35: resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} engines: {node: '>= 0.6'} dependencies: mime-db: 1.52.0 - dev: true /mime@1.6.0: resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} @@ -11023,7 +11040,6 @@ packages: /proxy-from-env@1.1.0: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} - dev: true /psl@1.9.0: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} From 77869d7b19e488af5e0ad12733f1a6aed6472d0c Mon Sep 17 00:00:00 2001 From: eerkaijun Date: Fri, 19 Jan 2024 23:28:50 -0500 Subject: [PATCH 4/5] injected wallet connect to rollop --- Makefile | 8 ++++---- packages/contracts/.env.example | 2 +- packages/contracts/Makefile | 3 ++- packages/webapp/src/chain.ts | 21 ++++++++++++++++++++- packages/webapp/src/utils/accounts.ts | 15 +++++++-------- pnpm-lock.yaml | 20 +++++--------------- 6 files changed, 39 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 8c4f68ae..95ca1bf6 100644 --- a/Makefile +++ b/Makefile @@ -21,14 +21,14 @@ anvil: # Runs rollop rollop: - @if [ ! -d "roll-op" ]; then \ - git clone https://github.com/0xFableOrg/roll-op.git; \ + @if [ ! -d "../roll-op" ]; then \ + git clone https://github.com/0xFableOrg/roll-op.git ../roll-op; \ fi - cd roll-op && ./rollop setup && ./rollop devnet + cd ../roll-op && ./rollop setup && ./rollop devnet # Runs account abstraction bundler and paymaster account-abstraction: - cd roll-op && ./rollop aa + cd ../roll-op && ./rollop aa # Runs the webapp in dev mode. webdev: diff --git a/packages/contracts/.env.example b/packages/contracts/.env.example index 4dc298c6..7854aba8 100755 --- a/packages/contracts/.env.example +++ b/packages/contracts/.env.example @@ -5,6 +5,6 @@ export PRIVATE_KEY_LOCAL=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784 export PRIVATE_KEY_TEST=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 export PRIVATE_KEY_MAIN=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 -export RPC_LOCAL=http://localhost:8545 +export RPC_LOCAL=http://localhost:9545 export RPC_TEST=https://rpc.chiadochain.net export RPC_MAIN=https://rpc.ankr.com/gnosis \ No newline at end of file diff --git a/packages/contracts/Makefile b/packages/contracts/Makefile index 6ec5d5b2..6a39ffe0 100755 --- a/packages/contracts/Makefile +++ b/packages/contracts/Makefile @@ -77,7 +77,8 @@ selectors: # Deploys locally, to testnet or mainnet depending on the $CONFIG value (locally if not set). deploy: build - @forge script src/deploy/Deploy.s.sol:Deploy \ + echo "Deploying to $(CONFIG)" + forge script src/deploy/Deploy.s.sol:Deploy \ --fork-url $(RPC_$(CONFIG)) \ --private-key $(PRIVATE_KEY_$(CONFIG)) \ --broadcast \ diff --git a/packages/webapp/src/chain.ts b/packages/webapp/src/chain.ts index 2e70a9c0..a8a4a7e7 100644 --- a/packages/webapp/src/chain.ts +++ b/packages/webapp/src/chain.ts @@ -5,6 +5,7 @@ */ import { getDefaultConfig, getDefaultConnectors } from "connectkit" +import { defineChain } from "viem" import { type Chain, createConfig } from "wagmi" import { localhost } from "wagmi/chains" @@ -13,7 +14,25 @@ import { BurnerConnector } from "src/wagmi/BurnerConnector" // ================================================================================================= /** The list of chains supported by the app. */ -export const chains = [localhost] +const rollop = defineChain({ + ...localhost, + id: 1201101712, + name: 'Rollop', + nativeCurrency: { + decimals: 18, + name: 'Ether', + symbol: 'ETH', + }, + rpcUrls: { + default: { + http: ["http://localhost:9545"] + }, + public: { + http: ["http://localhost:9545"] + } + } +}); +export const chains = [rollop] // ================================================================================================= // Wagmi + ConnectKit Config diff --git a/packages/webapp/src/utils/accounts.ts b/packages/webapp/src/utils/accounts.ts index 5ed56c72..3df58734 100644 --- a/packages/webapp/src/utils/accounts.ts +++ b/packages/webapp/src/utils/accounts.ts @@ -5,15 +5,12 @@ */ import axios from 'axios' -import { Address, http, parseEther, defineChain, toHex, concat } from 'viem' +import { Address, http, parseEther, defineChain, toHex, concat, createPublicClient } from 'viem' import { localhost } from 'viem/chains' -import { getPublicClient } from "wagmi/actions" import { generatePrivateKey } from 'viem/accounts' import { createSmartAccountClient, UserOperation } from 'permissionless' import { privateKeyToSimpleSmartAccount } from 'permissionless/accounts' -const publicClient = getPublicClient() - export async function createAccount() { const rollop = defineChain({ @@ -27,6 +24,10 @@ export async function createAccount() { }, }); + const publicClient = createPublicClient({ + transport: http("http://localhost:9545"), + }); + // generate an in browser private key const privateKey = generatePrivateKey() // TODO: store this private key in atom @@ -44,7 +45,6 @@ export async function createAccount() { account: simpleAccount, transport: http("http://localhost:4337"), sponsorUserOperation: async (args: { userOperation: UserOperation, entryPoint: Address }) => { - // console.log("Breakpoint1") const userOp = { sender: args.userOperation.sender, nonce: toHex(args.userOperation.nonce), @@ -78,11 +78,10 @@ export async function createAccount() { }); // to send a transaction, it will be similar to using walletClient, example below - /** + /* const txHash3 = await smartAccountClient.sendTransaction({ to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", value: BigInt(0), data: "0x68656c6c6f" - }); - */ + }); */ } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 76d504d2..26b97eef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1607,6 +1607,7 @@ packages: /@emotion/memoize@0.7.4: resolution: {integrity: sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==} + requiresBuild: true dev: false optional: true @@ -6237,17 +6238,6 @@ packages: ms: 2.0.0 dev: true - /debug@3.2.7: - resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - dependencies: - ms: 2.1.3 - dev: true - /debug@3.2.7(supports-color@8.1.1): resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} peerDependencies: @@ -6941,7 +6931,7 @@ packages: /eslint-import-resolver-node@0.3.9: resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==} dependencies: - debug: 3.2.7 + debug: 3.2.7(supports-color@8.1.1) is-core-module: 2.13.1 resolve: 1.22.8 transitivePeerDependencies: @@ -6993,7 +6983,7 @@ packages: optional: true dependencies: '@typescript-eslint/parser': 6.8.0(eslint@8.52.0)(typescript@5.2.2) - debug: 3.2.7 + debug: 3.2.7(supports-color@8.1.1) eslint: 8.52.0 eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@6.8.0)(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0)(eslint@8.52.0) @@ -7016,7 +7006,7 @@ packages: array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.2 array.prototype.flatmap: 1.3.2 - debug: 3.2.7 + debug: 3.2.7(supports-color@8.1.1) doctrine: 2.1.0 eslint: 8.52.0 eslint-import-resolver-node: 0.3.9 @@ -10723,7 +10713,7 @@ packages: peerDependencies: viem: ^1.19.4 dependencies: - viem: 1.16.6(typescript@5.2.2)(zod@3.22.2) + viem: 1.16.6(typescript@5.2.2)(zod@3.22.4) dev: false /picocolors@1.0.0: From a80cc788c55465179bb60967bdf2ac77b8ea3502 Mon Sep 17 00:00:00 2001 From: eerkaijun Date: Sun, 21 Jan 2024 18:03:54 +0000 Subject: [PATCH 5/5] complete shiftover to rollop --- packages/webapp/src/chain.ts | 2 +- packages/webapp/src/setup.ts | 3 +- packages/webapp/src/utils/accounts.ts | 2 +- packages/webapp/src/wagmi/BurnerConnector.ts | 7 ++- pnpm-lock.yaml | 51 ++++++++++++++------ 5 files changed, 43 insertions(+), 22 deletions(-) diff --git a/packages/webapp/src/chain.ts b/packages/webapp/src/chain.ts index a8a4a7e7..6d867eb2 100644 --- a/packages/webapp/src/chain.ts +++ b/packages/webapp/src/chain.ts @@ -14,7 +14,7 @@ import { BurnerConnector } from "src/wagmi/BurnerConnector" // ================================================================================================= /** The list of chains supported by the app. */ -const rollop = defineChain({ +export const rollop = defineChain({ ...localhost, id: 1201101712, name: 'Rollop', diff --git a/packages/webapp/src/setup.ts b/packages/webapp/src/setup.ts index 062e5ebd..d5904153 100644 --- a/packages/webapp/src/setup.ts +++ b/packages/webapp/src/setup.ts @@ -50,7 +50,8 @@ const filteredErrorCodes = [ ] const filteredErrorMessages: (string|RegExp)[] = [ - "ChainDoesNotSupportContract: Chain \"Localhost\" does not support contract \"ensUniversalResolver\"." + "ChainDoesNotSupportContract: Chain \"Localhost\" does not support contract \"ensUniversalResolver\".", + "ChainDoesNotSupportContract: Chain \"Rollop\" does not support contract \"ensUniversalResolver\"." ] const filteredWarningMessages = [ diff --git a/packages/webapp/src/utils/accounts.ts b/packages/webapp/src/utils/accounts.ts index 3df58734..7b33bc69 100644 --- a/packages/webapp/src/utils/accounts.ts +++ b/packages/webapp/src/utils/accounts.ts @@ -79,7 +79,7 @@ export async function createAccount() { // to send a transaction, it will be similar to using walletClient, example below /* - const txHash3 = await smartAccountClient.sendTransaction({ + const txHash = await smartAccountClient.sendTransaction({ to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", value: BigInt(0), data: "0x68656c6c6f" diff --git a/packages/webapp/src/wagmi/BurnerConnector.ts b/packages/webapp/src/wagmi/BurnerConnector.ts index 44651a98..51ec9db9 100644 --- a/packages/webapp/src/wagmi/BurnerConnector.ts +++ b/packages/webapp/src/wagmi/BurnerConnector.ts @@ -3,10 +3,9 @@ */ import { Connector, ConnectorData, WalletClient } from "wagmi" -import { Address } from "src/chain" +import { Address, rollop } from "src/chain" import { PrivateKeyAccount, privateKeyToAccount } from "viem/accounts" import { createWalletClient, http } from "viem" -import { localhost } from "wagmi/chains" import { connect, disconnect, getAccount } from "wagmi/actions" import { AsyncLock } from "src/utils/asyncLock" @@ -43,7 +42,7 @@ export class BurnerConnector extends Connector { readonly name = "0xFable Burner Wallet" ready = false - #chain = localhost + #chain = rollop #connected = false #connectLock = new AsyncLock() #privKey: PrivateKey = undefined as any @@ -52,7 +51,7 @@ export class BurnerConnector extends Connector { constructor() { super({ - chains: [localhost], + chains: [rollop], options: {} }) } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 26b97eef..0c7f32f0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,7 +24,7 @@ importers: version: 0.7.1 viem: specifier: ^1.16.6 - version: 1.16.6(typescript@5.2.2)(zod@3.22.4) + version: 1.16.6(typescript@5.2.2) devDependencies: jest: specifier: ^29.7.0 @@ -59,7 +59,7 @@ importers: version: 20.8.7 viem: specifier: ^1.16.6 - version: 1.16.6(typescript@5.2.2)(zod@3.22.4) + version: 1.16.6(typescript@5.2.2) packages/webapp: dependencies: @@ -116,7 +116,7 @@ importers: version: 0.7.1 viem: specifier: ^1.16.6 - version: 1.16.6(typescript@5.2.2)(zod@3.22.4) + version: 1.16.6(typescript@5.2.2) wagmi: specifier: ^1.4.5 version: 1.4.5(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.16.6) @@ -185,7 +185,6 @@ packages: /@adraffy/ens-normalize@1.10.0: resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} - dev: true /@adraffy/ens-normalize@1.9.0: resolution: {integrity: sha512-iowxq3U30sghZotgl4s/oJRci6WPBfNO5YYgk2cIOMCHr3LeGPcsZjCEr+33Q4N+oV3OABDAtA+pyvWjbvBifQ==} @@ -3034,7 +3033,7 @@ packages: resolution: {integrity: sha512-gYw0ki/EAuV1oSyMxpqandHjnthZjYYy+YWpTAzf8BqfXM3ItcZLpjxfg+3+mXW8HIO+3jw6T9iiqEXsqHaMMw==} dependencies: '@safe-global/safe-gateway-typescript-sdk': 3.12.0 - viem: 1.16.6(typescript@5.2.2)(zod@3.22.4) + viem: 1.19.4(typescript@5.2.2)(zod@3.22.4) transitivePeerDependencies: - bufferutil - typescript @@ -3045,7 +3044,7 @@ packages: resolution: {integrity: sha512-XJbEPuaVc7b9n23MqlF6c+ToYIS3f7P2Sel8f3cSBQ9WORE4xrSuvhMpK9fDSFqJ7by/brc+rmJR/5HViRr0/w==} dependencies: '@safe-global/safe-gateway-typescript-sdk': 3.12.0 - viem: 1.16.6(typescript@5.2.2)(zod@3.22.4) + viem: 1.19.4(typescript@5.2.2)(zod@3.22.4) transitivePeerDependencies: - bufferutil - typescript @@ -3063,7 +3062,7 @@ packages: resolution: {integrity: sha512-bcKpo1oj54hGholplGLpqPHRbIsnbixFtc06nwuNM5/dwSXOq/AAYoIBRsBmnZJSdfeNW5rnff7NTAz3ZCqR9Q==} dependencies: '@noble/curves': 1.0.0 - '@noble/hashes': 1.3.0 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.3 dev: true @@ -3077,7 +3076,7 @@ packages: /@scure/bip39@1.2.0: resolution: {integrity: sha512-SX/uKq52cuxm4YFXWFaVByaSHJh2w3BnokVSeUJVCv6K7WulT9u2BuNRBhuFl8vAuYnzx9bEu9WgpcNYTrYieg==} dependencies: - '@noble/hashes': 1.3.0 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.3 dev: true @@ -3982,7 +3981,7 @@ packages: picocolors: 1.0.0 prettier: 2.8.8 typescript: 5.2.2 - viem: 1.16.6(typescript@5.2.2)(zod@3.22.4) + viem: 1.19.4(typescript@5.2.2)(zod@3.22.4) wagmi: 1.4.5(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.16.6) zod: 3.22.4 transitivePeerDependencies: @@ -4010,7 +4009,7 @@ packages: abitype: 0.8.7(typescript@5.2.2)(zod@3.22.4) eventemitter3: 4.0.7 typescript: 5.2.2 - viem: 1.16.6(typescript@5.2.2)(zod@3.22.4) + viem: 1.16.6(typescript@5.2.2) transitivePeerDependencies: - '@react-native-async-storage/async-storage' - '@types/react' @@ -4035,7 +4034,7 @@ packages: abitype: 0.8.7(typescript@5.2.2)(zod@3.22.4) eventemitter3: 4.0.7 typescript: 5.2.2 - viem: 1.16.6(typescript@5.2.2)(zod@3.22.4) + viem: 1.16.6(typescript@5.2.2) zustand: 4.4.4(@types/react@18.2.31)(react@18.2.0) transitivePeerDependencies: - '@react-native-async-storage/async-storage' @@ -5949,7 +5948,7 @@ packages: react-use-measure: 2.1.1(react-dom@18.2.0)(react@18.2.0) resize-observer-polyfill: 1.5.1 styled-components: 5.3.11(@babel/core@7.23.2)(react-dom@18.2.0)(react-is@18.2.0)(react@18.2.0) - viem: 1.16.6(typescript@5.2.2)(zod@3.22.4) + viem: 1.16.6(typescript@5.2.2) wagmi: 1.4.5(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.16.6) transitivePeerDependencies: - '@babel/core' @@ -10713,7 +10712,7 @@ packages: peerDependencies: viem: ^1.19.4 dependencies: - viem: 1.16.6(typescript@5.2.2)(zod@3.22.4) + viem: 1.16.6(typescript@5.2.2) dev: false /picocolors@1.0.0: @@ -13009,7 +13008,7 @@ packages: - zod dev: true - /viem@1.16.6(typescript@5.2.2)(zod@3.22.4): + /viem@1.16.6(typescript@5.2.2): resolution: {integrity: sha512-jcWcFQ+xzIfDwexwPJRvCuCRJKEkK9iHTStG7mpU5MmuSBpACs4nATBDyXNFtUiyYTFzLlVEwWkt68K0nCSImg==} peerDependencies: typescript: '>=5.0.4' @@ -13031,6 +13030,28 @@ packages: - utf-8-validate - zod + /viem@1.19.4(typescript@5.2.2)(zod@3.22.4): + resolution: {integrity: sha512-CvAVaOzxlu3Q/cpfrYvTRMBIPDMAkLu8aFmHLqU1Bg25DyUxp9xwoF1Ljp38q7/Rosm1OPFQ4y6K64v/VwoumQ==} + peerDependencies: + typescript: '>=5.0.4' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@adraffy/ens-normalize': 1.10.0 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@scure/bip32': 1.3.2 + '@scure/bip39': 1.2.1 + abitype: 0.9.8(typescript@5.2.2)(zod@3.22.4) + isows: 1.0.3(ws@8.13.0) + typescript: 5.2.2 + ws: 8.13.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + - zod + /wagmi@1.4.5(@types/react@18.2.31)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(viem@1.16.6): resolution: {integrity: sha512-Ph62E6cO5n2Z8Z5LTyZrkaNprxTsbC4w0qZJT4OJdXrEELziI8z/b4FO6amVFXdu2rDp/wpvF56e4mhKC8/Kdw==} peerDependencies: @@ -13049,7 +13070,7 @@ packages: react: 18.2.0 typescript: 5.2.2 use-sync-external-store: 1.2.0(react@18.2.0) - viem: 1.16.6(typescript@5.2.2)(zod@3.22.4) + viem: 1.16.6(typescript@5.2.2) transitivePeerDependencies: - '@react-native-async-storage/async-storage' - '@types/react'