@@ -3,13 +3,12 @@ import { RunTab } from "../types/run-tab"
3
3
import { clearInstances , setAccount , setExecEnv } from "./actions"
4
4
import { displayNotification , fetchAccountsListFailed , fetchAccountsListRequest , fetchAccountsListSuccess , setMatchPassphrase , setPassphrase } from "./payload"
5
5
import { toChecksumAddress } from '@ethereumjs/util'
6
-
7
6
import "viem/window"
8
- import { createPublicClient , http , custom , Account , PublicClient , Address } from "viem"
7
+ import { custom , createWalletClient } from "viem"
9
8
import { sepolia } from "viem/chains"
10
9
import { entryPoint07Address } from "viem/account-abstraction"
11
- import "permissionless "
12
- import { toSafeSmartAccount } from "permissionless/accounts"
10
+ import { toAccount } from "viem/accounts "
11
+ const { toSafeSmartAccount } = require ( "permissionless/accounts" )
13
12
14
13
export const updateAccountBalances = async ( plugin : RunTab , dispatch : React . Dispatch < any > ) => {
15
14
const accounts = plugin . REACT_API . accounts . loadedAccounts
@@ -97,35 +96,26 @@ export const createSmartAccount = async (plugin: RunTab, dispatch: React.Dispatc
97
96
console . log ( 'createSmartAccount action' )
98
97
99
98
// @ts -ignore
100
- const accounts = await window . ethereum ! . request ( { method : 'eth_requestAccounts' } )
101
- console . log ( 'account---accounts->' , accounts )
102
- const selectedAddress = plugin . REACT_API . accounts . selectedAccount
103
- console . log ( 'account---selectedAddress->' , selectedAddress )
99
+ const [ account ] = await window . ethereum ! . request ( { method : 'eth_requestAccounts' } )
100
+ console . log ( 'account---accounts->' , account )
104
101
105
- const publicClient = createPublicClient ( {
102
+ const walletClient = createWalletClient ( {
103
+ account,
106
104
chain : sepolia ,
107
- transport : custom ( window . ethereum ) ,
105
+ transport : custom ( window . ethereum ! ) ,
108
106
} )
109
107
110
- console . log ( 'publicClient->' , publicClient )
111
-
112
-
113
- // const owner = privateKeyToAccount(SIGNER_PRIVATE_KEY)
114
-
115
-
116
-
117
108
const safeAccount = await toSafeSmartAccount ( {
118
- client : publicClient ,
109
+ client : walletClient ,
119
110
entryPoint : {
120
111
address : entryPoint07Address ,
121
112
version : "0.7" ,
122
113
} ,
123
- owners : [ selectedAddress ] ,
114
+ owners : [ toAccount ( account ) ] ,
124
115
// saltNonce: 0n, // optional
125
116
version : "1.4.1"
126
117
} )
127
118
128
- console . log ( 'safeAccount----->' , safeAccount )
129
119
console . log ( 'safeAccount----->' , safeAccount . address )
130
120
}
131
121
0 commit comments