Skip to content

Commit 682b08b

Browse files
committed
create safe account
1 parent 6605c8d commit 682b08b

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

libs/remix-ui/run-tab/src/lib/actions/account.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import { RunTab } from "../types/run-tab"
33
import { clearInstances, setAccount, setExecEnv } from "./actions"
44
import { displayNotification, fetchAccountsListFailed, fetchAccountsListRequest, fetchAccountsListSuccess, setMatchPassphrase, setPassphrase } from "./payload"
55
import { toChecksumAddress } from '@ethereumjs/util'
6-
76
import "viem/window"
8-
import { createPublicClient, http, custom, Account, PublicClient, Address } from "viem"
7+
import { custom, createWalletClient } from "viem"
98
import { sepolia } from "viem/chains"
109
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")
1312

1413
export const updateAccountBalances = async (plugin: RunTab, dispatch: React.Dispatch<any>) => {
1514
const accounts = plugin.REACT_API.accounts.loadedAccounts
@@ -97,35 +96,26 @@ export const createSmartAccount = async (plugin: RunTab, dispatch: React.Dispatc
9796
console.log('createSmartAccount action')
9897

9998
// @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)
104101

105-
const publicClient = createPublicClient({
102+
const walletClient = createWalletClient({
103+
account,
106104
chain: sepolia,
107-
transport: custom(window.ethereum),
105+
transport: custom(window.ethereum!),
108106
})
109107

110-
console.log('publicClient->', publicClient)
111-
112-
113-
// const owner = privateKeyToAccount(SIGNER_PRIVATE_KEY)
114-
115-
116-
117108
const safeAccount = await toSafeSmartAccount({
118-
client: publicClient,
109+
client: walletClient,
119110
entryPoint: {
120111
address: entryPoint07Address,
121112
version: "0.7",
122113
},
123-
owners: [selectedAddress],
114+
owners: [toAccount(account)],
124115
// saltNonce: 0n, // optional
125116
version: "1.4.1"
126117
})
127118

128-
console.log('safeAccount----->', safeAccount)
129119
console.log('safeAccount----->', safeAccount.address)
130120
}
131121

0 commit comments

Comments
 (0)