-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4187c33
commit dead656
Showing
4 changed files
with
108 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,41 @@ | ||
use cosmwasm_schema::cw_serde; | ||
use cosmwasm_std::Addr; | ||
use cw_storage_plus::{Item, Map}; | ||
|
||
use cw_storage_plus::{Index, IndexList, IndexedMap, Item, MultiIndex}; | ||
pub type SocialInfo = (Platform, ProfileId); | ||
pub type Platform = String; | ||
pub type ProfileId = String; | ||
pub const SOCIAL_TO_ADDRESS: Map<SocialInfo, Addr> = Map::new("social_to_address"); | ||
pub const ADDRESS_TO_SOCIAL: Map<Addr, SocialInfo> = Map::new("wallet_to_social"); | ||
pub struct InfoIndexes<'a> { | ||
pub address: MultiIndex<'a, Addr, UserInfo, String>, | ||
pub social_info: MultiIndex<'a, (String, String), UserInfo, String>, | ||
} | ||
impl<'a> IndexList<UserInfo> for InfoIndexes<'a> { | ||
fn get_indexes(&'_ self) -> Box<dyn Iterator<Item = &'_ dyn Index<UserInfo>> + '_> { | ||
let v: Vec<&dyn Index<UserInfo>> = vec![&self.address, &self.social_info]; | ||
Box::new(v.into_iter()) | ||
} | ||
} | ||
pub const fn infos<'a>() -> IndexedMap<'a, &'a str, UserInfo, InfoIndexes<'a>> { | ||
let indexes = InfoIndexes { | ||
address: MultiIndex::new( | ||
|_pk: &[u8], d: &UserInfo| d.address.clone(), | ||
"infos", | ||
"infos__address", | ||
), | ||
social_info: MultiIndex::new( | ||
|_pk: &[u8], d: &UserInfo| (d.platform_id.clone(), d.profile_id.clone()), | ||
"infos", | ||
"infos__social_info", | ||
), | ||
}; | ||
IndexedMap::new("infos", indexes) | ||
} | ||
#[cw_serde] | ||
pub struct UserInfo { | ||
pub address: Addr, | ||
pub platform_id: String, | ||
pub profile_id: String, | ||
} | ||
pub const USER_INFOS: IndexedMap<&str, UserInfo, InfoIndexes> = infos(); | ||
|
||
pub const OWNER: Item<Addr> = Item::new("owner"); | ||
pub const ACCEPTED_TOKEN: Item<Vec<String>> = Item::new("accepted_token"); | ||
|