@@ -119,83 +119,6 @@ fn parse_dpns_usernames_query(
119119 } )
120120}
121121
122- const DEFAULT_DPNS_USERNAMES_LIMIT : u32 = 10 ;
123-
124- fn resolve_dpns_usernames_limit ( limit : Option < u32 > ) -> u32 {
125- match limit {
126- Some ( 0 ) | None => DEFAULT_DPNS_USERNAMES_LIMIT ,
127- Some ( value) => value,
128- }
129- }
130-
131- fn usernames_from_documents ( documents_result : Documents ) -> Array {
132- let usernames_array = Array :: new ( ) ;
133- for ( _, doc_opt) in documents_result {
134- if let Some ( doc) = doc_opt {
135- let properties = doc. properties ( ) ;
136- if let ( Some ( Value :: Text ( label) ) , Some ( Value :: Text ( parent_domain) ) ) = (
137- properties. get ( "label" ) ,
138- properties. get ( "normalizedParentDomainName" ) ,
139- ) {
140- let username = format ! ( "{}.{}" , label, parent_domain) ;
141- usernames_array. push ( & JsValue :: from ( username) ) ;
142- }
143- }
144- }
145- usernames_array
146- }
147-
148- // TS definition for DpnsUsernamesQuery used by getDpnsUsernames*
149- #[ wasm_bindgen( typescript_custom_section) ]
150- const DPNS_USERNAMES_QUERY_TS : & ' static str = r#"
151- /**
152- * Query parameters for retrieving DPNS usernames.
153- */
154- export interface DpnsUsernamesQuery {
155- /**
156- * Identity to fetch usernames for.
157- */
158- identityId: IdentifierLike;
159-
160- /**
161- * Maximum number of usernames to return. Use 0 for default.
162- * @default 10
163- */
164- limit?: number;
165- }
166- "# ;
167-
168- #[ wasm_bindgen]
169- extern "C" {
170- #[ wasm_bindgen( typescript_type = "DpnsUsernamesQuery" ) ]
171- pub type DpnsUsernamesQueryJs ;
172- }
173-
174- #[ derive( Deserialize ) ]
175- #[ serde( rename_all = "camelCase" ) ]
176- struct DpnsUsernamesQueryInput {
177- identity_id : IdentifierWasm ,
178- #[ serde( default ) ]
179- limit : Option < u32 > ,
180- }
181-
182- struct DpnsUsernamesQueryParsed {
183- identity_id : Identifier ,
184- limit : Option < u32 > ,
185- }
186-
187- fn parse_dpns_usernames_query (
188- query : DpnsUsernamesQueryJs ,
189- ) -> Result < DpnsUsernamesQueryParsed , WasmSdkError > {
190- let input: DpnsUsernamesQueryInput =
191- deserialize_required_query ( query, "Query object is required" , "DPNS usernames query" ) ?;
192-
193- Ok ( DpnsUsernamesQueryParsed {
194- identity_id : input. identity_id . into ( ) ,
195- limit : input. limit ,
196- } )
197- }
198-
199122#[ wasm_bindgen( js_name = "DpnsUsernamesProofResponse" ) ]
200123#[ derive( Clone ) ]
201124pub struct DpnsUsernamesProofResponseWasm {
@@ -398,7 +321,10 @@ impl WasmSdk {
398321 }
399322
400323 #[ wasm_bindgen( js_name = "getDpnsUsernameByName" ) ]
401- pub async fn get_dpns_username_by_name ( & self , username : & str ) -> Result < DpnsUsernameInfo , WasmSdkError > {
324+ pub async fn get_dpns_username_by_name (
325+ & self ,
326+ username : & str ,
327+ ) -> Result < DpnsUsernameInfo , WasmSdkError > {
402328 const DPNS_CONTRACT_ID : & str = "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec" ;
403329 const DPNS_DOCUMENT_TYPE : & str = "domain" ;
404330
@@ -521,10 +447,7 @@ impl WasmSdk {
521447 }
522448 }
523449
524- #[ wasm_bindgen(
525- js_name = "getDpnsUsernames" ,
526- unchecked_return_type = "Array<string>"
527- ) ]
450+ #[ wasm_bindgen( js_name = "getDpnsUsernames" , unchecked_return_type = "Array<string>" ) ]
528451 pub async fn get_dpns_usernames (
529452 & self ,
530453 query : DpnsUsernamesQueryJs ,
0 commit comments