Skip to content

Commit

Permalink
Merge branch 'main' of github.com:zerodevapp/sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
SahilVasava committed Dec 4, 2024
2 parents 7931d94 + f92058b commit e43060e
Show file tree
Hide file tree
Showing 10 changed files with 802 additions and 74 deletions.
156 changes: 85 additions & 71 deletions packages/test/v0.7/multiChainECDSAValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
signUserOperations
} from "@zerodev/multi-chain-ecdsa-validator"
import { toMultiChainECDSAValidator } from "@zerodev/multi-chain-ecdsa-validator"
import {
type PrepareAndSignUserOperationsParameters,
prepareAndSignUserOperations
} from "@zerodev/multi-chain-ecdsa-validator/actions/prepareAndSignUserOperations.js"
import {
EIP1271Abi,
type KernelAccountClient,
Expand All @@ -24,6 +28,7 @@ import {
http,
type Address,
type Chain,
type Client,
type GetContractReturnType,
type Hex,
type PrivateKeyAccount,
Expand Down Expand Up @@ -94,7 +99,6 @@ const SEPOLIA_ZERODEV_RPC_URL = getBundlerRpc(
const SEPOLIA_ZERODEV_PAYMASTER_RPC_URL = getPaymasterRpc(
config["0.7"][sepolia.id].projectId
)

const OPTIMISM_SEPOLIA_ZERODEV_RPC_URL = getBundlerRpc(
config["0.7"][optimismSepolia.id].projectId
)
Expand Down Expand Up @@ -812,59 +816,62 @@ describe("MultiChainECDSAValidator", () => {
paymaster: opSepoliaZeroDevPaymasterClient
})

const sepoliaUserOp =
await sepoliaZerodevKernelClient.prepareUserOperation({
callData:
await sepoliaZerodevKernelClient.account.encodeCalls([
const clients: Client<Transport, Chain, SmartAccount>[] = [
{
...sepoliaZerodevKernelClient
},
{
...optimismSepoliaZerodevKernelClient
}
]

const userOps = await Promise.all(
clients.map(async (client) => {
return {
callData: await client.account.encodeCalls([
{
to: zeroAddress,
value: BigInt(0),
data: "0x"
}
])
}
})
)

const optimismSepoliaUserOp =
await optimismSepoliaZerodevKernelClient.prepareUserOperation({
callData:
await optimismSepoliaZerodevKernelClient.account.encodeCalls(
[
{
to: zeroAddress,
value: BigInt(0),
data: "0x"
}
]
)
})

const signedUserOps = await signUserOperations(
sepoliaZerodevKernelClient,
const userOpParams: PrepareAndSignUserOperationsParameters[] = [
{
userOperations: [
{ ...sepoliaUserOp, chainId: sepolia.id },
{
...optimismSepoliaUserOp,
chainId: optimismSepolia.id
}
]
...userOps[0],
chainId: sepolia.id
},
{
...userOps[1],
chainId: optimismSepolia.id
}
]

const signedUserOps = await prepareAndSignUserOperations(
clients,
userOpParams
)

const sepoliaUserOp = signedUserOps[0]
const optimismSepoliaUserOp = signedUserOps[1]

const sepoliaUserOpHash =
await sepoliaZerodevKernelClient.sendUserOperation({
...signedUserOps[0]
})
await sepoliaZerodevKernelClient.sendUserOperation(
sepoliaUserOp
)

console.log("sepoliaUserOpHash", sepoliaUserOpHash)
await sepoliaZerodevKernelClient.waitForUserOperationReceipt({
hash: sepoliaUserOpHash
})

const optimismSepoliaUserOpHash =
await optimismSepoliaZerodevKernelClient.sendUserOperation({
...signedUserOps[1]
})
await optimismSepoliaZerodevKernelClient.sendUserOperation(
optimismSepoliaUserOp
)

console.log("optimismSepoliaUserOpHash", optimismSepoliaUserOpHash)
await optimismSepoliaZerodevKernelClient.waitForUserOperationReceipt(
Expand Down Expand Up @@ -963,55 +970,62 @@ describe("MultiChainECDSAValidator", () => {
paymaster: opSepoliaZeroDevPaymasterClient
})

const sepoliaUserOp =
await sepoliaZerodevKernelClient.prepareUserOperation({
callData: await sepoliaKernelAccount.encodeCalls([
{
to: zeroAddress,
value: BigInt(0),
data: "0x"
}
])
})
const clients: Client<Transport, Chain, SmartAccount>[] = [
{
...sepoliaZerodevKernelClient
},
{
...optimismSepoliaZerodevKernelClient
}
]

const optimismSepoliaUserOp =
await optimismSepoliaZerodevKernelClient.prepareUserOperation({
callData: await optimismSepoliaKernelAccount.encodeCalls([
{
to: zeroAddress,
value: BigInt(0),
data: "0x"
}
])
const userOps = await Promise.all(
clients.map(async (client) => {
return {
callData: await client.account.encodeCalls([
{
to: zeroAddress,
value: BigInt(0),
data: "0x"
}
])
}
})
)

const signedEnableUserOps = await ecdsaSignUserOpsWithEnable({
multiChainUserOpConfigsForEnable: [
{
account: sepoliaKernelAccount,
userOp: sepoliaUserOp
},
{
account: optimismSepoliaKernelAccount,
userOp: optimismSepoliaUserOp
}
]
})
const userOpParams: PrepareAndSignUserOperationsParameters[] = [
{
...userOps[0],
chainId: sepolia.id
},
{
...userOps[1],
chainId: optimismSepolia.id
}
]

const signedUserOps = await prepareAndSignUserOperations(
clients,
userOpParams
)

const sepoliaUserOp = signedUserOps[0]
const optimismSepoliaUserOp = signedUserOps[1]

const sepoliaUserOpHash =
await sepoliaZerodevKernelClient.sendUserOperation({
...signedEnableUserOps[0]
})
await sepoliaZerodevKernelClient.sendUserOperation(
sepoliaUserOp
)

console.log("sepoliaUserOpHash", sepoliaUserOpHash)
await sepoliaZerodevKernelClient.waitForUserOperationReceipt({
hash: sepoliaUserOpHash
})

const optimismSepoliaUserOpHash =
await optimismSepoliaZerodevKernelClient.sendUserOperation({
...signedEnableUserOps[1]
})
await optimismSepoliaZerodevKernelClient.sendUserOperation(
optimismSepoliaUserOp
)

console.log("optimismSepoliaUserOpHash", optimismSepoliaUserOpHash)
await optimismSepoliaZerodevKernelClient.waitForUserOperationReceipt(
Expand Down
2 changes: 1 addition & 1 deletion packages/test/v0.7/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Test_ERC20Address = "0x3870419Ba2BBf0127060bCB37f69A1b1C090992B"
const testingChain = allChains.sepolia.id
export const kernelVersion = "0.3.1"
export const index = 11111111111111111n // 432334375434333332434365532464445487823332432423423n
const DEFAULT_PROVIDER = "ALCHEMY"
const DEFAULT_PROVIDER = "PIMLICO"
const projectId = config["0.7"][testingChain].projectId

export const getEntryPoint = (): {
Expand Down
12 changes: 12 additions & 0 deletions plugins/multi-chain-ecdsa/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @zerodev/multi-chain-ecdsa

## 5.4.2

### Minor Changes

- Change `sendUserOpeations` to `prepareAndSignUserOperations`

## 5.4.1

### Minor Changes

- - Add `sendUserOpeations` method

## 5.4.0

### Minor Changes
Expand Down
Loading

0 comments on commit e43060e

Please sign in to comment.