92503075a6
* new verireg methods * update changelog and add itest * update itest and cli * update new method's support till v9 * remove gateway APIs * fix cli internal var names
52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/fatih/color"
|
|
"github.com/ipfs/go-cid"
|
|
"github.com/mattn/go-isatty"
|
|
|
|
"github.com/filecoin-project/lotus/api/v0api"
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
)
|
|
|
|
// Set the global default, to be overridden by individual cli flags in order
|
|
func init() {
|
|
color.NoColor = os.Getenv("GOLOG_LOG_FMT") != "color" &&
|
|
!isatty.IsTerminal(os.Stdout.Fd()) &&
|
|
!isatty.IsCygwinTerminal(os.Stdout.Fd())
|
|
}
|
|
|
|
func parseTipSet(ctx context.Context, api v0api.FullNode, vals []string) (*types.TipSet, error) {
|
|
var headers []*types.BlockHeader
|
|
for _, c := range vals {
|
|
blkc, err := cid.Decode(c)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
bh, err := api.ChainGetBlock(ctx, blkc)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
headers = append(headers, bh)
|
|
}
|
|
|
|
return types.NewTipSet(headers)
|
|
}
|
|
|
|
func PrintJson(obj interface{}) error {
|
|
resJson, err := json.MarshalIndent(obj, "", " ")
|
|
if err != nil {
|
|
return fmt.Errorf("marshalling json: %w", err)
|
|
}
|
|
|
|
fmt.Println(string(resJson))
|
|
return nil
|
|
}
|