Skip to content

Commit

Permalink
fix: normalize OVL addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurka-o committed Nov 28, 2024
1 parent 0115250 commit 469059c
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function handleBuild(event: BuildEvent): void {
// Verify that the log is an ERC20 Transfer event and matches the OVL token address
if (
_topic0Fee.equals(TRANSFER_SIG) &&
_addressFee.toHexString() == OVL_ADDRESS &&
_addressFee.toHexString().toLowerCase() == OVL_ADDRESS.toLowerCase() &&
receipt.logs[index].topics.length > 1
) {
// Decode the recipient address from the log's topics
Expand All @@ -181,6 +181,15 @@ export function handleBuild(event: BuildEvent): void {
buildIndex.toString(),
index.toString()
])

log.error("handleBuild data transferFeeAmount: transaction: {}, _topic0Fee: {}, _addressFee: {}, topics.length {}, TRANSFER_SIG {}, OVL_ADDRESS {}", [
event.transaction.hash.toHexString(),
_topic0Fee.toHexString(),
_addressFee.toHexString().toLowerCase(),
receipt.logs[index].topics.length.toString(),
TRANSFER_SIG.toHexString(),
OVL_ADDRESS.toLowerCase()
])
}

index--
Expand All @@ -191,7 +200,7 @@ export function handleBuild(event: BuildEvent): void {

if (
_topic0Main.equals(TRANSFER_SIG) &&
_addressMain.toHexString() == OVL_ADDRESS &&
_addressMain.toHexString().toLowerCase() == OVL_ADDRESS.toLowerCase() &&
receipt.logs[index].topics.length > 1
) {
// Decode the recipient address from the log's topics
Expand All @@ -216,6 +225,15 @@ export function handleBuild(event: BuildEvent): void {
buildIndex.toString(),
index.toString()
])

log.error("handleBuild data userTransferAmount: transaction: {}, _topic0Fee: {}, _addressFee: {}, topics.length {}, TRANSFER_SIG {}, OVL_ADDRESS {}", [
event.transaction.hash.toHexString(),
_topic0Fee.toHexString(),
_addressFee.toHexString().toLowerCase(),
receipt.logs[index].topics.length.toString(),
TRANSFER_SIG.toHexString(),
OVL_ADDRESS.toLowerCase()
])
}
} else {
// Log an error if the receipt or factory is missing
Expand Down Expand Up @@ -394,7 +412,7 @@ export function handleUnwind(event: UnwindEvent): void {
// Find the log that matches the ERC20 transfer to the owner
if (
_topic0user.equals(TRANSFER_SIG) &&
_addressuser.toHexString() == OVL_ADDRESS &&
_addressuser.toHexString().toLowerCase() == OVL_ADDRESS.toLowerCase() &&
receipt.logs[userTransferIndex].topics.length > 1
) {
// Decode the recipient address from the log's topics
Expand Down Expand Up @@ -422,6 +440,15 @@ export function handleUnwind(event: UnwindEvent): void {
unwindIndex.toString(),
userTransferIndex.toString()
])

log.error("handleUnwind data userTransferIndex: transaction: {}, _topic0Fee: {}, _addressFee: {}, topics.length {}, TRANSFER_SIG {}, OVL_ADDRESS {}", [
event.transaction.hash.toHexString(),
_topic0user.toHexString(),
_addressuser.toHexString().toLowerCase(),
receipt.logs[userTransferIndex].topics.length.toString(),
TRANSFER_SIG.toHexString(),
OVL_ADDRESS.toLowerCase()
])
}

// Extract the first topic and address of the fee transfer log
Expand All @@ -431,7 +458,7 @@ export function handleUnwind(event: UnwindEvent): void {
// Find the log that matches the ERC20 transfer to the fee recipient
if (
_topic0.equals(TRANSFER_SIG) &&
_address.toHexString() == OVL_ADDRESS &&
_address.toHexString().toLowerCase() == OVL_ADDRESS.toLowerCase() &&
receipt.logs[feeIndex].topics.length > 1
) {
// Decode the recipient address from the log's topics
Expand All @@ -457,6 +484,15 @@ export function handleUnwind(event: UnwindEvent): void {
unwindIndex.toString(),
feeIndex.toString()
])

log.error("handleUnwind data feeIndex: transaction: {}, _topic0Fee: {}, _addressFee: {}, topics.length {}, TRANSFER_SIG {}, OVL_ADDRESS {}", [
event.transaction.hash.toHexString(),
_topic0user.toHexString(),
_addressuser.toHexString().toLowerCase(),
receipt.logs[userTransferIndex].topics.length.toString(),
TRANSFER_SIG.toHexString(),
OVL_ADDRESS.toLowerCase()
])
}
}

Expand Down Expand Up @@ -699,7 +735,7 @@ export function handleLiquidate(event: LiquidateEvent): void {
// Find the log that matches the ERC20 transfer to the feeRecipient
if (
_topic0.equals(TRANSFER_SIG) &&
_address.toHexString() == OVL_ADDRESS &&
_address.toHexString().toLowerCase() == OVL_ADDRESS.toLowerCase() &&
receipt.logs[feeIndex].topics.length > 1
) {
// Decode the recipient address from the log's topics
Expand Down Expand Up @@ -735,7 +771,7 @@ export function handleLiquidate(event: LiquidateEvent): void {
// Find the log that matches the ERC20 transfer to the sender (liquidator)
if (
_topic0.equals(TRANSFER_SIG) &&
_address.toHexString() == OVL_ADDRESS &&
_address.toHexString().toLowerCase() == OVL_ADDRESS.toLowerCase() &&
receipt.logs[liquidatorTransferIndex].topics.length > 1
) {
// Decode the recipient address from the log's topics
Expand Down

0 comments on commit 469059c

Please sign in to comment.