Skip to content

Commit 1f312c8

Browse files
Add scripts for mainnet migration
1 parent 21f6ecd commit 1f312c8

22 files changed

+1852
-117
lines changed

scripts/biconomy-migration/02-deploy-test-passport-wallet.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@ async function deployTestPassportWallet() {
3131
// LOAD DEPLOYMENT ARTIFACTS
3232
// ============================================================================
3333

34-
const deploymentPath = path.join(__dirname, "../deployment-summary-simplified.json");
34+
// Auto-detect network and load correct deployment file
35+
const currentNetwork = await ethers.provider.getNetwork();
36+
const isMainnet = currentNetwork.chainId === 8453; // Base Mainnet
37+
38+
const deploymentPath = isMainnet
39+
? path.join(__dirname, "mainnet-poc/deployment-summary-base-mainnet.json")
40+
: path.join(__dirname, "../deployment-summary-simplified.json");
41+
42+
console.log(`\n🌐 Network: ${currentNetwork.name} (chainId: ${currentNetwork.chainId})`);
43+
console.log(`📂 Loading deployment from: ${path.basename(deploymentPath)}\n`);
44+
3545
const deployment = JSON.parse(fs.readFileSync(deploymentPath, "utf8"));
3646

3747
const artifacts = {
@@ -71,8 +81,11 @@ async function deployTestPassportWallet() {
7181
const balance = await deployer.getBalance();
7282
console.log(`💰 Deployer Balance: ${ethers.utils.formatEther(balance)} ETH\n`);
7383

74-
if (balance.lt(ethers.utils.parseEther("0.01"))) {
75-
throw new Error("Insufficient balance for deployment (need at least 0.01 ETH)");
84+
// Adjust minimum balance requirement based on network
85+
const minBalance = isMainnet ? "0.005" : "0.01"; // Lower requirement for mainnet (real costs)
86+
87+
if (balance.lt(ethers.utils.parseEther(minBalance))) {
88+
throw new Error(`Insufficient balance for deployment (need at least ${minBalance} ETH)`);
7689
}
7790

7891
// ============================================================================

scripts/biconomy-migration/04-test-with-biconomy-abstractjs.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as fs from "fs";
1515
import * as path from "path";
1616
import { createWalletClient, http, parseEther } from "viem";
1717
import { privateKeyToAccount } from "viem/accounts";
18-
import { baseSepolia } from "viem/chains";
18+
import { baseSepolia, base } from "viem/chains";
1919
import {
2020
createBicoBundlerClient,
2121
toNexusAccount,
@@ -88,6 +88,18 @@ async function testWithBiconomySDK() {
8888
console.log(" ✅ Viem client configured\n");
8989
console.log("=".repeat(80));
9090

91+
// ============================================================================
92+
// DETECT NETWORK
93+
// ============================================================================
94+
95+
const network = await ethers.provider.getNetwork();
96+
const isMainnet = network.chainId === 8453; // Base Mainnet
97+
const viemChain = isMainnet ? base : baseSepolia;
98+
99+
console.log(`\n🌐 Network: ${viemChain.name} (chainId: ${network.chainId})`);
100+
console.log(` Mode: ${isMainnet ? 'MAINNET 🔴' : 'TESTNET 🟡'}\n`);
101+
console.log("=".repeat(80));
102+
91103
// ============================================================================
92104
// CREATE NEXUS ACCOUNT WITH BICONOMY SDK
93105
// ============================================================================
@@ -106,7 +118,7 @@ async function testWithBiconomySDK() {
106118
const nexusAccount = await toNexusAccount({
107119
signer: eoaAccount,
108120
chainConfiguration: {
109-
chain: baseSepolia,
121+
chain: viemChain,
110122
transport: http(),
111123
version: versionConfig,
112124
},
@@ -152,8 +164,14 @@ async function testWithBiconomySDK() {
152164

153165
console.log("\n🌐 Creating Bundler Client...");
154166

155-
// Load bundler URL from deployment or environment
156-
const bundlerUrl = process.env.NEXUS_BUNDLER_URL || "https://bundler.biconomy.io/api/v2/84532/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44";
167+
// Load bundler URL based on network
168+
const bundlerUrl = isMainnet
169+
? (process.env.BICONOMY_BUNDLER_URL_BASE || process.env.NEXUS_BUNDLER_URL)
170+
: (process.env.NEXUS_BUNDLER_URL || "https://bundler.biconomy.io/api/v2/84532/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44");
171+
172+
if (!bundlerUrl) {
173+
throw new Error("Bundler URL not configured! Set BICONOMY_BUNDLER_URL_BASE in .env");
174+
}
157175

158176
console.log(` Bundler URL: ${bundlerUrl}\n`);
159177

0 commit comments

Comments
 (0)