@zerodev/permissions 5.2.1-alpha.1 → 5.2.1-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_cjs/deserializePermissionAccount.js +11 -8
- package/_cjs/deserializePermissionAccount.js.map +1 -1
- package/_cjs/policies/index.js +4 -1
- package/_cjs/policies/index.js.map +1 -1
- package/_cjs/policies/toCallPolicy.js +1 -1
- package/_cjs/policies/toCallPolicy.js.map +1 -1
- package/_cjs/policies/toGasPolicy.js +1 -1
- package/_cjs/policies/toGasPolicy.js.map +1 -1
- package/_cjs/policies/toRateLimitPolicy.js +1 -1
- package/_cjs/policies/toRateLimitPolicy.js.map +1 -1
- package/_cjs/policies/toSignatureCallerPolicy.js +1 -1
- package/_cjs/policies/toSignatureCallerPolicy.js.map +1 -1
- package/_cjs/policies/toSudoPolicy.js +1 -1
- package/_cjs/policies/toSudoPolicy.js.map +1 -1
- package/_cjs/signers/toEmptyECDSASigner.js +30 -0
- package/_cjs/signers/toEmptyECDSASigner.js.map +1 -0
- package/_cjs/signers/toWebAuthnPubKey.js +4 -3
- package/_cjs/signers/toWebAuthnPubKey.js.map +1 -1
- package/_cjs/signers/toWebAuthnSigner.js +2 -2
- package/_cjs/signers/toWebAuthnSigner.js.map +1 -1
- package/_cjs/toPermissionValidator.js +13 -9
- package/_cjs/toPermissionValidator.js.map +1 -1
- package/_esm/deserializePermissionAccount.js +13 -10
- package/_esm/deserializePermissionAccount.js.map +1 -1
- package/_esm/policies/index.js +1 -1
- package/_esm/policies/index.js.map +1 -1
- package/_esm/policies/toCallPolicy.js +1 -1
- package/_esm/policies/toCallPolicy.js.map +1 -1
- package/_esm/policies/toGasPolicy.js +1 -1
- package/_esm/policies/toGasPolicy.js.map +1 -1
- package/_esm/policies/toRateLimitPolicy.js +1 -1
- package/_esm/policies/toRateLimitPolicy.js.map +1 -1
- package/_esm/policies/toSignatureCallerPolicy.js +1 -1
- package/_esm/policies/toSignatureCallerPolicy.js.map +1 -1
- package/_esm/policies/toSudoPolicy.js +1 -1
- package/_esm/policies/toSudoPolicy.js.map +1 -1
- package/_esm/signers/toEmptyECDSASigner.js +27 -0
- package/_esm/signers/toEmptyECDSASigner.js.map +1 -0
- package/_esm/signers/toWebAuthnPubKey.js +2 -1
- package/_esm/signers/toWebAuthnPubKey.js.map +1 -1
- package/_esm/signers/toWebAuthnSigner.js +1 -1
- package/_esm/signers/toWebAuthnSigner.js.map +1 -1
- package/_esm/toPermissionValidator.js +14 -10
- package/_esm/toPermissionValidator.js.map +1 -1
- package/_types/deserializePermissionAccount.d.ts +1 -1
- package/_types/deserializePermissionAccount.d.ts.map +1 -1
- package/_types/policies/index.d.ts +1 -1
- package/_types/policies/index.d.ts.map +1 -1
- package/_types/policies/toCallPolicy.d.ts +1 -1
- package/_types/policies/toCallPolicy.d.ts.map +1 -1
- package/_types/policies/toGasPolicy.d.ts +2 -2
- package/_types/policies/toGasPolicy.d.ts.map +1 -1
- package/_types/policies/toRateLimitPolicy.d.ts +1 -1
- package/_types/policies/toRateLimitPolicy.d.ts.map +1 -1
- package/_types/policies/toSignatureCallerPolicy.d.ts +1 -1
- package/_types/policies/toSignatureCallerPolicy.d.ts.map +1 -1
- package/_types/policies/toSudoPolicy.d.ts +1 -1
- package/_types/policies/toSudoPolicy.d.ts.map +1 -1
- package/_types/signers/toEmptyECDSASigner.d.ts +4 -0
- package/_types/signers/toEmptyECDSASigner.d.ts.map +1 -0
- package/_types/signers/toWebAuthnPubKey.d.ts.map +1 -1
- package/_types/signers/toWebAuthnSigner.d.ts.map +1 -1
- package/_types/toPermissionValidator.d.ts.map +1 -1
- package/_types/types.d.ts +2 -2
- package/_types/types.d.ts.map +1 -1
- package/deserializePermissionAccount.ts +19 -11
- package/package.json +3 -3
- package/policies/index.ts +1 -1
- package/policies/toCallPolicy.ts +2 -2
- package/policies/toGasPolicy.ts +4 -4
- package/policies/toRateLimitPolicy.ts +2 -2
- package/policies/toSignatureCallerPolicy.ts +2 -2
- package/policies/toSudoPolicy.ts +2 -2
- package/signers/toEmptyECDSASigner.ts +34 -0
- package/signers/toWebAuthnPubKey.ts +2 -1
- package/signers/toWebAuthnSigner.ts +2 -1
- package/toPermissionValidator.ts +19 -11
- package/types.ts +2 -2
package/toPermissionValidator.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { KernelV3AccountAbi } from "@zerodev/sdk"
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getAction,
|
|
4
|
+
getEntryPointVersion,
|
|
5
|
+
getUserOperationHash
|
|
6
|
+
} from "permissionless"
|
|
3
7
|
import type { EntryPoint } from "permissionless/types/entrypoint"
|
|
4
8
|
import {
|
|
5
9
|
type Address,
|
|
@@ -38,6 +42,11 @@ export async function toPermissionValidator<
|
|
|
38
42
|
}: PermissionPluginParams
|
|
39
43
|
): Promise<PermissionPlugin<entryPoint>> {
|
|
40
44
|
const chainId = await getChainId(client)
|
|
45
|
+
const entryPointVersion = getEntryPointVersion(entryPointAddress)
|
|
46
|
+
|
|
47
|
+
if (entryPointVersion !== "v0.7") {
|
|
48
|
+
throw new Error("Only EntryPoint 0.7 is supported")
|
|
49
|
+
}
|
|
41
50
|
|
|
42
51
|
const getEnableData = async (
|
|
43
52
|
_kernelAccountAddress?: Address
|
|
@@ -49,13 +58,13 @@ export async function toPermissionValidator<
|
|
|
49
58
|
...policies.map((policy) =>
|
|
50
59
|
concat([
|
|
51
60
|
policy.getPolicyInfoInBytes(),
|
|
52
|
-
policy.getPolicyData(
|
|
61
|
+
policy.getPolicyData()
|
|
53
62
|
])
|
|
54
63
|
),
|
|
55
64
|
concat([
|
|
56
65
|
flag,
|
|
57
66
|
signer.signerContractAddress,
|
|
58
|
-
signer.getSignerData(
|
|
67
|
+
signer.getSignerData()
|
|
59
68
|
])
|
|
60
69
|
]
|
|
61
70
|
]
|
|
@@ -68,7 +77,7 @@ export async function toPermissionValidator<
|
|
|
68
77
|
[{ name: "policyAndSignerData", type: "bytes[]" }],
|
|
69
78
|
[[toPolicyId(policies), flag, toSignerId(signer)]]
|
|
70
79
|
)
|
|
71
|
-
return slice(keccak256(pIdData), 0,
|
|
80
|
+
return slice(keccak256(pIdData), 0, 4)
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
return {
|
|
@@ -77,11 +86,7 @@ export async function toPermissionValidator<
|
|
|
77
86
|
address: zeroAddress,
|
|
78
87
|
source: "PermissionValidator",
|
|
79
88
|
getEnableData,
|
|
80
|
-
getIdentifier:
|
|
81
|
-
pad(getPermissionId(), {
|
|
82
|
-
size: 20,
|
|
83
|
-
dir: "right"
|
|
84
|
-
}),
|
|
89
|
+
getIdentifier: getPermissionId,
|
|
85
90
|
|
|
86
91
|
signMessage: async ({ message }) => {
|
|
87
92
|
return concat([
|
|
@@ -100,7 +105,7 @@ export async function toPermissionValidator<
|
|
|
100
105
|
const userOpHash = getUserOperationHash({
|
|
101
106
|
userOperation: { ...userOperation, signature: "0x" },
|
|
102
107
|
entryPoint: entryPointAddress,
|
|
103
|
-
chainId
|
|
108
|
+
chainId
|
|
104
109
|
})
|
|
105
110
|
|
|
106
111
|
const signature = await signer.account.signMessage({
|
|
@@ -109,7 +114,10 @@ export async function toPermissionValidator<
|
|
|
109
114
|
return concat(["0xff", signature])
|
|
110
115
|
},
|
|
111
116
|
|
|
112
|
-
getNonceKey
|
|
117
|
+
async getNonceKey(_accountAddress?: Address, customNonceKey?: bigint) {
|
|
118
|
+
if (customNonceKey) {
|
|
119
|
+
return customNonceKey
|
|
120
|
+
}
|
|
113
121
|
return 0n
|
|
114
122
|
},
|
|
115
123
|
|
package/types.ts
CHANGED
|
@@ -29,12 +29,12 @@ export type PolicyParams = {
|
|
|
29
29
|
export type ModularSigner = {
|
|
30
30
|
account: LocalAccount
|
|
31
31
|
signerContractAddress: Address
|
|
32
|
-
getSignerData: (
|
|
32
|
+
getSignerData: () => Hex
|
|
33
33
|
getDummySignature: () => Hex
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export type Policy = {
|
|
37
|
-
getPolicyData: (
|
|
37
|
+
getPolicyData: () => Hex
|
|
38
38
|
getPolicyInfoInBytes: () => Hex
|
|
39
39
|
// return params directly to serialize/deserialize Policy
|
|
40
40
|
policyParams:
|