From b1dd0cad0a71e1d15123816a605d81856724ff71 Mon Sep 17 00:00:00 2001 From: Igor Shadurin Date: Thu, 5 Dec 2024 14:28:32 +0300 Subject: [PATCH] refactor: permissionless updated, entry point updated to v7 --- package-lock.json | 110 +++++++++++++++++++++++++--------------- package.json | 4 +- src/rpc-helper/index.ts | 23 +++++---- 3 files changed, 83 insertions(+), 54 deletions(-) diff --git a/package-lock.json b/package-lock.json index f9daa8b..9dce92d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "3.0.0", "license": "MIT", "dependencies": { - "permissionless": "^0.1.28", - "viem": "^2.21.26" + "permissionless": "^0.2.21", + "viem": "^2.21.22" }, "devDependencies": { "@babel/core": "^7.25.8", @@ -62,7 +62,8 @@ "node_modules/@adraffy/ens-normalize": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.0.tgz", - "integrity": "sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==" + "integrity": "sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==", + "license": "MIT" }, "node_modules/@ampproject/remapping": { "version": "2.2.1", @@ -1903,10 +1904,11 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.0.tgz", - "integrity": "sha512-vH9PiIMMwvhCx31Af3HiGzsVNULDbyVkHXwlemn/B0TFj/00ho3y55efXrUZTfQipxoHC5u4xq6zblww1zm1Ig==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.3.tgz", + "integrity": "sha512-2b/g5hRmpbb1o4GnTZax9N9m0FXzz9OV42ZzI4rDDMDuHUqigAiQCEWChBWCY4ztAGVRjoWT19v0yMmc5/L5kA==", "dev": true, + "license": "Apache-2.0", "dependencies": { "levn": "^0.4.1" }, @@ -2786,6 +2788,45 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@noble/curves": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.7.0.tgz", + "integrity": "sha512-UTMhXK9SeDhFJVrHeUJ5uZlI6ajXg10O6Ddocf9S6GjbSBVZsJo88HzKwXznNfGpMTRDyJkqMjNDPYgf0qFWnw==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.6.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves/node_modules/@noble/hashes": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.6.0.tgz", + "integrity": "sha512-YUULf0Uk4/mAA89w+k3+yUYh6NrEvxZa5T6SY3wlMvE2chHkxFUUIDI8/XW1QSC357iA5pSnqt7XEhvFOqmDyQ==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.6.1.tgz", + "integrity": "sha512-pq5D8h10hHBjyqX+cfBm0i8JUXJ0UhczFc4r74zbuT9XgewFo2E3J1cOaGtdZynILNmQ685YWGzGE1Zv6io50w==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -2853,6 +2894,7 @@ "version": "1.1.9", "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.9.tgz", "integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==", + "license": "MIT", "funding": { "url": "https://paulmillr.com/funding/" } @@ -2861,6 +2903,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.5.0.tgz", "integrity": "sha512-8EnFYkqEQdnkuGBVpCzKxyIwDCBLDVj3oiX0EKUFre/tOjL/Hqba1D6n/8RcmaQy4f95qQFrO2A8Sr6ybh4NRw==", + "license": "MIT", "dependencies": { "@noble/curves": "~1.6.0", "@noble/hashes": "~1.5.0", @@ -2874,6 +2917,7 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.6.0.tgz", "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", + "license": "MIT", "dependencies": { "@noble/hashes": "1.5.0" }, @@ -2888,6 +2932,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "license": "MIT", "engines": { "node": "^14.21.3 || >=16" }, @@ -2899,6 +2944,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.4.0.tgz", "integrity": "sha512-BEEm6p8IueV/ZTfQLp/0vhw4NPnT9oWf5+28nvmeUICjP99f4vr2d+qc7AVGDDtwRep6ifR43Yed9ERVmiITzw==", + "license": "MIT", "dependencies": { "@noble/hashes": "~1.5.0", "@scure/base": "~1.1.8" @@ -2911,6 +2957,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "license": "MIT", "engines": { "node": "^14.21.3 || >=16" }, @@ -3565,6 +3612,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.6.tgz", "integrity": "sha512-MMSqYh4+C/aVqI2RQaWqbvI4Kxo5cQV40WQ4QFtDnNzCkqChm8MuENhElmynZlO0qUy/ObkEUaXtKqYnx1Kp3A==", + "license": "MIT", "funding": { "url": "https://github.com/sponsors/wevm" }, @@ -4463,10 +4511,11 @@ "dev": true }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -8162,11 +8211,12 @@ } }, "node_modules/permissionless": { - "version": "0.1.28", - "resolved": "https://registry.npmjs.org/permissionless/-/permissionless-0.1.28.tgz", - "integrity": "sha512-JjE4IofN2B1pqB4L7g/9G325pKXCGuPHfpc390jtVvk4CjnIIVQN1NwO97eb+bAYty+1aoBgYsw6ezxH1WmgWA==", + "version": "0.2.21", + "resolved": "https://registry.npmjs.org/permissionless/-/permissionless-0.2.21.tgz", + "integrity": "sha512-hNrRR/I5InbqkKgRBLhXQY5R0j9biqp688ECBxsW5AO99jOv9HPjz82EdRT87OG4XkCjO4AY20hi4ZPoc+XjRg==", + "license": "MIT", "peerDependencies": { - "viem": "^2.9.17" + "viem": "^2.21.22" } }, "node_modules/picocolors": { @@ -9718,15 +9768,16 @@ } }, "node_modules/viem": { - "version": "2.21.26", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.21.26.tgz", - "integrity": "sha512-qanTFUzU5y3tCZTwYlwA/LXCR4X7OsCPvvKOmxOyuY8gEvWKMS/oh+FBxYO/2bXOhDG/ylg1V3toIbRuMseF8w==", + "version": "2.21.22", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.21.22.tgz", + "integrity": "sha512-jU+WniqIhwDXfgWWkNX7YqlGqenzTa5roLDNs2cbcUGQXxG8aQt1vlTqeezM8W1kepkaU/jvR2QSq/lGirpzrQ==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/wevm" } ], + "license": "MIT", "dependencies": { "@adraffy/ens-normalize": "1.11.0", "@noble/curves": "1.6.0", @@ -9751,6 +9802,7 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.6.0.tgz", "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", + "license": "MIT", "dependencies": { "@noble/hashes": "1.5.0" }, @@ -9765,6 +9817,7 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "license": "MIT", "engines": { "node": "^14.21.3 || >=16" }, @@ -9809,31 +9862,6 @@ "@noble/hashes": "^1.4.0" } }, - "node_modules/webauthn-p256/node_modules/@noble/curves": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.6.0.tgz", - "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", - "dependencies": { - "@noble/hashes": "1.5.0" - }, - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/webauthn-p256/node_modules/@noble/hashes": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", - "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/webpack": { "version": "5.95.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.95.0.tgz", diff --git a/package.json b/package.json index 0c309da..42abefb 100644 --- a/package.json +++ b/package.json @@ -78,8 +78,8 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "permissionless": "^0.1.28", - "viem": "^2.21.26" + "permissionless": "^0.2.21", + "viem": "^2.21.22" }, "engines": { "node": ">=20" diff --git a/src/rpc-helper/index.ts b/src/rpc-helper/index.ts index cdbc9de..d72860f 100644 --- a/src/rpc-helper/index.ts +++ b/src/rpc-helper/index.ts @@ -1,16 +1,15 @@ import { INetworkConfig } from '../network-config' import { HDAccount } from 'viem/accounts' import { Chain, createPublicClient, http, HttpTransport } from 'viem' -import { LightSmartAccount, signerToLightSmartAccount } from 'permissionless/accounts' -import { createSmartAccountClient, ENTRYPOINT_ADDRESS_V06, SmartAccountClient } from 'permissionless' -import { ENTRYPOINT_ADDRESS_V06_TYPE } from 'permissionless/types' +import { toSimpleSmartAccount, ToSimpleSmartAccountReturnType } from 'permissionless/accounts' +import { createSmartAccountClient, SmartAccountClient } from 'permissionless' import { getChain } from '../utils/chain' import { assertNotEmptySigner } from '../connections/utils' +import { entryPoint07Address, type SmartAccount } from 'viem/account-abstraction' -export type LightSmartAccountType = LightSmartAccount +export type LightSmartAccountType = ToSimpleSmartAccountReturnType -// prettier-ignore -export type SmartAccountClientType = SmartAccountClient +export type SmartAccountClientType = SmartAccountClient export class RpcHelper { private account: LightSmartAccountType | undefined @@ -38,10 +37,13 @@ export class RpcHelper { assertNotEmptySigner(this.eoaSigner) if (!this.account) { - this.account = await signerToLightSmartAccount(this.getPublicClient(), { - signer: this.eoaSigner, - entryPoint: ENTRYPOINT_ADDRESS_V06, - lightAccountVersion: '1.1.0', + this.account = await toSimpleSmartAccount({ + owner: this.eoaSigner, + client: this.getPublicClient(), + entryPoint: { + address: entryPoint07Address, + version: '0.7', + }, }) } @@ -56,7 +58,6 @@ export class RpcHelper { const account = await this.getAccount() this.accountClient = createSmartAccountClient({ account, - entryPoint: ENTRYPOINT_ADDRESS_V06, chain: getChain(this.config.chainId), bundlerTransport: http(this.config.rpcUserOperationsUrl), // middleware: {