diff --git a/contract/src/lib.rs b/contract/src/lib.rs index 3121b690f..1dd6a6b16 100644 --- a/contract/src/lib.rs +++ b/contract/src/lib.rs @@ -5,6 +5,7 @@ use near_sdk::collections::LookupMap; use near_sdk::log; use near_sdk::serde::{Deserialize, Serialize}; use near_sdk::{env, near_bindgen, AccountId, PanicOnDefault, Promise, PromiseOrValue, PublicKey}; +use primitives::ParticipantInfo; use primitives::{CandidateInfo, Candidates, Participants, PkVotes, Votes}; use std::collections::{BTreeMap, HashSet}; @@ -74,6 +75,37 @@ impl MpcContract { } } + // This function can be used to transfer the MPC network to a new contract. + #[init] + pub fn init_running( + epoch: u64, + participants: BTreeMap, + threshold: usize, + public_key: PublicKey, + ) -> Self { + log!( + "init_running: signer={}, epoch={}, participants={}, threshold={}, public_key={:?}", + env::signer_account_id(), + epoch, + serde_json::to_string(&participants).unwrap(), + threshold, + public_key + ); + MpcContract { + protocol_state: ProtocolContractState::Running(RunningContractState { + epoch, + participants: Participants { participants }, + threshold, + public_key, + candidates: Candidates::new(), + join_votes: Votes::new(), + leave_votes: Votes::new(), + }), + pending_requests: LookupMap::new(b"m"), + request_counter: 0, + } + } + pub fn state(self) -> ProtocolContractState { self.protocol_state }