gravity_proto/
ethereum_claim.rs

1/// A mirror of the EthereumClaim interface on the Go side
2/// EthereumClaim represents a claim on ethereum state
3pub trait EthereumClaim {
4    /// All Ethereum claims that we relay from the Gravity contract and into the module
5    /// have a nonce that is strictly increasing and unique, since this nonce is
6    /// issued by the Ethereum contract it is immutable and must be agreed on by all validators
7    /// any disagreement on what claim goes to what nonce means someone is lying.
8    fn get_event_nonce(&self) -> u64;
9
10    /// The block height that the claimed event occurred on. This EventNonce provides sufficient
11    /// ordering for the execution of all claims. The block height is used only for batchTimeouts + logicTimeouts
12    /// when we go to create a new batch we set the timeout some number of batches out from the last
13    /// known height plus projected block progress since then.
14    fn get_eth_block_height(&self) -> u64;
15
16    /// the delegate address of the claimer, for MsgDepositClaim and MsgWithdrawClaim
17    /// this is sent in as the sdk.AccAddress of the delegated key. it is up to the user
18    /// to disambiguate this into a sdk.ValAddress
19    ///
20    fn get_claimer(&self) -> String;
21
22    /// Which type of claim this is
23    fn get_type(&self) -> ClaimType;
24
25    /*
26    TODO: Consider implementing ClaimHash, although it should be queryable via a cosmos node
27    fn validate_basic(&self) -> error;
28
29    /// The claim hash of this claim. This is used to store these claims and also used to check if two different
30    /// validators claims agree. Therefore it's extremely important that this include all elements of the claim
31    /// with the exception of the orchestrator who sent it in, which will be used as a different part of the index
32    fn claim_hash(&self) -> Result<Vec<u8>, error>;
33     */
34}
35
36impl ToString for ClaimType {
37    fn to_string(&self) -> String {
38        match self {
39            ClaimType::Unspecified => "CLAIM_TYPE_UNSPECIFIED".to_string(),
40            ClaimType::SendToCosmos => "CLAIM_TYPE_SEND_TO_COSMOS".to_string(),
41            ClaimType::BatchSendToEth => "CLAIM_TYPE_BATCH_SEND_TO_ETH".to_string(),
42            ClaimType::Erc20Deployed => "CLAIM_TYPE_ERC20_DEPLOYED".to_string(),
43            ClaimType::LogicCallExecuted => "CLAIM_TYPE_LOGIC_CALL_EXECUTED".to_string(),
44            ClaimType::ValsetUpdated => "CLAIM_TYPE_VALSET_UPDATED".to_string(),
45        }
46    }
47}
48
49impl EthereumClaim for MsgSendToCosmosClaim {
50    fn get_event_nonce(&self) -> u64 {
51        self.event_nonce
52    }
53
54    fn get_eth_block_height(&self) -> u64 {
55        self.eth_block_height
56    }
57
58    fn get_claimer(&self) -> String {
59        self.orchestrator.clone()
60    }
61
62    fn get_type(&self) -> ClaimType {
63        ClaimType::SendToCosmos
64    }
65}
66impl EthereumClaim for MsgBatchSendToEthClaim {
67    fn get_event_nonce(&self) -> u64 {
68        self.event_nonce
69    }
70
71    fn get_eth_block_height(&self) -> u64 {
72        self.eth_block_height
73    }
74
75    fn get_claimer(&self) -> String {
76        self.orchestrator.clone()
77    }
78
79    fn get_type(&self) -> ClaimType {
80        ClaimType::BatchSendToEth
81    }
82}
83impl EthereumClaim for MsgErc20DeployedClaim {
84    fn get_event_nonce(&self) -> u64 {
85        self.event_nonce
86    }
87
88    fn get_eth_block_height(&self) -> u64 {
89        self.eth_block_height
90    }
91
92    fn get_claimer(&self) -> String {
93        self.orchestrator.clone()
94    }
95
96    fn get_type(&self) -> ClaimType {
97        ClaimType::Erc20Deployed
98    }
99}
100impl EthereumClaim for MsgLogicCallExecutedClaim {
101    fn get_event_nonce(&self) -> u64 {
102        self.event_nonce
103    }
104
105    fn get_eth_block_height(&self) -> u64 {
106        self.eth_block_height
107    }
108
109    fn get_claimer(&self) -> String {
110        self.orchestrator.clone()
111    }
112
113    fn get_type(&self) -> ClaimType {
114        ClaimType::LogicCallExecuted
115    }
116}
117impl EthereumClaim for MsgValsetUpdatedClaim {
118    fn get_event_nonce(&self) -> u64 {
119        self.event_nonce
120    }
121
122    fn get_eth_block_height(&self) -> u64 {
123        self.eth_block_height
124    }
125
126    fn get_claimer(&self) -> String {
127        self.orchestrator.clone()
128    }
129
130    fn get_type(&self) -> ClaimType {
131        ClaimType::ValsetUpdated
132    }
133}