-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Pull Request Checklist - [ ] Did you add new tests and confirm existing tests pass? (`yarn test`) - [ ] Did you update relevant docs? (docs are found in the `site` folder, and guidelines for updating/adding docs can be found in the [contribution guide](https://github.com/alchemyplatform/aa-sdk/blob/main/CONTRIBUTING.md)) - [ ] Do your commits follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [ ] Does your PR title also follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard? - [ ] If you have a breaking change, is it [correctly reflected in your commit message](https://www.conventionalcommits.org/en/v1.0.0/#examples)? (e.g. `feat!: breaking change`) - [ ] Did you run lint (`yarn lint:check`) and fix any issues? (`yarn lint:write`) - [ ] Did you follow the [contribution guidelines](https://github.com/alchemyplatform/aa-sdk/blob/main/CONTRIBUTING.md)? <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces a `SingleSignerValidationModule` for managing single signer validation in the `ma-v2` smart contract system. It includes functions for packing signatures and encoding install/uninstall data, along with the necessary ABI definitions. ### Detailed summary - Added `PackSignatureParams` type and `packSignature` utility in `utils.ts`. - Implemented `SingleSignerValidationModule` with methods for encoding install/uninstall data in `single-signer-validation/module.ts`. - Enhanced `singleSignerMessageSigner` functionality for signing operations in `single-signer-validation/signer.ts`. - Defined the ABI for `SingleSignerValidation` in `single-signer-validation/abis/singleSignerValidation.ts`. - Created `MAV2FactoryAbi` and `smaV2Abi` with comprehensive function definitions and events in their respective files. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
Showing
9 changed files
with
2,393 additions
and
0 deletions.
There are no files selected for viewing
638 changes: 638 additions & 0 deletions
638
account-kit/smart-contracts/src/ma-v2/abis/maV2Factory.ts
Large diffs are not rendered by default.
Oops, something went wrong.
1,288 changes: 1,288 additions & 0 deletions
1,288
account-kit/smart-contracts/src/ma-v2/abis/smaV2.ts
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
330 changes: 330 additions & 0 deletions
330
...smart-contracts/src/ma-v2/modules/single-signer-validation/abis/singleSignerValidation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,330 @@ | ||
export const singleSignerValidationAbi = [ | ||
{ | ||
type: "function", | ||
name: "moduleId", | ||
inputs: [], | ||
outputs: [ | ||
{ | ||
name: "", | ||
type: "string", | ||
internalType: "string", | ||
}, | ||
], | ||
stateMutability: "pure", | ||
}, | ||
{ | ||
type: "function", | ||
name: "onInstall", | ||
inputs: [ | ||
{ | ||
name: "data", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
], | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
}, | ||
{ | ||
type: "function", | ||
name: "onUninstall", | ||
inputs: [ | ||
{ | ||
name: "data", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
], | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
}, | ||
{ | ||
type: "function", | ||
name: "replaySafeHash", | ||
inputs: [ | ||
{ | ||
name: "account", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
{ | ||
name: "hash", | ||
type: "bytes32", | ||
internalType: "bytes32", | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
name: "", | ||
type: "bytes32", | ||
internalType: "bytes32", | ||
}, | ||
], | ||
stateMutability: "view", | ||
}, | ||
{ | ||
type: "function", | ||
name: "signers", | ||
inputs: [ | ||
{ | ||
name: "entityId", | ||
type: "uint32", | ||
internalType: "uint32", | ||
}, | ||
{ | ||
name: "account", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
name: "", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
], | ||
stateMutability: "view", | ||
}, | ||
{ | ||
type: "function", | ||
name: "supportsInterface", | ||
inputs: [ | ||
{ | ||
name: "interfaceId", | ||
type: "bytes4", | ||
internalType: "bytes4", | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
name: "", | ||
type: "bool", | ||
internalType: "bool", | ||
}, | ||
], | ||
stateMutability: "view", | ||
}, | ||
{ | ||
type: "function", | ||
name: "transferSigner", | ||
inputs: [ | ||
{ | ||
name: "entityId", | ||
type: "uint32", | ||
internalType: "uint32", | ||
}, | ||
{ | ||
name: "newSigner", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
], | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
}, | ||
{ | ||
type: "function", | ||
name: "validateRuntime", | ||
inputs: [ | ||
{ | ||
name: "account", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
{ | ||
name: "entityId", | ||
type: "uint32", | ||
internalType: "uint32", | ||
}, | ||
{ | ||
name: "sender", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
{ | ||
name: "", | ||
type: "uint256", | ||
internalType: "uint256", | ||
}, | ||
{ | ||
name: "", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
{ | ||
name: "", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
], | ||
outputs: [], | ||
stateMutability: "view", | ||
}, | ||
{ | ||
type: "function", | ||
name: "validateSignature", | ||
inputs: [ | ||
{ | ||
name: "account", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
{ | ||
name: "entityId", | ||
type: "uint32", | ||
internalType: "uint32", | ||
}, | ||
{ | ||
name: "", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
{ | ||
name: "digest", | ||
type: "bytes32", | ||
internalType: "bytes32", | ||
}, | ||
{ | ||
name: "signature", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
name: "", | ||
type: "bytes4", | ||
internalType: "bytes4", | ||
}, | ||
], | ||
stateMutability: "view", | ||
}, | ||
{ | ||
type: "function", | ||
name: "validateUserOp", | ||
inputs: [ | ||
{ | ||
name: "entityId", | ||
type: "uint32", | ||
internalType: "uint32", | ||
}, | ||
{ | ||
name: "userOp", | ||
type: "tuple", | ||
internalType: "struct PackedUserOperation", | ||
components: [ | ||
{ | ||
name: "sender", | ||
type: "address", | ||
internalType: "address", | ||
}, | ||
{ | ||
name: "nonce", | ||
type: "uint256", | ||
internalType: "uint256", | ||
}, | ||
{ | ||
name: "initCode", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
{ | ||
name: "callData", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
{ | ||
name: "accountGasLimits", | ||
type: "bytes32", | ||
internalType: "bytes32", | ||
}, | ||
{ | ||
name: "preVerificationGas", | ||
type: "uint256", | ||
internalType: "uint256", | ||
}, | ||
{ | ||
name: "gasFees", | ||
type: "bytes32", | ||
internalType: "bytes32", | ||
}, | ||
{ | ||
name: "paymasterAndData", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
{ | ||
name: "signature", | ||
type: "bytes", | ||
internalType: "bytes", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "userOpHash", | ||
type: "bytes32", | ||
internalType: "bytes32", | ||
}, | ||
], | ||
outputs: [ | ||
{ | ||
name: "", | ||
type: "uint256", | ||
internalType: "uint256", | ||
}, | ||
], | ||
stateMutability: "view", | ||
}, | ||
{ | ||
type: "event", | ||
name: "SignerTransferred", | ||
inputs: [ | ||
{ | ||
name: "account", | ||
type: "address", | ||
indexed: true, | ||
internalType: "address", | ||
}, | ||
{ | ||
name: "entityId", | ||
type: "uint32", | ||
indexed: true, | ||
internalType: "uint32", | ||
}, | ||
{ | ||
name: "newSigner", | ||
type: "address", | ||
indexed: true, | ||
internalType: "address", | ||
}, | ||
{ | ||
name: "previousSigner", | ||
type: "address", | ||
indexed: false, | ||
internalType: "address", | ||
}, | ||
], | ||
anonymous: true, | ||
}, | ||
{ | ||
type: "error", | ||
name: "InvalidSignatureType", | ||
inputs: [], | ||
}, | ||
{ | ||
type: "error", | ||
name: "NotAuthorized", | ||
inputs: [], | ||
}, | ||
{ | ||
type: "error", | ||
name: "NotImplemented", | ||
inputs: [], | ||
}, | ||
{ | ||
type: "error", | ||
name: "UnexpectedDataPassed", | ||
inputs: [], | ||
}, | ||
]; |
49 changes: 49 additions & 0 deletions
49
account-kit/smart-contracts/src/ma-v2/modules/single-signer-validation/module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { encodeAbiParameters, type Address, type Hex } from "viem"; | ||
|
||
import { singleSignerValidationAbi } from "./abis/singleSignerValidation.js"; | ||
|
||
const addresses = { | ||
default: "0xEa3a0b544d517f6Ed3Dc2186C74D869c702C376e", | ||
} as Record<number | "default", Address>; | ||
|
||
const meta = { | ||
name: "SingleSignerValidation", | ||
version: "alpha.1", | ||
addresses, | ||
}; | ||
|
||
// Todo: some unified type for ERC-6900 v0.8 modules. I couldn't figure out how to parameterize the class itself over the abi type parameters for onInstall and onUninstall. | ||
export const SingleSignerValidationModule = { | ||
meta, | ||
abi: singleSignerValidationAbi, | ||
encodeOnInstallData: (args: { entityId: number; signer: Address }): Hex => { | ||
const { entityId, signer } = args; | ||
|
||
return encodeAbiParameters( | ||
[ | ||
{ | ||
type: "uint32", | ||
value: entityId, | ||
}, | ||
{ | ||
type: "address", | ||
value: signer, | ||
}, | ||
], | ||
[entityId, signer] | ||
); | ||
}, | ||
encodeOnUninstallData: (args: { entityId: number }): Hex => { | ||
const { entityId } = args; | ||
|
||
return encodeAbiParameters( | ||
[ | ||
{ | ||
type: "uint32", | ||
value: entityId, | ||
}, | ||
], | ||
[entityId] | ||
); | ||
}, | ||
}; |
Oops, something went wrong.