-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SG-975] Adds queries for text records and Twitter verification (#249)
* Query name text records * Add test * Add helper * Is twitter verified helper * Add twitter verified query * Update types
- Loading branch information
Showing
9 changed files
with
223 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::msg::QueryMsg; | ||
use cosmwasm_schema::cw_serde; | ||
use cosmwasm_std::{to_binary, Addr, QuerierWrapper, QueryRequest, StdResult, WasmQuery}; | ||
use sg_name::{TextRecord, NFT}; | ||
|
||
/// NameCollectionContract is a wrapper around Addr that provides a lot of helpers | ||
#[cw_serde] | ||
pub struct NameCollectionContract(pub Addr); | ||
|
||
impl NameCollectionContract { | ||
pub fn addr(&self) -> Addr { | ||
self.0.clone() | ||
} | ||
|
||
pub fn image_nft(&self, querier: &QuerierWrapper, name: &str) -> StdResult<Option<NFT>> { | ||
let res: Option<NFT> = querier.query(&QueryRequest::Wasm(WasmQuery::Smart { | ||
contract_addr: self.addr().into(), | ||
msg: to_binary(&QueryMsg::ImageNFT { | ||
name: name.to_string(), | ||
})?, | ||
}))?; | ||
|
||
Ok(res) | ||
} | ||
|
||
pub fn text_records(&self, querier: &QuerierWrapper, name: &str) -> StdResult<Vec<TextRecord>> { | ||
let res: Vec<TextRecord> = querier.query(&QueryRequest::Wasm(WasmQuery::Smart { | ||
contract_addr: self.addr().into(), | ||
msg: to_binary(&QueryMsg::TextRecords { | ||
name: name.to_string(), | ||
})?, | ||
}))?; | ||
|
||
Ok(res) | ||
} | ||
|
||
pub fn is_twitter_verified(&self, querier: &QuerierWrapper, name: &str) -> StdResult<bool> { | ||
let res: bool = querier.query(&QueryRequest::Wasm(WasmQuery::Smart { | ||
contract_addr: self.addr().into(), | ||
msg: to_binary(&QueryMsg::IsTwitterVerified { | ||
name: name.to_string(), | ||
})?, | ||
}))?; | ||
|
||
Ok(res) | ||
} | ||
} |
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
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