diff --git a/.env.example b/.env.example index 80b79ff3..2c074f1c 100644 --- a/.env.example +++ b/.env.example @@ -8,5 +8,4 @@ PAYMASTER_URL= PIMLICO_API_KEY= TENDERLY_API_KEY= TENDERLY_ACCOUNT_SLUG= -TENDERLY_PROJECT_SLUG= -VIRTUAL_BASE_SEPOLIA= \ No newline at end of file +TENDERLY_PROJECT_SLUG= \ No newline at end of file diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c1bfeed5..83d440bf 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -28,7 +28,6 @@ jobs: PIMLICO_API_KEY: ${{ secrets.PIMLICO_API_KEY }} PAYMASTER_URL: ${{ secrets.PAYMASTER_URL }} BUNDLER_URL: ${{ secrets.BUNDLER_URL }} - VIRTUAL_BASE_SEPOLIA: ${{ secrets.VIRTUAL_BASE_SEPOLIA }} CHAIN_ID: 84532 ALT_CHAIN_ID: 11155420 CI: true diff --git a/src/sdk/modules/smartSessionsValidator/toSmartSessionValidator.enable.mode.test.ts b/src/sdk/modules/smartSessionsValidator/toSmartSessionValidator.enable.mode.test.ts index 989ce959..a9dbad3d 100644 --- a/src/sdk/modules/smartSessionsValidator/toSmartSessionValidator.enable.mode.test.ts +++ b/src/sdk/modules/smartSessionsValidator/toSmartSessionValidator.enable.mode.test.ts @@ -16,9 +16,9 @@ import { beforeAll, describe, expect, test } from "vitest" import { CounterAbi } from "../../../test/__contracts/abi/CounterAbi" import { testAddresses } from "../../../test/callDatas" import { toNetwork } from "../../../test/testSetup" -import { getTestParamsForTestnet } from "../../../test/testUtils" -import type { NetworkConfig, TestnetParams } from "../../../test/testUtils" +import type { NetworkConfig } from "../../../test/testUtils" import { type NexusAccount, toNexusAccount } from "../../account/toNexusAccount" +import { safeMultiplier } from "../../account/utils/Utils" import { type NexusClient, createSmartAccountClient @@ -63,6 +63,8 @@ describe("modules.smartSessions.enable.mode.dx", async () => { let stringifiedSessionDatum: string + const index = 2n + beforeAll(async () => { network = await toNetwork("TESTNET_FROM_ENV_VARS") @@ -88,7 +90,7 @@ describe("modules.smartSessions.enable.mode.dx", async () => { }) nexusAccount = await toNexusAccount({ - index: 1n, + index, signer: eoaAccount, chain, transport: http() @@ -97,7 +99,7 @@ describe("modules.smartSessions.enable.mode.dx", async () => { nexusAccountAddress = await nexusAccount.getCounterFactualAddress() nexusClient = await createSmartAccountClient({ - index: 1n, + index, account: nexusAccount, signer: eoaAccount, chain, @@ -191,7 +193,7 @@ describe("modules.smartSessions.enable.mode.dx", async () => { const userOperation = await nexusClient.prepareUserOperation({ verificationGasLimit: 10000000n, callGasLimit: 10000000n, - preVerificationGas: 10000000n, + preVerificationGas: 100000000n, calls, signature: encodeSmartSessionSignature(sessionDetails), nonce: await nexusClient.account.getNonce({ @@ -278,7 +280,7 @@ describe("modules.smartSessions.enable.mode.dx", async () => { // Create a new Nexus client for the session // This client will be used to interact with the smart contract account using the session key const smartSessionNexusClient = await createSmartAccountClient({ - index: 1n, + index, accountAddress: usersSessionData.granter, signer: eoaAccount, chain, @@ -301,7 +303,7 @@ describe("modules.smartSessions.enable.mode.dx", async () => { const userOpHash = await useSmartSessionNexusClient.usePermission({ verificationGasLimit: 10000000n, callGasLimit: 10000000n, - preVerificationGas: 10000000n, + preVerificationGas: 100000000n, calls: [ { to: testAddresses.Counter, diff --git a/src/test/testUtils.ts b/src/test/testUtils.ts index 9b9c9b8e..3fef3257 100644 --- a/src/test/testUtils.ts +++ b/src/test/testUtils.ts @@ -42,6 +42,9 @@ import type { TestFileNetworkType } from "./testSetup" config() +const BASE_SEPOLIA_RPC_URL = + "https://virtual.base-sepolia.rpc.tenderly.co/6ccdd33d-d8f4-4476-8d37-63ba0ed0ea8f" + type AnvilInstance = ReturnType type BundlerInstance = ReturnType type BundlerDto = { @@ -215,17 +218,18 @@ export const toConfiguredAnvil = async ({ chainId: rpcPort, port: rpcPort, codeSizeLimit: 1000000000000, - forkUrl: shouldForkBaseSepolia - ? process.env.VIRTUAL_BASE_SEPOLIA - : undefined + forkUrl: shouldForkBaseSepolia ? BASE_SEPOLIA_RPC_URL : undefined } const instance = anvil(config) await instance.start() - await initDeployments(rpcPort) + await initDeployments(rpcPort, shouldForkBaseSepolia) return instance } -export const initDeployments = async (rpcPort: number) => { +export const initDeployments = async ( + rpcPort: number, + shouldForkBaseSepolia = false +) => { // Hardhat deployment of nexus repo: console.log( `using hardhat to deploy nexus contracts to http://localhost:${rpcPort}` @@ -234,19 +238,21 @@ export const initDeployments = async (rpcPort: number) => { await hardhatExec.deploy(rpcPort) console.log("hardhat deployment complete.") - // Hardcoded bytecode deployment of contracts using setCode: - console.log("setting bytecode with hardcoded calldata.") - const chain = getTestChainFromPort(rpcPort) - const account = getTestAccount() - const testClient = toTestClient(chain, account) - // Dynamic bytecode deployment of contracts using setCode: - console.log("setting bytecode with dynamic calldata from a testnet") - await setByteCodeHardcoded(testClient) - await setByteCodeDynamic(testClient, TEST_CONTRACTS) - - console.log("bytecode deployment complete.") - console.log("") + if (!shouldForkBaseSepolia) { + // Hardcoded bytecode deployment of contracts using setCode: + console.log("setting bytecode with hardcoded calldata.") + const chain = getTestChainFromPort(rpcPort) + const account = getTestAccount() + const testClient = toTestClient(chain, account) + + console.log("setting bytecode with dynamic calldata from a testnet") + await setByteCodeHardcoded(testClient) + await setByteCodeDynamic(testClient, TEST_CONTRACTS) + + console.log("bytecode deployment complete.") + console.log("") + } } const portOptions = { exclude: [] as number[] }