Skip to content

Commit

Permalink
validate function modified
Browse files Browse the repository at this point in the history
  • Loading branch information
giladHaimov committed Sep 5, 2024
1 parent aa9f0f7 commit 91e7e7c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions eth/gasprice/lfm/nativediscount.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,36 +209,37 @@ func validTransferData(functionSelector []byte, dataLen int) bool {
if !eq(functionSelector, transferFunction) {
return false
}
if dataLen == transferDataLen {
log.Debug("@lfm: erc20 transfer() call detected for gas price discount")
return true
if dataLen != transferDataLen {
log.Warn("@lfm: erc20 transfer() called with bad data", "dataLen", dataLen)
return false
}
log.Warn("@lfm: erc20 transfer() called with bad data", "dataLen", dataLen)
return false
log.Debug("@lfm: erc20 transfer() call detected for gas price discount")
return true
}

func validTransferFromData(functionSelector []byte, dataLen int) bool {
if !eq(functionSelector, transferFromFunction) {
return false
}
if dataLen == transferFromDataLen {
log.Debug("@lfm: erc20 transferFrom() call detected for gas price discount")
return true
if dataLen != transferFromDataLen {
log.Warn("@lfm: erc20 transferFrom() called with bad data", "dataLen", dataLen)
return false
}
log.Warn("@lfm: erc20 transferFrom() called with bad data", "dataLen", dataLen)
return false
log.Debug("@lfm: erc20 transferFrom() call detected for gas price discount")
return true

}

func validApproveData(functionSelector []byte, dataLen int) bool {
if !eq(functionSelector, approveFunction) {
return false
}
if dataLen == approveDataLen {
log.Debug("@lfm: erc20 approve() call detected for gas price discount")
return true
if dataLen != approveDataLen {
log.Warn("@lfm: erc20 approve() called with bad data", "dataLen", dataLen)
return false
}
log.Warn("@lfm: erc20 approve() called with bad data", "dataLen", dataLen)
return false
log.Debug("@lfm: erc20 approve() call detected for gas price discount")
return true
}

func eq(a []byte, b []byte) bool {
Expand Down

0 comments on commit 91e7e7c

Please sign in to comment.