github.com/Cleverse/go-ethereum@v0.0.0-20220927095127-45113064e7f2/cmd/checkpoint-admin/status.go (about)

     1  // Copyright 2019 The go-ethereum Authors
     2  // This file is part of go-ethereum.
     3  //
     4  // go-ethereum is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // go-ethereum is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU General Public License
    15  // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package main
    18  
    19  import (
    20  	"fmt"
    21  
    22  	"github.com/ethereum/go-ethereum/common"
    23  	"github.com/urfave/cli/v2"
    24  )
    25  
    26  var commandStatus = &cli.Command{
    27  	Name:  "status",
    28  	Usage: "Fetches the signers and checkpoint status of the oracle contract",
    29  	Flags: []cli.Flag{
    30  		nodeURLFlag,
    31  	},
    32  	Action: status,
    33  }
    34  
    35  // status fetches the admin list of specified registrar contract.
    36  func status(ctx *cli.Context) error {
    37  	// Create a wrapper around the checkpoint oracle contract
    38  	addr, oracle := newContract(newRPCClient(ctx.String(nodeURLFlag.Name)))
    39  	fmt.Printf("Oracle => %s\n", addr.Hex())
    40  	fmt.Println()
    41  
    42  	// Retrieve the list of authorized signers (admins)
    43  	admins, err := oracle.Contract().GetAllAdmin(nil)
    44  	if err != nil {
    45  		return err
    46  	}
    47  	for i, admin := range admins {
    48  		fmt.Printf("Admin %d => %s\n", i+1, admin.Hex())
    49  	}
    50  	fmt.Println()
    51  
    52  	// Retrieve the latest checkpoint
    53  	index, checkpoint, height, err := oracle.Contract().GetLatestCheckpoint(nil)
    54  	if err != nil {
    55  		return err
    56  	}
    57  	fmt.Printf("Checkpoint (published at #%d) %d => %s\n", height, index, common.Hash(checkpoint).Hex())
    58  
    59  	return nil
    60  }