Skip to content

Commit 47b6b75

Browse files
author
Grégory Saive
authored
Merge pull request #84 from evias/task/G82/fix-mosaic-service
issue #82: Fixed MosaicService to pass single MosaicInfo object instead of array
2 parents afdc959 + 64e7872 commit 47b6b75

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

e2e/service/MosaicService.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { map, mergeMap, toArray } from 'rxjs/operators';
22
import { AccountHttp } from '../../src/infrastructure/AccountHttp';
33
import { MosaicHttp } from '../../src/infrastructure/MosaicHttp';
4-
import { NamespaceHttp } from '../../src/infrastructure/NamespaceHttp';
54
import { Address } from '../../src/model/account/Address';
65
import { MosaicService } from '../../src/service/MosaicService';
76
import { APIUrl } from '../conf/conf.spec';
@@ -12,7 +11,6 @@ describe('MosaicService', () => {
1211
const mosaicService = new MosaicService(
1312
new AccountHttp(APIUrl),
1413
new MosaicHttp(APIUrl),
15-
new NamespaceHttp(APIUrl),
1614
);
1715

1816
const address = Address.createFromRawAddress('SCO2JY-N6OJSM-CJPPVS-Z3OX7P-TWPQEJ-GZTI6W-GLKK');

src/service/MosaicService.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ export class MosaicService {
3535
* Constructor
3636
* @param accountHttp
3737
* @param mosaicHttp
38-
* @param namespaceHttp
3938
*/
4039
constructor(private readonly accountHttp: AccountHttp,
41-
private readonly mosaicHttp: MosaicHttp,
42-
private readonly namespaceHttp: NamespaceHttp) {
40+
private readonly mosaicHttp: MosaicHttp) {
4341

4442
}
4543

@@ -51,6 +49,7 @@ export class MosaicService {
5149
mosaicsView(mosaicIds: MosaicId[]): Observable<MosaicView[]> {
5250
return observableOf(mosaicIds).pipe(
5351
mergeMap((_) => this.mosaicHttp.getMosaics(mosaicIds).pipe(
52+
mergeMap((_) => _),
5453
map((mosaicInfo: MosaicInfo) => {
5554
return new MosaicView(mosaicInfo);
5655
}),

test/service/MosaicService.spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import {expect} from 'chai';
1818
import {AccountHttp} from '../../src/infrastructure/AccountHttp';
1919
import {MosaicHttp} from '../../src/infrastructure/MosaicHttp';
20-
import {NamespaceHttp} from '../../src/infrastructure/NamespaceHttp';
2120
import {Address} from '../../src/model/account/Address';
2221
import {Mosaic} from '../../src/model/mosaic/Mosaic';
2322
import {MosaicId} from '../../src/model/mosaic/MosaicId';
@@ -32,7 +31,7 @@ describe('MosaicService', () => {
3231
it('mosaicsView', () => {
3332
const mosaicId = new MosaicId([3294802500, 2243684972]);
3433
const mosaicService = new MosaicService(
35-
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL));
34+
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL));
3635
return mosaicService.mosaicsView([mosaicId]).subscribe((mosaicsView: MosaicView[]) => {
3736
const mosaicView = mosaicsView[0];
3837
expect(mosaicView.mosaicInfo).to.be.an.instanceof(MosaicInfo);
@@ -42,15 +41,15 @@ describe('MosaicService', () => {
4241
it('mosaicsView of no existing mosaicId', () => {
4342
const mosaicId = new MosaicId([1234, 1234]);
4443
const mosaicService = new MosaicService(
45-
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL));
44+
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL));
4645
return mosaicService.mosaicsView([mosaicId]).subscribe((mosaicsView: MosaicView[]) => {
4746
expect(mosaicsView.length).to.be.equal(0);
4847
});
4948
});
5049

5150
it('mosaicsAmountView', () => {
5251
const mosaicService = new MosaicService(
53-
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL));
52+
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL));
5453
return mosaicService.mosaicsAmountViewFromAddress(Address.createFromRawAddress('SARNASAS2BIAB6LMFA3FPMGBPGIJGK6IJETM3ZSP'))
5554
.subscribe((mosaicsAmountView: MosaicAmountView[]) => {
5655
const mosaicAmountView = mosaicsAmountView[0];
@@ -60,7 +59,7 @@ describe('MosaicService', () => {
6059

6160
it('mosaicsAmountView of no existing account', () => {
6261
const mosaicService = new MosaicService(
63-
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL));
62+
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL));
6463
return mosaicService.mosaicsAmountViewFromAddress(Address.createFromRawAddress('SCKBZAMIQ6F46QMZUANE6E33KA63KA7KEQ5X6WJW'))
6564
.subscribe((mosaicsAmountView: MosaicAmountView[]) => {
6665
expect(mosaicsAmountView.length).to.be.equal(0);
@@ -70,7 +69,7 @@ describe('MosaicService', () => {
7069
it('mosaicsAmountView', () => {
7170
const mosaic = new Mosaic(new MosaicId([3646934825, 3576016193]), UInt64.fromUint(1000));
7271
const mosaicService = new MosaicService(
73-
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL), new NamespaceHttp(conf.NIS2_URL));
72+
new AccountHttp(conf.NIS2_URL), new MosaicHttp(conf.NIS2_URL));
7473
return mosaicService.mosaicsAmountView([mosaic]).subscribe((mosaicsAmountView: MosaicAmountView[]) => {
7574
const mosaicAmountView = mosaicsAmountView[0];
7675
expect(mosaicAmountView.mosaicInfo).to.be.an.instanceof(MosaicInfo);

0 commit comments

Comments
 (0)