From 01c6bba3a4bc2c8dfc9089047362067082223d17 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Thu, 8 Oct 2020 19:51:12 +0100 Subject: [PATCH 1/6] Fixed #681 - removed hardcoded nemesis epoch --- e2e/infrastructure/AccountHttp.spec.ts | 20 +- e2e/infrastructure/BlockHttp.spec.ts | 2 +- e2e/infrastructure/HashLockHttp.spec.ts | 18 +- e2e/infrastructure/IntegrationTestHelper.ts | 2 + e2e/infrastructure/Listener.spec.ts | 30 +- e2e/infrastructure/MetadataHttp.spec.ts | 16 +- e2e/infrastructure/MosaicHttp.spec.ts | 8 +- e2e/infrastructure/MultisigAccounts.spec.ts | 4 +- e2e/infrastructure/NamespaceHttp.spec.ts | 4 +- .../PersistentHarvesting.spec.ts | 8 +- e2e/infrastructure/RestrictionHttp.spec.ts | 16 +- e2e/infrastructure/SecretLockHttp.spec.ts | 2 +- e2e/infrastructure/TransactionHttp.spec.ts | 211 ++++++------ e2e/infrastructure/UnresolvedMapping.spec.ts | 26 +- e2e/service/AccountService.spec.ts | 2 +- e2e/service/BlockService.spec.ts | 2 +- .../MetadataTransactionService.spec.ts | 20 +- ...osaicRestrictionTransactionService.spec.ts | 22 +- e2e/service/TransactionService.spec.ts | 34 +- ...TransactionService_AggregateBonded.spec.ts | 22 +- src/core/utils/TransactionMapping.ts | 10 +- src/infrastructure/Http.ts | 14 +- src/infrastructure/Listener.ts | 8 +- src/infrastructure/RepositoryFactory.ts | 5 + src/infrastructure/RepositoryFactoryConfig.ts | 5 + src/infrastructure/RepositoryFactoryHttp.ts | 22 +- src/infrastructure/TransactionHttp.ts | 96 ++++-- src/infrastructure/TransactionStatusHttp.ts | 32 +- .../transaction/CreateTransactionFromDTO.ts | 60 ++-- .../CreateTransactionFromPayload.ts | 49 +-- .../AccountAddressRestrictionTransaction.ts | 7 +- .../transaction/AccountKeyLinkTransaction.ts | 7 +- .../transaction/AccountMetadataTransaction.ts | 7 +- .../AccountMosaicRestrictionTransaction.ts | 7 +- .../AccountOperationRestrictionTransaction.ts | 7 +- .../transaction/AddressAliasTransaction.ts | 7 +- src/model/transaction/AggregateTransaction.ts | 11 +- src/model/transaction/Deadline.ts | 27 +- src/model/transaction/LockFundsTransaction.ts | 7 +- .../MosaicAddressRestrictionTransaction.ts | 7 +- .../transaction/MosaicAliasTransaction.ts | 7 +- .../MosaicDefinitionTransaction.ts | 7 +- .../MosaicGlobalRestrictionTransaction.ts | 7 +- .../transaction/MosaicMetadataTransaction.ts | 7 +- .../MosaicSupplyChangeTransaction.ts | 7 +- .../MultisigAccountModificationTransaction.ts | 7 +- .../NamespaceMetadataTransaction.ts | 7 +- .../NamespaceRegistrationTransaction.ts | 17 +- .../transaction/NodeKeyLinkTransaction.ts | 7 +- .../transaction/SecretLockTransaction.ts | 7 +- .../transaction/SecretProofTransaction.ts | 7 +- src/model/transaction/Transaction.ts | 2 +- src/model/transaction/TransferTransaction.ts | 7 +- .../transaction/VotingKeyLinkTransaction.ts | 7 +- .../transaction/VrfKeyLinkTransaction.ts | 7 +- src/service/AggregateTransactionService.ts | 5 +- test/core/utils/TransactionMapping.spec.ts | 305 ++++++++++-------- .../TransactionMappingWithSignatures.spec.ts | 196 +++++------ test/infrastructure/Listener.spec.ts | 43 +-- test/infrastructure/MetadataHttp.spec.ts | 12 +- test/infrastructure/Page.spec.ts | 4 +- test/infrastructure/RepositoryFactory.spec.ts | 95 ++++++ .../SerializeTransactionToJSON.spec.ts | 48 +-- test/infrastructure/TransactionHttp.spec.ts | 20 +- .../TransactionStatusHttp.spec.ts | 3 +- .../CreateTransactionFromDTO.spec.ts | 33 +- test/model/account/Account.spec.ts | 8 +- test/model/message/EncryptedMessage.spec.ts | 2 +- ...sistentHarvestingDelegationMessage.spec.ts | 2 +- .../AccountKeyLinkTransaction.spec.ts | 21 +- .../AccountMetadataTransaction.spec.ts | 18 +- .../AccountRestrictionTransaction.spec.ts | 34 +- .../AddressAliasTransaction.spec.ts | 22 +- .../transaction/AggregateTransaction.spec.ts | 96 +++--- .../CosignatureTransaction.spec.ts | 14 +- test/model/transaction/Deadline.spec.ts | 10 +- .../transaction/HashLockTransaction.spec.ts | 12 +- .../transaction/LockFundsTransaction.spec.ts | 40 +-- ...osaicAddressRestrictionTransaction.spec.ts | 12 +- .../MosaicAliasTransaction.spec.ts | 26 +- .../MosaicDefinitionTransaction.spec.ts | 18 +- ...MosaicGlobalRestrictionTransaction.spec.ts | 12 +- .../MosaicMetadataTransaction.spec.ts | 22 +- .../MosaicSupplyChangeTransaction.spec.ts | 16 +- ...isigAccountModificationTransaction.spec.ts | 48 ++- .../NamespaceMetadataTransaction.spec.ts | 20 +- .../NamespaceRegistrationTransaction.spec.ts | 18 +- .../NodeKeyLinkTransaction.spec.ts | 16 +- ...istentDelegationRequestTransaction.spec.ts | 8 +- .../transaction/SecretLockTransaction.spec.ts | 32 +- .../SecretProofTransaction.spec.ts | 34 +- test/model/transaction/Transaction.spec.ts | 34 +- .../transaction/TransactionStatus.spec.ts | 2 +- .../TransactionStatusError.spec.ts | 2 +- .../transaction/TransferTransaction.spec.ts | 56 ++-- .../VotingKeyLinkTransaction.spec.ts | 14 +- .../transaction/VrfKeyLinkTransaction.spec.ts | 14 +- .../AggregateTransactionService.spec.ts | 80 ++--- .../MetadataTransactionservice.spec.ts | 12 +- ...osaicRestrictionTransactionservice.spec.ts | 27 +- test/service/TransactionService.spec.ts | 12 +- 101 files changed, 1461 insertions(+), 1091 deletions(-) diff --git a/e2e/infrastructure/AccountHttp.spec.ts b/e2e/infrastructure/AccountHttp.spec.ts index fdef41db23..24cc4a2b3d 100644 --- a/e2e/infrastructure/AccountHttp.spec.ts +++ b/e2e/infrastructure/AccountHttp.spec.ts @@ -87,7 +87,7 @@ describe('AccountHttp', () => { describe('Make sure test account is not virgin', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -104,7 +104,7 @@ describe('AccountHttp', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(9), networkType, @@ -119,7 +119,7 @@ describe('AccountHttp', () => { describe('Setup test AddressAlias', () => { it('Announce addressAliasTransaction', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, account.address, @@ -134,7 +134,7 @@ describe('AccountHttp', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -144,7 +144,7 @@ describe('AccountHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -249,7 +249,7 @@ describe('AccountHttp', () => { describe('Remove test AddressAlias', () => { it('Announce addressAliasTransaction', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Unlink, namespaceId, account.address, @@ -264,7 +264,7 @@ describe('AccountHttp', () => { describe('Restore test multisig Accounts', () => { it('Announce MultisigAccountModificationTransaction', () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), -1, 0, [], @@ -273,7 +273,7 @@ describe('AccountHttp', () => { helper.maxFee, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 0, 0, [], @@ -283,7 +283,7 @@ describe('AccountHttp', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), -1, -1, [], @@ -293,7 +293,7 @@ describe('AccountHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), diff --git a/e2e/infrastructure/BlockHttp.spec.ts b/e2e/infrastructure/BlockHttp.spec.ts index a5ce3eaa7a..1a51ae4209 100644 --- a/e2e/infrastructure/BlockHttp.spec.ts +++ b/e2e/infrastructure/BlockHttp.spec.ts @@ -67,7 +67,7 @@ describe('BlockHttp', () => { describe('Setup Test Data', () => { it('Announce TransferTransaction FER', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), diff --git a/e2e/infrastructure/HashLockHttp.spec.ts b/e2e/infrastructure/HashLockHttp.spec.ts index 7f96ebeea5..4ea23ebc12 100644 --- a/e2e/infrastructure/HashLockHttp.spec.ts +++ b/e2e/infrastructure/HashLockHttp.spec.ts @@ -68,7 +68,7 @@ describe('HashLockHttp', () => { const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), recipient, [], PlainMessage.create('test-message'), @@ -77,7 +77,7 @@ describe('HashLockHttp', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(1573430400, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(aggregatedTo.publicAccount)], networkType, [], @@ -92,7 +92,7 @@ describe('HashLockHttp', () => { mosaicId: UnresolvedMosaicId, ): any => { const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new Mosaic(mosaicId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -112,7 +112,7 @@ describe('HashLockHttp', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -122,7 +122,7 @@ describe('HashLockHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -190,7 +190,7 @@ describe('HashLockHttp', () => { describe('Restore test multisig Accounts', () => { it('Announce MultisigAccountModificationTransaction', () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), -1, 0, [], @@ -199,7 +199,7 @@ describe('HashLockHttp', () => { helper.maxFee, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 0, 0, [], @@ -209,7 +209,7 @@ describe('HashLockHttp', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), -1, -1, [], @@ -219,7 +219,7 @@ describe('HashLockHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), diff --git a/e2e/infrastructure/IntegrationTestHelper.ts b/e2e/infrastructure/IntegrationTestHelper.ts index 7797551300..f4e761c0fe 100644 --- a/e2e/infrastructure/IntegrationTestHelper.ts +++ b/e2e/infrastructure/IntegrationTestHelper.ts @@ -52,6 +52,7 @@ export class IntegrationTestHelper { public service = new BootstrapService(); public config: StartParams; public startEachTime = true; + public nemesisEpoch: number; private async startBootstrapServer(): Promise<{ accounts: string[]; apiUrl: string }> { this.config = { @@ -112,6 +113,7 @@ export class IntegrationTestHelper { this.networkType = await this.repositoryFactory.getNetworkType().toPromise(); this.generationHash = await this.repositoryFactory.getGenerationHash().toPromise(); + this.nemesisEpoch = await this.repositoryFactory.getNemesisEpoch().toPromise(); let index = 0; this.account = Account.createFromPrivateKey(accounts[index++], this.networkType); diff --git a/e2e/infrastructure/Listener.spec.ts b/e2e/infrastructure/Listener.spec.ts index 535a14fe8f..20fc2c8a1a 100644 --- a/e2e/infrastructure/Listener.spec.ts +++ b/e2e/infrastructure/Listener.spec.ts @@ -71,7 +71,7 @@ describe('Listener', () => { const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), recipient, [], PlainMessage.create('test-message'), @@ -80,7 +80,7 @@ describe('Listener', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(1573430400, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(aggregatedTo.publicAccount)], networkType, [], @@ -95,7 +95,7 @@ describe('Listener', () => { mosaicId: UnresolvedMosaicId, ): void => { const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new Mosaic(mosaicId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -109,7 +109,7 @@ describe('Listener', () => { describe('Confirmed', () => { it('confirmedTransactionsGiven address signer', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [], PlainMessage.create('test-message'), @@ -125,7 +125,7 @@ describe('Listener', () => { it('confirmedTransactionsGiven address recipient', () => { const recipientAddress = account2.address; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), recipientAddress, [], PlainMessage.create('test-message'), @@ -140,7 +140,7 @@ describe('Listener', () => { describe('UnConfirmed', () => { it('unconfirmedTransactionsAdded', (done) => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [], PlainMessage.create('test-message'), @@ -159,7 +159,7 @@ describe('Listener', () => { it('unconfirmedTransactionsRemoved', (done) => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [], PlainMessage.create('test-message'), @@ -180,7 +180,7 @@ describe('Listener', () => { describe('TransferTransaction', () => { it('standalone', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), cosignAccount1.address, [helper.createNetworkCurrency(10, true)], PlainMessage.create('test-message'), @@ -196,7 +196,7 @@ describe('Listener', () => { describe('MultisigAccountModificationTransaction - Create multisig account', () => { it('MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -206,7 +206,7 @@ describe('Listener', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -317,7 +317,7 @@ describe('Listener', () => { describe('MultisigAccountModificationTransaction - Restore multisig Accounts', () => { it('Restore Multisig Account', () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), -1, 0, [], @@ -325,7 +325,7 @@ describe('Listener', () => { networkType, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 0, 0, [], @@ -334,7 +334,7 @@ describe('Listener', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), -1, -1, [], @@ -343,7 +343,7 @@ describe('Listener', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), @@ -366,7 +366,7 @@ describe('Listener', () => { it('transactionStatusGiven', () => { const mosaics = [helper.createNetworkCurrency(1000000000000)]; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account2.address, mosaics, PlainMessage.create('test-message'), diff --git a/e2e/infrastructure/MetadataHttp.spec.ts b/e2e/infrastructure/MetadataHttp.spec.ts index 9e4f0d62ab..3532549c4d 100644 --- a/e2e/infrastructure/MetadataHttp.spec.ts +++ b/e2e/infrastructure/MetadataHttp.spec.ts @@ -72,7 +72,7 @@ describe('MetadataHttp', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -90,7 +90,7 @@ describe('MetadataHttp', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(9), networkType, @@ -105,7 +105,7 @@ describe('MetadataHttp', () => { describe('AccountMetadataTransaction', () => { it('aggregate', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(6), 23, @@ -115,7 +115,7 @@ describe('MetadataHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [accountMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -129,7 +129,7 @@ describe('MetadataHttp', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(6), mosaicId, @@ -140,7 +140,7 @@ describe('MetadataHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [mosaicMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -154,7 +154,7 @@ describe('MetadataHttp', () => { describe('NamespaceMetadataTransaction', () => { it('aggregate', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(6), namespaceId, @@ -165,7 +165,7 @@ describe('MetadataHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [namespaceMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], diff --git a/e2e/infrastructure/MosaicHttp.spec.ts b/e2e/infrastructure/MosaicHttp.spec.ts index ad8b4f4384..99168a2ef1 100644 --- a/e2e/infrastructure/MosaicHttp.spec.ts +++ b/e2e/infrastructure/MosaicHttp.spec.ts @@ -70,7 +70,7 @@ describe('MosaicHttp', () => { expect(nonce.toHex()).to.be.equals('22EA84A6'); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), nonce, mosaicId, MosaicFlags.create(true, true, false), @@ -100,7 +100,7 @@ describe('MosaicHttp', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(1000), networkType, @@ -115,7 +115,7 @@ describe('MosaicHttp', () => { describe('Setup test MosaicAlias', () => { it('Announce MosaicAliasTransaction', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -189,7 +189,7 @@ describe('MosaicHttp', () => { describe('Remove test MosaicAlias', () => { it('Announce MosaicAliasTransaction', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Unlink, namespaceId, mosaicId, diff --git a/e2e/infrastructure/MultisigAccounts.spec.ts b/e2e/infrastructure/MultisigAccounts.spec.ts index 4c4857e2a3..a2c54e2384 100644 --- a/e2e/infrastructure/MultisigAccounts.spec.ts +++ b/e2e/infrastructure/MultisigAccounts.spec.ts @@ -47,7 +47,7 @@ describe('MultisigAccounts', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -57,7 +57,7 @@ describe('MultisigAccounts', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], diff --git a/e2e/infrastructure/NamespaceHttp.spec.ts b/e2e/infrastructure/NamespaceHttp.spec.ts index 6a77577b32..f18be2bfd2 100644 --- a/e2e/infrastructure/NamespaceHttp.spec.ts +++ b/e2e/infrastructure/NamespaceHttp.spec.ts @@ -54,7 +54,7 @@ describe('NamespaceHttp', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(1000), helper.networkType, @@ -68,7 +68,7 @@ describe('NamespaceHttp', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, account.address, diff --git a/e2e/infrastructure/PersistentHarvesting.spec.ts b/e2e/infrastructure/PersistentHarvesting.spec.ts index 3d7d8013ac..a677e0016b 100644 --- a/e2e/infrastructure/PersistentHarvesting.spec.ts +++ b/e2e/infrastructure/PersistentHarvesting.spec.ts @@ -58,7 +58,7 @@ describe('PersistentHarvesting', () => { describe('AccountKeyLinkTransaction', () => { it('standalone', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), remoteAccount.publicKey, LinkAction.Link, networkType, @@ -73,7 +73,7 @@ describe('PersistentHarvesting', () => { describe('VrfKeyLinkTransaction', () => { it('standalone', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), vrfKeyPair.publicKey, LinkAction.Link, networkType, @@ -88,7 +88,7 @@ describe('PersistentHarvesting', () => { describe('NodeKeyLinkTransaction', () => { it('standalone', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 'cfd84eca83508bbee954668e4aecca736caefa615367da76afe6985d695381db', LinkAction.Link, networkType, @@ -108,7 +108,7 @@ describe('PersistentHarvesting', () => { describe('transactions', () => { it('should create delegated harvesting transaction', () => { const tx = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(1573430400), remoteAccount.privateKey, vrfKeyPair.privateKey, 'cfd84eca83508bbee954668e4aecca736caefa615367da76afe6985d695381db', diff --git a/e2e/infrastructure/RestrictionHttp.spec.ts b/e2e/infrastructure/RestrictionHttp.spec.ts index 47d746bed5..87ef2e80c1 100644 --- a/e2e/infrastructure/RestrictionHttp.spec.ts +++ b/e2e/infrastructure/RestrictionHttp.spec.ts @@ -75,7 +75,7 @@ describe('RestrictionHttp', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -94,7 +94,7 @@ describe('RestrictionHttp', () => { const nonce = MosaicNonce.createRandom(); referenceMosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), nonce, referenceMosaicId, MosaicFlags.create(true, true, true), @@ -111,7 +111,7 @@ describe('RestrictionHttp', () => { describe('Setup Test AccountAddressRestriction', () => { it('Announce AccountRestrictionTransaction', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [account3.address], [], @@ -126,7 +126,7 @@ describe('RestrictionHttp', () => { describe('MosaicGlobalRestrictionTransaction - Reference', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), referenceMosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -146,7 +146,7 @@ describe('RestrictionHttp', () => { describe('MosaicGlobalRestrictionTransaction - with referenceMosaicId', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -167,7 +167,7 @@ describe('RestrictionHttp', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, UInt64.fromUint(60641), account3.address, @@ -177,7 +177,7 @@ describe('RestrictionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -221,7 +221,7 @@ describe('RestrictionHttp', () => { describe('Remove test AccountRestriction - Address', () => { it('Announce AccountRestrictionTransaction', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [], [account3.address], diff --git a/e2e/infrastructure/SecretLockHttp.spec.ts b/e2e/infrastructure/SecretLockHttp.spec.ts index f089e1e91f..f78eb5976c 100644 --- a/e2e/infrastructure/SecretLockHttp.spec.ts +++ b/e2e/infrastructure/SecretLockHttp.spec.ts @@ -62,7 +62,7 @@ describe('SecretLockHttp', () => { describe('Create a hash lock', () => { it('Announce SecretLockTransaction', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, diff --git a/e2e/infrastructure/TransactionHttp.spec.ts b/e2e/infrastructure/TransactionHttp.spec.ts index 10c018af00..87d736205b 100644 --- a/e2e/infrastructure/TransactionHttp.spec.ts +++ b/e2e/infrastructure/TransactionHttp.spec.ts @@ -137,7 +137,7 @@ describe('TransactionHttp', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -165,7 +165,7 @@ describe('TransactionHttp', () => { it('aggregate', () => { const nonce = MosaicNonce.createRandom(); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), nonce, MosaicId.createFromNonce(nonce, account.address), MosaicFlags.create(true, true, true), @@ -175,7 +175,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [mosaicDefinitionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -189,7 +189,7 @@ describe('TransactionHttp', () => { describe('AccountMetadataTransaction', () => { it('aggregate', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account.address, UInt64.fromUint(5), 10, @@ -199,7 +199,7 @@ describe('TransactionHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [accountMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -221,7 +221,7 @@ describe('TransactionHttp', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account.address, UInt64.fromUint(5), mosaicId, @@ -232,7 +232,7 @@ describe('TransactionHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [mosaicMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -255,7 +255,7 @@ describe('TransactionHttp', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), namespaceName, UInt64.fromUint(50), networkType, @@ -275,7 +275,7 @@ describe('TransactionHttp', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), namespaceName, UInt64.fromUint(50), networkType, @@ -294,14 +294,14 @@ describe('TransactionHttp', () => { describe('NamespaceRegistrationTransaction', () => { it('aggregate', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), 'root-test-namespace-' + Math.floor(Math.random() * 10000), UInt64.fromUint(5), networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [registerNamespaceTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -315,7 +315,7 @@ describe('TransactionHttp', () => { describe('NamespaceMetadataTransaction', () => { it('aggregate', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account.address, UInt64.fromUint(5), addressAlias, @@ -326,7 +326,7 @@ describe('TransactionHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [namespaceMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -348,7 +348,7 @@ describe('TransactionHttp', () => { describe('MosaicGlobalRestrictionTransaction', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), mosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -366,7 +366,7 @@ describe('TransactionHttp', () => { describe('MosaicGlobalRestrictionTransaction', () => { it('aggregate', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), mosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -378,7 +378,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [mosaicGlobalRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -392,7 +392,7 @@ describe('TransactionHttp', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), mosaicId, UInt64.fromUint(60641), account3.address, @@ -402,7 +402,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -416,7 +416,7 @@ describe('TransactionHttp', () => { describe('TransferTransaction', () => { it('standalone', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -430,7 +430,7 @@ describe('TransactionHttp', () => { describe('TransferTransaction', () => { it('aggregate', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -438,7 +438,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [transferTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -451,7 +451,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Outgoing Address', () => { it('standalone', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), AddressRestrictionFlag.BlockOutgoingAddress, [account3.address], [], @@ -469,7 +469,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Outgoing Address', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), AddressRestrictionFlag.BlockOutgoingAddress, [], [account3.address], @@ -477,7 +477,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [addressModification.toAggregate(account.publicAccount)], networkType, [], @@ -491,7 +491,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Incoming Address', () => { it('standalone', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), AddressRestrictionFlag.BlockIncomingAddress, [account3.address], [], @@ -505,7 +505,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Incoming Address', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), AddressRestrictionFlag.BlockIncomingAddress, [], [account3.address], @@ -513,7 +513,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [addressModification.toAggregate(account.publicAccount)], networkType, [], @@ -527,7 +527,7 @@ describe('TransactionHttp', () => { it('standalone', () => { AccountRestrictionModification.createForMosaic(AccountRestrictionModificationAction.Add, mosaicId); const addressModification = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), MosaicRestrictionFlag.BlockMosaic, [mosaicId], [], @@ -546,7 +546,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Mosaic', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), MosaicRestrictionFlag.BlockMosaic, [], [mosaicId], @@ -554,7 +554,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [addressModification.toAggregate(account.publicAccount)], networkType, [], @@ -569,7 +569,7 @@ describe('TransactionHttp', () => { it('standalone', () => { AccountRestrictionModification.createForOperation(AccountRestrictionModificationAction.Add, TransactionType.ACCOUNT_KEY_LINK); const addressModification = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), OperationRestrictionFlag.BlockOutgoingTransactionType, [TransactionType.ACCOUNT_KEY_LINK], [], @@ -588,7 +588,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Outgoing Operation', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), OperationRestrictionFlag.BlockOutgoingTransactionType, [], [TransactionType.ACCOUNT_KEY_LINK], @@ -596,7 +596,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [addressModification.toAggregate(account3.publicAccount)], networkType, [], @@ -610,7 +610,7 @@ describe('TransactionHttp', () => { describe('AccountKeyLinkTransaction', () => { it('standalone', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), remoteAccount.publicKey, LinkAction.Link, networkType, @@ -628,14 +628,14 @@ describe('TransactionHttp', () => { describe('AccountKeyLinkTransaction', () => { it('aggregate', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), remoteAccount.publicKey, LinkAction.Unlink, networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [accountLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -649,7 +649,7 @@ describe('TransactionHttp', () => { describe('VrfKeyLinkTransaction', () => { it('standalone', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), harvestingAccount.publicKey, LinkAction.Link, networkType, @@ -667,14 +667,14 @@ describe('TransactionHttp', () => { describe('VrfKeyLinkTransaction', () => { it('aggregate', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), harvestingAccount.publicKey, LinkAction.Unlink, networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [vrfKeyLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -688,7 +688,7 @@ describe('TransactionHttp', () => { describe('NodeKeyLinkTransaction', () => { it('standalone', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), harvestingAccount.publicKey, LinkAction.Link, networkType, @@ -706,14 +706,14 @@ describe('TransactionHttp', () => { describe('NodeKeyLinkTransaction', () => { it('aggregate', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), harvestingAccount.publicKey, LinkAction.Unlink, networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [nodeKeyLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -727,7 +727,7 @@ describe('TransactionHttp', () => { describe('VotingKeyLinkTransaction', () => { it('standalone', () => { const votingLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), votingKey, 100, 300, @@ -749,7 +749,7 @@ describe('TransactionHttp', () => { describe('VotingKeyLinkTransaction', () => { it('aggregate', () => { const votingLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), votingKey, 100, 300, @@ -758,7 +758,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [votingLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -772,7 +772,7 @@ describe('TransactionHttp', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), AliasAction.Link, addressAlias, account.address, @@ -792,7 +792,7 @@ describe('TransactionHttp', () => { describe('Transfer Transaction using address alias', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), addressAlias, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -808,7 +808,7 @@ describe('TransactionHttp', () => { describe('AddressAliasTransaction', () => { it('aggregate', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), AliasAction.Unlink, addressAlias, account.address, @@ -816,7 +816,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [addressAliasTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -830,7 +830,7 @@ describe('TransactionHttp', () => { describe('MosaicSupplyChangeTransaction', () => { it('standalone', () => { const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -848,7 +848,7 @@ describe('TransactionHttp', () => { describe('MosaicSupplyChangeTransaction', () => { it('aggregate', () => { const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -856,7 +856,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [mosaicSupplyChangeTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -870,7 +870,7 @@ describe('TransactionHttp', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), AliasAction.Link, mosaicAlias, mosaicId, @@ -889,10 +889,16 @@ describe('TransactionHttp', () => { describe('HashLockTransaction - MosaicAlias', () => { it('standalone', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], networkType, [], helper.maxFee); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(helper.nemesisEpoch), + [], + networkType, + [], + helper.maxFee, + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const hashLockTransaction = HashLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), new Mosaic(new NamespaceId('cat.currency'), UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(10000), signedTransaction, @@ -907,7 +913,7 @@ describe('TransactionHttp', () => { describe('MosaicAliasTransaction', () => { it('aggregate', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), AliasAction.Unlink, mosaicAlias, mosaicId, @@ -915,7 +921,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [mosaicAliasTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -928,10 +934,16 @@ describe('TransactionHttp', () => { describe('LockFundsTransaction', () => { it('standalone', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], networkType, [], helper.maxFee); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(helper.nemesisEpoch), + [], + networkType, + [], + helper.maxFee, + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(10000), signedTransaction, @@ -944,10 +956,16 @@ describe('TransactionHttp', () => { }); describe('LockFundsTransaction', () => { it('aggregate', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], networkType, [], helper.maxFee); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(helper.nemesisEpoch), + [], + networkType, + [], + helper.maxFee, + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(10), signedTransaction, @@ -955,7 +973,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateLockFundsTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [lockFundsTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -968,7 +986,7 @@ describe('TransactionHttp', () => { describe('Aggregate Complete Transaction', () => { it('should announce aggregated complete transaction', () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account2.address, [], PlainMessage.create('Hi'), @@ -976,7 +994,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggTx = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [tx.toAggregate(account.publicAccount)], networkType, [], @@ -990,7 +1008,7 @@ describe('TransactionHttp', () => { describe('SecretLockTransaction', () => { it('standalone', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1012,7 +1030,7 @@ describe('TransactionHttp', () => { describe('HashType: Op_Sha3_256', () => { it('aggregate', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1022,7 +1040,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretLockTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [secretLockTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -1037,7 +1055,7 @@ describe('TransactionHttp', () => { const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20)); const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1054,7 +1072,7 @@ describe('TransactionHttp', () => { const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20)); const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1064,7 +1082,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretLockTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [secretLockTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -1076,7 +1094,7 @@ describe('TransactionHttp', () => { describe('HashType: Op_Hash_256', () => { it('standalone', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1091,7 +1109,7 @@ describe('TransactionHttp', () => { describe('HashType: Op_Hash_256', () => { it('aggregate', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1101,7 +1119,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretLockTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [secretLockTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -1118,7 +1136,7 @@ describe('TransactionHttp', () => { const proof = convert.uint8ToHex(secretSeed); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(helper.nemesisEpoch, 1, ChronoUnit.HOURS), helper.createNetworkCurrency(10, false), UInt64.fromUint(11), LockHashAlgorithm.Op_Sha3_256, @@ -1132,7 +1150,7 @@ describe('TransactionHttp', () => { return helper.announce(signedSecretLockTx).then(() => { const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), LockHashAlgorithm.Op_Sha3_256, secret, account2.address, @@ -1156,7 +1174,7 @@ describe('TransactionHttp', () => { const secret = sha3_256.create().update(secretSeed).hex(); const proof = convert.uint8ToHex(secretSeed); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1168,7 +1186,7 @@ describe('TransactionHttp', () => { return helper.announce(secretLockTransaction.signWith(account, generationHash)).then(() => { const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), LockHashAlgorithm.Op_Sha3_256, secret, account2.address, @@ -1177,7 +1195,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretProofTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [secretProofTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1194,7 +1212,7 @@ describe('TransactionHttp', () => { const secret = LockHashUtils.Op_Hash_160(randomBytes); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1206,7 +1224,7 @@ describe('TransactionHttp', () => { return helper.announce(secretLockTransaction.signWith(account, generationHash)).then(() => { const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), LockHashAlgorithm.Op_Hash_160, secret, account2.address, @@ -1227,7 +1245,7 @@ describe('TransactionHttp', () => { const secret = new ripemd160().update(Buffer.from(hash, 'hex')).digest('hex'); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1237,7 +1255,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), LockHashAlgorithm.Op_Hash_160, secret, account2.address, @@ -1246,7 +1264,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretProofTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [secretProofTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1266,7 +1284,7 @@ describe('TransactionHttp', () => { const secret = LockHashUtils.Op_Hash_256(randomBytes); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(1, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1277,7 +1295,7 @@ describe('TransactionHttp', () => { ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), LockHashAlgorithm.Op_Hash_256, secret, account2.address, @@ -1299,7 +1317,7 @@ describe('TransactionHttp', () => { const secret = sha256(Buffer.from(hash, 'hex')); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1309,7 +1327,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), LockHashAlgorithm.Op_Hash_256, secret, account2.address, @@ -1318,7 +1336,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretProofTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [secretProofTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1342,7 +1360,7 @@ describe('TransactionHttp', () => { const backAmount = helper.createNetworkCurrency(1); const aliceTransferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account2.address, [sendAmount], PlainMessage.create('payout'), @@ -1350,7 +1368,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const bobTransferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account.address, [backAmount], PlainMessage.create('payout'), @@ -1360,7 +1378,7 @@ describe('TransactionHttp', () => { // 01. Alice creates the aggregated tx and sign it. Then payload send to Bob const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), [aliceTransferTransaction.toAggregate(account.publicAccount), bobTransferTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1376,7 +1394,10 @@ describe('TransactionHttp', () => { const cosignatureSignedTransactions = [ new CosignatureSignedTransaction(signedTxBob.parentHash, signedTxBob.signature, signedTxBob.signerPublicKey), ]; - const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload) as AggregateTransaction; + const recreatedTx = TransactionMapping.createFromPayload( + aliceSignedTransaction.payload, + helper.nemesisEpoch, + ) as AggregateTransaction; const signedTransaction = recreatedTx.signTransactionGivenSignatures(account, cosignatureSignedTransactions, generationHash); @@ -1434,7 +1455,7 @@ describe('TransactionHttp', () => { describe('announce', () => { it('should return success when announce', async () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -1450,7 +1471,7 @@ describe('TransactionHttp', () => { describe('announceAggregateBonded', () => { it('should return success when announceAggregateBonded', async () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(helper.nemesisEpoch), account2.address, [helper.createNetworkCurrency(1)], PlainMessage.create('test-message'), @@ -1458,7 +1479,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(helper.nemesisEpoch, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], diff --git a/e2e/infrastructure/UnresolvedMapping.spec.ts b/e2e/infrastructure/UnresolvedMapping.spec.ts index 1eab3739af..5c53ede6dc 100644 --- a/e2e/infrastructure/UnresolvedMapping.spec.ts +++ b/e2e/infrastructure/UnresolvedMapping.spec.ts @@ -73,7 +73,7 @@ describe('Unresolved Mapping', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -92,7 +92,7 @@ describe('Unresolved Mapping', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(50), networkType, @@ -109,7 +109,7 @@ describe('Unresolved Mapping', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(50), networkType, @@ -125,7 +125,7 @@ describe('Unresolved Mapping', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceIdAddress, account.address, @@ -141,7 +141,7 @@ describe('Unresolved Mapping', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceIdMosaic, mosaicId, @@ -163,7 +163,7 @@ describe('Unresolved Mapping', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(5), namespaceIdMosaic, @@ -174,7 +174,7 @@ describe('Unresolved Mapping', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [mosaicMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -193,7 +193,7 @@ describe('Unresolved Mapping', () => { describe('MosaicGlobalRestrictionTransaction', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), namespaceIdMosaic, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -215,7 +215,7 @@ describe('Unresolved Mapping', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), namespaceIdMosaic, UInt64.fromUint(60641), namespaceIdAddress, @@ -225,7 +225,7 @@ describe('Unresolved Mapping', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -245,7 +245,7 @@ describe('Unresolved Mapping', () => { describe('TransferTransaction', () => { it('standalone', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account2.address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -269,7 +269,7 @@ describe('Unresolved Mapping', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Unlink, namespaceIdAddress, account.address, @@ -289,7 +289,7 @@ describe('Unresolved Mapping', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Unlink, namespaceIdMosaic, mosaicId, diff --git a/e2e/service/AccountService.spec.ts b/e2e/service/AccountService.spec.ts index dd7c2c7fa2..5a5b0e4e7a 100644 --- a/e2e/service/AccountService.spec.ts +++ b/e2e/service/AccountService.spec.ts @@ -54,7 +54,7 @@ describe('AccountService', () => { describe('Create a namespace', () => { it('Announce NamespaceRegistrationTransaction', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), name, UInt64.fromUint(300000), networkType, diff --git a/e2e/service/BlockService.spec.ts b/e2e/service/BlockService.spec.ts index 883d02bd5e..851714f4f5 100644 --- a/e2e/service/BlockService.spec.ts +++ b/e2e/service/BlockService.spec.ts @@ -64,7 +64,7 @@ describe('BlockService', () => { describe('Create a transfer', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account2.address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), diff --git a/e2e/service/MetadataTransactionService.spec.ts b/e2e/service/MetadataTransactionService.spec.ts index 5ac0e0a4e7..6ccf60687b 100644 --- a/e2e/service/MetadataTransactionService.spec.ts +++ b/e2e/service/MetadataTransactionService.spec.ts @@ -19,7 +19,7 @@ import { MetadataTransactionService } from '../../src/service/MetadataTransactio import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; describe('MetadataTransactionService', () => { - const deadline = Deadline.create(); + const deadline = Deadline.create(1573430400); const key = UInt64.fromUint(Math.round(Math.random() * 10)); const newValue = 'new test value'; @@ -56,7 +56,7 @@ describe('MetadataTransactionService', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, targetAccount.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -74,7 +74,7 @@ describe('MetadataTransactionService', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(9), networkType, @@ -90,7 +90,7 @@ describe('MetadataTransactionService', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), targetAccount.address, key, mosaicId, @@ -101,7 +101,7 @@ describe('MetadataTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [mosaicMetadataTransaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -116,7 +116,7 @@ describe('MetadataTransactionService', () => { describe('NamespaceMetadataTransaction', () => { it('aggregate', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), targetAccount.address, key, namespaceId, @@ -126,7 +126,7 @@ describe('MetadataTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [namespaceMetadataTransaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -234,7 +234,7 @@ describe('MetadataTransactionService', () => { ) .toPromise(); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -262,7 +262,7 @@ describe('MetadataTransactionService', () => { ) .toPromise(); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -290,7 +290,7 @@ describe('MetadataTransactionService', () => { ) .toPromise(); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transaction.toAggregate(targetAccount.publicAccount)], networkType, [], diff --git a/e2e/service/MosaicRestrictionTransactionService.spec.ts b/e2e/service/MosaicRestrictionTransactionService.spec.ts index 6f48fba7da..c68ac04b72 100644 --- a/e2e/service/MosaicRestrictionTransactionService.spec.ts +++ b/e2e/service/MosaicRestrictionTransactionService.spec.ts @@ -24,7 +24,7 @@ import { MosaicRestrictionTransactionService } from '../../src/service/MosaicRes import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; describe('MosaicRestrictionTransactionService', () => { - const deadline = Deadline.create(); + const deadline = Deadline.create(1573430400); const key = KeyGenerator.generateUInt64Key('TestKey'); let account: Account; let restrictionRepository: RestrictionMosaicRepository; @@ -61,7 +61,7 @@ describe('MosaicRestrictionTransactionService', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -78,7 +78,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('MosaicGlobalRestrictionTransaction - with referenceMosaicId', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, key, UInt64.fromUint(0), @@ -97,7 +97,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, key, account.address, @@ -107,7 +107,7 @@ describe('MosaicRestrictionTransactionService', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -122,7 +122,7 @@ describe('MosaicRestrictionTransactionService', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(50), networkType, @@ -139,7 +139,7 @@ describe('MosaicRestrictionTransactionService', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(50), networkType, @@ -155,7 +155,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceIdAddress, account.address, @@ -171,7 +171,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceIdMosaic, mosaicId, @@ -291,7 +291,7 @@ describe('MosaicRestrictionTransactionService', () => { .toPromise() .then((transaction: MosaicGlobalRestrictionTransaction) => { const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transaction.toAggregate(account.publicAccount)], networkType, [], @@ -311,7 +311,7 @@ describe('MosaicRestrictionTransactionService', () => { .toPromise() .then((transaction: MosaicAddressRestrictionTransaction) => { const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transaction.toAggregate(account.publicAccount)], networkType, [], diff --git a/e2e/service/TransactionService.spec.ts b/e2e/service/TransactionService.spec.ts index 1a37328447..b88948d993 100644 --- a/e2e/service/TransactionService.spec.ts +++ b/e2e/service/TransactionService.spec.ts @@ -84,7 +84,7 @@ describe('TransactionService', () => { function buildAggregateTransaction(): AggregateTransaction { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), addressAlias, [NetworkCurrencyLocal.createAbsolute(1), new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -93,7 +93,7 @@ describe('TransactionService', () => { ); // Unlink MosaicAlias const mosaicAliasTransactionUnlink = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Unlink, mosaicAlias, mosaicId, @@ -105,7 +105,7 @@ describe('TransactionService', () => { const nonce = MosaicNonce.createRandom(); newMosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), nonce, newMosaicId, MosaicFlags.create(true, true, false), @@ -116,7 +116,7 @@ describe('TransactionService', () => { ); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), newMosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(200000), @@ -126,7 +126,7 @@ describe('TransactionService', () => { // Link namespace with new MosaicId const mosaicAliasTransactionRelink = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, mosaicAlias, newMosaicId, @@ -136,7 +136,7 @@ describe('TransactionService', () => { // Use new mosaicAlias in metadata const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(5), mosaicAlias, @@ -146,7 +146,7 @@ describe('TransactionService', () => { helper.maxFee, ); return AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [ transferTransaction.toAggregate(account.publicAccount), mosaicAliasTransactionUnlink.toAggregate(account.publicAccount), @@ -170,7 +170,7 @@ describe('TransactionService', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(20), networkType, @@ -187,7 +187,7 @@ describe('TransactionService', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), namespaceName, UInt64.fromUint(50), networkType, @@ -203,7 +203,7 @@ describe('TransactionService', () => { describe('Setup test AddressAlias', () => { it('Announce addressAliasTransaction', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, addressAlias, account.address, @@ -222,7 +222,7 @@ describe('TransactionService', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), nonce, mosaicId, MosaicFlags.create(true, true, false), @@ -241,7 +241,7 @@ describe('TransactionService', () => { describe('MosaicSupplyChangeTransaction', () => { it('standalone', () => { const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(200000), @@ -257,7 +257,7 @@ describe('TransactionService', () => { describe('Setup MosaicAlias', () => { it('Announce MosaicAliasTransaction', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, mosaicAlias, mosaicId, @@ -273,7 +273,7 @@ describe('TransactionService', () => { describe('Create Transfer with alias', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), addressAlias, [NetworkCurrencyLocal.createAbsolute(1), new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -311,7 +311,7 @@ describe('TransactionService', () => { describe('Transfer mosaic to account 3', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account3.address, [new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -329,7 +329,7 @@ describe('TransactionService', () => { const transactions: SignedTransaction[] = []; // 1. Transfer A -> B const transaction1 = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account2.address, [new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -340,7 +340,7 @@ describe('TransactionService', () => { // 2. Transfer C -> D const transaction2 = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), cosignAccount4.address, [new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), diff --git a/e2e/service/TransactionService_AggregateBonded.spec.ts b/e2e/service/TransactionService_AggregateBonded.spec.ts index 92f0ecf19b..d33655c424 100644 --- a/e2e/service/TransactionService_AggregateBonded.spec.ts +++ b/e2e/service/TransactionService_AggregateBonded.spec.ts @@ -74,7 +74,7 @@ describe('TransactionService - AggregateBonded', () => { const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), recipient, [], PlainMessage.create('test-message'), @@ -83,7 +83,7 @@ describe('TransactionService - AggregateBonded', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(1573430400, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(aggregatedTo.publicAccount)], networkType, [], @@ -111,7 +111,7 @@ describe('TransactionService - AggregateBonded', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -121,7 +121,7 @@ describe('TransactionService - AggregateBonded', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -146,7 +146,7 @@ describe('TransactionService - AggregateBonded', () => { describe('should announce transaction', () => { it('announce', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account2.address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -169,7 +169,7 @@ describe('TransactionService - AggregateBonded', () => { it('announce', async () => { const signedAggregatedTransaction = createSignedAggregatedBondTransaction(multisigAccount, account, account2.address); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, NetworkCurrencyLocal.DIVISIBILITY))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -189,7 +189,7 @@ describe('TransactionService - AggregateBonded', () => { it('announce', async () => { const signedAggregatedTransaction = createSignedAggregatedBondTransaction(multisigAccount, account, account2.address); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, NetworkCurrencyLocal.DIVISIBILITY))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -216,7 +216,7 @@ describe('TransactionService - AggregateBonded', () => { describe('Restore test multisig Accounts', () => { it('Announce MultisigAccountModificationTransaction', async () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), -1, 0, [], @@ -225,7 +225,7 @@ describe('TransactionService - AggregateBonded', () => { helper.maxFee, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 0, 0, [], @@ -235,7 +235,7 @@ describe('TransactionService - AggregateBonded', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), -1, -1, [], @@ -245,7 +245,7 @@ describe('TransactionService - AggregateBonded', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), diff --git a/src/core/utils/TransactionMapping.ts b/src/core/utils/TransactionMapping.ts index d6ee61d2da..468ee4b387 100644 --- a/src/core/utils/TransactionMapping.ts +++ b/src/core/utils/TransactionMapping.ts @@ -23,19 +23,21 @@ export class TransactionMapping { /** * Create transaction class from Json. * @param {object} dataJson The transaction json object. + * @param {number} nemesisEpoch The nemesis block epoch. * @returns {module: model/transaction/transaction} The transaction class. */ - public static createFromDTO(dataJson: object): Transaction { - return CreateTransactionFromDTO(dataJson); + public static createFromDTO(dataJson: object, nemesisEpoch: number): Transaction { + return CreateTransactionFromDTO(dataJson, nemesisEpoch); } /** * Create transaction class from payload binary. * @param {string} payload The transaction binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} The transaction class. */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { - return CreateTransactionFromPayload(payload, isEmbedded); + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + return CreateTransactionFromPayload(payload, nemesisEpoch, isEmbedded); } } diff --git a/src/infrastructure/Http.ts b/src/infrastructure/Http.ts index f10d4fea3c..d87210a358 100644 --- a/src/infrastructure/Http.ts +++ b/src/infrastructure/Http.ts @@ -16,7 +16,7 @@ import { from as observableFrom, Observable, of, of as observableOf, throwError } from 'rxjs'; import { catchError, flatMap, map } from 'rxjs/operators'; -import { Configuration, NodeRoutesApi, Pagination, querystring } from 'symbol-openapi-typescript-fetch-client'; +import { Configuration, NetworkRoutesApi, NodeRoutesApi, Pagination, querystring } from 'symbol-openapi-typescript-fetch-client'; import { NetworkType } from '../model/network/NetworkType'; import { Page } from './Page'; import { RepositoryCallError } from './RepositoryCallError'; @@ -90,6 +90,18 @@ export abstract class Http { } } + createNemesisEpochObservable(nemesisEpoch?: number | Observable): Observable { + if (nemesisEpoch && nemesisEpoch instanceof Observable) { + return nemesisEpoch as Observable; + } else if (nemesisEpoch) { + return observableOf(nemesisEpoch); + } else { + return this.call(new NetworkRoutesApi(this.config()).getNetworkProperties(), (body) => + parseInt(body.network.epochAdjustment?.replace('s', '') ?? '0'), + ); + } + } + public config(): Configuration { const fetchApi = this.fetchApi || (typeof window !== 'undefined' && window.fetch.bind(window)) || fetch; return new Configuration({ basePath: this.url, fetchApi: fetchApi, queryParamsStringify: querystring }); diff --git a/src/infrastructure/Listener.ts b/src/infrastructure/Listener.ts index c5ee5ab2c4..f1b8b2cefb 100644 --- a/src/infrastructure/Listener.ts +++ b/src/infrastructure/Listener.ts @@ -87,6 +87,10 @@ export class Listener implements IListener { * Namespace repository for resolving account alias */ private namespaceRepository: NamespaceRepository, + /** + * Nemesis block creation epoch + */ + private nemesisEpoch: number, /** * WebSocket injected when using listeners in client. */ @@ -147,7 +151,7 @@ export class Listener implements IListener { this.messageSubject.next({ channelName: ListenerChannelName[channelName], channelParam: channelParam, - message: CreateTransactionFromDTO(message.data), + message: CreateTransactionFromDTO(message.data, this.nemesisEpoch), }); break; case ListenerChannelName.block: @@ -165,7 +169,7 @@ export class Listener implements IListener { Address.createFromRawAddress(channelParam), message.data.hash, message.data.code, - Deadline.createFromDTO(message.data.deadline), + Deadline.createFromDTO(message.data.deadline, this.nemesisEpoch), ), }); break; diff --git a/src/infrastructure/RepositoryFactory.ts b/src/infrastructure/RepositoryFactory.ts index db81620220..729a21bd53 100644 --- a/src/infrastructure/RepositoryFactory.ts +++ b/src/infrastructure/RepositoryFactory.ts @@ -136,4 +136,9 @@ export interface RepositoryFactory { * @returns a newly created {@link IListener} */ createListener(): IListener; + + /** + * @returns nemesis block epoch + */ + getNemesisEpoch(): Observable; } diff --git a/src/infrastructure/RepositoryFactoryConfig.ts b/src/infrastructure/RepositoryFactoryConfig.ts index d8d5f01d8c..2292ffdb7e 100644 --- a/src/infrastructure/RepositoryFactoryConfig.ts +++ b/src/infrastructure/RepositoryFactoryConfig.ts @@ -40,4 +40,9 @@ export interface RepositoryFactoryConfig { * 2) or node-fetch if running on server (window.fetch not found) */ fetchApi?: any; + + /** + * The nemesis block creation epoch + */ + nemesisEpoch?: number; } diff --git a/src/infrastructure/RepositoryFactoryHttp.ts b/src/infrastructure/RepositoryFactoryHttp.ts index 2982ae80ec..227b20b5f4 100644 --- a/src/infrastructure/RepositoryFactoryHttp.ts +++ b/src/infrastructure/RepositoryFactoryHttp.ts @@ -64,6 +64,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { private readonly websocketUrl: string; private readonly websocketInjected?: any; private readonly fetchApi?: any; + private readonly nemesisEpoch: Observable; /** * Constructor @@ -71,11 +72,20 @@ export class RepositoryFactoryHttp implements RepositoryFactory { * @param configs optional repository factory configs */ constructor(url: string, configs?: RepositoryFactoryConfig) { + const networkRepo = this.createNetworkRepository(); this.url = url; this.fetchApi = configs?.fetchApi; - this.networkType = configs?.networkType - ? observableOf(configs.networkType) - : this.createNetworkRepository().getNetworkType().pipe(shareReplay(1)); + this.networkType = configs?.networkType ? observableOf(configs.networkType) : networkRepo.getNetworkType().pipe(shareReplay(1)); + this.nemesisEpoch = configs?.nemesisEpoch + ? observableOf(configs.nemesisEpoch) + : networkRepo + .getNetworkProperties() + .pipe( + map((property) => { + return parseInt(property.network.epochAdjustment?.replace('s', '') ?? '0'); + }), + ) + .pipe(shareReplay(1)); this.generationHash = configs?.generationHash ? observableOf(configs?.generationHash) : this.createNodeRepository() @@ -135,7 +145,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { } createTransactionRepository(): TransactionRepository { - return new TransactionHttp(this.url, this.fetchApi); + return new TransactionHttp(this.url, this.nemesisEpoch, this.fetchApi); } createTransactionStatusRepository(): TransactionStatusRepository { @@ -161,4 +171,8 @@ export class RepositoryFactoryHttp implements RepositoryFactory { createListener(): IListener { return new Listener(this.websocketUrl, this.createNamespaceRepository(), this.websocketInjected); } + + getNemesisEpoch(): Observable { + return this.nemesisEpoch; + } } diff --git a/src/infrastructure/TransactionHttp.ts b/src/infrastructure/TransactionHttp.ts index 66027a47f5..4d2eb0aaec 100644 --- a/src/infrastructure/TransactionHttp.ts +++ b/src/infrastructure/TransactionHttp.ts @@ -55,15 +55,23 @@ export class TransactionHttp extends Http implements TransactionRepository { */ private blockRoutesApi: BlockRoutesApi; + /** + * @internal + * nemesis block creation epoch + */ + private readonly nemesisEpochObservable: Observable; + /** * Constructor * @param url Base catapult-rest url + * @param nemesisEpoch Nemesis block epoch * @param fetchApi fetch function to be used when performing rest requests. */ - constructor(url: string, fetchApi?: any) { + constructor(url: string, nemesisEpoch?: number | Observable, fetchApi?: any) { super(url, fetchApi); this.transactionRoutesApi = new TransactionRoutesApi(this.config()); this.blockRoutesApi = new BlockRoutesApi(this.config()); + this.nemesisEpochObservable = this.createNemesisEpochObservable(nemesisEpoch); } /** @@ -73,7 +81,13 @@ export class TransactionHttp extends Http implements TransactionRepository { * @returns Observable */ public getTransaction(transactionId: string, transactionGroup: TransactionGroup): Observable { - return this.call(this.getTransactionByGroup(transactionId, transactionGroup), (body) => CreateTransactionFromDTO(body)); + return this.nemesisEpochObservable.pipe( + mergeMap((nemesisEpoch) => + this.call(this.getTransactionByGroup(transactionId, transactionGroup), (body) => + CreateTransactionFromDTO(body, nemesisEpoch), + ), + ), + ); } /** @@ -89,22 +103,34 @@ export class TransactionHttp extends Http implements TransactionRepository { switch (transactionGroup) { case TransactionGroup.Confirmed: - return this.call(this.transactionRoutesApi.getConfirmedTransactions(transactionIdsBody), (body) => - body.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO); - }), + return this.nemesisEpochObservable.pipe( + mergeMap((nemesisEpoch) => + this.call(this.transactionRoutesApi.getConfirmedTransactions(transactionIdsBody), (body) => + body.map((transactionDTO) => { + return CreateTransactionFromDTO(transactionDTO, nemesisEpoch); + }), + ), + ), ); case TransactionGroup.Unconfirmed: - return this.call(this.transactionRoutesApi.getUnconfirmedTransactions(transactionIdsBody), (body) => - body.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO); - }), + return this.nemesisEpochObservable.pipe( + mergeMap((nemesisEpoch) => + this.call(this.transactionRoutesApi.getUnconfirmedTransactions(transactionIdsBody), (body) => + body.map((transactionDTO) => { + return CreateTransactionFromDTO(transactionDTO, nemesisEpoch); + }), + ), + ), ); case TransactionGroup.Partial: - return this.call(this.transactionRoutesApi.getPartialTransactions(transactionIdsBody), (body) => - body.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO); - }), + return this.nemesisEpochObservable.pipe( + mergeMap((nemesisEpoch) => + this.call(this.transactionRoutesApi.getPartialTransactions(transactionIdsBody), (body) => + body.map((transactionDTO) => { + return CreateTransactionFromDTO(transactionDTO, nemesisEpoch); + }), + ), + ), ); } } @@ -165,19 +191,27 @@ export class TransactionHttp extends Http implements TransactionRepository { * @returns Observable */ public getTransactionEffectiveFee(transactionId: string): Observable { - return this.call(this.getTransactionByGroup(transactionId, TransactionGroup.Confirmed), CreateTransactionFromDTO).pipe( - mergeMap((transaction) => { - // now read block details - return this.call( - this.blockRoutesApi.getBlockByHeight((transaction.transactionInfo as TransactionInfo).height.toString()), - (blockDTO: BlockInfoDTO) => { - // @see https://nemtech.github.io/concepts/transaction.html#fees - // effective_fee = feeMultiplier x transaction::size - return blockDTO.block.feeMultiplier * transaction.size; - }, - ); - }), - ); + return this.nemesisEpochObservable + .pipe( + mergeMap((nemesisEpoch) => + this.call(this.getTransactionByGroup(transactionId, TransactionGroup.Confirmed), (body) => + CreateTransactionFromDTO(body, nemesisEpoch), + ), + ), + ) + .pipe( + mergeMap((transaction) => { + // now read block details + return this.call( + this.blockRoutesApi.getBlockByHeight((transaction.transactionInfo as TransactionInfo).height.toString()), + (blockDTO: BlockInfoDTO) => { + // @see https://nemtech.github.io/concepts/transaction.html#fees + // effective_fee = feeMultiplier x transaction::size + return blockDTO.block.feeMultiplier * transaction.size; + }, + ); + }), + ); } /** @@ -187,8 +221,12 @@ export class TransactionHttp extends Http implements TransactionRepository { * @returns {Observable>} */ public search(criteria: TransactionSearchCriteria): Observable> { - return this.call(this.searchTransactionByGroup(criteria), (body) => - super.toPage(body.pagination, body.data, CreateTransactionFromDTO), + return this.nemesisEpochObservable.pipe( + mergeMap((nemesisEpoch) => + this.call(this.searchTransactionByGroup(criteria), (body) => + super.toPage(body.pagination, body.data, (body) => CreateTransactionFromDTO(body, nemesisEpoch)), + ), + ), ); } diff --git a/src/infrastructure/TransactionStatusHttp.ts b/src/infrastructure/TransactionStatusHttp.ts index a416386b9c..838c73b2c7 100644 --- a/src/infrastructure/TransactionStatusHttp.ts +++ b/src/infrastructure/TransactionStatusHttp.ts @@ -15,6 +15,7 @@ */ import { Observable } from 'rxjs'; +import { mergeMap } from 'rxjs/operators'; import { TransactionStatusDTO, TransactionStatusRoutesApi } from 'symbol-openapi-typescript-fetch-client'; import { Deadline } from '../model/transaction/Deadline'; import { TransactionStatus } from '../model/transaction/TransactionStatus'; @@ -34,14 +35,22 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo */ private transactionStatusRoutesApi: TransactionStatusRoutesApi; + /** + * @internal + * nemesis block creation epoch + */ + private readonly nemesisEpochObservable: Observable; + /** * Constructor * @param url Base catapult-rest url + * @param nemesisEpoch Nemesis block epoch * @param fetchApi fetch function to be used when performing rest requests. */ - constructor(url: string, fetchApi?: any) { + constructor(url: string, nemesisEpoch?: number | Observable, fetchApi?: any) { super(url, fetchApi); this.transactionStatusRoutesApi = new TransactionStatusRoutesApi(this.config()); + this.nemesisEpochObservable = this.createNemesisEpochObservable(nemesisEpoch); } /** @@ -50,7 +59,13 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo * @returns Observable */ public getTransactionStatus(transactionHash: string): Observable { - return this.call(this.transactionStatusRoutesApi.getTransactionStatus(transactionHash), (body) => this.toTransactionStatus(body)); + return this.nemesisEpochObservable.pipe( + mergeMap((nemesisEpoch) => + this.call(this.transactionStatusRoutesApi.getTransactionStatus(transactionHash), (body) => + this.toTransactionStatus(body, nemesisEpoch), + ), + ), + ); } /** @@ -62,8 +77,12 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo const transactionHashesBody = { hashes: transactionHashes, }; - return this.call(this.transactionStatusRoutesApi.getTransactionStatuses(transactionHashesBody), (body) => - body.map(this.toTransactionStatus), + return this.nemesisEpochObservable.pipe( + mergeMap((nemesisEpoch) => + this.call(this.transactionStatusRoutesApi.getTransactionStatuses(transactionHashesBody), (body) => + body.map((b) => this.toTransactionStatus(b, nemesisEpoch)), + ), + ), ); } @@ -72,13 +91,14 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo * * @internal * @param {TransactionStatusDTO} dto the TransactionStatusDTO object from rest. + * @param {number} nemesisEpoch the Nemesis block epoch * @returns {TransactionStatus} a TransactionStatus model */ - private toTransactionStatus(dto: TransactionStatusDTO): TransactionStatus { + private toTransactionStatus(dto: TransactionStatusDTO, nemesisEpoch): TransactionStatus { return new TransactionStatus( dto.group, dto.hash, - Deadline.createFromDTO(UInt64.fromNumericString(dto.deadline).toDTO()), + Deadline.createFromDTO(UInt64.fromNumericString(dto.deadline).toDTO(), nemesisEpoch ?? 0), dto.code, dto.height ? UInt64.fromNumericString(dto.height) : undefined, ); diff --git a/src/infrastructure/transaction/CreateTransactionFromDTO.ts b/src/infrastructure/transaction/CreateTransactionFromDTO.ts index face165824..451bce88d8 100644 --- a/src/infrastructure/transaction/CreateTransactionFromDTO.ts +++ b/src/infrastructure/transaction/CreateTransactionFromDTO.ts @@ -126,13 +126,14 @@ const extractMessage = (message: any): Message => { /** * Extract deadline from json payload. + * @param nemesisEpoch Nemesis block epoch * @param deadline - deadline dto */ -const extractDeadline = (deadline?: string): Deadline => { +const extractDeadline = (nemesisEpoch: number, deadline?: string): Deadline => { if (!deadline) { return Deadline.createEmtpy(); } - return Deadline.createFromDTO(deadline); + return Deadline.createFromDTO(deadline, nemesisEpoch); }; /** @@ -156,15 +157,16 @@ const extractTransactionMeta = (meta: any, id: string): TransactionInfo | Aggreg * @internal * @param transactionDTO * @param transactionInfo + * @param nemesisEpoch * @returns {any} * @constructor */ -const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Transaction => { +const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nemesisEpoch): Transaction => { if (transactionDTO.type === TransactionType.TRANSFER) { return new TransferTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.recipientAddress), extractMosaics(transactionDTO.mosaics), @@ -179,7 +181,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new NamespaceRegistrationTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.registrationType, transactionDTO.name, @@ -196,7 +198,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new MosaicDefinitionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), MosaicNonce.createFromNumber(transactionDTO.nonce), new MosaicId(transactionDTO.id), @@ -213,7 +215,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new MosaicSupplyChangeTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.mosaicId), transactionDTO.action, @@ -228,7 +230,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new MultisigAccountModificationTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.minApprovalDelta, transactionDTO.minRemovalDelta, @@ -245,7 +247,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new LockFundsTransaction( networkType, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), new Mosaic(new MosaicId(transactionDTO.mosaicId), UInt64.fromNumericString(transactionDTO.amount)), UInt64.fromNumericString(transactionDTO.duration), @@ -260,7 +262,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new SecretLockTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), new Mosaic(mosaicId, UInt64.fromNumericString(transactionDTO.amount)), UInt64.fromNumericString(transactionDTO.duration), @@ -278,7 +280,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new SecretProofTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.hashAlgorithm, transactionDTO.secret, @@ -294,7 +296,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new MosaicAliasTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.aliasAction, NamespaceId.createFromEncoded(transactionDTO.namespaceId), @@ -309,7 +311,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new AddressAliasTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.aliasAction, NamespaceId.createFromEncoded(transactionDTO.namespaceId), @@ -324,7 +326,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new AccountAddressRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.restrictionFlags, transactionDTO.restrictionAdditions ? transactionDTO.restrictionAdditions.map((addition) => extractRecipient(addition)) : [], @@ -339,7 +341,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new AccountOperationRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.restrictionFlags, transactionDTO.restrictionAdditions ? transactionDTO.restrictionAdditions : [], @@ -354,7 +356,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new AccountMosaicRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.restrictionFlags, transactionDTO.restrictionAdditions @@ -373,7 +375,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new AccountKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.linkAction, @@ -387,7 +389,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new MosaicGlobalRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.mosaicId), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.referenceMosaicId), @@ -406,7 +408,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new MosaicAddressRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.mosaicId), UInt64.fromHex(transactionDTO.restrictionKey), @@ -423,7 +425,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new AccountMetadataTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.targetAddress), UInt64.fromHex(transactionDTO.scopedMetadataKey), @@ -439,7 +441,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new MosaicMetadataTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.targetAddress), UInt64.fromHex(transactionDTO.scopedMetadataKey), @@ -456,7 +458,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new NamespaceMetadataTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.targetAddress), UInt64.fromHex(transactionDTO.scopedMetadataKey), @@ -473,7 +475,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new VrfKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.linkAction, @@ -487,7 +489,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new NodeKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.linkAction, @@ -501,7 +503,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr return new VotingKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(transactionDTO.deadline), + extractDeadline(nemesisEpoch, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.startEpoch, @@ -520,10 +522,11 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr /** * @internal * @param transactionDTO + * @param nemesisEpoch * @returns {Transaction} * @constructor */ -export const CreateTransactionFromDTO = (transactionDTO): Transaction => { +export const CreateTransactionFromDTO = (transactionDTO, nemesisEpoch): Transaction => { if ( transactionDTO.transaction.type === TransactionType.AGGREGATE_COMPLETE || transactionDTO.transaction.type === TransactionType.AGGREGATE_BONDED @@ -534,14 +537,14 @@ export const CreateTransactionFromDTO = (transactionDTO): Transaction => { innerTransactionDTO.transaction.maxFee = transactionDTO.transaction.maxFee; innerTransactionDTO.transaction.deadline = transactionDTO.transaction.deadline; innerTransactionDTO.transaction.signature = transactionDTO.transaction.signature; - return CreateStandaloneTransactionFromDTO(innerTransactionDTO.transaction, aggregateTransactionInfo); + return CreateStandaloneTransactionFromDTO(innerTransactionDTO.transaction, aggregateTransactionInfo, nemesisEpoch); }) : []; return new AggregateTransaction( transactionDTO.transaction.network, transactionDTO.transaction.type, transactionDTO.transaction.version, - extractDeadline(transactionDTO.transaction.deadline), + extractDeadline(nemesisEpoch, transactionDTO.transaction.deadline), UInt64.fromNumericString(transactionDTO.transaction.maxFee || '0'), innerTransactions, transactionDTO.transaction.cosignatures @@ -563,6 +566,7 @@ export const CreateTransactionFromDTO = (transactionDTO): Transaction => { return CreateStandaloneTransactionFromDTO( transactionDTO.transaction, extractTransactionMeta(transactionDTO.meta, transactionDTO.id), + nemesisEpoch, ); } }; diff --git a/src/infrastructure/transaction/CreateTransactionFromPayload.ts b/src/infrastructure/transaction/CreateTransactionFromPayload.ts index 0e6fdb54a6..f6e46043f6 100644 --- a/src/infrastructure/transaction/CreateTransactionFromPayload.ts +++ b/src/infrastructure/transaction/CreateTransactionFromPayload.ts @@ -46,63 +46,64 @@ import { VrfKeyLinkTransaction } from '../../model/transaction/VrfKeyLinkTransac /** * @internal * @param payload - The transaction binary data + * @param {number} nemesisEpoch Nemesis block epoch * @param isEmbedded - Is the transaction an embedded inner transaction * @returns {Transaction | InnerTransaction} * @constructor */ -export const CreateTransactionFromPayload = (payload: string, isEmbedded = false): Transaction | InnerTransaction => { +export const CreateTransactionFromPayload = (payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction => { const transactionBuilder = isEmbedded ? EmbeddedTransactionBuilder.loadFromBinary(convert.hexToUint8(payload)) : TransactionBuilder.loadFromBinary(convert.hexToUint8(payload)); const type = transactionBuilder.getType().valueOf(); switch (type) { case TransactionType.ACCOUNT_ADDRESS_RESTRICTION: - return AccountAddressRestrictionTransaction.createFromPayload(payload, isEmbedded); + return AccountAddressRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.ACCOUNT_MOSAIC_RESTRICTION: - return AccountMosaicRestrictionTransaction.createFromPayload(payload, isEmbedded); + return AccountMosaicRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.ACCOUNT_OPERATION_RESTRICTION: - return AccountOperationRestrictionTransaction.createFromPayload(payload, isEmbedded); + return AccountOperationRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.ACCOUNT_KEY_LINK: - return AccountKeyLinkTransaction.createFromPayload(payload, isEmbedded); + return AccountKeyLinkTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.ADDRESS_ALIAS: - return AddressAliasTransaction.createFromPayload(payload, isEmbedded); + return AddressAliasTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.MOSAIC_ALIAS: - return MosaicAliasTransaction.createFromPayload(payload, isEmbedded); + return MosaicAliasTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.MOSAIC_DEFINITION: - return MosaicDefinitionTransaction.createFromPayload(payload, isEmbedded); + return MosaicDefinitionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.MOSAIC_SUPPLY_CHANGE: - return MosaicSupplyChangeTransaction.createFromPayload(payload, isEmbedded); + return MosaicSupplyChangeTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.NAMESPACE_REGISTRATION: - return NamespaceRegistrationTransaction.createFromPayload(payload, isEmbedded); + return NamespaceRegistrationTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.TRANSFER: - return TransferTransaction.createFromPayload(payload, isEmbedded); + return TransferTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.SECRET_LOCK: - return SecretLockTransaction.createFromPayload(payload, isEmbedded); + return SecretLockTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.SECRET_PROOF: - return SecretProofTransaction.createFromPayload(payload, isEmbedded); + return SecretProofTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.MULTISIG_ACCOUNT_MODIFICATION: - return MultisigAccountModificationTransaction.createFromPayload(payload, isEmbedded); + return MultisigAccountModificationTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.HASH_LOCK: - return LockFundsTransaction.createFromPayload(payload, isEmbedded); + return LockFundsTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.MOSAIC_GLOBAL_RESTRICTION: - return MosaicGlobalRestrictionTransaction.createFromPayload(payload, isEmbedded); + return MosaicGlobalRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.MOSAIC_ADDRESS_RESTRICTION: - return MosaicAddressRestrictionTransaction.createFromPayload(payload, isEmbedded); + return MosaicAddressRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.ACCOUNT_METADATA: - return AccountMetadataTransaction.createFromPayload(payload, isEmbedded); + return AccountMetadataTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.MOSAIC_METADATA: - return MosaicMetadataTransaction.createFromPayload(payload, isEmbedded); + return MosaicMetadataTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.NAMESPACE_METADATA: - return NamespaceMetadataTransaction.createFromPayload(payload, isEmbedded); + return NamespaceMetadataTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.VRF_KEY_LINK: - return VrfKeyLinkTransaction.createFromPayload(payload, isEmbedded); + return VrfKeyLinkTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.NODE_KEY_LINK: - return NodeKeyLinkTransaction.createFromPayload(payload, isEmbedded); + return NodeKeyLinkTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.VOTING_KEY_LINK: - return VotingKeyLinkTransaction.createFromPayload(payload, isEmbedded); + return VotingKeyLinkTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); case TransactionType.AGGREGATE_COMPLETE: case TransactionType.AGGREGATE_BONDED: - return AggregateTransaction.createFromPayload(payload); + return AggregateTransaction.createFromPayload(payload, nemesisEpoch); default: throw new Error('Transaction type not implemented yet.'); } diff --git a/src/model/transaction/AccountAddressRestrictionTransaction.ts b/src/model/transaction/AccountAddressRestrictionTransaction.ts index b041233385..bd2a6471f8 100644 --- a/src/model/transaction/AccountAddressRestrictionTransaction.ts +++ b/src/model/transaction/AccountAddressRestrictionTransaction.ts @@ -109,10 +109,11 @@ export class AccountAddressRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -121,8 +122,8 @@ export class AccountAddressRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = AccountAddressRestrictionTransaction.create( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as AccountAddressRestrictionTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as AccountAddressRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions().map((addition) => { return UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(addition.unresolvedAddress)); diff --git a/src/model/transaction/AccountKeyLinkTransaction.ts b/src/model/transaction/AccountKeyLinkTransaction.ts index a0752da9a1..dd23697189 100644 --- a/src/model/transaction/AccountKeyLinkTransaction.ts +++ b/src/model/transaction/AccountKeyLinkTransaction.ts @@ -107,10 +107,11 @@ export class AccountKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -118,7 +119,9 @@ export class AccountKeyLinkTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = AccountKeyLinkTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as AccountKeyLinkTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as AccountKeyLinkTransactionBuilder).getDeadline().timestamp, nemesisEpoch), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/model/transaction/AccountMetadataTransaction.ts b/src/model/transaction/AccountMetadataTransaction.ts index e56744c402..9e2bb6308b 100644 --- a/src/model/transaction/AccountMetadataTransaction.ts +++ b/src/model/transaction/AccountMetadataTransaction.ts @@ -129,10 +129,11 @@ export class AccountMetadataTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -140,7 +141,9 @@ export class AccountMetadataTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = AccountMetadataTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as AccountMetadataTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as AccountMetadataTransactionBuilder).getDeadline().timestamp, nemesisEpoch), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), builder.getValueSizeDelta(), diff --git a/src/model/transaction/AccountMosaicRestrictionTransaction.ts b/src/model/transaction/AccountMosaicRestrictionTransaction.ts index fe92153b6d..afb13d0727 100644 --- a/src/model/transaction/AccountMosaicRestrictionTransaction.ts +++ b/src/model/transaction/AccountMosaicRestrictionTransaction.ts @@ -108,10 +108,11 @@ export class AccountMosaicRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountMosaicRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountMosaicRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -120,8 +121,8 @@ export class AccountMosaicRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = AccountMosaicRestrictionTransaction.create( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as AccountMosaicRestrictionTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as AccountMosaicRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions().map((addition) => { return UnresolvedMapping.toUnresolvedMosaic(new UInt64(addition.unresolvedMosaicId).toHex()); diff --git a/src/model/transaction/AccountOperationRestrictionTransaction.ts b/src/model/transaction/AccountOperationRestrictionTransaction.ts index e6c0121766..41863e5738 100644 --- a/src/model/transaction/AccountOperationRestrictionTransaction.ts +++ b/src/model/transaction/AccountOperationRestrictionTransaction.ts @@ -103,10 +103,11 @@ export class AccountOperationRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountOperationRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountOperationRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -115,8 +116,8 @@ export class AccountOperationRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = AccountOperationRestrictionTransaction.create( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as AccountOperationRestrictionTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as AccountOperationRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions(), builder.getRestrictionDeletions(), diff --git a/src/model/transaction/AddressAliasTransaction.ts b/src/model/transaction/AddressAliasTransaction.ts index 28e43c4791..17d84515bd 100644 --- a/src/model/transaction/AddressAliasTransaction.ts +++ b/src/model/transaction/AddressAliasTransaction.ts @@ -119,10 +119,11 @@ export class AddressAliasTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAddressAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AddressAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -130,7 +131,9 @@ export class AddressAliasTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = AddressAliasTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as AddressAliasTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as AddressAliasTransactionBuilder).getDeadline().timestamp, nemesisEpoch), builder.getAliasAction().valueOf(), new NamespaceId(builder.getNamespaceId().namespaceId), Address.createFromEncoded(Convert.uint8ToHex(builder.getAddress().address)), diff --git a/src/model/transaction/AggregateTransaction.ts b/src/model/transaction/AggregateTransaction.ts index d76843c548..486a4d9b8e 100644 --- a/src/model/transaction/AggregateTransaction.ts +++ b/src/model/transaction/AggregateTransaction.ts @@ -154,9 +154,10 @@ export class AggregateTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @returns {AggregateTransaction} */ - public static createFromPayload(payload: string): AggregateTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number): AggregateTransaction { /** * Get transaction type from the payload hex * As buffer uses separate builder class for Complete and bonded @@ -180,9 +181,9 @@ export class AggregateTransaction extends Transaction { return type === TransactionType.AGGREGATE_COMPLETE ? AggregateTransaction.createComplete( - Deadline.createFromDTO(builder.deadline.timestamp), + Deadline.createFromDTO(builder.deadline.timestamp, nemesisEpoch), innerTransactions.map((transactionRaw) => { - return CreateTransactionFromPayload(transactionRaw, true) as InnerTransaction; + return CreateTransactionFromPayload(transactionRaw, 1573430400, true) as InnerTransaction; }), networkType, consignatures, @@ -191,9 +192,9 @@ export class AggregateTransaction extends Transaction { signerPublicKey.match(`^[0]+$`) ? undefined : PublicAccount.createFromPublicKey(signerPublicKey, networkType), ) : AggregateTransaction.createBonded( - Deadline.createFromDTO(builder.deadline.timestamp), + Deadline.createFromDTO(builder.deadline.timestamp, nemesisEpoch), innerTransactions.map((transactionRaw) => { - return CreateTransactionFromPayload(transactionRaw, true) as InnerTransaction; + return CreateTransactionFromPayload(transactionRaw, 1573430400, true) as InnerTransaction; }), networkType, consignatures, diff --git a/src/model/transaction/Deadline.ts b/src/model/transaction/Deadline.ts index 287929f191..b7d22eeba3 100644 --- a/src/model/transaction/Deadline.ts +++ b/src/model/transaction/Deadline.ts @@ -25,7 +25,7 @@ export class Deadline { /** * @type {number} */ - public static timestampNemesisBlock = 1573430400; + private nemesisEpoch: number; /** * Deadline value @@ -34,11 +34,12 @@ export class Deadline { /** * Create deadline model + * @param nemesisEpoch * @param deadline * @param chronoUnit * @returns {Deadline} */ - public static create(deadline = 2, chronoUnit: ChronoUnit = ChronoUnit.HOURS): Deadline { + public static create(nemesisEpoch: number, deadline = 2, chronoUnit: ChronoUnit = ChronoUnit.HOURS): Deadline { const networkTimeStamp = new Date().getTime(); const timeStampDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(networkTimeStamp), ZoneId.SYSTEM); const deadlineDateTime = timeStampDateTime.plus(deadline, chronoUnit); @@ -49,7 +50,7 @@ export class Deadline { throw new Error('deadline should be less than 24 hours'); } - return new Deadline(deadlineDateTime); + return new Deadline(deadlineDateTime, nemesisEpoch); } /** @@ -59,43 +60,39 @@ export class Deadline { * @returns {Deadline} */ public static createEmtpy(): Deadline { - return new Deadline(LocalDateTime.MIN); + return new Deadline(LocalDateTime.MIN, 0); } /** * @param value * @returns {Deadline} */ - public static createFromDTO(value: string | number[]): Deadline { + public static createFromDTO(value: string | number[], nemesisEpoch: number): Deadline { const uint64Value = 'string' === typeof value ? UInt64.fromNumericString(value) : new UInt64(value); const dateSeconds = uint64Value.compact(); - const deadline = LocalDateTime.ofInstant( - Instant.ofEpochMilli(Math.round(dateSeconds + Deadline.timestampNemesisBlock * 1000)), - ZoneId.SYSTEM, - ); - return new Deadline(deadline); + const deadline = LocalDateTime.ofInstant(Instant.ofEpochMilli(Math.round(dateSeconds + nemesisEpoch * 1000)), ZoneId.SYSTEM); + return new Deadline(deadline, nemesisEpoch); } /** * @param deadline */ - private constructor(deadline: LocalDateTime) { + private constructor(deadline: LocalDateTime, nemesisEpoch: number) { this.value = deadline; + this.nemesisEpoch = nemesisEpoch; } /** * @internal */ public toDTO(): number[] { - return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - Deadline.timestampNemesisBlock * 1000).toDTO(); + return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - this.nemesisEpoch * 1000).toDTO(); } /** * @internal */ public toString(): string { - return UInt64.fromUint( - this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - Deadline.timestampNemesisBlock * 1000, - ).toString(); + return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - this.nemesisEpoch * 1000).toString(); } } diff --git a/src/model/transaction/LockFundsTransaction.ts b/src/model/transaction/LockFundsTransaction.ts index f4d36e967d..ed995b8ceb 100644 --- a/src/model/transaction/LockFundsTransaction.ts +++ b/src/model/transaction/LockFundsTransaction.ts @@ -134,10 +134,11 @@ export class LockFundsTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedHashLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : HashLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -145,7 +146,9 @@ export class LockFundsTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = LockFundsTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as HashLockTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as HashLockTransactionBuilder).getDeadline().timestamp, nemesisEpoch), new Mosaic(new MosaicId(builder.getMosaic().mosaicId.unresolvedMosaicId), new UInt64(builder.getMosaic().amount.amount)), new UInt64(builder.getDuration().blockDuration), new SignedTransaction('', Convert.uint8ToHex(builder.getHash().hash256), '', TransactionType.AGGREGATE_BONDED, networkType), diff --git a/src/model/transaction/MosaicAddressRestrictionTransaction.ts b/src/model/transaction/MosaicAddressRestrictionTransaction.ts index 3e5571b888..ddd08ffddc 100644 --- a/src/model/transaction/MosaicAddressRestrictionTransaction.ts +++ b/src/model/transaction/MosaicAddressRestrictionTransaction.ts @@ -145,10 +145,11 @@ export class MosaicAddressRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -157,8 +158,8 @@ export class MosaicAddressRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MosaicAddressRestrictionTransaction.create( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as MosaicAddressRestrictionTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as MosaicAddressRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), new UInt64(builder.getRestrictionKey()), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), diff --git a/src/model/transaction/MosaicAliasTransaction.ts b/src/model/transaction/MosaicAliasTransaction.ts index ac7b10c57e..a5a5cba541 100644 --- a/src/model/transaction/MosaicAliasTransaction.ts +++ b/src/model/transaction/MosaicAliasTransaction.ts @@ -116,10 +116,11 @@ export class MosaicAliasTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -127,7 +128,9 @@ export class MosaicAliasTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = MosaicAliasTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as MosaicAliasTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as MosaicAliasTransactionBuilder).getDeadline().timestamp, nemesisEpoch), builder.getAliasAction().valueOf(), new NamespaceId(builder.getNamespaceId().namespaceId), new MosaicId(builder.getMosaicId().mosaicId), diff --git a/src/model/transaction/MosaicDefinitionTransaction.ts b/src/model/transaction/MosaicDefinitionTransaction.ts index efa5b32c9d..47dc73363f 100644 --- a/src/model/transaction/MosaicDefinitionTransaction.ts +++ b/src/model/transaction/MosaicDefinitionTransaction.ts @@ -137,10 +137,11 @@ export class MosaicDefinitionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicDefinitionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicDefinitionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -149,8 +150,8 @@ export class MosaicDefinitionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MosaicDefinitionTransaction.create( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as MosaicDefinitionTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as MosaicDefinitionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), MosaicNonce.createFromUint8Array(builder.getNonce().serialize()), new MosaicId(builder.getId().mosaicId), MosaicFlags.create((builder.getFlags() & 1) === 1, (builder.getFlags() & 2) === 2, (builder.getFlags() & 4) === 4), diff --git a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts index b2049c001a..9fdfee69c6 100644 --- a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts +++ b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts @@ -161,10 +161,11 @@ export class MosaicGlobalRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicGlobalRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicGlobalRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -173,8 +174,8 @@ export class MosaicGlobalRestrictionTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MosaicGlobalRestrictionTransaction.create( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as MosaicGlobalRestrictionTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as MosaicGlobalRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), new UInt64(builder.getRestrictionKey()), new UInt64(builder.getPreviousRestrictionValue()), diff --git a/src/model/transaction/MosaicMetadataTransaction.ts b/src/model/transaction/MosaicMetadataTransaction.ts index f5370e986f..1203cef6fa 100644 --- a/src/model/transaction/MosaicMetadataTransaction.ts +++ b/src/model/transaction/MosaicMetadataTransaction.ts @@ -141,10 +141,11 @@ export class MosaicMetadataTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -152,7 +153,9 @@ export class MosaicMetadataTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = MosaicMetadataTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as MosaicMetadataTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as MosaicMetadataTransactionBuilder).getDeadline().timestamp, nemesisEpoch), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getTargetMosaicId().unresolvedMosaicId).toHex()), diff --git a/src/model/transaction/MosaicSupplyChangeTransaction.ts b/src/model/transaction/MosaicSupplyChangeTransaction.ts index 05e1275d82..5e4dbc81ba 100644 --- a/src/model/transaction/MosaicSupplyChangeTransaction.ts +++ b/src/model/transaction/MosaicSupplyChangeTransaction.ts @@ -121,10 +121,11 @@ export class MosaicSupplyChangeTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicSupplyChangeTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicSupplyChangeTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -133,8 +134,8 @@ export class MosaicSupplyChangeTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MosaicSupplyChangeTransaction.create( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as MosaicSupplyChangeTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as MosaicSupplyChangeTransactionBuilder).getDeadline().timestamp, nemesisEpoch), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), builder.getAction().valueOf(), new UInt64(builder.getDelta().amount), diff --git a/src/model/transaction/MultisigAccountModificationTransaction.ts b/src/model/transaction/MultisigAccountModificationTransaction.ts index 9ae2434d23..a8d90aa621 100644 --- a/src/model/transaction/MultisigAccountModificationTransaction.ts +++ b/src/model/transaction/MultisigAccountModificationTransaction.ts @@ -131,10 +131,11 @@ export class MultisigAccountModificationTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMultisigAccountModificationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MultisigAccountModificationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -143,8 +144,8 @@ export class MultisigAccountModificationTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = MultisigAccountModificationTransaction.create( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as MultisigAccountModificationTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as MultisigAccountModificationTransactionBuilder).getDeadline().timestamp, nemesisEpoch), builder.getMinApprovalDelta(), builder.getMinRemovalDelta(), builder.getAddressAdditions().map((addition) => { diff --git a/src/model/transaction/NamespaceMetadataTransaction.ts b/src/model/transaction/NamespaceMetadataTransaction.ts index 3447bb2af4..49c8683fd3 100644 --- a/src/model/transaction/NamespaceMetadataTransaction.ts +++ b/src/model/transaction/NamespaceMetadataTransaction.ts @@ -138,10 +138,11 @@ export class NamespaceMetadataTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNamespaceMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NamespaceMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -150,8 +151,8 @@ export class NamespaceMetadataTransaction extends Transaction { const signature = payload.substring(16, 144); const transaction = NamespaceMetadataTransaction.create( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as NamespaceMetadataTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as NamespaceMetadataTransactionBuilder).getDeadline().timestamp, nemesisEpoch), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), new NamespaceId(builder.getTargetNamespaceId().namespaceId), diff --git a/src/model/transaction/NamespaceRegistrationTransaction.ts b/src/model/transaction/NamespaceRegistrationTransaction.ts index 5f30f9a8d8..8e5174ed1d 100644 --- a/src/model/transaction/NamespaceRegistrationTransaction.ts +++ b/src/model/transaction/NamespaceRegistrationTransaction.ts @@ -174,10 +174,11 @@ export class NamespaceRegistrationTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNamespaceRegistrationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NamespaceRegistrationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -189,8 +190,11 @@ export class NamespaceRegistrationTransaction extends Transaction { registrationType === NamespaceRegistrationType.RootNamespace ? NamespaceRegistrationTransaction.createRootNamespace( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO( + (builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp, + nemesisEpoch, + ), Convert.decodeHex(Convert.uint8ToHex(builder.getName())), new UInt64(builder.getDuration()!.blockDuration), networkType, @@ -200,8 +204,11 @@ export class NamespaceRegistrationTransaction extends Transaction { ) : NamespaceRegistrationTransaction.createSubNamespace( isEmbedded - ? Deadline.create() - : Deadline.createFromDTO((builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp), + ? Deadline.createEmtpy() + : Deadline.createFromDTO( + (builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp, + nemesisEpoch, + ), Convert.decodeHex(Convert.uint8ToHex(builder.getName())), new NamespaceId(builder.getParentId()!.namespaceId), networkType, diff --git a/src/model/transaction/NodeKeyLinkTransaction.ts b/src/model/transaction/NodeKeyLinkTransaction.ts index 65e66fbff3..2a0a0ee920 100644 --- a/src/model/transaction/NodeKeyLinkTransaction.ts +++ b/src/model/transaction/NodeKeyLinkTransaction.ts @@ -103,10 +103,11 @@ export class NodeKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNodeKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NodeKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -114,7 +115,9 @@ export class NodeKeyLinkTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = NodeKeyLinkTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as NodeKeyLinkTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as NodeKeyLinkTransactionBuilder).getDeadline().timestamp, nemesisEpoch), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/model/transaction/SecretLockTransaction.ts b/src/model/transaction/SecretLockTransaction.ts index 1d1b4d9a64..d60e696820 100644 --- a/src/model/transaction/SecretLockTransaction.ts +++ b/src/model/transaction/SecretLockTransaction.ts @@ -142,10 +142,11 @@ export class SecretLockTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedSecretLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : SecretLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -153,7 +154,9 @@ export class SecretLockTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = SecretLockTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as SecretLockTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as SecretLockTransactionBuilder).getDeadline().timestamp, nemesisEpoch), new Mosaic( UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaic().mosaicId.unresolvedMosaicId).toHex()), new UInt64(builder.getMosaic().amount.amount), diff --git a/src/model/transaction/SecretProofTransaction.ts b/src/model/transaction/SecretProofTransaction.ts index 0584e6ef81..28a4de0106 100644 --- a/src/model/transaction/SecretProofTransaction.ts +++ b/src/model/transaction/SecretProofTransaction.ts @@ -119,10 +119,11 @@ export class SecretProofTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedSecretProofTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : SecretProofTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -130,7 +131,9 @@ export class SecretProofTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = SecretProofTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as SecretProofTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as SecretProofTransactionBuilder).getDeadline().timestamp, nemesisEpoch), builder.getHashAlgorithm().valueOf(), Convert.uint8ToHex(builder.getSecret().hash256), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getRecipientAddress().unresolvedAddress)), diff --git a/src/model/transaction/Transaction.ts b/src/model/transaction/Transaction.ts index d3c2742d80..f607931444 100644 --- a/src/model/transaction/Transaction.ts +++ b/src/model/transaction/Transaction.ts @@ -358,7 +358,7 @@ export abstract class Transaction { * @returns {Transaction} * @memberof Transaction */ - public reapplyGiven(deadline: Deadline = Deadline.create()): Transaction { + public reapplyGiven(deadline: Deadline): Transaction { if (this.isUnannounced()) { return DtoMapping.assign(this, { deadline }); } diff --git a/src/model/transaction/TransferTransaction.ts b/src/model/transaction/TransferTransaction.ts index 8ac85d752a..6f25102ae5 100644 --- a/src/model/transaction/TransferTransaction.ts +++ b/src/model/transaction/TransferTransaction.ts @@ -134,10 +134,11 @@ export class TransferTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedTransferTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : TransferTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -145,7 +146,9 @@ export class TransferTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = TransferTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as TransferTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as TransferTransactionBuilder).getDeadline().timestamp, nemesisEpoch), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getRecipientAddress().unresolvedAddress)), builder.getMosaics().map((mosaic) => { const id = new UInt64(mosaic.mosaicId.unresolvedMosaicId).toHex(); diff --git a/src/model/transaction/VotingKeyLinkTransaction.ts b/src/model/transaction/VotingKeyLinkTransaction.ts index 7c7f737bd8..37b0e21977 100644 --- a/src/model/transaction/VotingKeyLinkTransaction.ts +++ b/src/model/transaction/VotingKeyLinkTransaction.ts @@ -121,10 +121,11 @@ export class VotingKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedVotingKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : VotingKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -132,7 +133,9 @@ export class VotingKeyLinkTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = VotingKeyLinkTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as VotingKeyLinkTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as VotingKeyLinkTransactionBuilder).getDeadline().timestamp, nemesisEpoch), Convert.uint8ToHex(builder.getLinkedPublicKey().votingKey), builder.getStartEpoch().finalizationEpoch, builder.getEndEpoch().finalizationEpoch, diff --git a/src/model/transaction/VrfKeyLinkTransaction.ts b/src/model/transaction/VrfKeyLinkTransaction.ts index c32c004251..d337c447d2 100644 --- a/src/model/transaction/VrfKeyLinkTransaction.ts +++ b/src/model/transaction/VrfKeyLinkTransaction.ts @@ -103,10 +103,11 @@ export class VrfKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload + * @param {number} nemesisEpoch Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedVrfKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : VrfKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -114,7 +115,9 @@ export class VrfKeyLinkTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = VrfKeyLinkTransaction.create( - isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as VrfKeyLinkTransactionBuilder).getDeadline().timestamp), + isEmbedded + ? Deadline.createEmtpy() + : Deadline.createFromDTO((builder as VrfKeyLinkTransactionBuilder).getDeadline().timestamp, nemesisEpoch), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/service/AggregateTransactionService.ts b/src/service/AggregateTransactionService.ts index 0b11ef1625..86a592ffb9 100644 --- a/src/service/AggregateTransactionService.ts +++ b/src/service/AggregateTransactionService.ts @@ -47,10 +47,11 @@ export class AggregateTransactionService { /** * Check if an aggregate complete transaction has all cosignatories attached * @param signedTransaction - The signed aggregate transaction (complete) to be verified + * @param nemesisEpoch - The nemesis block epoch * @returns {Observable} */ - public isComplete(signedTransaction: SignedTransaction): Observable { - const aggregateTransaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AggregateTransaction; + public isComplete(signedTransaction: SignedTransaction, nemesisEpoch: number): Observable { + const aggregateTransaction = TransactionMapping.createFromPayload(signedTransaction.payload, nemesisEpoch) as AggregateTransaction; /** * Include both initiator & cosigners */ diff --git a/test/core/utils/TransactionMapping.spec.ts b/test/core/utils/TransactionMapping.spec.ts index 1a4152f669..612bbb8eaf 100644 --- a/test/core/utils/TransactionMapping.spec.ts +++ b/test/core/utils/TransactionMapping.spec.ts @@ -80,7 +80,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -89,7 +89,10 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = addressRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AccountAddressRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload( + signedTransaction.payload, + 1573430400, + ) as AccountAddressRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(AddressRestrictionFlag.AllowIncomingAddress); expect((transaction.restrictionAdditions[0] as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); @@ -99,7 +102,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -108,7 +111,10 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AccountMosaicRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload( + signedTransaction.payload, + 1573430400, + ) as AccountMosaicRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(MosaicRestrictionFlag.AllowMosaic); expect((transaction.restrictionAdditions[0] as MosaicId).toHex()).to.be.equal(mosaicId.toHex()); expect(transaction.restrictionDeletions.length).to.be.equal(0); @@ -117,7 +123,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -126,7 +132,10 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = operationRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AccountOperationRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload( + signedTransaction.payload, + 1573430400, + ) as AccountOperationRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(OperationRestrictionFlag.AllowOutgoingTransactionType); expect(transaction.restrictionAdditions[0]).to.be.equal(operation); expect(transaction.restrictionDeletions.length).to.be.equal(0); @@ -136,7 +145,7 @@ describe('TransactionMapping - createFromPayload', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -145,7 +154,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = addressAliasTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AddressAliasTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as AddressAliasTransaction; expect(transaction.aliasAction).to.be.equal(AliasAction.Link); expect(transaction.namespaceId.id.lower).to.be.equal(33347626); @@ -157,7 +166,7 @@ describe('TransactionMapping - createFromPayload', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -166,7 +175,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicAliasTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicAliasTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicAliasTransaction; expect(transaction.aliasAction).to.be.equal(AliasAction.Link); expect(transaction.namespaceId.id.lower).to.be.equal(33347626); expect(transaction.namespaceId.id.higher).to.be.equal(3779697293); @@ -176,7 +185,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -187,7 +196,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; expect(transaction.duration!.lower).to.be.equal(1000); expect(transaction.duration!.higher).to.be.equal(0); @@ -199,7 +208,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -210,7 +219,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -220,7 +229,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -231,7 +240,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -241,7 +250,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -252,7 +261,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -262,7 +271,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -273,7 +282,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -284,7 +293,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -293,7 +302,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicSupplyChangeTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicSupplyChangeTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicSupplyChangeTransaction; expect(transaction.action).to.be.equal(MosaicSupplyChangeAction.Increase); expect(transaction.delta.lower).to.be.equal(10); @@ -304,7 +313,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -313,7 +322,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = transferTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as TransferTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as TransferTransaction; expect(transaction.message.payload).to.be.equal('test-message'); expect(transaction.mosaics.length).to.be.equal(1); @@ -324,7 +333,7 @@ describe('TransactionMapping - createFromPayload', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SCOXVZMAZJTT4I3F7EAZYGNGR77D6WPTRFENHXQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -335,7 +344,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = secretLockTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as SecretLockTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as SecretLockTransaction; expect(transaction.mosaic.amount.equals(UInt64.fromUint(10))).to.be.equal(true); expect(transaction.duration.equals(UInt64.fromUint(100))).to.be.equal(true); @@ -347,7 +356,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), account.address, @@ -357,7 +366,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = secretProofTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as SecretProofTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as SecretProofTransaction; expect(transaction.hashAlgorithm).to.be.equal(0); expect(transaction.secret).to.be.equal('9B3155B37159DA50AA52D5967C509B410F5A36A3B1E31ECB5AC76675D79B4A5E'); expect(transaction.proof).to.be.equal(proof); @@ -366,7 +375,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -376,7 +385,10 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = modifyMultisigAccountTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MultisigAccountModificationTransaction; + const transaction = TransactionMapping.createFromPayload( + signedTransaction.payload, + 1573430400, + ) as MultisigAccountModificationTransaction; expect(transaction.minApprovalDelta).to.be.equal(2); expect(transaction.minRemovalDelta).to.be.equal(1); @@ -390,7 +402,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -398,25 +410,25 @@ describe('TransactionMapping - createFromPayload', () => { ); const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Convert.uint8ToHex(Crypto.randomBytes(48)), 1, 3, @@ -424,13 +436,13 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -440,7 +452,7 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -449,7 +461,7 @@ describe('TransactionMapping - createFromPayload', () => { UInt64.fromUint(0), ); const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -457,7 +469,7 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -466,7 +478,7 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -476,7 +488,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, new NamespaceId([2262289484, 3405110546]), new MosaicId([2262289484, 3405110546]), @@ -484,7 +496,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8('B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7')).hex(), account.address, @@ -493,7 +505,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [ transferTransaction.toAggregate(account.publicAccount), accountLinkTransaction.toAggregate(account.publicAccount), @@ -515,7 +527,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = aggregateTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AggregateTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE); expect(transaction.innerTransactions[0].type).to.be.equal(TransactionType.TRANSFER); @@ -524,7 +536,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -532,7 +544,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -540,17 +552,17 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = aggregateTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AggregateTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_BONDED); expect(transaction.innerTransactions[0].type).to.be.equal(TransactionType.TRANSFER); }); it('should create LockFundTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -559,7 +571,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedLockFundTransaction = lockTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedLockFundTransaction.payload) as LockFundsTransaction; + const transaction = TransactionMapping.createFromPayload(signedLockFundTransaction.payload, 1573430400) as LockFundsTransaction; deepEqual(transaction.mosaic.id.id, NetworkCurrencyLocal.NAMESPACE_ID.id); expect(transaction.mosaic.amount.compact()).to.be.equal(10000000); @@ -568,14 +580,14 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an AccountKeyLinkTransaction object with link action', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const signedTransaction = accountLinkTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AccountKeyLinkTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as AccountKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -583,14 +595,14 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an VrfKeyLinkTransaction object with link action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const signedTransaction = vrfKeyLinkTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as VrfKeyLinkTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as VrfKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -598,14 +610,14 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an NodeKeyLinkTransaction object with link action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const signedTransaction = nodeKeyLinkTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as NodeKeyLinkTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as NodeKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -614,7 +626,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an VotingKeyLinkTransaction object with link action', () => { const key = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), key, 1, 3, @@ -623,7 +635,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const signedTransaction = votingKeyLinkTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as VotingKeyLinkTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as VotingKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.startEpoch.toString()).to.be.equal('1'); @@ -633,7 +645,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -641,7 +653,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = registerNamespaceTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as NamespaceRegistrationTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as NamespaceRegistrationTransaction; expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.RootNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); @@ -649,7 +661,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -657,7 +669,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = registerNamespaceTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as NamespaceRegistrationTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as NamespaceRegistrationTransaction; expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.SubNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); @@ -665,7 +677,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -677,7 +689,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = mosaicGlobalRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload) as MosaicGlobalRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as MosaicGlobalRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_GLOBAL_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new MosaicId(UInt64.fromUint(1).toDTO()).toHex()); @@ -691,7 +703,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicAddressRestrictionTransaction', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), account.address, @@ -702,7 +714,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = mosaicAddressRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload) as MosaicAddressRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new MosaicId(UInt64.fromUint(1).toDTO()).toHex()); @@ -714,7 +726,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicAddressRestrictionTransaction - MosaicAlias', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -725,7 +737,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = mosaicAddressRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload) as MosaicAddressRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new NamespaceId('test').toHex()); @@ -738,7 +750,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AddressMetadataTransaction', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -747,7 +759,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const signedTx = accountMetadataTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload) as AccountMetadataTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as AccountMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -758,7 +770,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -769,7 +781,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = mosaicMetadataTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload) as MosaicMetadataTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as MosaicMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -781,7 +793,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create NamespaceMetadataTransaction', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -792,7 +804,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = namespaceMetadataTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload) as NamespaceMetadataTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as NamespaceMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -804,7 +816,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should throw error with invalid type', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -815,7 +827,7 @@ describe('TransactionMapping - createFromPayload', () => { const wrongType = signedTransaction.payload.substring(0, 219) + '0000' + signedTransaction.payload.substring(224); expect(() => { - TransactionMapping.createFromPayload(wrongType) as TransferTransaction; + TransactionMapping.createFromPayload(wrongType, 1573430400) as TransferTransaction; }).to.throw(); }); }); @@ -829,14 +841,14 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create TransferTransaction - Address', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON()) as TransferTransaction; + const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON(), 1573430400) as TransferTransaction; expect((transaction.recipientAddress as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); expect(transaction.message.payload).to.be.equal('test-message'); @@ -844,14 +856,14 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create TransferTransaction - NamespaceId', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new NamespaceId([33347626, 3779697293]), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON()) as TransferTransaction; + const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON(), 1573430400) as TransferTransaction; expect((transaction.recipientAddress as NamespaceId).id.toHex().toUpperCase()).to.be.equal( new UInt64([33347626, 3779697293]).toHex(), ); @@ -860,14 +872,14 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create TransferTransaction - Encrypted Message', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], new EncryptedMessage('12324556'), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON()) as TransferTransaction; + const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON(), 1573430400) as TransferTransaction; expect((transaction.recipientAddress as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); expect(transaction.message.type).to.be.equal(MessageType.EncryptedMessage); @@ -875,13 +887,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountKeyLinkTransaction', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(accountLinkTransaction.toJSON()) as AccountKeyLinkTransaction; + const transaction = TransactionMapping.createFromDTO(accountLinkTransaction.toJSON(), 1573430400) as AccountKeyLinkTransaction; expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); expect(transaction.linkAction).to.be.equal(LinkAction.Link); @@ -889,13 +901,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create VrfKeyLinkTransaction', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(vrfKeyLinkTransaction.toJSON()) as VrfKeyLinkTransaction; + const transaction = TransactionMapping.createFromDTO(vrfKeyLinkTransaction.toJSON(), 1573430400) as VrfKeyLinkTransaction; expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); expect(transaction.linkAction).to.be.equal(LinkAction.Link); @@ -903,13 +915,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NodeKeyLinkTransaction', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(nodeKeyLinkTransaction.toJSON()) as NodeKeyLinkTransaction; + const transaction = TransactionMapping.createFromDTO(nodeKeyLinkTransaction.toJSON(), 1573430400) as NodeKeyLinkTransaction; expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); expect(transaction.linkAction).to.be.equal(LinkAction.Link); @@ -918,7 +930,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create VotingKeyLinkTransaction', () => { const key = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), key, 1, 3, @@ -926,7 +938,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(votingKeyLinkTransaction.toJSON()) as VotingKeyLinkTransaction; + const transaction = TransactionMapping.createFromDTO(votingKeyLinkTransaction.toJSON(), 1573430400) as VotingKeyLinkTransaction; expect(transaction.linkedPublicKey).to.be.equal(key); expect(transaction.startEpoch.toString()).to.be.equal('1'); @@ -936,7 +948,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -945,6 +957,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( addressRestrictionTransaction.toJSON(), + 1573430400, ) as AccountAddressRestrictionTransaction; expect((transaction.restrictionAdditions[0] as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); @@ -955,14 +968,17 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(mosaicRestrictionTransaction.toJSON()) as AccountMosaicRestrictionTransaction; + const transaction = TransactionMapping.createFromDTO( + mosaicRestrictionTransaction.toJSON(), + 1573430400, + ) as AccountMosaicRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_MOSAIC_RESTRICTION); expect(transaction.restrictionFlags).to.be.equal(MosaicRestrictionFlag.AllowMosaic); @@ -972,7 +988,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -981,6 +997,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( operationRestrictionTransaction.toJSON(), + 1573430400, ) as AccountMosaicRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_OPERATION_RESTRICTION); @@ -992,14 +1009,14 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(addressAliasTransaction.toJSON()) as AddressAliasTransaction; + const transaction = TransactionMapping.createFromDTO(addressAliasTransaction.toJSON(), 1573430400) as AddressAliasTransaction; expect(transaction.type).to.be.equal(TransactionType.ADDRESS_ALIAS); expect(transaction.aliasAction).to.be.equal(AliasAction.Link); @@ -1009,13 +1026,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(mosaicAliasTransaction.toJSON()) as MosaicAliasTransaction; + const transaction = TransactionMapping.createFromDTO(mosaicAliasTransaction.toJSON(), 1573430400) as MosaicAliasTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ALIAS); expect(transaction.aliasAction).to.be.equal(AliasAction.Link); @@ -1023,7 +1040,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -1032,7 +1049,10 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(mosaicDefinitionTransaction.toJSON()) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromDTO( + mosaicDefinitionTransaction.toJSON(), + 1573430400, + ) as MosaicDefinitionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_DEFINITION); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -1044,14 +1064,17 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(mosaicSupplyChangeTransaction.toJSON()) as MosaicSupplyChangeTransaction; + const transaction = TransactionMapping.createFromDTO( + mosaicSupplyChangeTransaction.toJSON(), + 1573430400, + ) as MosaicSupplyChangeTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_SUPPLY_CHANGE); expect(transaction.action).to.be.equal(MosaicSupplyChangeAction.Increase); @@ -1061,7 +1084,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SCOXVZMAZJTT4I3F7EAZYGNGR77D6WPTRFENHXQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1070,7 +1093,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON()) as SecretLockTransaction; + const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON(), 1573430400) as SecretLockTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_LOCK); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1080,7 +1103,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1089,7 +1112,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON()) as SecretLockTransaction; + const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON(), 1573430400) as SecretLockTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_LOCK); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1100,7 +1123,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SCOXVZMAZJTT4I3F7EAZYGNGR77D6WPTRFENHXQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new Mosaic(new MosaicId([1, 1]), UInt64.fromUint(10)), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1109,7 +1132,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON()) as SecretLockTransaction; + const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON(), 1573430400) as SecretLockTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_LOCK); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1119,7 +1142,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), account.address, @@ -1127,7 +1150,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretProofTransaction.toJSON()) as SecretProofTransaction; + const transaction = TransactionMapping.createFromDTO(secretProofTransaction.toJSON(), 1573430400) as SecretProofTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_PROOF); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1140,7 +1163,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), recipientAddress, @@ -1148,7 +1171,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretProofTransaction.toJSON()) as SecretProofTransaction; + const transaction = TransactionMapping.createFromDTO(secretProofTransaction.toJSON(), 1573430400) as SecretProofTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_PROOF); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1159,7 +1182,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -1169,6 +1192,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( modifyMultisigAccountTransaction.toJSON(), + 1573430400, ) as MultisigAccountModificationTransaction; expect(transaction.type).to.be.equal(TransactionType.MULTISIG_ACCOUNT_MODIFICATION); @@ -1178,7 +1202,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -1186,13 +1210,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); - const transaction = TransactionMapping.createFromDTO(aggregateTransaction.toJSON()) as AggregateTransaction; + const transaction = TransactionMapping.createFromDTO(aggregateTransaction.toJSON(), 1573430400) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE); expect(transaction.innerTransactions.length).to.be.equal(1); @@ -1200,7 +1224,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -1208,30 +1232,30 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); - const transaction = TransactionMapping.createFromDTO(aggregateTransaction.toJSON()) as AggregateTransaction; + const transaction = TransactionMapping.createFromDTO(aggregateTransaction.toJSON(), 1573430400) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_BONDED); expect(transaction.innerTransactions.length).to.be.equal(1); }); it('should create LockFundTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(lockTransaction.toJSON()) as LockFundsTransaction; + const transaction = TransactionMapping.createFromDTO(lockTransaction.toJSON(), 1573430400) as LockFundsTransaction; expect(transaction.type).to.be.equal(TransactionType.HASH_LOCK); expect(transaction.hash).to.be.equal(signedTransaction.hash); @@ -1239,32 +1263,38 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(registerNamespaceTransaction.toJSON()) as NamespaceRegistrationTransaction; + const transaction = TransactionMapping.createFromDTO( + registerNamespaceTransaction.toJSON(), + 1573430400, + ) as NamespaceRegistrationTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_REGISTRATION); }); it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(registerNamespaceTransaction.toJSON()) as NamespaceRegistrationTransaction; + const transaction = TransactionMapping.createFromDTO( + registerNamespaceTransaction.toJSON(), + 1573430400, + ) as NamespaceRegistrationTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_REGISTRATION); }); it('should create MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -1276,6 +1306,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( mosaicGlobalRestrictionTransaction.toJSON(), + 1573430400, ) as MosaicGlobalRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_GLOBAL_RESTRICTION); @@ -1290,7 +1321,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicAddressRestrictionTransaction', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), account.address, @@ -1301,6 +1332,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( mosaicAddressRestrictionTransaction.toJSON(), + 1573430400, ) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); @@ -1313,7 +1345,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AddressMetadataTransaction', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -1321,7 +1353,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(accountMetadataTransaction.toJSON()) as AccountMetadataTransaction; + const transaction = TransactionMapping.createFromDTO(accountMetadataTransaction.toJSON(), 1573430400) as AccountMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -1332,7 +1364,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -1341,7 +1373,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(mosaicMetadataTransaction.toJSON()) as MosaicMetadataTransaction; + const transaction = TransactionMapping.createFromDTO(mosaicMetadataTransaction.toJSON(), 1573430400) as MosaicMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -1353,7 +1385,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NamespaceMetadataTransaction', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -1362,7 +1394,10 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(namespaceMetadataTransaction.toJSON()) as NamespaceMetadataTransaction; + const transaction = TransactionMapping.createFromDTO( + namespaceMetadataTransaction.toJSON(), + 1573430400, + ) as NamespaceMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; diff --git a/test/core/utils/TransactionMappingWithSignatures.spec.ts b/test/core/utils/TransactionMappingWithSignatures.spec.ts index 936e5382fc..75c7d30844 100644 --- a/test/core/utils/TransactionMappingWithSignatures.spec.ts +++ b/test/core/utils/TransactionMappingWithSignatures.spec.ts @@ -80,7 +80,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -91,7 +91,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = addressRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountAddressRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountAddressRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(AddressRestrictionFlag.AllowIncomingAddress); expect((transaction.restrictionAdditions[0] as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); @@ -102,7 +102,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(addressRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = addressRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountAddressRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountAddressRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -110,7 +110,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -122,7 +122,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountMosaicRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountMosaicRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(MosaicRestrictionFlag.AllowMosaic); expect((transaction.restrictionAdditions[0] as MosaicId).toHex()).to.be.equal(mosaicId.toHex()); expect(transaction.restrictionDeletions.length).to.be.equal(0); @@ -132,7 +132,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountMosaicRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountMosaicRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -140,7 +140,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -152,7 +152,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = operationRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountOperationRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountOperationRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(OperationRestrictionFlag.AllowOutgoingTransactionType); expect(transaction.restrictionAdditions[0]).to.be.equal(operation); expect(transaction.restrictionDeletions.length).to.be.equal(0); @@ -163,7 +163,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(operationRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = operationRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountOperationRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountOperationRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -172,7 +172,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -184,7 +184,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = addressAliasTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as AddressAliasTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AddressAliasTransaction; expect(transaction.aliasAction).to.be.equal(AliasAction.Link); expect(transaction.namespaceId.id.lower).to.be.equal(33347626); @@ -196,7 +196,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(addressAliasTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = addressAliasTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as AddressAliasTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AddressAliasTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -205,7 +205,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -217,7 +217,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicAliasTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAliasTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAliasTransaction; expect(transaction.aliasAction).to.be.equal(AliasAction.Link); expect(transaction.namespaceId.id.lower).to.be.equal(33347626); expect(transaction.namespaceId.id.higher).to.be.equal(3779697293); @@ -229,14 +229,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicAliasTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicAliasTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAliasTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAliasTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -250,7 +250,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicDefinitionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicDefinitionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicDefinitionTransaction; expect(transaction.duration!.lower).to.be.equal(1000); expect(transaction.duration!.higher).to.be.equal(0); @@ -264,14 +264,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicDefinitionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicDefinitionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicDefinitionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicDefinitionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -285,7 +285,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicDefinitionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicDefinitionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -297,7 +297,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicDefinitionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicDefinitionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicDefinitionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicDefinitionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -305,7 +305,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -317,7 +317,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicSupplyChangeTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicSupplyChangeTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicSupplyChangeTransaction; expect(transaction.action).to.be.equal(MosaicSupplyChangeAction.Increase); expect(transaction.delta.lower).to.be.equal(10); @@ -330,14 +330,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicSupplyChangeTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicSupplyChangeTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicSupplyChangeTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicSupplyChangeTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -349,7 +349,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = transferTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as TransferTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as TransferTransaction; expect(transaction.message.payload).to.be.equal('test-message'); expect(transaction.mosaics.length).to.be.equal(1); @@ -360,7 +360,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(transferTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = transferTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as TransferTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as TransferTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -369,7 +369,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -383,7 +383,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = secretLockTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as SecretLockTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as SecretLockTransaction; expect(transaction.mosaic.amount.equals(UInt64.fromUint(10))).to.be.equal(true); expect(transaction.duration.equals(UInt64.fromUint(100))).to.be.equal(true); @@ -396,7 +396,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(secretLockTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = secretLockTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as SecretLockTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as SecretLockTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -404,7 +404,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), account.address, @@ -417,7 +417,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = secretProofTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as SecretProofTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as SecretProofTransaction; expect(transaction.hashAlgorithm).to.be.equal(0); expect(transaction.secret).to.be.equal('9B3155B37159DA50AA52D5967C509B410F5A36A3B1E31ECB5AC76675D79B4A5E'); expect(transaction.proof).to.be.equal(proof); @@ -428,14 +428,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(secretProofTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = secretProofTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as SecretProofTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as SecretProofTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -448,7 +448,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = modifyMultisigAccountTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as MultisigAccountModificationTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MultisigAccountModificationTransaction; expect(transaction.minApprovalDelta).to.be.equal(2); expect(transaction.minRemovalDelta).to.be.equal(1); @@ -464,14 +464,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(modifyMultisigAccountTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = modifyMultisigAccountTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as MultisigAccountModificationTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MultisigAccountModificationTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -479,25 +479,25 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Convert.uint8ToHex(Crypto.randomBytes(48)), 1, 3, @@ -505,13 +505,13 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -521,7 +521,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -530,7 +530,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign UInt64.fromUint(0), ); const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -538,7 +538,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -547,7 +547,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -557,7 +557,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, new NamespaceId([2262289484, 3405110546]), new MosaicId([2262289484, 3405110546]), @@ -565,7 +565,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8('B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7')).hex(), account.address, @@ -574,7 +574,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [ transferTransaction.toAggregate(account.publicAccount), accountLinkTransaction.toAggregate(account.publicAccount), @@ -599,7 +599,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = aggregateTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as AggregateTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE); expect(transaction.innerTransactions[0].type).to.be.equal(TransactionType.TRANSFER); @@ -610,14 +610,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(aggregateTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = aggregateTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as AggregateTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AggregateTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -625,7 +625,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -636,7 +636,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = aggregateTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as AggregateTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_BONDED); expect(transaction.innerTransactions[0].type).to.be.equal(TransactionType.TRANSFER); @@ -646,16 +646,16 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(aggregateTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = aggregateTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as AggregateTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AggregateTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create LockFundTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -667,7 +667,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedLockFundTransaction = lockTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedLockFundTransaction) as LockFundsTransaction; + let transaction = TransactionMapping.createFromPayload(signedLockFundTransaction, 1573430400) as LockFundsTransaction; deepEqual(transaction.mosaic.id.id, NetworkCurrencyLocal.NAMESPACE_ID.id); expect(transaction.mosaic.amount.compact()).to.be.equal(10000000); @@ -678,14 +678,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(aggregateTransaction, { signature: emtptySignature, signer: undefined }); signedLockFundTransaction = aggregateTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedLockFundTransaction) as LockFundsTransaction; + transaction = TransactionMapping.createFromPayload(signedLockFundTransaction, 1573430400) as LockFundsTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create an AccountKeyLinkTransaction object with link action', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -695,7 +695,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = accountLinkTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountKeyLinkTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -705,14 +705,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(accountLinkTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = accountLinkTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountKeyLinkTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountKeyLinkTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create an VrfKeyLinkTransaction object with link action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -722,7 +722,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = vrfKeyLinkTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as VrfKeyLinkTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as VrfKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -732,14 +732,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(vrfKeyLinkTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = vrfKeyLinkTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as VrfKeyLinkTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as VrfKeyLinkTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create an NodeKeyLinkTransaction object with link action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -749,7 +749,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = nodeKeyLinkTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as NodeKeyLinkTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NodeKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -759,7 +759,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(nodeKeyLinkTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = nodeKeyLinkTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as NodeKeyLinkTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NodeKeyLinkTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -767,7 +767,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create an VotingKeyLinkTransaction object with link action', () => { const key = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), key, 1, 3, @@ -779,7 +779,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = votingKeyLinkTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as VotingKeyLinkTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as VotingKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(key); @@ -791,14 +791,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(votingKeyLinkTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = votingKeyLinkTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as VotingKeyLinkTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as VotingKeyLinkTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -809,7 +809,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = registerNamespaceTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceRegistrationTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceRegistrationTransaction; expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.RootNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); @@ -819,14 +819,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(registerNamespaceTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = registerNamespaceTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceRegistrationTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceRegistrationTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -837,7 +837,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = registerNamespaceTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceRegistrationTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceRegistrationTransaction; expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.SubNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); @@ -847,14 +847,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(registerNamespaceTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = registerNamespaceTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceRegistrationTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceRegistrationTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -870,7 +870,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicGlobalRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicGlobalRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicGlobalRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_GLOBAL_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new MosaicId(UInt64.fromUint(1).toDTO()).toHex()); @@ -886,14 +886,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicGlobalRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicGlobalRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicGlobalRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicGlobalRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicAddressRestrictionTransaction', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), account.address, @@ -907,7 +907,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicAddressRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAddressRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new MosaicId(UInt64.fromUint(1).toDTO()).toHex()); @@ -921,14 +921,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicAddressRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicAddressRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAddressRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAddressRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicAddressRestrictionTransaction - MosaicAlias', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -942,7 +942,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicAddressRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAddressRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new NamespaceId('test').toHex()); @@ -957,14 +957,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicAddressRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicAddressRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAddressRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAddressRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create AddressMetadataTransaction', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -976,7 +976,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = accountMetadataTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountMetadataTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -989,14 +989,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(accountMetadataTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = accountMetadataTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountMetadataTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountMetadataTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -1010,7 +1010,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicMetadataTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicMetadataTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -1024,14 +1024,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicMetadataTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicMetadataTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicMetadataTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicMetadataTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create NamespaceMetadataTransaction', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -1045,7 +1045,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = namespaceMetadataTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceMetadataTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -1059,14 +1059,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(namespaceMetadataTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = namespaceMetadataTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceMetadataTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceMetadataTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should throw error with invalid type', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -1080,7 +1080,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const wrongType = signedTransaction.substring(0, 219) + '0000' + signedTransaction.substring(224); expect(() => { - TransactionMapping.createFromPayload(wrongType) as TransferTransaction; + TransactionMapping.createFromPayload(wrongType, 1573430400) as TransferTransaction; }).to.throw(); }); }); diff --git a/test/infrastructure/Listener.spec.ts b/test/infrastructure/Listener.spec.ts index 408a5a0289..2d4dacff49 100644 --- a/test/infrastructure/Listener.spec.ts +++ b/test/infrastructure/Listener.spec.ts @@ -43,20 +43,21 @@ describe('Listener', () => { let namespaceRepoMock: NamespaceRepository; let namespaceRepo: NamespaceRepository; + const nemesisEpoch = 1573430400; beforeEach(() => { namespaceRepoMock = mock(); namespaceRepo = instance(namespaceRepoMock); }); it('should createComplete a WebSocket instance given url parameter', () => { - const listener = new Listener('http://localhost:3000/ws', namespaceRepo); + const listener = new Listener('http://localhost:3000/ws', namespaceRepo, nemesisEpoch); expect('http://localhost:3000/ws').to.be.equal(listener.url); listener.close(); }); describe('isOpen', () => { it('should return false when listener is created and not opened', () => { - const listener = new Listener('http://localhost:3000', namespaceRepo); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch); expect(listener.isOpen()).to.be.false; listener.close(); }); @@ -85,7 +86,7 @@ describe('Listener', () => { code: 'error-message', }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); @@ -124,7 +125,7 @@ describe('Listener', () => { code: 'error-message', }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); @@ -169,7 +170,7 @@ describe('Listener', () => { }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); @@ -192,7 +193,7 @@ describe('Listener', () => { describe('onerror', () => { it('should reject because of wrong server url', async () => { - const listener = new Listener('https://notcorrecturl:0000', namespaceRepo); + const listener = new Listener('https://notcorrecturl:0000', namespaceRepo, nemesisEpoch); await listener .open() .then(() => { @@ -235,7 +236,7 @@ describe('Listener', () => { ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), alias, [], PlainMessage.create('test-message'), @@ -246,7 +247,7 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -279,7 +280,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), alias, [], PlainMessage.create('test-message'), @@ -291,7 +292,7 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash2).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -324,7 +325,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), alias, [], PlainMessage.create('test-message'), @@ -335,7 +336,7 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -368,7 +369,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), alias2, [], PlainMessage.create('test-message'), @@ -380,7 +381,7 @@ describe('Listener', () => { const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((unconfirmedTransaction) => { reportedTransactions.push(unconfirmedTransaction); @@ -414,7 +415,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), alias2, [], PlainMessage.create('test-message'), @@ -429,7 +430,7 @@ describe('Listener', () => { const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -486,7 +487,7 @@ describe('Listener', () => { }; const reportedTransactions: string[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedHash) => { reportedTransactions.push(confirmedHash); @@ -506,7 +507,7 @@ describe('Listener', () => { }; const reportedTransactions: string[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress).subscribe((confirmedHash) => { reportedTransactions.push(confirmedHash); @@ -526,7 +527,7 @@ describe('Listener', () => { }; const reportedTransactions: string[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, 'invalid!').subscribe((confirmedHash) => { reportedTransactions.push(confirmedHash); @@ -583,7 +584,7 @@ describe('Listener', () => { }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); @@ -638,7 +639,7 @@ describe('Listener', () => { }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); listener.open(); diff --git a/test/infrastructure/MetadataHttp.spec.ts b/test/infrastructure/MetadataHttp.spec.ts index 62ef2d0e55..e5699592aa 100644 --- a/test/infrastructure/MetadataHttp.spec.ts +++ b/test/infrastructure/MetadataHttp.spec.ts @@ -361,7 +361,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); metadataTransactionService .createAccountMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, address, UInt64.fromHex('85BBEA6CC462B244'), @@ -394,7 +394,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); metadataTransactionService .createMosaicMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, address, mosaicId, @@ -428,7 +428,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); metadataTransactionService .createNamespaceMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, address, namespaceId, @@ -461,7 +461,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); await metadataTransactionService .createAccountMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, address, UInt64.fromHex('85BBEA6CC462B244'), @@ -490,7 +490,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); await metadataTransactionService .createMosaicMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, address, mosaicId, @@ -520,7 +520,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); await metadataTransactionService .createNamespaceMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, address, namespaceId, diff --git a/test/infrastructure/Page.spec.ts b/test/infrastructure/Page.spec.ts index 56f08b6d9d..a8bab694cf 100644 --- a/test/infrastructure/Page.spec.ts +++ b/test/infrastructure/Page.spec.ts @@ -27,7 +27,7 @@ describe('Page', () => { it('should create Page', () => { const account = TestingAccount; let page = new Page( - [TransferTransaction.create(Deadline.create(), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)], + [TransferTransaction.create(Deadline.create(1573430400), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)], 1, 1, ); @@ -37,7 +37,7 @@ describe('Page', () => { expect(page.isLastPage).to.be.false; page = new Page( - [TransferTransaction.create(Deadline.create(), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)], + [TransferTransaction.create(Deadline.create(1573430400), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)], 2, 2, ); diff --git a/test/infrastructure/RepositoryFactory.spec.ts b/test/infrastructure/RepositoryFactory.spec.ts index 02e2a74ddb..c0c75b5e3d 100644 --- a/test/infrastructure/RepositoryFactory.spec.ts +++ b/test/infrastructure/RepositoryFactory.spec.ts @@ -41,6 +41,7 @@ import { NetworkType } from '../../src/model/network/NetworkType'; import { NodeInfo } from '../../src/model/node/NodeInfo'; import { HashLockHttp } from '../../src/infrastructure/HashLockHttp'; import { SecretLockHttp } from '../../src/infrastructure/SecretLockHttp'; +import { NetworkConfigurationDTO } from 'symbol-openapi-typescript-fetch-client'; describe('RepositoryFactory', () => { it('Should create repositories', () => { @@ -121,6 +122,7 @@ describe('RepositoryFactory', () => { } })('http://localhost:3000', { generationHash: 'testHash', + nemesisEpoch: 1573430400, }); expect(counter).to.be.equals(0); @@ -135,6 +137,51 @@ describe('RepositoryFactory', () => { }); }); + it('Should get NemesisEpoch from cache', (done) => { + let counter = 0; + const repositoryMock: NetworkRepository = mock(); + const expectedNemesisEpoch = 1573430400; + const body: NetworkConfigurationDTO = { + network: { + identifier: 'public-test', + nemesisSignerPublicKey: 'E3F04CA92250B49679EBEF98FAC87C1CECAC7E7491ECBB2307DF1AD65BED57FD', + generationHashSeed: 'AE6488282F9C09457F017BE5EE26387B21EB15CF32D6DA1E9846C25E00828329', + epochAdjustment: '1573430400s', + }, + chain: {}, + plugins: {}, + }; + const observableOfNetworkProperties = observableOf(body).pipe( + map((v) => { + counter++; + return v; + }), + ); + when(repositoryMock.getNetworkProperties()).thenReturn(observableOfNetworkProperties); + + expect(observableOfNetworkProperties).to.be.equals(observableOfNetworkProperties); + + const repositoryFactory = new (class RepositoryFactoryHttpForTest extends RepositoryFactoryHttp { + createNetworkRepository(): NetworkRepository { + return instance(repositoryMock); + } + })('http://localhost:3000', { + generationHash: 'testHash', + networkType: 152, + }); + + expect(counter).to.be.equals(0); + repositoryFactory.getNemesisEpoch().subscribe((epoch) => { + expect(counter).to.be.equals(1); + expect(epoch).to.be.equals(expectedNemesisEpoch); + repositoryFactory.getNemesisEpoch().subscribe((network) => { + expect(counter).to.be.equals(1); + expect(network).to.be.equals(expectedNemesisEpoch); + done(); + }); + }); + }); + it('Should get NetworkType from memory', (done) => { let counter = 0; @@ -158,6 +205,7 @@ describe('RepositoryFactory', () => { })('http://localhost:3000', { networkType: expectedNetworkType, generationHash: 'testHash', + nemesisEpoch: 1573430400, }); expect(counter).to.be.equals(0); @@ -172,6 +220,53 @@ describe('RepositoryFactory', () => { }); }); + it('Should get NemesisEpoch from memory', (done) => { + let counter = 0; + + const repositoryMock: NetworkRepository = mock(); + const expectedNemesisEpoch = 1573430400; + const body: NetworkConfigurationDTO = { + network: { + identifier: 'public-test', + nemesisSignerPublicKey: 'E3F04CA92250B49679EBEF98FAC87C1CECAC7E7491ECBB2307DF1AD65BED57FD', + generationHashSeed: 'AE6488282F9C09457F017BE5EE26387B21EB15CF32D6DA1E9846C25E00828329', + epochAdjustment: '1573430400s', + }, + chain: {}, + plugins: {}, + }; + const observableOfNetworkProperties = observableOf(body).pipe( + map((v) => { + counter++; + return v; + }), + ); + when(repositoryMock.getNetworkProperties()).thenReturn(observableOfNetworkProperties); + + expect(observableOfNetworkProperties).to.be.equals(observableOfNetworkProperties); + + const repositoryFactory = new (class RepositoryFactoryHttpForTest extends RepositoryFactoryHttp { + createNetworkRepository(): NetworkRepository { + return instance(repositoryMock); + } + })('http://localhost:3000', { + networkType: 152, + generationHash: 'testHash', + nemesisEpoch: 1573430400, + }); + + expect(counter).to.be.equals(0); + repositoryFactory.getNemesisEpoch().subscribe((networkType) => { + expect(counter).to.be.equals(0); + expect(networkType).to.be.equals(expectedNemesisEpoch); + repositoryFactory.getNemesisEpoch().subscribe((network) => { + expect(counter).to.be.equals(0); + expect(network).to.be.equals(expectedNemesisEpoch); + done(); + }); + }); + }); + it('Should create listener object using injected ws', () => { class WebSocketMock { constructor(public readonly url: string) {} diff --git a/test/infrastructure/SerializeTransactionToJSON.spec.ts b/test/infrastructure/SerializeTransactionToJSON.spec.ts index 4de04b5f2c..a5e58df03d 100644 --- a/test/infrastructure/SerializeTransactionToJSON.spec.ts +++ b/test/infrastructure/SerializeTransactionToJSON.spec.ts @@ -64,7 +64,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountKeyLinkTransaction', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -79,7 +79,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -96,7 +96,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -113,7 +113,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -131,7 +131,7 @@ describe('SerializeTransactionToJSON', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -148,7 +148,7 @@ describe('SerializeTransactionToJSON', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -162,7 +162,7 @@ describe('SerializeTransactionToJSON', () => { it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -181,7 +181,7 @@ describe('SerializeTransactionToJSON', () => { it('should create MosaicDefinitionTransaction without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, false), @@ -200,7 +200,7 @@ describe('SerializeTransactionToJSON', () => { it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -215,7 +215,7 @@ describe('SerializeTransactionToJSON', () => { it('should create TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -232,7 +232,7 @@ describe('SerializeTransactionToJSON', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -250,7 +250,7 @@ describe('SerializeTransactionToJSON', () => { it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -268,7 +268,7 @@ describe('SerializeTransactionToJSON', () => { it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -285,7 +285,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -293,7 +293,7 @@ describe('SerializeTransactionToJSON', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -307,7 +307,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -315,7 +315,7 @@ describe('SerializeTransactionToJSON', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -329,10 +329,10 @@ describe('SerializeTransactionToJSON', () => { it('should create LockFundTransaction', () => { const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -347,7 +347,7 @@ describe('SerializeTransactionToJSON', () => { it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -360,7 +360,7 @@ describe('SerializeTransactionToJSON', () => { it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -373,7 +373,7 @@ describe('SerializeTransactionToJSON', () => { it('should create VrfKeyLinkTransaction', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -386,7 +386,7 @@ describe('SerializeTransactionToJSON', () => { it('should create NodeKeyLinkTransaction', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -400,7 +400,7 @@ describe('SerializeTransactionToJSON', () => { it('should create VotingKeyLinkTransaction', () => { const votingKey = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), votingKey, 1, 3, diff --git a/test/infrastructure/TransactionHttp.spec.ts b/test/infrastructure/TransactionHttp.spec.ts index 92a6cd99b5..bb545efb2d 100644 --- a/test/infrastructure/TransactionHttp.spec.ts +++ b/test/infrastructure/TransactionHttp.spec.ts @@ -62,28 +62,28 @@ describe('TransactionHttp', () => { before(() => { transactionRoutesApi = mock(); blockRoutesApi = mock(); - transactionHttp = new TransactionHttp(NIS2_URL); + transactionHttp = new TransactionHttp(NIS2_URL, 1573430400); (transactionHttp as object)['transactionRoutesApi'] = instance(transactionRoutesApi); (transactionHttp as object)['blockRoutesApi'] = instance(blockRoutesApi); }); it('should return an error when a non aggregate transaction bonded is announced via announceAggregateBonded method', () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), NetworkType.MIJIN_TEST, ); const aggTx = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); const signedTx = account.sign(aggTx, generationHash); - const trnsHttp = new TransactionHttp(NIS2_URL); + const trnsHttp = new TransactionHttp(NIS2_URL, 1573430400); expect(() => { trnsHttp.announceAggregateBonded(signedTx).toPromise().then(); }).to.throw(Error, 'Only Transaction Type 0x4241 is allowed for announce aggregate bonded'); @@ -388,7 +388,7 @@ describe('TransactionHttp', () => { it('Test announce', async () => { const response = { message: 'done' }; const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -407,7 +407,7 @@ describe('TransactionHttp', () => { const response = { message: 'done' }; const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -415,7 +415,7 @@ describe('TransactionHttp', () => { ); const aggTx = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(1573430400), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -495,7 +495,7 @@ describe('TransactionHttp', () => { it('announce - Error', async () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -515,7 +515,7 @@ describe('TransactionHttp', () => { const response = { message: 'done' }; const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -523,7 +523,7 @@ describe('TransactionHttp', () => { ); const aggTx = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(1573430400), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], diff --git a/test/infrastructure/TransactionStatusHttp.spec.ts b/test/infrastructure/TransactionStatusHttp.spec.ts index 0e08ae4620..9de3e82c97 100644 --- a/test/infrastructure/TransactionStatusHttp.spec.ts +++ b/test/infrastructure/TransactionStatusHttp.spec.ts @@ -29,10 +29,11 @@ import { NIS2_URL } from '../conf/conf.spec'; describe('TransactionStatusHttp', () => { let transactionStatusRoutesApi: TransactionStatusRoutesApi; let transactionStatusHttp: TransactionStatusHttp; + const nemesisEpoch = 1573430400; before(() => { transactionStatusRoutesApi = mock(); - transactionStatusHttp = new TransactionStatusHttp(NIS2_URL); + transactionStatusHttp = new TransactionStatusHttp(NIS2_URL, nemesisEpoch); (transactionStatusHttp as object)['transactionStatusRoutesApi'] = instance(transactionStatusRoutesApi); }); diff --git a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts index 24767e1f97..9878dbadcb 100644 --- a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts +++ b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts @@ -56,7 +56,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO) as TransferTransaction; + const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO, 1573430400) as TransferTransaction; deepEqual(transferTransaction.recipientAddress, Address.createFromEncoded(transferTransactionDTO.transaction.recipientAddress)); expect(transferTransaction.message.payload).to.be.equal('test-message'); expect(transferTransaction.size).to.be.equal(100); @@ -91,7 +91,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO) as TransferTransaction; + const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO, 1573430400) as TransferTransaction; deepEqual(transferTransaction.recipientAddress, Address.createFromEncoded(transferTransactionDTO.transaction.recipientAddress)); expect(transferTransaction.message.payload).to.be.equal(''); expect(transferTransaction.size).to.be.equal(100); @@ -157,7 +157,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateTransferTransaction = CreateTransactionFromDTO(aggregateTransferTransactionDTO); + const aggregateTransferTransaction = CreateTransactionFromDTO(aggregateTransferTransactionDTO, 1573430400); expect(aggregateTransferTransaction.size).eq(100); ValidateTransaction.validateAggregateTx(aggregateTransferTransaction, aggregateTransferTransactionDTO); }); @@ -192,7 +192,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO) as TransferTransaction; + const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO, 1573430400) as TransferTransaction; deepEqual(transferTransaction.recipientAddress, Address.createFromEncoded(transferTransactionDTO.transaction.recipientAddress)); expect(transferTransaction.message.payload).to.be.equal('test-message'); expect(transferTransaction.deadline.value).to.be.equal(LocalDateTime.MIN); @@ -229,7 +229,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const transferTransaction = CreateTransactionFromDTO(registerNamespaceTransactionDTO); + const transferTransaction = CreateTransactionFromDTO(registerNamespaceTransactionDTO, 1573430400); expect(transferTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(transferTransaction, registerNamespaceTransactionDTO); }); @@ -287,7 +287,10 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO(aggregateNamespaceRegistrationTransactionDTO); + const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO( + aggregateNamespaceRegistrationTransactionDTO, + 1573430400, + ); expect(aggregateNamespaceRegistrationTransaction.size).eq(100); ValidateTransaction.validateAggregateTx( aggregateNamespaceRegistrationTransaction, @@ -323,7 +326,7 @@ describe('CreateTransactionFromDTO', () => { network: 144, }, }; - const transferTransaction = CreateTransactionFromDTO(registerNamespaceTransactionDTO); + const transferTransaction = CreateTransactionFromDTO(registerNamespaceTransactionDTO, 1573430400); expect(transferTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(transferTransaction, registerNamespaceTransactionDTO); }); @@ -381,7 +384,10 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO(aggregateNamespaceRegistrationTransactionDTO); + const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO( + aggregateNamespaceRegistrationTransactionDTO, + 1573430400, + ); expect(aggregateNamespaceRegistrationTransaction.size).eq(100); ValidateTransaction.validateAggregateTx( aggregateNamespaceRegistrationTransaction, @@ -420,7 +426,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const mosaicDefinitionTransaction = CreateTransactionFromDTO(mosaicDefinitionTransactionDTO); + const mosaicDefinitionTransaction = CreateTransactionFromDTO(mosaicDefinitionTransactionDTO, 1573430400); expect(mosaicDefinitionTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(mosaicDefinitionTransaction, mosaicDefinitionTransactionDTO); @@ -480,7 +486,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO(aggregateMosaicDefinitionTransactionDTO); + const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO(aggregateMosaicDefinitionTransactionDTO, 1573430400); expect(aggregateNamespaceRegistrationTransaction.size).eq(100); ValidateTransaction.validateAggregateTx(aggregateNamespaceRegistrationTransaction, aggregateMosaicDefinitionTransactionDTO); }); @@ -513,7 +519,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const mosaicSupplyChangeTransaction = CreateTransactionFromDTO(mosaicSupplyChangeTransactionDTO); + const mosaicSupplyChangeTransaction = CreateTransactionFromDTO(mosaicSupplyChangeTransactionDTO, 1573430400); expect(mosaicSupplyChangeTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(mosaicSupplyChangeTransaction, mosaicSupplyChangeTransactionDTO); }); @@ -570,7 +576,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateMosaicSupplyChangeTransaction = CreateTransactionFromDTO(aggregateMosaicSupplyChangeTransactionDTO); + const aggregateMosaicSupplyChangeTransaction = CreateTransactionFromDTO(aggregateMosaicSupplyChangeTransactionDTO, 1573430400); expect(aggregateMosaicSupplyChangeTransaction.size).eq(100); ValidateTransaction.validateAggregateTx(aggregateMosaicSupplyChangeTransaction, aggregateMosaicSupplyChangeTransactionDTO); @@ -605,7 +611,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const modifyMultisigAccountTransaction = CreateTransactionFromDTO(modifyMultisigAccountTransactionDTO); + const modifyMultisigAccountTransaction = CreateTransactionFromDTO(modifyMultisigAccountTransactionDTO, 1573430400); expect(modifyMultisigAccountTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(modifyMultisigAccountTransaction, modifyMultisigAccountTransactionDTO); }); @@ -665,6 +671,7 @@ describe('CreateTransactionFromDTO', () => { const aggregateMultisigAccountModificationTransaction = CreateTransactionFromDTO( aggregateMultisigAccountModificationTransactionDTO, + 1573430400, ); expect(aggregateMultisigAccountModificationTransaction.size).eq(100); ValidateTransaction.validateAggregateTx( diff --git a/test/model/account/Account.spec.ts b/test/model/account/Account.spec.ts index 5041c6bf36..fb51d25e4c 100644 --- a/test/model/account/Account.spec.ts +++ b/test/model/account/Account.spec.ts @@ -72,14 +72,14 @@ describe('Account', () => { const account2 = Account.generateNewAccount(NetworkType.TEST_NET); const generationHash = 'C422CC3C9257A1568036E1726E64EB5923C8363A13D4344F9E66CD89C8789BC7'; const aliceTransferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account2.address, [sendAmount], PlainMessage.create('payout'), NetworkType.TEST_NET, ); const bobTransferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [backAmount], PlainMessage.create('payout'), @@ -88,7 +88,7 @@ describe('Account', () => { // 01. Alice creates the aggregated tx and sign it. Then payload send to Bob const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [aliceTransferTransaction.toAggregate(account.publicAccount), bobTransferTransaction.toAggregate(account2.publicAccount)], NetworkType.TEST_NET, [], @@ -103,7 +103,7 @@ describe('Account', () => { const cosignatureSignedTransactions = [ new CosignatureSignedTransaction(signedTxBob.parentHash, signedTxBob.signature, signedTxBob.signerPublicKey), ]; - const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload) as AggregateTransaction; + const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload, 1573430400) as AggregateTransaction; const signedTransaction = account.signTransactionGivenSignatures(recreatedTx, cosignatureSignedTransactions, generationHash); diff --git a/test/model/message/EncryptedMessage.spec.ts b/test/model/message/EncryptedMessage.spec.ts index d4057da366..03cfbe3cca 100644 --- a/test/model/message/EncryptedMessage.spec.ts +++ b/test/model/message/EncryptedMessage.spec.ts @@ -63,7 +63,7 @@ describe('EncryptedMessage', () => { it('should return decrepted message reading from message payload', () => { const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), recipient.address, [NetworkCurrencyLocal.createAbsolute(1)], sender.encryptMessage('Testing simple transfer', recipient.publicAccount), diff --git a/test/model/message/PersistentHarvestingDelegationMessage.spec.ts b/test/model/message/PersistentHarvestingDelegationMessage.spec.ts index d1b592e1c6..993a84fb37 100644 --- a/test/model/message/PersistentHarvestingDelegationMessage.spec.ts +++ b/test/model/message/PersistentHarvestingDelegationMessage.spec.ts @@ -82,7 +82,7 @@ describe('PersistentHarvestingDelegationMessage', () => { it('return decrepted message reading from message payload', () => { const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; const tx = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(1573430400), signingPrivateKey, vrfPrivateKey, recipient.publicKey, diff --git a/test/model/transaction/AccountKeyLinkTransaction.spec.ts b/test/model/transaction/AccountKeyLinkTransaction.spec.ts index 4153ea50a0..81a5e57ecd 100644 --- a/test/model/transaction/AccountKeyLinkTransaction.spec.ts +++ b/test/model/transaction/AccountKeyLinkTransaction.spec.ts @@ -34,7 +34,7 @@ describe('AccountKeyLinkTransaction', () => { it('should default maxFee field be set to 0', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -46,7 +46,7 @@ describe('AccountKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -59,7 +59,7 @@ describe('AccountKeyLinkTransaction', () => { it('should create an AccountKeyLinkTransaction object with link action', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -77,7 +77,7 @@ describe('AccountKeyLinkTransaction', () => { it('should create an AccountKeyLinkTransaction object with unlink action', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -96,7 +96,7 @@ describe('AccountKeyLinkTransaction', () => { describe('size', () => { it('should return 161 for AccountKeyLinkTransaction byte size', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -107,7 +107,7 @@ describe('AccountKeyLinkTransaction', () => { it('should create payload size', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -120,7 +120,7 @@ describe('AccountKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -132,7 +132,12 @@ describe('AccountKeyLinkTransaction', () => { }); it('Notify Account', () => { - const tx = AccountKeyLinkTransaction.create(Deadline.create(), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); + const tx = AccountKeyLinkTransaction.create( + Deadline.create(1573430400), + account.publicKey, + LinkAction.Unlink, + NetworkType.MIJIN_TEST, + ); let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; diff --git a/test/model/transaction/AccountMetadataTransaction.spec.ts b/test/model/transaction/AccountMetadataTransaction.spec.ts index 067d5fb6b4..8b5278b9de 100644 --- a/test/model/transaction/AccountMetadataTransaction.spec.ts +++ b/test/model/transaction/AccountMetadataTransaction.spec.ts @@ -37,7 +37,7 @@ describe('AccountMetadataTransaction', () => { it('should default maxFee field be set to 0', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -51,7 +51,7 @@ describe('AccountMetadataTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -66,7 +66,7 @@ describe('AccountMetadataTransaction', () => { it('should create and sign an AccountMetadataTransaction object', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -84,7 +84,7 @@ describe('AccountMetadataTransaction', () => { describe('size', () => { it('should return 174 for AccountMetadataTransaction byte size', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -101,7 +101,7 @@ describe('AccountMetadataTransaction', () => { it('should set payload size', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -118,7 +118,7 @@ describe('AccountMetadataTransaction', () => { it('should create EmbeddedTransactionBuilder', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -137,7 +137,7 @@ describe('AccountMetadataTransaction', () => { it('should resolve alias', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -153,7 +153,7 @@ describe('AccountMetadataTransaction', () => { it('Notify Account', () => { const tx = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, @@ -175,7 +175,7 @@ describe('AccountMetadataTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = AccountMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), 1, diff --git a/test/model/transaction/AccountRestrictionTransaction.spec.ts b/test/model/transaction/AccountRestrictionTransaction.spec.ts index 7aeb6d9761..4933d40486 100644 --- a/test/model/transaction/AccountRestrictionTransaction.spec.ts +++ b/test/model/transaction/AccountRestrictionTransaction.spec.ts @@ -67,7 +67,7 @@ describe('AccountRestrictionTransaction', () => { it('should return 160 for AccountAddressRestrictionTransaction transaction byte size with 1 modification', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -81,7 +81,7 @@ describe('AccountRestrictionTransaction', () => { it('should return 144 for AccountMosaicRestrictionTransaction transaction byte size with 1 modification', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -92,7 +92,7 @@ describe('AccountRestrictionTransaction', () => { it('should set payload size', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -105,7 +105,7 @@ describe('AccountRestrictionTransaction', () => { it('should return 138 for AccountOperationRestrictionTransaction transaction byte size with 1 modification', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -117,7 +117,7 @@ describe('AccountRestrictionTransaction', () => { it('should default maxFee field be set to 0', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -131,7 +131,7 @@ describe('AccountRestrictionTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -146,7 +146,7 @@ describe('AccountRestrictionTransaction', () => { it('should create allow incmoing address restriction transaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -163,7 +163,7 @@ describe('AccountRestrictionTransaction', () => { it('should create mosaic restriction transaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -178,7 +178,7 @@ describe('AccountRestrictionTransaction', () => { it('should create operation restriction transaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -193,7 +193,7 @@ describe('AccountRestrictionTransaction', () => { it('should create outgoing address restriction transaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); let addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowOutgoingAddress, [address], [], @@ -207,7 +207,7 @@ describe('AccountRestrictionTransaction', () => { ); addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.BlockOutgoingAddress, [address], [], @@ -224,7 +224,7 @@ describe('AccountRestrictionTransaction', () => { it('should create outgoing operation restriction transaction', () => { const operation = TransactionType.ADDRESS_ALIAS; let operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -236,7 +236,7 @@ describe('AccountRestrictionTransaction', () => { expect(signedTransaction.payload.substring(256, signedTransaction.payload.length)).to.be.equal('04400100000000004E42'); operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), OperationRestrictionFlag.BlockOutgoingTransactionType, [operation], [], @@ -251,7 +251,7 @@ describe('AccountRestrictionTransaction', () => { it('Notify Account', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowOutgoingAddress, [address], [], @@ -267,7 +267,7 @@ describe('AccountRestrictionTransaction', () => { expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; const txDeletion = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowOutgoingAddress, [], [address], @@ -287,7 +287,7 @@ describe('AccountRestrictionTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowOutgoingAddress, [alias], [], @@ -303,7 +303,7 @@ describe('AccountRestrictionTransaction', () => { expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; const txDeletion = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(), + Deadline.create(1573430400), AddressRestrictionFlag.AllowOutgoingAddress, [], [alias], diff --git a/test/model/transaction/AddressAliasTransaction.spec.ts b/test/model/transaction/AddressAliasTransaction.spec.ts index 8a6bc3b288..6a379eb9c2 100644 --- a/test/model/transaction/AddressAliasTransaction.spec.ts +++ b/test/model/transaction/AddressAliasTransaction.spec.ts @@ -38,7 +38,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -53,7 +53,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -69,7 +69,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -92,7 +92,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AliasTransaction.createForAddress( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -116,7 +116,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -130,7 +130,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -146,7 +146,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, address, @@ -158,7 +158,13 @@ describe('AddressAliasTransaction', () => { it('Notify Account', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); - const tx = AddressAliasTransaction.create(Deadline.create(), AliasAction.Link, namespaceId, address, NetworkType.MIJIN_TEST); + const tx = AddressAliasTransaction.create( + Deadline.create(1573430400), + AliasAction.Link, + namespaceId, + address, + NetworkType.MIJIN_TEST, + ); let canNotify = tx.shouldNotifyAccount(address); expect(canNotify).to.be.true; diff --git a/test/model/transaction/AggregateTransaction.spec.ts b/test/model/transaction/AggregateTransaction.spec.ts index 49df7dbcdb..e02720aaa8 100644 --- a/test/model/transaction/AggregateTransaction.spec.ts +++ b/test/model/transaction/AggregateTransaction.spec.ts @@ -80,7 +80,7 @@ describe('AggregateTransaction', () => { it('should default maxFee field be set to 0', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -88,7 +88,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -100,7 +100,7 @@ describe('AggregateTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -108,7 +108,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -121,7 +121,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -129,7 +129,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -144,14 +144,14 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with NamespaceRegistrationTransaction', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [registerNamespaceTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -168,7 +168,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -178,7 +178,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [mosaicDefinitionTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -196,7 +196,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -204,7 +204,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [mosaicSupplyChangeTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -221,7 +221,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [ @@ -232,7 +232,7 @@ describe('AggregateTransaction', () => { NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [modifyMultisigAccountTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -249,14 +249,14 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with different cosignatories', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(MultisigAccount.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -277,7 +277,7 @@ describe('AggregateTransaction', () => { it('should createBonded an AggregateTransaction object with TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -285,7 +285,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(2, ChronoUnit.MINUTES), + Deadline.create(1573430400, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -357,7 +357,7 @@ describe('AggregateTransaction', () => { }, }; - const aggregateTransaction = CreateTransactionFromDTO(aggregateTransactionDTO) as AggregateTransaction; + const aggregateTransaction = CreateTransactionFromDTO(aggregateTransactionDTO, 1573430400) as AggregateTransaction; expect( aggregateTransaction.signedByAccount( PublicAccount.createFromPublicKey( @@ -391,20 +391,20 @@ describe('AggregateTransaction', () => { }); it("should have type 0x4141 when it's complete", () => { - const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); expect(aggregateTransaction.type).to.be.equal(0x4141); }); it("should have type 0x4241 when it's bonded", () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST); expect(aggregateTransaction.type).to.be.equal(0x4241); }); it('should throw exception when adding an aggregated transaction as inner transaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -412,7 +412,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -420,7 +420,7 @@ describe('AggregateTransaction', () => { expect(() => { AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [aggregateTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -437,21 +437,21 @@ describe('AggregateTransaction', () => { const accountCarol = Cosignatory2Account; const AtoBTx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), accountBob.address, [], PlainMessage.create('a to b'), NetworkType.MIJIN_TEST, ); const BtoATx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), accountAlice.address, [], PlainMessage.create('b to a'), NetworkType.MIJIN_TEST, ); const CtoATx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), accountAlice.address, [], PlainMessage.create('c to a'), @@ -460,7 +460,7 @@ describe('AggregateTransaction', () => { // 01. Alice creates the aggregated tx and sign it, Then payload send to Bob & Carol const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [ AtoBTx.toAggregate(accountAlice.publicAccount), BtoATx.toAggregate(accountBob.publicAccount), @@ -486,7 +486,7 @@ describe('AggregateTransaction', () => { new CosignatureSignedTransaction(signedTxCarol.parentHash, signedTxCarol.signature, signedTxCarol.signerPublicKey), ]; - const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload) as AggregateTransaction; + const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload, 1573430400) as AggregateTransaction; const signedTransaction = recreatedTx.signTransactionGivenSignatures(accountAlice, cosignatureSignedTransactions, generationHash); @@ -507,21 +507,21 @@ describe('AggregateTransaction', () => { it('Should be able to add innertransactions to current aggregate tx', () => { const transferTx1 = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [], PlainMessage.create('a to b'), NetworkType.MIJIN_TEST, ); const transferTx2 = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [], PlainMessage.create('b to a'), NetworkType.MIJIN_TEST, ); let aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTx1.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -538,14 +538,14 @@ describe('AggregateTransaction', () => { it('Should be able to add cosignatures to current aggregate tx', () => { const transferTx1 = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [], PlainMessage.create('a to b'), NetworkType.MIJIN_TEST, ); let aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTx1.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -570,14 +570,14 @@ describe('AggregateTransaction', () => { describe('size', () => { it('should return 268 for AggregateTransaction byte size with TransferTransaction with 1 mosaic and message NEM', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(1573430400), [transaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -587,14 +587,14 @@ describe('AggregateTransaction', () => { }); it('should set payload size', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(1573430400), [transaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -607,7 +607,7 @@ describe('AggregateTransaction', () => { it('Test set maxFee using multiplier', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -615,7 +615,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -628,7 +628,7 @@ describe('AggregateTransaction', () => { it('Test set maxFee using multiplier', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -637,7 +637,7 @@ describe('AggregateTransaction', () => { expect(() => { AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -649,7 +649,7 @@ describe('AggregateTransaction', () => { const transferTransaction = new TransferTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), UInt64.fromUint(0), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], @@ -663,7 +663,7 @@ describe('AggregateTransaction', () => { NetworkType.MIJIN_TEST, TransactionType.AGGREGATE_COMPLETE, 1, - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), UInt64.fromUint(100), [transferTransaction.toAggregate(account.publicAccount)], [], @@ -683,14 +683,14 @@ describe('AggregateTransaction', () => { it('Notify Account', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account.address, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const tx = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -707,14 +707,14 @@ describe('AggregateTransaction', () => { it('Notify Account with alias', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const tx = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], diff --git a/test/model/transaction/CosignatureTransaction.spec.ts b/test/model/transaction/CosignatureTransaction.spec.ts index 116dd6be93..efc59dc512 100644 --- a/test/model/transaction/CosignatureTransaction.spec.ts +++ b/test/model/transaction/CosignatureTransaction.spec.ts @@ -89,7 +89,7 @@ describe('CosignatureTransaction', () => { }; it('should createComplete an TransferTransaction object and sign it', () => { - const aggregateTransferTransaction = CreateTransactionFromDTO(aggregateTransferTransactionDTO); + const aggregateTransferTransaction = CreateTransactionFromDTO(aggregateTransferTransactionDTO, 1573430400); const cosignatureTransaction = CosignatureTransaction.create(aggregateTransferTransaction as AggregateTransaction); @@ -106,7 +106,7 @@ describe('CosignatureTransaction', () => { it('should sign a transaction with transaction payload', () => { const txPayload = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [], PlainMessage.create('a to b'), @@ -122,7 +122,7 @@ describe('CosignatureTransaction', () => { it('should sign a transaction with provided transactionHash', () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [], PlainMessage.create('a to b'), @@ -130,7 +130,7 @@ describe('CosignatureTransaction', () => { ); const aggregate = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -149,7 +149,7 @@ describe('CosignatureTransaction', () => { it('should sign a transaction to throw', () => { const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, [], PlainMessage.create('a to b'), @@ -157,7 +157,7 @@ describe('CosignatureTransaction', () => { ); const aggregate = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -178,7 +178,7 @@ describe('CosignatureTransaction', () => { merkleComponentHash: '81E5E7AE49998802DABC816EC10158D3A7879702FF29084C2C992CD1289877A7', }, }); - const aggregate = CreateTransactionFromDTO(aggregateTransferTransactionDTO) as AggregateTransaction; + const aggregate = CreateTransactionFromDTO(aggregateTransferTransactionDTO, 1573430400) as AggregateTransaction; const cosignTx = new CosignatureTransaction(aggregate); expect(() => { cosignTx.signWith(account); diff --git a/test/model/transaction/Deadline.spec.ts b/test/model/transaction/Deadline.spec.ts index b6bb7f93be..c5788f52cd 100644 --- a/test/model/transaction/Deadline.spec.ts +++ b/test/model/transaction/Deadline.spec.ts @@ -20,7 +20,7 @@ import { Deadline } from '../../../src/model/transaction/Deadline'; describe('Deadline', () => { it('should createComplete timestamp today', () => { - const deadline = Deadline.create(); + const deadline = Deadline.create(1573430400); // avoid SYSTEM and UTC differences const networkTimeStamp = new Date().getTime(); @@ -34,18 +34,18 @@ describe('Deadline', () => { it('should throw error deadline smaller than timeStamp', () => { expect(() => { - Deadline.create(-3); + Deadline.create(1573430400, -3); }).to.throw(Error); }); it('should throw error deadline greater than 24h', () => { expect(() => { - Deadline.create(2, ChronoUnit.DAYS); + Deadline.create(1573430400, 2, ChronoUnit.DAYS); }).to.throw(Error); }); it('should createComplete date with Deadline array', () => { - const deadline = Deadline.createFromDTO('51110867862'); + const deadline = Deadline.createFromDTO('51110867862', 1573430400); expect(deadline.toDTO()[0]).to.be.equal(3866227606); expect(deadline.toDTO()[1]).to.be.equal(11); @@ -57,7 +57,7 @@ describe('Deadline', () => { }); it('make sure epochAdjustment is correct', () => { - const epochAdjustment = new Date(Deadline.timestampNemesisBlock * 1000); + const epochAdjustment = new Date(1573430400 * 1000); expect(epochAdjustment.getUTCFullYear()).to.be.equal(2019); expect(epochAdjustment.getUTCMonth() + 1).to.be.equal(11); diff --git a/test/model/transaction/HashLockTransaction.spec.ts b/test/model/transaction/HashLockTransaction.spec.ts index b13bc6b8d7..c28e33cee9 100644 --- a/test/model/transaction/HashLockTransaction.spec.ts +++ b/test/model/transaction/HashLockTransaction.spec.ts @@ -27,10 +27,10 @@ describe('HashLockTransaction', () => { const account = TestingAccount; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; it('creation with an aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const transaction = HashLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -43,11 +43,11 @@ describe('HashLockTransaction', () => { }); it('should throw exception if it is not a aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); expect(() => { HashLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -57,10 +57,10 @@ describe('HashLockTransaction', () => { }); it('Notify Account', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const tx = HashLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, diff --git a/test/model/transaction/LockFundsTransaction.spec.ts b/test/model/transaction/LockFundsTransaction.spec.ts index 408ea816e9..65ce76b186 100644 --- a/test/model/transaction/LockFundsTransaction.spec.ts +++ b/test/model/transaction/LockFundsTransaction.spec.ts @@ -54,10 +54,10 @@ describe('LockFundsTransaction', () => { }); it('should default maxFee field be set to 0', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -70,10 +70,10 @@ describe('LockFundsTransaction', () => { }); it('should filled maxFee override transaction maxFee', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -86,10 +86,10 @@ describe('LockFundsTransaction', () => { }); it('creation with an aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const transaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -101,11 +101,11 @@ describe('LockFundsTransaction', () => { }); it('should throw exception if it is not a aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); expect(() => { LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -115,10 +115,10 @@ describe('LockFundsTransaction', () => { }); it('should create and sign LockFundsTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -133,10 +133,10 @@ describe('LockFundsTransaction', () => { describe('size', () => { it('should return 184 for LockFundsTransaction transaction byte size', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -146,10 +146,10 @@ describe('LockFundsTransaction', () => { }); it('should set payload size', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -161,10 +161,10 @@ describe('LockFundsTransaction', () => { }); it('Test set maxFee using multiplier', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -177,12 +177,12 @@ describe('LockFundsTransaction', () => { }); it('Test resolveAlias can resolve', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const transaction = new LockFundsTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), UInt64.fromUint(0), new Mosaic(unresolvedMosaicId, UInt64.fromUint(1)), UInt64.fromUint(10), @@ -199,10 +199,10 @@ describe('LockFundsTransaction', () => { }); it('Notify Account', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const tx = LockFundsTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, diff --git a/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts b/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts index 0c97a7a916..36eb820bc6 100644 --- a/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts +++ b/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts @@ -59,7 +59,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('should createComplete an MosaicAddressRestrictionTransaction object and sign', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, UInt64.fromUint(1), account.address, @@ -83,7 +83,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('should createComplete an MosaicAddressRestrictionTransaction use mosaic alias', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), namespacId, UInt64.fromUint(1), account.address, @@ -108,7 +108,7 @@ describe('MosaicAddressRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, UInt64.fromUint(1), namespacId, @@ -131,7 +131,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('should format targetAddress payload with 8 bytes binary namespaceId - targetAddressToString', () => { const transaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(1), new NamespaceId('nem.owner'), @@ -152,7 +152,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('Test set maxFee using multiplier', () => { const transaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(1), new NamespaceId('nem.owner'), @@ -170,7 +170,7 @@ describe('MosaicAddressRestrictionTransaction', () => { const transaction = new MosaicAddressRestrictionTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), UInt64.fromUint(0), unresolvedMosaicId, UInt64.fromUint(8), diff --git a/test/model/transaction/MosaicAliasTransaction.spec.ts b/test/model/transaction/MosaicAliasTransaction.spec.ts index fbf2586a6e..b130a5d59f 100644 --- a/test/model/transaction/MosaicAliasTransaction.spec.ts +++ b/test/model/transaction/MosaicAliasTransaction.spec.ts @@ -41,7 +41,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -56,7 +56,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -72,7 +72,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -96,7 +96,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = AliasTransaction.createForMosaic( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -121,7 +121,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -134,7 +134,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -150,7 +150,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -166,7 +166,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -180,7 +180,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(), + Deadline.create(1573430400), AliasAction.Link, namespaceId, mosaicId, @@ -199,7 +199,13 @@ describe('MosaicAliasTransaction', () => { it('Notify Account', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); - const tx = MosaicAliasTransaction.create(Deadline.create(), AliasAction.Link, namespaceId, mosaicId, NetworkType.MIJIN_TEST); + const tx = MosaicAliasTransaction.create( + Deadline.create(1573430400), + AliasAction.Link, + namespaceId, + mosaicId, + NetworkType.MIJIN_TEST, + ); Object.assign(tx, { signer: account.publicAccount }); expect(tx.shouldNotifyAccount(account.address)).to.be.true; diff --git a/test/model/transaction/MosaicDefinitionTransaction.spec.ts b/test/model/transaction/MosaicDefinitionTransaction.spec.ts index 3c8f95ad40..997a6a96d6 100644 --- a/test/model/transaction/MosaicDefinitionTransaction.spec.ts +++ b/test/model/transaction/MosaicDefinitionTransaction.spec.ts @@ -35,7 +35,7 @@ describe('MosaicDefinitionTransaction', () => { it('should default maxFee field be set to 0', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -50,7 +50,7 @@ describe('MosaicDefinitionTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -66,7 +66,7 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it with flags 7', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -91,7 +91,7 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it with flags 0', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -117,7 +117,7 @@ describe('MosaicDefinitionTransaction', () => { describe('size', () => { it('should return 150 for MosaicDefinition transaction byte size', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, false), @@ -130,7 +130,7 @@ describe('MosaicDefinitionTransaction', () => { }); it('should set payload size', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, false), @@ -146,7 +146,7 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -169,7 +169,7 @@ describe('MosaicDefinitionTransaction', () => { it('Test set maxFee using multiplier', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -185,7 +185,7 @@ describe('MosaicDefinitionTransaction', () => { it('Notify Account', () => { const tx = MosaicDefinitionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), diff --git a/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts b/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts index 22c0d3abef..302ece8187 100644 --- a/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts +++ b/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts @@ -55,7 +55,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -85,7 +85,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), namespacId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -119,7 +119,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -149,7 +149,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -169,7 +169,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = new MosaicGlobalRestrictionTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), UInt64.fromUint(0), unresolvedMosaicId, unresolvedMosaicId, @@ -195,7 +195,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const tx = MosaicGlobalRestrictionTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), diff --git a/test/model/transaction/MosaicMetadataTransaction.spec.ts b/test/model/transaction/MosaicMetadataTransaction.spec.ts index 9be4a08330..330a96f6e4 100644 --- a/test/model/transaction/MosaicMetadataTransaction.spec.ts +++ b/test/model/transaction/MosaicMetadataTransaction.spec.ts @@ -55,7 +55,7 @@ describe('MosaicMetadataTransaction', () => { it('should default maxFee field be set to 0', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -70,7 +70,7 @@ describe('MosaicMetadataTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -86,7 +86,7 @@ describe('MosaicMetadataTransaction', () => { it('should create and sign an MosaicMetadataTransaction object', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -105,7 +105,7 @@ describe('MosaicMetadataTransaction', () => { it('should create and sign an MosaicMetadataTransaction object using alias', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), namespacId, @@ -124,7 +124,7 @@ describe('MosaicMetadataTransaction', () => { describe('size', () => { it('should return 182 for MosaicMetadataTransaction byte size', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -138,7 +138,7 @@ describe('MosaicMetadataTransaction', () => { it('should set payload size', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -154,7 +154,7 @@ describe('MosaicMetadataTransaction', () => { it('Test set maxFee using multiplier', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -172,7 +172,7 @@ describe('MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = new MosaicMetadataTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), UInt64.fromUint(0), account.address, UInt64.fromUint(1000), @@ -192,7 +192,7 @@ describe('MosaicMetadataTransaction', () => { it('should create EmbeddedTransactionBuilder', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -212,7 +212,7 @@ describe('MosaicMetadataTransaction', () => { it('Notify Account', () => { const tx = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -234,7 +234,7 @@ describe('MosaicMetadataTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = MosaicMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), alias, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), diff --git a/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts b/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts index f24d4c1a9b..7c08c73a79 100644 --- a/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts +++ b/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts @@ -54,7 +54,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should default maxFee field be set to 0', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -68,7 +68,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -83,7 +83,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should createComplete an MosaicSupplyChangeTransaction object and sign it', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -107,7 +107,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should return 145 for MosaicSupplyChange transaction byte size', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -119,7 +119,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should set payload size', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -134,7 +134,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('Test set maxFee using multiplier', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -149,7 +149,7 @@ describe('MosaicSupplyChangeTransaction', () => { const mosaicSupplyChangeTransaction = new MosaicSupplyChangeTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), UInt64.fromUint(0), unresolvedMosaicId, MosaicSupplyChangeAction.Increase, @@ -167,7 +167,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('Notify Account', () => { const tx = MosaicSupplyChangeTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new MosaicId([2262289484, 3405110546]), MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), diff --git a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts index f6db0fbd44..22779d36cf 100644 --- a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts +++ b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts @@ -42,7 +42,7 @@ describe('MultisigAccountModificationTransaction', () => { it('should default maxFee field be set to 0', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [address1, address2], @@ -56,7 +56,7 @@ describe('MultisigAccountModificationTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [address1, address2], @@ -71,7 +71,7 @@ describe('MultisigAccountModificationTransaction', () => { it('should createComplete an MultisigAccountModificationTransaction object and sign it', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 2, 1, [address1, address2], @@ -96,7 +96,7 @@ describe('MultisigAccountModificationTransaction', () => { describe('size', () => { it('should return 160 for MultisigAccountModificationTransaction transaction byte size with 1 modification', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 1, 1, [address1], @@ -110,7 +110,7 @@ describe('MultisigAccountModificationTransaction', () => { }); it('should set payload size', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 1, 1, [address1], @@ -127,7 +127,7 @@ describe('MultisigAccountModificationTransaction', () => { it('Test set maxFee using multiplier', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(), + Deadline.create(1573430400), 1, 1, [address1], @@ -141,7 +141,14 @@ describe('MultisigAccountModificationTransaction', () => { }); it('Notify Account', () => { - const txAddition = MultisigAccountModificationTransaction.create(Deadline.create(), 1, 1, [address1], [], NetworkType.MIJIN_TEST); + const txAddition = MultisigAccountModificationTransaction.create( + Deadline.create(1573430400), + 1, + 1, + [address1], + [], + NetworkType.MIJIN_TEST, + ); let canNotify = txAddition.shouldNotifyAccount(address1, []); expect(canNotify).to.be.true; @@ -152,7 +159,14 @@ describe('MultisigAccountModificationTransaction', () => { Object.assign(txAddition, { signer: account.publicAccount }); expect(txAddition.shouldNotifyAccount(account.address, [])).to.be.true; - const txDeletion = MultisigAccountModificationTransaction.create(Deadline.create(), 1, 1, [], [address1], NetworkType.MIJIN_TEST); + const txDeletion = MultisigAccountModificationTransaction.create( + Deadline.create(1573430400), + 1, + 1, + [], + [address1], + NetworkType.MIJIN_TEST, + ); let canNotifyDeletion = txDeletion.shouldNotifyAccount(address1, []); expect(canNotifyDeletion).to.be.true; @@ -167,7 +181,14 @@ describe('MultisigAccountModificationTransaction', () => { it('Notify Account with alias', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); - const txAddition = MultisigAccountModificationTransaction.create(Deadline.create(), 1, 1, [alias], [], NetworkType.MIJIN_TEST); + const txAddition = MultisigAccountModificationTransaction.create( + Deadline.create(1573430400), + 1, + 1, + [alias], + [], + NetworkType.MIJIN_TEST, + ); let canNotify = txAddition.shouldNotifyAccount(address1, [alias]); expect(canNotify).to.be.true; @@ -181,7 +202,14 @@ describe('MultisigAccountModificationTransaction', () => { Object.assign(txAddition, { signer: account.publicAccount }); expect(txAddition.shouldNotifyAccount(account.address, [])).to.be.true; - const txDeletion = MultisigAccountModificationTransaction.create(Deadline.create(), 1, 1, [], [alias], NetworkType.MIJIN_TEST); + const txDeletion = MultisigAccountModificationTransaction.create( + Deadline.create(1573430400), + 1, + 1, + [], + [alias], + NetworkType.MIJIN_TEST, + ); let canNotifyDeletion = txDeletion.shouldNotifyAccount(address1, [alias]); expect(canNotifyDeletion).to.be.true; diff --git a/test/model/transaction/NamespaceMetadataTransaction.spec.ts b/test/model/transaction/NamespaceMetadataTransaction.spec.ts index bfdce1a49a..040dd106da 100644 --- a/test/model/transaction/NamespaceMetadataTransaction.spec.ts +++ b/test/model/transaction/NamespaceMetadataTransaction.spec.ts @@ -37,7 +37,7 @@ describe('NamespaceMetadataTransaction', () => { it('should default maxFee field be set to 0', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -52,7 +52,7 @@ describe('NamespaceMetadataTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -68,7 +68,7 @@ describe('NamespaceMetadataTransaction', () => { it('should create and sign an NamespaceMetadataTransaction object', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -87,7 +87,7 @@ describe('NamespaceMetadataTransaction', () => { describe('size', () => { it('should return 182 for NamespaceMetadataTransaction byte size', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -101,7 +101,7 @@ describe('NamespaceMetadataTransaction', () => { it('should set payload size', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -117,7 +117,7 @@ describe('NamespaceMetadataTransaction', () => { it('Test set maxFee using multiplier', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -133,7 +133,7 @@ describe('NamespaceMetadataTransaction', () => { it('should create EmbeddedTransactionBuilder', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -153,7 +153,7 @@ describe('NamespaceMetadataTransaction', () => { it('should resolve alias', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -169,7 +169,7 @@ describe('NamespaceMetadataTransaction', () => { it('Notify Account', () => { const tx = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -191,7 +191,7 @@ describe('NamespaceMetadataTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = NamespaceMetadataTransaction.create( - Deadline.create(), + Deadline.create(1573430400), alias, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), diff --git a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts index ffb4b927fa..e322fdc275 100644 --- a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts +++ b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts @@ -33,7 +33,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should default maxFee field be set to 0', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -45,7 +45,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -58,7 +58,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should createComplete an root NamespaceRegistrationTransaction object and sign it', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -76,7 +76,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should createComplete an sub NamespaceRegistrationTransaction object and sign it', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -91,7 +91,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should createComplete an sub NamespaceRegistrationTransaction object and sign it - ParentId', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', new NamespaceId([929036875, 2226345261]), NetworkType.MIJIN_TEST, @@ -107,7 +107,7 @@ describe('NamespaceRegistrationTransaction', () => { describe('size', () => { it('should return 165 for NamespaceRegistrationTransaction with name of 19 bytes', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -117,7 +117,7 @@ describe('NamespaceRegistrationTransaction', () => { }); it('should set payload size', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -130,7 +130,7 @@ describe('NamespaceRegistrationTransaction', () => { it('Test set maxFee using multiplier', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -143,7 +143,7 @@ describe('NamespaceRegistrationTransaction', () => { it('Notify Account', () => { const tx = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(), + Deadline.create(1573430400), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, diff --git a/test/model/transaction/NodeKeyLinkTransaction.spec.ts b/test/model/transaction/NodeKeyLinkTransaction.spec.ts index ae3cb3efef..406bdc5d0a 100644 --- a/test/model/transaction/NodeKeyLinkTransaction.spec.ts +++ b/test/model/transaction/NodeKeyLinkTransaction.spec.ts @@ -34,7 +34,7 @@ describe('NodeKeyLinkTransaction', () => { it('should default maxFee field be set to 0', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -46,7 +46,7 @@ describe('NodeKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -59,7 +59,7 @@ describe('NodeKeyLinkTransaction', () => { it('should create an NodeKeyLinkTransaction object with link action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -77,7 +77,7 @@ describe('NodeKeyLinkTransaction', () => { it('should create an NodeKeyLinkTransaction object with unlink action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -96,7 +96,7 @@ describe('NodeKeyLinkTransaction', () => { describe('size', () => { it('should return 161 for NodeKeyLinkTransaction byte size', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -106,7 +106,7 @@ describe('NodeKeyLinkTransaction', () => { }); it('should set payload size', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -119,7 +119,7 @@ describe('NodeKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -131,7 +131,7 @@ describe('NodeKeyLinkTransaction', () => { }); it('Notify Account', () => { - const tx = NodeKeyLinkTransaction.create(Deadline.create(), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); + const tx = NodeKeyLinkTransaction.create(Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; diff --git a/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts b/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts index ee1333fa21..1ee2de457e 100644 --- a/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts +++ b/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts @@ -38,7 +38,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should default maxFee field be set to 0', () => { const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(1573430400), delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, @@ -51,7 +51,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(1573430400), delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, @@ -65,7 +65,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should createComplete an persistentDelegationRequestTransaction object and sign it', () => { const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(1573430400), delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, @@ -92,7 +92,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should throw exception with invalid harvester publicKey (message)', () => { expect(() => { PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(), + Deadline.create(1573430400), 'abc', vrfPrivateKey, recipientPublicKey, diff --git a/test/model/transaction/SecretLockTransaction.spec.ts b/test/model/transaction/SecretLockTransaction.spec.ts index c39ce7c891..73fbfa00b7 100644 --- a/test/model/transaction/SecretLockTransaction.spec.ts +++ b/test/model/transaction/SecretLockTransaction.spec.ts @@ -65,7 +65,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -82,7 +82,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -100,7 +100,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -120,7 +120,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -139,7 +139,7 @@ describe('SecretLockTransaction', () => { expect(() => { const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -154,7 +154,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -174,7 +174,7 @@ describe('SecretLockTransaction', () => { expect(() => { const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -188,7 +188,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -208,7 +208,7 @@ describe('SecretLockTransaction', () => { expect(() => { const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -224,7 +224,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -240,7 +240,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -258,7 +258,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -278,7 +278,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -296,7 +296,7 @@ describe('SecretLockTransaction', () => { const secretLockTransaction = new SecretLockTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), UInt64.fromUint(0), new Mosaic(unresolvedMosaicId, UInt64.fromUint(1)), UInt64.fromUint(100), @@ -320,7 +320,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -342,7 +342,7 @@ describe('SecretLockTransaction', () => { const namespaceId = new NamespaceId('test'); const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const canNotify = SecretLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, diff --git a/test/model/transaction/SecretProofTransaction.spec.ts b/test/model/transaction/SecretProofTransaction.spec.ts index c2838b385e..847a77afdf 100644 --- a/test/model/transaction/SecretProofTransaction.spec.ts +++ b/test/model/transaction/SecretProofTransaction.spec.ts @@ -56,7 +56,7 @@ describe('SecretProofTransaction', () => { it('should default maxFee field be set to 0', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -71,7 +71,7 @@ describe('SecretProofTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -87,7 +87,7 @@ describe('SecretProofTransaction', () => { it('should be created with LockHashAlgorithm: Op_Sha3_256 secret', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -103,7 +103,7 @@ describe('SecretProofTransaction', () => { expect(() => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, 'non valid hash', account.address, @@ -116,7 +116,7 @@ describe('SecretProofTransaction', () => { it('should be created with LockHashAlgorithm: Op_Hash_160 secret', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Hash_160, CryptoJS.RIPEMD160(CryptoJS.SHA256(proof).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex), account.address, @@ -132,7 +132,7 @@ describe('SecretProofTransaction', () => { expect(() => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Hash_160, 'non valid hash', account.address, @@ -145,7 +145,7 @@ describe('SecretProofTransaction', () => { it('should be created with LockHashAlgorithm: Op_Hash_256 secret', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Hash_256, CryptoJS.SHA256(CryptoJS.SHA256(proof).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex), account.address, @@ -161,7 +161,7 @@ describe('SecretProofTransaction', () => { expect(() => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Hash_256, 'non valid hash', account.address, @@ -175,7 +175,7 @@ describe('SecretProofTransaction', () => { it('should return 219 for SecretProofTransaction with proof and secret both 32 bytes', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Hash_256, CryptoJS.SHA256(CryptoJS.SHA256(proof).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex), account.address, @@ -190,7 +190,7 @@ describe('SecretProofTransaction', () => { it('should create and sign SecretProof Transaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -209,7 +209,7 @@ describe('SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), recipientAddress, @@ -225,7 +225,7 @@ describe('SecretProofTransaction', () => { it('Test set maxFee using multiplier', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -242,7 +242,7 @@ describe('SecretProofTransaction', () => { const transferTransaction = new SecretProofTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), @@ -264,7 +264,7 @@ describe('SecretProofTransaction', () => { const secretProofTransaction = new SecretProofTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), @@ -286,7 +286,7 @@ describe('SecretProofTransaction', () => { it('should return secret bytes', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -301,7 +301,7 @@ describe('SecretProofTransaction', () => { it('Notify Account', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const tx = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -322,7 +322,7 @@ describe('SecretProofTransaction', () => { const namespaceId = new NamespaceId('test'); const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const canNotify = SecretProofTransaction.create( - Deadline.create(), + Deadline.create(1573430400), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, diff --git a/test/model/transaction/Transaction.spec.ts b/test/model/transaction/Transaction.spec.ts index 006d0c0688..2bca23b94b 100644 --- a/test/model/transaction/Transaction.spec.ts +++ b/test/model/transaction/Transaction.spec.ts @@ -76,7 +76,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, @@ -92,7 +92,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, @@ -106,7 +106,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, @@ -122,7 +122,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, @@ -138,7 +138,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, @@ -154,14 +154,14 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, new TransactionInfo(UInt64.fromUint(100), 1, 'id_hash', 'hash', 'hash'), ); expect(() => { - transaction.reapplyGiven(Deadline.create()); + transaction.reapplyGiven(Deadline.create(1573430400)); }).to.throws("an Announced transaction can't be modified"); }); it('should return a new transaction', () => { @@ -169,13 +169,13 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, ); - const newTransaction = transaction.reapplyGiven(Deadline.create()); + const newTransaction = transaction.reapplyGiven(Deadline.create(1573430400)); expect(newTransaction).to.not.equal(transaction); }); it('should overide deadline properly', () => { @@ -183,13 +183,13 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, ); - const newDeadline = Deadline.create(3); + const newDeadline = Deadline.create(1573430400, 3); const newTransaction = transaction.reapplyGiven(newDeadline); const equal = newTransaction.deadline.value.equals(transaction.deadline.value); const after = newTransaction.deadline.value.isAfter(transaction.deadline.value); @@ -205,14 +205,14 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -227,7 +227,7 @@ describe('Transaction', () => { describe('Transaction serialize', () => { it('Should return serialized payload', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -247,7 +247,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(), + Deadline.create(1573430400), UInt64.fromUint(0), undefined, undefined, @@ -378,7 +378,7 @@ describe('Transaction', () => { it('is signed', () => { let tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -387,7 +387,7 @@ describe('Transaction', () => { expect(tx.isSigned(account.address)).to.be.false; const signed = tx.signWith(account, '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'); - tx = TransactionMapping.createFromPayload(signed.payload) as Transaction; + tx = TransactionMapping.createFromPayload(signed.payload, 1573430400) as Transaction; expect((tx as Transaction).isSigned(account.address)).to.be.true; expect((tx as Transaction).isSigned(Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'))).to.be.false; }); diff --git a/test/model/transaction/TransactionStatus.spec.ts b/test/model/transaction/TransactionStatus.spec.ts index 9591d844f2..19edfc0716 100644 --- a/test/model/transaction/TransactionStatus.spec.ts +++ b/test/model/transaction/TransactionStatus.spec.ts @@ -25,7 +25,7 @@ import { UInt64 } from '../../../src/model/UInt64'; describe('TransactionStatus', () => { it('should createComplete TransactionStatus object', () => { const transactionStatusDTO = { - deadline: Deadline.createFromDTO('1'), + deadline: Deadline.createFromDTO('1', 1573430400), group: TransactionGroupEnum.Confirmed, hash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', height: new UInt64([1, 0]), diff --git a/test/model/transaction/TransactionStatusError.spec.ts b/test/model/transaction/TransactionStatusError.spec.ts index 62f4daa941..17802b42df 100644 --- a/test/model/transaction/TransactionStatusError.spec.ts +++ b/test/model/transaction/TransactionStatusError.spec.ts @@ -33,7 +33,7 @@ describe('TransactionStatusError', () => { statusInfoErrorDTO.address, statusInfoErrorDTO.hash, statusInfoErrorDTO.code, - Deadline.createFromDTO(statusInfoErrorDTO.deadline), + Deadline.createFromDTO(statusInfoErrorDTO.deadline, 1573430400), ); expect(transactionStatusError.address).to.be.equal(statusInfoErrorDTO.address); diff --git a/test/model/transaction/TransferTransaction.spec.ts b/test/model/transaction/TransferTransaction.spec.ts index a3968bcfa6..d90d0508b9 100644 --- a/test/model/transaction/TransferTransaction.spec.ts +++ b/test/model/transaction/TransferTransaction.spec.ts @@ -73,7 +73,7 @@ describe('TransferTransaction', () => { it('should default maxFee field be set to 0', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -86,7 +86,7 @@ describe('TransferTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -100,7 +100,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object and sign it without mosaics', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -121,7 +121,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object with empty message', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], EmptyMessage, @@ -142,7 +142,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object and sign it with mosaics', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -165,7 +165,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object with NamespaceId recipientAddress', () => { const addressAlias = new NamespaceId('nem.owner'); const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), addressAlias, [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -188,7 +188,7 @@ describe('TransferTransaction', () => { it('should format TransferTransaction payload with 24 bytes binary address', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -205,7 +205,7 @@ describe('TransferTransaction', () => { it('should format TransferTransaction payload with 8 bytes binary namespaceId', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new NamespaceId('nem.owner'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -223,7 +223,7 @@ describe('TransferTransaction', () => { describe('size', () => { it('should return 180 for TransferTransaction with 1 mosaic and message NEM', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), @@ -235,7 +235,7 @@ describe('TransferTransaction', () => { it('should set payloadsize', () => { const transaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), @@ -249,7 +249,7 @@ describe('TransferTransaction', () => { it('should create TransferTransaction and sign using catbuffer-typescript', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -271,7 +271,7 @@ describe('TransferTransaction', () => { it('should create Transafer transaction for persistent harvesting delegation request transaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PersistentHarvestingDelegationMessage.create(delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, NetworkType.MIJIN_TEST), @@ -283,7 +283,7 @@ describe('TransferTransaction', () => { it('should createComplete an persistentDelegationRequestTransaction object and sign it', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PersistentHarvestingDelegationMessage.create(delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, NetworkType.MIJIN_TEST), @@ -304,7 +304,7 @@ describe('TransferTransaction', () => { it('should throw exception with mosaic provided when creating persistentDelegationRequestTransaction', () => { expect(() => { TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PersistentHarvestingDelegationMessage.create( @@ -321,7 +321,7 @@ describe('TransferTransaction', () => { it('should throw exception with invalid message when creating persistentDelegationRequestTransaction', () => { expect(() => { TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PersistentHarvestingDelegationMessage.create('abc', vrfPrivateKey, recipientPublicKey, NetworkType.MIJIN_TEST), @@ -333,7 +333,7 @@ describe('TransferTransaction', () => { it('should throw exception with invalid private key when creating persistentDelegationRequestTransaction', () => { expect(() => { TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PersistentHarvestingDelegationMessage.create( @@ -354,7 +354,7 @@ describe('TransferTransaction', () => { ]; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), mosaics, PlainMessage.create('NEM'), @@ -370,7 +370,7 @@ describe('TransferTransaction', () => { '64000000000000000000000000000000C8000000000000000000000000000000', ); - const sorted = CreateTransactionFromPayload(signedTransaction.payload) as TransferTransaction; + const sorted = CreateTransactionFromPayload(signedTransaction.payload, 1573430400) as TransferTransaction; expect(sorted.mosaics[0].id.id.compact()).to.be.equal(100); expect(sorted.mosaics[1].id.id.compact()).to.be.equal(200); }); @@ -383,7 +383,7 @@ describe('TransferTransaction', () => { ]; const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), mosaics, PlainMessage.create('NEM'), @@ -395,7 +395,7 @@ describe('TransferTransaction', () => { expect(transferTransaction.mosaics[2].id.toHex()).to.be.equal('67F2B76F28BD36BA'); const signedTransaction = transferTransaction.signWith(account, generationHash); - const sorted = CreateTransactionFromPayload(signedTransaction.payload) as TransferTransaction; + const sorted = CreateTransactionFromPayload(signedTransaction.payload, 1573430400) as TransferTransaction; expect(sorted.mosaics[0].id.toHex()).to.be.equal('67F2B76F28BD36BA'); expect(sorted.mosaics[1].id.toHex()).to.be.equal('77A1969932D987D7'); expect(sorted.mosaics[2].id.toHex()).to.be.equal('D525AD41D95FCF29'); @@ -404,14 +404,14 @@ describe('TransferTransaction', () => { it('Test Serialization and Deserialization Using namespaceIds', () => { const namespaceId = new NamespaceId('testaccount2'); const transferTransaction = TransferTransaction.create( - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), namespaceId, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const payload = transferTransaction.serialize(); - const newTransaction = CreateTransactionFromPayload(payload) as TransferTransaction; + const newTransaction = CreateTransactionFromPayload(payload, 1573430400) as TransferTransaction; const newPayload = newTransaction.serialize(); expect(newPayload).to.be.equal(payload); expect(newTransaction.recipientToString()).to.be.equal(transferTransaction.recipientToString()); @@ -419,7 +419,7 @@ describe('TransferTransaction', () => { it('Test set maxFee using multiplier', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -433,7 +433,7 @@ describe('TransferTransaction', () => { it('Test set maxFee using multiplier to throw', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -442,7 +442,7 @@ describe('TransferTransaction', () => { expect(() => { AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -454,7 +454,7 @@ describe('TransferTransaction', () => { const transferTransaction = new TransferTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1'), + Deadline.createFromDTO('1', 1573430400), UInt64.fromUint(0), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], @@ -475,7 +475,7 @@ describe('TransferTransaction', () => { it('Notify Account', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -495,7 +495,7 @@ describe('TransferTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const namespaceId = new NamespaceId('test'); const canNotify = TransferTransaction.create( - Deadline.create(), + Deadline.create(1573430400), namespaceId, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), diff --git a/test/model/transaction/VotingKeyLinkTransaction.spec.ts b/test/model/transaction/VotingKeyLinkTransaction.spec.ts index f3c12381ee..d4bd862a5b 100644 --- a/test/model/transaction/VotingKeyLinkTransaction.spec.ts +++ b/test/model/transaction/VotingKeyLinkTransaction.spec.ts @@ -38,7 +38,7 @@ describe('VotingKeyLinkTransaction', () => { it('should default maxFee field be set to 0', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), votingKey, startEpoch, endEpoch, @@ -54,7 +54,7 @@ describe('VotingKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), votingKey, startEpoch, endEpoch, @@ -71,7 +71,7 @@ describe('VotingKeyLinkTransaction', () => { it('should create an votingKeyLinkTransaction object with link action', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), votingKey, startEpoch, endEpoch, @@ -93,7 +93,7 @@ describe('VotingKeyLinkTransaction', () => { it('should create an VotingKeyLinkTransaction object with unlink action', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), votingKey, startEpoch, endEpoch, @@ -116,7 +116,7 @@ describe('VotingKeyLinkTransaction', () => { describe('size', () => { it('should return 185 for VotingKeyLinkTransaction byte size', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), votingKey, startEpoch, endEpoch, @@ -130,7 +130,7 @@ describe('VotingKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), votingKey, startEpoch, endEpoch, @@ -145,7 +145,7 @@ describe('VotingKeyLinkTransaction', () => { it('Notify Account', () => { const tx = VotingKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, startEpoch, endEpoch, diff --git a/test/model/transaction/VrfKeyLinkTransaction.spec.ts b/test/model/transaction/VrfKeyLinkTransaction.spec.ts index d84b338420..1ad464af04 100644 --- a/test/model/transaction/VrfKeyLinkTransaction.spec.ts +++ b/test/model/transaction/VrfKeyLinkTransaction.spec.ts @@ -34,7 +34,7 @@ describe('VrfKeyLinkTransaction', () => { it('should default maxFee field be set to 0', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -46,7 +46,7 @@ describe('VrfKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -59,7 +59,7 @@ describe('VrfKeyLinkTransaction', () => { it('should create an VrfKeyLinkTransaction object with link action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -77,7 +77,7 @@ describe('VrfKeyLinkTransaction', () => { it('should create an VrfKeyLinkTransaction object with unlink action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -96,7 +96,7 @@ describe('VrfKeyLinkTransaction', () => { describe('size', () => { it('should return 161 for VrfKeyLinkTransaction byte size', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -108,7 +108,7 @@ describe('VrfKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(), + Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -120,7 +120,7 @@ describe('VrfKeyLinkTransaction', () => { }); it('Notify Account', () => { - const tx = VrfKeyLinkTransaction.create(Deadline.create(), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); + const tx = VrfKeyLinkTransaction.create(Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; diff --git a/test/service/AggregateTransactionService.spec.ts b/test/service/AggregateTransactionService.spec.ts index 3d157e7ddf..eb695be909 100644 --- a/test/service/AggregateTransactionService.spec.ts +++ b/test/service/AggregateTransactionService.spec.ts @@ -188,7 +188,7 @@ describe('AggregateTransactionService', () => { * Expecting complete as Bob needs 2 signatures (account1 && (account2 || account3)) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -196,7 +196,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -204,7 +204,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account2], generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -221,7 +221,7 @@ describe('AggregateTransactionService', () => { * Expecting incomplete as Bob needs 2 signatures (account1 && (account2 || account3)) but only got account1 */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -229,7 +229,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -237,7 +237,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [], generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -254,7 +254,7 @@ describe('AggregateTransactionService', () => { * Expecting incomplete as Bob needs 2 signatures (account1 && (account2 || account3)) but got account4 */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -262,7 +262,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -270,7 +270,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account4], generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -288,7 +288,7 @@ describe('AggregateTransactionService', () => { * Expecting incomplete as Bob needs 2 signatures (account1 && (account2 || account3)) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -296,7 +296,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -304,14 +304,14 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(multisig2.publicAccount), transferTransaction2.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], ); const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account4], generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -329,7 +329,7 @@ describe('AggregateTransactionService', () => { * Expecting complete */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -337,7 +337,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -345,14 +345,14 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(multisig2.publicAccount), transferTransaction2.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], ); const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account4, account2], generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -367,7 +367,7 @@ describe('AggregateTransactionService', () => { * to determine if the act is complete or not */ const modifyMultisigTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), 1, 1, [], @@ -376,14 +376,14 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [modifyMultisigTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], ); const signedTransaction = aggregateTransaction.signWith(account2, generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -398,7 +398,7 @@ describe('AggregateTransactionService', () => { * to determine if the act is complete or not */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -406,7 +406,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -414,7 +414,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signWith(account1, generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -430,7 +430,7 @@ describe('AggregateTransactionService', () => { * Bob sign */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -438,7 +438,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -446,7 +446,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signWith(account4, generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -468,7 +468,7 @@ describe('AggregateTransactionService', () => { * Then the contract should appear as complete */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account1.address, [], PlainMessage.create('test-message'), @@ -476,7 +476,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -484,7 +484,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account4.publicAccount), transferTransaction2.toAggregate(account1.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -492,7 +492,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account4], generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -513,7 +513,7 @@ describe('AggregateTransactionService', () => { * Then the contract should appear as incomplete */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account1.address, [], PlainMessage.create('test-message'), @@ -521,7 +521,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -529,7 +529,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account4.publicAccount), transferTransaction2.toAggregate(account1.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -537,7 +537,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [], generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -551,7 +551,7 @@ describe('AggregateTransactionService', () => { * Bob (multisig3): is a 2/2 multisig account (account2 && account3) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -559,7 +559,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(multisig3.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -567,7 +567,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account2, [account3], generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -581,7 +581,7 @@ describe('AggregateTransactionService', () => { * Bob (multisig3): is a 2/2 multisig account (account2 && account3) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -589,7 +589,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(multisig3.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -597,7 +597,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account2, [], generationHash); aggregateTransactionService - .isComplete(signedTransaction) + .isComplete(signedTransaction, 1573430400) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; diff --git a/test/service/MetadataTransactionservice.spec.ts b/test/service/MetadataTransactionservice.spec.ts index d3ec41a946..534e24c8ce 100644 --- a/test/service/MetadataTransactionservice.spec.ts +++ b/test/service/MetadataTransactionservice.spec.ts @@ -111,7 +111,7 @@ describe('MetadataTransactionService', () => { it('should create AccountMetadataTransaction', (done) => { metadataTransactionService .createAccountMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, account.address, key, @@ -134,7 +134,7 @@ describe('MetadataTransactionService', () => { it('should create MosaicMetadataTransaction', (done) => { metadataTransactionService .createMosaicMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, account.address, new MosaicId(targetIdHex), @@ -159,7 +159,7 @@ describe('MetadataTransactionService', () => { it('should create NamespaceMetadataTransaction', (done) => { metadataTransactionService .createNamespaceMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, account.address, NamespaceId.createFromEncoded(targetIdHex), @@ -194,7 +194,7 @@ describe('MetadataTransactionService', () => { ).thenReject(); expect(() => { metadataTransactionService.createAccountMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, account.address, key, @@ -218,7 +218,7 @@ describe('MetadataTransactionService', () => { ).thenReject(); expect(() => { metadataTransactionService.createMosaicMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, account.address, new MosaicId(targetIdHex), @@ -243,7 +243,7 @@ describe('MetadataTransactionService', () => { ).thenReject(); expect(() => { metadataTransactionService.createNamespaceMetadataTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, account.address, NamespaceId.createFromEncoded(targetIdHex), diff --git a/test/service/MosaicRestrictionTransactionservice.spec.ts b/test/service/MosaicRestrictionTransactionservice.spec.ts index 7515bfe7a6..5312ad2162 100644 --- a/test/service/MosaicRestrictionTransactionservice.spec.ts +++ b/test/service/MosaicRestrictionTransactionservice.spec.ts @@ -103,7 +103,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicGlobalRestriction Transaction', (done) => { mosaicRestrictionTransactionService .createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, mosaicId, key, @@ -123,7 +123,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicGlobalRestriction Transaction - with referenceMosaicId', (done) => { mosaicRestrictionTransactionService .createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, mosaicId, key, @@ -143,7 +143,14 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicAddressRestriction Transaction', (done) => { mosaicRestrictionTransactionService - .createMosaicAddressRestrictionTransaction(Deadline.create(), NetworkType.MIJIN_TEST, mosaicId, key, account.address, '2000') + .createMosaicAddressRestrictionTransaction( + Deadline.create(1573430400), + NetworkType.MIJIN_TEST, + mosaicId, + key, + account.address, + '2000', + ) .subscribe((transaction: MosaicAddressRestrictionTransaction) => { expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.restrictionKey.toString()).to.be.equal(key.toString()); @@ -156,7 +163,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicGlobalRestriction Transaction with unresolvedMosaicId', (done) => { mosaicRestrictionTransactionService .createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, unresolvedMosaicId, key, @@ -176,7 +183,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicAddressRestriction Transaction with unresolvedAddress', (done) => { mosaicRestrictionTransactionService .createMosaicAddressRestrictionTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, unresolvedMosaicId, key, @@ -195,7 +202,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid unresolvedMosaicId', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, unresolvedAddress, key, @@ -208,7 +215,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid unresolvedAddress', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicAddressRestrictionTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, mosaicId, key, @@ -221,7 +228,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid value / key', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicGlobalRestrictionTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, mosaicId, key, @@ -232,7 +239,7 @@ describe('MosaicRestrictionTransactionService', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicAddressRestrictionTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, mosaicId, key, @@ -245,7 +252,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid address restriction key - MosaicAddressRestriction', () => { mosaicRestrictionTransactionService .createMosaicAddressRestrictionTransaction( - Deadline.create(), + Deadline.create(1573430400), NetworkType.MIJIN_TEST, mosaicIdWrongKey, invalidKey, diff --git a/test/service/TransactionService.spec.ts b/test/service/TransactionService.spec.ts index 27f210e168..7fbc6ef8bc 100644 --- a/test/service/TransactionService.spec.ts +++ b/test/service/TransactionService.spec.ts @@ -45,7 +45,7 @@ describe('TransactionService', () => { const generationHash = '82DB2528834C9926F0FCCE042466B24A266F5B685CB66D2869AF6648C043E950'; const account = Account.generateNewAccount(NetworkType.MIJIN_TEST); const transferTransaction = TransferTransaction.create( - Deadline.create(1, ChronoUnit.HOURS), + Deadline.create(1573430400, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -53,21 +53,21 @@ describe('TransactionService', () => { ); const aggregateCompleteTransaction = AggregateTransaction.createComplete( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); const aggregateBondedTransaction = AggregateTransaction.createBonded( - Deadline.create(), + Deadline.create(1573430400), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); const hashLockTransaction = HashLockTransaction.create( - Deadline.create(), + Deadline.create(1573430400), new Mosaic(new NamespaceId('cat.currency'), UInt64.fromUint(10 * Math.pow(10, NetworkCurrencyLocal.DIVISIBILITY))), UInt64.fromUint(10000), account.sign(aggregateBondedTransaction, generationHash), @@ -113,7 +113,7 @@ describe('TransactionService', () => { when(transactionRepositoryMock.announce(deepEqual(signedTransaction))).thenReturn(observableOf(transactionAnnounceResponse)); when(listener.confirmed(deepEqual(account.address), deepEqual(signedTransaction.hash))).thenReturn(EMPTY); - const statusError = new TransactionStatusError(account.address, signedTransaction.hash, 'Some Error', Deadline.create()); + const statusError = new TransactionStatusError(account.address, signedTransaction.hash, 'Some Error', Deadline.create(1573430400)); when(listener.status(deepEqual(account.address), signedTransaction.hash)).thenReturn(observableOf(statusError)); const service = new TransactionService(instance(transactionRepositoryMock), instance(mockedReceiptRepository)); @@ -159,7 +159,7 @@ describe('TransactionService', () => { ); when(listener.aggregateBondedAdded(deepEqual(account.address), deepEqual(signedTransaction.hash))).thenReturn(EMPTY); - const statusError = new TransactionStatusError(account.address, signedTransaction.hash, 'Some Error', Deadline.create()); + const statusError = new TransactionStatusError(account.address, signedTransaction.hash, 'Some Error', Deadline.create(1573430400)); when(listener.status(deepEqual(account.address), signedTransaction.hash)).thenReturn(observableOf(statusError)); const service = new TransactionService(instance(transactionRepositoryMock), instance(mockedReceiptRepository)); From 13e97685c380f39743b6a8f0a5a9cd2e5007864d Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Fri, 9 Oct 2020 14:11:08 +0100 Subject: [PATCH 2/6] renamed nemesisEpoch to EpochAdjustment --- e2e/infrastructure/IntegrationTestHelper.ts | 4 +- e2e/infrastructure/TransactionHttp.spec.ts | 190 +++++++++--------- src/core/utils/TransactionMapping.ts | 12 +- src/infrastructure/Http.ts | 10 +- src/infrastructure/Listener.ts | 6 +- src/infrastructure/RepositoryFactory.ts | 2 +- src/infrastructure/RepositoryFactoryConfig.ts | 2 +- src/infrastructure/RepositoryFactoryHttp.ts | 12 +- src/infrastructure/TransactionHttp.ts | 44 ++-- src/infrastructure/TransactionStatusHttp.ts | 26 +-- .../transaction/CreateTransactionFromDTO.ts | 64 +++--- .../CreateTransactionFromPayload.ts | 54 ++--- .../AccountAddressRestrictionTransaction.ts | 6 +- .../transaction/AccountKeyLinkTransaction.ts | 6 +- .../transaction/AccountMetadataTransaction.ts | 6 +- .../AccountMosaicRestrictionTransaction.ts | 6 +- .../AccountOperationRestrictionTransaction.ts | 9 +- .../transaction/AddressAliasTransaction.ts | 6 +- src/model/transaction/AggregateTransaction.ts | 8 +- src/model/transaction/Deadline.ts | 22 +- src/model/transaction/LockFundsTransaction.ts | 6 +- .../MosaicAddressRestrictionTransaction.ts | 6 +- .../transaction/MosaicAliasTransaction.ts | 6 +- .../MosaicDefinitionTransaction.ts | 6 +- .../MosaicGlobalRestrictionTransaction.ts | 6 +- .../transaction/MosaicMetadataTransaction.ts | 6 +- .../MosaicSupplyChangeTransaction.ts | 6 +- .../MultisigAccountModificationTransaction.ts | 9 +- .../NamespaceMetadataTransaction.ts | 6 +- .../NamespaceRegistrationTransaction.ts | 8 +- .../transaction/NodeKeyLinkTransaction.ts | 6 +- .../transaction/SecretLockTransaction.ts | 6 +- .../transaction/SecretProofTransaction.ts | 6 +- src/model/transaction/TransferTransaction.ts | 6 +- .../transaction/VotingKeyLinkTransaction.ts | 6 +- .../transaction/VrfKeyLinkTransaction.ts | 6 +- src/service/AggregateTransactionService.ts | 9 +- test/infrastructure/Listener.spec.ts | 34 ++-- test/infrastructure/RepositoryFactory.spec.ts | 30 +-- .../TransactionStatusHttp.spec.ts | 4 +- 40 files changed, 343 insertions(+), 330 deletions(-) diff --git a/e2e/infrastructure/IntegrationTestHelper.ts b/e2e/infrastructure/IntegrationTestHelper.ts index f4e761c0fe..46ea5a6831 100644 --- a/e2e/infrastructure/IntegrationTestHelper.ts +++ b/e2e/infrastructure/IntegrationTestHelper.ts @@ -52,7 +52,7 @@ export class IntegrationTestHelper { public service = new BootstrapService(); public config: StartParams; public startEachTime = true; - public nemesisEpoch: number; + public epochAdjustment: number; private async startBootstrapServer(): Promise<{ accounts: string[]; apiUrl: string }> { this.config = { @@ -113,7 +113,7 @@ export class IntegrationTestHelper { this.networkType = await this.repositoryFactory.getNetworkType().toPromise(); this.generationHash = await this.repositoryFactory.getGenerationHash().toPromise(); - this.nemesisEpoch = await this.repositoryFactory.getNemesisEpoch().toPromise(); + this.epochAdjustment = await this.repositoryFactory.getEpochAdjustment().toPromise(); let index = 0; this.account = Account.createFromPrivateKey(accounts[index++], this.networkType); diff --git a/e2e/infrastructure/TransactionHttp.spec.ts b/e2e/infrastructure/TransactionHttp.spec.ts index 87d736205b..7c6a72e2d9 100644 --- a/e2e/infrastructure/TransactionHttp.spec.ts +++ b/e2e/infrastructure/TransactionHttp.spec.ts @@ -137,7 +137,7 @@ describe('TransactionHttp', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -165,7 +165,7 @@ describe('TransactionHttp', () => { it('aggregate', () => { const nonce = MosaicNonce.createRandom(); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), nonce, MosaicId.createFromNonce(nonce, account.address), MosaicFlags.create(true, true, true), @@ -175,7 +175,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [mosaicDefinitionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -189,7 +189,7 @@ describe('TransactionHttp', () => { describe('AccountMetadataTransaction', () => { it('aggregate', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account.address, UInt64.fromUint(5), 10, @@ -199,7 +199,7 @@ describe('TransactionHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [accountMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -221,7 +221,7 @@ describe('TransactionHttp', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account.address, UInt64.fromUint(5), mosaicId, @@ -232,7 +232,7 @@ describe('TransactionHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [mosaicMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -255,7 +255,7 @@ describe('TransactionHttp', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -275,7 +275,7 @@ describe('TransactionHttp', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -294,14 +294,14 @@ describe('TransactionHttp', () => { describe('NamespaceRegistrationTransaction', () => { it('aggregate', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), 'root-test-namespace-' + Math.floor(Math.random() * 10000), UInt64.fromUint(5), networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [registerNamespaceTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -315,7 +315,7 @@ describe('TransactionHttp', () => { describe('NamespaceMetadataTransaction', () => { it('aggregate', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account.address, UInt64.fromUint(5), addressAlias, @@ -326,7 +326,7 @@ describe('TransactionHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [namespaceMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -348,7 +348,7 @@ describe('TransactionHttp', () => { describe('MosaicGlobalRestrictionTransaction', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), mosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -366,7 +366,7 @@ describe('TransactionHttp', () => { describe('MosaicGlobalRestrictionTransaction', () => { it('aggregate', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), mosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -378,7 +378,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [mosaicGlobalRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -392,7 +392,7 @@ describe('TransactionHttp', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), mosaicId, UInt64.fromUint(60641), account3.address, @@ -402,7 +402,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -416,7 +416,7 @@ describe('TransactionHttp', () => { describe('TransferTransaction', () => { it('standalone', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -430,7 +430,7 @@ describe('TransactionHttp', () => { describe('TransferTransaction', () => { it('aggregate', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -438,7 +438,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -451,7 +451,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Outgoing Address', () => { it('standalone', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), AddressRestrictionFlag.BlockOutgoingAddress, [account3.address], [], @@ -469,7 +469,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Outgoing Address', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), AddressRestrictionFlag.BlockOutgoingAddress, [], [account3.address], @@ -477,7 +477,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [addressModification.toAggregate(account.publicAccount)], networkType, [], @@ -491,7 +491,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Incoming Address', () => { it('standalone', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), AddressRestrictionFlag.BlockIncomingAddress, [account3.address], [], @@ -505,7 +505,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Incoming Address', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), AddressRestrictionFlag.BlockIncomingAddress, [], [account3.address], @@ -513,7 +513,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [addressModification.toAggregate(account.publicAccount)], networkType, [], @@ -527,7 +527,7 @@ describe('TransactionHttp', () => { it('standalone', () => { AccountRestrictionModification.createForMosaic(AccountRestrictionModificationAction.Add, mosaicId); const addressModification = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), MosaicRestrictionFlag.BlockMosaic, [mosaicId], [], @@ -546,7 +546,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Mosaic', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), MosaicRestrictionFlag.BlockMosaic, [], [mosaicId], @@ -554,7 +554,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [addressModification.toAggregate(account.publicAccount)], networkType, [], @@ -569,7 +569,7 @@ describe('TransactionHttp', () => { it('standalone', () => { AccountRestrictionModification.createForOperation(AccountRestrictionModificationAction.Add, TransactionType.ACCOUNT_KEY_LINK); const addressModification = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), OperationRestrictionFlag.BlockOutgoingTransactionType, [TransactionType.ACCOUNT_KEY_LINK], [], @@ -588,7 +588,7 @@ describe('TransactionHttp', () => { describe('AccountRestrictionTransaction - Outgoing Operation', () => { it('aggregate', () => { const addressModification = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), OperationRestrictionFlag.BlockOutgoingTransactionType, [], [TransactionType.ACCOUNT_KEY_LINK], @@ -596,7 +596,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [addressModification.toAggregate(account3.publicAccount)], networkType, [], @@ -610,7 +610,7 @@ describe('TransactionHttp', () => { describe('AccountKeyLinkTransaction', () => { it('standalone', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), remoteAccount.publicKey, LinkAction.Link, networkType, @@ -628,14 +628,14 @@ describe('TransactionHttp', () => { describe('AccountKeyLinkTransaction', () => { it('aggregate', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), remoteAccount.publicKey, LinkAction.Unlink, networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [accountLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -649,7 +649,7 @@ describe('TransactionHttp', () => { describe('VrfKeyLinkTransaction', () => { it('standalone', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), harvestingAccount.publicKey, LinkAction.Link, networkType, @@ -667,14 +667,14 @@ describe('TransactionHttp', () => { describe('VrfKeyLinkTransaction', () => { it('aggregate', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), harvestingAccount.publicKey, LinkAction.Unlink, networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [vrfKeyLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -688,7 +688,7 @@ describe('TransactionHttp', () => { describe('NodeKeyLinkTransaction', () => { it('standalone', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), harvestingAccount.publicKey, LinkAction.Link, networkType, @@ -706,14 +706,14 @@ describe('TransactionHttp', () => { describe('NodeKeyLinkTransaction', () => { it('aggregate', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), harvestingAccount.publicKey, LinkAction.Unlink, networkType, helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [nodeKeyLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -727,7 +727,7 @@ describe('TransactionHttp', () => { describe('VotingKeyLinkTransaction', () => { it('standalone', () => { const votingLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), votingKey, 100, 300, @@ -749,7 +749,7 @@ describe('TransactionHttp', () => { describe('VotingKeyLinkTransaction', () => { it('aggregate', () => { const votingLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), votingKey, 100, 300, @@ -758,7 +758,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [votingLinkTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -772,7 +772,7 @@ describe('TransactionHttp', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), AliasAction.Link, addressAlias, account.address, @@ -792,7 +792,7 @@ describe('TransactionHttp', () => { describe('Transfer Transaction using address alias', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), addressAlias, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -808,7 +808,7 @@ describe('TransactionHttp', () => { describe('AddressAliasTransaction', () => { it('aggregate', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), AliasAction.Unlink, addressAlias, account.address, @@ -816,7 +816,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [addressAliasTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -830,7 +830,7 @@ describe('TransactionHttp', () => { describe('MosaicSupplyChangeTransaction', () => { it('standalone', () => { const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -848,7 +848,7 @@ describe('TransactionHttp', () => { describe('MosaicSupplyChangeTransaction', () => { it('aggregate', () => { const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -856,7 +856,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [mosaicSupplyChangeTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -870,7 +870,7 @@ describe('TransactionHttp', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), AliasAction.Link, mosaicAlias, mosaicId, @@ -890,7 +890,7 @@ describe('TransactionHttp', () => { describe('HashLockTransaction - MosaicAlias', () => { it('standalone', () => { const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [], networkType, [], @@ -898,7 +898,7 @@ describe('TransactionHttp', () => { ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const hashLockTransaction = HashLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), new Mosaic(new NamespaceId('cat.currency'), UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(10000), signedTransaction, @@ -913,7 +913,7 @@ describe('TransactionHttp', () => { describe('MosaicAliasTransaction', () => { it('aggregate', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), AliasAction.Unlink, mosaicAlias, mosaicId, @@ -921,7 +921,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [mosaicAliasTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -935,7 +935,7 @@ describe('TransactionHttp', () => { describe('LockFundsTransaction', () => { it('standalone', () => { const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [], networkType, [], @@ -943,7 +943,7 @@ describe('TransactionHttp', () => { ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(10000), signedTransaction, @@ -957,7 +957,7 @@ describe('TransactionHttp', () => { describe('LockFundsTransaction', () => { it('aggregate', () => { const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [], networkType, [], @@ -965,7 +965,7 @@ describe('TransactionHttp', () => { ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(10), signedTransaction, @@ -973,7 +973,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateLockFundsTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [lockFundsTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -986,7 +986,7 @@ describe('TransactionHttp', () => { describe('Aggregate Complete Transaction', () => { it('should announce aggregated complete transaction', () => { const tx = TransferTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account2.address, [], PlainMessage.create('Hi'), @@ -994,7 +994,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggTx = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [tx.toAggregate(account.publicAccount)], networkType, [], @@ -1008,7 +1008,7 @@ describe('TransactionHttp', () => { describe('SecretLockTransaction', () => { it('standalone', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1030,7 +1030,7 @@ describe('TransactionHttp', () => { describe('HashType: Op_Sha3_256', () => { it('aggregate', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1040,7 +1040,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretLockTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [secretLockTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -1055,7 +1055,7 @@ describe('TransactionHttp', () => { const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20)); const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1072,7 +1072,7 @@ describe('TransactionHttp', () => { const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20)); const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1082,7 +1082,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretLockTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [secretLockTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -1094,7 +1094,7 @@ describe('TransactionHttp', () => { describe('HashType: Op_Hash_256', () => { it('standalone', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1109,7 +1109,7 @@ describe('TransactionHttp', () => { describe('HashType: Op_Hash_256', () => { it('aggregate', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1119,7 +1119,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretLockTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [secretLockTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -1136,7 +1136,7 @@ describe('TransactionHttp', () => { const proof = convert.uint8ToHex(secretSeed); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch, 1, ChronoUnit.HOURS), + Deadline.create(helper.epochAdjustment, 1, ChronoUnit.HOURS), helper.createNetworkCurrency(10, false), UInt64.fromUint(11), LockHashAlgorithm.Op_Sha3_256, @@ -1150,7 +1150,7 @@ describe('TransactionHttp', () => { return helper.announce(signedSecretLockTx).then(() => { const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Sha3_256, secret, account2.address, @@ -1174,7 +1174,7 @@ describe('TransactionHttp', () => { const secret = sha3_256.create().update(secretSeed).hex(); const proof = convert.uint8ToHex(secretSeed); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1186,7 +1186,7 @@ describe('TransactionHttp', () => { return helper.announce(secretLockTransaction.signWith(account, generationHash)).then(() => { const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Sha3_256, secret, account2.address, @@ -1195,7 +1195,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretProofTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [secretProofTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1212,7 +1212,7 @@ describe('TransactionHttp', () => { const secret = LockHashUtils.Op_Hash_160(randomBytes); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1224,7 +1224,7 @@ describe('TransactionHttp', () => { return helper.announce(secretLockTransaction.signWith(account, generationHash)).then(() => { const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Hash_160, secret, account2.address, @@ -1245,7 +1245,7 @@ describe('TransactionHttp', () => { const secret = new ripemd160().update(Buffer.from(hash, 'hex')).digest('hex'); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -1255,7 +1255,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Hash_160, secret, account2.address, @@ -1264,7 +1264,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretProofTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [secretProofTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1284,7 +1284,7 @@ describe('TransactionHttp', () => { const secret = LockHashUtils.Op_Hash_256(randomBytes); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(1, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1295,7 +1295,7 @@ describe('TransactionHttp', () => { ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Hash_256, secret, account2.address, @@ -1317,7 +1317,7 @@ describe('TransactionHttp', () => { const secret = sha256(Buffer.from(hash, 'hex')); const proof = secretSeed; const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -1327,7 +1327,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), LockHashAlgorithm.Op_Hash_256, secret, account2.address, @@ -1336,7 +1336,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateSecretProofTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [secretProofTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1360,7 +1360,7 @@ describe('TransactionHttp', () => { const backAmount = helper.createNetworkCurrency(1); const aliceTransferTransaction = TransferTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account2.address, [sendAmount], PlainMessage.create('payout'), @@ -1368,7 +1368,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const bobTransferTransaction = TransferTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account.address, [backAmount], PlainMessage.create('payout'), @@ -1378,7 +1378,7 @@ describe('TransactionHttp', () => { // 01. Alice creates the aggregated tx and sign it. Then payload send to Bob const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), [aliceTransferTransaction.toAggregate(account.publicAccount), bobTransferTransaction.toAggregate(account2.publicAccount)], networkType, [], @@ -1396,7 +1396,7 @@ describe('TransactionHttp', () => { ]; const recreatedTx = TransactionMapping.createFromPayload( aliceSignedTransaction.payload, - helper.nemesisEpoch, + helper.epochAdjustment, ) as AggregateTransaction; const signedTransaction = recreatedTx.signTransactionGivenSignatures(account, cosignatureSignedTransactions, generationHash); @@ -1455,7 +1455,7 @@ describe('TransactionHttp', () => { describe('announce', () => { it('should return success when announce', async () => { const transferTransaction = TransferTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -1471,7 +1471,7 @@ describe('TransactionHttp', () => { describe('announceAggregateBonded', () => { it('should return success when announceAggregateBonded', async () => { const transferTransaction = TransferTransaction.create( - Deadline.create(helper.nemesisEpoch), + Deadline.create(helper.epochAdjustment), account2.address, [helper.createNetworkCurrency(1)], PlainMessage.create('test-message'), @@ -1479,7 +1479,7 @@ describe('TransactionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(helper.nemesisEpoch, 2, ChronoUnit.MINUTES), + Deadline.create(helper.epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], diff --git a/src/core/utils/TransactionMapping.ts b/src/core/utils/TransactionMapping.ts index 468ee4b387..c2e02245fa 100644 --- a/src/core/utils/TransactionMapping.ts +++ b/src/core/utils/TransactionMapping.ts @@ -23,21 +23,21 @@ export class TransactionMapping { /** * Create transaction class from Json. * @param {object} dataJson The transaction json object. - * @param {number} nemesisEpoch The nemesis block epoch. + * @param {number} epochAdjustment The nemesis block epoch. * @returns {module: model/transaction/transaction} The transaction class. */ - public static createFromDTO(dataJson: object, nemesisEpoch: number): Transaction { - return CreateTransactionFromDTO(dataJson, nemesisEpoch); + public static createFromDTO(dataJson: object, epochAdjustment: number): Transaction { + return CreateTransactionFromDTO(dataJson, epochAdjustment); } /** * Create transaction class from payload binary. * @param {string} payload The transaction binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} The transaction class. */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { - return CreateTransactionFromPayload(payload, nemesisEpoch, isEmbedded); + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + return CreateTransactionFromPayload(payload, epochAdjustment, isEmbedded); } } diff --git a/src/infrastructure/Http.ts b/src/infrastructure/Http.ts index d87210a358..9a77e80fc4 100644 --- a/src/infrastructure/Http.ts +++ b/src/infrastructure/Http.ts @@ -90,11 +90,11 @@ export abstract class Http { } } - createNemesisEpochObservable(nemesisEpoch?: number | Observable): Observable { - if (nemesisEpoch && nemesisEpoch instanceof Observable) { - return nemesisEpoch as Observable; - } else if (nemesisEpoch) { - return observableOf(nemesisEpoch); + createEpochAdjustmentObservable(epochAdjustment?: number | Observable): Observable { + if (epochAdjustment && epochAdjustment instanceof Observable) { + return epochAdjustment as Observable; + } else if (epochAdjustment) { + return observableOf(epochAdjustment); } else { return this.call(new NetworkRoutesApi(this.config()).getNetworkProperties(), (body) => parseInt(body.network.epochAdjustment?.replace('s', '') ?? '0'), diff --git a/src/infrastructure/Listener.ts b/src/infrastructure/Listener.ts index f1b8b2cefb..d38b95356b 100644 --- a/src/infrastructure/Listener.ts +++ b/src/infrastructure/Listener.ts @@ -90,7 +90,7 @@ export class Listener implements IListener { /** * Nemesis block creation epoch */ - private nemesisEpoch: number, + private epochAdjustment: number, /** * WebSocket injected when using listeners in client. */ @@ -151,7 +151,7 @@ export class Listener implements IListener { this.messageSubject.next({ channelName: ListenerChannelName[channelName], channelParam: channelParam, - message: CreateTransactionFromDTO(message.data, this.nemesisEpoch), + message: CreateTransactionFromDTO(message.data, this.epochAdjustment), }); break; case ListenerChannelName.block: @@ -169,7 +169,7 @@ export class Listener implements IListener { Address.createFromRawAddress(channelParam), message.data.hash, message.data.code, - Deadline.createFromDTO(message.data.deadline, this.nemesisEpoch), + Deadline.createFromDTO(message.data.deadline, this.epochAdjustment), ), }); break; diff --git a/src/infrastructure/RepositoryFactory.ts b/src/infrastructure/RepositoryFactory.ts index 729a21bd53..695afdd0a6 100644 --- a/src/infrastructure/RepositoryFactory.ts +++ b/src/infrastructure/RepositoryFactory.ts @@ -140,5 +140,5 @@ export interface RepositoryFactory { /** * @returns nemesis block epoch */ - getNemesisEpoch(): Observable; + getEpochAdjustment(): Observable; } diff --git a/src/infrastructure/RepositoryFactoryConfig.ts b/src/infrastructure/RepositoryFactoryConfig.ts index 2292ffdb7e..d533be7cc4 100644 --- a/src/infrastructure/RepositoryFactoryConfig.ts +++ b/src/infrastructure/RepositoryFactoryConfig.ts @@ -44,5 +44,5 @@ export interface RepositoryFactoryConfig { /** * The nemesis block creation epoch */ - nemesisEpoch?: number; + epochAdjustment?: number; } diff --git a/src/infrastructure/RepositoryFactoryHttp.ts b/src/infrastructure/RepositoryFactoryHttp.ts index 227b20b5f4..179530ba7d 100644 --- a/src/infrastructure/RepositoryFactoryHttp.ts +++ b/src/infrastructure/RepositoryFactoryHttp.ts @@ -64,7 +64,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { private readonly websocketUrl: string; private readonly websocketInjected?: any; private readonly fetchApi?: any; - private readonly nemesisEpoch: Observable; + private readonly epochAdjustment: Observable; /** * Constructor @@ -76,8 +76,8 @@ export class RepositoryFactoryHttp implements RepositoryFactory { this.url = url; this.fetchApi = configs?.fetchApi; this.networkType = configs?.networkType ? observableOf(configs.networkType) : networkRepo.getNetworkType().pipe(shareReplay(1)); - this.nemesisEpoch = configs?.nemesisEpoch - ? observableOf(configs.nemesisEpoch) + this.epochAdjustment = configs?.epochAdjustment + ? observableOf(configs.epochAdjustment) : networkRepo .getNetworkProperties() .pipe( @@ -145,7 +145,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { } createTransactionRepository(): TransactionRepository { - return new TransactionHttp(this.url, this.nemesisEpoch, this.fetchApi); + return new TransactionHttp(this.url, this.epochAdjustment, this.fetchApi); } createTransactionStatusRepository(): TransactionStatusRepository { @@ -172,7 +172,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { return new Listener(this.websocketUrl, this.createNamespaceRepository(), this.websocketInjected); } - getNemesisEpoch(): Observable { - return this.nemesisEpoch; + getEpochAdjustment(): Observable { + return this.epochAdjustment; } } diff --git a/src/infrastructure/TransactionHttp.ts b/src/infrastructure/TransactionHttp.ts index 4d2eb0aaec..4acbaab163 100644 --- a/src/infrastructure/TransactionHttp.ts +++ b/src/infrastructure/TransactionHttp.ts @@ -59,19 +59,19 @@ export class TransactionHttp extends Http implements TransactionRepository { * @internal * nemesis block creation epoch */ - private readonly nemesisEpochObservable: Observable; + private readonly epochAdjustmentObservable: Observable; /** * Constructor * @param url Base catapult-rest url - * @param nemesisEpoch Nemesis block epoch + * @param epochAdjustment Nemesis block epoch * @param fetchApi fetch function to be used when performing rest requests. */ - constructor(url: string, nemesisEpoch?: number | Observable, fetchApi?: any) { + constructor(url: string, epochAdjustment?: number | Observable, fetchApi?: any) { super(url, fetchApi); this.transactionRoutesApi = new TransactionRoutesApi(this.config()); this.blockRoutesApi = new BlockRoutesApi(this.config()); - this.nemesisEpochObservable = this.createNemesisEpochObservable(nemesisEpoch); + this.epochAdjustmentObservable = this.createEpochAdjustmentObservable(epochAdjustment); } /** @@ -81,10 +81,10 @@ export class TransactionHttp extends Http implements TransactionRepository { * @returns Observable */ public getTransaction(transactionId: string, transactionGroup: TransactionGroup): Observable { - return this.nemesisEpochObservable.pipe( - mergeMap((nemesisEpoch) => + return this.epochAdjustmentObservable.pipe( + mergeMap((epochAdjustment) => this.call(this.getTransactionByGroup(transactionId, transactionGroup), (body) => - CreateTransactionFromDTO(body, nemesisEpoch), + CreateTransactionFromDTO(body, epochAdjustment), ), ), ); @@ -103,31 +103,31 @@ export class TransactionHttp extends Http implements TransactionRepository { switch (transactionGroup) { case TransactionGroup.Confirmed: - return this.nemesisEpochObservable.pipe( - mergeMap((nemesisEpoch) => + return this.epochAdjustmentObservable.pipe( + mergeMap((epochAdjustment) => this.call(this.transactionRoutesApi.getConfirmedTransactions(transactionIdsBody), (body) => body.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO, nemesisEpoch); + return CreateTransactionFromDTO(transactionDTO, epochAdjustment); }), ), ), ); case TransactionGroup.Unconfirmed: - return this.nemesisEpochObservable.pipe( - mergeMap((nemesisEpoch) => + return this.epochAdjustmentObservable.pipe( + mergeMap((epochAdjustment) => this.call(this.transactionRoutesApi.getUnconfirmedTransactions(transactionIdsBody), (body) => body.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO, nemesisEpoch); + return CreateTransactionFromDTO(transactionDTO, epochAdjustment); }), ), ), ); case TransactionGroup.Partial: - return this.nemesisEpochObservable.pipe( - mergeMap((nemesisEpoch) => + return this.epochAdjustmentObservable.pipe( + mergeMap((epochAdjustment) => this.call(this.transactionRoutesApi.getPartialTransactions(transactionIdsBody), (body) => body.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO, nemesisEpoch); + return CreateTransactionFromDTO(transactionDTO, epochAdjustment); }), ), ), @@ -191,11 +191,11 @@ export class TransactionHttp extends Http implements TransactionRepository { * @returns Observable */ public getTransactionEffectiveFee(transactionId: string): Observable { - return this.nemesisEpochObservable + return this.epochAdjustmentObservable .pipe( - mergeMap((nemesisEpoch) => + mergeMap((epochAdjustment) => this.call(this.getTransactionByGroup(transactionId, TransactionGroup.Confirmed), (body) => - CreateTransactionFromDTO(body, nemesisEpoch), + CreateTransactionFromDTO(body, epochAdjustment), ), ), ) @@ -221,10 +221,10 @@ export class TransactionHttp extends Http implements TransactionRepository { * @returns {Observable>} */ public search(criteria: TransactionSearchCriteria): Observable> { - return this.nemesisEpochObservable.pipe( - mergeMap((nemesisEpoch) => + return this.epochAdjustmentObservable.pipe( + mergeMap((epochAdjustment) => this.call(this.searchTransactionByGroup(criteria), (body) => - super.toPage(body.pagination, body.data, (body) => CreateTransactionFromDTO(body, nemesisEpoch)), + super.toPage(body.pagination, body.data, (body) => CreateTransactionFromDTO(body, epochAdjustment)), ), ), ); diff --git a/src/infrastructure/TransactionStatusHttp.ts b/src/infrastructure/TransactionStatusHttp.ts index 838c73b2c7..a929a3521b 100644 --- a/src/infrastructure/TransactionStatusHttp.ts +++ b/src/infrastructure/TransactionStatusHttp.ts @@ -39,18 +39,18 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo * @internal * nemesis block creation epoch */ - private readonly nemesisEpochObservable: Observable; + private readonly epochAdjustmentObservable: Observable; /** * Constructor * @param url Base catapult-rest url - * @param nemesisEpoch Nemesis block epoch + * @param epochAdjustment Nemesis block epoch * @param fetchApi fetch function to be used when performing rest requests. */ - constructor(url: string, nemesisEpoch?: number | Observable, fetchApi?: any) { + constructor(url: string, epochAdjustment?: number | Observable, fetchApi?: any) { super(url, fetchApi); this.transactionStatusRoutesApi = new TransactionStatusRoutesApi(this.config()); - this.nemesisEpochObservable = this.createNemesisEpochObservable(nemesisEpoch); + this.epochAdjustmentObservable = this.createEpochAdjustmentObservable(epochAdjustment); } /** @@ -59,10 +59,10 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo * @returns Observable */ public getTransactionStatus(transactionHash: string): Observable { - return this.nemesisEpochObservable.pipe( - mergeMap((nemesisEpoch) => + return this.epochAdjustmentObservable.pipe( + mergeMap((epochAdjustment) => this.call(this.transactionStatusRoutesApi.getTransactionStatus(transactionHash), (body) => - this.toTransactionStatus(body, nemesisEpoch), + this.toTransactionStatus(body, epochAdjustment), ), ), ); @@ -77,10 +77,10 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo const transactionHashesBody = { hashes: transactionHashes, }; - return this.nemesisEpochObservable.pipe( - mergeMap((nemesisEpoch) => + return this.epochAdjustmentObservable.pipe( + mergeMap((epochAdjustment) => this.call(this.transactionStatusRoutesApi.getTransactionStatuses(transactionHashesBody), (body) => - body.map((b) => this.toTransactionStatus(b, nemesisEpoch)), + body.map((b) => this.toTransactionStatus(b, epochAdjustment)), ), ), ); @@ -91,14 +91,14 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo * * @internal * @param {TransactionStatusDTO} dto the TransactionStatusDTO object from rest. - * @param {number} nemesisEpoch the Nemesis block epoch + * @param {number} epochAdjustment the Nemesis block epoch * @returns {TransactionStatus} a TransactionStatus model */ - private toTransactionStatus(dto: TransactionStatusDTO, nemesisEpoch): TransactionStatus { + private toTransactionStatus(dto: TransactionStatusDTO, epochAdjustment): TransactionStatus { return new TransactionStatus( dto.group, dto.hash, - Deadline.createFromDTO(UInt64.fromNumericString(dto.deadline).toDTO(), nemesisEpoch ?? 0), + Deadline.createFromDTO(UInt64.fromNumericString(dto.deadline).toDTO(), epochAdjustment ?? 0), dto.code, dto.height ? UInt64.fromNumericString(dto.height) : undefined, ); diff --git a/src/infrastructure/transaction/CreateTransactionFromDTO.ts b/src/infrastructure/transaction/CreateTransactionFromDTO.ts index 451bce88d8..76d52dd268 100644 --- a/src/infrastructure/transaction/CreateTransactionFromDTO.ts +++ b/src/infrastructure/transaction/CreateTransactionFromDTO.ts @@ -126,14 +126,14 @@ const extractMessage = (message: any): Message => { /** * Extract deadline from json payload. - * @param nemesisEpoch Nemesis block epoch + * @param epochAdjustment Nemesis block epoch * @param deadline - deadline dto */ -const extractDeadline = (nemesisEpoch: number, deadline?: string): Deadline => { +const extractDeadline = (epochAdjustment: number, deadline?: string): Deadline => { if (!deadline) { return Deadline.createEmtpy(); } - return Deadline.createFromDTO(deadline, nemesisEpoch); + return Deadline.createFromDTO(deadline, epochAdjustment); }; /** @@ -157,16 +157,16 @@ const extractTransactionMeta = (meta: any, id: string): TransactionInfo | Aggreg * @internal * @param transactionDTO * @param transactionInfo - * @param nemesisEpoch + * @param epochAdjustment * @returns {any} * @constructor */ -const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nemesisEpoch): Transaction => { +const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epochAdjustment): Transaction => { if (transactionDTO.type === TransactionType.TRANSFER) { return new TransferTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.recipientAddress), extractMosaics(transactionDTO.mosaics), @@ -181,7 +181,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new NamespaceRegistrationTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.registrationType, transactionDTO.name, @@ -198,7 +198,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new MosaicDefinitionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), MosaicNonce.createFromNumber(transactionDTO.nonce), new MosaicId(transactionDTO.id), @@ -215,7 +215,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new MosaicSupplyChangeTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.mosaicId), transactionDTO.action, @@ -230,7 +230,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new MultisigAccountModificationTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.minApprovalDelta, transactionDTO.minRemovalDelta, @@ -247,7 +247,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new LockFundsTransaction( networkType, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), new Mosaic(new MosaicId(transactionDTO.mosaicId), UInt64.fromNumericString(transactionDTO.amount)), UInt64.fromNumericString(transactionDTO.duration), @@ -262,7 +262,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new SecretLockTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), new Mosaic(mosaicId, UInt64.fromNumericString(transactionDTO.amount)), UInt64.fromNumericString(transactionDTO.duration), @@ -280,7 +280,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new SecretProofTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.hashAlgorithm, transactionDTO.secret, @@ -296,7 +296,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new MosaicAliasTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.aliasAction, NamespaceId.createFromEncoded(transactionDTO.namespaceId), @@ -311,7 +311,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new AddressAliasTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.aliasAction, NamespaceId.createFromEncoded(transactionDTO.namespaceId), @@ -326,7 +326,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new AccountAddressRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.restrictionFlags, transactionDTO.restrictionAdditions ? transactionDTO.restrictionAdditions.map((addition) => extractRecipient(addition)) : [], @@ -341,7 +341,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new AccountOperationRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.restrictionFlags, transactionDTO.restrictionAdditions ? transactionDTO.restrictionAdditions : [], @@ -356,7 +356,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new AccountMosaicRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.restrictionFlags, transactionDTO.restrictionAdditions @@ -375,7 +375,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new AccountKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.linkAction, @@ -389,7 +389,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new MosaicGlobalRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.mosaicId), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.referenceMosaicId), @@ -408,7 +408,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new MosaicAddressRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.mosaicId), UInt64.fromHex(transactionDTO.restrictionKey), @@ -425,7 +425,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new AccountMetadataTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.targetAddress), UInt64.fromHex(transactionDTO.scopedMetadataKey), @@ -441,7 +441,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new MosaicMetadataTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.targetAddress), UInt64.fromHex(transactionDTO.scopedMetadataKey), @@ -458,7 +458,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new NamespaceMetadataTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.targetAddress), UInt64.fromHex(transactionDTO.scopedMetadataKey), @@ -475,7 +475,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new VrfKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.linkAction, @@ -489,7 +489,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new NodeKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.linkAction, @@ -503,7 +503,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem return new VotingKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(nemesisEpoch, transactionDTO.deadline), + extractDeadline(epochAdjustment, transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.startEpoch, @@ -522,11 +522,11 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, nem /** * @internal * @param transactionDTO - * @param nemesisEpoch + * @param epochAdjustment * @returns {Transaction} * @constructor */ -export const CreateTransactionFromDTO = (transactionDTO, nemesisEpoch): Transaction => { +export const CreateTransactionFromDTO = (transactionDTO, epochAdjustment): Transaction => { if ( transactionDTO.transaction.type === TransactionType.AGGREGATE_COMPLETE || transactionDTO.transaction.type === TransactionType.AGGREGATE_BONDED @@ -537,14 +537,14 @@ export const CreateTransactionFromDTO = (transactionDTO, nemesisEpoch): Transact innerTransactionDTO.transaction.maxFee = transactionDTO.transaction.maxFee; innerTransactionDTO.transaction.deadline = transactionDTO.transaction.deadline; innerTransactionDTO.transaction.signature = transactionDTO.transaction.signature; - return CreateStandaloneTransactionFromDTO(innerTransactionDTO.transaction, aggregateTransactionInfo, nemesisEpoch); + return CreateStandaloneTransactionFromDTO(innerTransactionDTO.transaction, aggregateTransactionInfo, epochAdjustment); }) : []; return new AggregateTransaction( transactionDTO.transaction.network, transactionDTO.transaction.type, transactionDTO.transaction.version, - extractDeadline(nemesisEpoch, transactionDTO.transaction.deadline), + extractDeadline(epochAdjustment, transactionDTO.transaction.deadline), UInt64.fromNumericString(transactionDTO.transaction.maxFee || '0'), innerTransactions, transactionDTO.transaction.cosignatures @@ -566,7 +566,7 @@ export const CreateTransactionFromDTO = (transactionDTO, nemesisEpoch): Transact return CreateStandaloneTransactionFromDTO( transactionDTO.transaction, extractTransactionMeta(transactionDTO.meta, transactionDTO.id), - nemesisEpoch, + epochAdjustment, ); } }; diff --git a/src/infrastructure/transaction/CreateTransactionFromPayload.ts b/src/infrastructure/transaction/CreateTransactionFromPayload.ts index f6e46043f6..ceeedf4bac 100644 --- a/src/infrastructure/transaction/CreateTransactionFromPayload.ts +++ b/src/infrastructure/transaction/CreateTransactionFromPayload.ts @@ -46,64 +46,68 @@ import { VrfKeyLinkTransaction } from '../../model/transaction/VrfKeyLinkTransac /** * @internal * @param payload - The transaction binary data - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param isEmbedded - Is the transaction an embedded inner transaction * @returns {Transaction | InnerTransaction} * @constructor */ -export const CreateTransactionFromPayload = (payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction => { +export const CreateTransactionFromPayload = ( + payload: string, + epochAdjustment: number, + isEmbedded = false, +): Transaction | InnerTransaction => { const transactionBuilder = isEmbedded ? EmbeddedTransactionBuilder.loadFromBinary(convert.hexToUint8(payload)) : TransactionBuilder.loadFromBinary(convert.hexToUint8(payload)); const type = transactionBuilder.getType().valueOf(); switch (type) { case TransactionType.ACCOUNT_ADDRESS_RESTRICTION: - return AccountAddressRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return AccountAddressRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.ACCOUNT_MOSAIC_RESTRICTION: - return AccountMosaicRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return AccountMosaicRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.ACCOUNT_OPERATION_RESTRICTION: - return AccountOperationRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return AccountOperationRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.ACCOUNT_KEY_LINK: - return AccountKeyLinkTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return AccountKeyLinkTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.ADDRESS_ALIAS: - return AddressAliasTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return AddressAliasTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.MOSAIC_ALIAS: - return MosaicAliasTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return MosaicAliasTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.MOSAIC_DEFINITION: - return MosaicDefinitionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return MosaicDefinitionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.MOSAIC_SUPPLY_CHANGE: - return MosaicSupplyChangeTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return MosaicSupplyChangeTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.NAMESPACE_REGISTRATION: - return NamespaceRegistrationTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return NamespaceRegistrationTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.TRANSFER: - return TransferTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return TransferTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.SECRET_LOCK: - return SecretLockTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return SecretLockTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.SECRET_PROOF: - return SecretProofTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return SecretProofTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.MULTISIG_ACCOUNT_MODIFICATION: - return MultisigAccountModificationTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return MultisigAccountModificationTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.HASH_LOCK: - return LockFundsTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return LockFundsTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.MOSAIC_GLOBAL_RESTRICTION: - return MosaicGlobalRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return MosaicGlobalRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.MOSAIC_ADDRESS_RESTRICTION: - return MosaicAddressRestrictionTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return MosaicAddressRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.ACCOUNT_METADATA: - return AccountMetadataTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return AccountMetadataTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.MOSAIC_METADATA: - return MosaicMetadataTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return MosaicMetadataTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.NAMESPACE_METADATA: - return NamespaceMetadataTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return NamespaceMetadataTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.VRF_KEY_LINK: - return VrfKeyLinkTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return VrfKeyLinkTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.NODE_KEY_LINK: - return NodeKeyLinkTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return NodeKeyLinkTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.VOTING_KEY_LINK: - return VotingKeyLinkTransaction.createFromPayload(payload, nemesisEpoch, isEmbedded); + return VotingKeyLinkTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); case TransactionType.AGGREGATE_COMPLETE: case TransactionType.AGGREGATE_BONDED: - return AggregateTransaction.createFromPayload(payload, nemesisEpoch); + return AggregateTransaction.createFromPayload(payload, epochAdjustment); default: throw new Error('Transaction type not implemented yet.'); } diff --git a/src/model/transaction/AccountAddressRestrictionTransaction.ts b/src/model/transaction/AccountAddressRestrictionTransaction.ts index bd2a6471f8..31c4033c9d 100644 --- a/src/model/transaction/AccountAddressRestrictionTransaction.ts +++ b/src/model/transaction/AccountAddressRestrictionTransaction.ts @@ -109,11 +109,11 @@ export class AccountAddressRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -123,7 +123,7 @@ export class AccountAddressRestrictionTransaction extends Transaction { const transaction = AccountAddressRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AccountAddressRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as AccountAddressRestrictionTransactionBuilder).getDeadline().timestamp, epochAdjustment), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions().map((addition) => { return UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(addition.unresolvedAddress)); diff --git a/src/model/transaction/AccountKeyLinkTransaction.ts b/src/model/transaction/AccountKeyLinkTransaction.ts index dd23697189..797255087e 100644 --- a/src/model/transaction/AccountKeyLinkTransaction.ts +++ b/src/model/transaction/AccountKeyLinkTransaction.ts @@ -107,11 +107,11 @@ export class AccountKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -121,7 +121,7 @@ export class AccountKeyLinkTransaction extends Transaction { const transaction = AccountKeyLinkTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AccountKeyLinkTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as AccountKeyLinkTransactionBuilder).getDeadline().timestamp, epochAdjustment), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/model/transaction/AccountMetadataTransaction.ts b/src/model/transaction/AccountMetadataTransaction.ts index 9e2bb6308b..e7f9a2f60d 100644 --- a/src/model/transaction/AccountMetadataTransaction.ts +++ b/src/model/transaction/AccountMetadataTransaction.ts @@ -129,11 +129,11 @@ export class AccountMetadataTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -143,7 +143,7 @@ export class AccountMetadataTransaction extends Transaction { const transaction = AccountMetadataTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AccountMetadataTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as AccountMetadataTransactionBuilder).getDeadline().timestamp, epochAdjustment), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), builder.getValueSizeDelta(), diff --git a/src/model/transaction/AccountMosaicRestrictionTransaction.ts b/src/model/transaction/AccountMosaicRestrictionTransaction.ts index afb13d0727..02dd60add9 100644 --- a/src/model/transaction/AccountMosaicRestrictionTransaction.ts +++ b/src/model/transaction/AccountMosaicRestrictionTransaction.ts @@ -108,11 +108,11 @@ export class AccountMosaicRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountMosaicRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountMosaicRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -122,7 +122,7 @@ export class AccountMosaicRestrictionTransaction extends Transaction { const transaction = AccountMosaicRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AccountMosaicRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as AccountMosaicRestrictionTransactionBuilder).getDeadline().timestamp, epochAdjustment), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions().map((addition) => { return UnresolvedMapping.toUnresolvedMosaic(new UInt64(addition.unresolvedMosaicId).toHex()); diff --git a/src/model/transaction/AccountOperationRestrictionTransaction.ts b/src/model/transaction/AccountOperationRestrictionTransaction.ts index 41863e5738..a6bf8bb29a 100644 --- a/src/model/transaction/AccountOperationRestrictionTransaction.ts +++ b/src/model/transaction/AccountOperationRestrictionTransaction.ts @@ -103,11 +103,11 @@ export class AccountOperationRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountOperationRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountOperationRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -117,7 +117,10 @@ export class AccountOperationRestrictionTransaction extends Transaction { const transaction = AccountOperationRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AccountOperationRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO( + (builder as AccountOperationRestrictionTransactionBuilder).getDeadline().timestamp, + epochAdjustment, + ), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions(), builder.getRestrictionDeletions(), diff --git a/src/model/transaction/AddressAliasTransaction.ts b/src/model/transaction/AddressAliasTransaction.ts index 17d84515bd..cb6ad6407b 100644 --- a/src/model/transaction/AddressAliasTransaction.ts +++ b/src/model/transaction/AddressAliasTransaction.ts @@ -119,11 +119,11 @@ export class AddressAliasTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAddressAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AddressAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -133,7 +133,7 @@ export class AddressAliasTransaction extends Transaction { const transaction = AddressAliasTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AddressAliasTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as AddressAliasTransactionBuilder).getDeadline().timestamp, epochAdjustment), builder.getAliasAction().valueOf(), new NamespaceId(builder.getNamespaceId().namespaceId), Address.createFromEncoded(Convert.uint8ToHex(builder.getAddress().address)), diff --git a/src/model/transaction/AggregateTransaction.ts b/src/model/transaction/AggregateTransaction.ts index 486a4d9b8e..cd371d2b51 100644 --- a/src/model/transaction/AggregateTransaction.ts +++ b/src/model/transaction/AggregateTransaction.ts @@ -154,10 +154,10 @@ export class AggregateTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @returns {AggregateTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number): AggregateTransaction { + public static createFromPayload(payload: string, epochAdjustment: number): AggregateTransaction { /** * Get transaction type from the payload hex * As buffer uses separate builder class for Complete and bonded @@ -181,7 +181,7 @@ export class AggregateTransaction extends Transaction { return type === TransactionType.AGGREGATE_COMPLETE ? AggregateTransaction.createComplete( - Deadline.createFromDTO(builder.deadline.timestamp, nemesisEpoch), + Deadline.createFromDTO(builder.deadline.timestamp, epochAdjustment), innerTransactions.map((transactionRaw) => { return CreateTransactionFromPayload(transactionRaw, 1573430400, true) as InnerTransaction; }), @@ -192,7 +192,7 @@ export class AggregateTransaction extends Transaction { signerPublicKey.match(`^[0]+$`) ? undefined : PublicAccount.createFromPublicKey(signerPublicKey, networkType), ) : AggregateTransaction.createBonded( - Deadline.createFromDTO(builder.deadline.timestamp, nemesisEpoch), + Deadline.createFromDTO(builder.deadline.timestamp, epochAdjustment), innerTransactions.map((transactionRaw) => { return CreateTransactionFromPayload(transactionRaw, 1573430400, true) as InnerTransaction; }), diff --git a/src/model/transaction/Deadline.ts b/src/model/transaction/Deadline.ts index b7d22eeba3..bdde6b324d 100644 --- a/src/model/transaction/Deadline.ts +++ b/src/model/transaction/Deadline.ts @@ -25,7 +25,7 @@ export class Deadline { /** * @type {number} */ - private nemesisEpoch: number; + private epochAdjustment: number; /** * Deadline value @@ -34,12 +34,12 @@ export class Deadline { /** * Create deadline model - * @param nemesisEpoch + * @param epochAdjustment * @param deadline * @param chronoUnit * @returns {Deadline} */ - public static create(nemesisEpoch: number, deadline = 2, chronoUnit: ChronoUnit = ChronoUnit.HOURS): Deadline { + public static create(epochAdjustment: number, deadline = 2, chronoUnit: ChronoUnit = ChronoUnit.HOURS): Deadline { const networkTimeStamp = new Date().getTime(); const timeStampDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(networkTimeStamp), ZoneId.SYSTEM); const deadlineDateTime = timeStampDateTime.plus(deadline, chronoUnit); @@ -50,7 +50,7 @@ export class Deadline { throw new Error('deadline should be less than 24 hours'); } - return new Deadline(deadlineDateTime, nemesisEpoch); + return new Deadline(deadlineDateTime, epochAdjustment); } /** @@ -67,32 +67,32 @@ export class Deadline { * @param value * @returns {Deadline} */ - public static createFromDTO(value: string | number[], nemesisEpoch: number): Deadline { + public static createFromDTO(value: string | number[], epochAdjustment: number): Deadline { const uint64Value = 'string' === typeof value ? UInt64.fromNumericString(value) : new UInt64(value); const dateSeconds = uint64Value.compact(); - const deadline = LocalDateTime.ofInstant(Instant.ofEpochMilli(Math.round(dateSeconds + nemesisEpoch * 1000)), ZoneId.SYSTEM); - return new Deadline(deadline, nemesisEpoch); + const deadline = LocalDateTime.ofInstant(Instant.ofEpochMilli(Math.round(dateSeconds + epochAdjustment * 1000)), ZoneId.SYSTEM); + return new Deadline(deadline, epochAdjustment); } /** * @param deadline */ - private constructor(deadline: LocalDateTime, nemesisEpoch: number) { + private constructor(deadline: LocalDateTime, epochAdjustment: number) { this.value = deadline; - this.nemesisEpoch = nemesisEpoch; + this.epochAdjustment = epochAdjustment; } /** * @internal */ public toDTO(): number[] { - return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - this.nemesisEpoch * 1000).toDTO(); + return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - this.epochAdjustment * 1000).toDTO(); } /** * @internal */ public toString(): string { - return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - this.nemesisEpoch * 1000).toString(); + return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - this.epochAdjustment * 1000).toString(); } } diff --git a/src/model/transaction/LockFundsTransaction.ts b/src/model/transaction/LockFundsTransaction.ts index ed995b8ceb..20781c3f2b 100644 --- a/src/model/transaction/LockFundsTransaction.ts +++ b/src/model/transaction/LockFundsTransaction.ts @@ -134,11 +134,11 @@ export class LockFundsTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedHashLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : HashLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -148,7 +148,7 @@ export class LockFundsTransaction extends Transaction { const transaction = LockFundsTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as HashLockTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as HashLockTransactionBuilder).getDeadline().timestamp, epochAdjustment), new Mosaic(new MosaicId(builder.getMosaic().mosaicId.unresolvedMosaicId), new UInt64(builder.getMosaic().amount.amount)), new UInt64(builder.getDuration().blockDuration), new SignedTransaction('', Convert.uint8ToHex(builder.getHash().hash256), '', TransactionType.AGGREGATE_BONDED, networkType), diff --git a/src/model/transaction/MosaicAddressRestrictionTransaction.ts b/src/model/transaction/MosaicAddressRestrictionTransaction.ts index ddd08ffddc..509854125f 100644 --- a/src/model/transaction/MosaicAddressRestrictionTransaction.ts +++ b/src/model/transaction/MosaicAddressRestrictionTransaction.ts @@ -145,11 +145,11 @@ export class MosaicAddressRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -159,7 +159,7 @@ export class MosaicAddressRestrictionTransaction extends Transaction { const transaction = MosaicAddressRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicAddressRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as MosaicAddressRestrictionTransactionBuilder).getDeadline().timestamp, epochAdjustment), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), new UInt64(builder.getRestrictionKey()), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), diff --git a/src/model/transaction/MosaicAliasTransaction.ts b/src/model/transaction/MosaicAliasTransaction.ts index a5a5cba541..e2ad5f36e0 100644 --- a/src/model/transaction/MosaicAliasTransaction.ts +++ b/src/model/transaction/MosaicAliasTransaction.ts @@ -116,11 +116,11 @@ export class MosaicAliasTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -130,7 +130,7 @@ export class MosaicAliasTransaction extends Transaction { const transaction = MosaicAliasTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicAliasTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as MosaicAliasTransactionBuilder).getDeadline().timestamp, epochAdjustment), builder.getAliasAction().valueOf(), new NamespaceId(builder.getNamespaceId().namespaceId), new MosaicId(builder.getMosaicId().mosaicId), diff --git a/src/model/transaction/MosaicDefinitionTransaction.ts b/src/model/transaction/MosaicDefinitionTransaction.ts index 47dc73363f..567133de70 100644 --- a/src/model/transaction/MosaicDefinitionTransaction.ts +++ b/src/model/transaction/MosaicDefinitionTransaction.ts @@ -137,11 +137,11 @@ export class MosaicDefinitionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicDefinitionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicDefinitionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -151,7 +151,7 @@ export class MosaicDefinitionTransaction extends Transaction { const transaction = MosaicDefinitionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicDefinitionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as MosaicDefinitionTransactionBuilder).getDeadline().timestamp, epochAdjustment), MosaicNonce.createFromUint8Array(builder.getNonce().serialize()), new MosaicId(builder.getId().mosaicId), MosaicFlags.create((builder.getFlags() & 1) === 1, (builder.getFlags() & 2) === 2, (builder.getFlags() & 4) === 4), diff --git a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts index 9fdfee69c6..f6e46721f7 100644 --- a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts +++ b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts @@ -161,11 +161,11 @@ export class MosaicGlobalRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicGlobalRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicGlobalRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -175,7 +175,7 @@ export class MosaicGlobalRestrictionTransaction extends Transaction { const transaction = MosaicGlobalRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicGlobalRestrictionTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as MosaicGlobalRestrictionTransactionBuilder).getDeadline().timestamp, epochAdjustment), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), new UInt64(builder.getRestrictionKey()), new UInt64(builder.getPreviousRestrictionValue()), diff --git a/src/model/transaction/MosaicMetadataTransaction.ts b/src/model/transaction/MosaicMetadataTransaction.ts index 1203cef6fa..a6d17438fc 100644 --- a/src/model/transaction/MosaicMetadataTransaction.ts +++ b/src/model/transaction/MosaicMetadataTransaction.ts @@ -141,11 +141,11 @@ export class MosaicMetadataTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -155,7 +155,7 @@ export class MosaicMetadataTransaction extends Transaction { const transaction = MosaicMetadataTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicMetadataTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as MosaicMetadataTransactionBuilder).getDeadline().timestamp, epochAdjustment), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getTargetMosaicId().unresolvedMosaicId).toHex()), diff --git a/src/model/transaction/MosaicSupplyChangeTransaction.ts b/src/model/transaction/MosaicSupplyChangeTransaction.ts index 5e4dbc81ba..3996ded5a6 100644 --- a/src/model/transaction/MosaicSupplyChangeTransaction.ts +++ b/src/model/transaction/MosaicSupplyChangeTransaction.ts @@ -121,11 +121,11 @@ export class MosaicSupplyChangeTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicSupplyChangeTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicSupplyChangeTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -135,7 +135,7 @@ export class MosaicSupplyChangeTransaction extends Transaction { const transaction = MosaicSupplyChangeTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicSupplyChangeTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as MosaicSupplyChangeTransactionBuilder).getDeadline().timestamp, epochAdjustment), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), builder.getAction().valueOf(), new UInt64(builder.getDelta().amount), diff --git a/src/model/transaction/MultisigAccountModificationTransaction.ts b/src/model/transaction/MultisigAccountModificationTransaction.ts index a8d90aa621..0fe1c0aae1 100644 --- a/src/model/transaction/MultisigAccountModificationTransaction.ts +++ b/src/model/transaction/MultisigAccountModificationTransaction.ts @@ -131,11 +131,11 @@ export class MultisigAccountModificationTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMultisigAccountModificationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MultisigAccountModificationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -145,7 +145,10 @@ export class MultisigAccountModificationTransaction extends Transaction { const transaction = MultisigAccountModificationTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MultisigAccountModificationTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO( + (builder as MultisigAccountModificationTransactionBuilder).getDeadline().timestamp, + epochAdjustment, + ), builder.getMinApprovalDelta(), builder.getMinRemovalDelta(), builder.getAddressAdditions().map((addition) => { diff --git a/src/model/transaction/NamespaceMetadataTransaction.ts b/src/model/transaction/NamespaceMetadataTransaction.ts index 49c8683fd3..a47da0a343 100644 --- a/src/model/transaction/NamespaceMetadataTransaction.ts +++ b/src/model/transaction/NamespaceMetadataTransaction.ts @@ -138,11 +138,11 @@ export class NamespaceMetadataTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNamespaceMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NamespaceMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -152,7 +152,7 @@ export class NamespaceMetadataTransaction extends Transaction { const transaction = NamespaceMetadataTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as NamespaceMetadataTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as NamespaceMetadataTransactionBuilder).getDeadline().timestamp, epochAdjustment), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), new NamespaceId(builder.getTargetNamespaceId().namespaceId), diff --git a/src/model/transaction/NamespaceRegistrationTransaction.ts b/src/model/transaction/NamespaceRegistrationTransaction.ts index 8e5174ed1d..476a325b1b 100644 --- a/src/model/transaction/NamespaceRegistrationTransaction.ts +++ b/src/model/transaction/NamespaceRegistrationTransaction.ts @@ -174,11 +174,11 @@ export class NamespaceRegistrationTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNamespaceRegistrationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NamespaceRegistrationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -193,7 +193,7 @@ export class NamespaceRegistrationTransaction extends Transaction { ? Deadline.createEmtpy() : Deadline.createFromDTO( (builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp, - nemesisEpoch, + epochAdjustment, ), Convert.decodeHex(Convert.uint8ToHex(builder.getName())), new UInt64(builder.getDuration()!.blockDuration), @@ -207,7 +207,7 @@ export class NamespaceRegistrationTransaction extends Transaction { ? Deadline.createEmtpy() : Deadline.createFromDTO( (builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp, - nemesisEpoch, + epochAdjustment, ), Convert.decodeHex(Convert.uint8ToHex(builder.getName())), new NamespaceId(builder.getParentId()!.namespaceId), diff --git a/src/model/transaction/NodeKeyLinkTransaction.ts b/src/model/transaction/NodeKeyLinkTransaction.ts index 2a0a0ee920..5ce0d1f84e 100644 --- a/src/model/transaction/NodeKeyLinkTransaction.ts +++ b/src/model/transaction/NodeKeyLinkTransaction.ts @@ -103,11 +103,11 @@ export class NodeKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNodeKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NodeKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -117,7 +117,7 @@ export class NodeKeyLinkTransaction extends Transaction { const transaction = NodeKeyLinkTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as NodeKeyLinkTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as NodeKeyLinkTransactionBuilder).getDeadline().timestamp, epochAdjustment), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/model/transaction/SecretLockTransaction.ts b/src/model/transaction/SecretLockTransaction.ts index d60e696820..12a11ddd30 100644 --- a/src/model/transaction/SecretLockTransaction.ts +++ b/src/model/transaction/SecretLockTransaction.ts @@ -142,11 +142,11 @@ export class SecretLockTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedSecretLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : SecretLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -156,7 +156,7 @@ export class SecretLockTransaction extends Transaction { const transaction = SecretLockTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as SecretLockTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as SecretLockTransactionBuilder).getDeadline().timestamp, epochAdjustment), new Mosaic( UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaic().mosaicId.unresolvedMosaicId).toHex()), new UInt64(builder.getMosaic().amount.amount), diff --git a/src/model/transaction/SecretProofTransaction.ts b/src/model/transaction/SecretProofTransaction.ts index 28a4de0106..74cee9e65c 100644 --- a/src/model/transaction/SecretProofTransaction.ts +++ b/src/model/transaction/SecretProofTransaction.ts @@ -119,11 +119,11 @@ export class SecretProofTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedSecretProofTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : SecretProofTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -133,7 +133,7 @@ export class SecretProofTransaction extends Transaction { const transaction = SecretProofTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as SecretProofTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as SecretProofTransactionBuilder).getDeadline().timestamp, epochAdjustment), builder.getHashAlgorithm().valueOf(), Convert.uint8ToHex(builder.getSecret().hash256), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getRecipientAddress().unresolvedAddress)), diff --git a/src/model/transaction/TransferTransaction.ts b/src/model/transaction/TransferTransaction.ts index 6f25102ae5..57d5bf29bb 100644 --- a/src/model/transaction/TransferTransaction.ts +++ b/src/model/transaction/TransferTransaction.ts @@ -134,11 +134,11 @@ export class TransferTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedTransferTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : TransferTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -148,7 +148,7 @@ export class TransferTransaction extends Transaction { const transaction = TransferTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as TransferTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as TransferTransactionBuilder).getDeadline().timestamp, epochAdjustment), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getRecipientAddress().unresolvedAddress)), builder.getMosaics().map((mosaic) => { const id = new UInt64(mosaic.mosaicId.unresolvedMosaicId).toHex(); diff --git a/src/model/transaction/VotingKeyLinkTransaction.ts b/src/model/transaction/VotingKeyLinkTransaction.ts index 37b0e21977..2ee7a46f8d 100644 --- a/src/model/transaction/VotingKeyLinkTransaction.ts +++ b/src/model/transaction/VotingKeyLinkTransaction.ts @@ -121,11 +121,11 @@ export class VotingKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedVotingKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : VotingKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -135,7 +135,7 @@ export class VotingKeyLinkTransaction extends Transaction { const transaction = VotingKeyLinkTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as VotingKeyLinkTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as VotingKeyLinkTransactionBuilder).getDeadline().timestamp, epochAdjustment), Convert.uint8ToHex(builder.getLinkedPublicKey().votingKey), builder.getStartEpoch().finalizationEpoch, builder.getEndEpoch().finalizationEpoch, diff --git a/src/model/transaction/VrfKeyLinkTransaction.ts b/src/model/transaction/VrfKeyLinkTransaction.ts index d337c447d2..44177e251b 100644 --- a/src/model/transaction/VrfKeyLinkTransaction.ts +++ b/src/model/transaction/VrfKeyLinkTransaction.ts @@ -103,11 +103,11 @@ export class VrfKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} nemesisEpoch Nemesis block epoch + * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, nemesisEpoch: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedVrfKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : VrfKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -117,7 +117,7 @@ export class VrfKeyLinkTransaction extends Transaction { const transaction = VrfKeyLinkTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as VrfKeyLinkTransactionBuilder).getDeadline().timestamp, nemesisEpoch), + : Deadline.createFromDTO((builder as VrfKeyLinkTransactionBuilder).getDeadline().timestamp, epochAdjustment), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/service/AggregateTransactionService.ts b/src/service/AggregateTransactionService.ts index 86a592ffb9..60820e1a2a 100644 --- a/src/service/AggregateTransactionService.ts +++ b/src/service/AggregateTransactionService.ts @@ -47,11 +47,14 @@ export class AggregateTransactionService { /** * Check if an aggregate complete transaction has all cosignatories attached * @param signedTransaction - The signed aggregate transaction (complete) to be verified - * @param nemesisEpoch - The nemesis block epoch + * @param epochAdjustment - The nemesis block epoch * @returns {Observable} */ - public isComplete(signedTransaction: SignedTransaction, nemesisEpoch: number): Observable { - const aggregateTransaction = TransactionMapping.createFromPayload(signedTransaction.payload, nemesisEpoch) as AggregateTransaction; + public isComplete(signedTransaction: SignedTransaction, epochAdjustment: number): Observable { + const aggregateTransaction = TransactionMapping.createFromPayload( + signedTransaction.payload, + epochAdjustment, + ) as AggregateTransaction; /** * Include both initiator & cosigners */ diff --git a/test/infrastructure/Listener.spec.ts b/test/infrastructure/Listener.spec.ts index 2d4dacff49..acb00ee83e 100644 --- a/test/infrastructure/Listener.spec.ts +++ b/test/infrastructure/Listener.spec.ts @@ -43,21 +43,21 @@ describe('Listener', () => { let namespaceRepoMock: NamespaceRepository; let namespaceRepo: NamespaceRepository; - const nemesisEpoch = 1573430400; + const epochAdjustment = 1573430400; beforeEach(() => { namespaceRepoMock = mock(); namespaceRepo = instance(namespaceRepoMock); }); it('should createComplete a WebSocket instance given url parameter', () => { - const listener = new Listener('http://localhost:3000/ws', namespaceRepo, nemesisEpoch); + const listener = new Listener('http://localhost:3000/ws', namespaceRepo, epochAdjustment); expect('http://localhost:3000/ws').to.be.equal(listener.url); listener.close(); }); describe('isOpen', () => { it('should return false when listener is created and not opened', () => { - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment); expect(listener.isOpen()).to.be.false; listener.close(); }); @@ -86,7 +86,7 @@ describe('Listener', () => { code: 'error-message', }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); @@ -125,7 +125,7 @@ describe('Listener', () => { code: 'error-message', }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); @@ -170,7 +170,7 @@ describe('Listener', () => { }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); @@ -193,7 +193,7 @@ describe('Listener', () => { describe('onerror', () => { it('should reject because of wrong server url', async () => { - const listener = new Listener('https://notcorrecturl:0000', namespaceRepo, nemesisEpoch); + const listener = new Listener('https://notcorrecturl:0000', namespaceRepo, epochAdjustment); await listener .open() .then(() => { @@ -247,7 +247,7 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -292,7 +292,7 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash2).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -336,7 +336,7 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -381,7 +381,7 @@ describe('Listener', () => { const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((unconfirmedTransaction) => { reportedTransactions.push(unconfirmedTransaction); @@ -430,7 +430,7 @@ describe('Listener', () => { const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -487,7 +487,7 @@ describe('Listener', () => { }; const reportedTransactions: string[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedHash) => { reportedTransactions.push(confirmedHash); @@ -507,7 +507,7 @@ describe('Listener', () => { }; const reportedTransactions: string[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress).subscribe((confirmedHash) => { reportedTransactions.push(confirmedHash); @@ -527,7 +527,7 @@ describe('Listener', () => { }; const reportedTransactions: string[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, 'invalid!').subscribe((confirmedHash) => { reportedTransactions.push(confirmedHash); @@ -584,7 +584,7 @@ describe('Listener', () => { }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); @@ -639,7 +639,7 @@ describe('Listener', () => { }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, nemesisEpoch, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); listener.open(); diff --git a/test/infrastructure/RepositoryFactory.spec.ts b/test/infrastructure/RepositoryFactory.spec.ts index c0c75b5e3d..386473a2cd 100644 --- a/test/infrastructure/RepositoryFactory.spec.ts +++ b/test/infrastructure/RepositoryFactory.spec.ts @@ -122,7 +122,7 @@ describe('RepositoryFactory', () => { } })('http://localhost:3000', { generationHash: 'testHash', - nemesisEpoch: 1573430400, + epochAdjustment: 1573430400, }); expect(counter).to.be.equals(0); @@ -137,10 +137,10 @@ describe('RepositoryFactory', () => { }); }); - it('Should get NemesisEpoch from cache', (done) => { + it('Should get epochAdjustment from cache', (done) => { let counter = 0; const repositoryMock: NetworkRepository = mock(); - const expectedNemesisEpoch = 1573430400; + const expectedepochAdjustment = 1573430400; const body: NetworkConfigurationDTO = { network: { identifier: 'public-test', @@ -171,12 +171,12 @@ describe('RepositoryFactory', () => { }); expect(counter).to.be.equals(0); - repositoryFactory.getNemesisEpoch().subscribe((epoch) => { + repositoryFactory.getEpochAdjustment().subscribe((epoch) => { expect(counter).to.be.equals(1); - expect(epoch).to.be.equals(expectedNemesisEpoch); - repositoryFactory.getNemesisEpoch().subscribe((network) => { + expect(epoch).to.be.equals(expectedepochAdjustment); + repositoryFactory.getEpochAdjustment().subscribe((network) => { expect(counter).to.be.equals(1); - expect(network).to.be.equals(expectedNemesisEpoch); + expect(network).to.be.equals(expectedepochAdjustment); done(); }); }); @@ -205,7 +205,7 @@ describe('RepositoryFactory', () => { })('http://localhost:3000', { networkType: expectedNetworkType, generationHash: 'testHash', - nemesisEpoch: 1573430400, + epochAdjustment: 1573430400, }); expect(counter).to.be.equals(0); @@ -220,11 +220,11 @@ describe('RepositoryFactory', () => { }); }); - it('Should get NemesisEpoch from memory', (done) => { + it('Should get epochAdjustment from memory', (done) => { let counter = 0; const repositoryMock: NetworkRepository = mock(); - const expectedNemesisEpoch = 1573430400; + const expectedepochAdjustment = 1573430400; const body: NetworkConfigurationDTO = { network: { identifier: 'public-test', @@ -252,16 +252,16 @@ describe('RepositoryFactory', () => { })('http://localhost:3000', { networkType: 152, generationHash: 'testHash', - nemesisEpoch: 1573430400, + epochAdjustment: 1573430400, }); expect(counter).to.be.equals(0); - repositoryFactory.getNemesisEpoch().subscribe((networkType) => { + repositoryFactory.getEpochAdjustment().subscribe((networkType) => { expect(counter).to.be.equals(0); - expect(networkType).to.be.equals(expectedNemesisEpoch); - repositoryFactory.getNemesisEpoch().subscribe((network) => { + expect(networkType).to.be.equals(expectedepochAdjustment); + repositoryFactory.getEpochAdjustment().subscribe((network) => { expect(counter).to.be.equals(0); - expect(network).to.be.equals(expectedNemesisEpoch); + expect(network).to.be.equals(expectedepochAdjustment); done(); }); }); diff --git a/test/infrastructure/TransactionStatusHttp.spec.ts b/test/infrastructure/TransactionStatusHttp.spec.ts index 9de3e82c97..e64494ad8c 100644 --- a/test/infrastructure/TransactionStatusHttp.spec.ts +++ b/test/infrastructure/TransactionStatusHttp.spec.ts @@ -29,11 +29,11 @@ import { NIS2_URL } from '../conf/conf.spec'; describe('TransactionStatusHttp', () => { let transactionStatusRoutesApi: TransactionStatusRoutesApi; let transactionStatusHttp: TransactionStatusHttp; - const nemesisEpoch = 1573430400; + const epochAdjustment = 1573430400; before(() => { transactionStatusRoutesApi = mock(); - transactionStatusHttp = new TransactionStatusHttp(NIS2_URL, nemesisEpoch); + transactionStatusHttp = new TransactionStatusHttp(NIS2_URL, epochAdjustment); (transactionStatusHttp as object)['transactionStatusRoutesApi'] = instance(transactionStatusRoutesApi); }); From 8987599c6be5a80fdd6fd286cb122a7be6bdcaa0 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Fri, 9 Oct 2020 18:09:54 +0100 Subject: [PATCH 3/6] - Changed Deadline.valut => Deadline.adjustedValue - Restored mappings from previous commits --- e2e/infrastructure/AccountHttp.spec.ts | 23 +- e2e/infrastructure/BlockHttp.spec.ts | 5 +- e2e/infrastructure/HashLockHttp.spec.ts | 21 +- e2e/infrastructure/IntegrationTestHelper.ts | 3 +- e2e/infrastructure/Listener.spec.ts | 34 +- e2e/infrastructure/MetadataHttp.spec.ts | 19 +- e2e/infrastructure/MosaicHttp.spec.ts | 11 +- e2e/infrastructure/MultisigAccounts.spec.ts | 7 +- e2e/infrastructure/NamespaceHttp.spec.ts | 7 +- .../PersistentHarvesting.spec.ts | 12 +- e2e/infrastructure/RestrictionHttp.spec.ts | 18 +- e2e/infrastructure/SecretLockHttp.spec.ts | 4 +- e2e/infrastructure/TransactionHttp.spec.ts | 5 +- e2e/infrastructure/UnresolvedMapping.spec.ts | 28 +- e2e/service/AccountService.spec.ts | 4 +- e2e/service/BlockService.spec.ts | 4 +- .../MetadataTransactionService.spec.ts | 22 +- ...osaicRestrictionTransactionService.spec.ts | 24 +- e2e/service/TransactionService.spec.ts | 36 +- ...TransactionService_AggregateBonded.spec.ts | 25 +- src/core/utils/TransactionMapping.ts | 10 +- src/infrastructure/Http.ts | 14 +- src/infrastructure/Listener.ts | 8 +- src/infrastructure/RepositoryFactory.ts | 3 +- src/infrastructure/RepositoryFactoryHttp.ts | 11 +- src/infrastructure/TransactionHttp.ts | 96 ++---- src/infrastructure/TransactionStatusHttp.ts | 29 +- .../transaction/CreateTransactionFromDTO.ts | 60 ++-- .../CreateTransactionFromPayload.ts | 53 ++- .../AccountAddressRestrictionTransaction.ts | 5 +- .../transaction/AccountKeyLinkTransaction.ts | 5 +- .../transaction/AccountMetadataTransaction.ts | 5 +- .../AccountMosaicRestrictionTransaction.ts | 5 +- .../AccountOperationRestrictionTransaction.ts | 8 +- .../transaction/AddressAliasTransaction.ts | 5 +- src/model/transaction/AggregateTransaction.ts | 11 +- src/model/transaction/Deadline.ts | 61 ++-- src/model/transaction/LockFundsTransaction.ts | 7 +- .../MosaicAddressRestrictionTransaction.ts | 5 +- .../transaction/MosaicAliasTransaction.ts | 5 +- .../MosaicDefinitionTransaction.ts | 5 +- .../MosaicGlobalRestrictionTransaction.ts | 5 +- .../transaction/MosaicMetadataTransaction.ts | 5 +- .../MosaicSupplyChangeTransaction.ts | 5 +- .../MultisigAccountModificationTransaction.ts | 8 +- .../NamespaceMetadataTransaction.ts | 5 +- .../NamespaceRegistrationTransaction.ts | 13 +- .../transaction/NodeKeyLinkTransaction.ts | 5 +- .../transaction/SecretLockTransaction.ts | 7 +- .../transaction/SecretProofTransaction.ts | 5 +- src/model/transaction/TransferTransaction.ts | 7 +- .../transaction/VotingKeyLinkTransaction.ts | 5 +- .../transaction/VrfKeyLinkTransaction.ts | 7 +- src/service/AggregateTransactionService.ts | 8 +- test/core/utils/TransactionMapping.spec.ts | 308 ++++++++---------- .../TransactionMappingWithSignatures.spec.ts | 198 +++++------ test/infrastructure/Listener.spec.ts | 39 +-- test/infrastructure/MetadataHttp.spec.ts | 14 +- test/infrastructure/Page.spec.ts | 22 +- test/infrastructure/RepositoryFactory.spec.ts | 8 +- .../SerializeTransactionToJSON.spec.ts | 51 +-- test/infrastructure/TransactionHttp.spec.ts | 18 +- .../CreateTransactionFromDTO.spec.ts | 38 +-- test/model/account/Account.spec.ts | 10 +- test/model/message/EncryptedMessage.spec.ts | 4 +- ...sistentHarvestingDelegationMessage.spec.ts | 4 +- .../AccountKeyLinkTransaction.spec.ts | 18 +- .../AccountMetadataTransaction.spec.ts | 20 +- .../AccountRestrictionTransaction.spec.ts | 36 +- .../AddressAliasTransaction.spec.ts | 18 +- .../transaction/AggregateTransaction.spec.ts | 99 +++--- .../CosignatureTransaction.spec.ts | 16 +- test/model/transaction/Deadline.spec.ts | 41 ++- .../transaction/HashLockTransaction.spec.ts | 14 +- .../transaction/LockFundsTransaction.spec.ts | 52 +-- ...osaicAddressRestrictionTransaction.spec.ts | 14 +- .../MosaicAliasTransaction.spec.ts | 22 +- .../MosaicDefinitionTransaction.spec.ts | 20 +- ...MosaicGlobalRestrictionTransaction.spec.ts | 14 +- .../MosaicMetadataTransaction.spec.ts | 24 +- .../MosaicSupplyChangeTransaction.spec.ts | 18 +- ...isigAccountModificationTransaction.spec.ts | 22 +- .../NamespaceMetadataTransaction.spec.ts | 22 +- .../NamespaceRegistrationTransaction.spec.ts | 20 +- .../NodeKeyLinkTransaction.spec.ts | 23 +- ...istentDelegationRequestTransaction.spec.ts | 10 +- .../transaction/SecretLockTransaction.spec.ts | 34 +- .../SecretProofTransaction.spec.ts | 36 +- test/model/transaction/Transaction.spec.ts | 41 +-- .../transaction/TransactionStatus.spec.ts | 2 +- .../TransactionStatusError.spec.ts | 2 +- .../transaction/TransferTransaction.spec.ts | 58 ++-- .../VotingKeyLinkTransaction.spec.ts | 16 +- .../transaction/VrfKeyLinkTransaction.spec.ts | 21 +- .../AggregateTransactionService.spec.ts | 83 ++--- .../MetadataTransactionservice.spec.ts | 14 +- ...osaicRestrictionTransactionservice.spec.ts | 22 +- test/service/TransactionService.spec.ts | 25 +- 98 files changed, 1213 insertions(+), 1186 deletions(-) diff --git a/e2e/infrastructure/AccountHttp.spec.ts b/e2e/infrastructure/AccountHttp.spec.ts index 24cc4a2b3d..10f7674927 100644 --- a/e2e/infrastructure/AccountHttp.spec.ts +++ b/e2e/infrastructure/AccountHttp.spec.ts @@ -38,6 +38,7 @@ import { toArray, take } from 'rxjs/operators'; import { deepEqual } from 'assert'; import { Order } from '../../src/infrastructure/infrastructure'; import { AccountOrderBy } from '../../src/infrastructure/searchCriteria/AccountOrderBy'; +import { Duration } from 'js-joda'; describe('AccountHttp', () => { const helper = new IntegrationTestHelper(); @@ -56,6 +57,8 @@ describe('AccountHttp', () => { let generationHash: string; let networkType: NetworkType; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -87,7 +90,7 @@ describe('AccountHttp', () => { describe('Make sure test account is not virgin', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), @@ -104,7 +107,7 @@ describe('AccountHttp', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(9), networkType, @@ -119,7 +122,7 @@ describe('AccountHttp', () => { describe('Setup test AddressAlias', () => { it('Announce addressAliasTransaction', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, account.address, @@ -134,7 +137,7 @@ describe('AccountHttp', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -144,7 +147,7 @@ describe('AccountHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -249,7 +252,7 @@ describe('AccountHttp', () => { describe('Remove test AddressAlias', () => { it('Announce addressAliasTransaction', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Unlink, namespaceId, account.address, @@ -264,7 +267,7 @@ describe('AccountHttp', () => { describe('Restore test multisig Accounts', () => { it('Announce MultisigAccountModificationTransaction', () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), -1, 0, [], @@ -273,7 +276,7 @@ describe('AccountHttp', () => { helper.maxFee, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 0, 0, [], @@ -283,7 +286,7 @@ describe('AccountHttp', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), -1, -1, [], @@ -293,7 +296,7 @@ describe('AccountHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), diff --git a/e2e/infrastructure/BlockHttp.spec.ts b/e2e/infrastructure/BlockHttp.spec.ts index 1a51ae4209..1ebadeefe5 100644 --- a/e2e/infrastructure/BlockHttp.spec.ts +++ b/e2e/infrastructure/BlockHttp.spec.ts @@ -31,6 +31,7 @@ import { take } from 'rxjs/operators'; import { TransactionStatement } from '../../src/model/model'; import { ReceiptPaginationStreamer } from '../../src/infrastructure/paginationStreamer/ReceiptPaginationStreamer'; import { Order } from '../../src/infrastructure/infrastructure'; +import { Duration } from 'js-joda'; describe('BlockHttp', () => { const helper = new IntegrationTestHelper(); @@ -43,6 +44,8 @@ describe('BlockHttp', () => { let networkType: NetworkType; let transactionHash; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -67,7 +70,7 @@ describe('BlockHttp', () => { describe('Setup Test Data', () => { it('Announce TransferTransaction FER', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account2.address, [helper.createNetworkCurrency(1, false)], PlainMessage.create('test-message'), diff --git a/e2e/infrastructure/HashLockHttp.spec.ts b/e2e/infrastructure/HashLockHttp.spec.ts index 4ea23ebc12..40a1456a73 100644 --- a/e2e/infrastructure/HashLockHttp.spec.ts +++ b/e2e/infrastructure/HashLockHttp.spec.ts @@ -34,6 +34,7 @@ import { ChronoUnit } from 'js-joda'; import { SignedTransaction } from '../../src/model/transaction/SignedTransaction'; import { UnresolvedMosaicId } from '../../src/model/mosaic/UnresolvedMosaicId'; import { HashLockRepository } from '../../src/infrastructure/HashLockRepository'; +import { Duration } from 'js-joda'; describe('HashLockHttp', () => { const helper = new IntegrationTestHelper(); @@ -48,6 +49,8 @@ describe('HashLockHttp', () => { let generationHash: string; let networkType: NetworkType; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -68,7 +71,7 @@ describe('HashLockHttp', () => { const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), recipient, [], PlainMessage.create('test-message'), @@ -77,7 +80,7 @@ describe('HashLockHttp', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400, 2, ChronoUnit.MINUTES), + Deadline.create(epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(aggregatedTo.publicAccount)], networkType, [], @@ -92,7 +95,7 @@ describe('HashLockHttp', () => { mosaicId: UnresolvedMosaicId, ): any => { const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new Mosaic(mosaicId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -112,7 +115,7 @@ describe('HashLockHttp', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -122,7 +125,7 @@ describe('HashLockHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -190,7 +193,7 @@ describe('HashLockHttp', () => { describe('Restore test multisig Accounts', () => { it('Announce MultisigAccountModificationTransaction', () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), -1, 0, [], @@ -199,7 +202,7 @@ describe('HashLockHttp', () => { helper.maxFee, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 0, 0, [], @@ -209,7 +212,7 @@ describe('HashLockHttp', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), -1, -1, [], @@ -219,7 +222,7 @@ describe('HashLockHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), diff --git a/e2e/infrastructure/IntegrationTestHelper.ts b/e2e/infrastructure/IntegrationTestHelper.ts index 46ea5a6831..3bfd3dc31f 100644 --- a/e2e/infrastructure/IntegrationTestHelper.ts +++ b/e2e/infrastructure/IntegrationTestHelper.ts @@ -29,6 +29,7 @@ import { SignedTransaction } from '../../src/model/transaction/SignedTransaction import { Transaction } from '../../src/model/transaction/Transaction'; import { UInt64 } from '../../src/model/UInt64'; import { TransactionService } from '../../src/service/TransactionService'; +import { Duration } from 'js-joda'; export class IntegrationTestHelper { public apiUrl: string; @@ -52,7 +53,7 @@ export class IntegrationTestHelper { public service = new BootstrapService(); public config: StartParams; public startEachTime = true; - public epochAdjustment: number; + public epochAdjustment: Duration; private async startBootstrapServer(): Promise<{ accounts: string[]; apiUrl: string }> { this.config = { diff --git a/e2e/infrastructure/Listener.spec.ts b/e2e/infrastructure/Listener.spec.ts index 20fc2c8a1a..8dcea3873c 100644 --- a/e2e/infrastructure/Listener.spec.ts +++ b/e2e/infrastructure/Listener.spec.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { assert, expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { filter, mergeMap } from 'rxjs/operators'; import { TransactionRepository } from '../../src/infrastructure/TransactionRepository'; import { Account } from '../../src/model/account/Account'; @@ -47,6 +47,8 @@ describe('Listener', () => { let networkType: NetworkType; let transactionRepository: TransactionRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -71,7 +73,7 @@ describe('Listener', () => { const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), recipient, [], PlainMessage.create('test-message'), @@ -80,7 +82,7 @@ describe('Listener', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400, 2, ChronoUnit.MINUTES), + Deadline.create(epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(aggregatedTo.publicAccount)], networkType, [], @@ -95,7 +97,7 @@ describe('Listener', () => { mosaicId: UnresolvedMosaicId, ): void => { const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new Mosaic(mosaicId, UInt64.fromUint(10 * Math.pow(10, helper.networkCurrencyDivisibility))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -109,7 +111,7 @@ describe('Listener', () => { describe('Confirmed', () => { it('confirmedTransactionsGiven address signer', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('test-message'), @@ -125,7 +127,7 @@ describe('Listener', () => { it('confirmedTransactionsGiven address recipient', () => { const recipientAddress = account2.address; const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), recipientAddress, [], PlainMessage.create('test-message'), @@ -140,7 +142,7 @@ describe('Listener', () => { describe('UnConfirmed', () => { it('unconfirmedTransactionsAdded', (done) => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('test-message'), @@ -159,7 +161,7 @@ describe('Listener', () => { it('unconfirmedTransactionsRemoved', (done) => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('test-message'), @@ -180,7 +182,7 @@ describe('Listener', () => { describe('TransferTransaction', () => { it('standalone', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), cosignAccount1.address, [helper.createNetworkCurrency(10, true)], PlainMessage.create('test-message'), @@ -196,7 +198,7 @@ describe('Listener', () => { describe('MultisigAccountModificationTransaction - Create multisig account', () => { it('MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -206,7 +208,7 @@ describe('Listener', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -317,7 +319,7 @@ describe('Listener', () => { describe('MultisigAccountModificationTransaction - Restore multisig Accounts', () => { it('Restore Multisig Account', () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), -1, 0, [], @@ -325,7 +327,7 @@ describe('Listener', () => { networkType, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 0, 0, [], @@ -334,7 +336,7 @@ describe('Listener', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), -1, -1, [], @@ -343,7 +345,7 @@ describe('Listener', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), @@ -366,7 +368,7 @@ describe('Listener', () => { it('transactionStatusGiven', () => { const mosaics = [helper.createNetworkCurrency(1000000000000)]; const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account2.address, mosaics, PlainMessage.create('test-message'), diff --git a/e2e/infrastructure/MetadataHttp.spec.ts b/e2e/infrastructure/MetadataHttp.spec.ts index 3532549c4d..0bcc1d4984 100644 --- a/e2e/infrastructure/MetadataHttp.spec.ts +++ b/e2e/infrastructure/MetadataHttp.spec.ts @@ -36,6 +36,7 @@ import { MetadataType } from '../../src/model/model'; import { Order, MetadataPaginationStreamer } from '../../src/infrastructure/infrastructure'; import { deepEqual } from 'assert'; import { take, toArray } from 'rxjs/operators'; +import { Duration } from 'js-joda'; describe('MetadataHttp', () => { const helper = new IntegrationTestHelper(); @@ -47,6 +48,8 @@ describe('MetadataHttp', () => { let networkType: NetworkType; let metadataRepository: MetadataRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -72,7 +75,7 @@ describe('MetadataHttp', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -90,7 +93,7 @@ describe('MetadataHttp', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(9), networkType, @@ -105,7 +108,7 @@ describe('MetadataHttp', () => { describe('AccountMetadataTransaction', () => { it('aggregate', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(6), 23, @@ -115,7 +118,7 @@ describe('MetadataHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [accountMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -129,7 +132,7 @@ describe('MetadataHttp', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(6), mosaicId, @@ -140,7 +143,7 @@ describe('MetadataHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [mosaicMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -154,7 +157,7 @@ describe('MetadataHttp', () => { describe('NamespaceMetadataTransaction', () => { it('aggregate', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(6), namespaceId, @@ -165,7 +168,7 @@ describe('MetadataHttp', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [namespaceMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], diff --git a/e2e/infrastructure/MosaicHttp.spec.ts b/e2e/infrastructure/MosaicHttp.spec.ts index 99168a2ef1..7cae77425d 100644 --- a/e2e/infrastructure/MosaicHttp.spec.ts +++ b/e2e/infrastructure/MosaicHttp.spec.ts @@ -33,6 +33,7 @@ import { MosaicPaginationStreamer } from '../../src/infrastructure/paginationStr import { toArray, take } from 'rxjs/operators'; import { deepEqual } from 'assert'; import { TransactionGroup } from '../../src/infrastructure/TransactionGroup'; +import { Duration } from 'js-joda'; describe('MosaicHttp', () => { let mosaicId: MosaicId; @@ -44,6 +45,8 @@ describe('MosaicHttp', () => { const helper = new IntegrationTestHelper(); let networkType: NetworkType; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -70,7 +73,7 @@ describe('MosaicHttp', () => { expect(nonce.toHex()).to.be.equals('22EA84A6'); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, false), @@ -100,7 +103,7 @@ describe('MosaicHttp', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(1000), networkType, @@ -115,7 +118,7 @@ describe('MosaicHttp', () => { describe('Setup test MosaicAlias', () => { it('Announce MosaicAliasTransaction', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -189,7 +192,7 @@ describe('MosaicHttp', () => { describe('Remove test MosaicAlias', () => { it('Announce MosaicAliasTransaction', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Unlink, namespaceId, mosaicId, diff --git a/e2e/infrastructure/MultisigAccounts.spec.ts b/e2e/infrastructure/MultisigAccounts.spec.ts index a2c54e2384..a04227f644 100644 --- a/e2e/infrastructure/MultisigAccounts.spec.ts +++ b/e2e/infrastructure/MultisigAccounts.spec.ts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { Duration } from 'js-joda'; import { Account } from '../../src/model/account/Account'; import { NetworkType } from '../../src/model/network/NetworkType'; import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction'; @@ -29,6 +30,8 @@ describe('MultisigAccounts', () => { let generationHash: string; let networkType: NetworkType; + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { multisigAccount = helper.multisigAccount; @@ -47,7 +50,7 @@ describe('MultisigAccounts', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -57,7 +60,7 @@ describe('MultisigAccounts', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], diff --git a/e2e/infrastructure/NamespaceHttp.spec.ts b/e2e/infrastructure/NamespaceHttp.spec.ts index f18be2bfd2..d922bb5fa5 100644 --- a/e2e/infrastructure/NamespaceHttp.spec.ts +++ b/e2e/infrastructure/NamespaceHttp.spec.ts @@ -28,6 +28,7 @@ import { IntegrationTestHelper } from './IntegrationTestHelper'; import { NamespacePaginationStreamer } from '../../src/infrastructure/paginationStreamer/NamespacePaginationStreamer'; import { take, toArray } from 'rxjs/operators'; import { Order } from '../../src/infrastructure/infrastructure'; +import { Duration } from 'js-joda'; describe('NamespaceHttp', () => { let defaultNamespaceId: NamespaceId; @@ -37,6 +38,8 @@ describe('NamespaceHttp', () => { let generationHash: string; const helper = new IntegrationTestHelper(); + const epochAdjustment = Duration.ofSeconds(1573430400); + before(() => { return helper.start({ openListener: true }).then(() => { account = helper.account; @@ -54,7 +57,7 @@ describe('NamespaceHttp', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(1000), helper.networkType, @@ -68,7 +71,7 @@ describe('NamespaceHttp', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, account.address, diff --git a/e2e/infrastructure/PersistentHarvesting.spec.ts b/e2e/infrastructure/PersistentHarvesting.spec.ts index a677e0016b..637cc25333 100644 --- a/e2e/infrastructure/PersistentHarvesting.spec.ts +++ b/e2e/infrastructure/PersistentHarvesting.spec.ts @@ -23,6 +23,7 @@ import { AccountKeyLinkTransaction } from '../../src/model/transaction/AccountKe import { PersistentDelegationRequestTransaction } from '../../src/model/transaction/PersistentDelegationRequestTransaction'; import { VrfKeyLinkTransaction } from '../../src/model/transaction/VrfKeyLinkTransaction'; import { NodeKeyLinkTransaction } from '../../src/model/transaction/NodeKeyLinkTransaction'; +import { Duration } from 'js-joda'; describe('PersistentHarvesting', () => { const helper = new IntegrationTestHelper(); @@ -30,6 +31,9 @@ describe('PersistentHarvesting', () => { let generationHash: string; let networkType: NetworkType; let remoteAccount: Account; + + const epochAdjustment = Duration.ofSeconds(1573430400); + const vrfKeyPair = Account.createFromPrivateKey( '82798EA9A2D2D202AFCCC82C40A287780BCA3C7F7A2FD5B754832804C6BE1BAA', NetworkType.MIJIN_TEST, @@ -58,7 +62,7 @@ describe('PersistentHarvesting', () => { describe('AccountKeyLinkTransaction', () => { it('standalone', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), remoteAccount.publicKey, LinkAction.Link, networkType, @@ -73,7 +77,7 @@ describe('PersistentHarvesting', () => { describe('VrfKeyLinkTransaction', () => { it('standalone', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), vrfKeyPair.publicKey, LinkAction.Link, networkType, @@ -88,7 +92,7 @@ describe('PersistentHarvesting', () => { describe('NodeKeyLinkTransaction', () => { it('standalone', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'cfd84eca83508bbee954668e4aecca736caefa615367da76afe6985d695381db', LinkAction.Link, networkType, @@ -108,7 +112,7 @@ describe('PersistentHarvesting', () => { describe('transactions', () => { it('should create delegated harvesting transaction', () => { const tx = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), remoteAccount.privateKey, vrfKeyPair.privateKey, 'cfd84eca83508bbee954668e4aecca736caefa615367da76afe6985d695381db', diff --git a/e2e/infrastructure/RestrictionHttp.spec.ts b/e2e/infrastructure/RestrictionHttp.spec.ts index 87ef2e80c1..f0ce229df6 100644 --- a/e2e/infrastructure/RestrictionHttp.spec.ts +++ b/e2e/infrastructure/RestrictionHttp.spec.ts @@ -36,6 +36,7 @@ import { UInt64 } from '../../src/model/UInt64'; import { IntegrationTestHelper } from './IntegrationTestHelper'; import { AddressRestrictionFlag } from '../../src/model/restriction/AddressRestrictionFlag'; import { MosaicAddressRestriction } from '../../src/model/restriction/MosaicAddressRestriction'; +import { Duration } from 'js-joda'; describe('RestrictionHttp', () => { const helper = new IntegrationTestHelper(); @@ -48,6 +49,7 @@ describe('RestrictionHttp', () => { let mosaicId: MosaicId; let referenceMosaicId: MosaicId; let restrictionAccountRepository: RestrictionAccountRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -75,7 +77,7 @@ describe('RestrictionHttp', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -94,7 +96,7 @@ describe('RestrictionHttp', () => { const nonce = MosaicNonce.createRandom(); referenceMosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), nonce, referenceMosaicId, MosaicFlags.create(true, true, true), @@ -111,7 +113,7 @@ describe('RestrictionHttp', () => { describe('Setup Test AccountAddressRestriction', () => { it('Announce AccountRestrictionTransaction', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [account3.address], [], @@ -126,7 +128,7 @@ describe('RestrictionHttp', () => { describe('MosaicGlobalRestrictionTransaction - Reference', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), referenceMosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -146,7 +148,7 @@ describe('RestrictionHttp', () => { describe('MosaicGlobalRestrictionTransaction - with referenceMosaicId', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -167,7 +169,7 @@ describe('RestrictionHttp', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(60641), account3.address, @@ -177,7 +179,7 @@ describe('RestrictionHttp', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -221,7 +223,7 @@ describe('RestrictionHttp', () => { describe('Remove test AccountRestriction - Address', () => { it('Announce AccountRestrictionTransaction', () => { const addressModification = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [], [account3.address], diff --git a/e2e/infrastructure/SecretLockHttp.spec.ts b/e2e/infrastructure/SecretLockHttp.spec.ts index f78eb5976c..dd9c213577 100644 --- a/e2e/infrastructure/SecretLockHttp.spec.ts +++ b/e2e/infrastructure/SecretLockHttp.spec.ts @@ -28,6 +28,7 @@ import { SecretLockTransaction } from '../../src/model/transaction/SecretLockTra import { LockHashAlgorithm } from '../../src/model/lock/LockHashAlgorithm'; import { sha3_256 } from 'js-sha3'; import { Crypto } from '../../src/core/crypto'; +import { Duration } from 'js-joda'; describe('SecretLockHttp', () => { const helper = new IntegrationTestHelper(); @@ -37,6 +38,7 @@ describe('SecretLockHttp', () => { let generationHash: string; let networkType: NetworkType; let secret: string; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -62,7 +64,7 @@ describe('SecretLockHttp', () => { describe('Create a hash lock', () => { it('Announce SecretLockTransaction', () => { const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), helper.createNetworkCurrency(10, false), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, diff --git a/e2e/infrastructure/TransactionHttp.spec.ts b/e2e/infrastructure/TransactionHttp.spec.ts index 7c6a72e2d9..584fb819c7 100644 --- a/e2e/infrastructure/TransactionHttp.spec.ts +++ b/e2e/infrastructure/TransactionHttp.spec.ts @@ -1394,10 +1394,7 @@ describe('TransactionHttp', () => { const cosignatureSignedTransactions = [ new CosignatureSignedTransaction(signedTxBob.parentHash, signedTxBob.signature, signedTxBob.signerPublicKey), ]; - const recreatedTx = TransactionMapping.createFromPayload( - aliceSignedTransaction.payload, - helper.epochAdjustment, - ) as AggregateTransaction; + const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload) as AggregateTransaction; const signedTransaction = recreatedTx.signTransactionGivenSignatures(account, cosignatureSignedTransactions, generationHash); diff --git a/e2e/infrastructure/UnresolvedMapping.spec.ts b/e2e/infrastructure/UnresolvedMapping.spec.ts index 5c53ede6dc..1348a82cae 100644 --- a/e2e/infrastructure/UnresolvedMapping.spec.ts +++ b/e2e/infrastructure/UnresolvedMapping.spec.ts @@ -14,6 +14,7 @@ * limitations under the License. */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../src/core/format'; import { Account } from '../../src/model/account/Account'; import { PlainMessage } from '../../src/model/message/PlainMessage'; @@ -48,6 +49,7 @@ describe('Unresolved Mapping', () => { let mosaicId: MosaicId; let namespaceIdAddress: NamespaceId; let namespaceIdMosaic: NamespaceId; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -73,7 +75,7 @@ describe('Unresolved Mapping', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -92,7 +94,7 @@ describe('Unresolved Mapping', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -109,7 +111,7 @@ describe('Unresolved Mapping', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -125,7 +127,7 @@ describe('Unresolved Mapping', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceIdAddress, account.address, @@ -141,7 +143,7 @@ describe('Unresolved Mapping', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceIdMosaic, mosaicId, @@ -163,7 +165,7 @@ describe('Unresolved Mapping', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(5), namespaceIdMosaic, @@ -174,7 +176,7 @@ describe('Unresolved Mapping', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [mosaicMetadataTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -193,7 +195,7 @@ describe('Unresolved Mapping', () => { describe('MosaicGlobalRestrictionTransaction', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceIdMosaic, UInt64.fromUint(60641), UInt64.fromUint(0), @@ -215,7 +217,7 @@ describe('Unresolved Mapping', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceIdMosaic, UInt64.fromUint(60641), namespaceIdAddress, @@ -225,7 +227,7 @@ describe('Unresolved Mapping', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -245,7 +247,7 @@ describe('Unresolved Mapping', () => { describe('TransferTransaction', () => { it('standalone', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account2.address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -269,7 +271,7 @@ describe('Unresolved Mapping', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Unlink, namespaceIdAddress, account.address, @@ -289,7 +291,7 @@ describe('Unresolved Mapping', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Unlink, namespaceIdMosaic, mosaicId, diff --git a/e2e/service/AccountService.spec.ts b/e2e/service/AccountService.spec.ts index 5a5b0e4e7a..c5db172306 100644 --- a/e2e/service/AccountService.spec.ts +++ b/e2e/service/AccountService.spec.ts @@ -23,6 +23,7 @@ import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; import { AccountService } from '../../src/service/AccountService'; import { NamespaceRegistrationTransaction } from '../../src/model/transaction/NamespaceRegistrationTransaction'; import { NamespaceId } from '../../src/model/namespace/NamespaceId'; +import { Duration } from 'js-joda'; describe('AccountService', () => { const helper = new IntegrationTestHelper(); @@ -32,6 +33,7 @@ describe('AccountService', () => { let accountService: AccountService; let namespaceId: NamespaceId; const name = 'root-test-namespace-' + Math.floor(Math.random() * 10000); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -54,7 +56,7 @@ describe('AccountService', () => { describe('Create a namespace', () => { it('Announce NamespaceRegistrationTransaction', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), name, UInt64.fromUint(300000), networkType, diff --git a/e2e/service/BlockService.spec.ts b/e2e/service/BlockService.spec.ts index 851714f4f5..f826c4760c 100644 --- a/e2e/service/BlockService.spec.ts +++ b/e2e/service/BlockService.spec.ts @@ -28,6 +28,7 @@ import { BlockService } from '../../src/service/BlockService'; import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; import { TransactionGroup } from '../../src/infrastructure/TransactionGroup'; import { TransactionStatement } from '../../src/model/receipt/TransactionStatement'; +import { Duration } from 'js-joda'; describe('BlockService', () => { const helper = new IntegrationTestHelper(); @@ -39,6 +40,7 @@ describe('BlockService', () => { let blockService: BlockService; let transactionRepository: TransactionRepository; let receiptRepository: ReceiptRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -64,7 +66,7 @@ describe('BlockService', () => { describe('Create a transfer', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account2.address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), diff --git a/e2e/service/MetadataTransactionService.spec.ts b/e2e/service/MetadataTransactionService.spec.ts index 6ccf60687b..9391a395b0 100644 --- a/e2e/service/MetadataTransactionService.spec.ts +++ b/e2e/service/MetadataTransactionService.spec.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../src/core/format'; import { MetadataRepository } from '../../src/infrastructure/MetadataRepository'; import { Account } from '../../src/model/account/Account'; @@ -19,7 +20,8 @@ import { MetadataTransactionService } from '../../src/service/MetadataTransactio import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; describe('MetadataTransactionService', () => { - const deadline = Deadline.create(1573430400); + const epochAdjustment = Duration.ofSeconds(1573430400); + const deadline = Deadline.create(epochAdjustment); const key = UInt64.fromUint(Math.round(Math.random() * 10)); const newValue = 'new test value'; @@ -56,7 +58,7 @@ describe('MetadataTransactionService', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, targetAccount.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -74,7 +76,7 @@ describe('MetadataTransactionService', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(9), networkType, @@ -90,7 +92,7 @@ describe('MetadataTransactionService', () => { describe('MosaicMetadataTransaction', () => { it('aggregate', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), targetAccount.address, key, mosaicId, @@ -101,7 +103,7 @@ describe('MetadataTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [mosaicMetadataTransaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -116,7 +118,7 @@ describe('MetadataTransactionService', () => { describe('NamespaceMetadataTransaction', () => { it('aggregate', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), targetAccount.address, key, namespaceId, @@ -126,7 +128,7 @@ describe('MetadataTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [namespaceMetadataTransaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -234,7 +236,7 @@ describe('MetadataTransactionService', () => { ) .toPromise(); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -262,7 +264,7 @@ describe('MetadataTransactionService', () => { ) .toPromise(); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transaction.toAggregate(targetAccount.publicAccount)], networkType, [], @@ -290,7 +292,7 @@ describe('MetadataTransactionService', () => { ) .toPromise(); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transaction.toAggregate(targetAccount.publicAccount)], networkType, [], diff --git a/e2e/service/MosaicRestrictionTransactionService.spec.ts b/e2e/service/MosaicRestrictionTransactionService.spec.ts index c68ac04b72..a4d6b733d7 100644 --- a/e2e/service/MosaicRestrictionTransactionService.spec.ts +++ b/e2e/service/MosaicRestrictionTransactionService.spec.ts @@ -1,4 +1,5 @@ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { KeyGenerator } from '../../src/core/format/KeyGenerator'; import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository'; import { RestrictionMosaicRepository } from '../../src/infrastructure/RestrictionMosaicRepository'; @@ -24,7 +25,8 @@ import { MosaicRestrictionTransactionService } from '../../src/service/MosaicRes import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; describe('MosaicRestrictionTransactionService', () => { - const deadline = Deadline.create(1573430400); + const epochAdjustment = Duration.ofSeconds(1573430400); + const deadline = Deadline.create(epochAdjustment); const key = KeyGenerator.generateUInt64Key('TestKey'); let account: Account; let restrictionRepository: RestrictionMosaicRepository; @@ -61,7 +63,7 @@ describe('MosaicRestrictionTransactionService', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, true), @@ -78,7 +80,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('MosaicGlobalRestrictionTransaction - with referenceMosaicId', () => { it('standalone', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, key, UInt64.fromUint(0), @@ -97,7 +99,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('MosaicAddressRestrictionTransaction', () => { it('aggregate', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, key, account.address, @@ -107,7 +109,7 @@ describe('MosaicRestrictionTransactionService', () => { helper.maxFee, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [mosaicAddressRestrictionTransaction.toAggregate(account.publicAccount)], networkType, [], @@ -122,7 +124,7 @@ describe('MosaicRestrictionTransactionService', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -139,7 +141,7 @@ describe('MosaicRestrictionTransactionService', () => { it('standalone', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -155,7 +157,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('AddressAliasTransaction', () => { it('standalone', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceIdAddress, account.address, @@ -171,7 +173,7 @@ describe('MosaicRestrictionTransactionService', () => { describe('MosaicAliasTransaction', () => { it('standalone', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceIdMosaic, mosaicId, @@ -291,7 +293,7 @@ describe('MosaicRestrictionTransactionService', () => { .toPromise() .then((transaction: MosaicGlobalRestrictionTransaction) => { const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], networkType, [], @@ -311,7 +313,7 @@ describe('MosaicRestrictionTransactionService', () => { .toPromise() .then((transaction: MosaicAddressRestrictionTransaction) => { const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], networkType, [], diff --git a/e2e/service/TransactionService.spec.ts b/e2e/service/TransactionService.spec.ts index b88948d993..cd57d7f80a 100644 --- a/e2e/service/TransactionService.spec.ts +++ b/e2e/service/TransactionService.spec.ts @@ -15,6 +15,7 @@ */ import { assert, expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../src/core/format/Convert'; import { TransactionRepository } from '../../src/infrastructure/TransactionRepository'; import { Account } from '../../src/model/account/Account'; @@ -59,6 +60,7 @@ describe('TransactionService', () => { let networkType: NetworkType; let transactionService: TransactionService; let transactionRepository: TransactionRepository; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -84,7 +86,7 @@ describe('TransactionService', () => { function buildAggregateTransaction(): AggregateTransaction { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), addressAlias, [NetworkCurrencyLocal.createAbsolute(1), new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -93,7 +95,7 @@ describe('TransactionService', () => { ); // Unlink MosaicAlias const mosaicAliasTransactionUnlink = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Unlink, mosaicAlias, mosaicId, @@ -105,7 +107,7 @@ describe('TransactionService', () => { const nonce = MosaicNonce.createRandom(); newMosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), nonce, newMosaicId, MosaicFlags.create(true, true, false), @@ -116,7 +118,7 @@ describe('TransactionService', () => { ); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), newMosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(200000), @@ -126,7 +128,7 @@ describe('TransactionService', () => { // Link namespace with new MosaicId const mosaicAliasTransactionRelink = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, mosaicAlias, newMosaicId, @@ -136,7 +138,7 @@ describe('TransactionService', () => { // Use new mosaicAlias in metadata const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(5), mosaicAlias, @@ -146,7 +148,7 @@ describe('TransactionService', () => { helper.maxFee, ); return AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [ transferTransaction.toAggregate(account.publicAccount), mosaicAliasTransactionUnlink.toAggregate(account.publicAccount), @@ -170,7 +172,7 @@ describe('TransactionService', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(20), networkType, @@ -187,7 +189,7 @@ describe('TransactionService', () => { it('Announce NamespaceRegistrationTransaction', () => { const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceName, UInt64.fromUint(50), networkType, @@ -203,7 +205,7 @@ describe('TransactionService', () => { describe('Setup test AddressAlias', () => { it('Announce addressAliasTransaction', () => { const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, addressAlias, account.address, @@ -222,7 +224,7 @@ describe('TransactionService', () => { const nonce = MosaicNonce.createRandom(); mosaicId = MosaicId.createFromNonce(nonce, account.address); const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), nonce, mosaicId, MosaicFlags.create(true, true, false), @@ -241,7 +243,7 @@ describe('TransactionService', () => { describe('MosaicSupplyChangeTransaction', () => { it('standalone', () => { const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(200000), @@ -257,7 +259,7 @@ describe('TransactionService', () => { describe('Setup MosaicAlias', () => { it('Announce MosaicAliasTransaction', () => { const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, mosaicAlias, mosaicId, @@ -273,7 +275,7 @@ describe('TransactionService', () => { describe('Create Transfer with alias', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), addressAlias, [NetworkCurrencyLocal.createAbsolute(1), new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -311,7 +313,7 @@ describe('TransactionService', () => { describe('Transfer mosaic to account 3', () => { it('Announce TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account3.address, [new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -329,7 +331,7 @@ describe('TransactionService', () => { const transactions: SignedTransaction[] = []; // 1. Transfer A -> B const transaction1 = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account2.address, [new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -340,7 +342,7 @@ describe('TransactionService', () => { // 2. Transfer C -> D const transaction2 = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), cosignAccount4.address, [new Mosaic(mosaicAlias, UInt64.fromUint(1))], PlainMessage.create('test-message'), diff --git a/e2e/service/TransactionService_AggregateBonded.spec.ts b/e2e/service/TransactionService_AggregateBonded.spec.ts index d33655c424..6c777ae3b9 100644 --- a/e2e/service/TransactionService_AggregateBonded.spec.ts +++ b/e2e/service/TransactionService_AggregateBonded.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository'; import { Account } from '../../src/model/account/Account'; import { Address } from '../../src/model/account/Address'; @@ -49,6 +49,7 @@ describe('TransactionService - AggregateBonded', () => { let networkType: NetworkType; let transactionService: TransactionService; let NetworkCurrencyLocalId: MosaicId; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { return helper.start({ openListener: true }).then(() => { @@ -74,7 +75,7 @@ describe('TransactionService - AggregateBonded', () => { const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), recipient, [], PlainMessage.create('test-message'), @@ -83,7 +84,7 @@ describe('TransactionService - AggregateBonded', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400, 2, ChronoUnit.MINUTES), + Deadline.create(epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(aggregatedTo.publicAccount)], networkType, [], @@ -111,7 +112,7 @@ describe('TransactionService - AggregateBonded', () => { describe('Setup test multisig account', () => { it('Announce MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [cosignAccount1.address, cosignAccount2.address, cosignAccount3.address], @@ -121,7 +122,7 @@ describe('TransactionService - AggregateBonded', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)], networkType, [], @@ -146,7 +147,7 @@ describe('TransactionService - AggregateBonded', () => { describe('should announce transaction', () => { it('announce', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account2.address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -169,7 +170,7 @@ describe('TransactionService - AggregateBonded', () => { it('announce', async () => { const signedAggregatedTransaction = createSignedAggregatedBondTransaction(multisigAccount, account, account2.address); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, NetworkCurrencyLocal.DIVISIBILITY))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -189,7 +190,7 @@ describe('TransactionService - AggregateBonded', () => { it('announce', async () => { const signedAggregatedTransaction = createSignedAggregatedBondTransaction(multisigAccount, account, account2.address); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new Mosaic(NetworkCurrencyLocalId, UInt64.fromUint(10 * Math.pow(10, NetworkCurrencyLocal.DIVISIBILITY))), UInt64.fromUint(1000), signedAggregatedTransaction, @@ -216,7 +217,7 @@ describe('TransactionService - AggregateBonded', () => { describe('Restore test multisig Accounts', () => { it('Announce MultisigAccountModificationTransaction', async () => { const removeCosigner1 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), -1, 0, [], @@ -225,7 +226,7 @@ describe('TransactionService - AggregateBonded', () => { helper.maxFee, ); const removeCosigner2 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 0, 0, [], @@ -235,7 +236,7 @@ describe('TransactionService - AggregateBonded', () => { ); const removeCosigner3 = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), -1, -1, [], @@ -245,7 +246,7 @@ describe('TransactionService - AggregateBonded', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [ removeCosigner1.toAggregate(multisigAccount.publicAccount), removeCosigner2.toAggregate(multisigAccount.publicAccount), diff --git a/src/core/utils/TransactionMapping.ts b/src/core/utils/TransactionMapping.ts index c2e02245fa..d6ee61d2da 100644 --- a/src/core/utils/TransactionMapping.ts +++ b/src/core/utils/TransactionMapping.ts @@ -23,21 +23,19 @@ export class TransactionMapping { /** * Create transaction class from Json. * @param {object} dataJson The transaction json object. - * @param {number} epochAdjustment The nemesis block epoch. * @returns {module: model/transaction/transaction} The transaction class. */ - public static createFromDTO(dataJson: object, epochAdjustment: number): Transaction { - return CreateTransactionFromDTO(dataJson, epochAdjustment); + public static createFromDTO(dataJson: object): Transaction { + return CreateTransactionFromDTO(dataJson); } /** * Create transaction class from payload binary. * @param {string} payload The transaction binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} The transaction class. */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { - return CreateTransactionFromPayload(payload, epochAdjustment, isEmbedded); + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { + return CreateTransactionFromPayload(payload, isEmbedded); } } diff --git a/src/infrastructure/Http.ts b/src/infrastructure/Http.ts index 9a77e80fc4..f10d4fea3c 100644 --- a/src/infrastructure/Http.ts +++ b/src/infrastructure/Http.ts @@ -16,7 +16,7 @@ import { from as observableFrom, Observable, of, of as observableOf, throwError } from 'rxjs'; import { catchError, flatMap, map } from 'rxjs/operators'; -import { Configuration, NetworkRoutesApi, NodeRoutesApi, Pagination, querystring } from 'symbol-openapi-typescript-fetch-client'; +import { Configuration, NodeRoutesApi, Pagination, querystring } from 'symbol-openapi-typescript-fetch-client'; import { NetworkType } from '../model/network/NetworkType'; import { Page } from './Page'; import { RepositoryCallError } from './RepositoryCallError'; @@ -90,18 +90,6 @@ export abstract class Http { } } - createEpochAdjustmentObservable(epochAdjustment?: number | Observable): Observable { - if (epochAdjustment && epochAdjustment instanceof Observable) { - return epochAdjustment as Observable; - } else if (epochAdjustment) { - return observableOf(epochAdjustment); - } else { - return this.call(new NetworkRoutesApi(this.config()).getNetworkProperties(), (body) => - parseInt(body.network.epochAdjustment?.replace('s', '') ?? '0'), - ); - } - } - public config(): Configuration { const fetchApi = this.fetchApi || (typeof window !== 'undefined' && window.fetch.bind(window)) || fetch; return new Configuration({ basePath: this.url, fetchApi: fetchApi, queryParamsStringify: querystring }); diff --git a/src/infrastructure/Listener.ts b/src/infrastructure/Listener.ts index d38b95356b..c5ee5ab2c4 100644 --- a/src/infrastructure/Listener.ts +++ b/src/infrastructure/Listener.ts @@ -87,10 +87,6 @@ export class Listener implements IListener { * Namespace repository for resolving account alias */ private namespaceRepository: NamespaceRepository, - /** - * Nemesis block creation epoch - */ - private epochAdjustment: number, /** * WebSocket injected when using listeners in client. */ @@ -151,7 +147,7 @@ export class Listener implements IListener { this.messageSubject.next({ channelName: ListenerChannelName[channelName], channelParam: channelParam, - message: CreateTransactionFromDTO(message.data, this.epochAdjustment), + message: CreateTransactionFromDTO(message.data), }); break; case ListenerChannelName.block: @@ -169,7 +165,7 @@ export class Listener implements IListener { Address.createFromRawAddress(channelParam), message.data.hash, message.data.code, - Deadline.createFromDTO(message.data.deadline, this.epochAdjustment), + Deadline.createFromDTO(message.data.deadline), ), }); break; diff --git a/src/infrastructure/RepositoryFactory.ts b/src/infrastructure/RepositoryFactory.ts index 695afdd0a6..d106522066 100644 --- a/src/infrastructure/RepositoryFactory.ts +++ b/src/infrastructure/RepositoryFactory.ts @@ -33,6 +33,7 @@ import { TransactionRepository } from './TransactionRepository'; import { TransactionStatusRepository } from './TransactionStatusRepository'; import { HashLockRepository } from './HashLockRepository'; import { SecretLockRepository } from './SecretLockRepository'; +import { Duration } from 'js-joda'; /** * A repository factory allows clients to create repositories to access NEM Server without knowing @@ -140,5 +141,5 @@ export interface RepositoryFactory { /** * @returns nemesis block epoch */ - getEpochAdjustment(): Observable; + getEpochAdjustment(): Observable; } diff --git a/src/infrastructure/RepositoryFactoryHttp.ts b/src/infrastructure/RepositoryFactoryHttp.ts index 179530ba7d..d80c80eace 100644 --- a/src/infrastructure/RepositoryFactoryHttp.ts +++ b/src/infrastructure/RepositoryFactoryHttp.ts @@ -53,6 +53,7 @@ import { HashLockRepository } from './HashLockRepository'; import { SecretLockRepository } from './SecretLockRepository'; import { SecretLockHttp } from './SecretLockHttp'; import { HashLockHttp } from './HashLockHttp'; +import { Duration } from 'js-joda'; /** * Receipt http repository. * @@ -64,7 +65,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { private readonly websocketUrl: string; private readonly websocketInjected?: any; private readonly fetchApi?: any; - private readonly epochAdjustment: Observable; + private readonly epochAdjustment: Observable; /** * Constructor @@ -77,12 +78,12 @@ export class RepositoryFactoryHttp implements RepositoryFactory { this.fetchApi = configs?.fetchApi; this.networkType = configs?.networkType ? observableOf(configs.networkType) : networkRepo.getNetworkType().pipe(shareReplay(1)); this.epochAdjustment = configs?.epochAdjustment - ? observableOf(configs.epochAdjustment) + ? observableOf(Duration.ofSeconds(configs.epochAdjustment)) : networkRepo .getNetworkProperties() .pipe( map((property) => { - return parseInt(property.network.epochAdjustment?.replace('s', '') ?? '0'); + return Duration.ofSeconds(parseInt(property.network.epochAdjustment?.replace('s', '') ?? '0')); }), ) .pipe(shareReplay(1)); @@ -145,7 +146,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { } createTransactionRepository(): TransactionRepository { - return new TransactionHttp(this.url, this.epochAdjustment, this.fetchApi); + return new TransactionHttp(this.url, this.fetchApi); } createTransactionStatusRepository(): TransactionStatusRepository { @@ -172,7 +173,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { return new Listener(this.websocketUrl, this.createNamespaceRepository(), this.websocketInjected); } - getEpochAdjustment(): Observable { + getEpochAdjustment(): Observable { return this.epochAdjustment; } } diff --git a/src/infrastructure/TransactionHttp.ts b/src/infrastructure/TransactionHttp.ts index 4acbaab163..66027a47f5 100644 --- a/src/infrastructure/TransactionHttp.ts +++ b/src/infrastructure/TransactionHttp.ts @@ -55,23 +55,15 @@ export class TransactionHttp extends Http implements TransactionRepository { */ private blockRoutesApi: BlockRoutesApi; - /** - * @internal - * nemesis block creation epoch - */ - private readonly epochAdjustmentObservable: Observable; - /** * Constructor * @param url Base catapult-rest url - * @param epochAdjustment Nemesis block epoch * @param fetchApi fetch function to be used when performing rest requests. */ - constructor(url: string, epochAdjustment?: number | Observable, fetchApi?: any) { + constructor(url: string, fetchApi?: any) { super(url, fetchApi); this.transactionRoutesApi = new TransactionRoutesApi(this.config()); this.blockRoutesApi = new BlockRoutesApi(this.config()); - this.epochAdjustmentObservable = this.createEpochAdjustmentObservable(epochAdjustment); } /** @@ -81,13 +73,7 @@ export class TransactionHttp extends Http implements TransactionRepository { * @returns Observable */ public getTransaction(transactionId: string, transactionGroup: TransactionGroup): Observable { - return this.epochAdjustmentObservable.pipe( - mergeMap((epochAdjustment) => - this.call(this.getTransactionByGroup(transactionId, transactionGroup), (body) => - CreateTransactionFromDTO(body, epochAdjustment), - ), - ), - ); + return this.call(this.getTransactionByGroup(transactionId, transactionGroup), (body) => CreateTransactionFromDTO(body)); } /** @@ -103,34 +89,22 @@ export class TransactionHttp extends Http implements TransactionRepository { switch (transactionGroup) { case TransactionGroup.Confirmed: - return this.epochAdjustmentObservable.pipe( - mergeMap((epochAdjustment) => - this.call(this.transactionRoutesApi.getConfirmedTransactions(transactionIdsBody), (body) => - body.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO, epochAdjustment); - }), - ), - ), + return this.call(this.transactionRoutesApi.getConfirmedTransactions(transactionIdsBody), (body) => + body.map((transactionDTO) => { + return CreateTransactionFromDTO(transactionDTO); + }), ); case TransactionGroup.Unconfirmed: - return this.epochAdjustmentObservable.pipe( - mergeMap((epochAdjustment) => - this.call(this.transactionRoutesApi.getUnconfirmedTransactions(transactionIdsBody), (body) => - body.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO, epochAdjustment); - }), - ), - ), + return this.call(this.transactionRoutesApi.getUnconfirmedTransactions(transactionIdsBody), (body) => + body.map((transactionDTO) => { + return CreateTransactionFromDTO(transactionDTO); + }), ); case TransactionGroup.Partial: - return this.epochAdjustmentObservable.pipe( - mergeMap((epochAdjustment) => - this.call(this.transactionRoutesApi.getPartialTransactions(transactionIdsBody), (body) => - body.map((transactionDTO) => { - return CreateTransactionFromDTO(transactionDTO, epochAdjustment); - }), - ), - ), + return this.call(this.transactionRoutesApi.getPartialTransactions(transactionIdsBody), (body) => + body.map((transactionDTO) => { + return CreateTransactionFromDTO(transactionDTO); + }), ); } } @@ -191,27 +165,19 @@ export class TransactionHttp extends Http implements TransactionRepository { * @returns Observable */ public getTransactionEffectiveFee(transactionId: string): Observable { - return this.epochAdjustmentObservable - .pipe( - mergeMap((epochAdjustment) => - this.call(this.getTransactionByGroup(transactionId, TransactionGroup.Confirmed), (body) => - CreateTransactionFromDTO(body, epochAdjustment), - ), - ), - ) - .pipe( - mergeMap((transaction) => { - // now read block details - return this.call( - this.blockRoutesApi.getBlockByHeight((transaction.transactionInfo as TransactionInfo).height.toString()), - (blockDTO: BlockInfoDTO) => { - // @see https://nemtech.github.io/concepts/transaction.html#fees - // effective_fee = feeMultiplier x transaction::size - return blockDTO.block.feeMultiplier * transaction.size; - }, - ); - }), - ); + return this.call(this.getTransactionByGroup(transactionId, TransactionGroup.Confirmed), CreateTransactionFromDTO).pipe( + mergeMap((transaction) => { + // now read block details + return this.call( + this.blockRoutesApi.getBlockByHeight((transaction.transactionInfo as TransactionInfo).height.toString()), + (blockDTO: BlockInfoDTO) => { + // @see https://nemtech.github.io/concepts/transaction.html#fees + // effective_fee = feeMultiplier x transaction::size + return blockDTO.block.feeMultiplier * transaction.size; + }, + ); + }), + ); } /** @@ -221,12 +187,8 @@ export class TransactionHttp extends Http implements TransactionRepository { * @returns {Observable>} */ public search(criteria: TransactionSearchCriteria): Observable> { - return this.epochAdjustmentObservable.pipe( - mergeMap((epochAdjustment) => - this.call(this.searchTransactionByGroup(criteria), (body) => - super.toPage(body.pagination, body.data, (body) => CreateTransactionFromDTO(body, epochAdjustment)), - ), - ), + return this.call(this.searchTransactionByGroup(criteria), (body) => + super.toPage(body.pagination, body.data, CreateTransactionFromDTO), ); } diff --git a/src/infrastructure/TransactionStatusHttp.ts b/src/infrastructure/TransactionStatusHttp.ts index a929a3521b..094e786bc0 100644 --- a/src/infrastructure/TransactionStatusHttp.ts +++ b/src/infrastructure/TransactionStatusHttp.ts @@ -15,7 +15,6 @@ */ import { Observable } from 'rxjs'; -import { mergeMap } from 'rxjs/operators'; import { TransactionStatusDTO, TransactionStatusRoutesApi } from 'symbol-openapi-typescript-fetch-client'; import { Deadline } from '../model/transaction/Deadline'; import { TransactionStatus } from '../model/transaction/TransactionStatus'; @@ -35,12 +34,6 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo */ private transactionStatusRoutesApi: TransactionStatusRoutesApi; - /** - * @internal - * nemesis block creation epoch - */ - private readonly epochAdjustmentObservable: Observable; - /** * Constructor * @param url Base catapult-rest url @@ -50,7 +43,6 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo constructor(url: string, epochAdjustment?: number | Observable, fetchApi?: any) { super(url, fetchApi); this.transactionStatusRoutesApi = new TransactionStatusRoutesApi(this.config()); - this.epochAdjustmentObservable = this.createEpochAdjustmentObservable(epochAdjustment); } /** @@ -59,13 +51,7 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo * @returns Observable */ public getTransactionStatus(transactionHash: string): Observable { - return this.epochAdjustmentObservable.pipe( - mergeMap((epochAdjustment) => - this.call(this.transactionStatusRoutesApi.getTransactionStatus(transactionHash), (body) => - this.toTransactionStatus(body, epochAdjustment), - ), - ), - ); + return this.call(this.transactionStatusRoutesApi.getTransactionStatus(transactionHash), (body) => this.toTransactionStatus(body)); } /** @@ -77,12 +63,8 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo const transactionHashesBody = { hashes: transactionHashes, }; - return this.epochAdjustmentObservable.pipe( - mergeMap((epochAdjustment) => - this.call(this.transactionStatusRoutesApi.getTransactionStatuses(transactionHashesBody), (body) => - body.map((b) => this.toTransactionStatus(b, epochAdjustment)), - ), - ), + return this.call(this.transactionStatusRoutesApi.getTransactionStatuses(transactionHashesBody), (body) => + body.map(this.toTransactionStatus), ); } @@ -91,14 +73,13 @@ export class TransactionStatusHttp extends Http implements TransactionStatusRepo * * @internal * @param {TransactionStatusDTO} dto the TransactionStatusDTO object from rest. - * @param {number} epochAdjustment the Nemesis block epoch * @returns {TransactionStatus} a TransactionStatus model */ - private toTransactionStatus(dto: TransactionStatusDTO, epochAdjustment): TransactionStatus { + private toTransactionStatus(dto: TransactionStatusDTO): TransactionStatus { return new TransactionStatus( dto.group, dto.hash, - Deadline.createFromDTO(UInt64.fromNumericString(dto.deadline).toDTO(), epochAdjustment ?? 0), + Deadline.createFromDTO(UInt64.fromNumericString(dto.deadline).toDTO()), dto.code, dto.height ? UInt64.fromNumericString(dto.height) : undefined, ); diff --git a/src/infrastructure/transaction/CreateTransactionFromDTO.ts b/src/infrastructure/transaction/CreateTransactionFromDTO.ts index 76d52dd268..face165824 100644 --- a/src/infrastructure/transaction/CreateTransactionFromDTO.ts +++ b/src/infrastructure/transaction/CreateTransactionFromDTO.ts @@ -126,14 +126,13 @@ const extractMessage = (message: any): Message => { /** * Extract deadline from json payload. - * @param epochAdjustment Nemesis block epoch * @param deadline - deadline dto */ -const extractDeadline = (epochAdjustment: number, deadline?: string): Deadline => { +const extractDeadline = (deadline?: string): Deadline => { if (!deadline) { return Deadline.createEmtpy(); } - return Deadline.createFromDTO(deadline, epochAdjustment); + return Deadline.createFromDTO(deadline); }; /** @@ -157,16 +156,15 @@ const extractTransactionMeta = (meta: any, id: string): TransactionInfo | Aggreg * @internal * @param transactionDTO * @param transactionInfo - * @param epochAdjustment * @returns {any} * @constructor */ -const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epochAdjustment): Transaction => { +const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Transaction => { if (transactionDTO.type === TransactionType.TRANSFER) { return new TransferTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.recipientAddress), extractMosaics(transactionDTO.mosaics), @@ -181,7 +179,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new NamespaceRegistrationTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.registrationType, transactionDTO.name, @@ -198,7 +196,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new MosaicDefinitionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), MosaicNonce.createFromNumber(transactionDTO.nonce), new MosaicId(transactionDTO.id), @@ -215,7 +213,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new MosaicSupplyChangeTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.mosaicId), transactionDTO.action, @@ -230,7 +228,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new MultisigAccountModificationTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.minApprovalDelta, transactionDTO.minRemovalDelta, @@ -247,7 +245,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new LockFundsTransaction( networkType, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), new Mosaic(new MosaicId(transactionDTO.mosaicId), UInt64.fromNumericString(transactionDTO.amount)), UInt64.fromNumericString(transactionDTO.duration), @@ -262,7 +260,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new SecretLockTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), new Mosaic(mosaicId, UInt64.fromNumericString(transactionDTO.amount)), UInt64.fromNumericString(transactionDTO.duration), @@ -280,7 +278,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new SecretProofTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.hashAlgorithm, transactionDTO.secret, @@ -296,7 +294,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new MosaicAliasTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.aliasAction, NamespaceId.createFromEncoded(transactionDTO.namespaceId), @@ -311,7 +309,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new AddressAliasTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.aliasAction, NamespaceId.createFromEncoded(transactionDTO.namespaceId), @@ -326,7 +324,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new AccountAddressRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.restrictionFlags, transactionDTO.restrictionAdditions ? transactionDTO.restrictionAdditions.map((addition) => extractRecipient(addition)) : [], @@ -341,7 +339,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new AccountOperationRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.restrictionFlags, transactionDTO.restrictionAdditions ? transactionDTO.restrictionAdditions : [], @@ -356,7 +354,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new AccountMosaicRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.restrictionFlags, transactionDTO.restrictionAdditions @@ -375,7 +373,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new AccountKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.linkAction, @@ -389,7 +387,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new MosaicGlobalRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.mosaicId), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.referenceMosaicId), @@ -408,7 +406,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new MosaicAddressRestrictionTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), UnresolvedMapping.toUnresolvedMosaic(transactionDTO.mosaicId), UInt64.fromHex(transactionDTO.restrictionKey), @@ -425,7 +423,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new AccountMetadataTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.targetAddress), UInt64.fromHex(transactionDTO.scopedMetadataKey), @@ -441,7 +439,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new MosaicMetadataTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.targetAddress), UInt64.fromHex(transactionDTO.scopedMetadataKey), @@ -458,7 +456,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new NamespaceMetadataTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), extractRecipient(transactionDTO.targetAddress), UInt64.fromHex(transactionDTO.scopedMetadataKey), @@ -475,7 +473,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new VrfKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.linkAction, @@ -489,7 +487,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new NodeKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.linkAction, @@ -503,7 +501,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo return new VotingKeyLinkTransaction( transactionDTO.network, transactionDTO.version, - extractDeadline(epochAdjustment, transactionDTO.deadline), + extractDeadline(transactionDTO.deadline), UInt64.fromNumericString(transactionDTO.maxFee || '0'), transactionDTO.linkedPublicKey, transactionDTO.startEpoch, @@ -522,11 +520,10 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo, epo /** * @internal * @param transactionDTO - * @param epochAdjustment * @returns {Transaction} * @constructor */ -export const CreateTransactionFromDTO = (transactionDTO, epochAdjustment): Transaction => { +export const CreateTransactionFromDTO = (transactionDTO): Transaction => { if ( transactionDTO.transaction.type === TransactionType.AGGREGATE_COMPLETE || transactionDTO.transaction.type === TransactionType.AGGREGATE_BONDED @@ -537,14 +534,14 @@ export const CreateTransactionFromDTO = (transactionDTO, epochAdjustment): Trans innerTransactionDTO.transaction.maxFee = transactionDTO.transaction.maxFee; innerTransactionDTO.transaction.deadline = transactionDTO.transaction.deadline; innerTransactionDTO.transaction.signature = transactionDTO.transaction.signature; - return CreateStandaloneTransactionFromDTO(innerTransactionDTO.transaction, aggregateTransactionInfo, epochAdjustment); + return CreateStandaloneTransactionFromDTO(innerTransactionDTO.transaction, aggregateTransactionInfo); }) : []; return new AggregateTransaction( transactionDTO.transaction.network, transactionDTO.transaction.type, transactionDTO.transaction.version, - extractDeadline(epochAdjustment, transactionDTO.transaction.deadline), + extractDeadline(transactionDTO.transaction.deadline), UInt64.fromNumericString(transactionDTO.transaction.maxFee || '0'), innerTransactions, transactionDTO.transaction.cosignatures @@ -566,7 +563,6 @@ export const CreateTransactionFromDTO = (transactionDTO, epochAdjustment): Trans return CreateStandaloneTransactionFromDTO( transactionDTO.transaction, extractTransactionMeta(transactionDTO.meta, transactionDTO.id), - epochAdjustment, ); } }; diff --git a/src/infrastructure/transaction/CreateTransactionFromPayload.ts b/src/infrastructure/transaction/CreateTransactionFromPayload.ts index ceeedf4bac..0e6fdb54a6 100644 --- a/src/infrastructure/transaction/CreateTransactionFromPayload.ts +++ b/src/infrastructure/transaction/CreateTransactionFromPayload.ts @@ -46,68 +46,63 @@ import { VrfKeyLinkTransaction } from '../../model/transaction/VrfKeyLinkTransac /** * @internal * @param payload - The transaction binary data - * @param {number} epochAdjustment Nemesis block epoch * @param isEmbedded - Is the transaction an embedded inner transaction * @returns {Transaction | InnerTransaction} * @constructor */ -export const CreateTransactionFromPayload = ( - payload: string, - epochAdjustment: number, - isEmbedded = false, -): Transaction | InnerTransaction => { +export const CreateTransactionFromPayload = (payload: string, isEmbedded = false): Transaction | InnerTransaction => { const transactionBuilder = isEmbedded ? EmbeddedTransactionBuilder.loadFromBinary(convert.hexToUint8(payload)) : TransactionBuilder.loadFromBinary(convert.hexToUint8(payload)); const type = transactionBuilder.getType().valueOf(); switch (type) { case TransactionType.ACCOUNT_ADDRESS_RESTRICTION: - return AccountAddressRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return AccountAddressRestrictionTransaction.createFromPayload(payload, isEmbedded); case TransactionType.ACCOUNT_MOSAIC_RESTRICTION: - return AccountMosaicRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return AccountMosaicRestrictionTransaction.createFromPayload(payload, isEmbedded); case TransactionType.ACCOUNT_OPERATION_RESTRICTION: - return AccountOperationRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return AccountOperationRestrictionTransaction.createFromPayload(payload, isEmbedded); case TransactionType.ACCOUNT_KEY_LINK: - return AccountKeyLinkTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return AccountKeyLinkTransaction.createFromPayload(payload, isEmbedded); case TransactionType.ADDRESS_ALIAS: - return AddressAliasTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return AddressAliasTransaction.createFromPayload(payload, isEmbedded); case TransactionType.MOSAIC_ALIAS: - return MosaicAliasTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return MosaicAliasTransaction.createFromPayload(payload, isEmbedded); case TransactionType.MOSAIC_DEFINITION: - return MosaicDefinitionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return MosaicDefinitionTransaction.createFromPayload(payload, isEmbedded); case TransactionType.MOSAIC_SUPPLY_CHANGE: - return MosaicSupplyChangeTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return MosaicSupplyChangeTransaction.createFromPayload(payload, isEmbedded); case TransactionType.NAMESPACE_REGISTRATION: - return NamespaceRegistrationTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return NamespaceRegistrationTransaction.createFromPayload(payload, isEmbedded); case TransactionType.TRANSFER: - return TransferTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return TransferTransaction.createFromPayload(payload, isEmbedded); case TransactionType.SECRET_LOCK: - return SecretLockTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return SecretLockTransaction.createFromPayload(payload, isEmbedded); case TransactionType.SECRET_PROOF: - return SecretProofTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return SecretProofTransaction.createFromPayload(payload, isEmbedded); case TransactionType.MULTISIG_ACCOUNT_MODIFICATION: - return MultisigAccountModificationTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return MultisigAccountModificationTransaction.createFromPayload(payload, isEmbedded); case TransactionType.HASH_LOCK: - return LockFundsTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return LockFundsTransaction.createFromPayload(payload, isEmbedded); case TransactionType.MOSAIC_GLOBAL_RESTRICTION: - return MosaicGlobalRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return MosaicGlobalRestrictionTransaction.createFromPayload(payload, isEmbedded); case TransactionType.MOSAIC_ADDRESS_RESTRICTION: - return MosaicAddressRestrictionTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return MosaicAddressRestrictionTransaction.createFromPayload(payload, isEmbedded); case TransactionType.ACCOUNT_METADATA: - return AccountMetadataTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return AccountMetadataTransaction.createFromPayload(payload, isEmbedded); case TransactionType.MOSAIC_METADATA: - return MosaicMetadataTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return MosaicMetadataTransaction.createFromPayload(payload, isEmbedded); case TransactionType.NAMESPACE_METADATA: - return NamespaceMetadataTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return NamespaceMetadataTransaction.createFromPayload(payload, isEmbedded); case TransactionType.VRF_KEY_LINK: - return VrfKeyLinkTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return VrfKeyLinkTransaction.createFromPayload(payload, isEmbedded); case TransactionType.NODE_KEY_LINK: - return NodeKeyLinkTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return NodeKeyLinkTransaction.createFromPayload(payload, isEmbedded); case TransactionType.VOTING_KEY_LINK: - return VotingKeyLinkTransaction.createFromPayload(payload, epochAdjustment, isEmbedded); + return VotingKeyLinkTransaction.createFromPayload(payload, isEmbedded); case TransactionType.AGGREGATE_COMPLETE: case TransactionType.AGGREGATE_BONDED: - return AggregateTransaction.createFromPayload(payload, epochAdjustment); + return AggregateTransaction.createFromPayload(payload); default: throw new Error('Transaction type not implemented yet.'); } diff --git a/src/model/transaction/AccountAddressRestrictionTransaction.ts b/src/model/transaction/AccountAddressRestrictionTransaction.ts index 31c4033c9d..50751818ea 100644 --- a/src/model/transaction/AccountAddressRestrictionTransaction.ts +++ b/src/model/transaction/AccountAddressRestrictionTransaction.ts @@ -109,11 +109,10 @@ export class AccountAddressRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -123,7 +122,7 @@ export class AccountAddressRestrictionTransaction extends Transaction { const transaction = AccountAddressRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AccountAddressRestrictionTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as AccountAddressRestrictionTransactionBuilder).getDeadline().timestamp), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions().map((addition) => { return UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(addition.unresolvedAddress)); diff --git a/src/model/transaction/AccountKeyLinkTransaction.ts b/src/model/transaction/AccountKeyLinkTransaction.ts index 797255087e..f6a7d5e6ae 100644 --- a/src/model/transaction/AccountKeyLinkTransaction.ts +++ b/src/model/transaction/AccountKeyLinkTransaction.ts @@ -107,11 +107,10 @@ export class AccountKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -121,7 +120,7 @@ export class AccountKeyLinkTransaction extends Transaction { const transaction = AccountKeyLinkTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AccountKeyLinkTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as AccountKeyLinkTransactionBuilder).getDeadline().timestamp), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/model/transaction/AccountMetadataTransaction.ts b/src/model/transaction/AccountMetadataTransaction.ts index e7f9a2f60d..58715055c6 100644 --- a/src/model/transaction/AccountMetadataTransaction.ts +++ b/src/model/transaction/AccountMetadataTransaction.ts @@ -129,11 +129,10 @@ export class AccountMetadataTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -143,7 +142,7 @@ export class AccountMetadataTransaction extends Transaction { const transaction = AccountMetadataTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AccountMetadataTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as AccountMetadataTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), builder.getValueSizeDelta(), diff --git a/src/model/transaction/AccountMosaicRestrictionTransaction.ts b/src/model/transaction/AccountMosaicRestrictionTransaction.ts index 02dd60add9..63d8d38356 100644 --- a/src/model/transaction/AccountMosaicRestrictionTransaction.ts +++ b/src/model/transaction/AccountMosaicRestrictionTransaction.ts @@ -108,11 +108,10 @@ export class AccountMosaicRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountMosaicRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountMosaicRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -122,7 +121,7 @@ export class AccountMosaicRestrictionTransaction extends Transaction { const transaction = AccountMosaicRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AccountMosaicRestrictionTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as AccountMosaicRestrictionTransactionBuilder).getDeadline().timestamp), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions().map((addition) => { return UnresolvedMapping.toUnresolvedMosaic(new UInt64(addition.unresolvedMosaicId).toHex()); diff --git a/src/model/transaction/AccountOperationRestrictionTransaction.ts b/src/model/transaction/AccountOperationRestrictionTransaction.ts index a6bf8bb29a..41ceec7258 100644 --- a/src/model/transaction/AccountOperationRestrictionTransaction.ts +++ b/src/model/transaction/AccountOperationRestrictionTransaction.ts @@ -103,11 +103,10 @@ export class AccountOperationRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAccountOperationRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AccountOperationRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -117,10 +116,7 @@ export class AccountOperationRestrictionTransaction extends Transaction { const transaction = AccountOperationRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO( - (builder as AccountOperationRestrictionTransactionBuilder).getDeadline().timestamp, - epochAdjustment, - ), + : Deadline.createFromDTO((builder as AccountOperationRestrictionTransactionBuilder).getDeadline().timestamp), builder.getRestrictionFlags().valueOf(), builder.getRestrictionAdditions(), builder.getRestrictionDeletions(), diff --git a/src/model/transaction/AddressAliasTransaction.ts b/src/model/transaction/AddressAliasTransaction.ts index cb6ad6407b..dbf0829e4c 100644 --- a/src/model/transaction/AddressAliasTransaction.ts +++ b/src/model/transaction/AddressAliasTransaction.ts @@ -119,11 +119,10 @@ export class AddressAliasTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedAddressAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : AddressAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -133,7 +132,7 @@ export class AddressAliasTransaction extends Transaction { const transaction = AddressAliasTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as AddressAliasTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as AddressAliasTransactionBuilder).getDeadline().timestamp), builder.getAliasAction().valueOf(), new NamespaceId(builder.getNamespaceId().namespaceId), Address.createFromEncoded(Convert.uint8ToHex(builder.getAddress().address)), diff --git a/src/model/transaction/AggregateTransaction.ts b/src/model/transaction/AggregateTransaction.ts index cd371d2b51..d76843c548 100644 --- a/src/model/transaction/AggregateTransaction.ts +++ b/src/model/transaction/AggregateTransaction.ts @@ -154,10 +154,9 @@ export class AggregateTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @returns {AggregateTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number): AggregateTransaction { + public static createFromPayload(payload: string): AggregateTransaction { /** * Get transaction type from the payload hex * As buffer uses separate builder class for Complete and bonded @@ -181,9 +180,9 @@ export class AggregateTransaction extends Transaction { return type === TransactionType.AGGREGATE_COMPLETE ? AggregateTransaction.createComplete( - Deadline.createFromDTO(builder.deadline.timestamp, epochAdjustment), + Deadline.createFromDTO(builder.deadline.timestamp), innerTransactions.map((transactionRaw) => { - return CreateTransactionFromPayload(transactionRaw, 1573430400, true) as InnerTransaction; + return CreateTransactionFromPayload(transactionRaw, true) as InnerTransaction; }), networkType, consignatures, @@ -192,9 +191,9 @@ export class AggregateTransaction extends Transaction { signerPublicKey.match(`^[0]+$`) ? undefined : PublicAccount.createFromPublicKey(signerPublicKey, networkType), ) : AggregateTransaction.createBonded( - Deadline.createFromDTO(builder.deadline.timestamp, epochAdjustment), + Deadline.createFromDTO(builder.deadline.timestamp), innerTransactions.map((transactionRaw) => { - return CreateTransactionFromPayload(transactionRaw, 1573430400, true) as InnerTransaction; + return CreateTransactionFromPayload(transactionRaw, true) as InnerTransaction; }), networkType, consignatures, diff --git a/src/model/transaction/Deadline.ts b/src/model/transaction/Deadline.ts index bdde6b324d..38957cd247 100644 --- a/src/model/transaction/Deadline.ts +++ b/src/model/transaction/Deadline.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ChronoUnit, Instant, LocalDateTime, ZoneId } from 'js-joda'; +import { ChronoUnit, Duration, Instant, LocalDateTime, ZoneId } from 'js-joda'; import { UInt64 } from '../UInt64'; /** @@ -23,14 +23,9 @@ import { UInt64 } from '../UInt64'; */ export class Deadline { /** - * @type {number} + * Deadline value (without Nemesis epoch adjustment) */ - private epochAdjustment: number; - - /** - * Deadline value - */ - public value: LocalDateTime; + public adjustedValue: number; /** * Create deadline model @@ -39,18 +34,17 @@ export class Deadline { * @param chronoUnit * @returns {Deadline} */ - public static create(epochAdjustment: number, deadline = 2, chronoUnit: ChronoUnit = ChronoUnit.HOURS): Deadline { - const networkTimeStamp = new Date().getTime(); - const timeStampDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(networkTimeStamp), ZoneId.SYSTEM); - const deadlineDateTime = timeStampDateTime.plus(deadline, chronoUnit); + public static create(epochAdjustment: Duration, deadline = 2, chronoUnit: ChronoUnit = ChronoUnit.HOURS): Deadline { + const now = Instant.now(); + const deadlineDateTime = now.plus(deadline, chronoUnit); if (deadline <= 0) { throw new Error('deadline should be greater than 0'); - } else if (timeStampDateTime.plus(24, ChronoUnit.HOURS).compareTo(deadlineDateTime) !== 1) { + } else if (now.plus(24, ChronoUnit.HOURS).compareTo(deadlineDateTime) !== 1) { throw new Error('deadline should be less than 24 hours'); } - return new Deadline(deadlineDateTime, epochAdjustment); + return new Deadline(deadlineDateTime.minusMillis(epochAdjustment.toMillis()).toEpochMilli()); } /** @@ -60,39 +54,56 @@ export class Deadline { * @returns {Deadline} */ public static createEmtpy(): Deadline { - return new Deadline(LocalDateTime.MIN, 0); + return new Deadline(0); } /** * @param value * @returns {Deadline} */ - public static createFromDTO(value: string | number[], epochAdjustment: number): Deadline { + public static createFromDTO(value: string | number[]): Deadline { const uint64Value = 'string' === typeof value ? UInt64.fromNumericString(value) : new UInt64(value); - const dateSeconds = uint64Value.compact(); - const deadline = LocalDateTime.ofInstant(Instant.ofEpochMilli(Math.round(dateSeconds + epochAdjustment * 1000)), ZoneId.SYSTEM); - return new Deadline(deadline, epochAdjustment); + return new Deadline(uint64Value.compact()); } /** - * @param deadline + * Constructor + * @param adjustedValue Adjusted value. (Local datetime minus nemesis epoch adjustment) */ - private constructor(deadline: LocalDateTime, epochAdjustment: number) { - this.value = deadline; - this.epochAdjustment = epochAdjustment; + private constructor(adjustedValue: number) { + this.adjustedValue = adjustedValue; } /** * @internal */ public toDTO(): number[] { - return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - this.epochAdjustment * 1000).toDTO(); + return UInt64.fromUint(this.adjustedValue).toDTO(); } /** * @internal */ public toString(): string { - return UInt64.fromUint(this.value.atZone(ZoneId.SYSTEM).toInstant().toEpochMilli() - this.epochAdjustment * 1000).toString(); + return UInt64.fromUint(this.adjustedValue).toString(); + } + + /** + * Returns deadline as local date time. + * @param epochAdjustment the network's epoch adjustment. Defined in the network/properties. + * @returns {LocalDateTime} + */ + public toLocalDateTime(epochAdjustment: Duration): LocalDateTime { + return LocalDateTime.ofInstant(Instant.ofEpochMilli(this.adjustedValue).plusMillis(epochAdjustment.toMillis()), ZoneId.SYSTEM); + } + + /** + * Returns deadline as local date time. + * @param epochAdjustment the network's epoch adjustment. Defined in the network/properties. + * @param zoneId the Zone Id. + * @returns {LocalDateTime} + */ + public toLocalDateTimeGivenTimeZone(epochAdjustment: Duration, zoneId: ZoneId): LocalDateTime { + return LocalDateTime.ofInstant(Instant.ofEpochMilli(this.adjustedValue).plusMillis(epochAdjustment.toMillis()), zoneId); } } diff --git a/src/model/transaction/LockFundsTransaction.ts b/src/model/transaction/LockFundsTransaction.ts index 20781c3f2b..d8c56b795a 100644 --- a/src/model/transaction/LockFundsTransaction.ts +++ b/src/model/transaction/LockFundsTransaction.ts @@ -134,11 +134,10 @@ export class LockFundsTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedHashLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : HashLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -146,9 +145,7 @@ export class LockFundsTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = LockFundsTransaction.create( - isEmbedded - ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as HashLockTransactionBuilder).getDeadline().timestamp, epochAdjustment), + isEmbedded ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as HashLockTransactionBuilder).getDeadline().timestamp), new Mosaic(new MosaicId(builder.getMosaic().mosaicId.unresolvedMosaicId), new UInt64(builder.getMosaic().amount.amount)), new UInt64(builder.getDuration().blockDuration), new SignedTransaction('', Convert.uint8ToHex(builder.getHash().hash256), '', TransactionType.AGGREGATE_BONDED, networkType), diff --git a/src/model/transaction/MosaicAddressRestrictionTransaction.ts b/src/model/transaction/MosaicAddressRestrictionTransaction.ts index 509854125f..a3ac17d80d 100644 --- a/src/model/transaction/MosaicAddressRestrictionTransaction.ts +++ b/src/model/transaction/MosaicAddressRestrictionTransaction.ts @@ -145,11 +145,10 @@ export class MosaicAddressRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -159,7 +158,7 @@ export class MosaicAddressRestrictionTransaction extends Transaction { const transaction = MosaicAddressRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicAddressRestrictionTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as MosaicAddressRestrictionTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), new UInt64(builder.getRestrictionKey()), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), diff --git a/src/model/transaction/MosaicAliasTransaction.ts b/src/model/transaction/MosaicAliasTransaction.ts index e2ad5f36e0..434eafa0ea 100644 --- a/src/model/transaction/MosaicAliasTransaction.ts +++ b/src/model/transaction/MosaicAliasTransaction.ts @@ -116,11 +116,10 @@ export class MosaicAliasTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicAliasTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -130,7 +129,7 @@ export class MosaicAliasTransaction extends Transaction { const transaction = MosaicAliasTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicAliasTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as MosaicAliasTransactionBuilder).getDeadline().timestamp), builder.getAliasAction().valueOf(), new NamespaceId(builder.getNamespaceId().namespaceId), new MosaicId(builder.getMosaicId().mosaicId), diff --git a/src/model/transaction/MosaicDefinitionTransaction.ts b/src/model/transaction/MosaicDefinitionTransaction.ts index 567133de70..8b5507538a 100644 --- a/src/model/transaction/MosaicDefinitionTransaction.ts +++ b/src/model/transaction/MosaicDefinitionTransaction.ts @@ -137,11 +137,10 @@ export class MosaicDefinitionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicDefinitionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicDefinitionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -151,7 +150,7 @@ export class MosaicDefinitionTransaction extends Transaction { const transaction = MosaicDefinitionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicDefinitionTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as MosaicDefinitionTransactionBuilder).getDeadline().timestamp), MosaicNonce.createFromUint8Array(builder.getNonce().serialize()), new MosaicId(builder.getId().mosaicId), MosaicFlags.create((builder.getFlags() & 1) === 1, (builder.getFlags() & 2) === 2, (builder.getFlags() & 4) === 4), diff --git a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts index f6e46721f7..950be36259 100644 --- a/src/model/transaction/MosaicGlobalRestrictionTransaction.ts +++ b/src/model/transaction/MosaicGlobalRestrictionTransaction.ts @@ -161,11 +161,10 @@ export class MosaicGlobalRestrictionTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicGlobalRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicGlobalRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -175,7 +174,7 @@ export class MosaicGlobalRestrictionTransaction extends Transaction { const transaction = MosaicGlobalRestrictionTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicGlobalRestrictionTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as MosaicGlobalRestrictionTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), new UInt64(builder.getRestrictionKey()), new UInt64(builder.getPreviousRestrictionValue()), diff --git a/src/model/transaction/MosaicMetadataTransaction.ts b/src/model/transaction/MosaicMetadataTransaction.ts index a6d17438fc..2ca0469791 100644 --- a/src/model/transaction/MosaicMetadataTransaction.ts +++ b/src/model/transaction/MosaicMetadataTransaction.ts @@ -141,11 +141,10 @@ export class MosaicMetadataTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -155,7 +154,7 @@ export class MosaicMetadataTransaction extends Transaction { const transaction = MosaicMetadataTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicMetadataTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as MosaicMetadataTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getTargetMosaicId().unresolvedMosaicId).toHex()), diff --git a/src/model/transaction/MosaicSupplyChangeTransaction.ts b/src/model/transaction/MosaicSupplyChangeTransaction.ts index 3996ded5a6..fcafc5a2b6 100644 --- a/src/model/transaction/MosaicSupplyChangeTransaction.ts +++ b/src/model/transaction/MosaicSupplyChangeTransaction.ts @@ -121,11 +121,10 @@ export class MosaicSupplyChangeTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMosaicSupplyChangeTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MosaicSupplyChangeTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -135,7 +134,7 @@ export class MosaicSupplyChangeTransaction extends Transaction { const transaction = MosaicSupplyChangeTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as MosaicSupplyChangeTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as MosaicSupplyChangeTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaicId().unresolvedMosaicId).toHex()), builder.getAction().valueOf(), new UInt64(builder.getDelta().amount), diff --git a/src/model/transaction/MultisigAccountModificationTransaction.ts b/src/model/transaction/MultisigAccountModificationTransaction.ts index 0fe1c0aae1..690e3837a2 100644 --- a/src/model/transaction/MultisigAccountModificationTransaction.ts +++ b/src/model/transaction/MultisigAccountModificationTransaction.ts @@ -131,11 +131,10 @@ export class MultisigAccountModificationTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedMultisigAccountModificationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : MultisigAccountModificationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -145,10 +144,7 @@ export class MultisigAccountModificationTransaction extends Transaction { const transaction = MultisigAccountModificationTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO( - (builder as MultisigAccountModificationTransactionBuilder).getDeadline().timestamp, - epochAdjustment, - ), + : Deadline.createFromDTO((builder as MultisigAccountModificationTransactionBuilder).getDeadline().timestamp), builder.getMinApprovalDelta(), builder.getMinRemovalDelta(), builder.getAddressAdditions().map((addition) => { diff --git a/src/model/transaction/NamespaceMetadataTransaction.ts b/src/model/transaction/NamespaceMetadataTransaction.ts index a47da0a343..16aeebf9ba 100644 --- a/src/model/transaction/NamespaceMetadataTransaction.ts +++ b/src/model/transaction/NamespaceMetadataTransaction.ts @@ -138,11 +138,10 @@ export class NamespaceMetadataTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNamespaceMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NamespaceMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -152,7 +151,7 @@ export class NamespaceMetadataTransaction extends Transaction { const transaction = NamespaceMetadataTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as NamespaceMetadataTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as NamespaceMetadataTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getTargetAddress().unresolvedAddress)), new UInt64(builder.getScopedMetadataKey()), new NamespaceId(builder.getTargetNamespaceId().namespaceId), diff --git a/src/model/transaction/NamespaceRegistrationTransaction.ts b/src/model/transaction/NamespaceRegistrationTransaction.ts index 476a325b1b..6c890b9a71 100644 --- a/src/model/transaction/NamespaceRegistrationTransaction.ts +++ b/src/model/transaction/NamespaceRegistrationTransaction.ts @@ -174,11 +174,10 @@ export class NamespaceRegistrationTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNamespaceRegistrationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NamespaceRegistrationTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -191,10 +190,7 @@ export class NamespaceRegistrationTransaction extends Transaction { ? NamespaceRegistrationTransaction.createRootNamespace( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO( - (builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp, - epochAdjustment, - ), + : Deadline.createFromDTO((builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp), Convert.decodeHex(Convert.uint8ToHex(builder.getName())), new UInt64(builder.getDuration()!.blockDuration), networkType, @@ -205,10 +201,7 @@ export class NamespaceRegistrationTransaction extends Transaction { : NamespaceRegistrationTransaction.createSubNamespace( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO( - (builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp, - epochAdjustment, - ), + : Deadline.createFromDTO((builder as NamespaceRegistrationTransactionBuilder).getDeadline().timestamp), Convert.decodeHex(Convert.uint8ToHex(builder.getName())), new NamespaceId(builder.getParentId()!.namespaceId), networkType, diff --git a/src/model/transaction/NodeKeyLinkTransaction.ts b/src/model/transaction/NodeKeyLinkTransaction.ts index 5ce0d1f84e..31c44a8dac 100644 --- a/src/model/transaction/NodeKeyLinkTransaction.ts +++ b/src/model/transaction/NodeKeyLinkTransaction.ts @@ -103,11 +103,10 @@ export class NodeKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedNodeKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : NodeKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -117,7 +116,7 @@ export class NodeKeyLinkTransaction extends Transaction { const transaction = NodeKeyLinkTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as NodeKeyLinkTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as NodeKeyLinkTransactionBuilder).getDeadline().timestamp), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/model/transaction/SecretLockTransaction.ts b/src/model/transaction/SecretLockTransaction.ts index 12a11ddd30..ff196f3871 100644 --- a/src/model/transaction/SecretLockTransaction.ts +++ b/src/model/transaction/SecretLockTransaction.ts @@ -142,11 +142,10 @@ export class SecretLockTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedSecretLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : SecretLockTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -154,9 +153,7 @@ export class SecretLockTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = SecretLockTransaction.create( - isEmbedded - ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as SecretLockTransactionBuilder).getDeadline().timestamp, epochAdjustment), + isEmbedded ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as SecretLockTransactionBuilder).getDeadline().timestamp), new Mosaic( UnresolvedMapping.toUnresolvedMosaic(new UInt64(builder.getMosaic().mosaicId.unresolvedMosaicId).toHex()), new UInt64(builder.getMosaic().amount.amount), diff --git a/src/model/transaction/SecretProofTransaction.ts b/src/model/transaction/SecretProofTransaction.ts index 74cee9e65c..2c56586186 100644 --- a/src/model/transaction/SecretProofTransaction.ts +++ b/src/model/transaction/SecretProofTransaction.ts @@ -119,11 +119,10 @@ export class SecretProofTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedSecretProofTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : SecretProofTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -133,7 +132,7 @@ export class SecretProofTransaction extends Transaction { const transaction = SecretProofTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as SecretProofTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as SecretProofTransactionBuilder).getDeadline().timestamp), builder.getHashAlgorithm().valueOf(), Convert.uint8ToHex(builder.getSecret().hash256), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getRecipientAddress().unresolvedAddress)), diff --git a/src/model/transaction/TransferTransaction.ts b/src/model/transaction/TransferTransaction.ts index 57d5bf29bb..4cf4274a91 100644 --- a/src/model/transaction/TransferTransaction.ts +++ b/src/model/transaction/TransferTransaction.ts @@ -134,11 +134,10 @@ export class TransferTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedTransferTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : TransferTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -146,9 +145,7 @@ export class TransferTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = TransferTransaction.create( - isEmbedded - ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as TransferTransactionBuilder).getDeadline().timestamp, epochAdjustment), + isEmbedded ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as TransferTransactionBuilder).getDeadline().timestamp), UnresolvedMapping.toUnresolvedAddress(Convert.uint8ToHex(builder.getRecipientAddress().unresolvedAddress)), builder.getMosaics().map((mosaic) => { const id = new UInt64(mosaic.mosaicId.unresolvedMosaicId).toHex(); diff --git a/src/model/transaction/VotingKeyLinkTransaction.ts b/src/model/transaction/VotingKeyLinkTransaction.ts index 2ee7a46f8d..a85e876884 100644 --- a/src/model/transaction/VotingKeyLinkTransaction.ts +++ b/src/model/transaction/VotingKeyLinkTransaction.ts @@ -121,11 +121,10 @@ export class VotingKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedVotingKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : VotingKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -135,7 +134,7 @@ export class VotingKeyLinkTransaction extends Transaction { const transaction = VotingKeyLinkTransaction.create( isEmbedded ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as VotingKeyLinkTransactionBuilder).getDeadline().timestamp, epochAdjustment), + : Deadline.createFromDTO((builder as VotingKeyLinkTransactionBuilder).getDeadline().timestamp), Convert.uint8ToHex(builder.getLinkedPublicKey().votingKey), builder.getStartEpoch().finalizationEpoch, builder.getEndEpoch().finalizationEpoch, diff --git a/src/model/transaction/VrfKeyLinkTransaction.ts b/src/model/transaction/VrfKeyLinkTransaction.ts index 44177e251b..a6fd6317cb 100644 --- a/src/model/transaction/VrfKeyLinkTransaction.ts +++ b/src/model/transaction/VrfKeyLinkTransaction.ts @@ -103,11 +103,10 @@ export class VrfKeyLinkTransaction extends Transaction { /** * Create a transaction object from payload * @param {string} payload Binary payload - * @param {number} epochAdjustment Nemesis block epoch * @param {Boolean} isEmbedded Is embedded transaction (Default: false) * @returns {Transaction | InnerTransaction} */ - public static createFromPayload(payload: string, epochAdjustment: number, isEmbedded = false): Transaction | InnerTransaction { + public static createFromPayload(payload: string, isEmbedded = false): Transaction | InnerTransaction { const builder = isEmbedded ? EmbeddedVrfKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)) : VrfKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload)); @@ -115,9 +114,7 @@ export class VrfKeyLinkTransaction extends Transaction { const networkType = builder.getNetwork().valueOf(); const signature = payload.substring(16, 144); const transaction = VrfKeyLinkTransaction.create( - isEmbedded - ? Deadline.createEmtpy() - : Deadline.createFromDTO((builder as VrfKeyLinkTransactionBuilder).getDeadline().timestamp, epochAdjustment), + isEmbedded ? Deadline.createEmtpy() : Deadline.createFromDTO((builder as VrfKeyLinkTransactionBuilder).getDeadline().timestamp), Convert.uint8ToHex(builder.getLinkedPublicKey().key), builder.getLinkAction().valueOf(), networkType, diff --git a/src/service/AggregateTransactionService.ts b/src/service/AggregateTransactionService.ts index 60820e1a2a..0b11ef1625 100644 --- a/src/service/AggregateTransactionService.ts +++ b/src/service/AggregateTransactionService.ts @@ -47,14 +47,10 @@ export class AggregateTransactionService { /** * Check if an aggregate complete transaction has all cosignatories attached * @param signedTransaction - The signed aggregate transaction (complete) to be verified - * @param epochAdjustment - The nemesis block epoch * @returns {Observable} */ - public isComplete(signedTransaction: SignedTransaction, epochAdjustment: number): Observable { - const aggregateTransaction = TransactionMapping.createFromPayload( - signedTransaction.payload, - epochAdjustment, - ) as AggregateTransaction; + public isComplete(signedTransaction: SignedTransaction): Observable { + const aggregateTransaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AggregateTransaction; /** * Include both initiator & cosigners */ diff --git a/test/core/utils/TransactionMapping.spec.ts b/test/core/utils/TransactionMapping.spec.ts index 612bbb8eaf..8a61b47541 100644 --- a/test/core/utils/TransactionMapping.spec.ts +++ b/test/core/utils/TransactionMapping.spec.ts @@ -69,10 +69,12 @@ import { NodeKeyLinkTransaction } from '../../../src/model/transaction/NodeKeyLi import { AddressRestrictionFlag } from '../../../src/model/restriction/AddressRestrictionFlag'; import { OperationRestrictionFlag } from '../../../src/model/restriction/OperationRestrictionFlag'; import { MosaicRestrictionFlag } from '../../../src/model/restriction/MosaicRestrictionFlag'; +import { Duration } from 'js-joda'; describe('TransactionMapping - createFromPayload', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -80,7 +82,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -89,10 +91,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = addressRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload( - signedTransaction.payload, - 1573430400, - ) as AccountAddressRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AccountAddressRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(AddressRestrictionFlag.AllowIncomingAddress); expect((transaction.restrictionAdditions[0] as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); @@ -102,7 +101,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -111,10 +110,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload( - signedTransaction.payload, - 1573430400, - ) as AccountMosaicRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AccountMosaicRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(MosaicRestrictionFlag.AllowMosaic); expect((transaction.restrictionAdditions[0] as MosaicId).toHex()).to.be.equal(mosaicId.toHex()); expect(transaction.restrictionDeletions.length).to.be.equal(0); @@ -123,7 +119,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -132,10 +128,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = operationRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload( - signedTransaction.payload, - 1573430400, - ) as AccountOperationRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AccountOperationRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(OperationRestrictionFlag.AllowOutgoingTransactionType); expect(transaction.restrictionAdditions[0]).to.be.equal(operation); expect(transaction.restrictionDeletions.length).to.be.equal(0); @@ -145,7 +138,7 @@ describe('TransactionMapping - createFromPayload', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -154,7 +147,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = addressAliasTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as AddressAliasTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AddressAliasTransaction; expect(transaction.aliasAction).to.be.equal(AliasAction.Link); expect(transaction.namespaceId.id.lower).to.be.equal(33347626); @@ -166,7 +159,7 @@ describe('TransactionMapping - createFromPayload', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -175,7 +168,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicAliasTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicAliasTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicAliasTransaction; expect(transaction.aliasAction).to.be.equal(AliasAction.Link); expect(transaction.namespaceId.id.lower).to.be.equal(33347626); expect(transaction.namespaceId.id.higher).to.be.equal(3779697293); @@ -185,7 +178,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -196,7 +189,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; expect(transaction.duration!.lower).to.be.equal(1000); expect(transaction.duration!.higher).to.be.equal(0); @@ -208,7 +201,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -219,7 +212,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -229,7 +222,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -240,7 +233,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -250,7 +243,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -261,7 +254,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -271,7 +264,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -282,7 +275,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -293,7 +286,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -302,7 +295,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = mosaicSupplyChangeTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as MosaicSupplyChangeTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MosaicSupplyChangeTransaction; expect(transaction.action).to.be.equal(MosaicSupplyChangeAction.Increase); expect(transaction.delta.lower).to.be.equal(10); @@ -313,7 +306,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -322,7 +315,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = transferTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as TransferTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as TransferTransaction; expect(transaction.message.payload).to.be.equal('test-message'); expect(transaction.mosaics.length).to.be.equal(1); @@ -333,7 +326,7 @@ describe('TransactionMapping - createFromPayload', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SCOXVZMAZJTT4I3F7EAZYGNGR77D6WPTRFENHXQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -344,7 +337,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = secretLockTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as SecretLockTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as SecretLockTransaction; expect(transaction.mosaic.amount.equals(UInt64.fromUint(10))).to.be.equal(true); expect(transaction.duration.equals(UInt64.fromUint(100))).to.be.equal(true); @@ -356,7 +349,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), account.address, @@ -366,7 +359,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = secretProofTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as SecretProofTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as SecretProofTransaction; expect(transaction.hashAlgorithm).to.be.equal(0); expect(transaction.secret).to.be.equal('9B3155B37159DA50AA52D5967C509B410F5A36A3B1E31ECB5AC76675D79B4A5E'); expect(transaction.proof).to.be.equal(proof); @@ -375,7 +368,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -385,10 +378,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = modifyMultisigAccountTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload( - signedTransaction.payload, - 1573430400, - ) as MultisigAccountModificationTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as MultisigAccountModificationTransaction; expect(transaction.minApprovalDelta).to.be.equal(2); expect(transaction.minRemovalDelta).to.be.equal(1); @@ -402,7 +392,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -410,25 +400,25 @@ describe('TransactionMapping - createFromPayload', () => { ); const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Convert.uint8ToHex(Crypto.randomBytes(48)), 1, 3, @@ -436,13 +426,13 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -452,7 +442,7 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -461,7 +451,7 @@ describe('TransactionMapping - createFromPayload', () => { UInt64.fromUint(0), ); const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -469,7 +459,7 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -478,7 +468,7 @@ describe('TransactionMapping - createFromPayload', () => { NetworkType.MIJIN_TEST, ); const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -488,7 +478,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, new NamespaceId([2262289484, 3405110546]), new MosaicId([2262289484, 3405110546]), @@ -496,7 +486,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8('B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7')).hex(), account.address, @@ -505,7 +495,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [ transferTransaction.toAggregate(account.publicAccount), accountLinkTransaction.toAggregate(account.publicAccount), @@ -527,7 +517,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = aggregateTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as AggregateTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE); expect(transaction.innerTransactions[0].type).to.be.equal(TransactionType.TRANSFER); @@ -536,7 +526,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -544,7 +534,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -552,17 +542,17 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = aggregateTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as AggregateTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_BONDED); expect(transaction.innerTransactions[0].type).to.be.equal(TransactionType.TRANSFER); }); it('should create LockFundTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -571,7 +561,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedLockFundTransaction = lockTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedLockFundTransaction.payload, 1573430400) as LockFundsTransaction; + const transaction = TransactionMapping.createFromPayload(signedLockFundTransaction.payload) as LockFundsTransaction; deepEqual(transaction.mosaic.id.id, NetworkCurrencyLocal.NAMESPACE_ID.id); expect(transaction.mosaic.amount.compact()).to.be.equal(10000000); @@ -580,14 +570,14 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an AccountKeyLinkTransaction object with link action', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const signedTransaction = accountLinkTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as AccountKeyLinkTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as AccountKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -595,14 +585,14 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an VrfKeyLinkTransaction object with link action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const signedTransaction = vrfKeyLinkTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as VrfKeyLinkTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as VrfKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -610,14 +600,14 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an NodeKeyLinkTransaction object with link action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const signedTransaction = nodeKeyLinkTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as NodeKeyLinkTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as NodeKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -626,7 +616,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create an VotingKeyLinkTransaction object with link action', () => { const key = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), key, 1, 3, @@ -635,7 +625,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const signedTransaction = votingKeyLinkTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as VotingKeyLinkTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as VotingKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.startEpoch.toString()).to.be.equal('1'); @@ -645,7 +635,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -653,7 +643,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = registerNamespaceTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as NamespaceRegistrationTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as NamespaceRegistrationTransaction; expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.RootNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); @@ -661,7 +651,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -669,7 +659,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTransaction = registerNamespaceTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTransaction.payload, 1573430400) as NamespaceRegistrationTransaction; + const transaction = TransactionMapping.createFromPayload(signedTransaction.payload) as NamespaceRegistrationTransaction; expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.SubNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); @@ -677,7 +667,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -689,7 +679,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = mosaicGlobalRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as MosaicGlobalRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload) as MosaicGlobalRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_GLOBAL_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new MosaicId(UInt64.fromUint(1).toDTO()).toHex()); @@ -703,7 +693,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicAddressRestrictionTransaction', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), account.address, @@ -714,7 +704,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = mosaicAddressRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as MosaicAddressRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new MosaicId(UInt64.fromUint(1).toDTO()).toHex()); @@ -726,7 +716,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicAddressRestrictionTransaction - MosaicAlias', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -737,7 +727,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = mosaicAddressRestrictionTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as MosaicAddressRestrictionTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new NamespaceId('test').toHex()); @@ -750,7 +740,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create AddressMetadataTransaction', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -759,7 +749,7 @@ describe('TransactionMapping - createFromPayload', () => { ); const signedTx = accountMetadataTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as AccountMetadataTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload) as AccountMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -770,7 +760,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -781,7 +771,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = mosaicMetadataTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as MosaicMetadataTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload) as MosaicMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -793,7 +783,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should create NamespaceMetadataTransaction', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -804,7 +794,7 @@ describe('TransactionMapping - createFromPayload', () => { const signedTx = namespaceMetadataTransaction.signWith(account, generationHash); - const transaction = TransactionMapping.createFromPayload(signedTx.payload, 1573430400) as NamespaceMetadataTransaction; + const transaction = TransactionMapping.createFromPayload(signedTx.payload) as NamespaceMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -816,7 +806,7 @@ describe('TransactionMapping - createFromPayload', () => { it('should throw error with invalid type', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -827,7 +817,7 @@ describe('TransactionMapping - createFromPayload', () => { const wrongType = signedTransaction.payload.substring(0, 219) + '0000' + signedTransaction.payload.substring(224); expect(() => { - TransactionMapping.createFromPayload(wrongType, 1573430400) as TransferTransaction; + TransactionMapping.createFromPayload(wrongType) as TransferTransaction; }).to.throw(); }); }); @@ -835,20 +825,21 @@ describe('TransactionMapping - createFromPayload', () => { describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should create TransferTransaction - Address', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON(), 1573430400) as TransferTransaction; + const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON()) as TransferTransaction; expect((transaction.recipientAddress as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); expect(transaction.message.payload).to.be.equal('test-message'); @@ -856,14 +847,14 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create TransferTransaction - NamespaceId', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new NamespaceId([33347626, 3779697293]), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON(), 1573430400) as TransferTransaction; + const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON()) as TransferTransaction; expect((transaction.recipientAddress as NamespaceId).id.toHex().toUpperCase()).to.be.equal( new UInt64([33347626, 3779697293]).toHex(), ); @@ -872,14 +863,14 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create TransferTransaction - Encrypted Message', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], new EncryptedMessage('12324556'), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON(), 1573430400) as TransferTransaction; + const transaction = TransactionMapping.createFromDTO(transferTransaction.toJSON()) as TransferTransaction; expect((transaction.recipientAddress as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); expect(transaction.message.type).to.be.equal(MessageType.EncryptedMessage); @@ -887,13 +878,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountKeyLinkTransaction', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(accountLinkTransaction.toJSON(), 1573430400) as AccountKeyLinkTransaction; + const transaction = TransactionMapping.createFromDTO(accountLinkTransaction.toJSON()) as AccountKeyLinkTransaction; expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); expect(transaction.linkAction).to.be.equal(LinkAction.Link); @@ -901,13 +892,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create VrfKeyLinkTransaction', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(vrfKeyLinkTransaction.toJSON(), 1573430400) as VrfKeyLinkTransaction; + const transaction = TransactionMapping.createFromDTO(vrfKeyLinkTransaction.toJSON()) as VrfKeyLinkTransaction; expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); expect(transaction.linkAction).to.be.equal(LinkAction.Link); @@ -915,13 +906,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NodeKeyLinkTransaction', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(nodeKeyLinkTransaction.toJSON(), 1573430400) as NodeKeyLinkTransaction; + const transaction = TransactionMapping.createFromDTO(nodeKeyLinkTransaction.toJSON()) as NodeKeyLinkTransaction; expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); expect(transaction.linkAction).to.be.equal(LinkAction.Link); @@ -930,7 +921,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create VotingKeyLinkTransaction', () => { const key = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), key, 1, 3, @@ -938,7 +929,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(votingKeyLinkTransaction.toJSON(), 1573430400) as VotingKeyLinkTransaction; + const transaction = TransactionMapping.createFromDTO(votingKeyLinkTransaction.toJSON()) as VotingKeyLinkTransaction; expect(transaction.linkedPublicKey).to.be.equal(key); expect(transaction.startEpoch.toString()).to.be.equal('1'); @@ -948,7 +939,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -957,7 +948,6 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( addressRestrictionTransaction.toJSON(), - 1573430400, ) as AccountAddressRestrictionTransaction; expect((transaction.restrictionAdditions[0] as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); @@ -968,17 +958,14 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO( - mosaicRestrictionTransaction.toJSON(), - 1573430400, - ) as AccountMosaicRestrictionTransaction; + const transaction = TransactionMapping.createFromDTO(mosaicRestrictionTransaction.toJSON()) as AccountMosaicRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_MOSAIC_RESTRICTION); expect(transaction.restrictionFlags).to.be.equal(MosaicRestrictionFlag.AllowMosaic); @@ -988,7 +975,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -997,7 +984,6 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( operationRestrictionTransaction.toJSON(), - 1573430400, ) as AccountMosaicRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_OPERATION_RESTRICTION); @@ -1009,14 +995,14 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(addressAliasTransaction.toJSON(), 1573430400) as AddressAliasTransaction; + const transaction = TransactionMapping.createFromDTO(addressAliasTransaction.toJSON()) as AddressAliasTransaction; expect(transaction.type).to.be.equal(TransactionType.ADDRESS_ALIAS); expect(transaction.aliasAction).to.be.equal(AliasAction.Link); @@ -1026,13 +1012,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(mosaicAliasTransaction.toJSON(), 1573430400) as MosaicAliasTransaction; + const transaction = TransactionMapping.createFromDTO(mosaicAliasTransaction.toJSON()) as MosaicAliasTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ALIAS); expect(transaction.aliasAction).to.be.equal(AliasAction.Link); @@ -1040,7 +1026,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -1049,10 +1035,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO( - mosaicDefinitionTransaction.toJSON(), - 1573430400, - ) as MosaicDefinitionTransaction; + const transaction = TransactionMapping.createFromDTO(mosaicDefinitionTransaction.toJSON()) as MosaicDefinitionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_DEFINITION); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -1064,17 +1047,14 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO( - mosaicSupplyChangeTransaction.toJSON(), - 1573430400, - ) as MosaicSupplyChangeTransaction; + const transaction = TransactionMapping.createFromDTO(mosaicSupplyChangeTransaction.toJSON()) as MosaicSupplyChangeTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_SUPPLY_CHANGE); expect(transaction.action).to.be.equal(MosaicSupplyChangeAction.Increase); @@ -1084,7 +1064,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SCOXVZMAZJTT4I3F7EAZYGNGR77D6WPTRFENHXQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1093,7 +1073,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON(), 1573430400) as SecretLockTransaction; + const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON()) as SecretLockTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_LOCK); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1103,7 +1083,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1112,7 +1092,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON(), 1573430400) as SecretLockTransaction; + const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON()) as SecretLockTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_LOCK); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1123,7 +1103,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SCOXVZMAZJTT4I3F7EAZYGNGR77D6WPTRFENHXQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new Mosaic(new MosaicId([1, 1]), UInt64.fromUint(10)), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -1132,7 +1112,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON(), 1573430400) as SecretLockTransaction; + const transaction = TransactionMapping.createFromDTO(secretLockTransaction.toJSON()) as SecretLockTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_LOCK); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1142,7 +1122,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), account.address, @@ -1150,7 +1130,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretProofTransaction.toJSON(), 1573430400) as SecretProofTransaction; + const transaction = TransactionMapping.createFromDTO(secretProofTransaction.toJSON()) as SecretProofTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_PROOF); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1163,7 +1143,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), recipientAddress, @@ -1171,7 +1151,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(secretProofTransaction.toJSON(), 1573430400) as SecretProofTransaction; + const transaction = TransactionMapping.createFromDTO(secretProofTransaction.toJSON()) as SecretProofTransaction; expect(transaction.type).to.be.equal(TransactionType.SECRET_PROOF); expect(transaction.hashAlgorithm).to.be.equal(LockHashAlgorithm.Op_Sha3_256); @@ -1182,7 +1162,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -1192,7 +1172,6 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( modifyMultisigAccountTransaction.toJSON(), - 1573430400, ) as MultisigAccountModificationTransaction; expect(transaction.type).to.be.equal(TransactionType.MULTISIG_ACCOUNT_MODIFICATION); @@ -1202,7 +1181,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -1210,13 +1189,13 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); - const transaction = TransactionMapping.createFromDTO(aggregateTransaction.toJSON(), 1573430400) as AggregateTransaction; + const transaction = TransactionMapping.createFromDTO(aggregateTransaction.toJSON()) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE); expect(transaction.innerTransactions.length).to.be.equal(1); @@ -1224,7 +1203,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -1232,30 +1211,30 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); - const transaction = TransactionMapping.createFromDTO(aggregateTransaction.toJSON(), 1573430400) as AggregateTransaction; + const transaction = TransactionMapping.createFromDTO(aggregateTransaction.toJSON()) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_BONDED); expect(transaction.innerTransactions.length).to.be.equal(1); }); it('should create LockFundTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(lockTransaction.toJSON(), 1573430400) as LockFundsTransaction; + const transaction = TransactionMapping.createFromDTO(lockTransaction.toJSON()) as LockFundsTransaction; expect(transaction.type).to.be.equal(TransactionType.HASH_LOCK); expect(transaction.hash).to.be.equal(signedTransaction.hash); @@ -1263,38 +1242,32 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO( - registerNamespaceTransaction.toJSON(), - 1573430400, - ) as NamespaceRegistrationTransaction; + const transaction = TransactionMapping.createFromDTO(registerNamespaceTransaction.toJSON()) as NamespaceRegistrationTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_REGISTRATION); }); it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO( - registerNamespaceTransaction.toJSON(), - 1573430400, - ) as NamespaceRegistrationTransaction; + const transaction = TransactionMapping.createFromDTO(registerNamespaceTransaction.toJSON()) as NamespaceRegistrationTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_REGISTRATION); }); it('should create MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -1306,7 +1279,6 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( mosaicGlobalRestrictionTransaction.toJSON(), - 1573430400, ) as MosaicGlobalRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_GLOBAL_RESTRICTION); @@ -1321,7 +1293,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicAddressRestrictionTransaction', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), account.address, @@ -1332,7 +1304,6 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => const transaction = TransactionMapping.createFromDTO( mosaicAddressRestrictionTransaction.toJSON(), - 1573430400, ) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); @@ -1345,7 +1316,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create AddressMetadataTransaction', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -1353,7 +1324,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(accountMetadataTransaction.toJSON(), 1573430400) as AccountMetadataTransaction; + const transaction = TransactionMapping.createFromDTO(accountMetadataTransaction.toJSON()) as AccountMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -1364,7 +1335,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -1373,7 +1344,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO(mosaicMetadataTransaction.toJSON(), 1573430400) as MosaicMetadataTransaction; + const transaction = TransactionMapping.createFromDTO(mosaicMetadataTransaction.toJSON()) as MosaicMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -1385,7 +1356,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => it('should create NamespaceMetadataTransaction', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -1394,10 +1365,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => NetworkType.MIJIN_TEST, ); - const transaction = TransactionMapping.createFromDTO( - namespaceMetadataTransaction.toJSON(), - 1573430400, - ) as NamespaceMetadataTransaction; + const transaction = TransactionMapping.createFromDTO(namespaceMetadataTransaction.toJSON()) as NamespaceMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; diff --git a/test/core/utils/TransactionMappingWithSignatures.spec.ts b/test/core/utils/TransactionMappingWithSignatures.spec.ts index 75c7d30844..1bd8cd4ee7 100644 --- a/test/core/utils/TransactionMappingWithSignatures.spec.ts +++ b/test/core/utils/TransactionMappingWithSignatures.spec.ts @@ -66,6 +66,7 @@ import { NodeKeyLinkTransaction } from '../../../src/model/transaction/NodeKeyLi import { AddressRestrictionFlag } from '../../../src/model/restriction/AddressRestrictionFlag'; import { MosaicRestrictionFlag } from '../../../src/model/restriction/MosaicRestrictionFlag'; import { OperationRestrictionFlag } from '../../../src/model/restriction/OperationRestrictionFlag'; +import { Duration } from 'js-joda'; describe('TransactionMapping - createFromPayload with optional sigature and signer', () => { let account: Account; @@ -73,6 +74,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const testSignature = '4CBA582B4C898FD6D218499251FE8EE1214D3715545023123F70D25389D577A96E74C1FCD07FF8F0D678A4DA5CAD8CCB173DDD9F7975A6985ADCD7AD625B170F'; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -80,7 +82,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -91,7 +93,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = addressRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountAddressRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountAddressRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(AddressRestrictionFlag.AllowIncomingAddress); expect((transaction.restrictionAdditions[0] as Address).plain()).to.be.equal('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); @@ -102,7 +104,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(addressRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = addressRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountAddressRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountAddressRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -110,7 +112,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -122,7 +124,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountMosaicRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountMosaicRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(MosaicRestrictionFlag.AllowMosaic); expect((transaction.restrictionAdditions[0] as MosaicId).toHex()).to.be.equal(mosaicId.toHex()); expect(transaction.restrictionDeletions.length).to.be.equal(0); @@ -132,7 +134,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountMosaicRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountMosaicRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -140,7 +142,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -152,7 +154,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = operationRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountOperationRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountOperationRestrictionTransaction; expect(transaction.restrictionFlags).to.be.equal(OperationRestrictionFlag.AllowOutgoingTransactionType); expect(transaction.restrictionAdditions[0]).to.be.equal(operation); expect(transaction.restrictionDeletions.length).to.be.equal(0); @@ -163,7 +165,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(operationRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = operationRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountOperationRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountOperationRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -172,7 +174,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -184,7 +186,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = addressAliasTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AddressAliasTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as AddressAliasTransaction; expect(transaction.aliasAction).to.be.equal(AliasAction.Link); expect(transaction.namespaceId.id.lower).to.be.equal(33347626); @@ -196,7 +198,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(addressAliasTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = addressAliasTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AddressAliasTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as AddressAliasTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -205,7 +207,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -217,7 +219,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicAliasTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAliasTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAliasTransaction; expect(transaction.aliasAction).to.be.equal(AliasAction.Link); expect(transaction.namespaceId.id.lower).to.be.equal(33347626); expect(transaction.namespaceId.id.higher).to.be.equal(3779697293); @@ -229,14 +231,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicAliasTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicAliasTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAliasTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAliasTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -250,7 +252,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicDefinitionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicDefinitionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicDefinitionTransaction; expect(transaction.duration!.lower).to.be.equal(1000); expect(transaction.duration!.higher).to.be.equal(0); @@ -264,14 +266,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicDefinitionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicDefinitionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicDefinitionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicDefinitionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicDefinitionTransaction - without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -285,7 +287,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicDefinitionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicDefinitionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicDefinitionTransaction; expect(transaction.divisibility).to.be.equal(3); expect(transaction.flags.supplyMutable).to.be.equal(false); @@ -297,7 +299,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicDefinitionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicDefinitionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicDefinitionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicDefinitionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -305,7 +307,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -317,7 +319,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicSupplyChangeTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicSupplyChangeTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicSupplyChangeTransaction; expect(transaction.action).to.be.equal(MosaicSupplyChangeAction.Increase); expect(transaction.delta.lower).to.be.equal(10); @@ -330,14 +332,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicSupplyChangeTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicSupplyChangeTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicSupplyChangeTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicSupplyChangeTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -349,7 +351,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = transferTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as TransferTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as TransferTransaction; expect(transaction.message.payload).to.be.equal('test-message'); expect(transaction.mosaics.length).to.be.equal(1); @@ -360,7 +362,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(transferTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = transferTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as TransferTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as TransferTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -369,7 +371,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -383,7 +385,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = secretLockTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as SecretLockTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as SecretLockTransaction; expect(transaction.mosaic.amount.equals(UInt64.fromUint(10))).to.be.equal(true); expect(transaction.duration.equals(UInt64.fromUint(100))).to.be.equal(true); @@ -396,7 +398,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(secretLockTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = secretLockTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as SecretLockTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as SecretLockTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -404,7 +406,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8(proof)).hex(), account.address, @@ -417,7 +419,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = secretProofTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as SecretProofTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as SecretProofTransaction; expect(transaction.hashAlgorithm).to.be.equal(0); expect(transaction.secret).to.be.equal('9B3155B37159DA50AA52D5967C509B410F5A36A3B1E31ECB5AC76675D79B4A5E'); expect(transaction.proof).to.be.equal(proof); @@ -428,14 +430,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(secretProofTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = secretProofTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as SecretProofTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as SecretProofTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -448,7 +450,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = modifyMultisigAccountTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MultisigAccountModificationTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as MultisigAccountModificationTransaction; expect(transaction.minApprovalDelta).to.be.equal(2); expect(transaction.minRemovalDelta).to.be.equal(1); @@ -464,14 +466,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(modifyMultisigAccountTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = modifyMultisigAccountTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MultisigAccountModificationTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as MultisigAccountModificationTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -479,25 +481,25 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, ); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Convert.uint8ToHex(Crypto.randomBytes(48)), 1, 3, @@ -505,13 +507,13 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -521,7 +523,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -530,7 +532,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign UInt64.fromUint(0), ); const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -538,7 +540,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -547,7 +549,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign NetworkType.MIJIN_TEST, ); const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -557,7 +559,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, new NamespaceId([2262289484, 3405110546]), new MosaicId([2262289484, 3405110546]), @@ -565,7 +567,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(Convert.hexToUint8('B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7')).hex(), account.address, @@ -574,7 +576,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [ transferTransaction.toAggregate(account.publicAccount), accountLinkTransaction.toAggregate(account.publicAccount), @@ -599,7 +601,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = aggregateTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AggregateTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE); expect(transaction.innerTransactions[0].type).to.be.equal(TransactionType.TRANSFER); @@ -610,14 +612,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(aggregateTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = aggregateTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AggregateTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as AggregateTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -625,7 +627,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -636,7 +638,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = aggregateTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AggregateTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as AggregateTransaction; expect(transaction.type).to.be.equal(TransactionType.AGGREGATE_BONDED); expect(transaction.innerTransactions[0].type).to.be.equal(TransactionType.TRANSFER); @@ -646,16 +648,16 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(aggregateTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = aggregateTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AggregateTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as AggregateTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create LockFundTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -667,7 +669,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedLockFundTransaction = lockTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedLockFundTransaction, 1573430400) as LockFundsTransaction; + let transaction = TransactionMapping.createFromPayload(signedLockFundTransaction) as LockFundsTransaction; deepEqual(transaction.mosaic.id.id, NetworkCurrencyLocal.NAMESPACE_ID.id); expect(transaction.mosaic.amount.compact()).to.be.equal(10000000); @@ -678,14 +680,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(aggregateTransaction, { signature: emtptySignature, signer: undefined }); signedLockFundTransaction = aggregateTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedLockFundTransaction, 1573430400) as LockFundsTransaction; + transaction = TransactionMapping.createFromPayload(signedLockFundTransaction) as LockFundsTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create an AccountKeyLinkTransaction object with link action', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -695,7 +697,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = accountLinkTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountKeyLinkTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -705,14 +707,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(accountLinkTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = accountLinkTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountKeyLinkTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountKeyLinkTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create an VrfKeyLinkTransaction object with link action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -722,7 +724,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = vrfKeyLinkTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as VrfKeyLinkTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as VrfKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -732,14 +734,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(vrfKeyLinkTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = vrfKeyLinkTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as VrfKeyLinkTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as VrfKeyLinkTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create an NodeKeyLinkTransaction object with link action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -749,7 +751,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = nodeKeyLinkTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NodeKeyLinkTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as NodeKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(account.publicKey); @@ -759,7 +761,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(nodeKeyLinkTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = nodeKeyLinkTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NodeKeyLinkTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as NodeKeyLinkTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); @@ -767,7 +769,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign it('should create an VotingKeyLinkTransaction object with link action', () => { const key = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), key, 1, 3, @@ -779,7 +781,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = votingKeyLinkTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as VotingKeyLinkTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as VotingKeyLinkTransaction; expect(transaction.linkAction).to.be.equal(1); expect(transaction.linkedPublicKey).to.be.equal(key); @@ -791,14 +793,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(votingKeyLinkTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = votingKeyLinkTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as VotingKeyLinkTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as VotingKeyLinkTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -809,7 +811,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = registerNamespaceTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceRegistrationTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceRegistrationTransaction; expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.RootNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); @@ -819,14 +821,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(registerNamespaceTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = registerNamespaceTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceRegistrationTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceRegistrationTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -837,7 +839,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = registerNamespaceTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceRegistrationTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceRegistrationTransaction; expect(transaction.registrationType).to.be.equal(NamespaceRegistrationType.SubNamespace); expect(transaction.namespaceName).to.be.equal('root-test-namespace'); @@ -847,14 +849,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(registerNamespaceTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = registerNamespaceTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceRegistrationTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceRegistrationTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), UInt64.fromUint(0), @@ -870,7 +872,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicGlobalRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicGlobalRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicGlobalRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_GLOBAL_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new MosaicId(UInt64.fromUint(1).toDTO()).toHex()); @@ -886,14 +888,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicGlobalRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicGlobalRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicGlobalRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicGlobalRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicAddressRestrictionTransaction', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(4444), account.address, @@ -907,7 +909,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicAddressRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAddressRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new MosaicId(UInt64.fromUint(1).toDTO()).toHex()); @@ -921,14 +923,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicAddressRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicAddressRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAddressRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAddressRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicAddressRestrictionTransaction - MosaicAlias', () => { const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new NamespaceId('test'), UInt64.fromUint(4444), account.address, @@ -942,7 +944,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicAddressRestrictionTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAddressRestrictionTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAddressRestrictionTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION); expect(transaction.mosaicId.toHex()).to.be.equal(new NamespaceId('test').toHex()); @@ -957,14 +959,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicAddressRestrictionTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicAddressRestrictionTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicAddressRestrictionTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicAddressRestrictionTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create AddressMetadataTransaction', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -976,7 +978,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign ); let signedTransaction = accountMetadataTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountMetadataTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -989,14 +991,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(accountMetadataTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = accountMetadataTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as AccountMetadataTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as AccountMetadataTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -1010,7 +1012,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = mosaicMetadataTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicMetadataTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.MOSAIC_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -1024,14 +1026,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(mosaicMetadataTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = mosaicMetadataTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as MosaicMetadataTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as MosaicMetadataTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should create NamespaceMetadataTransaction', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -1045,7 +1047,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign let signedTransaction = namespaceMetadataTransaction.serialize(); - let transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceMetadataTransaction; + let transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceMetadataTransaction; expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_METADATA); expect(transaction.targetAddress.equals(account.address)).to.be.true; @@ -1059,14 +1061,14 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign Object.assign(namespaceMetadataTransaction, { signature: emtptySignature, signer: undefined }); signedTransaction = namespaceMetadataTransaction.serialize(); - transaction = TransactionMapping.createFromPayload(signedTransaction, 1573430400) as NamespaceMetadataTransaction; + transaction = TransactionMapping.createFromPayload(signedTransaction) as NamespaceMetadataTransaction; expect(transaction.signature).to.be.undefined; expect(transaction.signer).to.be.undefined; }); it('should throw error with invalid type', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -1080,7 +1082,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const wrongType = signedTransaction.substring(0, 219) + '0000' + signedTransaction.substring(224); expect(() => { - TransactionMapping.createFromPayload(wrongType, 1573430400) as TransferTransaction; + TransactionMapping.createFromPayload(wrongType) as TransferTransaction; }).to.throw(); }); }); diff --git a/test/infrastructure/Listener.spec.ts b/test/infrastructure/Listener.spec.ts index acb00ee83e..2a6e78c47d 100644 --- a/test/infrastructure/Listener.spec.ts +++ b/test/infrastructure/Listener.spec.ts @@ -34,6 +34,7 @@ import { TransactionStatusError } from '../../src/model/transaction/TransactionS import { TransferTransaction } from '../../src/model/transaction/TransferTransaction'; import { UInt64 } from '../../src/model/UInt64'; import { FinalizedBlock } from '../../src/model/blockchain/FinalizedBlock'; +import { Duration } from 'js-joda'; describe('Listener', () => { const account = Account.createFromPrivateKey( @@ -43,7 +44,7 @@ describe('Listener', () => { let namespaceRepoMock: NamespaceRepository; let namespaceRepo: NamespaceRepository; - const epochAdjustment = 1573430400; + const epochAdjustment = Duration.ofSeconds(1573430400); beforeEach(() => { namespaceRepoMock = mock(); namespaceRepo = instance(namespaceRepoMock); @@ -86,7 +87,7 @@ describe('Listener', () => { code: 'error-message', }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); @@ -125,7 +126,7 @@ describe('Listener', () => { code: 'error-message', }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); @@ -170,7 +171,7 @@ describe('Listener', () => { }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); @@ -236,7 +237,7 @@ describe('Listener', () => { ); const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), alias, [], PlainMessage.create('test-message'), @@ -247,7 +248,7 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -280,7 +281,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), alias, [], PlainMessage.create('test-message'), @@ -292,7 +293,7 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash2).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -325,7 +326,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), alias, [], PlainMessage.create('test-message'), @@ -336,7 +337,7 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -369,7 +370,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), alias2, [], PlainMessage.create('test-message'), @@ -381,7 +382,7 @@ describe('Listener', () => { const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((unconfirmedTransaction) => { reportedTransactions.push(unconfirmedTransaction); @@ -415,7 +416,7 @@ describe('Listener', () => { observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), ); const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), alias2, [], PlainMessage.create('test-message'), @@ -430,7 +431,7 @@ describe('Listener', () => { const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); @@ -487,7 +488,7 @@ describe('Listener', () => { }; const reportedTransactions: string[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedHash) => { reportedTransactions.push(confirmedHash); @@ -507,7 +508,7 @@ describe('Listener', () => { }; const reportedTransactions: string[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress).subscribe((confirmedHash) => { reportedTransactions.push(confirmedHash); @@ -527,7 +528,7 @@ describe('Listener', () => { }; const reportedTransactions: string[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); subscriptionMethod(listener, subscribedAddress, 'invalid!').subscribe((confirmedHash) => { reportedTransactions.push(confirmedHash); @@ -584,7 +585,7 @@ describe('Listener', () => { }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); @@ -639,7 +640,7 @@ describe('Listener', () => { }, }; - const listener = new Listener('http://localhost:3000', namespaceRepo, epochAdjustment, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); listener.open(); diff --git a/test/infrastructure/MetadataHttp.spec.ts b/test/infrastructure/MetadataHttp.spec.ts index e5699592aa..1443a795d5 100644 --- a/test/infrastructure/MetadataHttp.spec.ts +++ b/test/infrastructure/MetadataHttp.spec.ts @@ -14,6 +14,7 @@ * limitations under the License. */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { MetadataEntryDTO, MetadataRoutesApi, @@ -42,6 +43,7 @@ import { UInt64 } from '../../src/model/UInt64'; import { MetadataTransactionService } from '../../src/service/MetadataTransactionService'; describe('MetadataHttp', () => { + const epochAdjustment = Duration.ofSeconds(1573430400); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const mosaicId = new MosaicId('941299B2B7E1291C'); const namespaceId = new NamespaceId('some.address'); @@ -361,7 +363,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); metadataTransactionService .createAccountMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, UInt64.fromHex('85BBEA6CC462B244'), @@ -394,7 +396,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); metadataTransactionService .createMosaicMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, mosaicId, @@ -428,7 +430,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); metadataTransactionService .createNamespaceMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, namespaceId, @@ -461,7 +463,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); await metadataTransactionService .createAccountMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, UInt64.fromHex('85BBEA6CC462B244'), @@ -490,7 +492,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); await metadataTransactionService .createMosaicMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, mosaicId, @@ -520,7 +522,7 @@ describe('MetadataHttp', () => { const metadataTransactionService = new MetadataTransactionService(metadataRepository); await metadataTransactionService .createNamespaceMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, address, namespaceId, diff --git a/test/infrastructure/Page.spec.ts b/test/infrastructure/Page.spec.ts index a8bab694cf..dc08df2b5c 100644 --- a/test/infrastructure/Page.spec.ts +++ b/test/infrastructure/Page.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Page } from '../../src/infrastructure/infrastructure'; import { PlainMessage } from '../../src/model/message/PlainMessage'; import { NetworkType } from '../../src/model/network/NetworkType'; @@ -24,10 +25,19 @@ import { TransferTransaction } from '../../src/model/transaction/TransferTransac import { TestingAccount } from '../conf/conf.spec'; describe('Page', () => { + const epochAdjustment = Duration.ofSeconds(1573430400); it('should create Page', () => { const account = TestingAccount; let page = new Page( - [TransferTransaction.create(Deadline.create(1573430400), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)], + [ + TransferTransaction.create( + Deadline.create(epochAdjustment), + account.address, + [], + PlainMessage.create(''), + NetworkType.TEST_NET, + ), + ], 1, 1, ); @@ -37,7 +47,15 @@ describe('Page', () => { expect(page.isLastPage).to.be.false; page = new Page( - [TransferTransaction.create(Deadline.create(1573430400), account.address, [], PlainMessage.create(''), NetworkType.TEST_NET)], + [ + TransferTransaction.create( + Deadline.create(epochAdjustment), + account.address, + [], + PlainMessage.create(''), + NetworkType.TEST_NET, + ), + ], 2, 2, ); diff --git a/test/infrastructure/RepositoryFactory.spec.ts b/test/infrastructure/RepositoryFactory.spec.ts index 386473a2cd..65e1274e77 100644 --- a/test/infrastructure/RepositoryFactory.spec.ts +++ b/test/infrastructure/RepositoryFactory.spec.ts @@ -173,10 +173,10 @@ describe('RepositoryFactory', () => { expect(counter).to.be.equals(0); repositoryFactory.getEpochAdjustment().subscribe((epoch) => { expect(counter).to.be.equals(1); - expect(epoch).to.be.equals(expectedepochAdjustment); + expect(epoch.seconds()).to.be.equals(expectedepochAdjustment); repositoryFactory.getEpochAdjustment().subscribe((network) => { expect(counter).to.be.equals(1); - expect(network).to.be.equals(expectedepochAdjustment); + expect(network.seconds()).to.be.equals(expectedepochAdjustment); done(); }); }); @@ -258,10 +258,10 @@ describe('RepositoryFactory', () => { expect(counter).to.be.equals(0); repositoryFactory.getEpochAdjustment().subscribe((networkType) => { expect(counter).to.be.equals(0); - expect(networkType).to.be.equals(expectedepochAdjustment); + expect(networkType.seconds()).to.be.equals(expectedepochAdjustment); repositoryFactory.getEpochAdjustment().subscribe((network) => { expect(counter).to.be.equals(0); - expect(network).to.be.equals(expectedepochAdjustment); + expect(network.seconds()).to.be.equals(expectedepochAdjustment); done(); }); }); diff --git a/test/infrastructure/SerializeTransactionToJSON.spec.ts b/test/infrastructure/SerializeTransactionToJSON.spec.ts index a5e58df03d..a4fa7413b0 100644 --- a/test/infrastructure/SerializeTransactionToJSON.spec.ts +++ b/test/infrastructure/SerializeTransactionToJSON.spec.ts @@ -54,17 +54,18 @@ import { VotingKeyLinkTransaction } from '../../src/model/transaction/VotingKeyL import { VrfKeyLinkTransaction } from '../../src/model/transaction/VrfKeyLinkTransaction'; import { UInt64 } from '../../src/model/UInt64'; import { TestingAccount } from '../conf/conf.spec'; +import { Duration } from 'js-joda'; describe('SerializeTransactionToJSON', () => { let account: Account; - + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should create AccountKeyLinkTransaction', () => { const accountLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -79,7 +80,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountRestrictionAddressTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -96,7 +97,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountRestrictionMosaicTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -113,7 +114,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AccountRestrictionOperationTransaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -131,7 +132,7 @@ describe('SerializeTransactionToJSON', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -148,7 +149,7 @@ describe('SerializeTransactionToJSON', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -162,7 +163,7 @@ describe('SerializeTransactionToJSON', () => { it('should create MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -181,7 +182,7 @@ describe('SerializeTransactionToJSON', () => { it('should create MosaicDefinitionTransaction without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, false), @@ -200,7 +201,7 @@ describe('SerializeTransactionToJSON', () => { it('should create MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -215,7 +216,7 @@ describe('SerializeTransactionToJSON', () => { it('should create TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -232,7 +233,7 @@ describe('SerializeTransactionToJSON', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -250,7 +251,7 @@ describe('SerializeTransactionToJSON', () => { it('should create SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -268,7 +269,7 @@ describe('SerializeTransactionToJSON', () => { it('should create ModifyMultiSigTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [Address.createFromPublicKey('B0F93CBEE49EEB9953C6F3985B15A4F238E205584D8F924C621CBE4D7AC6EC24', NetworkType.MIJIN_TEST)], @@ -285,7 +286,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AggregatedTransaction - Complete', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -293,7 +294,7 @@ describe('SerializeTransactionToJSON', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -307,7 +308,7 @@ describe('SerializeTransactionToJSON', () => { it('should create AggregatedTransaction - Bonded', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -315,7 +316,7 @@ describe('SerializeTransactionToJSON', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -329,10 +330,10 @@ describe('SerializeTransactionToJSON', () => { it('should create LockFundTransaction', () => { const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -347,7 +348,7 @@ describe('SerializeTransactionToJSON', () => { it('should create NamespaceRegistrationTransaction - Root', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -360,7 +361,7 @@ describe('SerializeTransactionToJSON', () => { it('should create NamespaceRegistrationTransaction - Sub', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -373,7 +374,7 @@ describe('SerializeTransactionToJSON', () => { it('should create VrfKeyLinkTransaction', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -386,7 +387,7 @@ describe('SerializeTransactionToJSON', () => { it('should create NodeKeyLinkTransaction', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -400,7 +401,7 @@ describe('SerializeTransactionToJSON', () => { it('should create VotingKeyLinkTransaction', () => { const votingKey = Convert.uint8ToHex(Crypto.randomBytes(48)); const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), votingKey, 1, 3, diff --git a/test/infrastructure/TransactionHttp.spec.ts b/test/infrastructure/TransactionHttp.spec.ts index bb545efb2d..309c85e715 100644 --- a/test/infrastructure/TransactionHttp.spec.ts +++ b/test/infrastructure/TransactionHttp.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { BlockDTO, BlockInfoDTO, @@ -58,6 +59,7 @@ describe('TransactionHttp', () => { cosignature.signerPublicKey = 'signerPubKey'; cosignature.signature = 'signature'; cosignature.version = '0'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { transactionRoutesApi = mock(); @@ -69,14 +71,14 @@ describe('TransactionHttp', () => { it('should return an error when a non aggregate transaction bonded is announced via announceAggregateBonded method', () => { const tx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), NetworkType.MIJIN_TEST, ); const aggTx = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -388,7 +390,7 @@ describe('TransactionHttp', () => { it('Test announce', async () => { const response = { message: 'done' }; const tx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -407,7 +409,7 @@ describe('TransactionHttp', () => { const response = { message: 'done' }; const tx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -415,7 +417,7 @@ describe('TransactionHttp', () => { ); const aggTx = AggregateTransaction.createBonded( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -495,7 +497,7 @@ describe('TransactionHttp', () => { it('announce - Error', async () => { const tx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -515,7 +517,7 @@ describe('TransactionHttp', () => { const response = { message: 'done' }; const tx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('Hi'), @@ -523,7 +525,7 @@ describe('TransactionHttp', () => { ); const aggTx = AggregateTransaction.createBonded( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], diff --git a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts index 9878dbadcb..5ec9e2f864 100644 --- a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts +++ b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts @@ -19,9 +19,10 @@ import { CreateTransactionFromDTO } from '../../../src/infrastructure/transactio import { Address } from '../../../src/model/account/Address'; import { TransferTransaction } from '../../../src/model/transaction/TransferTransaction'; import ValidateTransaction from './ValidateTransaction'; -import { LocalDateTime } from 'js-joda'; +import { Duration, LocalDateTime } from 'js-joda'; describe('CreateTransactionFromDTO', () => { + const epochAdjustment = Duration.ofSeconds(1573430400); describe('TransferTransaction', () => { it('standalone', () => { const transferTransactionDTO = { @@ -56,7 +57,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO, 1573430400) as TransferTransaction; + const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO) as TransferTransaction; deepEqual(transferTransaction.recipientAddress, Address.createFromEncoded(transferTransactionDTO.transaction.recipientAddress)); expect(transferTransaction.message.payload).to.be.equal('test-message'); expect(transferTransaction.size).to.be.equal(100); @@ -91,7 +92,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO, 1573430400) as TransferTransaction; + const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO) as TransferTransaction; deepEqual(transferTransaction.recipientAddress, Address.createFromEncoded(transferTransactionDTO.transaction.recipientAddress)); expect(transferTransaction.message.payload).to.be.equal(''); expect(transferTransaction.size).to.be.equal(100); @@ -157,7 +158,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateTransferTransaction = CreateTransactionFromDTO(aggregateTransferTransactionDTO, 1573430400); + const aggregateTransferTransaction = CreateTransactionFromDTO(aggregateTransferTransactionDTO); expect(aggregateTransferTransaction.size).eq(100); ValidateTransaction.validateAggregateTx(aggregateTransferTransaction, aggregateTransferTransactionDTO); }); @@ -192,10 +193,10 @@ describe('CreateTransactionFromDTO', () => { }, }; - const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO, 1573430400) as TransferTransaction; + const transferTransaction = CreateTransactionFromDTO(transferTransactionDTO) as TransferTransaction; deepEqual(transferTransaction.recipientAddress, Address.createFromEncoded(transferTransactionDTO.transaction.recipientAddress)); expect(transferTransaction.message.payload).to.be.equal('test-message'); - expect(transferTransaction.deadline.value).to.be.equal(LocalDateTime.MIN); + expect(transferTransaction.deadline.adjustedValue).to.be.equal(LocalDateTime.MIN.second()); expect(transferTransaction.maxFee.toString()).to.be.equal('0'); }); }); @@ -229,7 +230,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const transferTransaction = CreateTransactionFromDTO(registerNamespaceTransactionDTO, 1573430400); + const transferTransaction = CreateTransactionFromDTO(registerNamespaceTransactionDTO); expect(transferTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(transferTransaction, registerNamespaceTransactionDTO); }); @@ -287,10 +288,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO( - aggregateNamespaceRegistrationTransactionDTO, - 1573430400, - ); + const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO(aggregateNamespaceRegistrationTransactionDTO); expect(aggregateNamespaceRegistrationTransaction.size).eq(100); ValidateTransaction.validateAggregateTx( aggregateNamespaceRegistrationTransaction, @@ -326,7 +324,7 @@ describe('CreateTransactionFromDTO', () => { network: 144, }, }; - const transferTransaction = CreateTransactionFromDTO(registerNamespaceTransactionDTO, 1573430400); + const transferTransaction = CreateTransactionFromDTO(registerNamespaceTransactionDTO); expect(transferTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(transferTransaction, registerNamespaceTransactionDTO); }); @@ -384,10 +382,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO( - aggregateNamespaceRegistrationTransactionDTO, - 1573430400, - ); + const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO(aggregateNamespaceRegistrationTransactionDTO); expect(aggregateNamespaceRegistrationTransaction.size).eq(100); ValidateTransaction.validateAggregateTx( aggregateNamespaceRegistrationTransaction, @@ -426,7 +421,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const mosaicDefinitionTransaction = CreateTransactionFromDTO(mosaicDefinitionTransactionDTO, 1573430400); + const mosaicDefinitionTransaction = CreateTransactionFromDTO(mosaicDefinitionTransactionDTO); expect(mosaicDefinitionTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(mosaicDefinitionTransaction, mosaicDefinitionTransactionDTO); @@ -486,7 +481,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO(aggregateMosaicDefinitionTransactionDTO, 1573430400); + const aggregateNamespaceRegistrationTransaction = CreateTransactionFromDTO(aggregateMosaicDefinitionTransactionDTO); expect(aggregateNamespaceRegistrationTransaction.size).eq(100); ValidateTransaction.validateAggregateTx(aggregateNamespaceRegistrationTransaction, aggregateMosaicDefinitionTransactionDTO); }); @@ -519,7 +514,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const mosaicSupplyChangeTransaction = CreateTransactionFromDTO(mosaicSupplyChangeTransactionDTO, 1573430400); + const mosaicSupplyChangeTransaction = CreateTransactionFromDTO(mosaicSupplyChangeTransactionDTO); expect(mosaicSupplyChangeTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(mosaicSupplyChangeTransaction, mosaicSupplyChangeTransactionDTO); }); @@ -576,7 +571,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const aggregateMosaicSupplyChangeTransaction = CreateTransactionFromDTO(aggregateMosaicSupplyChangeTransactionDTO, 1573430400); + const aggregateMosaicSupplyChangeTransaction = CreateTransactionFromDTO(aggregateMosaicSupplyChangeTransactionDTO); expect(aggregateMosaicSupplyChangeTransaction.size).eq(100); ValidateTransaction.validateAggregateTx(aggregateMosaicSupplyChangeTransaction, aggregateMosaicSupplyChangeTransactionDTO); @@ -611,7 +606,7 @@ describe('CreateTransactionFromDTO', () => { }, }; - const modifyMultisigAccountTransaction = CreateTransactionFromDTO(modifyMultisigAccountTransactionDTO, 1573430400); + const modifyMultisigAccountTransaction = CreateTransactionFromDTO(modifyMultisigAccountTransactionDTO); expect(modifyMultisigAccountTransaction.size).eq(100); ValidateTransaction.validateStandaloneTx(modifyMultisigAccountTransaction, modifyMultisigAccountTransactionDTO); }); @@ -671,7 +666,6 @@ describe('CreateTransactionFromDTO', () => { const aggregateMultisigAccountModificationTransaction = CreateTransactionFromDTO( aggregateMultisigAccountModificationTransactionDTO, - 1573430400, ); expect(aggregateMultisigAccountModificationTransaction.size).eq(100); ValidateTransaction.validateAggregateTx( diff --git a/test/model/account/Account.spec.ts b/test/model/account/Account.spec.ts index fb51d25e4c..b893c3d8a4 100644 --- a/test/model/account/Account.spec.ts +++ b/test/model/account/Account.spec.ts @@ -25,6 +25,7 @@ import { AggregateTransaction } from '../../../src/model/transaction/AggregateTr import { CosignatureTransaction } from '../../../src/model/transaction/CosignatureTransaction'; import { CosignatureSignedTransaction } from '../../../src/model/transaction/CosignatureSignedTransaction'; import { TransactionMapping } from '../../../src/core/utils/TransactionMapping'; +import { Duration } from 'js-joda'; describe('Account', () => { const accountInformation = { @@ -33,6 +34,7 @@ describe('Account', () => { publicKey: '9801508C58666C746F471538E43002B85B1CD542F9874B2861183919BA8787B6'.toUpperCase(), }; + const epochAdjustment = Duration.ofSeconds(1573430400); it('should be created via private key', () => { const account = Account.createFromPrivateKey(accountInformation.privateKey, NetworkType.MIJIN_TEST); expect(account.publicKey).to.be.equal(accountInformation.publicKey); @@ -72,14 +74,14 @@ describe('Account', () => { const account2 = Account.generateNewAccount(NetworkType.TEST_NET); const generationHash = 'C422CC3C9257A1568036E1726E64EB5923C8363A13D4344F9E66CD89C8789BC7'; const aliceTransferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account2.address, [sendAmount], PlainMessage.create('payout'), NetworkType.TEST_NET, ); const bobTransferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [backAmount], PlainMessage.create('payout'), @@ -88,7 +90,7 @@ describe('Account', () => { // 01. Alice creates the aggregated tx and sign it. Then payload send to Bob const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [aliceTransferTransaction.toAggregate(account.publicAccount), bobTransferTransaction.toAggregate(account2.publicAccount)], NetworkType.TEST_NET, [], @@ -103,7 +105,7 @@ describe('Account', () => { const cosignatureSignedTransactions = [ new CosignatureSignedTransaction(signedTxBob.parentHash, signedTxBob.signature, signedTxBob.signerPublicKey), ]; - const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload, 1573430400) as AggregateTransaction; + const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload) as AggregateTransaction; const signedTransaction = account.signTransactionGivenSignatures(recreatedTx, cosignatureSignedTransactions, generationHash); diff --git a/test/model/message/EncryptedMessage.spec.ts b/test/model/message/EncryptedMessage.spec.ts index 03cfbe3cca..d98315ef24 100644 --- a/test/model/message/EncryptedMessage.spec.ts +++ b/test/model/message/EncryptedMessage.spec.ts @@ -21,6 +21,7 @@ import { NetworkType } from '../../../src/model/network/NetworkType'; import { Deadline } from '../../../src/model/transaction/Deadline'; import { TransferTransaction } from '../../../src/model/transaction/TransferTransaction'; import { NetworkCurrencyLocal } from '../../../src/model/mosaic/NetworkCurrencyLocal'; +import { Duration } from 'js-joda'; describe('EncryptedMessage', () => { let sender: Account; @@ -28,6 +29,7 @@ describe('EncryptedMessage', () => { let sender_nis: Account; let recipient_nis: Account; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { sender = Account.createFromPrivateKey('2602F4236B199B3DF762B2AAB46FC3B77D8DDB214F0B62538D3827576C46C108', NetworkType.MIJIN_TEST); recipient = Account.createFromPrivateKey( @@ -63,7 +65,7 @@ describe('EncryptedMessage', () => { it('should return decrepted message reading from message payload', () => { const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), recipient.address, [NetworkCurrencyLocal.createAbsolute(1)], sender.encryptMessage('Testing simple transfer', recipient.publicAccount), diff --git a/test/model/message/PersistentHarvestingDelegationMessage.spec.ts b/test/model/message/PersistentHarvestingDelegationMessage.spec.ts index 993a84fb37..25c4c653cd 100644 --- a/test/model/message/PersistentHarvestingDelegationMessage.spec.ts +++ b/test/model/message/PersistentHarvestingDelegationMessage.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Account } from '../../../src/model/account/Account'; import { MessageType } from '../../../src/model/message/MessageType'; import { PersistentHarvestingDelegationMessage } from '../../../src/model/message/PersistentHarvestingDelegationMessage'; @@ -28,6 +29,7 @@ describe('PersistentHarvestingDelegationMessage', () => { let recipient_nis: Account; const signingPrivateKey = 'F0AB1010EFEE19EE5373719881DF5123C13E643C519655F7E97347BFF77175BF'; const vrfPrivateKey = '800F35F1CC66C2B62CE9DD9F31003B9B3E5C7A2F381FB8952A294277A1015D83'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { sender = Account.createFromPrivateKey('2602F4236B199B3DF762B2AAB46FC3B77D8DDB214F0B62538D3827576C46C108', NetworkType.MIJIN_TEST); recipient = Account.createFromPrivateKey( @@ -82,7 +84,7 @@ describe('PersistentHarvestingDelegationMessage', () => { it('return decrepted message reading from message payload', () => { const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; const tx = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), signingPrivateKey, vrfPrivateKey, recipient.publicKey, diff --git a/test/model/transaction/AccountKeyLinkTransaction.spec.ts b/test/model/transaction/AccountKeyLinkTransaction.spec.ts index 81a5e57ecd..da3c7698bd 100644 --- a/test/model/transaction/AccountKeyLinkTransaction.spec.ts +++ b/test/model/transaction/AccountKeyLinkTransaction.spec.ts @@ -24,17 +24,19 @@ import { LinkAction } from '../../../src/model/transaction/LinkAction'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('AccountKeyLinkTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -46,7 +48,7 @@ describe('AccountKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -59,7 +61,7 @@ describe('AccountKeyLinkTransaction', () => { it('should create an AccountKeyLinkTransaction object with link action', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -77,7 +79,7 @@ describe('AccountKeyLinkTransaction', () => { it('should create an AccountKeyLinkTransaction object with unlink action', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -96,7 +98,7 @@ describe('AccountKeyLinkTransaction', () => { describe('size', () => { it('should return 161 for AccountKeyLinkTransaction byte size', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -107,7 +109,7 @@ describe('AccountKeyLinkTransaction', () => { it('should create payload size', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -120,7 +122,7 @@ describe('AccountKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const accountKeyLinkTransaction = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -133,7 +135,7 @@ describe('AccountKeyLinkTransaction', () => { it('Notify Account', () => { const tx = AccountKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, diff --git a/test/model/transaction/AccountMetadataTransaction.spec.ts b/test/model/transaction/AccountMetadataTransaction.spec.ts index 8b5278b9de..bcfc8c3cb7 100644 --- a/test/model/transaction/AccountMetadataTransaction.spec.ts +++ b/test/model/transaction/AccountMetadataTransaction.spec.ts @@ -27,17 +27,19 @@ import { TransactionType } from '../../../src/model/transaction/TransactionType' import { deepEqual } from 'assert'; import { Address } from '../../../src/model/account/Address'; import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; +import { Duration } from 'js-joda'; describe('AccountMetadataTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -51,7 +53,7 @@ describe('AccountMetadataTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -66,7 +68,7 @@ describe('AccountMetadataTransaction', () => { it('should create and sign an AccountMetadataTransaction object', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -84,7 +86,7 @@ describe('AccountMetadataTransaction', () => { describe('size', () => { it('should return 174 for AccountMetadataTransaction byte size', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -101,7 +103,7 @@ describe('AccountMetadataTransaction', () => { it('should set payload size', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -118,7 +120,7 @@ describe('AccountMetadataTransaction', () => { it('should create EmbeddedTransactionBuilder', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -137,7 +139,7 @@ describe('AccountMetadataTransaction', () => { it('should resolve alias', () => { const accountMetadataTransaction = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -153,7 +155,7 @@ describe('AccountMetadataTransaction', () => { it('Notify Account', () => { const tx = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, @@ -175,7 +177,7 @@ describe('AccountMetadataTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = AccountMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), 1, diff --git a/test/model/transaction/AccountRestrictionTransaction.spec.ts b/test/model/transaction/AccountRestrictionTransaction.spec.ts index 4933d40486..738b332fc4 100644 --- a/test/model/transaction/AccountRestrictionTransaction.spec.ts +++ b/test/model/transaction/AccountRestrictionTransaction.spec.ts @@ -31,10 +31,12 @@ import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; import { AddressRestrictionFlag } from '../../../src/model/restriction/AddressRestrictionFlag'; import { OperationRestrictionFlag } from '../../../src/model/restriction/OperationRestrictionFlag'; import { MosaicRestrictionFlag } from '../../../src/model/restriction/MosaicRestrictionFlag'; +import { Duration } from 'js-joda'; describe('AccountRestrictionTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -67,7 +69,7 @@ describe('AccountRestrictionTransaction', () => { it('should return 160 for AccountAddressRestrictionTransaction transaction byte size with 1 modification', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -81,7 +83,7 @@ describe('AccountRestrictionTransaction', () => { it('should return 144 for AccountMosaicRestrictionTransaction transaction byte size with 1 modification', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -92,7 +94,7 @@ describe('AccountRestrictionTransaction', () => { it('should set payload size', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -105,7 +107,7 @@ describe('AccountRestrictionTransaction', () => { it('should return 138 for AccountOperationRestrictionTransaction transaction byte size with 1 modification', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -117,7 +119,7 @@ describe('AccountRestrictionTransaction', () => { it('should default maxFee field be set to 0', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -131,7 +133,7 @@ describe('AccountRestrictionTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -146,7 +148,7 @@ describe('AccountRestrictionTransaction', () => { it('should create allow incmoing address restriction transaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowIncomingAddress, [address], [], @@ -163,7 +165,7 @@ describe('AccountRestrictionTransaction', () => { it('should create mosaic restriction transaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicRestrictionTransaction = AccountRestrictionTransaction.createMosaicRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicRestrictionFlag.AllowMosaic, [mosaicId], [], @@ -178,7 +180,7 @@ describe('AccountRestrictionTransaction', () => { it('should create operation restriction transaction', () => { const operation = TransactionType.ADDRESS_ALIAS; const operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -193,7 +195,7 @@ describe('AccountRestrictionTransaction', () => { it('should create outgoing address restriction transaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); let addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [address], [], @@ -207,7 +209,7 @@ describe('AccountRestrictionTransaction', () => { ); addressRestrictionTransaction = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.BlockOutgoingAddress, [address], [], @@ -224,7 +226,7 @@ describe('AccountRestrictionTransaction', () => { it('should create outgoing operation restriction transaction', () => { const operation = TransactionType.ADDRESS_ALIAS; let operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), OperationRestrictionFlag.AllowOutgoingTransactionType, [operation], [], @@ -236,7 +238,7 @@ describe('AccountRestrictionTransaction', () => { expect(signedTransaction.payload.substring(256, signedTransaction.payload.length)).to.be.equal('04400100000000004E42'); operationRestrictionTransaction = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), OperationRestrictionFlag.BlockOutgoingTransactionType, [operation], [], @@ -251,7 +253,7 @@ describe('AccountRestrictionTransaction', () => { it('Notify Account', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [address], [], @@ -267,7 +269,7 @@ describe('AccountRestrictionTransaction', () => { expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; const txDeletion = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [], [address], @@ -287,7 +289,7 @@ describe('AccountRestrictionTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [alias], [], @@ -303,7 +305,7 @@ describe('AccountRestrictionTransaction', () => { expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; const txDeletion = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AddressRestrictionFlag.AllowOutgoingAddress, [], [alias], diff --git a/test/model/transaction/AddressAliasTransaction.spec.ts b/test/model/transaction/AddressAliasTransaction.spec.ts index 6a379eb9c2..707d70c5d1 100644 --- a/test/model/transaction/AddressAliasTransaction.spec.ts +++ b/test/model/transaction/AddressAliasTransaction.spec.ts @@ -26,10 +26,12 @@ import { Deadline } from '../../../src/model/transaction/Deadline'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { AliasTransaction } from '../../../src/model/model'; +import { Duration } from 'js-joda'; describe('AddressAliasTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -38,7 +40,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -53,7 +55,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -69,7 +71,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -92,7 +94,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AliasTransaction.createForAddress( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -116,7 +118,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -130,7 +132,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -146,7 +148,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const addressAliasTransaction = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, @@ -159,7 +161,7 @@ describe('AddressAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = AddressAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, address, diff --git a/test/model/transaction/AggregateTransaction.spec.ts b/test/model/transaction/AggregateTransaction.spec.ts index e02720aaa8..829ac08dc1 100644 --- a/test/model/transaction/AggregateTransaction.spec.ts +++ b/test/model/transaction/AggregateTransaction.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { TransactionMapping } from '../../../src/core/utils/TransactionMapping'; import { CreateTransactionFromDTO } from '../../../src/infrastructure/transaction/CreateTransactionFromDTO'; @@ -58,6 +58,7 @@ describe('AggregateTransaction', () => { const unresolvedAddress = new NamespaceId('address'); const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -80,7 +81,7 @@ describe('AggregateTransaction', () => { it('should default maxFee field be set to 0', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -88,7 +89,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -100,7 +101,7 @@ describe('AggregateTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -108,7 +109,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -121,7 +122,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -129,7 +130,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -144,14 +145,14 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with NamespaceRegistrationTransaction', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [registerNamespaceTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -168,7 +169,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with MosaicDefinitionTransaction', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -178,7 +179,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [mosaicDefinitionTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -196,7 +197,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with MosaicSupplyChangeTransaction', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -204,7 +205,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [mosaicSupplyChangeTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -221,7 +222,7 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with MultisigAccountModificationTransaction', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [ @@ -232,7 +233,7 @@ describe('AggregateTransaction', () => { NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [modifyMultisigAccountTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -249,14 +250,14 @@ describe('AggregateTransaction', () => { it('should createComplete an AggregateTransaction object with different cosignatories', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(MultisigAccount.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -277,7 +278,7 @@ describe('AggregateTransaction', () => { it('should createBonded an AggregateTransaction object with TransferTransaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -285,7 +286,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400, 2, ChronoUnit.MINUTES), + Deadline.create(epochAdjustment, 2, ChronoUnit.MINUTES), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -357,7 +358,7 @@ describe('AggregateTransaction', () => { }, }; - const aggregateTransaction = CreateTransactionFromDTO(aggregateTransactionDTO, 1573430400) as AggregateTransaction; + const aggregateTransaction = CreateTransactionFromDTO(aggregateTransactionDTO) as AggregateTransaction; expect( aggregateTransaction.signedByAccount( PublicAccount.createFromPublicKey( @@ -391,20 +392,20 @@ describe('AggregateTransaction', () => { }); it("should have type 0x4141 when it's complete", () => { - const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); expect(aggregateTransaction.type).to.be.equal(0x4141); }); it("should have type 0x4241 when it's bonded", () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST); expect(aggregateTransaction.type).to.be.equal(0x4241); }); it('should throw exception when adding an aggregated transaction as inner transaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -412,7 +413,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -420,7 +421,7 @@ describe('AggregateTransaction', () => { expect(() => { AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [aggregateTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -437,21 +438,21 @@ describe('AggregateTransaction', () => { const accountCarol = Cosignatory2Account; const AtoBTx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), accountBob.address, [], PlainMessage.create('a to b'), NetworkType.MIJIN_TEST, ); const BtoATx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), accountAlice.address, [], PlainMessage.create('b to a'), NetworkType.MIJIN_TEST, ); const CtoATx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), accountAlice.address, [], PlainMessage.create('c to a'), @@ -460,7 +461,7 @@ describe('AggregateTransaction', () => { // 01. Alice creates the aggregated tx and sign it, Then payload send to Bob & Carol const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [ AtoBTx.toAggregate(accountAlice.publicAccount), BtoATx.toAggregate(accountBob.publicAccount), @@ -486,7 +487,7 @@ describe('AggregateTransaction', () => { new CosignatureSignedTransaction(signedTxCarol.parentHash, signedTxCarol.signature, signedTxCarol.signerPublicKey), ]; - const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload, 1573430400) as AggregateTransaction; + const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload) as AggregateTransaction; const signedTransaction = recreatedTx.signTransactionGivenSignatures(accountAlice, cosignatureSignedTransactions, generationHash); @@ -507,21 +508,21 @@ describe('AggregateTransaction', () => { it('Should be able to add innertransactions to current aggregate tx', () => { const transferTx1 = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), NetworkType.MIJIN_TEST, ); const transferTx2 = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('b to a'), NetworkType.MIJIN_TEST, ); let aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTx1.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -538,14 +539,14 @@ describe('AggregateTransaction', () => { it('Should be able to add cosignatures to current aggregate tx', () => { const transferTx1 = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), NetworkType.MIJIN_TEST, ); let aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTx1.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -570,14 +571,14 @@ describe('AggregateTransaction', () => { describe('size', () => { it('should return 268 for AggregateTransaction byte size with TransferTransaction with 1 mosaic and message NEM', () => { const transaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -587,14 +588,14 @@ describe('AggregateTransaction', () => { }); it('should set payload size', () => { const transaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), NetworkType.MIJIN_TEST, ); const aggregateTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -607,7 +608,7 @@ describe('AggregateTransaction', () => { it('Test set maxFee using multiplier', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -615,7 +616,7 @@ describe('AggregateTransaction', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -628,7 +629,7 @@ describe('AggregateTransaction', () => { it('Test set maxFee using multiplier', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), @@ -637,7 +638,7 @@ describe('AggregateTransaction', () => { expect(() => { AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -649,7 +650,7 @@ describe('AggregateTransaction', () => { const transferTransaction = new TransferTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), UInt64.fromUint(0), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], @@ -663,7 +664,7 @@ describe('AggregateTransaction', () => { NetworkType.MIJIN_TEST, TransactionType.AGGREGATE_COMPLETE, 1, - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), UInt64.fromUint(100), [transferTransaction.toAggregate(account.publicAccount)], [], @@ -683,14 +684,14 @@ describe('AggregateTransaction', () => { it('Notify Account', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account.address, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const tx = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -707,14 +708,14 @@ describe('AggregateTransaction', () => { it('Notify Account with alias', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const tx = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], diff --git a/test/model/transaction/CosignatureTransaction.spec.ts b/test/model/transaction/CosignatureTransaction.spec.ts index efc59dc512..aabaaf5bf4 100644 --- a/test/model/transaction/CosignatureTransaction.spec.ts +++ b/test/model/transaction/CosignatureTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { CreateTransactionFromDTO } from '../../../src/infrastructure/transaction/CreateTransactionFromDTO'; import { Account } from '../../../src/model/account/Account'; import { PlainMessage } from '../../../src/model/message/PlainMessage'; @@ -28,6 +29,7 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('CosignatureTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -89,7 +91,7 @@ describe('CosignatureTransaction', () => { }; it('should createComplete an TransferTransaction object and sign it', () => { - const aggregateTransferTransaction = CreateTransactionFromDTO(aggregateTransferTransactionDTO, 1573430400); + const aggregateTransferTransaction = CreateTransactionFromDTO(aggregateTransferTransactionDTO); const cosignatureTransaction = CosignatureTransaction.create(aggregateTransferTransaction as AggregateTransaction); @@ -106,7 +108,7 @@ describe('CosignatureTransaction', () => { it('should sign a transaction with transaction payload', () => { const txPayload = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), @@ -122,7 +124,7 @@ describe('CosignatureTransaction', () => { it('should sign a transaction with provided transactionHash', () => { const tx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), @@ -130,7 +132,7 @@ describe('CosignatureTransaction', () => { ); const aggregate = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -149,7 +151,7 @@ describe('CosignatureTransaction', () => { it('should sign a transaction to throw', () => { const tx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, [], PlainMessage.create('a to b'), @@ -157,7 +159,7 @@ describe('CosignatureTransaction', () => { ); const aggregate = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [tx.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -178,7 +180,7 @@ describe('CosignatureTransaction', () => { merkleComponentHash: '81E5E7AE49998802DABC816EC10158D3A7879702FF29084C2C992CD1289877A7', }, }); - const aggregate = CreateTransactionFromDTO(aggregateTransferTransactionDTO, 1573430400) as AggregateTransaction; + const aggregate = CreateTransactionFromDTO(aggregateTransferTransactionDTO) as AggregateTransaction; const cosignTx = new CosignatureTransaction(aggregate); expect(() => { cosignTx.signWith(account); diff --git a/test/model/transaction/Deadline.spec.ts b/test/model/transaction/Deadline.spec.ts index c5788f52cd..217c6a0d9e 100644 --- a/test/model/transaction/Deadline.spec.ts +++ b/test/model/transaction/Deadline.spec.ts @@ -17,35 +17,38 @@ import { expect } from 'chai'; import { ChronoUnit, Instant, LocalDateTime, ZoneId } from 'js-joda'; import { Deadline } from '../../../src/model/transaction/Deadline'; +import { Duration } from 'js-joda'; describe('Deadline', () => { + const epochAdjustment = Duration.ofSeconds(1573430400); + it('should createComplete timestamp today', () => { - const deadline = Deadline.create(1573430400); + const deadline = Deadline.create(epochAdjustment); // avoid SYSTEM and UTC differences const networkTimeStamp = new Date().getTime(); const timestampLocal = LocalDateTime.ofInstant(Instant.ofEpochMilli(networkTimeStamp), ZoneId.SYSTEM); const reproducedDate = timestampLocal.plus(2, ChronoUnit.HOURS); - expect(deadline.value.dayOfMonth()).to.be.equal(reproducedDate.dayOfMonth()); - expect(deadline.value.monthValue()).to.be.equal(reproducedDate.monthValue()); - expect(deadline.value.year()).to.be.equal(reproducedDate.year()); + expect(deadline.toLocalDateTime(epochAdjustment).dayOfMonth()).to.be.equal(reproducedDate.dayOfMonth()); + expect(deadline.toLocalDateTime(epochAdjustment).monthValue()).to.be.equal(reproducedDate.monthValue()); + expect(deadline.toLocalDateTime(epochAdjustment).year()).to.be.equal(reproducedDate.year()); }); it('should throw error deadline smaller than timeStamp', () => { expect(() => { - Deadline.create(1573430400, -3); + Deadline.create(epochAdjustment, -3); }).to.throw(Error); }); it('should throw error deadline greater than 24h', () => { expect(() => { - Deadline.create(1573430400, 2, ChronoUnit.DAYS); + Deadline.create(epochAdjustment, 2, ChronoUnit.DAYS); }).to.throw(Error); }); it('should createComplete date with Deadline array', () => { - const deadline = Deadline.createFromDTO('51110867862', 1573430400); + const deadline = Deadline.createFromDTO('51110867862'); expect(deadline.toDTO()[0]).to.be.equal(3866227606); expect(deadline.toDTO()[1]).to.be.equal(11); @@ -53,7 +56,7 @@ describe('Deadline', () => { it('should createComplete empty deadline', () => { const deadline = Deadline.createEmtpy(); - expect(deadline.value).to.be.equal(LocalDateTime.MIN); + expect(deadline.adjustedValue).to.be.equal(LocalDateTime.MIN.second()); }); it('make sure epochAdjustment is correct', () => { @@ -66,4 +69,26 @@ describe('Deadline', () => { expect(epochAdjustment.getUTCMinutes()).to.be.equal(0); expect(epochAdjustment.toUTCString()).to.be.equal('Mon, 11 Nov 2019 00:00:00 GMT'); }); + + it('should create local date time - default time zone', () => { + const deadline = Deadline.createFromDTO('1'); + const datetime = deadline.toLocalDateTime(epochAdjustment); + expect(datetime.year()).to.be.equal(2019); + expect(datetime.month().value()).to.be.equal(11); + expect(datetime.dayOfMonth()).to.be.equal(11); + expect(datetime.hour()).to.be.equal(0); + expect(datetime.second()).to.be.equal(0); + expect(datetime.minute()).to.be.equal(0); + }); + + it('should create local date time - customer time zone', () => { + const deadline = Deadline.createFromDTO('1'); + const datetime = deadline.toLocalDateTimeGivenTimeZone(epochAdjustment, ZoneId.of('UTC-2')); + expect(datetime.year()).to.be.equal(2019); + expect(datetime.month().value()).to.be.equal(11); + expect(datetime.dayOfMonth()).to.be.equal(10); + expect(datetime.hour()).to.be.equal(22); + expect(datetime.second()).to.be.equal(0); + expect(datetime.minute()).to.be.equal(0); + }); }); diff --git a/test/model/transaction/HashLockTransaction.spec.ts b/test/model/transaction/HashLockTransaction.spec.ts index c28e33cee9..b361138e11 100644 --- a/test/model/transaction/HashLockTransaction.spec.ts +++ b/test/model/transaction/HashLockTransaction.spec.ts @@ -14,6 +14,7 @@ * limitations under the License. */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { NetworkCurrencyLocal } from '../../../src/model/mosaic/NetworkCurrencyLocal'; import { NetworkType } from '../../../src/model/network/NetworkType'; @@ -26,11 +27,12 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('HashLockTransaction', () => { const account = TestingAccount; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); it('creation with an aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const transaction = HashLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -43,11 +45,11 @@ describe('HashLockTransaction', () => { }); it('should throw exception if it is not a aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); expect(() => { HashLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -57,10 +59,10 @@ describe('HashLockTransaction', () => { }); it('Notify Account', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const tx = HashLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, diff --git a/test/model/transaction/LockFundsTransaction.spec.ts b/test/model/transaction/LockFundsTransaction.spec.ts index 65ce76b186..d36ea5104f 100644 --- a/test/model/transaction/LockFundsTransaction.spec.ts +++ b/test/model/transaction/LockFundsTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { deepEqual } from 'assert'; import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { Mosaic } from '../../../src/model/mosaic/Mosaic'; @@ -40,6 +41,7 @@ describe('LockFundsTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -54,10 +56,10 @@ describe('LockFundsTransaction', () => { }); it('should default maxFee field be set to 0', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -70,10 +72,10 @@ describe('LockFundsTransaction', () => { }); it('should filled maxFee override transaction maxFee', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -86,10 +88,10 @@ describe('LockFundsTransaction', () => { }); it('creation with an aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const transaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -101,11 +103,11 @@ describe('LockFundsTransaction', () => { }); it('should throw exception if it is not a aggregate bonded tx', () => { - const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); expect(() => { LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -115,10 +117,10 @@ describe('LockFundsTransaction', () => { }); it('should create and sign LockFundsTransaction', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -133,10 +135,15 @@ describe('LockFundsTransaction', () => { describe('size', () => { it('should return 184 for LockFundsTransaction transaction byte size', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(epochAdjustment), + [], + NetworkType.MIJIN_TEST, + [], + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -146,10 +153,15 @@ describe('LockFundsTransaction', () => { }); it('should set payload size', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded( + Deadline.create(epochAdjustment), + [], + NetworkType.MIJIN_TEST, + [], + ); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -161,10 +173,10 @@ describe('LockFundsTransaction', () => { }); it('Test set maxFee using multiplier', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const lockFundsTransaction = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, @@ -177,12 +189,12 @@ describe('LockFundsTransaction', () => { }); it('Test resolveAlias can resolve', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const transaction = new LockFundsTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), UInt64.fromUint(0), new Mosaic(unresolvedMosaicId, UInt64.fromUint(1)), UInt64.fromUint(10), @@ -199,10 +211,10 @@ describe('LockFundsTransaction', () => { }); it('Notify Account', () => { - const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(1573430400), [], NetworkType.MIJIN_TEST, []); + const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); const tx = LockFundsTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createRelative(10), UInt64.fromUint(10), signedTransaction, diff --git a/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts b/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts index 36eb820bc6..c4ce9023ba 100644 --- a/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts +++ b/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { Address } from '../../../src/model/account/Address'; @@ -39,6 +40,7 @@ describe('MosaicAddressRestrictionTransaction', () => { const unresolvedAddress = new NamespaceId('address'); const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -59,7 +61,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('should createComplete an MosaicAddressRestrictionTransaction object and sign', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), account.address, @@ -83,7 +85,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('should createComplete an MosaicAddressRestrictionTransaction use mosaic alias', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespacId, UInt64.fromUint(1), account.address, @@ -108,7 +110,7 @@ describe('MosaicAddressRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicAddressRestrictionTransaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), namespacId, @@ -131,7 +133,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('should format targetAddress payload with 8 bytes binary namespaceId - targetAddressToString', () => { const transaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(1), new NamespaceId('nem.owner'), @@ -152,7 +154,7 @@ describe('MosaicAddressRestrictionTransaction', () => { it('Test set maxFee using multiplier', () => { const transaction = MosaicAddressRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId(UInt64.fromUint(1).toDTO()), UInt64.fromUint(1), new NamespaceId('nem.owner'), @@ -170,7 +172,7 @@ describe('MosaicAddressRestrictionTransaction', () => { const transaction = new MosaicAddressRestrictionTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), UInt64.fromUint(0), unresolvedMosaicId, UInt64.fromUint(8), diff --git a/test/model/transaction/MosaicAliasTransaction.spec.ts b/test/model/transaction/MosaicAliasTransaction.spec.ts index b130a5d59f..787b8c9aeb 100644 --- a/test/model/transaction/MosaicAliasTransaction.spec.ts +++ b/test/model/transaction/MosaicAliasTransaction.spec.ts @@ -29,10 +29,12 @@ import { deepEqual } from 'assert'; import { EmbeddedTransactionBuilder } from 'catbuffer-typescript/dist/EmbeddedTransactionBuilder'; import { TransactionType } from '../../../src/model/transaction/TransactionType'; import { AliasTransaction } from '../../../src/model/transaction/AliasTransaction'; +import { Duration } from 'js-joda'; describe('MosaicAliasTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -41,7 +43,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -56,7 +58,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -72,7 +74,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -96,7 +98,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = AliasTransaction.createForMosaic( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -121,7 +123,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -134,7 +136,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -150,7 +152,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -166,7 +168,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -180,7 +182,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicAliasTransaction = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, @@ -200,7 +202,7 @@ describe('MosaicAliasTransaction', () => { const namespaceId = new NamespaceId([33347626, 3779697293]); const mosaicId = new MosaicId([2262289484, 3405110546]); const tx = MosaicAliasTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), AliasAction.Link, namespaceId, mosaicId, diff --git a/test/model/transaction/MosaicDefinitionTransaction.spec.ts b/test/model/transaction/MosaicDefinitionTransaction.spec.ts index 997a6a96d6..1b1e6ecef3 100644 --- a/test/model/transaction/MosaicDefinitionTransaction.spec.ts +++ b/test/model/transaction/MosaicDefinitionTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { MosaicFlags } from '../../../src/model/mosaic/MosaicFlags'; @@ -29,13 +30,14 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('MosaicDefinitionTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -50,7 +52,7 @@ describe('MosaicDefinitionTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -66,7 +68,7 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it with flags 7', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, true), @@ -91,7 +93,7 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it with flags 0', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -117,7 +119,7 @@ describe('MosaicDefinitionTransaction', () => { describe('size', () => { it('should return 150 for MosaicDefinition transaction byte size', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, false), @@ -130,7 +132,7 @@ describe('MosaicDefinitionTransaction', () => { }); it('should set payload size', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(true, true, false), @@ -146,7 +148,7 @@ describe('MosaicDefinitionTransaction', () => { it('should createComplete an MosaicDefinitionTransaction object and sign it without duration', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -169,7 +171,7 @@ describe('MosaicDefinitionTransaction', () => { it('Test set maxFee using multiplier', () => { const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), @@ -185,7 +187,7 @@ describe('MosaicDefinitionTransaction', () => { it('Notify Account', () => { const tx = MosaicDefinitionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), MosaicNonce.createFromUint8Array(new Uint8Array([0xe6, 0xde, 0x84, 0xb8])), // nonce new MosaicId(UInt64.fromUint(1).toDTO()), // ID MosaicFlags.create(false, false, false), diff --git a/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts b/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts index 302ece8187..fd468036cb 100644 --- a/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts +++ b/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { MosaicId } from '../../../src/model/mosaic/MosaicId'; @@ -38,6 +39,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -55,7 +57,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -85,7 +87,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespacId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -119,7 +121,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -149,7 +151,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const mosaicGlobalRestrictionTransaction = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), @@ -169,7 +171,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicGlobalRestrictionTransaction = new MosaicGlobalRestrictionTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), UInt64.fromUint(0), unresolvedMosaicId, unresolvedMosaicId, @@ -195,7 +197,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { const mosaicId = new MosaicId(UInt64.fromUint(1).toDTO()); const referenceMosaicId = new MosaicId(UInt64.fromUint(2).toDTO()); const tx = MosaicGlobalRestrictionTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, UInt64.fromUint(1), UInt64.fromUint(9), diff --git a/test/model/transaction/MosaicMetadataTransaction.spec.ts b/test/model/transaction/MosaicMetadataTransaction.spec.ts index 330a96f6e4..f9ef79a171 100644 --- a/test/model/transaction/MosaicMetadataTransaction.spec.ts +++ b/test/model/transaction/MosaicMetadataTransaction.spec.ts @@ -33,6 +33,7 @@ import { TestingAccount } from '../../conf/conf.spec'; import { EmbeddedTransactionBuilder } from 'catbuffer-typescript'; import { Address } from '../../../src/model/account/Address'; import { TransactionType } from '../../../src/model/transaction/TransactionType'; +import { Duration } from 'js-joda'; describe('MosaicMetadataTransaction', () => { let account: Account; @@ -40,6 +41,7 @@ describe('MosaicMetadataTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -55,7 +57,7 @@ describe('MosaicMetadataTransaction', () => { it('should default maxFee field be set to 0', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -70,7 +72,7 @@ describe('MosaicMetadataTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -86,7 +88,7 @@ describe('MosaicMetadataTransaction', () => { it('should create and sign an MosaicMetadataTransaction object', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -105,7 +107,7 @@ describe('MosaicMetadataTransaction', () => { it('should create and sign an MosaicMetadataTransaction object using alias', () => { const namespacId = NamespaceId.createFromEncoded('9550CA3FC9B41FC5'); const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), namespacId, @@ -124,7 +126,7 @@ describe('MosaicMetadataTransaction', () => { describe('size', () => { it('should return 182 for MosaicMetadataTransaction byte size', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -138,7 +140,7 @@ describe('MosaicMetadataTransaction', () => { it('should set payload size', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -154,7 +156,7 @@ describe('MosaicMetadataTransaction', () => { it('Test set maxFee using multiplier', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -172,7 +174,7 @@ describe('MosaicMetadataTransaction', () => { const mosaicMetadataTransaction = new MosaicMetadataTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), UInt64.fromUint(0), account.address, UInt64.fromUint(1000), @@ -192,7 +194,7 @@ describe('MosaicMetadataTransaction', () => { it('should create EmbeddedTransactionBuilder', () => { const mosaicMetadataTransaction = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -212,7 +214,7 @@ describe('MosaicMetadataTransaction', () => { it('Notify Account', () => { const tx = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), @@ -234,7 +236,7 @@ describe('MosaicMetadataTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = MosaicMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), alias, UInt64.fromUint(1000), new MosaicId([2262289484, 3405110546]), diff --git a/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts b/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts index 7c08c73a79..e69dfec814 100644 --- a/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts +++ b/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { MosaicId } from '../../../src/model/mosaic/MosaicId'; @@ -38,6 +39,7 @@ describe('MosaicSupplyChangeTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -54,7 +56,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should default maxFee field be set to 0', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -68,7 +70,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -83,7 +85,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should createComplete an MosaicSupplyChangeTransaction object and sign it', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -107,7 +109,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should return 145 for MosaicSupplyChange transaction byte size', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -119,7 +121,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('should set payload size', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -134,7 +136,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('Test set maxFee using multiplier', () => { const mosaicId = new MosaicId([2262289484, 3405110546]); const mosaicSupplyChangeTransaction = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), mosaicId, MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), @@ -149,7 +151,7 @@ describe('MosaicSupplyChangeTransaction', () => { const mosaicSupplyChangeTransaction = new MosaicSupplyChangeTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), UInt64.fromUint(0), unresolvedMosaicId, MosaicSupplyChangeAction.Increase, @@ -167,7 +169,7 @@ describe('MosaicSupplyChangeTransaction', () => { it('Notify Account', () => { const tx = MosaicSupplyChangeTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new MosaicId([2262289484, 3405110546]), MosaicSupplyChangeAction.Increase, UInt64.fromUint(10), diff --git a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts index 22779d36cf..5a817d2912 100644 --- a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts +++ b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts @@ -24,6 +24,7 @@ import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; +import { Duration } from 'js-joda'; describe('MultisigAccountModificationTransaction', () => { let account: Account; @@ -36,13 +37,14 @@ describe('MultisigAccountModificationTransaction', () => { 'B1B5581FC81A6970DEE418D2C2978F2724228B7B36C5C6DF71B0162BB04778B4', NetworkType.MIJIN_TEST, ); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [address1, address2], @@ -56,7 +58,7 @@ describe('MultisigAccountModificationTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [address1, address2], @@ -71,7 +73,7 @@ describe('MultisigAccountModificationTransaction', () => { it('should createComplete an MultisigAccountModificationTransaction object and sign it', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 2, 1, [address1, address2], @@ -96,7 +98,7 @@ describe('MultisigAccountModificationTransaction', () => { describe('size', () => { it('should return 160 for MultisigAccountModificationTransaction transaction byte size with 1 modification', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 1, 1, [address1], @@ -110,7 +112,7 @@ describe('MultisigAccountModificationTransaction', () => { }); it('should set payload size', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 1, 1, [address1], @@ -127,7 +129,7 @@ describe('MultisigAccountModificationTransaction', () => { it('Test set maxFee using multiplier', () => { const modifyMultisigAccountTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 1, 1, [address1], @@ -142,7 +144,7 @@ describe('MultisigAccountModificationTransaction', () => { it('Notify Account', () => { const txAddition = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 1, 1, [address1], @@ -160,7 +162,7 @@ describe('MultisigAccountModificationTransaction', () => { expect(txAddition.shouldNotifyAccount(account.address, [])).to.be.true; const txDeletion = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 1, 1, [], @@ -182,7 +184,7 @@ describe('MultisigAccountModificationTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const txAddition = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 1, 1, [alias], @@ -203,7 +205,7 @@ describe('MultisigAccountModificationTransaction', () => { expect(txAddition.shouldNotifyAccount(account.address, [])).to.be.true; const txDeletion = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 1, 1, [], diff --git a/test/model/transaction/NamespaceMetadataTransaction.spec.ts b/test/model/transaction/NamespaceMetadataTransaction.spec.ts index 040dd106da..e366bee763 100644 --- a/test/model/transaction/NamespaceMetadataTransaction.spec.ts +++ b/test/model/transaction/NamespaceMetadataTransaction.spec.ts @@ -27,17 +27,19 @@ import { EmbeddedTransactionBuilder } from 'catbuffer-typescript/dist/EmbeddedTr import { TransactionType } from '../../../src/model/transaction/TransactionType'; import { deepEqual } from 'assert'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('NamespaceMetadataTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -52,7 +54,7 @@ describe('NamespaceMetadataTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -68,7 +70,7 @@ describe('NamespaceMetadataTransaction', () => { it('should create and sign an NamespaceMetadataTransaction object', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -87,7 +89,7 @@ describe('NamespaceMetadataTransaction', () => { describe('size', () => { it('should return 182 for NamespaceMetadataTransaction byte size', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -101,7 +103,7 @@ describe('NamespaceMetadataTransaction', () => { it('should set payload size', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -117,7 +119,7 @@ describe('NamespaceMetadataTransaction', () => { it('Test set maxFee using multiplier', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -133,7 +135,7 @@ describe('NamespaceMetadataTransaction', () => { it('should create EmbeddedTransactionBuilder', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -153,7 +155,7 @@ describe('NamespaceMetadataTransaction', () => { it('should resolve alias', () => { const namespaceMetadataTransaction = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -169,7 +171,7 @@ describe('NamespaceMetadataTransaction', () => { it('Notify Account', () => { const tx = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.address, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), @@ -191,7 +193,7 @@ describe('NamespaceMetadataTransaction', () => { const alias = new NamespaceId('test'); const wrongAlias = new NamespaceId('wrong'); const tx = NamespaceMetadataTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), alias, UInt64.fromUint(1000), new NamespaceId([2262289484, 3405110546]), diff --git a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts index e322fdc275..244e35014f 100644 --- a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts +++ b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Convert } from '../../../src/core/format'; import { Account } from '../../../src/model/account/Account'; import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; @@ -27,13 +28,14 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('NamespaceRegistrationTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -45,7 +47,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -58,7 +60,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should createComplete an root NamespaceRegistrationTransaction object and sign it', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -76,7 +78,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should createComplete an sub NamespaceRegistrationTransaction object and sign it', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', 'parent-test-namespace', NetworkType.MIJIN_TEST, @@ -91,7 +93,7 @@ describe('NamespaceRegistrationTransaction', () => { it('should createComplete an sub NamespaceRegistrationTransaction object and sign it - ParentId', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createSubNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', new NamespaceId([929036875, 2226345261]), NetworkType.MIJIN_TEST, @@ -107,7 +109,7 @@ describe('NamespaceRegistrationTransaction', () => { describe('size', () => { it('should return 165 for NamespaceRegistrationTransaction with name of 19 bytes', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -117,7 +119,7 @@ describe('NamespaceRegistrationTransaction', () => { }); it('should set payload size', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -130,7 +132,7 @@ describe('NamespaceRegistrationTransaction', () => { it('Test set maxFee using multiplier', () => { const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, @@ -143,7 +145,7 @@ describe('NamespaceRegistrationTransaction', () => { it('Notify Account', () => { const tx = NamespaceRegistrationTransaction.createRootNamespace( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'root-test-namespace', UInt64.fromUint(1000), NetworkType.MIJIN_TEST, diff --git a/test/model/transaction/NodeKeyLinkTransaction.spec.ts b/test/model/transaction/NodeKeyLinkTransaction.spec.ts index 406bdc5d0a..f93711619f 100644 --- a/test/model/transaction/NodeKeyLinkTransaction.spec.ts +++ b/test/model/transaction/NodeKeyLinkTransaction.spec.ts @@ -24,17 +24,19 @@ import { LinkAction } from '../../../src/model/transaction/LinkAction'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('NodeKeyLinkTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); it('should default maxFee field be set to 0', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -46,7 +48,7 @@ describe('NodeKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -59,7 +61,7 @@ describe('NodeKeyLinkTransaction', () => { it('should create an NodeKeyLinkTransaction object with link action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -77,7 +79,7 @@ describe('NodeKeyLinkTransaction', () => { it('should create an NodeKeyLinkTransaction object with unlink action', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -96,7 +98,7 @@ describe('NodeKeyLinkTransaction', () => { describe('size', () => { it('should return 161 for NodeKeyLinkTransaction byte size', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -106,7 +108,7 @@ describe('NodeKeyLinkTransaction', () => { }); it('should set payload size', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -119,7 +121,7 @@ describe('NodeKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const nodeKeyLinkTransaction = NodeKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -131,7 +133,12 @@ describe('NodeKeyLinkTransaction', () => { }); it('Notify Account', () => { - const tx = NodeKeyLinkTransaction.create(Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); + const tx = NodeKeyLinkTransaction.create( + Deadline.create(epochAdjustment), + account.publicKey, + LinkAction.Unlink, + NetworkType.MIJIN_TEST, + ); let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; diff --git a/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts b/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts index 1ee2de457e..6445821b0d 100644 --- a/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts +++ b/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts @@ -15,6 +15,7 @@ */ import { expect } from 'chai'; +import { Duration } from 'js-joda'; import { Account } from '../../../src/model/account/Account'; import { Address } from '../../../src/model/account/Address'; import { MessageMarker } from '../../../src/model/message/MessageMarker'; @@ -31,6 +32,7 @@ describe('PersistentDelegationRequestTransaction', () => { const recipientPublicKey = '9DBF67474D6E1F8B131B4EB1F5BA0595AFFAE1123607BC1048F342193D7E669F'; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; const messageMarker = MessageMarker.PersistentDelegationUnlock; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; @@ -38,7 +40,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should default maxFee field be set to 0', () => { const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, @@ -51,7 +53,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, @@ -65,7 +67,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should createComplete an persistentDelegationRequestTransaction object and sign it', () => { const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, @@ -92,7 +94,7 @@ describe('PersistentDelegationRequestTransaction', () => { it('should throw exception with invalid harvester publicKey (message)', () => { expect(() => { PersistentDelegationRequestTransaction.createPersistentDelegationRequestTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), 'abc', vrfPrivateKey, recipientPublicKey, diff --git a/test/model/transaction/SecretLockTransaction.spec.ts b/test/model/transaction/SecretLockTransaction.spec.ts index 73fbfa00b7..b39d968bd9 100644 --- a/test/model/transaction/SecretLockTransaction.spec.ts +++ b/test/model/transaction/SecretLockTransaction.spec.ts @@ -36,6 +36,7 @@ import { TransactionInfo } from '../../../src/model/transaction/TransactionInfo' import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import * as CryptoJS from 'crypto-js'; +import { Duration } from 'js-joda'; describe('SecretLockTransaction', () => { let account: Account; @@ -44,6 +45,7 @@ describe('SecretLockTransaction', () => { const unresolvedMosaicId = new NamespaceId('mosaic'); const mosaicId = new MosaicId('0DC67FBE1CAD29E5'); const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -65,7 +67,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -82,7 +84,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -100,7 +102,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -120,7 +122,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -139,7 +141,7 @@ describe('SecretLockTransaction', () => { expect(() => { const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -154,7 +156,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -174,7 +176,7 @@ describe('SecretLockTransaction', () => { expect(() => { const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_160, @@ -188,7 +190,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -208,7 +210,7 @@ describe('SecretLockTransaction', () => { expect(() => { const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -224,7 +226,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -240,7 +242,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Hash_256, @@ -258,7 +260,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -278,7 +280,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const secretLockTransaction = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -296,7 +298,7 @@ describe('SecretLockTransaction', () => { const secretLockTransaction = new SecretLockTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), UInt64.fromUint(0), new Mosaic(unresolvedMosaicId, UInt64.fromUint(1)), UInt64.fromUint(100), @@ -320,7 +322,7 @@ describe('SecretLockTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, @@ -342,7 +344,7 @@ describe('SecretLockTransaction', () => { const namespaceId = new NamespaceId('test'); const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const canNotify = SecretLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkCurrencyLocal.createAbsolute(10), UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, diff --git a/test/model/transaction/SecretProofTransaction.spec.ts b/test/model/transaction/SecretProofTransaction.spec.ts index 847a77afdf..a1c37a0834 100644 --- a/test/model/transaction/SecretProofTransaction.spec.ts +++ b/test/model/transaction/SecretProofTransaction.spec.ts @@ -34,12 +34,14 @@ import { TestingAccount } from '../../conf/conf.spec'; import { EmbeddedTransactionBuilder } from 'catbuffer-typescript/dist/EmbeddedTransactionBuilder'; import { TransactionType } from '../../../src/model/transaction/TransactionType'; import * as CryptoJS from 'crypto-js'; +import { Duration } from 'js-joda'; describe('SecretProofTransaction', () => { let account: Account; let statement: Statement; const unresolvedAddress = new NamespaceId('address'); const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; statement = new Statement( @@ -56,7 +58,7 @@ describe('SecretProofTransaction', () => { it('should default maxFee field be set to 0', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -71,7 +73,7 @@ describe('SecretProofTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -87,7 +89,7 @@ describe('SecretProofTransaction', () => { it('should be created with LockHashAlgorithm: Op_Sha3_256 secret', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -103,7 +105,7 @@ describe('SecretProofTransaction', () => { expect(() => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, 'non valid hash', account.address, @@ -116,7 +118,7 @@ describe('SecretProofTransaction', () => { it('should be created with LockHashAlgorithm: Op_Hash_160 secret', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_160, CryptoJS.RIPEMD160(CryptoJS.SHA256(proof).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex), account.address, @@ -132,7 +134,7 @@ describe('SecretProofTransaction', () => { expect(() => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_160, 'non valid hash', account.address, @@ -145,7 +147,7 @@ describe('SecretProofTransaction', () => { it('should be created with LockHashAlgorithm: Op_Hash_256 secret', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_256, CryptoJS.SHA256(CryptoJS.SHA256(proof).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex), account.address, @@ -161,7 +163,7 @@ describe('SecretProofTransaction', () => { expect(() => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_256, 'non valid hash', account.address, @@ -175,7 +177,7 @@ describe('SecretProofTransaction', () => { it('should return 219 for SecretProofTransaction with proof and secret both 32 bytes', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Hash_256, CryptoJS.SHA256(CryptoJS.SHA256(proof).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex), account.address, @@ -190,7 +192,7 @@ describe('SecretProofTransaction', () => { it('should create and sign SecretProof Transaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -209,7 +211,7 @@ describe('SecretProofTransaction', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const recipientAddress = new NamespaceId('test'); const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), recipientAddress, @@ -225,7 +227,7 @@ describe('SecretProofTransaction', () => { it('Test set maxFee using multiplier', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -242,7 +244,7 @@ describe('SecretProofTransaction', () => { const transferTransaction = new SecretProofTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), @@ -264,7 +266,7 @@ describe('SecretProofTransaction', () => { const secretProofTransaction = new SecretProofTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), @@ -286,7 +288,7 @@ describe('SecretProofTransaction', () => { it('should return secret bytes', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const secretProofTransaction = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -301,7 +303,7 @@ describe('SecretProofTransaction', () => { it('Notify Account', () => { const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const tx = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, @@ -322,7 +324,7 @@ describe('SecretProofTransaction', () => { const namespaceId = new NamespaceId('test'); const proof = 'B778A39A3663719DFC5E48C9D78431B1E45C2AF9DF538782BF199C189DABEAC7'; const canNotify = SecretProofTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), account.address, diff --git a/test/model/transaction/Transaction.spec.ts b/test/model/transaction/Transaction.spec.ts index 2bca23b94b..c4a983f095 100644 --- a/test/model/transaction/Transaction.spec.ts +++ b/test/model/transaction/Transaction.spec.ts @@ -32,10 +32,11 @@ import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; import { TransactionMapping } from '../../../src/core/utils/TransactionMapping'; +import { Duration } from 'js-joda'; describe('Transaction', () => { let account: Account; - + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -76,7 +77,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -92,7 +93,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -106,7 +107,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -122,7 +123,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -138,7 +139,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -154,14 +155,14 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, new TransactionInfo(UInt64.fromUint(100), 1, 'id_hash', 'hash', 'hash'), ); expect(() => { - transaction.reapplyGiven(Deadline.create(1573430400)); + transaction.reapplyGiven(Deadline.create(epochAdjustment)); }).to.throws("an Announced transaction can't be modified"); }); it('should return a new transaction', () => { @@ -169,13 +170,13 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, ); - const newTransaction = transaction.reapplyGiven(Deadline.create(1573430400)); + const newTransaction = transaction.reapplyGiven(Deadline.create(epochAdjustment)); expect(newTransaction).to.not.equal(transaction); }); it('should overide deadline properly', () => { @@ -183,16 +184,16 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, ); - const newDeadline = Deadline.create(1573430400, 3); + const newDeadline = Deadline.create(epochAdjustment, 3); const newTransaction = transaction.reapplyGiven(newDeadline); - const equal = newTransaction.deadline.value.equals(transaction.deadline.value); - const after = newTransaction.deadline.value.isAfter(transaction.deadline.value); + const equal = newTransaction.deadline.adjustedValue === transaction.deadline.adjustedValue; + const after = newTransaction.deadline.adjustedValue > transaction.deadline.adjustedValue; expect(newTransaction.deadline).to.be.equal(newDeadline); expect(equal).to.be.equal(false); expect(after).to.be.equal(true); @@ -205,14 +206,14 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -227,7 +228,7 @@ describe('Transaction', () => { describe('Transaction serialize', () => { it('Should return serialized payload', () => { const transaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -247,7 +248,7 @@ describe('Transaction', () => { TransactionType.TRANSFER, NetworkType.MIJIN_TEST, 1, - Deadline.create(1573430400), + Deadline.create(epochAdjustment), UInt64.fromUint(0), undefined, undefined, @@ -378,7 +379,7 @@ describe('Transaction', () => { it('is signed', () => { let tx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -387,7 +388,7 @@ describe('Transaction', () => { expect(tx.isSigned(account.address)).to.be.false; const signed = tx.signWith(account, '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'); - tx = TransactionMapping.createFromPayload(signed.payload, 1573430400) as Transaction; + tx = TransactionMapping.createFromPayload(signed.payload) as Transaction; expect((tx as Transaction).isSigned(account.address)).to.be.true; expect((tx as Transaction).isSigned(Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'))).to.be.false; }); diff --git a/test/model/transaction/TransactionStatus.spec.ts b/test/model/transaction/TransactionStatus.spec.ts index 19edfc0716..9591d844f2 100644 --- a/test/model/transaction/TransactionStatus.spec.ts +++ b/test/model/transaction/TransactionStatus.spec.ts @@ -25,7 +25,7 @@ import { UInt64 } from '../../../src/model/UInt64'; describe('TransactionStatus', () => { it('should createComplete TransactionStatus object', () => { const transactionStatusDTO = { - deadline: Deadline.createFromDTO('1', 1573430400), + deadline: Deadline.createFromDTO('1'), group: TransactionGroupEnum.Confirmed, hash: '18C036C20B32348D63684E09A13128A2C18F6A75650D3A5FB43853D716E5E219', height: new UInt64([1, 0]), diff --git a/test/model/transaction/TransactionStatusError.spec.ts b/test/model/transaction/TransactionStatusError.spec.ts index 17802b42df..62f4daa941 100644 --- a/test/model/transaction/TransactionStatusError.spec.ts +++ b/test/model/transaction/TransactionStatusError.spec.ts @@ -33,7 +33,7 @@ describe('TransactionStatusError', () => { statusInfoErrorDTO.address, statusInfoErrorDTO.hash, statusInfoErrorDTO.code, - Deadline.createFromDTO(statusInfoErrorDTO.deadline, 1573430400), + Deadline.createFromDTO(statusInfoErrorDTO.deadline), ); expect(transactionStatusError.address).to.be.equal(statusInfoErrorDTO.address); diff --git a/test/model/transaction/TransferTransaction.spec.ts b/test/model/transaction/TransferTransaction.spec.ts index d90d0508b9..0fdab15185 100644 --- a/test/model/transaction/TransferTransaction.spec.ts +++ b/test/model/transaction/TransferTransaction.spec.ts @@ -39,6 +39,7 @@ import { ResolutionType } from '../../../src/model/receipt/ResolutionType'; import { ReceiptSource } from '../../../src/model/receipt/ReceiptSource'; import { ResolutionEntry } from '../../../src/model/receipt/ResolutionEntry'; import { TransactionInfo } from '../../../src/model/transaction/TransactionInfo'; +import { Duration } from 'js-joda'; describe('TransferTransaction', () => { let account: Account; @@ -51,6 +52,7 @@ describe('TransferTransaction', () => { const unresolvedAddress = new NamespaceId('address'); const unresolvedMosaicId = new NamespaceId('mosaic'); const mosaicId = new MosaicId('0DC67FBE1CAD29E5'); + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; }); @@ -73,7 +75,7 @@ describe('TransferTransaction', () => { it('should default maxFee field be set to 0', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -86,7 +88,7 @@ describe('TransferTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -100,7 +102,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object and sign it without mosaics', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -121,7 +123,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object with empty message', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], EmptyMessage, @@ -142,7 +144,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object and sign it with mosaics', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -165,7 +167,7 @@ describe('TransferTransaction', () => { it('should createComplete an TransferTransaction object with NamespaceId recipientAddress', () => { const addressAlias = new NamespaceId('nem.owner'); const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), addressAlias, [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -188,7 +190,7 @@ describe('TransferTransaction', () => { it('should format TransferTransaction payload with 24 bytes binary address', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -205,7 +207,7 @@ describe('TransferTransaction', () => { it('should format TransferTransaction payload with 8 bytes binary namespaceId', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new NamespaceId('nem.owner'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -223,7 +225,7 @@ describe('TransferTransaction', () => { describe('size', () => { it('should return 180 for TransferTransaction with 1 mosaic and message NEM', () => { const transaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), @@ -235,7 +237,7 @@ describe('TransferTransaction', () => { it('should set payloadsize', () => { const transaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('NEM'), @@ -249,7 +251,7 @@ describe('TransferTransaction', () => { it('should create TransferTransaction and sign using catbuffer-typescript', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PlainMessage.create('test-message'), @@ -271,7 +273,7 @@ describe('TransferTransaction', () => { it('should create Transafer transaction for persistent harvesting delegation request transaction', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PersistentHarvestingDelegationMessage.create(delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, NetworkType.MIJIN_TEST), @@ -283,7 +285,7 @@ describe('TransferTransaction', () => { it('should createComplete an persistentDelegationRequestTransaction object and sign it', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PersistentHarvestingDelegationMessage.create(delegatedPrivateKey, vrfPrivateKey, recipientPublicKey, NetworkType.MIJIN_TEST), @@ -304,7 +306,7 @@ describe('TransferTransaction', () => { it('should throw exception with mosaic provided when creating persistentDelegationRequestTransaction', () => { expect(() => { TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PersistentHarvestingDelegationMessage.create( @@ -321,7 +323,7 @@ describe('TransferTransaction', () => { it('should throw exception with invalid message when creating persistentDelegationRequestTransaction', () => { expect(() => { TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PersistentHarvestingDelegationMessage.create('abc', vrfPrivateKey, recipientPublicKey, NetworkType.MIJIN_TEST), @@ -333,7 +335,7 @@ describe('TransferTransaction', () => { it('should throw exception with invalid private key when creating persistentDelegationRequestTransaction', () => { expect(() => { TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createRelative(100)], PersistentHarvestingDelegationMessage.create( @@ -354,7 +356,7 @@ describe('TransferTransaction', () => { ]; const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), mosaics, PlainMessage.create('NEM'), @@ -370,7 +372,7 @@ describe('TransferTransaction', () => { '64000000000000000000000000000000C8000000000000000000000000000000', ); - const sorted = CreateTransactionFromPayload(signedTransaction.payload, 1573430400) as TransferTransaction; + const sorted = CreateTransactionFromPayload(signedTransaction.payload) as TransferTransaction; expect(sorted.mosaics[0].id.id.compact()).to.be.equal(100); expect(sorted.mosaics[1].id.id.compact()).to.be.equal(200); }); @@ -383,7 +385,7 @@ describe('TransferTransaction', () => { ]; const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), mosaics, PlainMessage.create('NEM'), @@ -395,7 +397,7 @@ describe('TransferTransaction', () => { expect(transferTransaction.mosaics[2].id.toHex()).to.be.equal('67F2B76F28BD36BA'); const signedTransaction = transferTransaction.signWith(account, generationHash); - const sorted = CreateTransactionFromPayload(signedTransaction.payload, 1573430400) as TransferTransaction; + const sorted = CreateTransactionFromPayload(signedTransaction.payload) as TransferTransaction; expect(sorted.mosaics[0].id.toHex()).to.be.equal('67F2B76F28BD36BA'); expect(sorted.mosaics[1].id.toHex()).to.be.equal('77A1969932D987D7'); expect(sorted.mosaics[2].id.toHex()).to.be.equal('D525AD41D95FCF29'); @@ -404,14 +406,14 @@ describe('TransferTransaction', () => { it('Test Serialization and Deserialization Using namespaceIds', () => { const namespaceId = new NamespaceId('testaccount2'); const transferTransaction = TransferTransaction.create( - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), namespaceId, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), NetworkType.MIJIN_TEST, ); const payload = transferTransaction.serialize(); - const newTransaction = CreateTransactionFromPayload(payload, 1573430400) as TransferTransaction; + const newTransaction = CreateTransactionFromPayload(payload) as TransferTransaction; const newPayload = newTransaction.serialize(); expect(newPayload).to.be.equal(payload); expect(newTransaction.recipientToString()).to.be.equal(transferTransaction.recipientToString()); @@ -419,7 +421,7 @@ describe('TransferTransaction', () => { it('Test set maxFee using multiplier', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -433,7 +435,7 @@ describe('TransferTransaction', () => { it('Test set maxFee using multiplier to throw', () => { const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -442,7 +444,7 @@ describe('TransferTransaction', () => { expect(() => { AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -454,7 +456,7 @@ describe('TransferTransaction', () => { const transferTransaction = new TransferTransaction( NetworkType.MIJIN_TEST, 1, - Deadline.createFromDTO('1', 1573430400), + Deadline.createFromDTO('1'), UInt64.fromUint(0), unresolvedAddress, [new Mosaic(unresolvedMosaicId, UInt64.fromUint(1))], @@ -475,7 +477,7 @@ describe('TransferTransaction', () => { it('Notify Account', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const tx = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), address, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), @@ -495,7 +497,7 @@ describe('TransferTransaction', () => { const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const namespaceId = new NamespaceId('test'); const canNotify = TransferTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), namespaceId, [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), diff --git a/test/model/transaction/VotingKeyLinkTransaction.spec.ts b/test/model/transaction/VotingKeyLinkTransaction.spec.ts index d4bd862a5b..66268b5415 100644 --- a/test/model/transaction/VotingKeyLinkTransaction.spec.ts +++ b/test/model/transaction/VotingKeyLinkTransaction.spec.ts @@ -24,6 +24,7 @@ import { LinkAction } from '../../../src/model/transaction/LinkAction'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('VotingKeyLinkTransaction', () => { let account: Account; @@ -31,6 +32,7 @@ describe('VotingKeyLinkTransaction', () => { const startEpoch = 1; const endEpoch = 10; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); before(() => { account = TestingAccount; votingKey = '344B9146A1F8DBBD8AFC830A2AAB7A83692E73AD775159B811355B1D2C0C27120243B10A16D4B5001B2AF0ED456C82D0'; @@ -38,7 +40,7 @@ describe('VotingKeyLinkTransaction', () => { it('should default maxFee field be set to 0', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -54,7 +56,7 @@ describe('VotingKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -71,7 +73,7 @@ describe('VotingKeyLinkTransaction', () => { it('should create an votingKeyLinkTransaction object with link action', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -93,7 +95,7 @@ describe('VotingKeyLinkTransaction', () => { it('should create an VotingKeyLinkTransaction object with unlink action', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -116,7 +118,7 @@ describe('VotingKeyLinkTransaction', () => { describe('size', () => { it('should return 185 for VotingKeyLinkTransaction byte size', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -130,7 +132,7 @@ describe('VotingKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const votingKeyLinkTransaction = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), votingKey, startEpoch, endEpoch, @@ -145,7 +147,7 @@ describe('VotingKeyLinkTransaction', () => { it('Notify Account', () => { const tx = VotingKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, startEpoch, endEpoch, diff --git a/test/model/transaction/VrfKeyLinkTransaction.spec.ts b/test/model/transaction/VrfKeyLinkTransaction.spec.ts index 1ad464af04..d623afa913 100644 --- a/test/model/transaction/VrfKeyLinkTransaction.spec.ts +++ b/test/model/transaction/VrfKeyLinkTransaction.spec.ts @@ -24,6 +24,7 @@ import { LinkAction } from '../../../src/model/transaction/LinkAction'; import { UInt64 } from '../../../src/model/UInt64'; import { TestingAccount } from '../../conf/conf.spec'; import { Address } from '../../../src/model/account/Address'; +import { Duration } from 'js-joda'; describe('VrfKeyLinkTransaction', () => { let account: Account; @@ -31,10 +32,11 @@ describe('VrfKeyLinkTransaction', () => { before(() => { account = TestingAccount; }); + const epochAdjustment = Duration.ofSeconds(1573430400); it('should default maxFee field be set to 0', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -46,7 +48,7 @@ describe('VrfKeyLinkTransaction', () => { it('should filled maxFee override transaction maxFee', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -59,7 +61,7 @@ describe('VrfKeyLinkTransaction', () => { it('should create an VrfKeyLinkTransaction object with link action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Link, NetworkType.MIJIN_TEST, @@ -77,7 +79,7 @@ describe('VrfKeyLinkTransaction', () => { it('should create an VrfKeyLinkTransaction object with unlink action', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -96,7 +98,7 @@ describe('VrfKeyLinkTransaction', () => { describe('size', () => { it('should return 161 for VrfKeyLinkTransaction byte size', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -108,7 +110,7 @@ describe('VrfKeyLinkTransaction', () => { it('Test set maxFee using multiplier', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST, @@ -120,7 +122,12 @@ describe('VrfKeyLinkTransaction', () => { }); it('Notify Account', () => { - const tx = VrfKeyLinkTransaction.create(Deadline.create(1573430400), account.publicKey, LinkAction.Unlink, NetworkType.MIJIN_TEST); + const tx = VrfKeyLinkTransaction.create( + Deadline.create(epochAdjustment), + account.publicKey, + LinkAction.Unlink, + NetworkType.MIJIN_TEST, + ); let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; diff --git a/test/service/AggregateTransactionService.spec.ts b/test/service/AggregateTransactionService.spec.ts index eb695be909..b49a93307c 100644 --- a/test/service/AggregateTransactionService.spec.ts +++ b/test/service/AggregateTransactionService.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { of as observableOf } from 'rxjs'; import { deepEqual, instance, mock, when } from 'ts-mockito'; import { MultisigRepository } from '../../src/infrastructure/MultisigRepository'; @@ -91,6 +91,7 @@ describe('AggregateTransactionService', () => { NetworkType.MIJIN_TEST, ); const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; + const epochAdjustment = Duration.ofSeconds(1573430400); function givenMultisig2AccountInfo(): MultisigAccountInfo { return new MultisigAccountInfo(multisig2.address, 2, 1, [multisig1.address, account1.address], []); @@ -188,7 +189,7 @@ describe('AggregateTransactionService', () => { * Expecting complete as Bob needs 2 signatures (account1 && (account2 || account3)) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -196,7 +197,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -204,7 +205,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account2], generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -221,7 +222,7 @@ describe('AggregateTransactionService', () => { * Expecting incomplete as Bob needs 2 signatures (account1 && (account2 || account3)) but only got account1 */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -229,7 +230,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -237,7 +238,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [], generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -254,7 +255,7 @@ describe('AggregateTransactionService', () => { * Expecting incomplete as Bob needs 2 signatures (account1 && (account2 || account3)) but got account4 */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -262,7 +263,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -270,7 +271,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account4], generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -288,7 +289,7 @@ describe('AggregateTransactionService', () => { * Expecting incomplete as Bob needs 2 signatures (account1 && (account2 || account3)) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -296,7 +297,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -304,14 +305,14 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount), transferTransaction2.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], ); const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account4], generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -329,7 +330,7 @@ describe('AggregateTransactionService', () => { * Expecting complete */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -337,7 +338,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account2.address, [], PlainMessage.create('test-message'), @@ -345,14 +346,14 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig2.publicAccount), transferTransaction2.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], ); const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account4, account2], generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -367,7 +368,7 @@ describe('AggregateTransactionService', () => { * to determine if the act is complete or not */ const modifyMultisigTransaction = MultisigAccountModificationTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), 1, 1, [], @@ -376,14 +377,14 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [modifyMultisigTransaction.toAggregate(multisig2.publicAccount)], NetworkType.MIJIN_TEST, [], ); const signedTransaction = aggregateTransaction.signWith(account2, generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -398,7 +399,7 @@ describe('AggregateTransactionService', () => { * to determine if the act is complete or not */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -406,7 +407,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -414,7 +415,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signWith(account1, generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -430,7 +431,7 @@ describe('AggregateTransactionService', () => { * Bob sign */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -438,7 +439,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account4.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -446,7 +447,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signWith(account4, generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -468,7 +469,7 @@ describe('AggregateTransactionService', () => { * Then the contract should appear as complete */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account1.address, [], PlainMessage.create('test-message'), @@ -476,7 +477,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -484,7 +485,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account4.publicAccount), transferTransaction2.toAggregate(account1.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -492,7 +493,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [account4], generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -513,7 +514,7 @@ describe('AggregateTransactionService', () => { * Then the contract should appear as incomplete */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account1.address, [], PlainMessage.create('test-message'), @@ -521,7 +522,7 @@ describe('AggregateTransactionService', () => { ); const transferTransaction2 = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -529,7 +530,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account4.publicAccount), transferTransaction2.toAggregate(account1.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -537,7 +538,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account1, [], generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; @@ -551,7 +552,7 @@ describe('AggregateTransactionService', () => { * Bob (multisig3): is a 2/2 multisig account (account2 && account3) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -559,7 +560,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig3.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -567,7 +568,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account2, [account3], generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.true; @@ -581,7 +582,7 @@ describe('AggregateTransactionService', () => { * Bob (multisig3): is a 2/2 multisig account (account2 && account3) */ const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), account4.address, [], PlainMessage.create('test-message'), @@ -589,7 +590,7 @@ describe('AggregateTransactionService', () => { ); const aggregateTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(multisig3.publicAccount)], NetworkType.MIJIN_TEST, [], @@ -597,7 +598,7 @@ describe('AggregateTransactionService', () => { const signedTransaction = aggregateTransaction.signTransactionWithCosignatories(account2, [], generationHash); aggregateTransactionService - .isComplete(signedTransaction, 1573430400) + .isComplete(signedTransaction) .toPromise() .then((isComplete) => { expect(isComplete).to.be.false; diff --git a/test/service/MetadataTransactionservice.spec.ts b/test/service/MetadataTransactionservice.spec.ts index 534e24c8ce..907ea7e41a 100644 --- a/test/service/MetadataTransactionservice.spec.ts +++ b/test/service/MetadataTransactionservice.spec.ts @@ -35,6 +35,7 @@ import { UInt64 } from '../../src/model/UInt64'; import { MetadataTransactionService } from '../../src/service/MetadataTransactionService'; import { TestingAccount } from '../conf/conf.spec'; import { Page } from '../../src/infrastructure/Page'; +import { Duration } from 'js-joda'; describe('MetadataTransactionService', () => { let account: Account; @@ -43,6 +44,7 @@ describe('MetadataTransactionService', () => { const value = 'TEST'; const deltaValue = 'dalta'; const targetIdHex = '941299B2B7E1291C'; + const epochAdjustment = Duration.ofSeconds(1573430400); function mockMetadata(type: MetadataType): Metadata { let targetId; @@ -111,7 +113,7 @@ describe('MetadataTransactionService', () => { it('should create AccountMetadataTransaction', (done) => { metadataTransactionService .createAccountMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, key, @@ -134,7 +136,7 @@ describe('MetadataTransactionService', () => { it('should create MosaicMetadataTransaction', (done) => { metadataTransactionService .createMosaicMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, new MosaicId(targetIdHex), @@ -159,7 +161,7 @@ describe('MetadataTransactionService', () => { it('should create NamespaceMetadataTransaction', (done) => { metadataTransactionService .createNamespaceMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, NamespaceId.createFromEncoded(targetIdHex), @@ -194,7 +196,7 @@ describe('MetadataTransactionService', () => { ).thenReject(); expect(() => { metadataTransactionService.createAccountMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, key, @@ -218,7 +220,7 @@ describe('MetadataTransactionService', () => { ).thenReject(); expect(() => { metadataTransactionService.createMosaicMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, new MosaicId(targetIdHex), @@ -243,7 +245,7 @@ describe('MetadataTransactionService', () => { ).thenReject(); expect(() => { metadataTransactionService.createNamespaceMetadataTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, account.address, NamespaceId.createFromEncoded(targetIdHex), diff --git a/test/service/MosaicRestrictionTransactionservice.spec.ts b/test/service/MosaicRestrictionTransactionservice.spec.ts index 5312ad2162..c177c9dfbf 100644 --- a/test/service/MosaicRestrictionTransactionservice.spec.ts +++ b/test/service/MosaicRestrictionTransactionservice.spec.ts @@ -37,6 +37,7 @@ import { UInt64 } from '../../src/model/UInt64'; import { MosaicRestrictionTransactionService } from '../../src/service/MosaicRestrictionTransactionService'; import { TestingAccount } from '../conf/conf.spec'; import { Page } from '../../src/infrastructure/Page'; +import { Duration } from 'js-joda'; describe('MosaicRestrictionTransactionService', () => { let account: Account; @@ -51,6 +52,7 @@ describe('MosaicRestrictionTransactionService', () => { const globalRestrictionValue = '1000'; const globalRestrictionType = MosaicRestrictionType.LE; const addressRestrictionValue = '10'; + const epochAdjustment = Duration.ofSeconds(1573430400); function mockGlobalRestriction(): Page { const restriction = new MosaicGlobalRestriction( @@ -103,7 +105,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicGlobalRestriction Transaction', (done) => { mosaicRestrictionTransactionService .createMosaicGlobalRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -123,7 +125,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicGlobalRestriction Transaction - with referenceMosaicId', (done) => { mosaicRestrictionTransactionService .createMosaicGlobalRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -144,7 +146,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicAddressRestriction Transaction', (done) => { mosaicRestrictionTransactionService .createMosaicAddressRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -163,7 +165,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicGlobalRestriction Transaction with unresolvedMosaicId', (done) => { mosaicRestrictionTransactionService .createMosaicGlobalRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, unresolvedMosaicId, key, @@ -183,7 +185,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should create MosaicAddressRestriction Transaction with unresolvedAddress', (done) => { mosaicRestrictionTransactionService .createMosaicAddressRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, unresolvedMosaicId, key, @@ -202,7 +204,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid unresolvedMosaicId', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicGlobalRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, unresolvedAddress, key, @@ -215,7 +217,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid unresolvedAddress', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicAddressRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -228,7 +230,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid value / key', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicGlobalRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -239,7 +241,7 @@ describe('MosaicRestrictionTransactionService', () => { expect(() => { mosaicRestrictionTransactionService.createMosaicAddressRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicId, key, @@ -252,7 +254,7 @@ describe('MosaicRestrictionTransactionService', () => { it('should throw error with invalid address restriction key - MosaicAddressRestriction', () => { mosaicRestrictionTransactionService .createMosaicAddressRestrictionTransaction( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), NetworkType.MIJIN_TEST, mosaicIdWrongKey, invalidKey, diff --git a/test/service/TransactionService.spec.ts b/test/service/TransactionService.spec.ts index 7fbc6ef8bc..caef819213 100644 --- a/test/service/TransactionService.spec.ts +++ b/test/service/TransactionService.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit, Duration } from 'js-joda'; import { EMPTY, of as observableOf } from 'rxjs'; import { deepEqual, instance, mock, when } from 'ts-mockito'; import { IListener } from '../../src/infrastructure/IListener'; @@ -44,8 +44,9 @@ import { TransactionService } from '../../src/service/TransactionService'; describe('TransactionService', () => { const generationHash = '82DB2528834C9926F0FCCE042466B24A266F5B685CB66D2869AF6648C043E950'; const account = Account.generateNewAccount(NetworkType.MIJIN_TEST); + const epochAdjustment = Duration.ofSeconds(1573430400); const transferTransaction = TransferTransaction.create( - Deadline.create(1573430400, 1, ChronoUnit.HOURS), + Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), [], PlainMessage.create('test-message'), @@ -53,21 +54,21 @@ describe('TransactionService', () => { ); const aggregateCompleteTransaction = AggregateTransaction.createComplete( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); const aggregateBondedTransaction = AggregateTransaction.createBonded( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), [transferTransaction.toAggregate(account.publicAccount)], NetworkType.MIJIN_TEST, [], ); const hashLockTransaction = HashLockTransaction.create( - Deadline.create(1573430400), + Deadline.create(epochAdjustment), new Mosaic(new NamespaceId('cat.currency'), UInt64.fromUint(10 * Math.pow(10, NetworkCurrencyLocal.DIVISIBILITY))), UInt64.fromUint(10000), account.sign(aggregateBondedTransaction, generationHash), @@ -113,7 +114,12 @@ describe('TransactionService', () => { when(transactionRepositoryMock.announce(deepEqual(signedTransaction))).thenReturn(observableOf(transactionAnnounceResponse)); when(listener.confirmed(deepEqual(account.address), deepEqual(signedTransaction.hash))).thenReturn(EMPTY); - const statusError = new TransactionStatusError(account.address, signedTransaction.hash, 'Some Error', Deadline.create(1573430400)); + const statusError = new TransactionStatusError( + account.address, + signedTransaction.hash, + 'Some Error', + Deadline.create(epochAdjustment), + ); when(listener.status(deepEqual(account.address), signedTransaction.hash)).thenReturn(observableOf(statusError)); const service = new TransactionService(instance(transactionRepositoryMock), instance(mockedReceiptRepository)); @@ -159,7 +165,12 @@ describe('TransactionService', () => { ); when(listener.aggregateBondedAdded(deepEqual(account.address), deepEqual(signedTransaction.hash))).thenReturn(EMPTY); - const statusError = new TransactionStatusError(account.address, signedTransaction.hash, 'Some Error', Deadline.create(1573430400)); + const statusError = new TransactionStatusError( + account.address, + signedTransaction.hash, + 'Some Error', + Deadline.create(epochAdjustment), + ); when(listener.status(deepEqual(account.address), signedTransaction.hash)).thenReturn(observableOf(statusError)); const service = new TransactionService(instance(transactionRepositoryMock), instance(mockedReceiptRepository)); From a2d3ef4eb29c5f9546f4407cbe4064085b25cd7b Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Fri, 9 Oct 2020 18:24:11 +0100 Subject: [PATCH 4/6] Lint fixes --- src/model/transaction/Deadline.ts | 8 ++++---- .../transaction/CreateTransactionFromDTO.spec.ts | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/model/transaction/Deadline.ts b/src/model/transaction/Deadline.ts index 38957cd247..ebcde4926d 100644 --- a/src/model/transaction/Deadline.ts +++ b/src/model/transaction/Deadline.ts @@ -28,10 +28,10 @@ export class Deadline { public adjustedValue: number; /** - * Create deadline model - * @param epochAdjustment - * @param deadline - * @param chronoUnit + * Create deadline model. Default to 2 chrono hours in advance. + * @param {Duration} epochAdjustment the network's epoch adjustment (seconds). Defined in the network/properties. e.g. Duration.ofSeconds(1573430400); + * @param {number} deadline the deadline unit value. + * @param {ChronoUnit} chronoUnit the crhono unit. e.g ChronoUnit.HOURS * @returns {Deadline} */ public static create(epochAdjustment: Duration, deadline = 2, chronoUnit: ChronoUnit = ChronoUnit.HOURS): Deadline { diff --git a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts index 5ec9e2f864..4e775c4f3a 100644 --- a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts +++ b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts @@ -19,10 +19,9 @@ import { CreateTransactionFromDTO } from '../../../src/infrastructure/transactio import { Address } from '../../../src/model/account/Address'; import { TransferTransaction } from '../../../src/model/transaction/TransferTransaction'; import ValidateTransaction from './ValidateTransaction'; -import { Duration, LocalDateTime } from 'js-joda'; +import { LocalDateTime } from 'js-joda'; describe('CreateTransactionFromDTO', () => { - const epochAdjustment = Duration.ofSeconds(1573430400); describe('TransferTransaction', () => { it('standalone', () => { const transferTransactionDTO = { From db97c5791d98f557f962ac1f51c0c39e1237d0e9 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Fri, 9 Oct 2020 18:27:13 +0100 Subject: [PATCH 5/6] Removed 24 hours check as it is only for testnet / mainnet --- src/model/transaction/Deadline.ts | 3 --- test/model/transaction/Deadline.spec.ts | 6 ------ 2 files changed, 9 deletions(-) diff --git a/src/model/transaction/Deadline.ts b/src/model/transaction/Deadline.ts index ebcde4926d..05433f672c 100644 --- a/src/model/transaction/Deadline.ts +++ b/src/model/transaction/Deadline.ts @@ -40,10 +40,7 @@ export class Deadline { if (deadline <= 0) { throw new Error('deadline should be greater than 0'); - } else if (now.plus(24, ChronoUnit.HOURS).compareTo(deadlineDateTime) !== 1) { - throw new Error('deadline should be less than 24 hours'); } - return new Deadline(deadlineDateTime.minusMillis(epochAdjustment.toMillis()).toEpochMilli()); } diff --git a/test/model/transaction/Deadline.spec.ts b/test/model/transaction/Deadline.spec.ts index 217c6a0d9e..bcb8c0d14c 100644 --- a/test/model/transaction/Deadline.spec.ts +++ b/test/model/transaction/Deadline.spec.ts @@ -41,12 +41,6 @@ describe('Deadline', () => { }).to.throw(Error); }); - it('should throw error deadline greater than 24h', () => { - expect(() => { - Deadline.create(epochAdjustment, 2, ChronoUnit.DAYS); - }).to.throw(Error); - }); - it('should createComplete date with Deadline array', () => { const deadline = Deadline.createFromDTO('51110867862'); From 25805ddbbd9622fd01059bfd4caa34c861b5e9a3 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Fri, 9 Oct 2020 19:21:48 +0100 Subject: [PATCH 6/6] - Added server duration handler --- src/core/format/Utilities.ts | 4 +- src/core/utils/DtoMapping.ts | 42 +++++++++++++++++++++ src/infrastructure/RepositoryFactoryHttp.ts | 3 +- test/core/utils/DtoMapping.spec.ts | 28 ++++++++++++++ 4 files changed, 74 insertions(+), 3 deletions(-) diff --git a/src/core/format/Utilities.ts b/src/core/format/Utilities.ts index 9dc0dbb02a..727824e1af 100644 --- a/src/core/format/Utilities.ts +++ b/src/core/format/Utilities.ts @@ -101,11 +101,11 @@ export const throwInvalidFqn = (reason: any, name: any): void => { export const extractPartName = (name: string, start: number, size: number): string => { if (0 === size) { - this.throwInvalidFqn('empty part', name); + throwInvalidFqn('empty part', name); } const partName = name.substr(start, size); if (!idGeneratorConst.name_pattern.test(partName)) { - this.throwInvalidFqn(`invalid part name [${partName}]`, name); + throwInvalidFqn(`invalid part name [${partName}]`, name); } return partName; }; diff --git a/src/core/utils/DtoMapping.ts b/src/core/utils/DtoMapping.ts index 9bf8aae4b2..ea3247617a 100644 --- a/src/core/utils/DtoMapping.ts +++ b/src/core/utils/DtoMapping.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { Duration } from 'js-joda'; import { Address } from '../../model/account/Address'; import { MosaicId } from '../../model/mosaic/MosaicId'; import { AccountRestriction } from '../../model/restriction/AccountRestriction'; @@ -78,4 +79,45 @@ export class DtoMapping { public static mapEnum(value: E1 | undefined): E2 { return (value as unknown) as E2; } + + /** + * It parse a server time/duration configuration like: - 1000ms 1000 milliseconds - 15s 15 seconds + * - 5m 5 minutes - 2h 2 hours - 10d 10 days + * + *

into a @{@link Duration} object + * + * @param serverValue time. + * @return {Duration} an instant from that value. + */ + public static parseServerDuration(serverValue: string): Duration { + const preprocessedValue = serverValue.replace(`'`, '').trim(); + const regex = `([0-9]+)([hdms]+)[:\\s]?$`; + let duration = Duration.ofSeconds(0); + const matcher = preprocessedValue.match(regex); + if (matcher && matcher.length === 3) { + const num = parseInt(matcher[1]); + const type = matcher[2]; + switch (type) { + case 'ms': + duration = duration.plusMillis(num); + break; + case 's': + duration = duration.plusSeconds(num); + break; + case 'm': + duration = duration.plusMinutes(num); + break; + case 'h': + duration = duration.plusHours(num); + break; + case 'd': + duration = duration.plusDays(num); + break; + default: + throw new Error('Duration value format is not recognized.'); + } + return duration; + } + throw new Error(`Duration value format is not recognized.`); + } } diff --git a/src/infrastructure/RepositoryFactoryHttp.ts b/src/infrastructure/RepositoryFactoryHttp.ts index d80c80eace..979b928455 100644 --- a/src/infrastructure/RepositoryFactoryHttp.ts +++ b/src/infrastructure/RepositoryFactoryHttp.ts @@ -54,6 +54,7 @@ import { SecretLockRepository } from './SecretLockRepository'; import { SecretLockHttp } from './SecretLockHttp'; import { HashLockHttp } from './HashLockHttp'; import { Duration } from 'js-joda'; +import { DtoMapping } from '../core/utils/DtoMapping'; /** * Receipt http repository. * @@ -83,7 +84,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory { .getNetworkProperties() .pipe( map((property) => { - return Duration.ofSeconds(parseInt(property.network.epochAdjustment?.replace('s', '') ?? '0')); + return DtoMapping.parseServerDuration(property.network.epochAdjustment ?? '-'); }), ) .pipe(shareReplay(1)); diff --git a/test/core/utils/DtoMapping.spec.ts b/test/core/utils/DtoMapping.spec.ts index 0ab2994b2e..1000742b67 100644 --- a/test/core/utils/DtoMapping.spec.ts +++ b/test/core/utils/DtoMapping.spec.ts @@ -63,4 +63,32 @@ describe('DtoMapping', () => { expect(result).not.to.be.undefined; expect((result.accountRestrictions.restrictions[0].values[0] as MosaicId).toHex()).to.be.equal(mosaicId.toHex()); }); + + it('parseServerDuration', () => { + const epochS = '12345s'; + expect(DtoMapping.parseServerDuration(epochS).seconds()).to.be.equal(12345); + const epochM = '12345m'; + expect(DtoMapping.parseServerDuration(epochM).toMinutes()).to.be.equal(12345); + const epochH = '12345h'; + expect(DtoMapping.parseServerDuration(epochH).toHours()).to.be.equal(12345); + const epochMS = '12345ms'; + expect(DtoMapping.parseServerDuration(epochMS).toMillis()).to.be.equal(12345); + const epochD = '12345d'; + expect(DtoMapping.parseServerDuration(epochD).toDays()).to.be.equal(12345); + }); + + it('parseServerDuration - exception', () => { + expect(() => { + const epochS = '12345g'; + DtoMapping.parseServerDuration(epochS).seconds(); + }).to.throw(); + expect(() => { + const epochS = 'adfs'; + DtoMapping.parseServerDuration(epochS).seconds(); + }).to.throw(); + expect(() => { + const epochS = '123s45'; + DtoMapping.parseServerDuration(epochS).seconds(); + }).to.throw(); + }); });