File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,44 @@ export class NamespaceHttp extends Http implements NamespaceRepository {
165165 } ) ) ;
166166 }
167167
168+ /**
169+ * Gets the MosaicId from a MosaicAlias
170+ * @param alias - String containing the address alias
171+ * @returns Observable<MosaicId | null>
172+ */
173+ public getLinkedMosaicId ( alias : string ) : Observable < MosaicId | null > {
174+ return this . getNetworkTypeObservable ( ) . pipe (
175+ mergeMap ( ( networkType ) => observableFrom (
176+ this . namespaceRoutesApi . getNamespace ( alias ) ) . pipe (
177+ map ( ( namespaceInfoDTO ) => {
178+
179+ if ( namespaceInfoDTO . namespace . alias . type === AliasType . Mosaic ) {
180+ return new MosaicId ( namespaceInfoDTO . namespace . alias . mosaicId ) ;
181+ }
182+
183+ return null ;
184+ } ) ) ) ) ;
185+ }
186+
187+ /**
188+ * Gets the Address from a AddressAlias
189+ * @param alias - String containing the address alias
190+ * @returns Observable<Address>
191+ */
192+ public getLinkedAddress ( alias : string ) : Observable < Address | null > {
193+ return this . getNetworkTypeObservable ( ) . pipe (
194+ mergeMap ( ( networkType ) => observableFrom (
195+ this . namespaceRoutesApi . getNamespace ( alias ) ) . pipe (
196+ map ( ( namespaceInfoDTO ) => {
197+
198+ if ( namespaceInfoDTO . namespace . alias . type === AliasType . Address ) {
199+ return Address . createFromRawAddress ( namespaceInfoDTO . namespace . alias . address ) ;
200+ }
201+
202+ return null ;
203+ } ) ) ) ) ;
204+ }
205+
168206 private extractLevels ( namespace : any ) : NamespaceId [ ] {
169207 const result : NamespaceId [ ] = [ ] ;
170208 if ( namespace . level0 ) {
Original file line number Diff line number Diff line change 1717import { Observable } from 'rxjs' ;
1818import { Address } from '../model/account/Address' ;
1919import { PublicAccount } from '../model/account/PublicAccount' ;
20+ import { MosaicId } from '../model/mosaic/MosaicId' ;
2021import { NamespaceId } from '../model/namespace/NamespaceId' ;
2122import { NamespaceInfo } from '../model/namespace/NamespaceInfo' ;
2223import { NamespaceName } from '../model/namespace/NamespaceName' ;
@@ -60,4 +61,18 @@ export interface NamespaceRepository {
6061 * @returns Observable<NamespaceName[]>
6162 */
6263 getNamespacesName ( namespaceIds : NamespaceId [ ] ) : Observable < NamespaceName [ ] > ;
64+
65+ /**
66+ * Gets the MosaicId from a MosaicAlias
67+ * @param alias - String containing the address alias
68+ * @returns Observable<MosaicId | null>
69+ */
70+ getLinkedMosaicId ( alias : string ) : Observable < MosaicId | null > ;
71+
72+ /**
73+ * Gets the Address from a AddressAlias
74+ * @param alias - String containing the address alias
75+ * @returnsObservable <Address | null>
76+ */
77+ getLinkedAddress ( alias : string ) : Observable < Address | null > ;
6378}
You can’t perform that action at this time.
0 commit comments