github.com/ethxdao/go-ethereum@v0.0.0-20221218102228-5ae34a9cc189/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/ethxdao/go-ethereum/common"
    23  )
    24  
    25  var commandStatus = &cli.Command{
    26  	Name:  "status",
    27  	Usage: "Fetches the signers and checkpoint status of the oracle contract",
    28  	Flags: []cli.Flag{
    29  		nodeURLFlag,
    30  	},
    31  	Action: status,
    32  }
    33  
    34  // status fetches the admin list of specified registrar contract.
    35  func status(ctx *cli.Context) error {
    36  	// Create a wrapper around the checkpoint oracle contract
    37  	addr, oracle := newContract(newRPCClient(ctx.String(nodeURLFlag.Name)))
    38  	fmt.Printf("Oracle => %s\n", addr.Hex())
    39  	fmt.Println()
    40  
    41  	// Retrieve the list of authorized signers (admins)
    42  	admins, err := oracle.Contract().GetAllAdmin(nil)
    43  	if err != nil {
    44  		return err
    45  	}
    46  	for i, admin := range admins {
    47  		fmt.Printf("Admin %d => %s\n", i+1, admin.Hex())
    48  	}
    49  	fmt.Println()
    50  
    51  	// Retrieve the latest checkpoint
    52  	index, checkpoint, height, err := oracle.Contract().GetLatestCheckpoint(nil)
    53  	if err != nil {
    54  		return err
    55  	}
    56  	fmt.Printf("Checkpoint (published at #%d) %d => %s\n", height, index, common.Hash(checkpoint).Hex())
    57  
    58  	return nil
    59  }