Skip to content

Commit 58e87c3

Browse files
author
Grégory Saive
authored
Merge branch 'master' into task/g52_delegated_harvesting
2 parents 2e2e7f9 + 6fffd51 commit 58e87c3

19 files changed

+234
-100
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');

package-lock.json

Lines changed: 10 additions & 10 deletions
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/Listener.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import * as WebSocket from 'ws';
2020
import {Address} from '../model/account/Address';
2121
import {PublicAccount} from '../model/account/PublicAccount';
2222
import {BlockInfo} from '../model/blockchain/BlockInfo';
23+
import {NamespaceId} from '../model/namespace/NamespaceId';
2324
import {AggregateTransaction} from '../model/transaction/AggregateTransaction';
2425
import {AggregateTransactionCosignature} from '../model/transaction/AggregateTransactionCosignature';
2526
import {CosignatureSignedTransaction} from '../model/transaction/CosignatureSignedTransaction';
@@ -375,8 +376,16 @@ export class Listener {
375376
* @param address
376377
* @returns {boolean}
377378
*/
378-
private transactionHasSignerOrReceptor(transaction: Transaction, address: Address): boolean {
379-
return transaction.signer!.address.equals(address) ||
380-
(transaction instanceof TransferTransaction && transaction.recipient.equals(address));
379+
private transactionHasSignerOrReceptor(transaction: Transaction, address: Address | NamespaceId): boolean {
380+
381+
if (address instanceof NamespaceId) {
382+
return transaction instanceof TransferTransaction
383+
&& (transaction.recipient as NamespaceId).equals(address);
384+
}
385+
386+
return transaction.signer!.address.equals(address) || (
387+
transaction instanceof TransferTransaction
388+
&& (transaction.recipient as Address).equals(address)
389+
);
381390
}
382391
}

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
*/

src/model/namespace/MosaicAlias.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,12 @@ export class MosaicAlias implements Alias {
5151
}
5252
return false;
5353
}
54+
55+
/**
56+
* Get string value of mosaicId
57+
* @returns {string}
58+
*/
59+
public toHex(): string {
60+
return this.mosaicId.toHex();
61+
}
5462
}

src/model/transaction/AddressAliasTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class AddressAliasTransaction extends Transaction {
4848
address: Address,
4949
networkType: NetworkType): AddressAliasTransaction {
5050
return new AddressAliasTransaction(networkType,
51-
TransactionVersion.MOSAIC_ALIAS,
51+
TransactionVersion.ADDRESS_ALIAS,
5252
deadline,
5353
new UInt64([0, 0]),
5454
actionType,
@@ -88,7 +88,7 @@ export class AddressAliasTransaction extends Transaction {
8888
signature?: string,
8989
signer?: PublicAccount,
9090
transactionInfo?: TransactionInfo) {
91-
super(TransactionType.MOSAIC_ALIAS, networkType, version, deadline, fee, signature, signer, transactionInfo);
91+
super(TransactionType.ADDRESS_ALIAS, networkType, version, deadline, fee, signature, signer, transactionInfo);
9292
}
9393

9494
/**

src/model/transaction/AggregateTransaction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ export class AggregateTransaction extends Transaction {
133133
public signTransactionWithCosignatories(initiatorAccount: Account, cosignatories: Account[]) {
134134
const aggregateTransaction = this.buildTransaction();
135135
const signedTransactionRaw = aggregateTransaction.signTransactionWithCosigners(initiatorAccount, cosignatories);
136-
return new SignedTransaction(signedTransactionRaw.payload, signedTransactionRaw.hash, initiatorAccount.publicKey, this.type, this.networkType);
136+
return new SignedTransaction(signedTransactionRaw.payload, signedTransactionRaw.hash, initiatorAccount.publicKey,
137+
this.type, this.networkType);
137138
}
138139

139140
/**

src/model/transaction/Transaction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { Deadline } from './Deadline';
2424
import { InnerTransaction } from './InnerTransaction';
2525
import { SignedTransaction } from './SignedTransaction';
2626
import { TransactionInfo } from './TransactionInfo';
27+
import { TransactionType } from './TransactionType';
2728

2829
/**
2930
* An abstract transaction class that serves as the base class of all NEM transactions.
@@ -112,6 +113,9 @@ export abstract class Transaction {
112113
* @returns InnerTransaction
113114
*/
114115
public toAggregate(signer: PublicAccount): InnerTransaction {
116+
if (this.type === TransactionType.AGGREGATE_BONDED || this.type === TransactionType.AGGREGATE_COMPLETE) {
117+
throw new Error('Inner transaction cannot be an aggregated transaction.');
118+
}
115119
return Object.assign({__proto__: Object.getPrototypeOf(this)}, this, {signer});
116120
}
117121

0 commit comments

Comments
 (0)