11use std:: path:: { Path , PathBuf } ;
22
3- use near_mpc_contract_interface:: types:: { Keyset , ProtocolContractState } ;
3+ use near_mpc_contract_interface:: types:: ProtocolContractState ;
44use tokio:: fs:: File ;
55use tokio:: io:: AsyncReadExt ;
66
7- use crate :: ports:: ContractStateReader ;
7+ use crate :: ports:: ReadContractState ;
88
99const CONTRACT_STATE_FILENAME : & str = "contract_state.json" ;
1010
@@ -18,9 +18,6 @@ pub enum Error {
1818
1919 #[ error( "failed to deserialize secrets" ) ]
2020 JsonDeserialization ( serde_json:: Error ) ,
21-
22- #[ error( "incorrect contract state: {0}" ) ]
23- IncorrectContractState ( String ) ,
2421}
2522
2623pub struct ContractStateFixture {
@@ -36,7 +33,7 @@ impl ContractStateFixture {
3633 }
3734}
3835
39- impl ContractStateReader for ContractStateFixture {
36+ impl ReadContractState for ContractStateFixture {
4037 type Error = Error ;
4138
4239 async fn get_contract_state ( & self ) -> Result < ProtocolContractState , Self :: Error > {
@@ -53,33 +50,13 @@ impl ContractStateReader for ContractStateFixture {
5350 }
5451}
5552
56- pub fn get_keyset_from_contract_state (
57- contract_state : & ProtocolContractState ,
58- ) -> Result < Keyset , Error > {
59- match contract_state {
60- ProtocolContractState :: NotInitialized => {
61- Err ( Error :: IncorrectContractState ( "NotInitialized" . to_string ( ) ) )
62- }
63- ProtocolContractState :: Resharing ( _) => {
64- Err ( Error :: IncorrectContractState ( "Resharing" . to_string ( ) ) )
65- }
66- ProtocolContractState :: Initializing ( state) => Ok ( Keyset {
67- epoch_id : state. epoch_id ,
68- domains : state. generated_keys . clone ( ) ,
69- } ) ,
70- ProtocolContractState :: Running ( state) => Ok ( state. keyset . clone ( ) ) ,
71- }
72- }
73-
7453#[ cfg( test) ]
7554mod tests {
7655 use std:: path:: PathBuf ;
7756
7857 use near_mpc_contract_interface:: types:: { GovernanceThreshold , ProtocolContractState } ;
7958
80- use crate :: {
81- adapters:: contract_state_fixture:: ContractStateFixture , ports:: ContractStateReader ,
82- } ;
59+ use crate :: { adapters:: contract_state_fixture:: ContractStateFixture , ports:: ReadContractState } ;
8360
8461 pub const TEST_CONTRACT_STATE_PATH : & str = "assets/" ;
8562 #[ tokio:: test]
0 commit comments