Skip to content

Commit

Permalink
chore: remove base sepolia url from env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Jan 6, 2025
1 parent 8705d5a commit 3105090
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ PAYMASTER_URL=
PIMLICO_API_KEY=
TENDERLY_API_KEY=
TENDERLY_ACCOUNT_SLUG=
TENDERLY_PROJECT_SLUG=
VIRTUAL_BASE_SEPOLIA=
TENDERLY_PROJECT_SLUG=
1 change: 0 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand All @@ -88,7 +90,7 @@ describe("modules.smartSessions.enable.mode.dx", async () => {
})

nexusAccount = await toNexusAccount({
index: 1n,
index,
signer: eoaAccount,
chain,
transport: http()
Expand All @@ -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,
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
40 changes: 23 additions & 17 deletions src/test/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof anvil>
type BundlerInstance = ReturnType<typeof alto>
type BundlerDto = {
Expand Down Expand Up @@ -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}`
Expand All @@ -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[] }
Expand Down

0 comments on commit 3105090

Please sign in to comment.