Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add update config to weighted validator plugin #178

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
6 changes: 6 additions & 0 deletions plugins/weighted-r1-k1/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @zerodev/weighted-validator

## 5.3.0-alpha-4

### Patch Changes

- Added the update-config feature and migrated to the webauthn-key module

## 5.3.0-alpha-3

### Patch Changes
Expand Down
179 changes: 151 additions & 28 deletions plugins/weighted-r1-k1/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,32 @@ export const WeightedValidatorAbi = [
name: "eip712Domain",
inputs: [],
outputs: [
{ name: "fields", type: "bytes1", internalType: "bytes1" },
{
name: "fields",
type: "bytes1",
internalType: "bytes1"
},
{ name: "name", type: "string", internalType: "string" },
{ name: "version", type: "string", internalType: "string" },
{ name: "chainId", type: "uint256", internalType: "uint256" },
{
name: "version",
type: "string",
internalType: "string"
},
{
name: "chainId",
type: "uint256",
internalType: "uint256"
},
{
name: "verifyingContract",
type: "address",
internalType: "address"
},
{ name: "salt", type: "bytes32", internalType: "bytes32" },
{
name: "salt",
type: "bytes32",
internalType: "bytes32"
},
{
name: "extensions",
type: "uint256[]",
Expand All @@ -35,20 +51,40 @@ export const WeightedValidatorAbi = [
type: "uint256",
internalType: "uint256"
},
{ name: "kernel", type: "address", internalType: "address" }
{
name: "kernel",
type: "address",
internalType: "address"
}
],
outputs: [
{ name: "guardianType", type: "bytes1", internalType: "bytes1" },
{ name: "weight", type: "uint24", internalType: "uint24" },
{ name: "encodedPublicKey", type: "bytes", internalType: "bytes" }
{
name: "guardianType",
type: "bytes1",
internalType: "bytes1"
},
{
name: "weight",
type: "uint24",
internalType: "uint24"
},
{
name: "encodedPublicKey",
type: "bytes",
internalType: "bytes"
}
],
stateMutability: "view"
},
{
type: "function",
name: "isInitialized",
inputs: [
{ name: "smartAccount", type: "address", internalType: "address" }
{
name: "smartAccount",
type: "address",
internalType: "address"
}
],
outputs: [{ name: "", type: "bool", internalType: "bool" }],
stateMutability: "view"
Expand All @@ -57,7 +93,11 @@ export const WeightedValidatorAbi = [
type: "function",
name: "isModuleType",
inputs: [
{ name: "moduleTypeId", type: "uint256", internalType: "uint256" }
{
name: "moduleTypeId",
type: "uint256",
internalType: "uint256"
}
],
outputs: [{ name: "", type: "bool", internalType: "bool" }],
stateMutability: "pure"
Expand All @@ -67,8 +107,16 @@ export const WeightedValidatorAbi = [
name: "isValidSignatureWithSender",
inputs: [
{ name: "", type: "address", internalType: "address" },
{ name: "hash", type: "bytes32", internalType: "bytes32" },
{ name: "signature", type: "bytes", internalType: "bytes" }
{
name: "hash",
type: "bytes32",
internalType: "bytes32"
},
{
name: "signature",
type: "bytes",
internalType: "bytes"
}
],
outputs: [{ name: "", type: "bytes4", internalType: "bytes4" }],
stateMutability: "view"
Expand Down Expand Up @@ -96,7 +144,11 @@ export const WeightedValidatorAbi = [
type: "bytes32",
internalType: "bytes32"
},
{ name: "kernel", type: "address", internalType: "address" }
{
name: "kernel",
type: "address",
internalType: "address"
}
],
outputs: [
{
Expand All @@ -109,10 +161,21 @@ export const WeightedValidatorAbi = [
type: "uint48",
internalType: "ValidAfter"
},
{ name: "approvals", type: "uint24", internalType: "uint24" }
{
name: "approvals",
type: "uint24",
internalType: "uint24"
}
],
stateMutability: "view"
},
{
type: "function",
name: "renew",
inputs: [{ name: "_data", type: "bytes", internalType: "bytes" }],
outputs: [],
stateMutability: "nonpayable"
},
{
type: "function",
name: "validateUserOp",
Expand All @@ -127,9 +190,21 @@ export const WeightedValidatorAbi = [
type: "address",
internalType: "address"
},
{ name: "nonce", type: "uint256", internalType: "uint256" },
{ name: "initCode", type: "bytes", internalType: "bytes" },
{ name: "callData", type: "bytes", internalType: "bytes" },
{
name: "nonce",
type: "uint256",
internalType: "uint256"
},
{
name: "initCode",
type: "bytes",
internalType: "bytes"
},
{
name: "callData",
type: "bytes",
internalType: "bytes"
},
{
name: "accountGasLimits",
type: "bytes32",
Expand All @@ -150,10 +225,18 @@ export const WeightedValidatorAbi = [
type: "bytes",
internalType: "bytes"
},
{ name: "signature", type: "bytes", internalType: "bytes" }
{
name: "signature",
type: "bytes",
internalType: "bytes"
}
]
},
{ name: "userOpHash", type: "bytes32", internalType: "bytes32" }
{
name: "userOpHash",
type: "bytes32",
internalType: "bytes32"
}
],
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
stateMutability: "payable"
Expand All @@ -172,22 +255,48 @@ export const WeightedValidatorAbi = [
type: "uint256",
internalType: "uint256"
},
{ name: "kernel", type: "address", internalType: "address" }
{
name: "kernel",
type: "address",
internalType: "address"
}
],
outputs: [
{ name: "status", type: "uint8", internalType: "enum VoteStatus" }
{
name: "status",
type: "uint8",
internalType: "enum VoteStatus"
}
],
stateMutability: "view"
},
{
type: "function",
name: "weightedStorage",
inputs: [{ name: "kernel", type: "address", internalType: "address" }],
inputs: [
{
name: "kernel",
type: "address",
internalType: "address"
}
],
outputs: [
{ name: "totalWeight", type: "uint24", internalType: "uint24" },
{ name: "threshold", type: "uint24", internalType: "uint24" },
{
name: "totalWeight",
type: "uint24",
internalType: "uint24"
},
{
name: "threshold",
type: "uint24",
internalType: "uint24"
},
{ name: "delay", type: "uint48", internalType: "uint48" },
{ name: "guardianLength", type: "uint32", internalType: "uint32" }
{
name: "guardianLength",
type: "uint32",
internalType: "uint32"
}
],
stateMutability: "view"
},
Expand Down Expand Up @@ -319,7 +428,11 @@ export const WeightedValidatorAbi = [
type: "error",
name: "AlreadyInitialized",
inputs: [
{ name: "smartAccount", type: "address", internalType: "address" }
{
name: "smartAccount",
type: "address",
internalType: "address"
}
]
},
{
Expand All @@ -330,13 +443,23 @@ export const WeightedValidatorAbi = [
{
type: "error",
name: "InvalidTargetAddress",
inputs: [{ name: "target", type: "address", internalType: "address" }]
inputs: [
{
name: "target",
type: "address",
internalType: "address"
}
]
},
{
type: "error",
name: "NotInitialized",
inputs: [
{ name: "smartAccount", type: "address", internalType: "address" }
{
name: "smartAccount",
type: "address",
internalType: "address"
}
]
},
{ type: "error", name: "NotSupportedSignatureType", inputs: [] },
Expand Down
2 changes: 1 addition & 1 deletion plugins/weighted-r1-k1/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getRecoveryAction = (entryPoint: EntryPoint): Action => {
}

export const WEIGHTED_VALIDATOR_ADDRESS_V07 =
"0x70815ACa0463140de5F50A7c8dd0B4f45395BC41"
"0x2E29537bBaf8AB5dC8037Fa4Bc3DEB2c289498A3"

export enum SIGNER_TYPE {
ECDSA = "0x01",
Expand Down
9 changes: 4 additions & 5 deletions plugins/weighted-r1-k1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import {
type ECDSASignerParams,
toECDSASigner
} from "./signers/toECDSASigner.js"
import { WebAuthnMode, toWebAuthnPubKey } from "./signers/toWebAuthnPubKey.js"
import {
type WebAuthnKey,
type WebAuthnModularSignerParams,
toWebAuthnSigner
} from "./signers/toWebAuthnSigner.js"
import {
type WeightedSigner,
type WeightedValidatorConfig,
createWeightedValidator,
getCurrentSigners,
getUpdateConfigCall,
getValidatorAddress
} from "./toWeightedValidatorPlugin.js"

Expand All @@ -37,12 +37,11 @@ export {
type WeightedValidatorConfig,
type WeightedSigner,
getValidatorAddress,
getUpdateConfigCall,
getCurrentSigners,
type KernelValidator,
toECDSASigner,
type ECDSASignerParams,
toWebAuthnPubKey,
type WebAuthnKey,
WebAuthnMode,
type WebAuthnModularSignerParams,
toWebAuthnSigner,
type ApproveUserOperationParameters,
Expand Down
3 changes: 2 additions & 1 deletion plugins/weighted-r1-k1/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zerodev/weighted-validator",
"version": "5.3.0-alpha-3",
"version": "5.3.0-alpha-4",
"author": "ZeroDev",
"main": "./_cjs/index.js",
"module": "./_esm/index.js",
Expand Down Expand Up @@ -41,6 +41,7 @@
"peerDependencies": {
"viem": "^2.16.3",
"@zerodev/sdk": "^5.2.1",
"@zerodev/webauthn-key": "^5.3.0",
"permissionless": "^0.1.18"
}
}
Loading