You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.7 KiB

  1. package types
  2. import (
  3. "time"
  4. acm "github.com/tendermint/tendermint/account"
  5. . "github.com/tendermint/tendermint/common"
  6. ptypes "github.com/tendermint/tendermint/permission/types"
  7. "github.com/tendermint/tendermint/wire"
  8. )
  9. //------------------------------------------------------------
  10. // we store the gendoc in the db
  11. var GenDocKey = []byte("GenDocKey")
  12. //------------------------------------------------------------
  13. // core types for a genesis definition
  14. type BasicAccount struct {
  15. Address []byte `json:"address"`
  16. Amount int64 `json:"amount"`
  17. }
  18. type GenesisAccount struct {
  19. Address []byte `json:"address"`
  20. Amount int64 `json:"amount"`
  21. Name string `json:"name"`
  22. Permissions *ptypes.AccountPermissions `json:"permissions"`
  23. }
  24. type GenesisValidator struct {
  25. PubKey acm.PubKeyEd25519 `json:"pub_key"`
  26. Amount int64 `json:"amount"`
  27. Name string `json:"name"`
  28. UnbondTo []BasicAccount `json:"unbond_to"`
  29. }
  30. type GenesisParams struct {
  31. GlobalPermissions *ptypes.AccountPermissions `json:"global_permissions"`
  32. }
  33. type GenesisDoc struct {
  34. GenesisTime time.Time `json:"genesis_time"`
  35. ChainID string `json:"chain_id"`
  36. Params *GenesisParams `json:"params"`
  37. Accounts []GenesisAccount `json:"accounts"`
  38. Validators []GenesisValidator `json:"validators"`
  39. }
  40. //------------------------------------------------------------
  41. // Make genesis state from file
  42. func GenesisDocFromJSON(jsonBlob []byte) (genState *GenesisDoc) {
  43. var err error
  44. wire.ReadJSONPtr(&genState, jsonBlob, &err)
  45. if err != nil {
  46. Exit(Fmt("Couldn't read GenesisDoc: %v", err))
  47. }
  48. return
  49. }