From 350908c51e13ae3578639eb35d9cd93cfaa6ab5a Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Sat, 21 Sep 2019 16:08:35 +0100 Subject: [PATCH 1/3] JAV-19 [Github #259 #260] Removed unused mosaic properties coee Fixed jsdoc --- e2e/infrastructure/TransactionHttp.spec.ts | 2 +- .../CreateTransactionFromDTO.spec.ts | 371 ++++-------------- .../transaction/ValidateTransaction.ts | 38 +- src/infrastructure/model/models.ts | 3 - src/infrastructure/model/mosaicDTO.ts | 2 - .../transaction/SerializeTransactionToJSON.ts | 2 +- .../MosaicAddressRestrictionTransaction.ts | 7 +- .../MosaicDefinitionTransaction.ts | 6 +- .../MosaicGlobalRestrictionTransaction.ts | 24 +- .../NamespaceRegistrationTransaction.ts | 12 +- test/core/utils/TransactionMapping.spec.ts | 4 +- test/model/mosaic/Mosaic.spec.ts | 2 +- test/model/mosaic/MosaicFlags.spec.ts | 7 - 13 files changed, 130 insertions(+), 350 deletions(-) diff --git a/e2e/infrastructure/TransactionHttp.spec.ts b/e2e/infrastructure/TransactionHttp.spec.ts index 2f3506d179..184ed45e0b 100644 --- a/e2e/infrastructure/TransactionHttp.spec.ts +++ b/e2e/infrastructure/TransactionHttp.spec.ts @@ -315,7 +315,7 @@ describe('TransactionHttp', () => { listener.confirmed(account.address).subscribe((transaction: NamespaceRegistrationTransaction) => { expect(transaction.namespaceId, 'NamespaceId').not.to.be.undefined; expect(transaction.namespaceName, 'NamespaceName').not.to.be.undefined; - expect(transaction.namespaceType, 'NamespaceRegistrationType').not.to.be.undefined; + expect(transaction.registrationType, 'RegistrationType').not.to.be.undefined; done(); }); listener.status(account.address).subscribe((error) => { diff --git a/e2e/infrastructure/transaction/CreateTransactionFromDTO.spec.ts b/e2e/infrastructure/transaction/CreateTransactionFromDTO.spec.ts index 95ba819780..460b8e8a3b 100644 --- a/e2e/infrastructure/transaction/CreateTransactionFromDTO.spec.ts +++ b/e2e/infrastructure/transaction/CreateTransactionFromDTO.spec.ts @@ -26,10 +26,7 @@ describe('CreateTransactionFromDTO', () => { it('standalone', () => { const transferTransactionDTO = { meta: { - height: [ - 78, - 0, - ], + height: '78', hash: '533243B8575C4058F894C453160AFF055A4A905978AC331460F44104D831E4AC', merkleComponentHash: '533243B8575C4058F894C453160AFF055A4A905978AC331460F44104D831E4AC', index: 0, @@ -41,8 +38,8 @@ describe('CreateTransactionFromDTO', () => { signerPublicKey: '2FC3872A792933617D70E02AFF8FBDE152821A0DF0CA5FB04CB56FC3D21C8863', version: 36865, type: 16724, - maxFee: [0, 0], - deadline: [3362498678, 22], + maxFee: '0', + deadline: '1000', recipientAddress: '906415867F121D037AF447E711B0F5E4D52EBBF066D96860EB', message: { payload: '746573742D6D657373616765', @@ -50,8 +47,8 @@ describe('CreateTransactionFromDTO', () => { }, mosaics: [ { - id: [3294802500, 2243684972], - amount: [10, 0], + id: '85BBEA6CC462B244', + amount: '10', }, ], }, @@ -65,10 +62,7 @@ describe('CreateTransactionFromDTO', () => { it('standalone without message', () => { const transferTransactionDTO = { meta: { - height: [ - 78, - 0, - ], + height: '78', hash: '533243B8575C4058F894C453160AFF055A4A905978AC331460F44104D831E4AC', merkleComponentHash: '533243B8575C4058F894C453160AFF055A4A905978AC331460F44104D831E4AC', index: 0, @@ -80,13 +74,13 @@ describe('CreateTransactionFromDTO', () => { signerPublicKey: '2FC3872A792933617D70E02AFF8FBDE152821A0DF0CA5FB04CB56FC3D21C8863', version: 36865, type: 16724, - maxFee: [0, 0], - deadline: [3362498678, 22], + maxFee: '0', + deadline: '1000', recipientAddress: '906415867F121D037AF447E711B0F5E4D52EBBF066D96860EB', mosaics: [ { - id: [3294802500, 2243684972], - amount: [10, 0], + id: '85BBEA6CC462B244', + amount: '10', }, ], }, @@ -101,10 +95,7 @@ describe('CreateTransactionFromDTO', () => { const aggregateTransferTransactionDTO = { meta: { hash: '671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E55', index: 0, merkleComponentHash: '81E5E7AE49998802DABC816EC10158D3A7879702FF29084C2C992CD1289877A7', @@ -117,14 +108,8 @@ describe('CreateTransactionFromDTO', () => { signerPublicKey: 'A5F82EC8EBB341427B6785C8111906CD0DF18838FB11B51CE0E18B5E79DFF630', }, ], - deadline: [ - 3266625578, - 11, - ], - maxFee: [ - 0, - 0, - ], + deadline: '1000', + maxFee: '0', signature: '939673209A13FF82397578D22CC96EB8516A6760C894D9B7535E3A1E0680' + '07B9255CFA9A914C97142A7AE18533E381C846B69D2AE0D60D1DC8A55AD120E2B606', signerPublicKey: '7681ED5023141D9CDCF184E5A7B60B7D466739918ED5DA30F7E71EA7B86EFF2D', @@ -133,10 +118,7 @@ describe('CreateTransactionFromDTO', () => { meta: { aggregateHash: '3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006', aggregateId: '5A0069D83F17CF0001777E55', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E56', index: 0, }, @@ -147,14 +129,8 @@ describe('CreateTransactionFromDTO', () => { }, mosaics: [ { - amount: [ - 3863990592, - 95248, - ], - id: [ - 3646934825, - 3576016193, - ], + amount: '1000', + id: '85BBEA6CC462B244', }, ], recipientAddress: '9050B9837EFAB4BBE8A4B9BB32D812F9885C00D8FC1650E142', @@ -181,33 +157,18 @@ describe('CreateTransactionFromDTO', () => { const registerNamespaceTransactionDTO = { meta: { hash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', - height: [ - 1, - 0, - ], + height: '1', id: '59FDA0733F17CF0001772CA7', index: 19, merkleComponentHash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', }, transaction: { - deadline: [ - 1, - 0, - ], - duration: [ - 1000, - 0, - ], - maxFee: [ - 0, - 0, - ], + deadline: '1', + duration: '1000', + maxFee: '0', name: 'a2p1mg', - namespaceId: [ - 437145074, - 4152736179, - ], - namespaceType: 0, + id: '85BBEA6CC462B244', + registrationType: 0, signature: '553E696EB4A54E43A11D180EBA57E4B89D0048C9DD2604A9E0608120018B9E0' + '2F6EE63025FEEBCED3293B622AF8581334D0BDAB7541A9E7411E7EE4EF0BC5D0E', signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', @@ -225,10 +186,7 @@ describe('CreateTransactionFromDTO', () => { const aggregateNamespaceRegistrationTransactionDTO = { meta: { hash: '671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E55', index: 0, merkleComponentHash: '81E5E7AE49998802DABC816EC10158D3A7879702FF29084C2C992CD1289877A7', @@ -241,14 +199,8 @@ describe('CreateTransactionFromDTO', () => { signerPublicKey: 'A5F82EC8EBB341427B6785C8111906CD0DF18838FB11B51CE0E18B5E79DFF630', }, ], - deadline: [ - 3266625578, - 11, - ], - maxFee: [ - 0, - 0, - ], + deadline: '1000', + maxFee: '0', signature: '939673209A13FF82397578D22CC96EB8516A6760C894D9B7535E3A1E0680' + '07B9255CFA9A914C97142A7AE18533E381C846B69D2AE0D60D1DC8A55AD120E2B606', signerPublicKey: '7681ED5023141D9CDCF184E5A7B60B7D466739918ED5DA30F7E71EA7B86EFF2D', @@ -257,24 +209,15 @@ describe('CreateTransactionFromDTO', () => { meta: { aggregateHash: '3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006', aggregateId: '5A0069D83F17CF0001777E55', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E56', index: 0, }, transaction: { - duration: [ - 1000, - 0, - ], + duration: '1000', name: 'a2p1mg', - namespaceId: [ - 437145074, - 4152736179, - ], - namespaceType: 0, + id: '85BBEA6CC462B244', + registrationType: 0, signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', type: 16718, version: 36865, @@ -300,33 +243,18 @@ describe('CreateTransactionFromDTO', () => { const registerNamespaceTransactionDTO = { meta: { hash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', - height: [ - 1, - 0, - ], + height: '1', id: '59FDA0733F17CF0001772CA7', index: 19, merkleComponentHash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', }, transaction: { - deadline: [ - 1, - 0, - ], - maxFee: [ - 0, - 0, - ], + deadline: '1', + maxFee: '0', name: '0unius', - namespaceId: [ - 1970060410, - 3289875941, - ], - namespaceType: 1, - parentId: [ - 3316183705, - 3829351378, - ], + id: '99BBEA6CC462B244', + registrationType: 1, + parentId: '85BBEA6CC462B244', signature: '553E696EB4A54E43A11D180EBA57E4B89D0048C9DD2604A9E0608120018B9' + 'E02F6EE63025FEEBCED3293B622AF8581334D0BDAB7541A9E7411E7EE4EF0BC5D0E', signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', @@ -343,10 +271,7 @@ describe('CreateTransactionFromDTO', () => { const aggregateNamespaceRegistrationTransactionDTO = { meta: { hash: '671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E55', index: 0, merkleComponentHash: '81E5E7AE49998802DABC816EC10158D3A7879702FF29084C2C992CD1289877A7', @@ -359,14 +284,8 @@ describe('CreateTransactionFromDTO', () => { signerPublicKey: 'A5F82EC8EBB341427B6785C8111906CD0DF18838FB11B51CE0E18B5E79DFF630', }, ], - deadline: [ - 3266625578, - 11, - ], - maxFee: [ - 0, - 0, - ], + deadline: '1000', + maxFee: '0', signature: '939673209A13FF82397578D22CC96EB8516A6760C894D9B7535E3A1E0680' + '07B9255CFA9A914C97142A7AE18533E381C846B69D2AE0D60D1DC8A55AD120E2B606', signerPublicKey: '7681ED5023141D9CDCF184E5A7B60B7D466739918ED5DA30F7E71EA7B86EFF2D', @@ -375,24 +294,15 @@ describe('CreateTransactionFromDTO', () => { meta: { aggregateHash: '3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006', aggregateId: '5A0069D83F17CF0001777E55', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E56', index: 0, }, transaction: { name: '0unius', - namespaceId: [ - 1970060410, - 3289875941, - ], - namespaceType: 1, - parentId: [ - 3316183705, - 3829351378, - ], + id: '99BBEA6CC462B244', + registrationType: 1, + parentId: '85BBEA6CC462B244', signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', type: 16718, version: 36865, @@ -418,54 +328,19 @@ describe('CreateTransactionFromDTO', () => { const mosaicDefinitionTransactionDTO = { meta: { hash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', - height: [ - 1, - 0, - ], + height: '1', id: '59FDA0733F17CF0001772CA7', index: 19, merkleComponentHash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', }, transaction: { - deadline: [ - 1, - 0, - ], - maxFee: [ - 0, - 0, - ], - mosaicId: [ - 3248159581, - 740240531, - ], - nonce: [ - 1, - 0, - ], - properties: [ - { - id: 0, - value: [ - 7, - 0, - ], - }, - { - id: 1, - value: [ - 6, - 0, - ], - }, - { - id: 2, - value: [ - 1000, - 0, - ], - }, - ], + deadline: '1', + maxFee: '0', + id: '85BBEA6CC462B244', + nonce: '1', + flags: 7, + diversibility: 6, + duration: '1000', signature: '553E696EB4A54E43A11D180EBA57E4B89D0048C9DD2604A9E0608120018B9E02F6EE63025FE' + 'EBCED3293B622AF8581334D0BDAB7541A9E7411E7EE4EF0BC5D0E', signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', @@ -483,10 +358,7 @@ describe('CreateTransactionFromDTO', () => { const aggregateMosaicDefinitionTransactionDTO = { meta: { hash: '671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E55', index: 0, merkleComponentHash: '81E5E7AE49998802DABC816EC10158D3A7879702FF29084C2C992CD1289877A7', @@ -499,14 +371,8 @@ describe('CreateTransactionFromDTO', () => { signerPublicKey: 'A5F82EC8EBB341427B6785C8111906CD0DF18838FB11B51CE0E18B5E79DFF630', }, ], - deadline: [ - 3266625578, - 11, - ], - maxFee: [ - 0, - 0, - ], + deadline: '1000', + maxFee: '0', signature: '939673209A13FF82397578D22CC96EB8516A6760C894D9B7535E3A1E0680' + '07B9255CFA9A914C97142A7AE18533E381C846B69D2AE0D60D1DC8A55AD120E2B606', signerPublicKey: '7681ED5023141D9CDCF184E5A7B60B7D466739918ED5DA30F7E71EA7B86EFF2D', @@ -515,45 +381,16 @@ describe('CreateTransactionFromDTO', () => { meta: { aggregateHash: '3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006', aggregateId: '5A0069D83F17CF0001777E55', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E56', index: 0, }, transaction: { - mosaicId: [ - 3248159581, - 740240531, - ], - nonce: [ - 1, - 0, - ], - properties: [ - { - id: 0, - value: [ - 7, - 0, - ], - }, - { - id: 1, - value: [ - 6, - 0, - ], - }, - { - id: 2, - value: [ - 1000, - 0, - ], - }, - ], + id: '85BBEA6CC462B244', + nonce: '1', + flags: 7, + divisibility: 6, + duration: '1000', signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', type: 16717, version: 36865, @@ -578,32 +415,17 @@ describe('CreateTransactionFromDTO', () => { const mosaicSupplyChangeTransactionDTO = { meta: { hash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', - height: [ - 1, - 0, - ], + height: '1', id: '59FDA0733F17CF0001772CA7', index: 19, merkleComponentHash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', }, transaction: { - deadline: [ - 1, - 0, - ], - delta: [ - 100000, - 0, - ], + deadline: '1', + delta: '1000', direction: 1, - maxFee: [ - 0, - 0, - ], - mosaicId: [ - 3070467832, - 2688515262, - ], + maxFee: '0', + mosaicId: '85BBEA6CC462B244', signature: '553E696EB4A54E43A11D180EBA57E4B89D0048C9DD2604A9E0608120018B9E0' + '2F6EE63025FEEBCED3293B622AF8581334D0BDAB7541A9E7411E7EE4EF0BC5D0E', signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', @@ -621,10 +443,7 @@ describe('CreateTransactionFromDTO', () => { const aggregateMosaicSupplyChangeTransactionDTO = { meta: { hash: '671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E55', index: 0, merkleComponentHash: '81E5E7AE49998802DABC816EC10158D3A7879702FF29084C2C992CD1289877A7', @@ -637,14 +456,8 @@ describe('CreateTransactionFromDTO', () => { signerPublicKey: 'A5F82EC8EBB341427B6785C8111906CD0DF18838FB11B51CE0E18B5E79DFF630', }, ], - deadline: [ - 3266625578, - 11, - ], - maxFee: [ - 0, - 0, - ], + deadline: '1000', + maxFee: '0', signature: '939673209A13FF82397578D22CC96EB8516A6760C894D9B7535E3A1E0680' + '07B9255CFA9A914C97142A7AE18533E381C846B69D2AE0D60D1DC8A55AD120E2B606', signerPublicKey: '7681ED5023141D9CDCF184E5A7B60B7D466739918ED5DA30F7E71EA7B86EFF2D', @@ -653,23 +466,14 @@ describe('CreateTransactionFromDTO', () => { meta: { aggregateHash: '3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006', aggregateId: '5A0069D83F17CF0001777E55', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E56', index: 0, }, transaction: { - delta: [ - 100000, - 0, - ], + delta: '1000', direction: 1, - mosaicId: [ - 3070467832, - 2688515262, - ], + mosaicId: '85BBEA6CC462B244', signerPublicKey: 'B4F12E7C9F6946091E2CB8B6D3A12B50D17CCBBF646386EA27CE2946A7423DCF', type: 16973, version: 36865, @@ -694,23 +498,14 @@ describe('CreateTransactionFromDTO', () => { const modifyMultisigAccountTransactionDTO = { meta: { hash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', - height: [ - 1, - 0, - ], + height: '1', id: '59FDA0733F17CF0001772CA7', index: 19, merkleComponentHash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', }, transaction: { - deadline: [ - 1, - 0, - ], - maxFee: [ - 0, - 0, - ], + deadline: '1', + maxFee: '0', minApprovalDelta: 1, minRemovalDelta: 1, modifications: [ @@ -737,10 +532,7 @@ describe('CreateTransactionFromDTO', () => { const aggregateMultisigAccountModificationTransactionDTO = { meta: { hash: '671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E55', index: 0, merkleComponentHash: '81E5E7AE49998802DABC816EC10158D3A7879702FF29084C2C992CD1289877A7', @@ -753,14 +545,8 @@ describe('CreateTransactionFromDTO', () => { signerPublicKey: 'A5F82EC8EBB341427B6785C8111906CD0DF18838FB11B51CE0E18B5E79DFF630', }, ], - deadline: [ - 3266625578, - 11, - ], - maxFee: [ - 0, - 0, - ], + deadline: '1000', + maxFee: '0', signature: '939673209A13FF82397578D22CC96EB8516A6760C894D9B7535E3A1E0680' + '07B9255CFA9A914C97142A7AE18533E381C846B69D2AE0D60D1DC8A55AD120E2B606', signerPublicKey: '7681ED5023141D9CDCF184E5A7B60B7D466739918ED5DA30F7E71EA7B86EFF2D', @@ -769,10 +555,7 @@ describe('CreateTransactionFromDTO', () => { meta: { aggregateHash: '3D28C804EDD07D5A728E5C5FFEC01AB07AFA5766AE6997B38526D36015A4D006', aggregateId: '5A0069D83F17CF0001777E55', - height: [ - 18160, - 0, - ], + height: '1860', id: '5A0069D83F17CF0001777E56', index: 0, }, diff --git a/e2e/infrastructure/transaction/ValidateTransaction.ts b/e2e/infrastructure/transaction/ValidateTransaction.ts index 66789cc3a1..53982e10e4 100644 --- a/e2e/infrastructure/transaction/ValidateTransaction.ts +++ b/e2e/infrastructure/transaction/ValidateTransaction.ts @@ -28,7 +28,7 @@ import {UInt64} from '../../../src/model/UInt64'; const ValidateTransaction = { validateStandaloneTx: (transaction, transactionDTO) => { deepEqual(transaction.transactionInfo.height, - new UInt64(transactionDTO.meta.height)); + UInt64.fromNumericString(transactionDTO.meta.height)); expect(transaction.transactionInfo.hash) .to.be.equal(transactionDTO.meta.hash); expect(transaction.transactionInfo.merkleComponentHash) @@ -49,8 +49,8 @@ const ValidateTransaction = { expect(transaction.type) .to.be.equal(transactionDTO.transaction.type); deepEqual(transaction.maxFee, - new UInt64(transactionDTO.transaction.maxFee)); - deepEqual(transaction.deadline.toDTO(), + UInt64.fromNumericString(transactionDTO.transaction.maxFee)); + deepEqual(transaction.deadline.toString(), transactionDTO.transaction.deadline); if (transaction.type === TransactionType.TRANSFER) { @@ -67,7 +67,7 @@ const ValidateTransaction = { }, validateAggregateTx: (aggregateTransaction, aggregateTransactionDTO) => { deepEqual(aggregateTransaction.transactionInfo.height, - new UInt64(aggregateTransactionDTO.meta.height)); + UInt64.fromNumericString(aggregateTransactionDTO.meta.height)); expect(aggregateTransaction.transactionInfo.hash) .to.be.equal(aggregateTransactionDTO.meta.hash); expect(aggregateTransaction.transactionInfo.merkleComponentHash) @@ -88,8 +88,8 @@ const ValidateTransaction = { expect(aggregateTransaction.type) .to.be.equal(aggregateTransactionDTO.transaction.type); deepEqual(aggregateTransaction.maxFee, - new UInt64(aggregateTransactionDTO.transaction.maxFee)); - deepEqual(aggregateTransaction.deadline.toDTO(), + UInt64.fromNumericString(aggregateTransactionDTO.transaction.maxFee)); + deepEqual(aggregateTransaction.deadline.toString(), aggregateTransactionDTO.transaction.deadline); ValidateTransaction.validateStandaloneTx(aggregateTransaction.innerTransactions[0], @@ -98,15 +98,15 @@ const ValidateTransaction = { validateMosaicCreationTx: (mosaicDefinitionTransaction, mosaicDefinitionTransactionDTO) => { deepEqual(mosaicDefinitionTransaction.mosaicId, - new MosaicId(mosaicDefinitionTransactionDTO.transaction.mosaicId)); - expect(mosaicDefinitionTransaction.mosaicProperties.divisibility) - .to.be.equal(mosaicDefinitionTransactionDTO.transaction.properties[1].value[0]); - deepEqual(mosaicDefinitionTransaction.mosaicProperties.duration, - new UInt64(mosaicDefinitionTransactionDTO.transaction.properties[2].value)); + new MosaicId(mosaicDefinitionTransactionDTO.transaction.id)); + expect(mosaicDefinitionTransaction.divisibility) + .to.be.equal(mosaicDefinitionTransactionDTO.transaction.divisibility); + deepEqual(mosaicDefinitionTransaction.duration, + UInt64.fromNumericString(mosaicDefinitionTransactionDTO.transaction.duration)); - expect(mosaicDefinitionTransaction.mosaicProperties.supplyMutable) + expect(mosaicDefinitionTransaction.flags.supplyMutable) .to.be.equal(true); - expect(mosaicDefinitionTransaction.mosaicProperties.transferable) + expect(mosaicDefinitionTransaction.flags.transferable) .to.be.equal(true); }, validateMosaicSupplyChangeTx: (mosaicSupplyChangeTransaction, mosaicSupplyChangeTransactionDTO) => { @@ -115,7 +115,7 @@ const ValidateTransaction = { expect(mosaicSupplyChangeTransaction.direction) .to.be.equal(mosaicSupplyChangeTransactionDTO.transaction.direction); deepEqual(mosaicSupplyChangeTransaction.delta, - new UInt64(mosaicSupplyChangeTransactionDTO.transaction.delta)); + UInt64.fromNumericString(mosaicSupplyChangeTransactionDTO.transaction.delta)); }, validateMultisigModificationTx: (modifyMultisigAccountTransaction, modifyMultisigAccountTransactionDTO) => { expect(modifyMultisigAccountTransaction.minApprovalDelta) @@ -131,16 +131,16 @@ const ValidateTransaction = { ); }, validateNamespaceCreationTx: (registerNamespaceTransaction, registerNamespaceTransactionDTO) => { - expect(registerNamespaceTransaction.namespaceType) - .to.be.equal(registerNamespaceTransactionDTO.transaction.namespaceType); + expect(registerNamespaceTransaction.registrationType) + .to.be.equal(registerNamespaceTransactionDTO.transaction.registrationType); expect(registerNamespaceTransaction.namespaceName) .to.be.equal(registerNamespaceTransactionDTO.transaction.name); deepEqual(registerNamespaceTransaction.namespaceId, - NamespaceId.createFromEncoded(registerNamespaceTransactionDTO.transaction.namespaceId)); + NamespaceId.createFromEncoded(registerNamespaceTransactionDTO.transaction.id)); - if (registerNamespaceTransaction.namespaceType === 0) { + if (registerNamespaceTransaction.registrationType === 0) { deepEqual(registerNamespaceTransaction.duration, - new UInt64(registerNamespaceTransactionDTO.transaction.duration)); + UInt64.fromNumericString(registerNamespaceTransactionDTO.transaction.duration)); } else { deepEqual(registerNamespaceTransaction.parentId, NamespaceId.createFromEncoded(registerNamespaceTransactionDTO.transaction.parentId)); diff --git a/src/infrastructure/model/models.ts b/src/infrastructure/model/models.ts index 49ccd87e9b..7f0fbedea8 100644 --- a/src/infrastructure/model/models.ts +++ b/src/infrastructure/model/models.ts @@ -92,7 +92,6 @@ export * from './mosaicDefinitionTransactionDTO'; export * from './mosaicIds'; export * from './mosaicInfoDTO'; export * from './mosaicNamesDTO'; -export * from './mosaicPropertiesDTO'; export * from './mosaicRestrictionTypeEnum'; export * from './mosaicSupplyChangeActionEnum'; export * from './mosaicSupplyChangeTransactionBodyDTO'; @@ -239,7 +238,6 @@ import { MosaicDefinitionTransactionDTO } from './mosaicDefinitionTransactionDTO import { MosaicIds } from './mosaicIds'; import { MosaicInfoDTO } from './mosaicInfoDTO'; import { MosaicNamesDTO } from './mosaicNamesDTO'; -import { MosaicPropertiesDTO } from './mosaicPropertiesDTO'; import { MosaicRestrictionTypeEnum } from './mosaicRestrictionTypeEnum'; import { MosaicSupplyChangeActionEnum } from './mosaicSupplyChangeActionEnum'; import { MosaicSupplyChangeTransactionBodyDTO } from './mosaicSupplyChangeTransactionBodyDTO'; @@ -406,7 +404,6 @@ let typeMap: {[index: string]: any} = { "MosaicIds": MosaicIds, "MosaicInfoDTO": MosaicInfoDTO, "MosaicNamesDTO": MosaicNamesDTO, - "MosaicPropertiesDTO": MosaicPropertiesDTO, "MosaicSupplyChangeTransactionBodyDTO": MosaicSupplyChangeTransactionBodyDTO, "MosaicSupplyChangeTransactionDTO": MosaicSupplyChangeTransactionDTO, "MosaicsNamesDTO": MosaicsNamesDTO, diff --git a/src/infrastructure/model/mosaicDTO.ts b/src/infrastructure/model/mosaicDTO.ts index e15419eac9..c62fabe3ba 100644 --- a/src/infrastructure/model/mosaicDTO.ts +++ b/src/infrastructure/model/mosaicDTO.ts @@ -25,8 +25,6 @@ * Do not edit the class manually. */ -import { MosaicPropertiesDTO } from './mosaicPropertiesDTO'; - export class MosaicDTO { /** * Mosaic identifier. diff --git a/src/infrastructure/transaction/SerializeTransactionToJSON.ts b/src/infrastructure/transaction/SerializeTransactionToJSON.ts index 3544a83fce..cac7fc3e1f 100644 --- a/src/infrastructure/transaction/SerializeTransactionToJSON.ts +++ b/src/infrastructure/transaction/SerializeTransactionToJSON.ts @@ -130,7 +130,7 @@ export const SerializeTransactionToJSON = (transaction: Transaction): any => { const registerNamespaceParentId = (transaction as NamespaceRegistrationTransaction).parentId; const jsonObject = { - namespaceType: (transaction as NamespaceRegistrationTransaction).namespaceType, + registrationType: (transaction as NamespaceRegistrationTransaction).registrationType, namespaceName: (transaction as NamespaceRegistrationTransaction).namespaceName, id: (transaction as NamespaceRegistrationTransaction).namespaceId.toHex(), }; diff --git a/src/model/transaction/MosaicAddressRestrictionTransaction.ts b/src/model/transaction/MosaicAddressRestrictionTransaction.ts index 61d1560ddf..bffe4a6a08 100644 --- a/src/model/transaction/MosaicAddressRestrictionTransaction.ts +++ b/src/model/transaction/MosaicAddressRestrictionTransaction.ts @@ -85,9 +85,12 @@ export class MosaicAddressRestrictionTransaction extends Transaction { * @param version * @param deadline * @param maxFee - * @param mosaicNonce * @param mosaicId - * @param mosaicProperties + * @param signature + * @param restrictionKey + * @param targetAddress + * @param previousRestrictionValue + * @param newRestrictionValue * @param signature * @param signer * @param transactionInfo diff --git a/src/model/transaction/MosaicDefinitionTransaction.ts b/src/model/transaction/MosaicDefinitionTransaction.ts index 024037a051..547b1b0ded 100644 --- a/src/model/transaction/MosaicDefinitionTransaction.ts +++ b/src/model/transaction/MosaicDefinitionTransaction.ts @@ -81,9 +81,11 @@ export class MosaicDefinitionTransaction extends Transaction { * @param version * @param deadline * @param maxFee - * @param mosaicNonce + * @param nonce * @param mosaicId - * @param mosaicProperties + * @param flags + * @param divisibility + * @param duration * @param signature * @param signer * @param transactionInfo diff --git a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts index f55a120269..89348522cc 100644 --- a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts +++ b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts @@ -89,16 +89,20 @@ export class MosaicGlobalRestrictionTransaction extends Transaction { } /** - * @param networkType - * @param version - * @param deadline - * @param maxFee - * @param mosaicNonce - * @param mosaicId - * @param mosaicProperties - * @param signature - * @param signer - * @param transactionInfo + * @param networkType - The network type + * @param version - The transaction version + * @param deadline - The deadline to include the transaction. + * @param maxFee - (Optional) Max fee defined by the sender + * @param mosaicId - The mosaic id ex: new MosaicId([481110499, 231112638]). + * @param referenceMosaicId - The mosaic id providing the restriction key. + * @param restrictionKey - The restriction key. + * @param previousRestrictionValue - The previous restriction value. + * @param previousRestrictionType - The previous restriction type. + * @param newRestrictionValue - The new restriction value. + * @param previousRestrictionType - The previous restriction tpye. + * @param signature - The transaction signature + * @param signer - The signer + * @param transactionInfo - The transaction info */ constructor(networkType: NetworkType, version: number, diff --git a/src/model/transaction/NamespaceRegistrationTransaction.ts b/src/model/transaction/NamespaceRegistrationTransaction.ts index 436bf20c9a..7b9b228553 100644 --- a/src/model/transaction/NamespaceRegistrationTransaction.ts +++ b/src/model/transaction/NamespaceRegistrationTransaction.ts @@ -108,7 +108,7 @@ export class NamespaceRegistrationTransaction extends Transaction { * @param version * @param deadline * @param maxFee - * @param namespaceType + * @param registrationType * @param namespaceName * @param namespaceId * @param duration @@ -124,7 +124,7 @@ export class NamespaceRegistrationTransaction extends Transaction { /** * The namespace type could be namespace or sub namespace */ - public readonly namespaceType: NamespaceRegistrationType, + public readonly registrationType: NamespaceRegistrationType, /** * The namespace name */ @@ -158,10 +158,10 @@ export class NamespaceRegistrationTransaction extends Transaction { isEmbedded: boolean = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNamespaceRegistrationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NamespaceRegistrationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); - const namespaceType = builder.getRegistrationType().valueOf(); + const registrationType = builder.getRegistrationType().valueOf(); const signerPublicKey = Convert.uint8ToHex(builder.getSignerPublicKey().key); const networkType = Convert.hexToUint8(builder.getVersion().toString(16))[0]; - const transaction = namespaceType === NamespaceRegistrationType.RootNamespace ? + const transaction = registrationType === NamespaceRegistrationType.RootNamespace ? NamespaceRegistrationTransaction.createRootNamespace( isEmbedded ? Deadline.create() : Deadline.createFromDTO( (builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp), @@ -210,7 +210,7 @@ export class NamespaceRegistrationTransaction extends Transaction { const signerBuffer = new Uint8Array(32); const signatureBuffer = new Uint8Array(64); let transactionBuilder: NamespaceRegistrationTransactionBuilder; - if (this.namespaceType === NamespaceRegistrationType.RootNamespace) { + if (this.registrationType === NamespaceRegistrationType.RootNamespace) { transactionBuilder = new NamespaceRegistrationTransactionBuilder( new SignatureDto(signatureBuffer), new KeyDto(signerBuffer), @@ -246,7 +246,7 @@ export class NamespaceRegistrationTransaction extends Transaction { */ protected generateEmbeddedBytes(): Uint8Array { let transactionBuilder: EmbeddedNamespaceRegistrationTransactionBuilder; - if (this.namespaceType === NamespaceRegistrationType.RootNamespace) { + if (this.registrationType === NamespaceRegistrationType.RootNamespace) { transactionBuilder = new EmbeddedNamespaceRegistrationTransactionBuilder( new KeyDto(Convert.hexToUint8(this.signer!.publicKey)), this.versionToDTO(), diff --git a/test/core/utils/TransactionMapping.spec.ts b/test/core/utils/TransactionMapping.spec.ts index c50ebb60fb..2905fa2a9c 100644 --- a/test/core/utils/TransactionMapping.spec.ts +++ b/test/core/utils/TransactionMapping.spec.ts @@ -509,7 +509,7 @@ describe('TransactionMapping - createFromPayload', () => { const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as NamespaceRegistrationTransaction; - expect(transaction.namespaceType).to.be.equal(NamespaceRegistrationType.RootNamespace); + expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.RootNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); }); @@ -526,7 +526,7 @@ describe('TransactionMapping - createFromPayload', () => { const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as NamespaceRegistrationTransaction; - expect(transaction.namespaceType).to.be.equal(NamespaceRegistrationType.SubNamespace); + expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.SubNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); }); diff --git a/test/model/mosaic/Mosaic.spec.ts b/test/model/mosaic/Mosaic.spec.ts index b3fa2f01b0..5364952fad 100644 --- a/test/model/mosaic/Mosaic.spec.ts +++ b/test/model/mosaic/Mosaic.spec.ts @@ -16,8 +16,8 @@ import {deepEqual} from 'assert'; import {Mosaic} from '../../../src/model/mosaic/Mosaic'; -import {UInt64} from '../../../src/model/UInt64'; import {MosaicId} from '../../../src/model/mosaic/MosaicId'; +import {UInt64} from '../../../src/model/UInt64'; describe('Mosaic', () => { diff --git a/test/model/mosaic/MosaicFlags.spec.ts b/test/model/mosaic/MosaicFlags.spec.ts index d8e5f71567..e38eada1cc 100644 --- a/test/model/mosaic/MosaicFlags.spec.ts +++ b/test/model/mosaic/MosaicFlags.spec.ts @@ -22,14 +22,7 @@ import {UInt64} from '../../../src/model/UInt64'; describe('MosaicFlags', () => { it('should createComplete an MosaicFlags object with constructor', () => { - const propertiesDTO = { - flags: 7, - divisibility: 3, - duration: '1000', - }; - const mosaicFlags = new MosaicFlags(7); - expect(mosaicFlags.supplyMutable).to.be.equal(true); expect(mosaicFlags.transferable).to.be.equal(true); expect(mosaicFlags.restrictable).to.be.equal(true); From 7f6048e97d20189f1ea91cf96f1a35a59aabbac1 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Sat, 21 Sep 2019 16:50:56 +0100 Subject: [PATCH 2/3] Fixed #241 --- src/infrastructure/AccountHttp.ts | 2 +- src/model/wallet/EncryptedPrivateKey.ts | 6 ++---- src/model/wallet/SimpleWallet.ts | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/infrastructure/AccountHttp.ts b/src/infrastructure/AccountHttp.ts index 43e6629f17..e9d7c636f7 100644 --- a/src/infrastructure/AccountHttp.ts +++ b/src/infrastructure/AccountHttp.ts @@ -32,6 +32,7 @@ import { NamespaceId } from '../model/namespace/NamespaceId'; import { NamespaceName } from '../model/namespace/NamespaceName'; import {AggregateTransaction} from '../model/transaction/AggregateTransaction'; import {Transaction} from '../model/transaction/Transaction'; +import { UInt64 } from '../model/UInt64'; import {AccountRepository} from './AccountRepository'; import { AccountInfoDTO, AccountNamesDTO, @@ -45,7 +46,6 @@ import {Http} from './Http'; import {NetworkHttp} from './NetworkHttp'; import {QueryParams} from './QueryParams'; import {CreateTransactionFromDTO} from './transaction/CreateTransactionFromDTO'; -import { UInt64 } from '../model/UInt64'; /** * Account http repository. diff --git a/src/model/wallet/EncryptedPrivateKey.ts b/src/model/wallet/EncryptedPrivateKey.ts index ff6f21132b..42fb702dad 100644 --- a/src/model/wallet/EncryptedPrivateKey.ts +++ b/src/model/wallet/EncryptedPrivateKey.ts @@ -23,7 +23,6 @@ import { WalletAlgorithm } from './WalletAlgorithm'; */ export class EncryptedPrivateKey { /** - * @internal * @param encryptedKey * @param iv */ @@ -40,15 +39,14 @@ export class EncryptedPrivateKey { } /** - * @internal * Decrypt an encrypted private key * @param password */ - decrypt(password: Password): string { + public decrypt(password: Password): string { const common = { password: password.value, privateKey: '', - } + }; const wallet = { encrypted: this.encryptedKey, iv: this.iv, diff --git a/src/model/wallet/SimpleWallet.ts b/src/model/wallet/SimpleWallet.ts index 3b4d51f21e..70d5f613d5 100644 --- a/src/model/wallet/SimpleWallet.ts +++ b/src/model/wallet/SimpleWallet.ts @@ -30,7 +30,6 @@ import {Wallet} from './Wallet'; export class SimpleWallet extends Wallet { /** - * @internal * @param name * @param network * @param address From 23b7b41b2e6155470634f75dabf0be499ae69693 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Sat, 21 Sep 2019 22:27:35 +0100 Subject: [PATCH 3/3] Fixed readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e00abf4bc..a8f8bacf8c 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ with the NEM2 (a.k.a Catapult) Due to a network upgrade with [catapult-server@elephant3](https://github.com/nemtech/catapult-server/releases/tag/v0.7.0.1) version, **it is recommended to use this package's 0.13.2 version and upwards to use this package with Elephant versioned networks**. -The upgrade to this package's [version v0.13.1](https://github.com/nemtech/nem2-sdk-typescript-javascript/releases/tag/v0.13.1) is mandatory for **elephant compatibility**. +The upgrade to this package's [version v0.13.2](https://github.com/nemtech/nem2-sdk-typescript-javascript/releases/tag/v0.13.2) is mandatory for **elephant compatibility**. ### _Dragon_ Network Compatibility (catapult-server@0.4.0.1)