-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
curio: Command for generating market tokens
- Loading branch information
Showing
9 changed files
with
198 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"sort" | ||
|
||
"github.com/urfave/cli/v2" | ||
"golang.org/x/xerrors" | ||
|
||
"github.com/filecoin-project/lotus/cmd/curio/deps" | ||
"github.com/filecoin-project/lotus/curiosrc/market/lmrpc" | ||
) | ||
|
||
var marketCmd = &cli.Command{ | ||
Name: "market", | ||
Subcommands: []*cli.Command{ | ||
marketRPCInfoCmd, | ||
}, | ||
} | ||
|
||
var marketRPCInfoCmd = &cli.Command{ | ||
Flags: []cli.Flag{ | ||
&cli.StringSliceFlag{ | ||
Name: "layers", | ||
Usage: "list of layers to be interpreted (atop defaults). Default: base", | ||
}, | ||
}, | ||
Action: func(cctx *cli.Context) error { | ||
db, err := deps.MakeDB(cctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cfg, err := deps.GetConfig(cctx, db) | ||
if err != nil { | ||
return xerrors.Errorf("get config: %w", err) | ||
} | ||
|
||
ts, err := lmrpc.MakeTokens(cfg) | ||
if err != nil { | ||
return xerrors.Errorf("make tokens: %w", err) | ||
} | ||
|
||
var addrTokens []struct { | ||
Address string | ||
Token string | ||
} | ||
|
||
for address, s := range ts { | ||
addrTokens = append(addrTokens, struct { | ||
Address string | ||
Token string | ||
}{ | ||
Address: address.String(), | ||
Token: s, | ||
}) | ||
} | ||
|
||
sort.Slice(addrTokens, func(i, j int) bool { | ||
return addrTokens[i].Address < addrTokens[j].Address | ||
}) | ||
|
||
for _, at := range addrTokens { | ||
fmt.Printf("%s %s\n", at.Address, at.Token) | ||
} | ||
|
||
return nil | ||
}, | ||
Name: "rpc-info", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters