@zerodev/sdk
Advanced tools
Comparing version 5.0.1 to 5.0.2
@@ -15,5 +15,3 @@ "use strict"; | ||
gasTokenData: args.gasTokenData && { | ||
tokenAddress: args.gasTokenData.tokenAddress, | ||
erc20UserOp: (0, utils_1.deepHexlify)(args.gasTokenData.erc20UserOp), | ||
erc20CallData: args.gasTokenData.erc20CallData | ||
tokenAddress: args.gasTokenData.tokenAddress | ||
}, | ||
@@ -20,0 +18,0 @@ shouldOverrideFee: args.shouldOverrideFee ?? false, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.constants = exports.TokenActionsAbi = exports.KernelFactoryAbi = exports.KernelAccountAbi = exports.createKernelAccountClient = exports.createZeroDevPaymasterClient = exports.kernelAccountClientActions = exports.zerodevPaymasterActions = exports.sponsorUserOperation = exports.EIP1271ABI = exports.addressToEmptyAccount = exports.KERNEL_ADDRESSES = exports.createKernelAccount = void 0; | ||
exports.gasTokenChainAddresses = exports.constants = exports.TokenActionsAbi = exports.KernelFactoryAbi = exports.KernelAccountAbi = exports.createKernelAccountClient = exports.createZeroDevPaymasterClient = exports.kernelAccountClientActions = exports.zerodevPaymasterActions = exports.sponsorUserOperation = exports.EIP1271ABI = exports.addressToEmptyAccount = exports.KERNEL_ADDRESSES = exports.createKernelAccount = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -27,2 +27,4 @@ var index_js_1 = require("./accounts/index.js"); | ||
tslib_1.__exportStar(require("./utils.js"), exports); | ||
var gasTokenChainAddresses_js_1 = require("./gasTokenChainAddresses.js"); | ||
Object.defineProperty(exports, "gasTokenChainAddresses", { enumerable: true, get: function () { return gasTokenChainAddresses_js_1.gasTokenChainAddresses; } }); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.walletClientToSmartAccountSigner = exports.providerToSmartAccountSigner = exports.getKernelVersion = void 0; | ||
exports.getERC20PaymasterApproveData = exports.walletClientToSmartAccountSigner = exports.providerToSmartAccountSigner = exports.getKernelVersion = void 0; | ||
const permissionless_1 = require("permissionless"); | ||
const viem_1 = require("viem"); | ||
const index_js_1 = require("./accounts/index.js"); | ||
const constants_js_1 = require("./constants.js"); | ||
@@ -37,2 +38,23 @@ const getKernelVersion = (kernelImpl) => { | ||
exports.walletClientToSmartAccountSigner = walletClientToSmartAccountSigner; | ||
const getERC20PaymasterApproveData = async (client, { tokenAddress, approveAmount }) => { | ||
const response = await client.request({ | ||
method: "zd_pm_accounts", | ||
params: [ | ||
{ | ||
chainId: client.chain?.id, | ||
entryPointAddress: index_js_1.KERNEL_ADDRESSES.ENTRYPOINT_V0_6 | ||
} | ||
] | ||
}); | ||
return { | ||
to: tokenAddress, | ||
data: (0, viem_1.encodeFunctionData)({ | ||
abi: viem_1.erc20Abi, | ||
functionName: "approve", | ||
args: [response[0], approveAmount] | ||
}), | ||
value: 0n | ||
}; | ||
}; | ||
exports.getERC20PaymasterApproveData = getERC20PaymasterApproveData; | ||
//# sourceMappingURL=utils.js.map |
@@ -15,5 +15,3 @@ import { deepHexlify } from "permissionless/utils"; | ||
gasTokenData: args.gasTokenData && { | ||
tokenAddress: args.gasTokenData.tokenAddress, | ||
erc20UserOp: deepHexlify(args.gasTokenData.erc20UserOp), | ||
erc20CallData: args.gasTokenData.erc20CallData | ||
tokenAddress: args.gasTokenData.tokenAddress | ||
}, | ||
@@ -20,0 +18,0 @@ shouldOverrideFee: args.shouldOverrideFee ?? false, |
@@ -13,2 +13,3 @@ export { createKernelAccount, KERNEL_ADDRESSES, addressToEmptyAccount, EIP1271ABI } from "./accounts/index.js"; | ||
export * from "./utils.js"; | ||
export { gasTokenChainAddresses } from "./gasTokenChainAddresses.js"; | ||
//# sourceMappingURL=index.js.map |
import { walletClientToCustomSigner } from "permissionless"; | ||
import { createWalletClient, custom, zeroAddress } from "viem"; | ||
import { createWalletClient, custom, encodeFunctionData, erc20Abi, zeroAddress } from "viem"; | ||
import { KERNEL_ADDRESSES } from "./accounts/index.js"; | ||
import { KernelImplToVersionMap, LATEST_KERNEL_VERSION } from "./constants.js"; | ||
@@ -32,2 +33,22 @@ export const getKernelVersion = (kernelImpl) => { | ||
}; | ||
export const getERC20PaymasterApproveData = async (client, { tokenAddress, approveAmount }) => { | ||
const response = await client.request({ | ||
method: "zd_pm_accounts", | ||
params: [ | ||
{ | ||
chainId: client.chain?.id, | ||
entryPointAddress: KERNEL_ADDRESSES.ENTRYPOINT_V0_6 | ||
} | ||
] | ||
}); | ||
return { | ||
to: tokenAddress, | ||
data: encodeFunctionData({ | ||
abi: erc20Abi, | ||
functionName: "approve", | ||
args: [response[0], approveAmount] | ||
}), | ||
value: 0n | ||
}; | ||
}; | ||
//# sourceMappingURL=utils.js.map |
@@ -10,4 +10,2 @@ import type { UserOperation } from "permissionless/types/userOperation.js"; | ||
tokenAddress: Hex; | ||
erc20UserOp: PartialBy<UserOperation, "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "paymasterAndData">; | ||
erc20CallData: Hex; | ||
}; | ||
@@ -14,0 +12,0 @@ shouldOverrideFee?: boolean; |
@@ -45,2 +45,4 @@ import type { SmartAccount } from "permissionless/accounts/types"; | ||
[x: `bytes1[${string}]`]: undefined; | ||
[x: `bytes5[${string}]`]: undefined; | ||
[x: `bytes10[${string}]`]: undefined; | ||
[x: `bytes16[${string}]`]: undefined; | ||
@@ -50,3 +52,2 @@ [x: `bytes2[${string}]`]: undefined; | ||
[x: `bytes4[${string}]`]: undefined; | ||
[x: `bytes5[${string}]`]: undefined; | ||
[x: `bytes6[${string}]`]: undefined; | ||
@@ -56,3 +57,2 @@ [x: `bytes7[${string}]`]: undefined; | ||
[x: `bytes9[${string}]`]: undefined; | ||
[x: `bytes10[${string}]`]: undefined; | ||
[x: `bytes11[${string}]`]: undefined; | ||
@@ -80,5 +80,5 @@ [x: `bytes12[${string}]`]: undefined; | ||
[x: `int[${string}]`]: undefined; | ||
[x: `int56[${string}]`]: undefined; | ||
[x: `int40[${string}]`]: undefined; | ||
[x: `int16[${string}]`]: undefined; | ||
[x: `int56[${string}]`]: undefined; | ||
[x: `int8[${string}]`]: undefined; | ||
@@ -114,5 +114,5 @@ [x: `int24[${string}]`]: undefined; | ||
[x: `uint[${string}]`]: undefined; | ||
[x: `uint56[${string}]`]: undefined; | ||
[x: `uint40[${string}]`]: undefined; | ||
[x: `uint16[${string}]`]: undefined; | ||
[x: `uint56[${string}]`]: undefined; | ||
[x: `uint8[${string}]`]: undefined; | ||
@@ -152,2 +152,4 @@ [x: `uint24[${string}]`]: undefined; | ||
bytes1?: undefined; | ||
bytes5?: undefined; | ||
bytes10?: undefined; | ||
bytes16?: undefined; | ||
@@ -157,3 +159,2 @@ bytes2?: undefined; | ||
bytes4?: undefined; | ||
bytes5?: undefined; | ||
bytes6?: undefined; | ||
@@ -163,3 +164,2 @@ bytes7?: undefined; | ||
bytes9?: undefined; | ||
bytes10?: undefined; | ||
bytes11?: undefined; | ||
@@ -186,5 +186,5 @@ bytes12?: undefined; | ||
bytes32?: undefined; | ||
int56?: undefined; | ||
int40?: undefined; | ||
int16?: undefined; | ||
int56?: undefined; | ||
int8?: undefined; | ||
@@ -219,5 +219,5 @@ int24?: undefined; | ||
int256?: undefined; | ||
uint56?: undefined; | ||
uint40?: undefined; | ||
uint16?: undefined; | ||
uint56?: undefined; | ||
uint8?: undefined; | ||
@@ -224,0 +224,0 @@ uint24?: undefined; |
@@ -12,2 +12,3 @@ export { createKernelAccount, type KernelSmartAccount, KERNEL_ADDRESSES, addressToEmptyAccount, EIP1271ABI } from "./accounts/index.js"; | ||
export * from "./utils.js"; | ||
export { gasTokenChainAddresses, type TokenSymbolsMap } from "./gasTokenChainAddresses.js"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -14,4 +14,2 @@ import type { UserOperation, UserOperationWithBigIntAsHex } from "permissionless/types/userOperation"; | ||
tokenAddress: Hex; | ||
erc20UserOp: PartialBy<UserOperationWithBigIntAsHex, "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "paymasterAndData">; | ||
erc20CallData: Hex; | ||
}; | ||
@@ -31,2 +29,12 @@ shouldOverrideFee?: boolean; | ||
}; | ||
}, | ||
{ | ||
Method: "zd_pm_accounts"; | ||
Parameters: [ | ||
{ | ||
chainId: number; | ||
entryPointAddress: Address; | ||
} | ||
]; | ||
ReturnType: Address[]; | ||
} | ||
@@ -33,0 +41,0 @@ ]; |
import { type Address, type Hex, type WalletClient } from "viem"; | ||
import type { ZeroDevPaymasterClient } from "./clients/paymasterClient.js"; | ||
export declare const getKernelVersion: (kernelImpl?: Address) => string; | ||
@@ -11,3 +12,11 @@ interface EIP1193Provider { | ||
export declare const walletClientToSmartAccountSigner: (walletClient: WalletClient) => import("permissionless/_types/accounts/types.js").SmartAccountSigner<"custom", `0x${string}`>; | ||
export declare const getERC20PaymasterApproveData: (client: ZeroDevPaymasterClient, { tokenAddress, approveAmount }: { | ||
tokenAddress: Address; | ||
approveAmount: bigint; | ||
}) => Promise<{ | ||
to: Address; | ||
value: bigint; | ||
data: Hex; | ||
}>; | ||
export {}; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -22,10 +22,2 @@ import type { | ||
tokenAddress: Hex | ||
erc20UserOp: PartialBy< | ||
UserOperation, | ||
| "callGasLimit" | ||
| "preVerificationGas" | ||
| "verificationGasLimit" | ||
| "paymasterAndData" | ||
> | ||
erc20CallData: Hex | ||
} | ||
@@ -56,7 +48,3 @@ shouldOverrideFee?: boolean | ||
gasTokenData: args.gasTokenData && { | ||
tokenAddress: args.gasTokenData.tokenAddress, | ||
erc20UserOp: deepHexlify( | ||
args.gasTokenData.erc20UserOp | ||
) as UserOperationWithBigIntAsHex, | ||
erc20CallData: args.gasTokenData.erc20CallData | ||
tokenAddress: args.gasTokenData.tokenAddress | ||
}, | ||
@@ -63,0 +51,0 @@ shouldOverrideFee: args.shouldOverrideFee ?? false, |
@@ -37,1 +37,5 @@ export { | ||
export * from "./utils.js" | ||
export { | ||
gasTokenChainAddresses, | ||
type TokenSymbolsMap | ||
} from "./gasTokenChainAddresses.js" |
{ | ||
"name": "@zerodev/sdk", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"author": "ZeroDev", | ||
@@ -5,0 +5,0 @@ "main": "./_cjs/index.js", |
@@ -23,10 +23,2 @@ import type { | ||
tokenAddress: Hex | ||
erc20UserOp: PartialBy< | ||
UserOperationWithBigIntAsHex, | ||
| "callGasLimit" | ||
| "preVerificationGas" | ||
| "verificationGasLimit" | ||
| "paymasterAndData" | ||
> | ||
erc20CallData: Hex | ||
} | ||
@@ -46,2 +38,12 @@ shouldOverrideFee?: boolean | ||
} | ||
}, | ||
{ | ||
Method: "zd_pm_accounts" | ||
Parameters: [ | ||
{ | ||
chainId: number | ||
entryPointAddress: Address | ||
} | ||
] | ||
ReturnType: Address[] | ||
} | ||
@@ -48,0 +50,0 @@ ] |
34
utils.ts
@@ -8,4 +8,8 @@ import { walletClientToCustomSigner } from "permissionless" | ||
custom, | ||
encodeFunctionData, | ||
erc20Abi, | ||
zeroAddress | ||
} from "viem" | ||
import { KERNEL_ADDRESSES } from "./accounts/index.js" | ||
import type { ZeroDevPaymasterClient } from "./clients/paymasterClient.js" | ||
import { KernelImplToVersionMap, LATEST_KERNEL_VERSION } from "./constants.js" | ||
@@ -49,1 +53,31 @@ | ||
} | ||
export const getERC20PaymasterApproveData = async ( | ||
client: ZeroDevPaymasterClient, | ||
{ | ||
tokenAddress, | ||
approveAmount | ||
}: { | ||
tokenAddress: Address | ||
approveAmount: bigint | ||
} | ||
): Promise<{ to: Address; value: bigint; data: Hex }> => { | ||
const response = await client.request({ | ||
method: "zd_pm_accounts", | ||
params: [ | ||
{ | ||
chainId: client.chain?.id as number, | ||
entryPointAddress: KERNEL_ADDRESSES.ENTRYPOINT_V0_6 | ||
} | ||
] | ||
}) | ||
return { | ||
to: tokenAddress, | ||
data: encodeFunctionData({ | ||
abi: erc20Abi, | ||
functionName: "approve", | ||
args: [response[0], approveAmount] | ||
}), | ||
value: 0n | ||
} | ||
} |
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
439258
157
9377