status.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. package main
  17. import (
  18. "fmt"
  19. "github.com/ethereum/go-ethereum/cmd/utils"
  20. "github.com/ethereum/go-ethereum/common"
  21. "gopkg.in/urfave/cli.v1"
  22. )
  23. var commandStatus = cli.Command{
  24. Name: "status",
  25. Usage: "Fetches the signers and checkpoint status of the oracle contract",
  26. Flags: []cli.Flag{
  27. nodeURLFlag,
  28. },
  29. Action: utils.MigrateFlags(status),
  30. }
  31. // status fetches the admin list of specified registrar contract.
  32. func status(ctx *cli.Context) error {
  33. // Create a wrapper around the checkpoint oracle contract
  34. addr, oracle := newContract(newRPCClient(ctx.GlobalString(nodeURLFlag.Name)))
  35. fmt.Printf("Oracle => %s\n", addr.Hex())
  36. fmt.Println()
  37. // Retrieve the list of authorized signers (admins)
  38. admins, err := oracle.Contract().GetAllAdmin(nil)
  39. if err != nil {
  40. return err
  41. }
  42. for i, admin := range admins {
  43. fmt.Printf("Admin %d => %s\n", i+1, admin.Hex())
  44. }
  45. fmt.Println()
  46. // Retrieve the latest checkpoint
  47. index, checkpoint, height, err := oracle.Contract().GetLatestCheckpoint(nil)
  48. if err != nil {
  49. return err
  50. }
  51. fmt.Printf("Checkpoint (published at #%d) %d => %s\n", height, index, common.Hash(checkpoint).Hex())
  52. return nil
  53. }