@biconomy/sdk
Version:
SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.
50 lines • 2.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSimulationUserOp = void 0;
exports.tenderlySimulation = tenderlySimulation;
const account_abstraction_1 = require("viem/account-abstraction");
const _1 = require("./index.js");
const constants_1 = require("../../constants/index.js");
const deepHexlify_1 = require("./deepHexlify.js");
const getSimulationUserOp = (partialUserOp) => {
const simulationGasLimits = {
callGasLimit: 100000000000n,
verificationGasLimit: 100000000000n,
preVerificationGas: 1n,
maxFeePerGas: 100000000000n,
maxPriorityFeePerGas: 1n,
paymasterVerificationGasLimit: 100000000000n,
paymasterPostOpGasLimit: 100000n
};
const mergedUserOp = (0, deepHexlify_1.deepHexlify)({
...simulationGasLimits,
...partialUserOp
});
return (0, account_abstraction_1.toPackedUserOperation)(mergedUserOp);
};
exports.getSimulationUserOp = getSimulationUserOp;
function tenderlySimulation(partialUserOp, chainId = 84532) {
const tenderlyDetails = (0, _1.getTenderlyDetails)();
if (!tenderlyDetails) {
console.log("Tenderly details not found in environment variables. Please set TENDERLY_API_KEY, TENDERLY_ACCOUNT_SLUG, and TENDERLY_PROJECT_SLUG.");
return null;
}
const tenderlyUrl = new URL(`https://dashboard.tenderly.co/${tenderlyDetails.accountSlug}/${tenderlyDetails.projectSlug}/simulator/new`);
const packedUserOp = (0, exports.getSimulationUserOp)(partialUserOp);
const params = new URLSearchParams({
contractAddress: constants_1.ENTRY_POINT_ADDRESS,
value: "0",
network: chainId.toString(),
contractFunction: "0x765e827f",
functionInputs: JSON.stringify([packedUserOp]),
stateOverrides: JSON.stringify([
{
contractAddress: packedUserOp.sender,
balance: "100000000000000000000"
}
])
});
tenderlyUrl.search = params.toString();
return tenderlyUrl.toString();
}
//# sourceMappingURL=tenderlySimulation.js.map