@@ -55,20 +55,20 @@ async function testWithBiconomySDK() {
5555
5656 console . log ( "\n⚙️ Setting up Viem client..." ) ;
5757
58- // Get owner's private key from environment or hardhat
59- const [ hardhatSigner ] = await ethers . getSigners ( ) ;
60-
61- if ( hardhatSigner . address . toLowerCase ( ) !== ownerAddress . toLowerCase ( ) ) {
62- throw new Error (
63- `Signer mismatch! Expected ${ ownerAddress } , got ${ hardhatSigner . address } `
64- ) ;
58+ // Support custom owner (same as scripts 02 and 03)
59+ let privateKeyRaw : string | undefined ;
60+
61+ const customOwnerPk = process . env . MIGRATION_TEST_OWNER_PK ;
62+ if ( customOwnerPk ) {
63+ privateKeyRaw = customOwnerPk ;
64+ console . log ( " ⚠️ Using custom owner from MIGRATION_TEST_OWNER_PK" ) ;
65+ } else {
66+ // Get private key from .env (same as used for deployment)
67+ privateKeyRaw = process . env . BASE_SEPOLIA_PRIVATE_KEY || process . env . COLD_WALLET_PRIVATE_KEY ;
6568 }
6669
67- // Get private key from .env (same as used for deployment)
68- const privateKeyRaw = process . env . BASE_SEPOLIA_PRIVATE_KEY || process . env . COLD_WALLET_PRIVATE_KEY ;
69-
7070 if ( ! privateKeyRaw ) {
71- throw new Error ( "BASE_SEPOLIA_PRIVATE_KEY or COLD_WALLET_PRIVATE_KEY not found in .env " ) ;
71+ throw new Error ( "MIGRATION_TEST_OWNER_PK, BASE_SEPOLIA_PRIVATE_KEY or COLD_WALLET_PRIVATE_KEY not found" ) ;
7272 }
7373
7474 // Ensure it has 0x prefix
@@ -77,6 +77,14 @@ async function testWithBiconomySDK() {
7777 const eoaAccount = privateKeyToAccount ( privateKey as `0x${string } `) ;
7878
7979 console . log ( ` EOA: ${ eoaAccount . address } ` ) ;
80+
81+ // Verify it matches the owner
82+ if ( eoaAccount . address . toLowerCase ( ) !== ownerAddress . toLowerCase ( ) ) {
83+ throw new Error (
84+ `Signer mismatch! Expected ${ ownerAddress } , got ${ eoaAccount . address } `
85+ ) ;
86+ }
87+
8088 console . log ( " ✅ Viem client configured\n" ) ;
8189 console . log ( "=" . repeat ( 80 ) ) ;
8290
@@ -86,8 +94,8 @@ async function testWithBiconomySDK() {
8694
8795 console . log ( "\n🔗 Creating Nexus Account with Biconomy SDK..." ) ;
8896
89- // Use MEE version v2.1 .0 (matches our deployment)
90- const version = MEEVersion . V2_1_0 ;
97+ // Use MEE version v2.2 .0 (Experimental - matches our Nexus v1.2.1 deployment)
98+ const version = MEEVersion . V2_2_0 ;
9199 const versionConfig = getMEEVersion ( version ) ;
92100
93101 console . log ( ` MEE Version: ${ version } ` ) ;
@@ -113,7 +121,29 @@ async function testWithBiconomySDK() {
113121 ) ;
114122 }
115123
116- console . log ( " ✅ Address matches migrated wallet\n" ) ;
124+ console . log ( " ✅ Address matches migrated wallet" ) ;
125+
126+ // Check account initialization using Nexus contract
127+ // NOTE: nexusAccount from SDK does NOT have an isInitialized() method
128+ // We need to call the Nexus contract directly using ethers.js
129+ const Nexus = await ethers . getContractFactory ( "Nexus" ) ;
130+ const nexusContract = Nexus . attach ( walletAddress ) ;
131+
132+ try {
133+ const isInitialized = await nexusContract . isInitialized ( ) ;
134+ console . log ( ` Initialization: ${ isInitialized ? "✅ YES" : "❌ NO" } ` ) ;
135+
136+ if ( ! isInitialized ) {
137+ console . log ( " ⚠️ Warning: Wallet is not initialized!" ) ;
138+ }
139+ } catch ( error : any ) {
140+ console . log ( ` ⚠️ Could not check initialization: ${ error . message } ` ) ;
141+ }
142+
143+ // Check account ID from SDK
144+ console . log ( ` Account ID: ${ nexusAccount . accountId } ` ) ;
145+
146+ console . log ( ) ;
117147 console . log ( "=" . repeat ( 80 ) ) ;
118148
119149 // ========================================================================
@@ -172,7 +202,7 @@ async function testWithBiconomySDK() {
172202 // Get current gas prices from provider
173203 const feeData = await provider . getFeeData ( ) ;
174204 console . log ( ` ⛽ Max Fee Per Gas: ${ ethers . utils . formatUnits ( feeData . maxFeePerGas || 0 , "gwei" ) } gwei` ) ;
175- console . log ( ` ⛽ Max Priority Fee: ${ ethers . utils . formatUnits ( feeData . maxPriorityFeePerGas || 0 , "gwei" ) } gwei` ) ;
205+ console . log ( ` ⛽ Max Priority Fee: ${ ethers . utils . formatUnits ( feeData . maxPriorityFeePerGas || 0 , "gwei" ) } gwei\n ` ) ;
176206
177207 const userOpHash = await bundlerClient . sendUserOperation ( {
178208 calls : [
@@ -181,9 +211,6 @@ async function testWithBiconomySDK() {
181211 value : testAmount ,
182212 } ,
183213 ] ,
184- // Provide gas parameters manually to avoid bundler gas estimation issues
185- maxFeePerGas : BigInt ( feeData . maxFeePerGas ?. toString ( ) || "1000000000" ) , // 1 gwei fallback
186- maxPriorityFeePerGas : BigInt ( feeData . maxPriorityFeePerGas ?. toString ( ) || "1000000000" ) , // 1 gwei fallback
187214 } ) ;
188215
189216 console . log ( ` ✅ UserOp submitted: ${ userOpHash } \n` ) ;
0 commit comments