status.go 1.8 KB

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