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