forked from umbracle/ethgo
-
Notifications
You must be signed in to change notification settings - Fork 3
/
4byte.go
44 lines (36 loc) · 869 Bytes
/
4byte.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package commands
import (
fourbyte "github.com/cloudwalk/ethgo/4byte"
"github.com/mitchellh/cli"
)
// FourByteCommand is the command to resolve 4byte actions
type FourByteCommand struct {
UI cli.Ui
}
// Help implements the cli.Command interface
func (c *FourByteCommand) Help() string {
return `Usage: ethgo 4byte [signature]
Resolve a 4byte signature`
}
// Synopsis implements the cli.Command interface
func (c *FourByteCommand) Synopsis() string {
return "Resolve a 4byte signature"
}
// Run implements the cli.Command interface
func (c *FourByteCommand) Run(args []string) int {
if len(args) == 0 {
c.UI.Output("No arguments provided")
return 1
}
found, err := fourbyte.Resolve(args[0])
if err != nil {
c.UI.Output(err.Error())
return 1
}
if found == "" {
c.UI.Output("Resolve not found")
return 1
}
c.UI.Output(found)
return 0
}