@zerodev/sdk
Advanced tools
Comparing version 4.0.2-alpha.23 to 4.0.2-alpha.24
@@ -20,3 +20,2 @@ export * from "./kernel-zerodev/abis/index.js"; | ||
export { ZeroDevEthersProvider } from "./kernel-zerodev/ethers-provider/ethers-provider.js"; | ||
export { ZeroDevLocalAccountSigner } from "./kernel-zerodev/signer/zd-local-account.js"; | ||
export * as constants from "./kernel-zerodev/constants.js"; |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.constants = exports.ZeroDevLocalAccountSigner = exports.ZeroDevEthersProvider = exports.getChainId = exports.ZeroDevProvider = exports.KernelSmartContractAccount = exports.ValidatorProvider = exports.KernelBaseValidator = exports.ValidatorMode = void 0; | ||
exports.constants = exports.ZeroDevEthersProvider = exports.getChainId = exports.ZeroDevProvider = exports.KernelSmartContractAccount = exports.ValidatorProvider = exports.KernelBaseValidator = exports.ValidatorMode = void 0; | ||
__exportStar(require("./kernel-zerodev/abis/index.js"), exports); | ||
@@ -48,5 +48,3 @@ var base_js_1 = require("./kernel-zerodev/validator/base.js"); | ||
Object.defineProperty(exports, "ZeroDevEthersProvider", { enumerable: true, get: function () { return ethers_provider_js_1.ZeroDevEthersProvider; } }); | ||
var zd_local_account_js_1 = require("./kernel-zerodev/signer/zd-local-account.js"); | ||
Object.defineProperty(exports, "ZeroDevLocalAccountSigner", { enumerable: true, get: function () { return zd_local_account_js_1.ZeroDevLocalAccountSigner; } }); | ||
exports.constants = __importStar(require("./kernel-zerodev/constants.js")); | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import { type Address, type Chain, type HttpTransport } from "viem"; | ||
import { type SmartAccountProviderOpts, type UserOperationCallData, type BatchUserOperationCallData, type SendUserOperationResult, SmartAccountProvider, type AccountMiddlewareFn } from "@alchemy/aa-core"; | ||
import { type Address, type Chain, type Hash, type HttpTransport, type RpcTransactionRequest } from "viem"; | ||
import { type SmartAccountProviderOpts, type UserOperationCallData, type BatchUserOperationCallData, type SendUserOperationResult, SmartAccountProvider, type AccountMiddlewareFn, type UserOperationOverrides } from "@alchemy/aa-core"; | ||
import { KernelSmartContractAccount } from "./account.js"; | ||
@@ -28,3 +28,4 @@ import type { PaymasterAndBundlerProviders, PaymasterConfig, PaymasterPolicy } from "./paymaster/types.js"; | ||
getProjectId: () => string; | ||
sendUserOperation: <T extends UserOperationCallData | BatchUserOperationCallData>(data: T, operation?: UserOpDataOperationTypes<T>) => Promise<SendUserOperationResult>; | ||
sendTransaction: (request: RpcTransactionRequest, operation?: UserOpDataOperationTypes<UserOperationCallData>) => Promise<Hash>; | ||
sendUserOperation: <T extends UserOperationCallData | BatchUserOperationCallData>(data: T, overrides?: UserOperationOverrides, operation?: UserOpDataOperationTypes<T>) => Promise<SendUserOperationResult>; | ||
isReplacementOpError(errorIn: any): boolean; | ||
@@ -31,0 +32,0 @@ unwrapError(errorIn: any): Error; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ZeroDevProvider = exports.Operation = void 0; | ||
const viem_1 = require("viem"); | ||
const aa_core_1 = require("@alchemy/aa-core"); | ||
@@ -57,2 +58,25 @@ const constants_js_1 = require("./constants.js"); | ||
}); | ||
Object.defineProperty(this, "sendTransaction", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async (request, operation = Operation.Call) => { | ||
if (!request.to) { | ||
throw new Error("transaction is missing to address"); | ||
} | ||
const overrides = {}; | ||
if (request.maxFeePerGas) { | ||
overrides.maxFeePerGas = request.maxFeePerGas; | ||
} | ||
if (request.maxPriorityFeePerGas) { | ||
overrides.maxPriorityFeePerGas = request.maxPriorityFeePerGas; | ||
} | ||
const { hash } = await this.sendUserOperation({ | ||
target: request.to, | ||
data: request.data ?? "0x", | ||
value: request.value ? (0, viem_1.fromHex)(request.value, "bigint") : 0n, | ||
}, overrides, operation); | ||
return await this.waitForUserOperationTransaction(hash); | ||
} | ||
}); | ||
Object.defineProperty(this, "sendUserOperation", { | ||
@@ -62,3 +86,3 @@ enumerable: true, | ||
writable: true, | ||
value: async (data, operation = Operation.Call) => { | ||
value: async (data, overrides, operation = Operation.Call) => { | ||
if (!(0, account_js_1.isKernelAccount)(this.account)) { | ||
@@ -101,3 +125,3 @@ throw new Error("account not connected!"); | ||
do { | ||
const uoStruct = await (0, aa_core_1.asyncPipe)(this.dummyPaymasterDataMiddleware, this.feeDataGetter, this.paymasterDataMiddleware, this.gasEstimator, this.customMiddleware ?? aa_core_1.noOpMiddleware)({ | ||
const uoStruct = await (0, aa_core_1.asyncPipe)(this.dummyPaymasterDataMiddleware, this.feeDataGetter, this.paymasterDataMiddleware, this.gasEstimator, this.customMiddleware ?? aa_core_1.noOpMiddleware, async (struct) => ({ ...struct, ...overrides }))({ | ||
initCode, | ||
@@ -104,0 +128,0 @@ sender: this.getAddress(), |
import { type Hex, type WalletClient } from "viem"; | ||
import type { SmartAccountSigner, UserOperationCallData } from "@alchemy/aa-core"; | ||
import { Signer } from "@ethersproject/abstract-signer"; | ||
import { Wallet } from "@ethersproject/wallet"; | ||
import type { SupportedGasToken } from "./paymaster/types.js"; | ||
@@ -12,3 +13,4 @@ export type UserOperationCallDataWithDelegate = UserOperationCallData & { | ||
export declare const convertWalletClientToAccountSigner: (client: WalletClient) => SmartAccountSigner; | ||
export declare const convertEthersSignerToAccountSigner: (signer: Signer) => SmartAccountSigner; | ||
export declare const isWallet: (signer: any) => signer is Wallet; | ||
export declare const convertEthersSignerToAccountSigner: (signer: Signer | Wallet) => SmartAccountSigner; | ||
export declare function getRPCProviderOwner(web3Provider: any): SmartAccountSigner; | ||
@@ -15,0 +17,0 @@ export declare function getCustodialOwner(identifier: string, { custodialFilePath, privateKey, publicKey, keyId, apiUrl, }: { |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.randomHexString = exports.getCustodialOwner = exports.getRPCProviderOwner = exports.convertEthersSignerToAccountSigner = exports.convertWalletClientToAccountSigner = exports.getGasTokenAddress = exports.encodeMultiSend = void 0; | ||
exports.randomHexString = exports.getCustodialOwner = exports.getRPCProviderOwner = exports.convertEthersSignerToAccountSigner = exports.isWallet = exports.convertWalletClientToAccountSigner = exports.getGasTokenAddress = exports.encodeMultiSend = void 0; | ||
const viem_1 = require("viem"); | ||
@@ -45,5 +45,8 @@ const providers_1 = require("@ethersproject/providers"); | ||
})), | ||
signTypedData: async (params) => await client.signTypedData({ ...params, account: client.account }), | ||
}; | ||
}; | ||
exports.convertWalletClientToAccountSigner = convertWalletClientToAccountSigner; | ||
const isWallet = (signer) => signer && signer._signTypedData !== undefined; | ||
exports.isWallet = isWallet; | ||
const convertEthersSignerToAccountSigner = (signer) => { | ||
@@ -53,2 +56,8 @@ return { | ||
signMessage: async (msg) => (await signer.signMessage(msg)), | ||
signTypedData: async (params) => { | ||
if (!(0, exports.isWallet)(signer)) { | ||
throw Error("signTypedData method not implemented in signer"); | ||
} | ||
return (await signer._signTypedData(params.domain, params.types, params.message)); | ||
}, | ||
}; | ||
@@ -63,2 +72,3 @@ }; | ||
signMessage: async (msg) => (await signer.signMessage(msg)), | ||
signTypedData: async (params) => (await signer._signTypedData(params.domain, params.types, params.message)), | ||
}; | ||
@@ -107,2 +117,3 @@ } | ||
signMessage: async (msg) => (await turnkeySigner.signMessage(msg)), | ||
signTypedData: async (params) => (await turnkeySigner.signTypedData(params.domain, params.types, params.message)), | ||
}; | ||
@@ -109,0 +120,0 @@ } |
@@ -36,3 +36,3 @@ import { type SmartAccountSigner, type UserOperationRequest } from "@alchemy/aa-core"; | ||
protected bundlerProvider?: PaymasterAndBundlerProviders; | ||
protected publicClient?: PublicClient<Transport, Chain, true>; | ||
protected publicClient?: PublicClient<Transport, Chain>; | ||
constructor(params: KernelBaseValidatorParams); | ||
@@ -39,0 +39,0 @@ abstract encodeEnable(enableData: Hex): Hex; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const constants_js_1 = require("../constants.js"); | ||
const index_js_1 = require("viem/dist/types/chains/index.js"); | ||
var ValidatorMode; | ||
@@ -117,3 +118,3 @@ (function (ValidatorMode) { | ||
}), | ||
chain: this.chain, | ||
chain: this.chain ?? index_js_1.polygonMumbai, | ||
}); | ||
@@ -120,0 +121,0 @@ } |
@@ -20,3 +20,2 @@ export * from "./kernel-zerodev/abis/index.js"; | ||
export { ZeroDevEthersProvider } from "./kernel-zerodev/ethers-provider/ethers-provider.js"; | ||
export { ZeroDevLocalAccountSigner } from "./kernel-zerodev/signer/zd-local-account.js"; | ||
export * as constants from "./kernel-zerodev/constants.js"; |
@@ -11,4 +11,3 @@ export * from "./kernel-zerodev/abis/index.js"; | ||
export { ZeroDevEthersProvider } from "./kernel-zerodev/ethers-provider/ethers-provider.js"; | ||
export { ZeroDevLocalAccountSigner } from "./kernel-zerodev/signer/zd-local-account.js"; | ||
export * as constants from "./kernel-zerodev/constants.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import { type Address, type Chain, type HttpTransport } from "viem"; | ||
import { type SmartAccountProviderOpts, type UserOperationCallData, type BatchUserOperationCallData, type SendUserOperationResult, SmartAccountProvider, type AccountMiddlewareFn } from "@alchemy/aa-core"; | ||
import { type Address, type Chain, type Hash, type HttpTransport, type RpcTransactionRequest } from "viem"; | ||
import { type SmartAccountProviderOpts, type UserOperationCallData, type BatchUserOperationCallData, type SendUserOperationResult, SmartAccountProvider, type AccountMiddlewareFn, type UserOperationOverrides } from "@alchemy/aa-core"; | ||
import { KernelSmartContractAccount } from "./account.js"; | ||
@@ -28,3 +28,4 @@ import type { PaymasterAndBundlerProviders, PaymasterConfig, PaymasterPolicy } from "./paymaster/types.js"; | ||
getProjectId: () => string; | ||
sendUserOperation: <T extends UserOperationCallData | BatchUserOperationCallData>(data: T, operation?: UserOpDataOperationTypes<T>) => Promise<SendUserOperationResult>; | ||
sendTransaction: (request: RpcTransactionRequest, operation?: UserOpDataOperationTypes<UserOperationCallData>) => Promise<Hash>; | ||
sendUserOperation: <T extends UserOperationCallData | BatchUserOperationCallData>(data: T, overrides?: UserOperationOverrides, operation?: UserOpDataOperationTypes<T>) => Promise<SendUserOperationResult>; | ||
isReplacementOpError(errorIn: any): boolean; | ||
@@ -31,0 +32,0 @@ unwrapError(errorIn: any): Error; |
@@ -1,2 +0,2 @@ | ||
import {} from "viem"; | ||
import { fromHex, } from "viem"; | ||
import { deepHexlify, resolveProperties, getChain, asyncPipe, noOpMiddleware, SmartAccountProvider, } from "@alchemy/aa-core"; | ||
@@ -55,2 +55,25 @@ import { BUNDLER_URL, DEFAULT_SEND_TX_MAX_RETRIES, DEFAULT_SEND_TX_RETRY_INTERVAL_MS, ENTRYPOINT_ADDRESS, minPriorityFeePerBidDefaults, } from "./constants.js"; | ||
}); | ||
Object.defineProperty(this, "sendTransaction", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async (request, operation = Operation.Call) => { | ||
if (!request.to) { | ||
throw new Error("transaction is missing to address"); | ||
} | ||
const overrides = {}; | ||
if (request.maxFeePerGas) { | ||
overrides.maxFeePerGas = request.maxFeePerGas; | ||
} | ||
if (request.maxPriorityFeePerGas) { | ||
overrides.maxPriorityFeePerGas = request.maxPriorityFeePerGas; | ||
} | ||
const { hash } = await this.sendUserOperation({ | ||
target: request.to, | ||
data: request.data ?? "0x", | ||
value: request.value ? fromHex(request.value, "bigint") : 0n, | ||
}, overrides, operation); | ||
return await this.waitForUserOperationTransaction(hash); | ||
} | ||
}); | ||
Object.defineProperty(this, "sendUserOperation", { | ||
@@ -60,3 +83,3 @@ enumerable: true, | ||
writable: true, | ||
value: async (data, operation = Operation.Call) => { | ||
value: async (data, overrides, operation = Operation.Call) => { | ||
if (!isKernelAccount(this.account)) { | ||
@@ -99,3 +122,3 @@ throw new Error("account not connected!"); | ||
do { | ||
const uoStruct = await asyncPipe(this.dummyPaymasterDataMiddleware, this.feeDataGetter, this.paymasterDataMiddleware, this.gasEstimator, this.customMiddleware ?? noOpMiddleware)({ | ||
const uoStruct = await asyncPipe(this.dummyPaymasterDataMiddleware, this.feeDataGetter, this.paymasterDataMiddleware, this.gasEstimator, this.customMiddleware ?? noOpMiddleware, async (struct) => ({ ...struct, ...overrides }))({ | ||
initCode, | ||
@@ -102,0 +125,0 @@ sender: this.getAddress(), |
import { type Hex, type WalletClient } from "viem"; | ||
import type { SmartAccountSigner, UserOperationCallData } from "@alchemy/aa-core"; | ||
import { Signer } from "@ethersproject/abstract-signer"; | ||
import { Wallet } from "@ethersproject/wallet"; | ||
import type { SupportedGasToken } from "./paymaster/types.js"; | ||
@@ -12,3 +13,4 @@ export type UserOperationCallDataWithDelegate = UserOperationCallData & { | ||
export declare const convertWalletClientToAccountSigner: (client: WalletClient) => SmartAccountSigner; | ||
export declare const convertEthersSignerToAccountSigner: (signer: Signer) => SmartAccountSigner; | ||
export declare const isWallet: (signer: any) => signer is Wallet; | ||
export declare const convertEthersSignerToAccountSigner: (signer: Signer | Wallet) => SmartAccountSigner; | ||
export declare function getRPCProviderOwner(web3Provider: any): SmartAccountSigner; | ||
@@ -15,0 +17,0 @@ export declare function getCustodialOwner(identifier: string, { custodialFilePath, privateKey, publicKey, keyId, apiUrl, }: { |
import { encodePacked, fromBytes, toBytes, toHex, } from "viem"; | ||
import { Signer } from "@ethersproject/abstract-signer"; | ||
import { Wallet } from "@ethersproject/wallet"; | ||
import { Web3Provider } from "@ethersproject/providers"; | ||
@@ -37,4 +38,6 @@ import { API_URL, gasTokenChainAddresses } from "./constants.js"; | ||
})), | ||
signTypedData: async (params) => await client.signTypedData({ ...params, account: client.account }), | ||
}; | ||
}; | ||
export const isWallet = (signer) => signer && signer._signTypedData !== undefined; | ||
export const convertEthersSignerToAccountSigner = (signer) => { | ||
@@ -44,2 +47,8 @@ return { | ||
signMessage: async (msg) => (await signer.signMessage(msg)), | ||
signTypedData: async (params) => { | ||
if (!isWallet(signer)) { | ||
throw Error("signTypedData method not implemented in signer"); | ||
} | ||
return (await signer._signTypedData(params.domain, params.types, params.message)); | ||
}, | ||
}; | ||
@@ -53,2 +62,3 @@ }; | ||
signMessage: async (msg) => (await signer.signMessage(msg)), | ||
signTypedData: async (params) => (await signer._signTypedData(params.domain, params.types, params.message)), | ||
}; | ||
@@ -96,2 +106,3 @@ } | ||
signMessage: async (msg) => (await turnkeySigner.signMessage(msg)), | ||
signTypedData: async (params) => (await turnkeySigner.signTypedData(params.domain, params.types, params.message)), | ||
}; | ||
@@ -98,0 +109,0 @@ } |
@@ -36,3 +36,3 @@ import { type SmartAccountSigner, type UserOperationRequest } from "@alchemy/aa-core"; | ||
protected bundlerProvider?: PaymasterAndBundlerProviders; | ||
protected publicClient?: PublicClient<Transport, Chain, true>; | ||
protected publicClient?: PublicClient<Transport, Chain>; | ||
constructor(params: KernelBaseValidatorParams); | ||
@@ -39,0 +39,0 @@ abstract encodeEnable(enableData: Hex): Hex; |
@@ -5,2 +5,3 @@ import {} from "@alchemy/aa-core"; | ||
import { BUNDLER_URL, ECDSA_VALIDATOR_ADDRESS, ENTRYPOINT_ADDRESS, } from "../constants.js"; | ||
import { polygonMumbai } from "viem/dist/types/chains/index.js"; | ||
export var ValidatorMode; | ||
@@ -115,3 +116,3 @@ (function (ValidatorMode) { | ||
}), | ||
chain: this.chain, | ||
chain: this.chain ?? polygonMumbai, | ||
}); | ||
@@ -118,0 +119,0 @@ } |
@@ -20,4 +20,3 @@ export * from "./kernel-zerodev/abis/index.js"; | ||
export { ZeroDevEthersProvider } from "./kernel-zerodev/ethers-provider/ethers-provider.js"; | ||
export { ZeroDevLocalAccountSigner } from "./kernel-zerodev/signer/zd-local-account.js"; | ||
export * as constants from "./kernel-zerodev/constants.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import { type Address, type Chain, type HttpTransport } from "viem"; | ||
import { type SmartAccountProviderOpts, type UserOperationCallData, type BatchUserOperationCallData, type SendUserOperationResult, SmartAccountProvider, type AccountMiddlewareFn } from "@alchemy/aa-core"; | ||
import { type Address, type Chain, type Hash, type HttpTransport, type RpcTransactionRequest } from "viem"; | ||
import { type SmartAccountProviderOpts, type UserOperationCallData, type BatchUserOperationCallData, type SendUserOperationResult, SmartAccountProvider, type AccountMiddlewareFn, type UserOperationOverrides } from "@alchemy/aa-core"; | ||
import { KernelSmartContractAccount } from "./account.js"; | ||
@@ -28,3 +28,4 @@ import type { PaymasterAndBundlerProviders, PaymasterConfig, PaymasterPolicy } from "./paymaster/types.js"; | ||
getProjectId: () => string; | ||
sendUserOperation: <T extends UserOperationCallData | BatchUserOperationCallData>(data: T, operation?: UserOpDataOperationTypes<T>) => Promise<SendUserOperationResult>; | ||
sendTransaction: (request: RpcTransactionRequest, operation?: UserOpDataOperationTypes<UserOperationCallData>) => Promise<Hash>; | ||
sendUserOperation: <T extends UserOperationCallData | BatchUserOperationCallData>(data: T, overrides?: UserOperationOverrides, operation?: UserOpDataOperationTypes<T>) => Promise<SendUserOperationResult>; | ||
isReplacementOpError(errorIn: any): boolean; | ||
@@ -31,0 +32,0 @@ unwrapError(errorIn: any): Error; |
import { type Hex, type WalletClient } from "viem"; | ||
import type { SmartAccountSigner, UserOperationCallData } from "@alchemy/aa-core"; | ||
import { Signer } from "@ethersproject/abstract-signer"; | ||
import { Wallet } from "@ethersproject/wallet"; | ||
import type { SupportedGasToken } from "./paymaster/types.js"; | ||
@@ -12,3 +13,4 @@ export type UserOperationCallDataWithDelegate = UserOperationCallData & { | ||
export declare const convertWalletClientToAccountSigner: (client: WalletClient) => SmartAccountSigner; | ||
export declare const convertEthersSignerToAccountSigner: (signer: Signer) => SmartAccountSigner; | ||
export declare const isWallet: (signer: any) => signer is Wallet; | ||
export declare const convertEthersSignerToAccountSigner: (signer: Signer | Wallet) => SmartAccountSigner; | ||
export declare function getRPCProviderOwner(web3Provider: any): SmartAccountSigner; | ||
@@ -15,0 +17,0 @@ export declare function getCustodialOwner(identifier: string, { custodialFilePath, privateKey, publicKey, keyId, apiUrl, }: { |
@@ -36,3 +36,3 @@ import { type SmartAccountSigner, type UserOperationRequest } from "@alchemy/aa-core"; | ||
protected bundlerProvider?: PaymasterAndBundlerProviders; | ||
protected publicClient?: PublicClient<Transport, Chain, true>; | ||
protected publicClient?: PublicClient<Transport, Chain>; | ||
constructor(params: KernelBaseValidatorParams); | ||
@@ -39,0 +39,0 @@ abstract encodeEnable(enableData: Hex): Hex; |
{ | ||
"name": "@zerodev/sdk", | ||
"version": "4.0.2-alpha.23", | ||
"version": "4.0.2-alpha.24", | ||
"description": "A collection of ERC-4337 compliant smart contract account interfaces", | ||
@@ -38,17 +38,15 @@ "author": "ZeroDev", | ||
"test": "vitest", | ||
"test:run": "vitest run" | ||
"test:run": "vitest run", | ||
"test:run-e2e": "vitest run --config vitest.config.e2e.ts" | ||
}, | ||
"devDependencies": { | ||
"@alchemy/aa-core": "^0.1.0-alpha.16", | ||
"@alchemy/aa-ethers": "^0.1.0-alpha.16", | ||
"@alchemy/aa-core": "^0.1.0-alpha.23", | ||
"@alchemy/aa-ethers": "^0.1.0-alpha.23", | ||
"@turnkey/ethers": "^0.16.2", | ||
"typescript": "^5.0.4", | ||
"typescript-template": "*", | ||
"viem": "^1.1.7", | ||
"vitest": "^0.31.0" | ||
}, | ||
"peerDependencies": { | ||
"@alchemy/aa-core": "^0.1.0-alpha.16", | ||
"@alchemy/aa-ethers": "^0.1.0-alpha.16", | ||
"viem": "^1.1.7" | ||
"@alchemy/aa-core": "^0.1.0-alpha.23" | ||
}, | ||
@@ -69,4 +67,5 @@ "publishConfig": { | ||
"dependencies": { | ||
"axios": "^1.4.0" | ||
"axios": "^1.4.0", | ||
"viem": "^1.5.3" | ||
} | ||
} |
@@ -12,3 +12,3 @@ # ZeroDev SDK | ||
```bash | ||
yarn add @alchemy/aa-core @zerodevapp/sdk@alpha viem | ||
yarn add @zerodev/sdk@alpha | ||
``` | ||
@@ -19,3 +19,3 @@ | ||
```bash | ||
npm i -s @alchemy/aa-core @zerodevapp/sdk@alpha viem | ||
npm i -s @zerodev/sdk@alpha | ||
``` | ||
@@ -28,3 +28,3 @@ | ||
```ts | ||
import { ECDSAValidator } from "@zerodevapp/sdk@alpha"; | ||
import { ECDSAValidator } from "@zerodev/sdk@alpha"; | ||
import { PrivateKeySigner } from "@alchemy/aa-core"; | ||
@@ -140,3 +140,3 @@ | ||
convertEthersSignerToAccountSigner, | ||
} from "@zerodevapp/sdk@alpha"; | ||
} from "@zerodev/sdk@alpha"; | ||
@@ -176,3 +176,3 @@ // 1. Create an ethers Wallet | ||
convertWalletClientToAccountSigner, | ||
} from "@zerodevapp/sdk@alpha"; | ||
} from "@zerodev/sdk@alpha"; | ||
@@ -202,3 +202,3 @@ // 1. Create a Viem Wallet Client using the custom transport | ||
```ts | ||
import { ECDSAProvider, getRPCProviderOwner } from "@zerodevapp/sdk@alpha"; | ||
import { ECDSAProvider, getRPCProviderOwner } from "@zerodev/sdk@alpha"; | ||
import { Magic } from "magic-sdk"; | ||
@@ -219,3 +219,3 @@ | ||
```ts | ||
import { ECDSAProvider, getRPCProviderOwner } from "@zerodevapp/sdk@alpha"; | ||
import { ECDSAProvider, getRPCProviderOwner } from "@zerodev/sdk@alpha"; | ||
import { Web3Auth } from "@web3auth/modal"; | ||
@@ -244,3 +244,3 @@ | ||
```ts | ||
import { constants } from "@zerodevapp/sdk@alpha"; | ||
import { constants } from "@zerodev/sdk@alpha"; | ||
// 1. Get the default ecdsa validator provider | ||
@@ -247,0 +247,0 @@ const ecdsaProvider = await ECDSAProvider.init({ |
@@ -39,4 +39,3 @@ // Add you exports here, make sure to export types separately from impls and use the `type` keyword when exporting them | ||
export { ZeroDevEthersProvider } from "./kernel-zerodev/ethers-provider/ethers-provider.js"; | ||
export { ZeroDevLocalAccountSigner } from "./kernel-zerodev/signer/zd-local-account.js"; | ||
export * as constants from "./kernel-zerodev/constants.js"; |
@@ -1,3 +0,7 @@ | ||
import type { SmartAccountSigner } from "@alchemy/aa-core"; | ||
import type { Address, Hex } from "viem"; | ||
import type { | ||
Address, | ||
Hex, | ||
SignTypedDataParams, | ||
SmartAccountSigner, | ||
} from "@alchemy/aa-core"; | ||
@@ -9,3 +13,3 @@ export class MockSigner implements SmartAccountSigner { | ||
signMessage(msg: Uint8Array | Hex | string): Promise<Hex> { | ||
signMessage(_msg: Uint8Array | Hex | string): Promise<Hex> { | ||
return Promise.resolve( | ||
@@ -15,2 +19,8 @@ "0x4d61c5c27fb64b207cbf3bcf60d78e725659cff5f93db9a1316162117dff72aa631761619d93d4d97dfb761ba00b61f9274c6a4a76e494df644d968dd84ddcdb1c" | ||
} | ||
signTypedData(_params: SignTypedDataParams): Promise<`0x${string}`> { | ||
return Promise.resolve( | ||
"0x4d61c5c27fb64b207cbf3bcf60d78e725659cff5f93db9a1316162117dff72aa631761619d93d4d97dfb761ba00b61f9274c6a4a76e494df644d968dd84ddcdb1c" | ||
); | ||
} | ||
} |
import { | ||
fromHex, | ||
type Address, | ||
type Chain, | ||
type Hash, | ||
type Hex, | ||
@@ -22,2 +24,3 @@ type HttpTransport, | ||
type AccountMiddlewareFn, | ||
type UserOperationOverrides, | ||
} from "@alchemy/aa-core"; | ||
@@ -109,2 +112,31 @@ import { | ||
sendTransaction = async ( | ||
request: RpcTransactionRequest, | ||
operation: UserOpDataOperationTypes<UserOperationCallData> = Operation.Call | ||
): Promise<Hash> => { | ||
if (!request.to) { | ||
throw new Error("transaction is missing to address"); | ||
} | ||
const overrides: UserOperationOverrides = {}; | ||
if (request.maxFeePerGas) { | ||
overrides.maxFeePerGas = request.maxFeePerGas; | ||
} | ||
if (request.maxPriorityFeePerGas) { | ||
overrides.maxPriorityFeePerGas = request.maxPriorityFeePerGas; | ||
} | ||
const { hash } = await this.sendUserOperation( | ||
{ | ||
target: request.to, | ||
data: request.data ?? "0x", | ||
value: request.value ? fromHex(request.value, "bigint") : 0n, | ||
}, | ||
overrides, | ||
operation | ||
); | ||
return await this.waitForUserOperationTransaction(hash as Hash); | ||
}; | ||
sendUserOperation = async < | ||
@@ -114,2 +146,3 @@ T extends UserOperationCallData | BatchUserOperationCallData | ||
data: T, | ||
overrides?: UserOperationOverrides, | ||
operation: UserOpDataOperationTypes<T> = Operation.Call as UserOpDataOperationTypes<T> | ||
@@ -166,3 +199,4 @@ ): Promise<SendUserOperationResult> => { | ||
this.gasEstimator, | ||
this.customMiddleware ?? noOpMiddleware | ||
this.customMiddleware ?? noOpMiddleware, | ||
async (struct) => ({ ...struct, ...overrides }) | ||
)({ | ||
@@ -169,0 +203,0 @@ initCode, |
@@ -10,6 +10,8 @@ import { | ||
import type { | ||
SignTypedDataParams, | ||
SmartAccountSigner, | ||
UserOperationCallData, | ||
} from "@alchemy/aa-core"; | ||
import { Signer } from "@ethersproject/abstract-signer"; | ||
import { Signer, type TypedDataField } from "@ethersproject/abstract-signer"; | ||
import { Wallet } from "@ethersproject/wallet"; | ||
import { Web3Provider, type ExternalProvider } from "@ethersproject/providers"; | ||
@@ -73,7 +75,12 @@ import { API_URL, gasTokenChainAddresses } from "./constants.js"; | ||
})) as `0x${string}`, | ||
signTypedData: async (params: SignTypedDataParams) => | ||
await client.signTypedData({ ...params, account: client.account! }), | ||
}; | ||
}; | ||
export const isWallet = (signer: any): signer is Wallet => | ||
signer && signer._signTypedData !== undefined; | ||
export const convertEthersSignerToAccountSigner = ( | ||
signer: Signer | ||
signer: Signer | Wallet | ||
): SmartAccountSigner => { | ||
@@ -85,2 +92,12 @@ return { | ||
(await signer.signMessage(msg)) as `0x${string}`, | ||
signTypedData: async (params: SignTypedDataParams) => { | ||
if (!isWallet(signer)) { | ||
throw Error("signTypedData method not implemented in signer"); | ||
} | ||
return (await signer._signTypedData( | ||
params.domain!, | ||
params.types as unknown as Record<string, TypedDataField[]>, | ||
params.message | ||
)) as Hex; | ||
}, | ||
}; | ||
@@ -98,2 +115,8 @@ }; | ||
(await signer.signMessage(msg)) as `0x${string}`, | ||
signTypedData: async (params: SignTypedDataParams) => | ||
(await signer._signTypedData( | ||
params.domain!, | ||
params.types as unknown as Record<string, TypedDataField[]>, | ||
params.message | ||
)) as Hex, | ||
}; | ||
@@ -162,2 +185,8 @@ } | ||
(await turnkeySigner.signMessage(msg)) as `0x${string}`, | ||
signTypedData: async (params: SignTypedDataParams) => | ||
(await turnkeySigner.signTypedData( | ||
params.domain, | ||
params.types, | ||
params.message | ||
)) as Hex, | ||
}; | ||
@@ -164,0 +193,0 @@ } |
@@ -26,2 +26,3 @@ import { | ||
import type { PaymasterAndBundlerProviders } from "../paymaster/types.js"; | ||
import { polygonMumbai } from "viem/dist/types/chains/index.js"; | ||
@@ -64,3 +65,3 @@ export enum ValidatorMode { | ||
protected bundlerProvider?: PaymasterAndBundlerProviders; | ||
protected publicClient?: PublicClient<Transport, Chain, true>; | ||
protected publicClient?: PublicClient<Transport, Chain>; | ||
@@ -92,3 +93,3 @@ constructor(params: KernelBaseValidatorParams) { | ||
}), | ||
chain: this.chain, | ||
chain: this.chain ?? polygonMumbai, | ||
}); | ||
@@ -95,0 +96,0 @@ } |
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
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
3
6
1275241
383
21370
+ Addedviem@^1.5.3
- Removed@alchemy/aa-ethers@0.1.1(transitive)
- Removed@ethersproject/abi@5.7.0(transitive)
- Removed@ethersproject/abstract-provider@5.7.0(transitive)
- Removed@ethersproject/abstract-signer@5.7.0(transitive)
- Removed@ethersproject/address@5.7.0(transitive)
- Removed@ethersproject/base64@5.7.0(transitive)
- Removed@ethersproject/basex@5.7.0(transitive)
- Removed@ethersproject/bignumber@5.7.0(transitive)
- Removed@ethersproject/bytes@5.7.0(transitive)
- Removed@ethersproject/constants@5.7.0(transitive)
- Removed@ethersproject/contracts@5.7.0(transitive)
- Removed@ethersproject/hash@5.7.0(transitive)
- Removed@ethersproject/hdnode@5.7.0(transitive)
- Removed@ethersproject/json-wallets@5.7.0(transitive)
- Removed@ethersproject/keccak256@5.7.0(transitive)
- Removed@ethersproject/logger@5.7.0(transitive)
- Removed@ethersproject/networks@5.7.1(transitive)
- Removed@ethersproject/pbkdf2@5.7.0(transitive)
- Removed@ethersproject/properties@5.7.0(transitive)
- Removed@ethersproject/providers@5.7.2(transitive)
- Removed@ethersproject/random@5.7.0(transitive)
- Removed@ethersproject/rlp@5.7.0(transitive)
- Removed@ethersproject/sha2@5.7.0(transitive)
- Removed@ethersproject/signing-key@5.7.0(transitive)
- Removed@ethersproject/strings@5.7.0(transitive)
- Removed@ethersproject/transactions@5.7.0(transitive)
- Removed@ethersproject/wallet@5.7.0(transitive)
- Removed@ethersproject/web@5.7.1(transitive)
- Removed@ethersproject/wordlists@5.7.0(transitive)
- Removedaes-js@3.0.0(transitive)
- Removedbech32@1.1.4(transitive)
- Removedbn.js@4.12.15.2.1(transitive)
- Removedbrorand@1.1.0(transitive)
- Removedelliptic@6.5.4(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedjs-sha3@0.8.0(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
- Removedscrypt-js@3.0.1(transitive)
- Removedws@7.4.6(transitive)