Skip to content

Commit ab0fb0c

Browse files
authored
Merge pull request #310 from NEMStudios/task/g309_MosaicSupply_action
Fixed MosaicSupplyChangeTransaction schema issue (Direction -> Action)
2 parents ee1aa81 + 0201306 commit ab0fb0c

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

e2e/infrastructure/TransactionHttp.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ describe('TransactionHttp', () => {
11481148
const signedTransaction = mosaicSupplyChangeTransaction.signWith(account, generationHash);
11491149
listener.confirmed(account.address).subscribe((transaction: MosaicSupplyChangeTransaction) => {
11501150
expect(transaction.delta, 'Delta').not.to.be.undefined;
1151-
expect(transaction.direction, 'Direction').not.to.be.undefined;
1151+
expect(transaction.action, 'Action').not.to.be.undefined;
11521152
expect(transaction.mosaicId, 'MosaicId').not.to.be.undefined;
11531153
done();
11541154
});

e2e/infrastructure/transaction/CreateTransactionFromDTO.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ describe('CreateTransactionFromDTO', () => {
423423
transaction: {
424424
deadline: '1',
425425
delta: '1000',
426-
direction: 1,
426+
action: 1,
427427
maxFee: '0',
428428
mosaicId: '85BBEA6CC462B244',
429429
signature: '553E696EB4A54E43A11D180EBA57E4B89D0048C9DD2604A9E0608120018B9E0' +
@@ -472,7 +472,7 @@ describe('CreateTransactionFromDTO', () => {
472472
},
473473
transaction: {
474474
delta: '1000',
475-
direction: 1,
475+
action: 1,
476476
mosaicId: '85BBEA6CC462B244',
477477
signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF',
478478
type: 16973,

e2e/infrastructure/transaction/ValidateTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ const ValidateTransaction = {
112112
validateMosaicSupplyChangeTx: (mosaicSupplyChangeTransaction, mosaicSupplyChangeTransactionDTO) => {
113113
deepEqual(mosaicSupplyChangeTransaction.mosaicId,
114114
new MosaicId(mosaicSupplyChangeTransactionDTO.transaction.mosaicId));
115-
expect(mosaicSupplyChangeTransaction.direction)
116-
.to.be.equal(mosaicSupplyChangeTransactionDTO.transaction.direction);
115+
expect(mosaicSupplyChangeTransaction.action)
116+
.to.be.equal(mosaicSupplyChangeTransactionDTO.transaction.action);
117117
deepEqual(mosaicSupplyChangeTransaction.delta,
118118
UInt64.fromNumericString(mosaicSupplyChangeTransactionDTO.transaction.delta));
119119
},

src/infrastructure/transaction/CreateTransactionFromDTO.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
178178
Deadline.createFromDTO(transactionDTO.deadline),
179179
UInt64.fromNumericString(transactionDTO.maxFee || '0'),
180180
new MosaicId(transactionDTO.mosaicId),
181-
transactionDTO.direction,
181+
transactionDTO.action,
182182
UInt64.fromNumericString(transactionDTO.delta),
183183
transactionDTO.signature,
184184
transactionDTO.signerPublicKey ? PublicAccount.createFromPublicKey(transactionDTO.signerPublicKey,

src/infrastructure/transaction/SerializeTransactionToJSON.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export const SerializeTransactionToJSON = (transaction: Transaction): any => {
122122
case TransactionType.MOSAIC_SUPPLY_CHANGE:
123123
return {
124124
mosaicId: (transaction as MosaicSupplyChangeTransaction).mosaicId.toHex(),
125-
direction: (transaction as MosaicSupplyChangeTransaction).direction,
125+
action: (transaction as MosaicSupplyChangeTransaction).action,
126126
delta: (transaction as MosaicSupplyChangeTransaction).delta.toString(),
127127
};
128128
case TransactionType.REGISTER_NAMESPACE:

src/model/transaction/MosaicSupplyChangeTransaction.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ export class MosaicSupplyChangeTransaction extends Transaction {
4444
* Create a mosaic supply change transaction object
4545
* @param deadline - The deadline to include the transaction.
4646
* @param mosaicId - The mosaic id.
47-
* @param direction - The supply type.
47+
* @param action - The supply change action (increase | decrease).
4848
* @param delta - The supply change in units for the mosaic.
4949
* @param networkType - The network type.
5050
* @param maxFee - (Optional) Max fee defined by the sender
5151
* @returns {MosaicSupplyChangeTransaction}
5252
*/
5353
public static create(deadline: Deadline,
5454
mosaicId: MosaicId,
55-
direction: MosaicSupplyChangeAction,
55+
action: MosaicSupplyChangeAction,
5656
delta: UInt64,
5757
networkType: NetworkType,
5858
maxFee: UInt64 = new UInt64([0, 0])): MosaicSupplyChangeTransaction {
@@ -61,7 +61,7 @@ export class MosaicSupplyChangeTransaction extends Transaction {
6161
deadline,
6262
maxFee,
6363
mosaicId,
64-
direction,
64+
action,
6565
delta,
6666
);
6767
}
@@ -72,7 +72,7 @@ export class MosaicSupplyChangeTransaction extends Transaction {
7272
* @param deadline
7373
* @param maxFee
7474
* @param mosaicId
75-
* @param direction
75+
* @param action
7676
* @param delta
7777
* @param signature
7878
* @param signer
@@ -89,7 +89,7 @@ export class MosaicSupplyChangeTransaction extends Transaction {
8989
/**
9090
* The supply type.
9191
*/
92-
public readonly direction: MosaicSupplyChangeAction,
92+
public readonly action: MosaicSupplyChangeAction,
9393
/**
9494
* The supply change in units for the mosaic.
9595
*/
@@ -136,10 +136,10 @@ export class MosaicSupplyChangeTransaction extends Transaction {
136136

137137
// set static byte size fields
138138
const byteMosaicId = 8;
139-
const byteDirection = 1;
139+
const byteAction = 1;
140140
const byteDelta = 8;
141141

142-
return byteSize + byteMosaicId + byteDirection + byteDelta;
142+
return byteSize + byteMosaicId + byteAction + byteDelta;
143143
}
144144

145145
/**
@@ -158,7 +158,7 @@ export class MosaicSupplyChangeTransaction extends Transaction {
158158
new AmountDto(this.maxFee.toDTO()),
159159
new TimestampDto(this.deadline.toDTO()),
160160
new UnresolvedMosaicIdDto(this.mosaicId.id.toDTO()),
161-
this.direction.valueOf(),
161+
this.action.valueOf(),
162162
new AmountDto(this.delta.toDTO()),
163163
);
164164
return transactionBuilder.serialize();
@@ -174,7 +174,7 @@ export class MosaicSupplyChangeTransaction extends Transaction {
174174
this.versionToDTO(),
175175
TransactionType.MOSAIC_SUPPLY_CHANGE.valueOf(),
176176
new UnresolvedMosaicIdDto(this.mosaicId.id.toDTO()),
177-
this.direction.valueOf(),
177+
this.action.valueOf(),
178178
new AmountDto(this.delta.toDTO()),
179179
);
180180
return transactionBuilder.serialize();

test/core/utils/TransactionMapping.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ describe('TransactionMapping - createFromPayload', () => {
311311

312312
const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicSupplyChangeTransaction;
313313

314-
expect(transaction.direction).to.be.equal(MosaicSupplyChangeAction.Increase);
314+
expect(transaction.action).to.be.equal(MosaicSupplyChangeAction.Increase);
315315
expect(transaction.delta.lower).to.be.equal(10);
316316
expect(transaction.delta.higher).to.be.equal(0);
317317
expect(transaction.mosaicId.id.lower).to.be.equal(2262289484);
@@ -877,7 +877,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () =>
877877
TransactionMapping.createFromDTO(mosaicSupplyChangeTransaction.toJSON()) as MosaicSupplyChangeTransaction;
878878

879879
expect(transaction.type).to.be.equal(TransactionType.MOSAIC_SUPPLY_CHANGE);
880-
expect(transaction.direction).to.be.equal(MosaicSupplyChangeAction.Increase);
880+
expect(transaction.action).to.be.equal(MosaicSupplyChangeAction.Increase);
881881

882882
});
883883

test/infrastructure/SerializeTransactionToJSON.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import { expect } from 'chai';
1818
import { sha3_256 } from 'js-sha3';
1919
import {Convert as convert} from '../../src/core/format';
2020
import { Account } from '../../src/model/account/Account';
21-
import { AccountRestrictionModificationAction } from '../../src/model/restriction/AccountRestrictionModificationAction';
22-
import { AccountRestrictionType } from '../../src/model/restriction/AccountRestrictionType';
2321
import { Address } from '../../src/model/account/Address';
2422
import { PublicAccount } from '../../src/model/account/PublicAccount';
2523
import { NetworkType } from '../../src/model/blockchain/NetworkType';
@@ -31,6 +29,8 @@ import { MosaicSupplyChangeAction } from '../../src/model/mosaic/MosaicSupplyCha
3129
import { NetworkCurrencyMosaic } from '../../src/model/mosaic/NetworkCurrencyMosaic';
3230
import { AliasAction } from '../../src/model/namespace/AliasAction';
3331
import { NamespaceId } from '../../src/model/namespace/NamespaceId';
32+
import { AccountRestrictionModificationAction } from '../../src/model/restriction/AccountRestrictionModificationAction';
33+
import { AccountRestrictionType } from '../../src/model/restriction/AccountRestrictionType';
3434
import { AccountLinkTransaction } from '../../src/model/transaction/AccountLinkTransaction';
3535
import { AccountRestrictionModification } from '../../src/model/transaction/AccountRestrictionModification';
3636
import { AccountRestrictionTransaction } from '../../src/model/transaction/AccountRestrictionTransaction';
@@ -221,7 +221,7 @@ describe('SerializeTransactionToJSON', () => {
221221
const json = mosaicSupplyChangeTransaction.toJSON();
222222

223223
expect(json.transaction.type).to.be.equal(TransactionType.MOSAIC_SUPPLY_CHANGE);
224-
expect(json.transaction.direction).to.be.equal(MosaicSupplyChangeAction.Increase);
224+
expect(json.transaction.action).to.be.equal(MosaicSupplyChangeAction.Increase);
225225

226226
});
227227

test/model/transaction/MosaicSupplyChangeTransaction.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {NetworkType} from '../../../src/model/blockchain/NetworkType';
2020
import {MosaicId} from '../../../src/model/mosaic/MosaicId';
2121
import {MosaicSupplyChangeAction} from '../../../src/model/mosaic/MosaicSupplyChangeAction';
2222
import {Deadline} from '../../../src/model/transaction/Deadline';
23-
import {MosaicSupplyChangeTransaction,} from '../../../src/model/transaction/MosaicSupplyChangeTransaction';
23+
import {MosaicSupplyChangeTransaction} from '../../../src/model/transaction/MosaicSupplyChangeTransaction';
2424
import {UInt64} from '../../../src/model/UInt64';
2525
import {TestingAccount} from '../../conf/conf.spec';
2626

@@ -53,7 +53,7 @@ describe('MosaicSupplyChangeTransaction', () => {
5353
MosaicSupplyChangeAction.Increase,
5454
UInt64.fromUint(10),
5555
NetworkType.MIJIN_TEST,
56-
new UInt64([1, 0])
56+
new UInt64([1, 0]),
5757
);
5858

5959
expect(mosaicSupplyChangeTransaction.maxFee.higher).to.be.equal(0);
@@ -70,7 +70,7 @@ describe('MosaicSupplyChangeTransaction', () => {
7070
NetworkType.MIJIN_TEST,
7171
);
7272

73-
expect(mosaicSupplyChangeTransaction.direction).to.be.equal(MosaicSupplyChangeAction.Increase);
73+
expect(mosaicSupplyChangeTransaction.action).to.be.equal(MosaicSupplyChangeAction.Increase);
7474
expect(mosaicSupplyChangeTransaction.delta.lower).to.be.equal(10);
7575
expect(mosaicSupplyChangeTransaction.delta.higher).to.be.equal(0);
7676
expect(mosaicSupplyChangeTransaction.mosaicId.id.lower).to.be.equal(2262289484);

0 commit comments

Comments
 (0)