I'm listening for an event:
OrdersMatched (bytes32 buyHash, bytes32 sellHash, index_topic_1 address maker, index_topic_2 address taker, uint256 price, index_topic_3 bytes32 metadata)
This is what I'm currently doing and I'm getting an error:
contract.on('OrdersMatched', (buyHash, sellHash, from, to, price, metadata) => {
console.log('from', from)
console.log('to', to)
console.log('price', ethers.utils.formatUnits(price, 18)) // decode
if (metadata !== '0x0000000000000000000000000000000000000000000000000000000000000000') {
console.log('metadata', ethers.utils.parseBytes32String(metadata)) // decode bytes32 (doesn't work)
}
console.log('')
})
error - uncaughtException: Error: invalid codepoint at offset 3; unexpected continuation byte (argument="bytes", value=Uint8Array(0x5c5321ae45550685308a405827575e3d6b4a84aa), code=INVALID_ARGUMENT, version=strings/5.4.0)
I'd love some help figuring out how to get this decoding.
Thanks!
Edit:
Logs of metadata and its type:
md 0x66fdd5e25ef9ddb305ba3c2aae1856ab9c6f2979000000000000000000000000
md type string