1414 * limitations under the License.
1515 */
1616
17- import { AccountRoutesApi } from 'nem2-library' ;
1817import { from as observableFrom , Observable } from 'rxjs' ;
1918import { map , mergeMap } from 'rxjs/operators' ;
2019import { DtoMapping } from '../core/utils/DtoMapping' ;
@@ -33,6 +32,7 @@ import {AggregateTransaction} from '../model/transaction/AggregateTransaction';
3332import { Transaction } from '../model/transaction/Transaction' ;
3433import { UInt64 } from '../model/UInt64' ;
3534import { AccountRepository } from './AccountRepository' ;
35+ import * as api from './ApiClient' ;
3636import { Http } from './Http' ;
3737import { NetworkHttp } from './NetworkHttp' ;
3838import { QueryParams } from './QueryParams' ;
@@ -48,7 +48,7 @@ export class AccountHttp extends Http implements AccountRepository {
4848 * @internal
4949 * Nem2 Library account routes api
5050 */
51- private accountRoutesApi : AccountRoutesApi ;
51+ private accountRoutesApi : api . AccountRoutesApi ;
5252
5353 /**
5454 * Constructor
@@ -57,8 +57,8 @@ export class AccountHttp extends Http implements AccountRepository {
5757 */
5858 constructor ( url : string , networkHttp ?: NetworkHttp ) {
5959 networkHttp = networkHttp == null ? new NetworkHttp ( url ) : networkHttp ;
60- super ( url , networkHttp ) ;
61- this . accountRoutesApi = new AccountRoutesApi ( this . apiClient ) ;
60+ super ( networkHttp ) ;
61+ this . accountRoutesApi = new api . AccountRoutesApi ( url ) ;
6262 }
6363
6464 /**
@@ -67,7 +67,7 @@ export class AccountHttp extends Http implements AccountRepository {
6767 * @returns Observable<AccountInfo>
6868 */
6969 public getAccountInfo ( address : Address ) : Observable < AccountInfo > {
70- return observableFrom ( this . accountRoutesApi . getAccountInfo ( address . plain ( ) ) ) . pipe ( map ( ( accountInfoDTO ) => {
70+ return observableFrom ( this . accountRoutesApi . getAccountInfo ( address . plain ( ) ) ) . pipe ( map ( ( accountInfoDTO : api . AccountInfoDTO ) => {
7171 return new AccountInfo (
7272 accountInfoDTO . meta ,
7373 Address . createFromEncoded ( accountInfoDTO . account . address ) ,
@@ -90,7 +90,8 @@ export class AccountHttp extends Http implements AccountRepository {
9090 * @returns Observable<AccountProperty>
9191 */
9292 public getAccountProperties ( address : Address ) : Observable < AccountPropertiesInfo > {
93- return observableFrom ( this . accountRoutesApi . getAccountProperties ( address . plain ( ) ) ) . pipe ( map ( ( accountProperties ) => {
93+ return observableFrom ( this . accountRoutesApi . getAccountProperties ( address . plain ( ) ) )
94+ . pipe ( map ( ( accountProperties : api . AccountPropertiesInfoDTO ) => {
9495 return DtoMapping . extractAccountPropertyFromDto ( accountProperties ) ;
9596 } ) ) ;
9697 }
@@ -105,7 +106,8 @@ export class AccountHttp extends Http implements AccountRepository {
105106 addresses : addresses . map ( ( address ) => address . plain ( ) ) ,
106107 } ;
107108 return observableFrom (
108- this . accountRoutesApi . getAccountPropertiesFromAccounts ( accountIds ) ) . pipe ( map ( ( accountProperties ) => {
109+ this . accountRoutesApi . getAccountPropertiesFromAccounts ( accountIds ) )
110+ . pipe ( map ( ( accountProperties : api . AccountPropertiesDTO [ ] ) => {
109111 return accountProperties . map ( ( property ) => {
110112 return DtoMapping . extractAccountPropertyFromDto ( property ) ;
111113 } ) ;
@@ -122,15 +124,16 @@ export class AccountHttp extends Http implements AccountRepository {
122124 addresses : addresses . map ( ( address ) => address . plain ( ) ) ,
123125 } ;
124126 return observableFrom (
125- this . accountRoutesApi . getAccountsInfo ( accountIdsBody ) ) . pipe ( map ( ( accountsInfoMetaDataDTO ) => {
126- return accountsInfoMetaDataDTO . map ( ( accountInfoDTO ) => {
127+ this . accountRoutesApi . getAccountsInfo ( accountIdsBody ) ) . pipe ( map ( ( accountsInfoMetaDataDTO : api . AccountInfoDTO [ ] ) => {
128+ return accountsInfoMetaDataDTO . map ( ( accountInfoDTO : api . AccountInfoDTO ) => {
127129 return new AccountInfo (
128130 accountInfoDTO . meta ,
129131 Address . createFromEncoded ( accountInfoDTO . account . address ) ,
130132 new UInt64 ( accountInfoDTO . account . addressHeight ) ,
131133 accountInfoDTO . account . publicKey ,
132134 new UInt64 ( accountInfoDTO . account . publicKeyHeight ) ,
133- accountInfoDTO . account . mosaics . map ( ( mosaicDTO ) => new Mosaic ( mosaicDTO . id , mosaicDTO . amount ) ) ,
135+ accountInfoDTO . account . mosaics . map ( ( mosaicDTO : api . MosaicDTO ) =>
136+ new Mosaic ( new MosaicId ( mosaicDTO . id ) , new UInt64 ( mosaicDTO . amount ) ) ) ,
134137 new UInt64 ( accountInfoDTO . account . importance ) ,
135138 new UInt64 ( accountInfoDTO . account . importanceHeight ) ,
136139 ) ;
@@ -143,12 +146,12 @@ export class AccountHttp extends Http implements AccountRepository {
143146 addresses : addresses . map ( ( address ) => address . plain ( ) ) ,
144147 } ;
145148 return observableFrom (
146- this . accountRoutesApi . getAccountsNames ( accountIdsBody ) ) . pipe ( map ( ( accountNames ) => {
149+ this . accountRoutesApi . getAccountsNames ( accountIdsBody ) ) . pipe ( map ( ( accountNames : api . AccountNamesDTO [ ] ) => {
147150 return accountNames . map ( ( accountName ) => {
148151 return new AccountNames (
149152 Address . createFromEncoded ( accountName . address ) ,
150153 accountName . names . map ( ( name ) => {
151- new NamespaceName ( new NamespaceId ( name ) , name ) ;
154+ return new NamespaceName ( new NamespaceId ( name ) , name ) ;
152155 } ) ,
153156 ) ;
154157 } ) ;
@@ -162,7 +165,8 @@ export class AccountHttp extends Http implements AccountRepository {
162165 public getMultisigAccountInfo ( address : Address ) : Observable < MultisigAccountInfo > {
163166 return this . getNetworkTypeObservable ( ) . pipe (
164167 mergeMap ( ( networkType ) => observableFrom (
165- this . accountRoutesApi . getAccountMultisig ( address . plain ( ) ) ) . pipe ( map ( ( multisigAccountInfoDTO ) => {
168+ this . accountRoutesApi . getAccountMultisig ( address . plain ( ) ) )
169+ . pipe ( map ( ( multisigAccountInfoDTO : api . MultisigAccountInfoDTO ) => {
166170 return new MultisigAccountInfo (
167171 PublicAccount . createFromPublicKey ( multisigAccountInfoDTO . multisig . account , networkType ) ,
168172 multisigAccountInfoDTO . multisig . minApproval ,
@@ -183,7 +187,8 @@ export class AccountHttp extends Http implements AccountRepository {
183187 public getMultisigAccountGraphInfo ( address : Address ) : Observable < MultisigAccountGraphInfo > {
184188 return this . getNetworkTypeObservable ( ) . pipe (
185189 mergeMap ( ( networkType ) => observableFrom (
186- this . accountRoutesApi . getAccountMultisigGraph ( address . plain ( ) ) ) . pipe ( map ( ( multisigAccountGraphInfosDTO ) => {
190+ this . accountRoutesApi . getAccountMultisigGraph ( address . plain ( ) ) )
191+ . pipe ( map ( ( multisigAccountGraphInfosDTO : api . MultisigAccountGraphInfoDTO [ ] ) => {
187192 const multisigAccounts = new Map < number , MultisigAccountInfo [ ] > ( ) ;
188193 multisigAccountGraphInfosDTO . map ( ( multisigAccountGraphInfoDTO ) => {
189194 multisigAccounts . set ( multisigAccountGraphInfoDTO . level ,
@@ -211,8 +216,11 @@ export class AccountHttp extends Http implements AccountRepository {
211216 */
212217 public transactions ( publicAccount : PublicAccount , queryParams ?: QueryParams ) : Observable < Transaction [ ] > {
213218 return observableFrom (
214- this . accountRoutesApi . transactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
215- map ( ( transactionsDTO ) => {
219+ this . accountRoutesApi . transactions ( publicAccount . publicKey ,
220+ this . queryParams ( queryParams ) . pageSize ,
221+ this . queryParams ( queryParams ) . id ,
222+ this . queryParams ( queryParams ) . order ) ) . pipe (
223+ map ( ( transactionsDTO : api . TransactionInfoDTO [ ] ) => {
216224 return transactionsDTO . map ( ( transactionDTO ) => {
217225 return CreateTransactionFromDTO ( transactionDTO ) ;
218226 } ) ;
@@ -228,8 +236,11 @@ export class AccountHttp extends Http implements AccountRepository {
228236 */
229237 public incomingTransactions ( publicAccount : PublicAccount , queryParams ?: QueryParams ) : Observable < Transaction [ ] > {
230238 return observableFrom (
231- this . accountRoutesApi . incomingTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
232- map ( ( transactionsDTO ) => {
239+ this . accountRoutesApi . incomingTransactions ( publicAccount . publicKey ,
240+ this . queryParams ( queryParams ) . pageSize ,
241+ this . queryParams ( queryParams ) . id ,
242+ this . queryParams ( queryParams ) . order ) ) . pipe (
243+ map ( ( transactionsDTO : api . TransactionInfoDTO [ ] ) => {
233244 return transactionsDTO . map ( ( transactionDTO ) => {
234245 return CreateTransactionFromDTO ( transactionDTO ) ;
235246 } ) ;
@@ -245,8 +256,11 @@ export class AccountHttp extends Http implements AccountRepository {
245256 */
246257 public outgoingTransactions ( publicAccount : PublicAccount , queryParams ?: QueryParams ) : Observable < Transaction [ ] > {
247258 return observableFrom (
248- this . accountRoutesApi . outgoingTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
249- map ( ( transactionsDTO ) => {
259+ this . accountRoutesApi . outgoingTransactions ( publicAccount . publicKey ,
260+ this . queryParams ( queryParams ) . pageSize ,
261+ this . queryParams ( queryParams ) . id ,
262+ this . queryParams ( queryParams ) . order ) ) . pipe (
263+ map ( ( transactionsDTO : api . TransactionInfoDTO [ ] ) => {
250264 return transactionsDTO . map ( ( transactionDTO ) => {
251265 return CreateTransactionFromDTO ( transactionDTO ) ;
252266 } ) ;
@@ -263,8 +277,11 @@ export class AccountHttp extends Http implements AccountRepository {
263277 */
264278 public unconfirmedTransactions ( publicAccount : PublicAccount , queryParams ?: QueryParams ) : Observable < Transaction [ ] > {
265279 return observableFrom (
266- this . accountRoutesApi . unconfirmedTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
267- map ( ( transactionsDTO ) => {
280+ this . accountRoutesApi . unconfirmedTransactions ( publicAccount . publicKey ,
281+ this . queryParams ( queryParams ) . pageSize ,
282+ this . queryParams ( queryParams ) . id ,
283+ this . queryParams ( queryParams ) . order ) ) . pipe (
284+ map ( ( transactionsDTO : api . TransactionInfoDTO [ ] ) => {
268285 return transactionsDTO . map ( ( transactionDTO ) => {
269286 return CreateTransactionFromDTO ( transactionDTO ) ;
270287 } ) ;
@@ -280,8 +297,11 @@ export class AccountHttp extends Http implements AccountRepository {
280297 */
281298 public aggregateBondedTransactions ( publicAccount : PublicAccount , queryParams ?: QueryParams ) : Observable < AggregateTransaction [ ] > {
282299 return observableFrom (
283- this . accountRoutesApi . partialTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
284- map ( ( transactionsDTO ) => {
300+ this . accountRoutesApi . partialTransactions ( publicAccount . publicKey ,
301+ this . queryParams ( queryParams ) . pageSize ,
302+ this . queryParams ( queryParams ) . id ,
303+ this . queryParams ( queryParams ) . order ) ) . pipe (
304+ map ( ( transactionsDTO : api . TransactionInfoDTO [ ] ) => {
285305 return transactionsDTO . map ( ( transactionDTO ) => {
286306 return CreateTransactionFromDTO ( transactionDTO ) as AggregateTransaction ;
287307 } ) ;
0 commit comments