Skip to content

Commit 77c8524

Browse files
committed
JAV-3 [Github #244]
Made optional of: - previousRestrictionValue (MosaicAddressRestrictionTx) - referenceMosaicId (MosaicGlobalRestrictionTx)
1 parent f97a24b commit 77c8524

File tree

6 files changed

+10
-15
lines changed

6 files changed

+10
-15
lines changed

e2e/infrastructure/TransactionHttp.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ describe('TransactionHttp', () => {
419419
const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create(
420420
Deadline.create(),
421421
mosaicId,
422-
new MosaicId(UInt64.fromUint(0).toDTO()),
423422
UInt64.fromUint(60641),
424423
UInt64.fromUint(0),
425424
MosaicRestrictionType.NONE,
@@ -453,7 +452,6 @@ describe('TransactionHttp', () => {
453452
const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create(
454453
Deadline.create(),
455454
mosaicId,
456-
new MosaicId(UInt64.fromUint(0).toDTO()),
457455
UInt64.fromUint(60641),
458456
UInt64.fromUint(0),
459457
MosaicRestrictionType.GE,
@@ -494,7 +492,6 @@ describe('TransactionHttp', () => {
494492
mosaicId,
495493
UInt64.fromUint(60641),
496494
account3.address,
497-
UInt64.fromHex('FFFFFFFFFFFFFFFF'),
498495
UInt64.fromUint(2),
499496
NetworkType.MIJIN_TEST,
500497
);

src/model/transaction/MosaicAddressRestrictionTransaction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ export class MosaicAddressRestrictionTransaction extends Transaction {
5454
* @param mosaicId - The mosaic id ex: new MosaicId([481110499, 231112638]).
5555
* @param restrictionKey - The restriction key.
5656
* @param targetAddress - The affected unresolved address.
57-
* @param previousRestrictionValue - The previous restriction value.
5857
* @param newRestrictionValue - The new restriction value.
5958
* @param networkType - The network type.
59+
* @param previousRestrictionValue - (Optional) The previous restriction value.
6060
* @param maxFee - (Optional) Max fee defined by the sender
6161
* @returns {MosaicAddressRestrictionTransaction}
6262
*/
6363
public static create(deadline: Deadline,
6464
mosaicId: MosaicId,
6565
restrictionKey: UInt64,
6666
targetAddress: Address,
67-
previousRestrictionValue: UInt64,
6867
newRestrictionValue: UInt64,
6968
networkType: NetworkType,
69+
previousRestrictionValue: UInt64 = UInt64.fromHex('FFFFFFFFFFFFFFFF'),
7070
maxFee: UInt64 = new UInt64([0, 0])): MosaicAddressRestrictionTransaction {
7171
return new MosaicAddressRestrictionTransaction(networkType,
7272
TransactionVersion.MOSAIC_ADDRESS_RESTRICTION,
@@ -140,9 +140,9 @@ export class MosaicAddressRestrictionTransaction extends Transaction {
140140
new MosaicId(builder.getMosaicId().unresolvedMosaicId),
141141
new UInt64(builder.getRestrictionKey()),
142142
Address.createFromEncoded(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)),
143-
new UInt64(builder.getPreviousRestrictionValue()),
144143
new UInt64(builder.getNewRestrictionValue()),
145144
networkType,
145+
new UInt64(builder.getPreviousRestrictionValue()),
146146
isEmbedded ? new UInt64([0, 0]) : new UInt64((builder as MosaicAddressRestrictionTransactionBuilder).fee.amount),
147147
);
148148
return isEmbedded ?

src/model/transaction/MosaicGlobalRestrictionTransaction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,25 @@ export class MosaicGlobalRestrictionTransaction extends Transaction {
5454
*
5555
* @param deadline - The deadline to include the transaction.
5656
* @param mosaicId - The mosaic id ex: new MosaicId([481110499, 231112638]).
57-
* @param referenceMosaicId - The mosaic id providing the restriction key.
5857
* @param restrictionKey - The restriction key.
5958
* @param previousRestrictionValue - The previous restriction value.
6059
* @param previousRestrictionType - The previous restriction type.
6160
* @param newRestrictionValue - The new restriction value.
6261
* @param previousRestrictionType - The previous restriction tpye.
6362
* @param networkType - The network type.
63+
* @param referenceMosaicId - (Optional) The mosaic id providing the restriction key.
6464
* @param maxFee - (Optional) Max fee defined by the sender
6565
* @returns {MosaicGlobalRestrictionTransaction}
6666
*/
6767
public static create(deadline: Deadline,
6868
mosaicId: MosaicId,
69-
referenceMosaicId: MosaicId,
7069
restrictionKey: UInt64,
7170
previousRestrictionValue: UInt64,
7271
previousRestrictionType: MosaicRestrictionType,
7372
newRestrictionValue: UInt64,
7473
newRestrictionType: MosaicRestrictionType,
7574
networkType: NetworkType,
75+
referenceMosaicId: MosaicId = new MosaicId(UInt64.fromUint(0).toDTO()),
7676
maxFee: UInt64 = new UInt64([0, 0])): MosaicGlobalRestrictionTransaction {
7777
return new MosaicGlobalRestrictionTransaction(networkType,
7878
TransactionVersion.MOSAIC_GLOBAL_RESTRICTION,
@@ -154,13 +154,13 @@ export class MosaicGlobalRestrictionTransaction extends Transaction {
154154
isEmbedded ? Deadline.create() : Deadline.createFromDTO(
155155
(builder as MosaicGlobalRestrictionTransactionBuilder).getDeadline().timestamp),
156156
new MosaicId(builder.getMosaicId().unresolvedMosaicId),
157-
new MosaicId(builder.getReferenceMosaicId().unresolvedMosaicId),
158157
new UInt64(builder.getRestrictionKey()),
159158
new UInt64(builder.getPreviousRestrictionValue()),
160159
builder.getPreviousRestrictionType().valueOf(),
161160
new UInt64(builder.getNewRestrictionValue()),
162161
builder.getNewRestrictionType().valueOf(),
163162
networkType,
163+
new MosaicId(builder.getReferenceMosaicId().unresolvedMosaicId),
164164
isEmbedded ? new UInt64([0, 0]) : new UInt64((builder as MosaicGlobalRestrictionTransactionBuilder).fee.amount),
165165
);
166166
return isEmbedded ?

test/core/utils/TransactionMapping.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ describe('TransactionMapping - createFromPayload', () => {
534534
const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create(
535535
Deadline.create(),
536536
new MosaicId(UInt64.fromUint(1).toDTO()),
537-
new MosaicId(UInt64.fromUint(0).toDTO()),
538537
UInt64.fromUint(4444),
539538
UInt64.fromUint(0),
540539
MosaicRestrictionType.NONE,
@@ -564,8 +563,8 @@ describe('TransactionMapping - createFromPayload', () => {
564563
UInt64.fromUint(4444),
565564
account.address,
566565
UInt64.fromUint(0),
567-
UInt64.fromUint(0),
568566
NetworkType.MIJIN_TEST,
567+
UInt64.fromUint(0),
569568
);
570569

571570
const signedTx = mosaicAddressRestrictionTransaction.signWith(account, generationHash);
@@ -1019,7 +1018,6 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () =>
10191018
const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create(
10201019
Deadline.create(),
10211020
new MosaicId(UInt64.fromUint(1).toDTO()),
1022-
new MosaicId(UInt64.fromUint(0).toDTO()),
10231021
UInt64.fromUint(4444),
10241022
UInt64.fromUint(0),
10251023
MosaicRestrictionType.NONE,
@@ -1048,8 +1046,8 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () =>
10481046
UInt64.fromUint(4444),
10491047
account.address,
10501048
UInt64.fromUint(0),
1051-
UInt64.fromUint(0),
10521049
NetworkType.MIJIN_TEST,
1050+
UInt64.fromUint(0),
10531051
);
10541052

10551053
const transaction =

test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ describe('MosaicAddressRestrictionTransaction', () => {
3737
mosaicId,
3838
UInt64.fromUint(1),
3939
account.address,
40-
UInt64.fromUint(9),
4140
UInt64.fromUint(8),
4241
NetworkType.MIJIN_TEST,
42+
UInt64.fromUint(9),
4343
);
4444
expect(mosaicAddressRestrictionTransaction.mosaicId.toHex()).to.be.equal(mosaicId.toHex());
4545
expect(mosaicAddressRestrictionTransaction.restrictionKey.toHex()).to.be.equal(UInt64.fromUint(1).toHex());

test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ describe('MosaicGlobalRestrictionTransaction', () => {
3737
const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create(
3838
Deadline.create(),
3939
mosaicId,
40-
referenceMosaicId,
4140
UInt64.fromUint(1),
4241
UInt64.fromUint(9),
4342
MosaicRestrictionType.EQ,
4443
UInt64.fromUint(8),
4544
MosaicRestrictionType.GE,
4645
NetworkType.MIJIN_TEST,
46+
referenceMosaicId,
4747
);
4848

4949
expect(mosaicGlobalRestrictionTransaction.mosaicId.toHex()).to.be.equal(mosaicId.toHex());

0 commit comments

Comments
 (0)