-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26a2f05
commit deeec7a
Showing
10 changed files
with
265 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package eventsdb | ||
|
||
import "github.com/tendermint/go-amino" | ||
|
||
func RegisterAminoEvents(codec *amino.Codec) { | ||
codec.RegisterInterface((*Event)(nil), nil) | ||
codec.RegisterConcrete(RewardEvent{}, | ||
"minter/RewardEvent", nil) | ||
codec.RegisterConcrete(SlashEvent{}, | ||
"minter/SlashEvent", nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package eventsdb | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/MinterTeam/minter-go-node/core/types" | ||
) | ||
|
||
type Role string | ||
|
||
var ( | ||
RoleValidator Role = "Validator" | ||
RoleDelegator Role = "Delegator" | ||
RoleDAO Role = "DAO" | ||
RoleDevelopers Role = "Developers" | ||
) | ||
|
||
type Event interface{} | ||
type Events []Event | ||
|
||
type RewardEvent struct { | ||
Role Role | ||
Address types.Address | ||
Amount string | ||
ValidatorPubKey types.Pubkey | ||
} | ||
|
||
func (e RewardEvent) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(struct { | ||
Role string `json:"role"` | ||
Address string `json:"address"` | ||
Amount string `json:"amount"` | ||
ValidatorPubKey string `json:"validator_pub_key"` | ||
}{ | ||
Role: string(e.Role), | ||
Address: e.Address.String(), | ||
Amount: e.Amount, | ||
ValidatorPubKey: fmt.Sprintf("Mp%x", e.ValidatorPubKey), | ||
}) | ||
} | ||
|
||
type SlashEvent struct { | ||
Address types.Address | ||
Amount string | ||
Coin types.CoinSymbol | ||
ValidatorPubKey types.Pubkey | ||
} | ||
|
||
func (e SlashEvent) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(struct { | ||
Address string `json:"address"` | ||
Amount string `json:"amount"` | ||
Coin string `json:"coin"` | ||
ValidatorPubKey string `json:"validator_pub_key"` | ||
}{ | ||
Address: e.Address.String(), | ||
Amount: e.Amount, | ||
Coin: e.Coin.String(), | ||
ValidatorPubKey: fmt.Sprintf("Mp%x", e.ValidatorPubKey), | ||
}) | ||
} |
Oops, something went wrong.