@exromany/lido-csm-sdk
Version:
[](https://github.com/lidofinance/lido-csm-sdk/blob/main/LICENSE.txt) [](h
30 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCoverReceiptEvents = void 0;
const lido_ethereum_sdk_1 = require("@lidofinance/lido-ethereum-sdk");
const viem_1 = require("viem");
const Accounting_js_1 = require("../abi/Accounting.js");
const BOND_LOCK_CHANGED_EVENT = (0, viem_1.getAbiItem)({
abi: Accounting_js_1.AccountingAbi,
name: 'BondLockChanged',
});
const BOND_LOCK_CHANGED_SIGNATURE = (0, viem_1.toEventHash)(BOND_LOCK_CHANGED_EVENT);
const parseCoverReceiptEvents = async (receipt) => {
for (const log of receipt.logs) {
if (log.topics[0] !== BOND_LOCK_CHANGED_SIGNATURE)
continue;
const parsedLog = (0, viem_1.decodeEventLog)({
abi: [BOND_LOCK_CHANGED_EVENT],
strict: true,
data: log.data,
topics: log.topics,
});
return parsedLog.args.newAmount;
}
throw new lido_ethereum_sdk_1.SDKError({
message: 'could not find BondLockChanged event in transaction',
code: lido_ethereum_sdk_1.ERROR_CODE.TRANSACTION_ERROR,
});
};
exports.parseCoverReceiptEvents = parseCoverReceiptEvents;
//# sourceMappingURL=parse-cover-receipt-events.js.map