@@ -4,6 +4,7 @@ import type { Transaction as InternalTransaction } from './txRunner'
44import { Web3 } from 'web3'
55import { BrowserProvider } from 'ethers'
66import { normalizeHexAddress } from '../helpers/uiHelper'
7+ import { aaSupportedNetworks , aaLocalStorageKey , getPimlicoBundlerURL , aaDeterminiticProxyAddress } from '../helpers/aaConstants'
78import { toBigInt , toHex , toChecksumAddress } from 'web3-utils'
89import { randomBytes } from 'crypto'
910import "viem/window"
@@ -110,7 +111,7 @@ export class TxRunnerWeb3 {
110111 } else {
111112 try {
112113 if ( tx . fromSmartAccount ) {
113- const { txHash, contractAddress } = await this . sendUserOp ( tx )
114+ const { txHash, contractAddress } = await this . sendUserOp ( tx , network . id )
114115 cb ( null , txHash , isCreation , true , contractAddress )
115116 } else {
116117 const res = await this . getWeb3 ( ) . eth . sendTransaction ( tx , null , { checkRevertBeforeSending : false , ignoreGasPricing : true } )
@@ -201,8 +202,11 @@ export class TxRunnerWeb3 {
201202 callback ( new Error ( 'Gas estimation failed because of an unknown internal error. This may indicated that the transaction will fail.' ) )
202203 return
203204 }
204- if ( tx . fromSmartAccount && tx . value === "0" && err && err . error && err . error . indexOf ( 'insufficient funds for transfer' ) !== - 1 ) {
205- // Do not show dialog for insufficient funds as smart account may be using paymaster
205+ if ( tx . fromSmartAccount && tx . value === "0" &&
206+ err && err . message && err . message . includes ( 'missing revert data' )
207+ ) {
208+ // Do not show dialog for 'missing revert data'
209+ // tx fees can be managed by paymaster in case of smart account tx
206210 // @todo If paymaster is used, check if balance/credits are available
207211 err = null
208212 }
@@ -225,16 +229,13 @@ export class TxRunnerWeb3 {
225229 } )
226230 }
227231
228- async sendUserOp ( tx ) {
229- const localStorageKey = 'smartAccounts'
230- const PUBLIC_NODE_URL = "https://go.getblock.io/ee42d0a88f314707be11dd799b122cb9"
231- const determiniticProxyAddress = "0x4e59b44847b379578588920cA78FbF26c0B4956C"
232- const network = 'sepolia'
233- const chain = chains [ network ]
234- const BUNDLER_URL = `https://pimlico.remixproject.org/api/proxy/${ chain . id } `
232+ async sendUserOp ( tx , chainId ) {
233+ const chain = chains [ aaSupportedNetworks [ chainId ] . name ]
234+ const PUBLIC_NODE_URL = aaSupportedNetworks [ chainId ] . publicNodeUrl
235+ const BUNDLER_URL = getPimlicoBundlerURL ( chainId )
235236
236237 // Check that saOwner is there in MM addresses
237- let smartAccountsObj = localStorage . getItem ( localStorageKey )
238+ let smartAccountsObj = localStorage . getItem ( aaLocalStorageKey )
238239 smartAccountsObj = JSON . parse ( smartAccountsObj )
239240 const saDetails = smartAccountsObj [ chain . id ] [ tx . from ]
240241 const saOwner = saDetails [ 'ownerEOA' ]
@@ -248,7 +249,7 @@ export class TxRunnerWeb3 {
248249
249250 const publicClient = createPublicClient ( {
250251 chain,
251- transport : http ( PUBLIC_NODE_URL ) // choose any provider here
252+ transport : http ( PUBLIC_NODE_URL )
252253 } )
253254
254255 const safeAccount = await toSafeSmartAccount ( {
@@ -284,15 +285,15 @@ export class TxRunnerWeb3 {
284285
285286 const expectedDeploymentAddress = getContractAddress ( {
286287 bytecode,
287- from : determiniticProxyAddress ,
288+ from : aaDeterminiticProxyAddress ,
288289 opcode : 'CREATE2' ,
289290 salt
290291 } )
291292 let txHash , contractAddress
292293 if ( ! tx . to ) {
293294 // contract deployment transaction
294295 txHash = await saClient . sendTransaction ( {
295- to : determiniticProxyAddress ,
296+ to : aaDeterminiticProxyAddress ,
296297 data : encodePacked ( [ "bytes32" , "bytes" ] , [ salt , bytecode ] )
297298 } )
298299 // check if code is deployed to expectedDeployment Address
@@ -303,7 +304,7 @@ export class TxRunnerWeb3 {
303304 contractAddress = expectedDeploymentAddress
304305 } else {
305306 contractAddress = undefined
306- console . error ( 'Error in contract deployment' )
307+ console . error ( 'Error in contract deployment using smart account ' )
307308 }
308309 } else {
309310 // contract interaction transaction
0 commit comments