Skip to content

Commit c67281a

Browse files
author
Grégory Saive
authored
Merge branch 'master' into task/g132_encrypted_message
2 parents 5ed485e + ad87563 commit c67281a

File tree

8 files changed

+94
-82
lines changed

8 files changed

+94
-82
lines changed

src/model/transaction/AccountPropertyModification.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { Address } from '../account/Address';
1718
import { PropertyModificationType } from '../account/PropertyModificationType';
19+
import { MosaicId } from '../mosaic/MosaicId';
20+
import { TransactionType } from './TransactionType';
1821

1922
export class AccountPropertyModification<T> {
2023

@@ -35,6 +38,38 @@ export class AccountPropertyModification<T> {
3538

3639
}
3740

41+
/**
42+
* Create an address filter for account property modification
43+
* @param modificationType - modification type. 0: Add, 1: Remove
44+
* @param address - modification value (Address)
45+
* @returns {AccountPropertyModification}
46+
*/
47+
public static createForAddress(modificationType: PropertyModificationType,
48+
address: Address): AccountPropertyModification<string> {
49+
return new AccountPropertyModification<string>(modificationType, address.plain());
50+
}
51+
/**
52+
* Create an mosaic filter for account property modification
53+
* @param modificationType - modification type. 0: Add, 1: Remove
54+
* @param mosaicId - modification value (Mosaic)
55+
* @returns {AccountPropertyModification}
56+
*/
57+
public static createForMosaic(modificationType: PropertyModificationType,
58+
mosaicId: MosaicId): AccountPropertyModification<number[]> {
59+
return new AccountPropertyModification<number[]>(modificationType, mosaicId.id.toDTO());
60+
}
61+
62+
/**
63+
* Create an entity type filter for account property modification
64+
* @param modificationType - modification type. 0: Add, 1: Remove
65+
* @param entityType - modification value (Transaction Type)
66+
* @returns {AccountPropertyModification}
67+
*/
68+
public static createForEntityType(modificationType: PropertyModificationType,
69+
entityType: number): AccountPropertyModification<TransactionType> {
70+
return new AccountPropertyModification<TransactionType>(modificationType, entityType);
71+
}
72+
3873
/**
3974
* @internal
4075
*/

src/model/transaction/AccountPropertyTransaction.ts

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Address } from '../account/Address';
18-
import { PropertyModificationType } from '../account/PropertyModificationType';
1917
import { PropertyType } from '../account/PropertyType';
2018
import { NetworkType } from '../blockchain/NetworkType';
21-
import { MosaicId } from '../mosaic/MosaicId';
2219
import { UInt64 } from '../UInt64';
2320
import { AccountPropertyModification } from './AccountPropertyModification';
2421
import { Deadline } from './Deadline';
2522
import { ModifyAccountPropertyAddressTransaction } from './ModifyAccountPropertyAddressTransaction';
2623
import { ModifyAccountPropertyEntityTypeTransaction } from './ModifyAccountPropertyEntityTypeTransaction';
2724
import { ModifyAccountPropertyMosaicTransaction } from './ModifyAccountPropertyMosaicTransaction';
25+
import { TransactionType } from './TransactionType';
2826

