Skip to content

Commit

Permalink
Merge pull request #608 from near/xiangyi/BorshStorageKey
Browse files Browse the repository at this point in the history
use BorshStorageKey for the prefix of LookupMap for pending_requests
  • Loading branch information
volovyks authored May 27, 2024
2 parents 1e4a743 + a5e91f0 commit 653f4e1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ pub mod primitives;
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::LookupMap;
use near_sdk::serde::{Deserialize, Serialize};
use near_sdk::{env, near_bindgen, AccountId, Promise, PromiseOrValue, PublicKey};
use near_sdk::{log, Gas};
use near_sdk::{
env, log, near_bindgen, AccountId, BorshStorageKey, Gas, Promise, PromiseOrValue, PublicKey,
};
use primitives::{CandidateInfo, Candidates, ParticipantInfo, Participants, PkVotes, Votes};
use std::collections::{BTreeMap, HashSet};

Expand Down Expand Up @@ -47,6 +48,11 @@ pub enum ProtocolContractState {
Resharing(ResharingContractState),
}

#[derive(BorshSerialize, BorshDeserialize, BorshStorageKey, Hash, Clone, Debug, PartialEq, Eq)]
pub enum StorageKey {
PendingRequests,
}

#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, Debug)]
pub enum VersionedMpcContract {
Expand Down Expand Up @@ -103,7 +109,7 @@ impl MpcContract {
threshold,
pk_votes: PkVotes::new(),
}),
pending_requests: LookupMap::new(b"m"),
pending_requests: LookupMap::new(StorageKey::PendingRequests),
request_counter: 0,
}
}
Expand Down Expand Up @@ -527,7 +533,7 @@ impl VersionedMpcContract {
}
Self::V0(MpcContract {
protocol_state: ProtocolContractState::NotInitialized,
pending_requests: LookupMap::new(b"m"),
pending_requests: LookupMap::new(StorageKey::PendingRequests),
request_counter: 0,
})
}
Expand Down

0 comments on commit 653f4e1

Please sign in to comment.