Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/internal/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"math"
"strconv"
"strings"

libcommon "github.com/String-xyz/go-lib/v2/common"
"github.com/ethereum/go-ethereum/accounts"
Expand Down Expand Up @@ -70,3 +71,14 @@ func SliceContains(elems []string, v string) bool {
}
return false
}

func StringContainsAny(target string, substrs []string) bool {
// convert target to lowercase
noSpaceLowerCase := strings.ReplaceAll(strings.ToLower(target), " ", "")
for _, substr := range substrs {
if strings.Contains(noSpaceLowerCase, strings.ReplaceAll(strings.ToLower(substr), " ", "")) {
return true
}
}
return false
}
2 changes: 1 addition & 1 deletion pkg/service/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ func (t transaction) testTransaction(executor Executor, request model.Transactio
tokenAddresses := []string{}
tokenAmounts := []big.Int{}
for _, action := range request.Actions {
if strings.ToLower(strings.ReplaceAll(action.CxFunc, " ", "")) == "approve(address,uint256)" {
if common.StringContainsAny(action.CxFunc, []string{"approve", "transfer"}) {
tokenAddresses = append(tokenAddresses, action.CxAddr)
// It should be safe at this point to w3.I without panic
tokenAmounts = append(tokenAmounts, *w3.I(action.CxParams[1]))
Expand Down