2927
export class AccountPropertyTransaction {
3028
/**
@@ -95,7 +93,7 @@ export class AccountPropertyTransaction {
9593
public static createEntityTypePropertyModificationTransaction(
9694
deadline: Deadline,
9795
propertyType: PropertyType,
98-
modifications: Array<AccountPropertyModification<number>>,
96+
modifications: Array<AccountPropertyModification<TransactionType>>,
9997
networkType: NetworkType,
10098
maxFee: UInt64 = new UInt64([0, 0])
10199
): ModifyAccountPropertyEntityTypeTransaction {
@@ -110,37 +108,4 @@ export class AccountPropertyTransaction {
110108
maxFee,
111109
);
112110
}
113-
114-
/**
115-
* Create an address filter for account property modification
116-
* @param modificationType - modification type. 0: Add, 1: Remove
117-
* @param address - modification value (Address)
118-
* @returns {AccountPropertyModification}
119-
*/
120-
public static createAddressFilter(modificationType: PropertyModificationType,
121-
address: Address): AccountPropertyModification<string> {
122-
return new AccountPropertyModification<string>(modificationType, address.plain());
123-
}
124-
125-
/**
126-
* Create an mosaic filter for account property modification
127-
* @param modificationType - modification type. 0: Add, 1: Remove
128-
* @param mosaicId - modification value (Mosaic)
129-
* @returns {AccountPropertyModification}
130-
*/
131-
public static createMosaicFilter(modificationType: PropertyModificationType,
132-
mosaicId: MosaicId): AccountPropertyModification<number[]> {
133-
return new AccountPropertyModification<number[]>(modificationType, mosaicId.id.toDTO());
134-
}
135-
136-
/**
137-
* Create an entity type filter for account property modification
138-
* @param modificationType - modification type. 0: Add, 1: Remove
139-
* @param entityType - modification value (Transaction Type)
140-
* @returns {AccountPropertyModification}
141-
*/
142-
public static createEntityTypeFilter(modificationType: PropertyModificationType,
143-
entityType: number): AccountPropertyModification<number> {
144-
return new AccountPropertyModification<number>(modificationType, entityType);
145-
}
146111
}

