Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka committed Sep 26, 2024
1 parent 3d750f3 commit 3a357f9
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions intents/intent_data_transaction_delayed_abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,16 @@ func EncodeDelayedABI(data *delayedEncodeType) (string, error) {
// - transferFrom(address,address,uint256)
// making sure that the method matches the returned one
func getMethodFromAbi(abi string, method string) (string, []string, error) {
type FunctionAbi struct {
Name string `json:"name"`
Type string `json:"type"`
Inputs []struct {
InternalType string `json:"internalType"`
Name string `json:"name"`
Type string `json:"type"`
} `json:"inputs"`
}

//
// First attempt to parse `abi` string as a plain method abi
// ie. transferFrom(address,address,uint256)
//

// Handle the case for already encoded method abi
if strings.Contains(abi, "(") && strings.Contains(abi, ")") && strings.HasPrefix(abi, method) {
// NOTE: even though the ethcoder function is `ParseEventDef`, designed for event type parsing
// the abi format for a single function structure is the same, so it works. Perhaps we will rename
// `ParseEventDef` in the future, or just add another method with a different name.
eventDef, err := ethcoder.ParseEventDef(abi)
if err != nil {
return "", nil, err
Expand All @@ -135,6 +128,16 @@ func getMethodFromAbi(abi string, method string) (string, []string, error) {
// a JSON object of the full abi definition
//

type FunctionAbi struct {
Name string `json:"name"`
Type string `json:"type"`
Inputs []struct {
InternalType string `json:"internalType"`
Name string `json:"name"`
Type string `json:"type"`
} `json:"inputs"`
}

// Handle array of function abis and single function abi
var abis []FunctionAbi
if strings.HasPrefix(abi, "[") {
Expand Down

0 comments on commit 3a357f9

Please sign in to comment.