From bf9aba7c0efd518e7edfb923d05334e40ca3db9a Mon Sep 17 00:00:00 2001 From: Greg S Date: Tue, 12 Mar 2019 12:52:13 +0100 Subject: [PATCH 1/3] issue #82: Fixed MosaicService to pass single MosaicInfo object instead of array --- src/service/MosaicService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service/MosaicService.ts b/src/service/MosaicService.ts index 805cd3a255..5abd1486a6 100644 --- a/src/service/MosaicService.ts +++ b/src/service/MosaicService.ts @@ -68,7 +68,7 @@ export class MosaicService { mergeMap((mosaic: Mosaic) => this.mosaicsView([mosaic.id]).pipe( filter((_) => _.length !== 0), map((mosaicViews) => { - return new MosaicAmountView(mosaicViews[0].mosaicInfo, mosaic.amount); + return new MosaicAmountView(mosaicViews[0].mosaicInfo[0], mosaic.amount); }), toArray()))); } From b6aa399258c8fd388967f07e2027fa884d399847 Mon Sep 17 00:00:00 2001 From: Greg S Date: Tue, 12 Mar 2019 14:36:27 +0100 Subject: [PATCH 2/3] issue #82: removed namespaceHttp dependency injection --- e2e/service/MosaicService.spec.ts | 2 -- src/service/MosaicService.ts | 4 +--- test/service/MosaicService.spec.ts | 11 +++++------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/e2e/service/MosaicService.spec.ts b/e2e/service/MosaicService.spec.ts index c59f39b30f..398ec7cb31 100644 --- a/e2e/service/MosaicService.spec.ts +++ b/e2e/service/MosaicService.spec.ts @@ -1,7 +1,6 @@ import { map, mergeMap, toArray } from 'rxjs/operators'; import { AccountHttp } from '../../src/infrastructure/AccountHttp'; import { MosaicHttp } from '../../src/infrastructure/MosaicHttp'; -import { NamespaceHttp } from '../../src/infrastructure/NamespaceHttp'; import { Address } from '../../src/model/account/Address'; import { MosaicService } from '../../src/service/MosaicService'; import { APIUrl } from '../conf/conf.spec'; @@ -12,7 +11,6 @@ describe('MosaicService', () => { const mosaicService = new MosaicService( new AccountHttp(APIUrl), new MosaicHttp(APIUrl), - new NamespaceHttp(APIUrl), ); const address = Address.createFromRawAddress('SCO2JY-N6OJSM-CJPPVS-Z3OX7P-TWPQEJ-GZTI6W-GLKK'); diff --git a/src/service/MosaicService.ts b/src/service/MosaicService.ts index 5abd1486a6..ed14e8fd40 100644 --- a/src/service/MosaicService.ts +++ b/src/service/MosaicService.ts @@ -35,11 +35,9 @@ export class MosaicService { * Constructor * @param accountHttp * @param mosaicHttp - * @param namespaceHttp */ constructor(private readonly accountHttp: AccountHttp, - private readonly mosaicHttp: MosaicHttp, - private readonly namespaceHttp: NamespaceHttp) { + private readonly mosaicHttp: MosaicHttp) { } diff --git a/test/service/MosaicService.spec.ts b/test/service/MosaicService.spec.ts index b4cda237c1..6508e006e5 100644 --- a/test/service/MosaicService.spec.ts +++ b/test/service/MosaicService.spec.ts @@ -17,7 +17,6 @@ import {expect} from 'chai'; import {AccountHttp} from '../../src/infrastructure/AccountHttp'; import {MosaicHttp} from '../../src/infrastructure/MosaicHttp'; -import {NamespaceHttp} from '../../src/infrastructure/NamespaceHttp'; import {Address} from '../../src/model/account/Address'; import {Mosaic} from '../../src/model/mosaic/Mosaic'; import {MosaicId} from '../../src/model/mosaic/MosaicId'; @@ -32,7 +31,7 @@ describe('MosaicService', () => { it('mosaicsView', () => { const mosaicId = new MosaicId([3294802500, 2243684972]); const mosaicService = new MosaicService( - new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL)); + new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL)); return mosaicService.mosaicsView([mosaicId]).subscribe((mosaicsView: MosaicView[]) => { const mosaicView = mosaicsView[0]; expect(mosaicView.mosaicInfo).to.be.an.instanceof(MosaicInfo); @@ -42,7 +41,7 @@ describe('MosaicService', () => { it('mosaicsView of no existing mosaicId', () => { const mosaicId = new MosaicId([1234, 1234]); const mosaicService = new MosaicService( - new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL)); + new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL)); return mosaicService.mosaicsView([mosaicId]).subscribe((mosaicsView: MosaicView[]) => { expect(mosaicsView.length).to.be.equal(0); }); @@ -50,7 +49,7 @@ describe('MosaicService', () => { it('mosaicsAmountView', () => { const mosaicService = new MosaicService( - new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL)); + new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL)); return mosaicService.mosaicsAmountViewFromAddress(Address.createFromRawAddress('SARNASAS2BIAB6LMFA3FPMGBPGIJGK6IJETM3ZSP')) .subscribe((mosaicsAmountView: MosaicAmountView[]) => { const mosaicAmountView = mosaicsAmountView[0]; @@ -60,7 +59,7 @@ describe('MosaicService', () => { it('mosaicsAmountView of no existing account', () => { const mosaicService = new MosaicService( - new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL)); + new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL)); return mosaicService.mosaicsAmountViewFromAddress(Address.createFromRawAddress('SCKBZAMIQ6F46QMZUANE6E33KA63KA7KEQ5X6WJW')) .subscribe((mosaicsAmountView: MosaicAmountView[]) => { expect(mosaicsAmountView.length).to.be.equal(0); @@ -70,7 +69,7 @@ describe('MosaicService', () => { it('mosaicsAmountView', () => { const mosaic = new Mosaic(new MosaicId([3646934825, 3576016193]), UInt64.fromUint(1000)); const mosaicService = new MosaicService( - new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL)); + new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL)); return mosaicService.mosaicsAmountView([mosaic]).subscribe((mosaicsAmountView: MosaicAmountView[]) => { const mosaicAmountView = mosaicsAmountView[0]; expect(mosaicAmountView.mosaicInfo).to.be.an.instanceof(MosaicInfo); From 64e7872c397be6b46c0b4c64eac609286349cff8 Mon Sep 17 00:00:00 2001 From: Greg S Date: Tue, 12 Mar 2019 16:36:36 +0100 Subject: [PATCH 3/3] issue #82: removed bugfix in favor of mergeMap bugfix for mosaicInfo injection --- src/service/MosaicService.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/service/MosaicService.ts b/src/service/MosaicService.ts index ed14e8fd40..7d4b9482e0 100644 --- a/src/service/MosaicService.ts +++ b/src/service/MosaicService.ts @@ -49,6 +49,7 @@ export class MosaicService { mosaicsView(mosaicIds: MosaicId[]): Observable { return observableOf(mosaicIds).pipe( mergeMap((_) => this.mosaicHttp.getMosaics(mosaicIds).pipe( + mergeMap((_) => _), map((mosaicInfo: MosaicInfo) => { return new MosaicView(mosaicInfo); }), @@ -66,7 +67,7 @@ export class MosaicService { mergeMap((mosaic: Mosaic) => this.mosaicsView([mosaic.id]).pipe( filter((_) => _.length !== 0), map((mosaicViews) => { - return new MosaicAmountView(mosaicViews[0].mosaicInfo[0], mosaic.amount); + return new MosaicAmountView(mosaicViews[0].mosaicInfo, mosaic.amount); }), toArray()))); }