-
Notifications
You must be signed in to change notification settings - Fork 0
/
callback_msgs.go
63 lines (53 loc) · 2.5 KB
/
callback_msgs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package contract
import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
)
// FuryaSudoMsg callback message sent to a contract.
// See https://github.com/furyanrasta/furya-contracts/blob/main/packages/bindings/src/sudo.rs
type FuryaSudoMsg struct {
PrivilegeChange *PrivilegeChangeMsg `json:"privilege_change,omitempty"`
BeginBlock *BeginBlock `json:"begin_block,omitempty"`
// This will be delivered every block if the contract is currently registered for End Block
// Block height and time is already in Env
EndBlock *struct{} `json:"end_block,omitempty"`
// This will be delivered after everything.
// The data in the Response is (JSON?) encoded diff to the validator set
EndWithValidatorUpdate *struct{} `json:"end_with_validator_update,omitempty"`
// Export dump state for genesis export
Export *struct{} `json:"export,omitempty"`
// Import genesis state
Import *wasmtypes.RawContractMessage `json:"import,omitempty"`
}
// PrivilegeChangeMsg is called on a contract when it is made privileged or demoted
type PrivilegeChangeMsg struct {
/// This is called when a contract gets "privileged status".
/// It is a proper place to call `RegisterXXX` methods that require this status.
/// Contracts that require this should be in a "frozen" state until they get this callback.
Promoted *struct{} `json:"promoted,omitempty"`
/// This is called when a contract looses "privileged status"
Demoted *struct{} `json:"demoted,omitempty"`
}
// BeginBlock is delivered every block if the contract is currently registered for Begin Block
type BeginBlock struct {
Evidence []Evidence `json:"evidence"` // This is key for slashing - let's figure out a standard for these types
}
type EvidenceType string
const (
EvidenceDuplicateVote EvidenceType = "duplicate_vote"
EvidenceLightClientAttack EvidenceType = "light_client_attack"
)
// Evidence See https://github.com/tendermint/tendermint/blob/v0.34.8/proto/tendermint/abci/types.proto#L354-L375
type Evidence struct {
EvidenceType EvidenceType `json:"evidence_type"`
Validator Validator `json:"validator"`
Height uint64 `json:"height"`
// the time when the offense occurred (in nanosec UNIX time, like env.block.time)
Time uint64 `json:"time"`
TotalVotingPower uint64 `json:"total_voting_power"`
}
// Validator See https://github.com/tendermint/tendermint/blob/v0.34.8/proto/tendermint/abci/types.proto#L336-L340
type Validator struct {
// The first 20 bytes of SHA256(public key)
Address []byte `json:"address"`
Power uint64 `json:"power"`
}