Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function decodeTransferLog(log: Log): Transfer | null {
if (!log || !log.topics || !log.data) {
console.error('Invalid transfer log:', log)
return null
}
/**
* Decode using the parameter signture for an ERC20 Transfer event
* For unknown reasons, blockscout includes an extra unknown param in the log's topics list
* Including this unknown param in the input list or decoding won't work
*/
try {
// @ts-ignore
const decodedLog: any = Web3EthAbi.default.decodeLog(
[
{
indexed: true,
name: 'unknown',
type: 'address',
},
{
indexed: true,
name: 'from',
type: 'address',
},
{
indexed: true,
name: 'to',
type: 'address',
},