Skip to content

Commit

Permalink
@zerodev/wallet v0.0.9 (#143)
Browse files Browse the repository at this point in the history
* support v2

* fix: block permission with kernel v2

* bump package version

---------

Co-authored-by: jstinhw <[email protected]>
  • Loading branch information
blakecduncan and jstinhw authored Jun 3, 2024
1 parent a56a95c commit 039b998
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
6 changes: 6 additions & 0 deletions wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @zerodev/wallet

## 0.0.9

### Patch Changes

- Add support for entrypoint v0.6 to KernelEIP1193Provider

## 0.0.8

### Patch Changes
Expand Down
37 changes: 27 additions & 10 deletions wallet/KernelEIP1193Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createZeroDevPaymasterClient } from "@zerodev/sdk/clients"
import {
type BundlerClient,
ENTRYPOINT_ADDRESS_V06,
ENTRYPOINT_ADDRESS_V07,
type EstimateUserOperationGasReturnType,
bundlerActions
} from "permissionless"
Expand Down Expand Up @@ -81,6 +82,22 @@ export class KernelEIP1193Provider<
KernelSmartAccount<entryPoint>
>

const permissions =
kernelClient.account.entryPoint === ENTRYPOINT_ADDRESS_V07
? {
supported: true,
permissionTypes: [
"sudo",
"contract-call",
"rate-limit",
"gas-limit",
"signature"
]
}
: {
supported: false
}

const capabilities = {
[kernelClient.account.address]: {
[toHex(kernelClient.chain.id)]: {
Expand All @@ -90,16 +107,7 @@ export class KernelEIP1193Provider<
paymasterService: {
supported: true
},
permissions: {
supported: true,
permissionTypes: [
"sudo",
"contract-call",
"rate-limit",
"gas-limit",
"signature"
]
}
permissions
}
}
}
Expand Down Expand Up @@ -260,6 +268,12 @@ export class KernelEIP1193Provider<
if (Number(chainId) !== accountChainId) {
throw new Error("invalid chain id")
}
if (
this.kernelClient.account.entryPoint !== ENTRYPOINT_ADDRESS_V07 &&
capabilities?.permissions
) {
throw new Error("Permissions not supported with kernel v2")
}

let kernelAccountClient: KernelAccountClient<
entryPoint,
Expand Down Expand Up @@ -378,6 +392,9 @@ export class KernelEIP1193Provider<
private async handleWalletIssuePermissions(
params: [IssuePermissionsParams]
) {
if (this.kernelClient.account.entryPoint !== ENTRYPOINT_ADDRESS_V07) {
throw new Error("Permissions not supported with kernel v2")
}
const capabilities =
this.handleWalletCapabilities()[toHex(this.kernelClient.chain.id)]
.permissions.permissionTypes
Expand Down
2 changes: 1 addition & 1 deletion wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zerodev/wallet",
"version": "0.0.8",
"version": "0.0.9",
"author": "ZeroDev",
"main": "./_cjs/index.js",
"module": "./_esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion wallet/types/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ export type SessionType = {
}
}

export type ZeroDevVersion = "v3"
export type ZeroDevVersion = "v2" | "v3"

0 comments on commit 039b998

Please sign in to comment.