diff --git a/pkg/internal/common/util.go b/pkg/internal/common/util.go index b96f4bd4..a5df5442 100644 --- a/pkg/internal/common/util.go +++ b/pkg/internal/common/util.go @@ -7,6 +7,7 @@ import ( "io" "math" "strconv" + "strings" libcommon "github.com/String-xyz/go-lib/v2/common" "github.com/ethereum/go-ethereum/accounts" @@ -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 +} diff --git a/pkg/service/transaction.go b/pkg/service/transaction.go index ca510703..7df88d8d 100644 --- a/pkg/service/transaction.go +++ b/pkg/service/transaction.go @@ -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]))