-
Notifications
You must be signed in to change notification settings - Fork 44
/
status.go
60 lines (49 loc) · 1.19 KB
/
status.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package solar
import (
"fmt"
"os"
"github.com/qtumproject/solar/contract"
)
func init() {
cli := app.Command("status", "Show statuses of contracts")
contractNames := cli.Arg("names", "contract names").Strings()
appTasks["status"] = func() (err error) {
names := *contractNames
repo := solar.ContractsRepository()
if repo.Len() == 0 {
fmt.Println("No deployed contract yet")
os.Exit(0)
}
var contracts []*contract.DeployedContract
if len(names) != 0 {
for _, name := range names {
c, found := repo.Get(name)
if !found {
fmt.Printf("\u2757\ufe0f %s: not found\n", name)
continue
}
contracts = append(contracts, c)
}
// contracts =
} else {
contracts = repo.SortedContracts()
}
for _, c := range contracts {
// FIXME: store deploy name in contract
name := c.DeployName
if c.Confirmed {
fmt.Printf("\u2705 %s\n", name)
} else {
fmt.Printf(" %s\n", name)
}
fmt.Printf(" txid: %s\n", c.TransactionID)
fmt.Printf(" address: %s\n", c.Address)
fmt.Printf(" confirmed: %v\n", c.Confirmed)
if c.Sender != "" {
fmt.Printf(" owner: %v\n", c.Sender)
}
fmt.Println("")
}
return nil
}
}