Skip to content

Commit afdc959

Browse files
author
Grégory Saive
authored
Merge pull request #81 from evias/task/G76/fix-mosaic-dto
issue #76: Fixed MosaicInfoDTO fields with new cow DTO content
2 parents a354ca8 + 37a874d commit afdc959

File tree

7 files changed

+39
-68
lines changed

7 files changed

+39
-68
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nem2-sdk",
3-
"version": "0.10.3-4",
3+
"version": "0.10.3-5",
44
"description": "Reactive Nem2 sdk for typescript and javascript",
55
"scripts": {
66
"pretest": "npm run build",

src/infrastructure/MosaicHttp.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ export class MosaicHttp extends Http implements MosaicRepository {
6161
mergeMap((networkType) => observableFrom(
6262
this.mosaicRoutesApi.getMosaic(mosaicId.toHex())).pipe(map((mosaicInfoDTO) => {
6363
return new MosaicInfo(
64-
mosaicInfoDTO.meta.active,
65-
mosaicInfoDTO.meta.index,
6664
mosaicInfoDTO.meta.id,
6765
new MosaicId(mosaicInfoDTO.mosaic.mosaicId),
68-
new UInt64(mosaicInfoDTO.mosaic.nonce),
6966
new UInt64(mosaicInfoDTO.mosaic.supply),
7067
new UInt64(mosaicInfoDTO.mosaic.height),
7168
PublicAccount.createFromPublicKey(mosaicInfoDTO.mosaic.owner, networkType),
69+
mosaicInfoDTO.mosaic.revision,
7270
new MosaicProperties(
7371
new UInt64(mosaicInfoDTO.mosaic.properties[0]),
7472
(new UInt64(mosaicInfoDTO.mosaic.properties[1])).compact(),
@@ -93,14 +91,12 @@ export class MosaicHttp extends Http implements MosaicRepository {
9391
this.mosaicRoutesApi.getMosaics(mosaicIdsBody)).pipe(map((mosaicInfosDTO) => {
9492
return mosaicInfosDTO.map((mosaicInfoDTO) => {
9593
return new MosaicInfo(
96-
mosaicInfoDTO.meta.active,
97-
mosaicInfoDTO.meta.index,
9894
mosaicInfoDTO.meta.id,
9995
new MosaicId(mosaicInfoDTO.mosaic.mosaicId),
100-
new UInt64(mosaicInfoDTO.mosaic.nonce),
10196
new UInt64(mosaicInfoDTO.mosaic.supply),
10297
new UInt64(mosaicInfoDTO.mosaic.height),
10398
PublicAccount.createFromPublicKey(mosaicInfoDTO.mosaic.owner, networkType),
99+
mosaicInfoDTO.mosaic.revision,
104100
new MosaicProperties(
105101
new UInt64(mosaicInfoDTO.mosaic.properties[0]),
106102
(new UInt64(mosaicInfoDTO.mosaic.properties[1])).compact(),

src/model/mosaic/MosaicInfo.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,13 @@ export class MosaicInfo {
3636
* @param levy
3737
*/
3838
constructor(/**
39-
* Mosaic is active.
40-
*/
41-
public readonly active: boolean,
42-
/**
43-
* The mosaic index.
44-
*/
45-
public readonly index: number,
46-
/**
4739
* The meta data id.
4840
*/
4941
public readonly metaId: string,
5042
/**
5143
* The mosaic id.
5244
*/
5345
public readonly mosaicId: MosaicId,
54-
/**
55-
* The mosaic nonce.
56-
*/
57-
public readonly nonce: UInt64,
5846
/**
5947
* The mosaic supply.
6048
*/
@@ -67,6 +55,10 @@ export class MosaicInfo {
6755
* The public key of the mosaic creator.
6856
*/
6957
public readonly owner: PublicAccount,
58+
/**
59+
* The mosaic revision
60+
*/
61+
public readonly revision: number,
7062
/**
7163
* The mosaic properties.
7264
*/

test/model/mosaic/MosaicAmountView.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,21 @@ describe('MosaicAmountView', () => {
2929
let mosaicInfo: MosaicInfo;
3030

3131
before(() => {
32-
mosaicInfo = new MosaicInfo(true, 0, '59FDA0733F17CF0001772CBC', new MosaicId([3294802500, 2243684972]),
33-
new UInt64([1, 0]), new UInt64([3403414400, 2095475]), new UInt64([1, 0]),
32+
mosaicInfo = new MosaicInfo(
33+
'59FDA0733F17CF0001772CBC',
34+
new MosaicId([3294802500, 2243684972]), // mosaicId
35+
new UInt64([3403414400, 2095475]), // supply
36+
new UInt64([1, 0]), // height
3437
PublicAccount.createFromPublicKey('B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', NetworkType.MIJIN_TEST),
38+
1, // revision
3539
MosaicProperties.create({
3640
supplyMutable: true,
3741
transferable: true,
3842
levyMutable: true,
3943
divisibility: 3,
4044
duration: UInt64.fromUint(1000),
41-
}), {});
45+
}),
46+
{});
4247
});
4348

4449
it('should createComplete a Mosaic Amount View', () => {

test/model/mosaic/MosaicInfo.spec.ts

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,22 @@ import {NamespaceId} from '../../../src/model/namespace/NamespaceId';
2727
describe('MosaicInfo', () => {
2828
const mosaicInfoDTO = {
2929
meta: {
30-
active: true,
3130
id: '59FDA0733F17CF0001772CBC',
32-
index: 0,
3331
},
3432
mosaic: {
35-
height: new UInt64([1, 0]),
36-
levy: {},
3733
mosaicId: new MosaicId([3646934825, 3576016193]),
38-
nonce: new UInt64([1, 0]),
39-
owner: PublicAccount.createFromPublicKey('B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF',
34+
supply: new UInt64([3403414400, 2095475]),
35+
height: new UInt64([1, 0]),
36+
owner: PublicAccount.createFromPublicKey(
37+
'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF',
4038
NetworkType.MIJIN_TEST),
39+
revision: 1,
4140
properties: [
42-
new UInt64([
43-
6,
44-
0,
45-
]),
46-
new UInt64([
47-
3,
48-
0,
49-
]),
50-
new UInt64([
51-
1000,
52-
0,
53-
]),
41+
new UInt64([6, 0]), // divisibility
42+
new UInt64([3, 0]), // flags
43+
new UInt64([1000, 0]), // duration
5444
],
55-
supply: new UInt64([3403414400, 2095475]),
45+
levy: {},
5646
},
5747
};
5848

@@ -62,14 +52,12 @@ describe('MosaicInfo', () => {
6252

6353
it('should createComplete an MosaicInfo object', () => {
6454
const mosaicInfo = new MosaicInfo(
65-
mosaicInfoDTO.meta.active,
66-
mosaicInfoDTO.meta.index,
6755
mosaicInfoDTO.meta.id,
6856
mosaicInfoDTO.mosaic.mosaicId,
69-
mosaicInfoDTO.mosaic.nonce,
7057
mosaicInfoDTO.mosaic.supply,
7158
mosaicInfoDTO.mosaic.height,
7259
mosaicInfoDTO.mosaic.owner,
60+
mosaicInfoDTO.mosaic.revision,
7361
new MosaicProperties(
7462
mosaicInfoDTO.mosaic.properties[0],
7563
mosaicInfoDTO.mosaic.properties[1].compact(),
@@ -78,14 +66,12 @@ describe('MosaicInfo', () => {
7866
mosaicInfoDTO.mosaic.levy,
7967
);
8068

81-
expect(mosaicInfo.active).to.be.equal(mosaicInfoDTO.meta.active);
82-
expect(mosaicInfo.index).to.be.equal(mosaicInfoDTO.meta.index);
8369
expect(mosaicInfo.metaId).to.be.equal(mosaicInfoDTO.meta.id);
8470
deepEqual(mosaicInfo.mosaicId, mosaicInfoDTO.mosaic.mosaicId);
85-
deepEqual(mosaicInfo.nonce, mosaicInfoDTO.mosaic.nonce);
8671
deepEqual(mosaicInfo.supply, mosaicInfoDTO.mosaic.supply);
8772
deepEqual(mosaicInfo.height, mosaicInfoDTO.mosaic.height);
8873
expect(mosaicInfo.owner).to.be.equal(mosaicInfoDTO.mosaic.owner);
74+
deepEqual(mosaicInfo.revision, mosaicInfoDTO.mosaic.revision);
8975

9076
expect(mosaicInfo.divisibility).to.be.equal(mosaicInfoDTO.mosaic.properties[1].lower);
9177
deepEqual(mosaicInfo.duration, mosaicInfoDTO.mosaic.properties[2]);
@@ -95,14 +81,12 @@ describe('MosaicInfo', () => {
9581
describe('isSupplyMutable', () => {
9682
it('should return true when it\'s mutable', () => {
9783
const mosaicInfo = new MosaicInfo(
98-
mosaicInfoDTO.meta.active,
99-
mosaicInfoDTO.meta.index,
10084
mosaicInfoDTO.meta.id,
10185
mosaicInfoDTO.mosaic.mosaicId,
102-
mosaicInfoDTO.mosaic.nonce,
10386
mosaicInfoDTO.mosaic.supply,
10487
mosaicInfoDTO.mosaic.height,
10588
mosaicInfoDTO.mosaic.owner,
89+
mosaicInfoDTO.mosaic.revision,
10690
MosaicProperties.create({
10791
supplyMutable: true,
10892
transferable: false,
@@ -118,14 +102,12 @@ describe('MosaicInfo', () => {
118102

119103
it('should return false when it\'s immutable', () => {
120104
const mosaicInfo = new MosaicInfo(
121-
mosaicInfoDTO.meta.active,
122-
mosaicInfoDTO.meta.index,
123105
mosaicInfoDTO.meta.id,
124106
mosaicInfoDTO.mosaic.mosaicId,
125-
mosaicInfoDTO.mosaic.nonce,
126107
mosaicInfoDTO.mosaic.supply,
127108
mosaicInfoDTO.mosaic.height,
128109
mosaicInfoDTO.mosaic.owner,
110+
mosaicInfoDTO.mosaic.revision,
129111
MosaicProperties.create({
130112
supplyMutable: false,
131113
transferable: false,
@@ -142,14 +124,12 @@ describe('MosaicInfo', () => {
142124
describe('isTransferable', () => {
143125
it('should return true when it\'s transferable', () => {
144126
const mosaicInfo = new MosaicInfo(
145-
mosaicInfoDTO.meta.active,
146-
mosaicInfoDTO.meta.index,
147127
mosaicInfoDTO.meta.id,
148128
mosaicInfoDTO.mosaic.mosaicId,
149-
mosaicInfoDTO.mosaic.nonce,
150129
mosaicInfoDTO.mosaic.supply,
151130
mosaicInfoDTO.mosaic.height,
152131
mosaicInfoDTO.mosaic.owner,
132+
mosaicInfoDTO.mosaic.revision,
153133
MosaicProperties.create({
154134
supplyMutable: false,
155135
transferable: true,
@@ -164,14 +144,12 @@ describe('MosaicInfo', () => {
164144

165145
it('should return false when it\'s not transferable', () => {
166146
const mosaicInfo = new MosaicInfo(
167-
mosaicInfoDTO.meta.active,
168-
mosaicInfoDTO.meta.index,
169147
mosaicInfoDTO.meta.id,
170148
mosaicInfoDTO.mosaic.mosaicId,
171-
mosaicInfoDTO.mosaic.nonce,
172149
mosaicInfoDTO.mosaic.supply,
173150
mosaicInfoDTO.mosaic.height,
174151
mosaicInfoDTO.mosaic.owner,
152+
mosaicInfoDTO.mosaic.revision,
175153
MosaicProperties.create({
176154
supplyMutable: false,
177155
transferable: false,
@@ -188,14 +166,12 @@ describe('MosaicInfo', () => {
188166
describe('isLevyMutable', () => {
189167
it('should return true when it\'s mutable', () => {
190168
const mosaicInfo = new MosaicInfo(
191-
mosaicInfoDTO.meta.active,
192-
mosaicInfoDTO.meta.index,
193169
mosaicInfoDTO.meta.id,
194170
mosaicInfoDTO.mosaic.mosaicId,
195-
mosaicInfoDTO.mosaic.nonce,
196171
mosaicInfoDTO.mosaic.supply,
197172
mosaicInfoDTO.mosaic.height,
198173
mosaicInfoDTO.mosaic.owner,
174+
mosaicInfoDTO.mosaic.revision,
199175
MosaicProperties.create({
200176
supplyMutable: true,
201177
transferable: false,
@@ -210,14 +186,12 @@ describe('MosaicInfo', () => {
210186

211187
it('should return false when it\'s immutable', () => {
212188
const mosaicInfo = new MosaicInfo(
213-
mosaicInfoDTO.meta.active,
214-
mosaicInfoDTO.meta.index,
215189
mosaicInfoDTO.meta.id,
216190
mosaicInfoDTO.mosaic.mosaicId,
217-
mosaicInfoDTO.mosaic.nonce,
218191
mosaicInfoDTO.mosaic.supply,
219192
mosaicInfoDTO.mosaic.height,
220193
mosaicInfoDTO.mosaic.owner,
194+
mosaicInfoDTO.mosaic.revision,
221195
MosaicProperties.create({
222196
supplyMutable: false,
223197
transferable: false,

test/model/mosaic/MosaicView.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ describe('MosaicView', () => {
2929
let mosaicInfo: MosaicInfo;
3030

3131
before(() => {
32-
mosaicInfo = new MosaicInfo(true, 0, '59FDA0733F17CF0001772CBC', new MosaicId([3294802500, 2243684972]),
33-
new UInt64([1, 0]), new UInt64([3403414400, 2095475]), new UInt64([1, 0]),
32+
mosaicInfo = new MosaicInfo(
33+
'59FDA0733F17CF0001772CBC',
34+
new MosaicId([3294802500, 2243684972]),
35+
new UInt64([3403414400, 2095475]), // supply
36+
new UInt64([1, 0]), // height
3437
PublicAccount.createFromPublicKey('B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', NetworkType.MIJIN_TEST),
38+
1, // revision
3539
MosaicProperties.create({
3640
supplyMutable: true,
3741
transferable: true,

0 commit comments

Comments
 (0)