-
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.
feat: add initial skeleton for 6900 account support
- Loading branch information
Showing
8 changed files
with
477 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
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
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,74 @@ | ||
export const IStandardExecutorAbi = [ | ||
{ | ||
inputs: [ | ||
{ | ||
components: [ | ||
{ | ||
internalType: "address", | ||
name: "target", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "value", | ||
type: "uint256", | ||
}, | ||
{ | ||
internalType: "bytes", | ||
name: "data", | ||
type: "bytes", | ||
}, | ||
], | ||
internalType: "struct Execution", | ||
name: "execution", | ||
type: "tuple", | ||
}, | ||
], | ||
name: "execute", | ||
outputs: [ | ||
{ | ||
internalType: "bytes", | ||
name: "", | ||
type: "bytes", | ||
}, | ||
], | ||
stateMutability: "payable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
components: [ | ||
{ | ||
internalType: "address", | ||
name: "target", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "value", | ||
type: "uint256", | ||
}, | ||
{ | ||
internalType: "bytes", | ||
name: "data", | ||
type: "bytes", | ||
}, | ||
], | ||
internalType: "struct Execution[]", | ||
name: "executions", | ||
type: "tuple[]", | ||
}, | ||
], | ||
name: "executeBatch", | ||
outputs: [ | ||
{ | ||
internalType: "bytes[]", | ||
name: "", | ||
type: "bytes[]", | ||
}, | ||
], | ||
stateMutability: "payable", | ||
type: "function", | ||
}, | ||
] as const; |
237 changes: 237 additions & 0 deletions
237
packages/accounts/src/msca/abis/MultiOwnerMSCAFactory.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,237 @@ | ||
export const MultiOwnerMSCAFactoryAbi = [ | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "address", | ||
name: "owner", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "address", | ||
name: "multiOwnerPlugin", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "address", | ||
name: "implementation", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "bytes32", | ||
name: "manifestHash", | ||
type: "bytes32", | ||
}, | ||
{ | ||
internalType: "contract IEntryPoint", | ||
name: "entryPoint", | ||
type: "address", | ||
}, | ||
], | ||
stateMutability: "nonpayable", | ||
type: "constructor", | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ | ||
indexed: true, | ||
internalType: "address", | ||
name: "previousOwner", | ||
type: "address", | ||
}, | ||
{ | ||
indexed: true, | ||
internalType: "address", | ||
name: "newOwner", | ||
type: "address", | ||
}, | ||
], | ||
name: "OwnershipTransferred", | ||
type: "event", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "ENTRYPOINT", | ||
outputs: [ | ||
{ | ||
internalType: "contract IEntryPoint", | ||
name: "", | ||
type: "address", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "IMPL", | ||
outputs: [ | ||
{ | ||
internalType: "address", | ||
name: "", | ||
type: "address", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "MULTI_OWNER_PLUGIN", | ||
outputs: [ | ||
{ | ||
internalType: "address", | ||
name: "", | ||
type: "address", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "uint32", | ||
name: "unstakeDelay", | ||
type: "uint32", | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "amount", | ||
type: "uint256", | ||
}, | ||
], | ||
name: "addStake", | ||
outputs: [], | ||
stateMutability: "payable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "uint256", | ||
name: "salt", | ||
type: "uint256", | ||
}, | ||
{ | ||
internalType: "address[]", | ||
name: "owners", | ||
type: "address[]", | ||
}, | ||
], | ||
name: "createAccount", | ||
outputs: [ | ||
{ | ||
internalType: "address", | ||
name: "addr", | ||
type: "address", | ||
}, | ||
], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "uint256", | ||
name: "salt", | ||
type: "uint256", | ||
}, | ||
{ | ||
internalType: "address[]", | ||
name: "owners", | ||
type: "address[]", | ||
}, | ||
], | ||
name: "getAddress", | ||
outputs: [ | ||
{ | ||
internalType: "address", | ||
name: "", | ||
type: "address", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "owner", | ||
outputs: [ | ||
{ | ||
internalType: "address", | ||
name: "", | ||
type: "address", | ||
}, | ||
], | ||
stateMutability: "view", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "renounceOwnership", | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "address", | ||
name: "newOwner", | ||
type: "address", | ||
}, | ||
], | ||
name: "transferOwnership", | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [], | ||
name: "unlockStake", | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "address payable", | ||
name: "to", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "address", | ||
name: "token", | ||
type: "address", | ||
}, | ||
{ | ||
internalType: "uint256", | ||
name: "amount", | ||
type: "uint256", | ||
}, | ||
], | ||
name: "withdraw", | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: "address payable", | ||
name: "to", | ||
type: "address", | ||
}, | ||
], | ||
name: "withdrawStake", | ||
outputs: [], | ||
stateMutability: "nonpayable", | ||
type: "function", | ||
}, | ||
{ | ||
stateMutability: "payable", | ||
type: "receive", | ||
}, | ||
] as const; |
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,59 @@ | ||
import { | ||
BaseSmartContractAccount, | ||
SignerSchema, | ||
createBaseSmartAccountParamsSchema, | ||
type BatchUserOperationCallData, | ||
type SupportedTransports, | ||
} from "@alchemy/aa-core"; | ||
import { | ||
encodeFunctionData, | ||
type Address, | ||
type FallbackTransport, | ||
type Hex, | ||
type Transport, | ||
} from "viem"; | ||
import { z } from "zod"; | ||
import { IStandardExecutorAbi } from "./abis/IStandardExecutor.js"; | ||
|
||
export const createModularSmartContractAccountSchema = < | ||
TTransport extends SupportedTransports = Transport | ||
>() => | ||
createBaseSmartAccountParamsSchema<TTransport>().extend({ | ||
owner: SignerSchema, | ||
}); | ||
|
||
export type ModularSmartContractAccountParams = z.input< | ||
ReturnType<typeof createModularSmartContractAccountSchema> | ||
>; | ||
|
||
export abstract class BaseModularSmartContractAccount< | ||
TTransport extends Transport | FallbackTransport = Transport | ||
> extends BaseSmartContractAccount<TTransport> { | ||
async encodeExecute(target: Address, value: bigint, data: Hex): Promise<Hex> { | ||
return encodeFunctionData({ | ||
abi: IStandardExecutorAbi, | ||
functionName: "execute", | ||
args: [ | ||
{ | ||
target, | ||
data, | ||
value, | ||
}, | ||
], | ||
}); | ||
} | ||
|
||
async encodeBatchExecute(txs: BatchUserOperationCallData): Promise<Hex> { | ||
return encodeFunctionData({ | ||
abi: IStandardExecutorAbi, | ||
functionName: "executeBatch", | ||
args: [ | ||
txs.map((tx) => ({ | ||
target: tx.target, | ||
data: tx.data, | ||
value: tx.value ?? 0n, | ||
})), | ||
], | ||
}); | ||
} | ||
} |
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,2 @@ | ||
export { MultiOwnerPlugin } from "./plugin.js"; | ||
export { MultiOwnerPluginSigner } from "./signer.js"; |
Oops, something went wrong.