diff --git a/services/wallet/thirdparty/fourbyte/client.go b/services/wallet/thirdparty/fourbyte/client.go index 18645d1ed..ad8d166c1 100644 --- a/services/wallet/thirdparty/fourbyte/client.go +++ b/services/wallet/thirdparty/fourbyte/client.go @@ -23,7 +23,7 @@ type Signature struct { type ByID []Signature func (s ByID) Len() int { return len(s) } -func (s ByID) Less(i, j int) bool { return s[i].ID < s[j].ID } +func (s ByID) Less(i, j int) bool { return s[i].ID > s[j].ID } func (s ByID) Swap(i, j int) { s[i], s[j] = s[j], s[i] } type SignatureList struct { @@ -53,6 +53,7 @@ func (c *Client) Run(data string) (*thirdparty.DataParsed, error) { return nil, errors.New("input is badly formatted") } methodSigData := data[2:10] + fmt.Println(methodSigData) url := fmt.Sprintf("https://www.4byte.directory/api/v1/signatures/?hex_signature=%s", methodSigData) resp, err := c.DoQuery(url) if err != nil { @@ -77,6 +78,7 @@ func (c *Client) Run(data string) (*thirdparty.DataParsed, error) { results := signatures.Results sort.Sort(ByID(results)) for _, signature := range results { + id := fmt.Sprintf("0x%x", signature.ID) name := strings.Split(signature.Text, "(")[0] rs := rgx.FindStringSubmatch(signature.Text) @@ -102,6 +104,7 @@ func (c *Client) Run(data string) (*thirdparty.DataParsed, error) { return &thirdparty.DataParsed{ Name: name, + ID: id, Signature: signature.Text, Inputs: inputsMapString, }, nil diff --git a/services/wallet/thirdparty/fourbyte/client_test.go b/services/wallet/thirdparty/fourbyte/client_test.go index 6167bbbf8..89fa3d9e7 100644 --- a/services/wallet/thirdparty/fourbyte/client_test.go +++ b/services/wallet/thirdparty/fourbyte/client_test.go @@ -12,6 +12,7 @@ func TestRun(t *testing.T) { require.Nil(t, err) require.Equal(t, res.Signature, "processDepositQueue(address,uint256)") require.Equal(t, res.Name, "processDepositQueue") + require.Equal(t, res.ID, "0xf94d2") require.Equal(t, res.Inputs, map[string]string{ "0": "0x3030303030303030303030303637306463613632", "1": "44417128579249187980157595307322491418158007948522794164811090501355597543782", diff --git a/services/wallet/thirdparty/types.go b/services/wallet/thirdparty/types.go index 2c9e26fae..fec7e2af3 100644 --- a/services/wallet/thirdparty/types.go +++ b/services/wallet/thirdparty/types.go @@ -84,6 +84,7 @@ type NFTContractOwnershipProvider interface { type DataParsed struct { Name string `json:"name"` + ID string `json:"id"` Inputs map[string]string `json:"inputs"` Signature string `json:"signature"` }