@alchemy/aa-accounts
Advanced tools
Comparing version 0.1.0-alpha.14 to 0.1.0-alpha.15
@@ -5,4 +5,5 @@ export { KernelFactoryAbi } from "./kernel-zerodev/abis/KernelFactoryAbi"; | ||
export type { KernelBaseValidatorParams } from "./kernel-zerodev/validator/base"; | ||
export type { KernelBatchUserOperationCallData, KernelUserOperationCallData, } from "./kernel-zerodev/types"; | ||
export type { KernelSmartAccountParams } from "./kernel-zerodev/account"; | ||
export { KernelSmartContractAccount } from "./kernel-zerodev/account"; | ||
export { KernelAccountProvider } from "./kernel-zerodev/provider"; |
@@ -5,2 +5,3 @@ import type { Address } from "abitype"; | ||
import { type BaseSmartAccountParams, BaseSmartContractAccount, type SmartAccountSigner } from "@alchemy/aa-core"; | ||
import type { BatchUserOperationCallData } from "@alchemy/aa-core/src"; | ||
export interface KernelSmartAccountParams<TTransport extends Transport | FallbackTransport = Transport> extends BaseSmartAccountParams<TTransport> { | ||
@@ -23,2 +24,3 @@ owner: SmartAccountSigner; | ||
encodeExecuteDelegate(target: Hex, value: bigint, data: Hex): Promise<Hex>; | ||
encodeBatchExecute(_txs: BatchUserOperationCallData): Promise<`0x${string}`>; | ||
signWithEip6492(msg: string | Uint8Array): Promise<Hex>; | ||
@@ -25,0 +27,0 @@ signMessage(msg: Uint8Array | string): Promise<Hex>; |
@@ -10,2 +10,4 @@ "use strict"; | ||
const aa_core_1 = require("@alchemy/aa-core"); | ||
const MultiSendAbi_1 = require("./abis/MultiSendAbi"); | ||
const utils_1 = require("./utils"); | ||
class KernelSmartContractAccount extends aa_core_1.BaseSmartContractAccount { | ||
@@ -51,3 +53,3 @@ constructor(params) { | ||
getDummySignature() { | ||
return "0x4046ab7d9c387d7a5ef5ca0777eded29767fd9863048946d35b3042d2f7458ff7c62ade2903503e15973a63a296313eab15b964a18d79f4b06c8c01c7028143c1c"; | ||
return "0x00000000b650d28e51cf39d5c0bb7db6d81cce5f0a77baba8bf8de587c0bc83fa70e374f3bfef2afb697dc5627c669de7dc13e96c85697e0f6aae2f2ebe227552d00cb181c"; | ||
} | ||
@@ -65,2 +67,10 @@ async encodeExecute(target, value, data) { | ||
} | ||
async encodeBatchExecute(_txs) { | ||
const multiSendData = (0, viem_1.concatHex)(_txs.map((tx) => (0, utils_1.encodeCall)(tx))); | ||
return (0, viem_1.encodeFunctionData)({ | ||
abi: MultiSendAbi_1.MultiSendAbi, | ||
functionName: "multiSend", | ||
args: [multiSendData], | ||
}); | ||
} | ||
async signWithEip6492(msg) { | ||
@@ -67,0 +77,0 @@ try { |
@@ -1,9 +0,5 @@ | ||
import type { HttpTransport } from "viem"; | ||
import { type AccountMiddlewareFn, SmartAccountProvider } from "@alchemy/aa-core"; | ||
import type { Hash, HttpTransport } from "viem"; | ||
import { SmartAccountProvider } from "@alchemy/aa-core"; | ||
export declare class KernelAccountProvider extends SmartAccountProvider<HttpTransport> { | ||
gasEstimator: AccountMiddlewareFn; | ||
request: (args: { | ||
method: string; | ||
params?: any[]; | ||
}) => Promise<any>; | ||
signMessage: (msg: string | Uint8Array) => Promise<Hash>; | ||
} |
@@ -8,36 +8,11 @@ "use strict"; | ||
super(...arguments); | ||
Object.defineProperty(this, "gasEstimator", { | ||
Object.defineProperty(this, "signMessage", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async (struct) => { | ||
const request = (0, aa_core_1.deepHexlify)(await (0, aa_core_1.resolveProperties)(struct)); | ||
const estimates = await this.rpcClient.estimateUserOperationGas(request, this.entryPointAddress); | ||
estimates.verificationGasLimit = | ||
(BigInt(estimates.verificationGasLimit) * 130n) / 100n; | ||
return { | ||
...struct, | ||
...estimates, | ||
}; | ||
} | ||
}); | ||
Object.defineProperty(this, "request", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async (args) => { | ||
const { method, params } = args; | ||
if (method === "personal_sign") { | ||
if (!this.account) { | ||
throw new Error("account not connected!"); | ||
} | ||
const [data, address] = params; | ||
if (address !== (await this.getAddress())) { | ||
throw new Error("cannot sign for address that is not the current account"); | ||
} | ||
return this.account.signWithEip6492(data); | ||
value: async (msg) => { | ||
if (!this.account) { | ||
throw new Error("account not connected!"); | ||
} | ||
else { | ||
return super.request(args); | ||
} | ||
return this.account.signWithEip6492(msg); | ||
} | ||
@@ -44,0 +19,0 @@ }); |
@@ -5,4 +5,5 @@ export { KernelFactoryAbi } from "./kernel-zerodev/abis/KernelFactoryAbi"; | ||
export type { KernelBaseValidatorParams } from "./kernel-zerodev/validator/base"; | ||
export type { KernelBatchUserOperationCallData, KernelUserOperationCallData, } from "./kernel-zerodev/types"; | ||
export type { KernelSmartAccountParams } from "./kernel-zerodev/account"; | ||
export { KernelSmartContractAccount } from "./kernel-zerodev/account"; | ||
export { KernelAccountProvider } from "./kernel-zerodev/provider"; |
@@ -5,2 +5,3 @@ import type { Address } from "abitype"; | ||
import { type BaseSmartAccountParams, BaseSmartContractAccount, type SmartAccountSigner } from "@alchemy/aa-core"; | ||
import type { BatchUserOperationCallData } from "@alchemy/aa-core/src"; | ||
export interface KernelSmartAccountParams<TTransport extends Transport | FallbackTransport = Transport> extends BaseSmartAccountParams<TTransport> { | ||
@@ -23,2 +24,3 @@ owner: SmartAccountSigner; | ||
encodeExecuteDelegate(target: Hex, value: bigint, data: Hex): Promise<Hex>; | ||
encodeBatchExecute(_txs: BatchUserOperationCallData): Promise<`0x${string}`>; | ||
signWithEip6492(msg: string | Uint8Array): Promise<Hex>; | ||
@@ -25,0 +27,0 @@ signMessage(msg: Uint8Array | string): Promise<Hex>; |
@@ -7,2 +7,4 @@ import { concatHex, encodeAbiParameters, encodeFunctionData, hashMessage, toBytes, } from "viem"; | ||
import { BaseSmartContractAccount, } from "@alchemy/aa-core"; | ||
import { MultiSendAbi } from "./abis/MultiSendAbi"; | ||
import { encodeCall } from "./utils"; | ||
export class KernelSmartContractAccount extends BaseSmartContractAccount { | ||
@@ -48,3 +50,3 @@ constructor(params) { | ||
getDummySignature() { | ||
return "0x4046ab7d9c387d7a5ef5ca0777eded29767fd9863048946d35b3042d2f7458ff7c62ade2903503e15973a63a296313eab15b964a18d79f4b06c8c01c7028143c1c"; | ||
return "0x00000000b650d28e51cf39d5c0bb7db6d81cce5f0a77baba8bf8de587c0bc83fa70e374f3bfef2afb697dc5627c669de7dc13e96c85697e0f6aae2f2ebe227552d00cb181c"; | ||
} | ||
@@ -62,2 +64,10 @@ async encodeExecute(target, value, data) { | ||
} | ||
async encodeBatchExecute(_txs) { | ||
const multiSendData = concatHex(_txs.map((tx) => encodeCall(tx))); | ||
return encodeFunctionData({ | ||
abi: MultiSendAbi, | ||
functionName: "multiSend", | ||
args: [multiSendData], | ||
}); | ||
} | ||
async signWithEip6492(msg) { | ||
@@ -64,0 +74,0 @@ try { |
@@ -1,9 +0,5 @@ | ||
import type { HttpTransport } from "viem"; | ||
import { type AccountMiddlewareFn, SmartAccountProvider } from "@alchemy/aa-core"; | ||
import type { Hash, HttpTransport } from "viem"; | ||
import { SmartAccountProvider } from "@alchemy/aa-core"; | ||
export declare class KernelAccountProvider extends SmartAccountProvider<HttpTransport> { | ||
gasEstimator: AccountMiddlewareFn; | ||
request: (args: { | ||
method: string; | ||
params?: any[]; | ||
}) => Promise<any>; | ||
signMessage: (msg: string | Uint8Array) => Promise<Hash>; | ||
} |
@@ -1,39 +0,15 @@ | ||
import { deepHexlify, resolveProperties, SmartAccountProvider, } from "@alchemy/aa-core"; | ||
import { SmartAccountProvider } from "@alchemy/aa-core"; | ||
import { KernelSmartContractAccount } from "./account"; | ||
export class KernelAccountProvider extends SmartAccountProvider { | ||
constructor() { | ||
super(...arguments); | ||
Object.defineProperty(this, "gasEstimator", { | ||
Object.defineProperty(this, "signMessage", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async (struct) => { | ||
const request = deepHexlify(await resolveProperties(struct)); | ||
const estimates = await this.rpcClient.estimateUserOperationGas(request, this.entryPointAddress); | ||
estimates.verificationGasLimit = | ||
(BigInt(estimates.verificationGasLimit) * 130n) / 100n; | ||
return { | ||
...struct, | ||
...estimates, | ||
}; | ||
} | ||
}); | ||
Object.defineProperty(this, "request", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async (args) => { | ||
const { method, params } = args; | ||
if (method === "personal_sign") { | ||
if (!this.account) { | ||
throw new Error("account not connected!"); | ||
} | ||
const [data, address] = params; | ||
if (address !== (await this.getAddress())) { | ||
throw new Error("cannot sign for address that is not the current account"); | ||
} | ||
return this.account.signWithEip6492(data); | ||
value: async (msg) => { | ||
if (!this.account) { | ||
throw new Error("account not connected!"); | ||
} | ||
else { | ||
return super.request(args); | ||
} | ||
return this.account.signWithEip6492(msg); | ||
} | ||
@@ -40,0 +16,0 @@ }); |
@@ -5,2 +5,3 @@ export { KernelFactoryAbi } from "./kernel-zerodev/abis/KernelFactoryAbi"; | ||
export type { KernelBaseValidatorParams } from "./kernel-zerodev/validator/base"; | ||
export type { KernelBatchUserOperationCallData, KernelUserOperationCallData, } from "./kernel-zerodev/types"; | ||
export type { KernelSmartAccountParams } from "./kernel-zerodev/account"; | ||
@@ -7,0 +8,0 @@ export { KernelSmartContractAccount } from "./kernel-zerodev/account"; |
@@ -5,2 +5,3 @@ import type { Address } from "abitype"; | ||
import { type BaseSmartAccountParams, BaseSmartContractAccount, type SmartAccountSigner } from "@alchemy/aa-core"; | ||
import type { BatchUserOperationCallData } from "@alchemy/aa-core/src"; | ||
export interface KernelSmartAccountParams<TTransport extends Transport | FallbackTransport = Transport> extends BaseSmartAccountParams<TTransport> { | ||
@@ -23,2 +24,3 @@ owner: SmartAccountSigner; | ||
encodeExecuteDelegate(target: Hex, value: bigint, data: Hex): Promise<Hex>; | ||
encodeBatchExecute(_txs: BatchUserOperationCallData): Promise<`0x${string}`>; | ||
signWithEip6492(msg: string | Uint8Array): Promise<Hex>; | ||
@@ -25,0 +27,0 @@ signMessage(msg: Uint8Array | string): Promise<Hex>; |
@@ -1,10 +0,6 @@ | ||
import type { HttpTransport } from "viem"; | ||
import { type AccountMiddlewareFn, SmartAccountProvider } from "@alchemy/aa-core"; | ||
import type { Hash, HttpTransport } from "viem"; | ||
import { SmartAccountProvider } from "@alchemy/aa-core"; | ||
export declare class KernelAccountProvider extends SmartAccountProvider<HttpTransport> { | ||
gasEstimator: AccountMiddlewareFn; | ||
request: (args: { | ||
method: string; | ||
params?: any[]; | ||
}) => Promise<any>; | ||
signMessage: (msg: string | Uint8Array) => Promise<Hash>; | ||
} | ||
//# sourceMappingURL=provider.d.ts.map |
{ | ||
"name": "@alchemy/aa-accounts", | ||
"version": "0.1.0-alpha.14", | ||
"version": "0.1.0-alpha.15", | ||
"description": "A collection of ERC-4337 compliant smart contract account interfaces", | ||
@@ -41,3 +41,3 @@ "author": "Alchemy", | ||
"devDependencies": { | ||
"@alchemy/aa-core": "^0.1.0-alpha.14", | ||
"@alchemy/aa-core": "^0.1.0-alpha.15", | ||
"typescript": "^5.0.4", | ||
@@ -64,3 +64,3 @@ "typescript-template": "*", | ||
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme", | ||
"gitHead": "5b67970bdad3951372a43fdebea6f255b4fdac64" | ||
"gitHead": "0dfe3a02286d3a6d5daac71f4d1985832e4fd0ad" | ||
} |
@@ -12,4 +12,8 @@ // Add you exports here, make sure to export types separately from impls and use the `type` keyword when exporting them | ||
export type { KernelBaseValidatorParams } from "./kernel-zerodev/validator/base"; | ||
export type { | ||
KernelBatchUserOperationCallData, | ||
KernelUserOperationCallData, | ||
} from "./kernel-zerodev/types"; | ||
export type { KernelSmartAccountParams } from "./kernel-zerodev/account"; | ||
export { KernelSmartContractAccount } from "./kernel-zerodev/account"; | ||
export { KernelAccountProvider } from "./kernel-zerodev/provider"; |
@@ -1,2 +0,2 @@ | ||
import { Address, Hex, SmartAccountSigner } from "@alchemy/aa-core"; | ||
import type { Address, Hex, SmartAccountSigner } from "@alchemy/aa-core"; | ||
@@ -8,3 +8,3 @@ export class MockSignerValidator implements SmartAccountSigner { | ||
signMessage(msg: Uint8Array | Hex | string): Promise<Hex> { | ||
async signMessage(msg: Uint8Array | Hex | string): Promise<Hex> { | ||
switch (msg) { | ||
@@ -17,4 +17,6 @@ case "0xabcfC3DB1e0f5023F5a4f40c03D149f316E6A5cc": | ||
return "0x6c21c7271c8403452c5a812c9ba776b33b12733953f154d36d989d379c92ec632b7a1997ca16203a7ef5fcd639bcaa3d5420b65e0774a8bca7fad6d1437024661c"; | ||
default: | ||
throw new Error("Invalid message"); | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Address, Hex, SmartAccountSigner } from "@alchemy/aa-core"; | ||
import type { Address, Hex, SmartAccountSigner } from "@alchemy/aa-core"; | ||
@@ -8,3 +8,3 @@ export class MockSigner implements SmartAccountSigner { | ||
signMessage(msg: Uint8Array | Hex | string): Promise<Hex> { | ||
signMessage(_msg: Uint8Array | Hex | string): Promise<Hex> { | ||
return Promise.resolve( | ||
@@ -11,0 +11,0 @@ "0x4d61c5c27fb64b207cbf3bcf60d78e725659cff5f93db9a1316162117dff72aa631761619d93d4d97dfb761ba00b61f9274c6a4a76e494df644d968dd84ddcdb1c" |
@@ -21,2 +21,5 @@ import type { Address } from "abitype"; | ||
} from "@alchemy/aa-core"; | ||
import type { BatchUserOperationCallData } from "@alchemy/aa-core/src"; | ||
import { MultiSendAbi } from "./abis/MultiSendAbi"; | ||
import { encodeCall } from "./utils"; | ||
@@ -52,3 +55,3 @@ export interface KernelSmartAccountParams< | ||
getDummySignature(): Hex { | ||
return "0x4046ab7d9c387d7a5ef5ca0777eded29767fd9863048946d35b3042d2f7458ff7c62ade2903503e15973a63a296313eab15b964a18d79f4b06c8c01c7028143c1c"; | ||
return "0x00000000b650d28e51cf39d5c0bb7db6d81cce5f0a77baba8bf8de587c0bc83fa70e374f3bfef2afb697dc5627c669de7dc13e96c85697e0f6aae2f2ebe227552d00cb181c"; | ||
} | ||
@@ -72,2 +75,15 @@ | ||
override async encodeBatchExecute( | ||
_txs: BatchUserOperationCallData | ||
): Promise<`0x${string}`> { | ||
const multiSendData: `0x${string}` = concatHex( | ||
_txs.map((tx) => encodeCall(tx)) | ||
); | ||
return encodeFunctionData({ | ||
abi: MultiSendAbi, | ||
functionName: "multiSend", | ||
args: [multiSendData], | ||
}); | ||
} | ||
async signWithEip6492(msg: string | Uint8Array): Promise<Hex> { | ||
@@ -74,0 +90,0 @@ try { |
@@ -1,46 +0,12 @@ | ||
import type { HttpTransport } from "viem"; | ||
import { | ||
type AccountMiddlewareFn, | ||
deepHexlify, | ||
resolveProperties, | ||
SmartAccountProvider, | ||
} from "@alchemy/aa-core"; | ||
import type { Hash, HttpTransport } from "viem"; | ||
import { SmartAccountProvider } from "@alchemy/aa-core"; | ||
import { KernelSmartContractAccount } from "./account"; | ||
export class KernelAccountProvider extends SmartAccountProvider<HttpTransport> { | ||
gasEstimator: AccountMiddlewareFn = async (struct) => { | ||
const request = deepHexlify(await resolveProperties(struct)); | ||
const estimates = await this.rpcClient.estimateUserOperationGas( | ||
request, | ||
this.entryPointAddress | ||
); | ||
estimates.verificationGasLimit = | ||
(BigInt(estimates.verificationGasLimit) * 130n) / 100n; | ||
return { | ||
...struct, | ||
...estimates, | ||
}; | ||
}; | ||
request: (args: { method: string; params?: any[] }) => Promise<any> = async ( | ||
args | ||
) => { | ||
const { method, params } = args; | ||
if (method === "personal_sign") { | ||
if (!this.account) { | ||
throw new Error("account not connected!"); | ||
} | ||
const [data, address] = params!; | ||
if (address !== (await this.getAddress())) { | ||
throw new Error( | ||
"cannot sign for address that is not the current account" | ||
); | ||
} | ||
// @ts-ignore | ||
return this.account.signWithEip6492(data); | ||
} else { | ||
return super.request(args); | ||
signMessage = async (msg: string | Uint8Array): Promise<Hash> => { | ||
if (!this.account) { | ||
throw new Error("account not connected!"); | ||
} | ||
return (this.account as KernelSmartContractAccount).signWithEip6492(msg); | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
232771
89
4725