UNPKG

@tunghm/relay-kit

Version:
50 lines 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.userOperationToHexValues = exports.getEip1193Provider = exports.getEip4337BundlerProvider = void 0; const ethers_1 = require("ethers"); /** * Gets the EIP-4337 bundler provider. * * @param {string} bundlerUrl The EIP-4337 bundler URL. * @return {Provider} The EIP-4337 bundler provider. */ function getEip4337BundlerProvider(bundlerUrl) { const provider = new ethers_1.ethers.JsonRpcProvider(bundlerUrl, undefined, { batchMaxCount: 1 }); return provider; } exports.getEip4337BundlerProvider = getEip4337BundlerProvider; /** * Gets the EIP-1193 provider from the bundler url. * * @param {string} rpcUrl The RPC URL. * @return {Provider} The EIP-1193 provider. */ function getEip1193Provider(rpcUrl) { const provider = new ethers_1.ethers.JsonRpcProvider(rpcUrl, undefined, { batchMaxCount: 1 }); return provider; } exports.getEip1193Provider = getEip1193Provider; /** * Converts various bigint values from a UserOperation to their hexadecimal representation. * * @param {UserOperation} userOperation - The UserOperation object whose values are to be converted. * @returns {UserOperation} A new UserOperation object with the values converted to hexadecimal. */ function userOperationToHexValues(userOperation) { const userOperationWithHexValues = { ...userOperation, nonce: ethers_1.ethers.toBeHex(userOperation.nonce), callGasLimit: ethers_1.ethers.toBeHex(userOperation.callGasLimit), verificationGasLimit: ethers_1.ethers.toBeHex(userOperation.verificationGasLimit), preVerificationGas: ethers_1.ethers.toBeHex(userOperation.preVerificationGas), maxFeePerGas: ethers_1.ethers.toBeHex(userOperation.maxFeePerGas), maxPriorityFeePerGas: ethers_1.ethers.toBeHex(userOperation.maxPriorityFeePerGas) }; return userOperationWithHexValues; } exports.userOperationToHexValues = userOperationToHexValues; //# sourceMappingURL=utils.js.map