src/model/transaction/ModifyAccountPropertyEntityTypeTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class ModifyAccountPropertyEntityTypeTransaction extends Transaction {
4040
*/
4141
public static create(deadline: Deadline,
4242
propertyType: PropertyType,
43-
modifications: Array<AccountPropertyModification<number>>,
43+
modifications: Array<AccountPropertyModification<TransactionType>>,
4444
networkType: NetworkType,
4545
maxFee: UInt64 = new UInt64([0, 0])): ModifyAccountPropertyEntityTypeTransaction {
4646
return new ModifyAccountPropertyEntityTypeTransaction(networkType,
@@ -68,7 +68,7 @@ export class ModifyAccountPropertyEntityTypeTransaction extends Transaction {
6868
deadline: Deadline,
6969
maxFee: UInt64,
7070
public readonly propertyType: PropertyType,
71-
public readonly modifications: Array<AccountPropertyModification<number>>,
71+
public readonly modifications: Array<AccountPropertyModification<TransactionType>>,
7272
signature?: string,
7373
signer?: PublicAccount,
7474
transactionInfo?: TransactionInfo) {

test/core/utils/TransactionMapping.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { AliasActionType } from '../../../src/model/namespace/AliasActionType';
3535
import { NamespaceId } from '../../../src/model/namespace/NamespaceId';
3636
import { NamespaceType } from '../../../src/model/namespace/NamespaceType';
3737
import { AccountLinkTransaction } from '../../../src/model/transaction/AccountLinkTransaction';
38+
import { AccountPropertyModification } from '../../../src/model/transaction/AccountPropertyModification';
3839
import { AccountPropertyTransaction } from '../../../src/model/transaction/AccountPropertyTransaction';
3940
import { AddressAliasTransaction } from '../../../src/model/transaction/AddressAliasTransaction';
4041
import { AggregateTransaction } from '../../../src/model/transaction/AggregateTransaction';
@@ -69,7 +70,7 @@ describe('TransactionMapping - createFromPayload', () => {
6970

7071
it('should create AccountPropertyAddressTransaction', () => {
7172
const address = Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC');
72-
const addressPropertyFilter = AccountPropertyTransaction.createAddressFilter(
73+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
7374
PropertyModificationType.Add,
7475
address,
7576
);
@@ -91,7 +92,7 @@ describe('TransactionMapping - createFromPayload', () => {
9192

9293
it('should create AccountPropertyMosaicTransaction', () => {
9394
const mosaicId = new MosaicId([2262289484, 3405110546]);
94-
const mosaicPropertyFilter = AccountPropertyTransaction.createMosaicFilter(
95+
const mosaicPropertyFilter = AccountPropertyModification.createForMosaic(
9596
PropertyModificationType.Add,
9697
mosaicId,
9798
);
@@ -113,7 +114,7 @@ describe('TransactionMapping - createFromPayload', () => {
113114

114115
it('should create AccountPropertyMosaicTransaction', () => {
115116
const entityType = TransactionType.ADDRESS_ALIAS;
116-
const entityTypePropertyFilter = AccountPropertyTransaction.createEntityTypeFilter(
117+
const entityTypePropertyFilter = AccountPropertyModification.createForEntityType(
117118
PropertyModificationType.Add,
118119
entityType,
119120
);
@@ -607,7 +608,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () =>
607608

608609
it('should create AccountPropertyAddressTransaction', () => {
609610
const address = Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC');
610-
const addressPropertyFilter = AccountPropertyTransaction.createAddressFilter(
611+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
611612
PropertyModificationType.Add,
612613
address,
613614
);
@@ -628,7 +629,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () =>
628629

629630
it('should create AccountPropertyMosaicTransaction', () => {
630631
const mosaicId = new MosaicId([2262289484, 3405110546]);
631-
const mosaicPropertyFilter = AccountPropertyTransaction.createMosaicFilter(
632+
const mosaicPropertyFilter = AccountPropertyModification.createForMosaic(
632633
PropertyModificationType.Add,
633634
mosaicId,
634635
);
@@ -649,7 +650,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () =>
649650

650651
it('should create AccountPropertyMosaicTransaction', () => {
651652
const entityType = TransactionType.ADDRESS_ALIAS;
652-
const entityTypePropertyFilter = AccountPropertyTransaction.createEntityTypeFilter(
653+
const entityTypePropertyFilter = AccountPropertyModification.createForEntityType(
653654
PropertyModificationType.Add,
654655
entityType,
655656
);

test/infrastructure/Listener.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Listener', () => {
4040
throw new Error('This should not be called when expecting error');
4141
})
4242
.catch((error) => {
43-
expect(error.message.toString()).to.be.equal("getaddrinfo ENOTFOUND notcorrecturl notcorrecturl:0000");
43+
expect(error.message.toString()).not.to.be.equal('');
4444
});
4545
});
4646
});

test/infrastructure/SerializeTransactionToJSON.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { AliasActionType } from '../../src/model/namespace/AliasActionType';
3434
import { NamespaceId } from '../../src/model/namespace/NamespaceId';
3535
import { NamespaceType } from '../../src/model/namespace/NamespaceType';
3636
import { AccountLinkTransaction } from '../../src/model/transaction/AccountLinkTransaction';
37+
import { AccountPropertyModification } from '../../src/model/transaction/AccountPropertyModification';
3738
import { AccountPropertyTransaction } from '../../src/model/transaction/AccountPropertyTransaction';
3839
import { AddressAliasTransaction } from '../../src/model/transaction/AddressAliasTransaction';
3940
import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction';
@@ -80,7 +81,7 @@ describe('SerializeTransactionToJSON', () => {
8081

8182
it('should create AccountPropertyAddressTransaction', () => {
8283
const address = Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC');
83-
const addressPropertyFilter = AccountPropertyTransaction.createAddressFilter(
84+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
8485
PropertyModificationType.Add,
8586
address,
8687
);
@@ -100,7 +101,7 @@ describe('SerializeTransactionToJSON', () => {
100101

101102
it('should create AccountPropertyMosaicTransaction', () => {
102103
const mosaicId = new MosaicId([2262289484, 3405110546]);
103-
const mosaicPropertyFilter = AccountPropertyTransaction.createMosaicFilter(
104+
const mosaicPropertyFilter = AccountPropertyModification.createForMosaic(
104105
PropertyModificationType.Add,
105106
mosaicId,
106107
);
@@ -120,7 +121,7 @@ describe('SerializeTransactionToJSON', () => {
120121

121122
it('should create AccountPropertyMosaicTransaction', () => {
122123
const entityType = TransactionType.ADDRESS_ALIAS;
123-
const entityTypePropertyFilter = AccountPropertyTransaction.createEntityTypeFilter(
124+
const entityTypePropertyFilter = AccountPropertyModification.createForEntityType(
124125
PropertyModificationType.Add,
125126
entityType,
126127
);

test/model/transaction/AccountPropertyTransaction.spec.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
import {expect} from 'chai';
1818
import {Account} from '../../../src/model/account/Account';
1919
import {Address} from '../../../src/model/account/Address';
20+
import { PropertyModificationType } from '../../../src/model/account/PropertyModificationType';
21+
import { PropertyType } from '../../../src/model/account/PropertyType';
2022
import {NetworkType} from '../../../src/model/blockchain/NetworkType';
21-
import { PropertyModificationType, PropertyType, TransactionType } from '../../../src/model/model';
2223
import {MosaicId} from '../../../src/model/mosaic/MosaicId';
24+
import { AccountPropertyModification } from '../../../src/model/transaction/AccountPropertyModification';
2325
import {AccountPropertyTransaction} from '../../../src/model/transaction/AccountPropertyTransaction';
2426
import {Deadline} from '../../../src/model/transaction/Deadline';
27+
import { TransactionType } from '../../../src/model/transaction/TransactionType';
2528
import {UInt64} from '../../../src/model/UInt64';
2629
import {TestingAccount} from '../../conf/conf.spec';
2730

@@ -33,7 +36,7 @@ describe('AccountPropertyTransaction', () => {
3336
});
3437
it('should create address property filter', () => {
3538
const address = Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC');
36-
const addressPropertyFilter = AccountPropertyTransaction.createAddressFilter(
39+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
3740
PropertyModificationType.Add,
3841
address,
3942
);
@@ -43,7 +46,7 @@ describe('AccountPropertyTransaction', () => {
4346

4447
it('should create mosaic property filter', () => {
4548
const mosaicId = new MosaicId([2262289484, 3405110546]);
46-
const mosaicPropertyFilter = AccountPropertyTransaction.createMosaicFilter(
49+
const mosaicPropertyFilter = AccountPropertyModification.createForMosaic(
4750
PropertyModificationType.Add,
4851
mosaicId,
4952
);
@@ -54,7 +57,7 @@ describe('AccountPropertyTransaction', () => {
5457

5558
it('should create entity type property filter', () => {
5659
const entityType = TransactionType.ADDRESS_ALIAS;
57-
const entityTypePropertyFilter = AccountPropertyTransaction.createEntityTypeFilter(
60+
const entityTypePropertyFilter = AccountPropertyModification.createForEntityType(
5861
PropertyModificationType.Add,
5962
entityType,
6063
);
@@ -65,7 +68,7 @@ describe('AccountPropertyTransaction', () => {
6568
describe('size', () => {
6669
it('should return 148 for ModifyAccountPropertyAddressTransaction transaction byte size with 1 modification', () => {
6770
const address = Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC');
68-
const addressPropertyFilter = AccountPropertyTransaction.createAddressFilter(
71+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
6972
PropertyModificationType.Add,
7073
address,
7174
);
@@ -81,7 +84,7 @@ describe('AccountPropertyTransaction', () => {
8184

8285
it('should return 131 for ModifyAccountPropertyMosaicTransaction transaction byte size with 1 modification', () => {
8386
const mosaicId = new MosaicId([2262289484, 3405110546]);
84-
const mosaicPropertyFilter = AccountPropertyTransaction.createMosaicFilter(
87+
const mosaicPropertyFilter = AccountPropertyModification.createForMosaic(
8588
PropertyModificationType.Add,
8689
mosaicId,
8790
);
@@ -96,7 +99,7 @@ describe('AccountPropertyTransaction', () => {
9699

97100
it('should return 125 for ModifyAccountPropertyEntityTypeTransaction transaction byte size with 1 modification', () => {
98101
const entityType = TransactionType.ADDRESS_ALIAS;
99-
const entityTypePropertyFilter = AccountPropertyTransaction.createEntityTypeFilter(
102+
const entityTypePropertyFilter = AccountPropertyModification.createForEntityType(
100103
PropertyModificationType.Add,
101104
entityType,
102105
);
@@ -110,10 +113,9 @@ describe('AccountPropertyTransaction', () => {
110113
});
111114
});
112115

113-
114116
it('should default maxFee field be set to 0', () => {
115117
const address = Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC');
116-
const addressPropertyFilter = AccountPropertyTransaction.createAddressFilter(
118+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
117119
PropertyModificationType.Add,
118120
address,
119121
);
@@ -130,7 +132,7 @@ describe('AccountPropertyTransaction', () => {
130132

131133
it('should filled maxFee override transaction maxFee', () => {
132134
const address = Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC');
133-
const addressPropertyFilter = AccountPropertyTransaction.createAddressFilter(
135+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
134136
PropertyModificationType.Add,
135137
address,
136138
);
@@ -139,7 +141,7 @@ describe('AccountPropertyTransaction', () => {
139141
PropertyType.AllowAddress,
140142
[addressPropertyFilter],
141143
NetworkType.MIJIN_TEST,
142-
new UInt64([1, 0])
144+
new UInt64([1, 0]),
143145
);
144146

145147
expect(addressPropertyTransaction.maxFee.higher).to.be.equal(0);
@@ -149,7 +151,7 @@ describe('AccountPropertyTransaction', () => {
149151
it('should create address property transaction', () => {
150152

151153
const address = Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC');
152-
const addressPropertyFilter = AccountPropertyTransaction.createAddressFilter(
154+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
153155
PropertyModificationType.Add,
154156
address,
155157
);
@@ -172,7 +174,7 @@ describe('AccountPropertyTransaction', () => {
172174
it('should throw exception when create address property transaction with wrong type', () => {
173175

174176
const address = Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC');
175-
const addressPropertyFilter = AccountPropertyTransaction.createAddressFilter(
177+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
176178
PropertyModificationType.Add,
177179
address,
178180
);
@@ -191,7 +193,7 @@ describe('AccountPropertyTransaction', () => {
191193
it('should create mosaic property transaction', () => {
192194

193195
const mosaicId = new MosaicId([2262289484, 3405110546]);
194-
const mosaicPropertyFilter = AccountPropertyTransaction.createMosaicFilter(
196+
const mosaicPropertyFilter = AccountPropertyModification.createForMosaic(
195197
PropertyModificationType.Add,
196198
mosaicId,
197199
);
@@ -214,7 +216,7 @@ describe('AccountPropertyTransaction', () => {
214216
it('should throw exception when create mosaic property transaction with wrong type', () => {
215217

216218
const mosaicId = new MosaicId([2262289484, 3405110546]);
217-
const mosaicPropertyFilter = AccountPropertyTransaction.createMosaicFilter(
219+
const mosaicPropertyFilter = AccountPropertyModification.createForMosaic(
218220
PropertyModificationType.Add,
219221
mosaicId,
220222
);
@@ -233,7 +235,7 @@ describe('AccountPropertyTransaction', () => {
233235
it('should create entity type property transaction', () => {
234236

235237
const entityType = TransactionType.ADDRESS_ALIAS;
236-
const entityTypePropertyFilter = AccountPropertyTransaction.createEntityTypeFilter(
238+
const entityTypePropertyFilter = AccountPropertyModification.createForEntityType(
237239
PropertyModificationType.Add,
238240
entityType,
239241
);

0 commit comments

Comments
 (0)