-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
72 lines (56 loc) · 1.41 KB
/
main.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
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"context"
"encoding/json"
"fmt"
"github.com/alecthomas/kong"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
tmrpc "github.com/tendermint/tendermint/rpc/client/http"
)
const (
denom = "uakt"
rpcNode = "http://135.181.60.250:26657"
)
type runctx struct {
cctx client.Context
denom string
locked sdk.Int
}
type showCmd struct{}
func (c *showCmd) Run(ctx *runctx) error {
status, err := getStatus(context.Background(), ctx.cctx, ctx.denom, ctx.locked)
if err != nil {
return err
}
buf, err := json.MarshalIndent(status, "", " ")
if err != nil {
return err
}
fmt.Println(string(buf))
return nil
}
func main() {
var cli struct {
Node string `help:"RPC URI" default:"https://rpc.prod.ewr1.akash.farm:443/token/PHAH3PAI/"`
Denom string `help:"Denomination" default:"uakt"`
Locked string `help:"Locked token amount" default:"28903382000000"`
Show showCmd `cmd help:"Show summary" default:"1"`
Server serverCmd `cmd help:"Run server"`
}
ctx := kong.Parse(&cli)
tmclient, err := tmrpc.New(cli.Node, "")
ctx.FatalIfErrorf(err)
cctx := createContext()
cctx = cctx.WithClient(tmclient)
locked, ok := sdk.NewIntFromString(cli.Locked)
if !ok || locked.IsNegative() {
ctx.Fatalf("invalid locked value: %s", cli.Locked)
}
rctx := runctx{
cctx: cctx,
denom: cli.Denom,
locked: locked,
}
ctx.FatalIfErrorf(ctx.Run(&rctx))
}