@alchemy/aa-core
Version:
viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts
64 lines • 2.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.dropAndReplaceUserOperation = void 0;
const isSmartAccountClient_js_1 = require("../../client/isSmartAccountClient.js");
const account_js_1 = require("../../errors/account.js");
const client_js_1 = require("../../errors/client.js");
const index_js_1 = require("../../utils/index.js");
const runMiddlewareStack_js_1 = require("./internal/runMiddlewareStack.js");
const sendUserOperation_js_1 = require("./internal/sendUserOperation.js");
async function dropAndReplaceUserOperation(client, args) {
const { account = client.account, uoToDrop, overrides, context } = args;
if (!account) {
throw new account_js_1.AccountNotFoundError();
}
if (!(0, isSmartAccountClient_js_1.isBaseSmartAccountClient)(client)) {
throw new client_js_1.IncompatibleClientError("BaseSmartAccountClient", "dropAndReplaceUserOperation", client);
}
const entryPoint = account.getEntryPoint();
const uoToSubmit = (entryPoint.version === "0.6.0"
? {
initCode: uoToDrop.initCode,
sender: uoToDrop.sender,
nonce: uoToDrop.nonce,
callData: uoToDrop.callData,
signature: await account.getDummySignature(),
}
: {
...(uoToDrop.factory &&
uoToDrop.factoryData
? {
factory: uoToDrop.factory,
factoryData: uoToDrop
.factoryData,
}
: {}),
sender: uoToDrop.sender,
nonce: uoToDrop.nonce,
callData: uoToDrop.callData,
signature: await account.getDummySignature(),
});
const { maxFeePerGas, maxPriorityFeePerGas } = await (0, runMiddlewareStack_js_1._runMiddlewareStack)(client, {
uo: uoToSubmit,
overrides,
account,
});
const _overrides = {
...overrides,
maxFeePerGas: (0, index_js_1.bigIntMax)(BigInt(maxFeePerGas ?? 0n), (0, index_js_1.bigIntMultiply)(uoToDrop.maxFeePerGas, 1.1)),
maxPriorityFeePerGas: (0, index_js_1.bigIntMax)(BigInt(maxPriorityFeePerGas ?? 0n), (0, index_js_1.bigIntMultiply)(uoToDrop.maxPriorityFeePerGas, 1.1)),
};
const uoToSend = await (0, runMiddlewareStack_js_1._runMiddlewareStack)(client, {
uo: uoToSubmit,
overrides: _overrides,
account,
});
return (0, sendUserOperation_js_1._sendUserOperation)(client, {
uoStruct: uoToSend,
account,
context,
overrides: _overrides,
});
}
exports.dropAndReplaceUserOperation = dropAndReplaceUserOperation;
//# sourceMappingURL=dropAndReplaceUserOperation.js.map