From 663abeb4edb205ba921088977f75baba555c3ed2 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Tue, 13 Oct 2020 14:41:11 +0100 Subject: [PATCH 1/2] Changed usage of epochAdjustment back to number --- e2e/infrastructure/AccountHttp.spec.ts | 3 +-- e2e/infrastructure/BlockHttp.spec.ts | 3 +-- e2e/infrastructure/HashLockHttp.spec.ts | 5 ++-- e2e/infrastructure/IntegrationTestHelper.ts | 3 +-- e2e/infrastructure/Listener.spec.ts | 4 +-- e2e/infrastructure/MetadataHttp.spec.ts | 3 +-- e2e/infrastructure/MosaicHttp.spec.ts | 3 +-- e2e/infrastructure/MultisigAccounts.spec.ts | 3 +-- e2e/infrastructure/NamespaceHttp.spec.ts | 3 +-- e2e/infrastructure/RestrictionHttp.spec.ts | 3 +-- e2e/infrastructure/TransactionHttp.spec.ts | 2 +- e2e/infrastructure/UnresolvedMapping.spec.ts | 3 +-- .../MetadataTransactionService.spec.ts | 3 +-- ...osaicRestrictionTransactionService.spec.ts | 3 +-- ...TransactionService_AggregateBonded.spec.ts | 2 +- src/core/utils/DtoMapping.ts | 2 +- src/infrastructure/RepositoryFactory.ts | 5 ++-- src/infrastructure/RepositoryFactoryHttp.ts | 9 +++---- src/model/transaction/Deadline.ts | 26 ++++++++++++------- test/core/utils/TransactionMapping.spec.ts | 5 ++-- .../TransactionMappingWithSignatures.spec.ts | 3 +-- test/infrastructure/Listener.spec.ts | 3 +-- test/infrastructure/MetadataHttp.spec.ts | 3 +-- test/infrastructure/Page.spec.ts | 3 +-- test/infrastructure/RepositoryFactory.spec.ts | 8 +++--- .../SerializeTransactionToJSON.spec.ts | 3 +-- test/infrastructure/TransactionHttp.spec.ts | 3 +-- .../CreateTransactionFromDTO.spec.ts | 2 +- test/model/account/Account.spec.ts | 3 +-- test/model/message/EncryptedMessage.spec.ts | 3 +-- ...sistentHarvestingDelegationMessage.spec.ts | 3 +-- .../AccountKeyLinkTransaction.spec.ts | 3 +-- .../AccountMetadataTransaction.spec.ts | 3 +-- .../AccountRestrictionTransaction.spec.ts | 3 +-- .../AddressAliasTransaction.spec.ts | 3 +-- .../transaction/AggregateTransaction.spec.ts | 4 +-- .../CosignatureTransaction.spec.ts | 3 +-- test/model/transaction/Deadline.spec.ts | 5 ++-- .../transaction/HashLockTransaction.spec.ts | 3 +-- .../transaction/LockFundsTransaction.spec.ts | 3 +-- ...osaicAddressRestrictionTransaction.spec.ts | 3 +-- .../MosaicAliasTransaction.spec.ts | 3 +-- .../MosaicDefinitionTransaction.spec.ts | 3 +-- ...MosaicGlobalRestrictionTransaction.spec.ts | 3 +-- .../MosaicMetadataTransaction.spec.ts | 3 +-- .../MosaicSupplyChangeTransaction.spec.ts | 3 +-- ...isigAccountModificationTransaction.spec.ts | 3 +-- .../NamespaceMetadataTransaction.spec.ts | 3 +-- .../NamespaceRegistrationTransaction.spec.ts | 3 +-- .../NodeKeyLinkTransaction.spec.ts | 3 +-- ...istentDelegationRequestTransaction.spec.ts | 3 +-- .../transaction/SecretLockTransaction.spec.ts | 3 +-- .../SecretProofTransaction.spec.ts | 3 +-- test/model/transaction/Transaction.spec.ts | 3 +-- .../transaction/TransferTransaction.spec.ts | 3 +-- .../VotingKeyLinkTransaction.spec.ts | 3 +-- .../transaction/VrfKeyLinkTransaction.spec.ts | 3 +-- .../AggregateTransactionService.spec.ts | 4 +-- .../MetadataTransactionservice.spec.ts | 3 +-- ...osaicRestrictionTransactionservice.spec.ts | 3 +-- test/service/TransactionService.spec.ts | 4 +-- 61 files changed, 90 insertions(+), 135 deletions(-) diff --git a/e2e/infrastructure/AccountHttp.spec.ts b/e2e/infrastructure/AccountHttp.spec.ts index 10f7674927..57ab766b51 100644 --- a/e2e/infrastructure/AccountHttp.spec.ts +++ b/e2e/infrastructure/AccountHttp.spec.ts @@ -38,7 +38,6 @@ 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(); @@ -57,7 +56,7 @@ describe('AccountHttp', () => { let generationHash: string; let networkType: NetworkType; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/infrastructure/BlockHttp.spec.ts b/e2e/infrastructure/BlockHttp.spec.ts index 1ebadeefe5..c1e2a7c4f2 100644 --- a/e2e/infrastructure/BlockHttp.spec.ts +++ b/e2e/infrastructure/BlockHttp.spec.ts @@ -31,7 +31,6 @@ 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(); @@ -44,7 +43,7 @@ describe('BlockHttp', () => { let networkType: NetworkType; let transactionHash; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/infrastructure/HashLockHttp.spec.ts b/e2e/infrastructure/HashLockHttp.spec.ts index 40a1456a73..3abf983cde 100644 --- a/e2e/infrastructure/HashLockHttp.spec.ts +++ b/e2e/infrastructure/HashLockHttp.spec.ts @@ -30,11 +30,10 @@ import { deepEqual } from 'assert'; import { Order, HashLockPaginationStreamer } from '../../src/infrastructure/infrastructure'; import { Mosaic } from '../../src/model/mosaic/Mosaic'; import { LockFundsTransaction } from '../../src/model/transaction/LockFundsTransaction'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit } from '@js-joda/core'; 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(); @@ -49,7 +48,7 @@ describe('HashLockHttp', () => { let generationHash: string; let networkType: NetworkType; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/infrastructure/IntegrationTestHelper.ts b/e2e/infrastructure/IntegrationTestHelper.ts index 3bfd3dc31f..46ea5a6831 100644 --- a/e2e/infrastructure/IntegrationTestHelper.ts +++ b/e2e/infrastructure/IntegrationTestHelper.ts @@ -29,7 +29,6 @@ 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; @@ -53,7 +52,7 @@ export class IntegrationTestHelper { public service = new BootstrapService(); public config: StartParams; public startEachTime = true; - public epochAdjustment: Duration; + public epochAdjustment: number; 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 8dcea3873c..228901e457 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, Duration } from 'js-joda'; +import { ChronoUnit } from '@js-joda/core'; import { filter, mergeMap } from 'rxjs/operators'; import { TransactionRepository } from '../../src/infrastructure/TransactionRepository'; import { Account } from '../../src/model/account/Account'; @@ -47,7 +47,7 @@ describe('Listener', () => { let networkType: NetworkType; let transactionRepository: TransactionRepository; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/infrastructure/MetadataHttp.spec.ts b/e2e/infrastructure/MetadataHttp.spec.ts index 0bcc1d4984..832d196301 100644 --- a/e2e/infrastructure/MetadataHttp.spec.ts +++ b/e2e/infrastructure/MetadataHttp.spec.ts @@ -36,7 +36,6 @@ 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(); @@ -48,7 +47,7 @@ describe('MetadataHttp', () => { let networkType: NetworkType; let metadataRepository: MetadataRepository; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/infrastructure/MosaicHttp.spec.ts b/e2e/infrastructure/MosaicHttp.spec.ts index 7cae77425d..4a45f5e959 100644 --- a/e2e/infrastructure/MosaicHttp.spec.ts +++ b/e2e/infrastructure/MosaicHttp.spec.ts @@ -33,7 +33,6 @@ 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; @@ -45,7 +44,7 @@ describe('MosaicHttp', () => { const helper = new IntegrationTestHelper(); let networkType: NetworkType; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/infrastructure/MultisigAccounts.spec.ts b/e2e/infrastructure/MultisigAccounts.spec.ts index a04227f644..2bd1446bf8 100644 --- a/e2e/infrastructure/MultisigAccounts.spec.ts +++ b/e2e/infrastructure/MultisigAccounts.spec.ts @@ -13,7 +13,6 @@ * 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'; @@ -30,7 +29,7 @@ describe('MultisigAccounts', () => { let generationHash: string; let networkType: NetworkType; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/infrastructure/NamespaceHttp.spec.ts b/e2e/infrastructure/NamespaceHttp.spec.ts index d922bb5fa5..863d3318b3 100644 --- a/e2e/infrastructure/NamespaceHttp.spec.ts +++ b/e2e/infrastructure/NamespaceHttp.spec.ts @@ -28,7 +28,6 @@ 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; @@ -38,7 +37,7 @@ describe('NamespaceHttp', () => { let generationHash: string; const helper = new IntegrationTestHelper(); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/infrastructure/RestrictionHttp.spec.ts b/e2e/infrastructure/RestrictionHttp.spec.ts index f0ce229df6..e94bb9a76f 100644 --- a/e2e/infrastructure/RestrictionHttp.spec.ts +++ b/e2e/infrastructure/RestrictionHttp.spec.ts @@ -36,7 +36,6 @@ 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(); @@ -49,7 +48,7 @@ describe('RestrictionHttp', () => { let mosaicId: MosaicId; let referenceMosaicId: MosaicId; let restrictionAccountRepository: RestrictionAccountRepository; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/infrastructure/TransactionHttp.spec.ts b/e2e/infrastructure/TransactionHttp.spec.ts index 584fb819c7..c81d889cfa 100644 --- a/e2e/infrastructure/TransactionHttp.spec.ts +++ b/e2e/infrastructure/TransactionHttp.spec.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { expect } from 'chai'; -import { ChronoUnit } from 'js-joda'; +import { ChronoUnit } from '@js-joda/core'; import { sha3_256 } from 'js-sha3'; import { Crypto } from '../../src/core/crypto'; import { Convert, Convert as convert } from '../../src/core/format'; diff --git a/e2e/infrastructure/UnresolvedMapping.spec.ts b/e2e/infrastructure/UnresolvedMapping.spec.ts index 1348a82cae..faa5237a47 100644 --- a/e2e/infrastructure/UnresolvedMapping.spec.ts +++ b/e2e/infrastructure/UnresolvedMapping.spec.ts @@ -14,7 +14,6 @@ * 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'; @@ -49,7 +48,7 @@ describe('Unresolved Mapping', () => { let mosaicId: MosaicId; let namespaceIdAddress: NamespaceId; let namespaceIdMosaic: NamespaceId; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { return helper.start({ openListener: true }).then(() => { diff --git a/e2e/service/MetadataTransactionService.spec.ts b/e2e/service/MetadataTransactionService.spec.ts index 9391a395b0..844bd0714b 100644 --- a/e2e/service/MetadataTransactionService.spec.ts +++ b/e2e/service/MetadataTransactionService.spec.ts @@ -1,5 +1,4 @@ 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'; @@ -20,7 +19,7 @@ import { MetadataTransactionService } from '../../src/service/MetadataTransactio import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; describe('MetadataTransactionService', () => { - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; const deadline = Deadline.create(epochAdjustment); const key = UInt64.fromUint(Math.round(Math.random() * 10)); const newValue = 'new test value'; diff --git a/e2e/service/MosaicRestrictionTransactionService.spec.ts b/e2e/service/MosaicRestrictionTransactionService.spec.ts index a4d6b733d7..fbaa6f0ec7 100644 --- a/e2e/service/MosaicRestrictionTransactionService.spec.ts +++ b/e2e/service/MosaicRestrictionTransactionService.spec.ts @@ -1,5 +1,4 @@ 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'; @@ -25,7 +24,7 @@ import { MosaicRestrictionTransactionService } from '../../src/service/MosaicRes import { IntegrationTestHelper } from '../infrastructure/IntegrationTestHelper'; describe('MosaicRestrictionTransactionService', () => { - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; const deadline = Deadline.create(epochAdjustment); const key = KeyGenerator.generateUInt64Key('TestKey'); let account: Account; diff --git a/e2e/service/TransactionService_AggregateBonded.spec.ts b/e2e/service/TransactionService_AggregateBonded.spec.ts index 60477f96d5..1de1720d2a 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 } from '@js-joda/core'; import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository'; import { Account } from '../../src/model/account/Account'; import { Address } from '../../src/model/account/Address'; diff --git a/src/core/utils/DtoMapping.ts b/src/core/utils/DtoMapping.ts index ea3247617a..50462119d5 100644 --- a/src/core/utils/DtoMapping.ts +++ b/src/core/utils/DtoMapping.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Duration } from 'js-joda'; +import { Duration } from '@js-joda/core'; import { Address } from '../../model/account/Address'; import { MosaicId } from '../../model/mosaic/MosaicId'; import { AccountRestriction } from '../../model/restriction/AccountRestriction'; diff --git a/src/infrastructure/RepositoryFactory.ts b/src/infrastructure/RepositoryFactory.ts index d106522066..05156a9600 100644 --- a/src/infrastructure/RepositoryFactory.ts +++ b/src/infrastructure/RepositoryFactory.ts @@ -33,7 +33,6 @@ 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 @@ -139,7 +138,7 @@ export interface RepositoryFactory { createListener(): IListener; /** - * @returns nemesis block epoch + * @returns nemesis block epoch adjustment in seconds */ - getEpochAdjustment(): Observable; + getEpochAdjustment(): Observable; } diff --git a/src/infrastructure/RepositoryFactoryHttp.ts b/src/infrastructure/RepositoryFactoryHttp.ts index 979b928455..fe27e85104 100644 --- a/src/infrastructure/RepositoryFactoryHttp.ts +++ b/src/infrastructure/RepositoryFactoryHttp.ts @@ -53,7 +53,6 @@ import { HashLockRepository } from './HashLockRepository'; 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. @@ -66,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 @@ -79,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(Duration.ofSeconds(configs.epochAdjustment)) + ? observableOf(configs.epochAdjustment) : networkRepo .getNetworkProperties() .pipe( map((property) => { - return DtoMapping.parseServerDuration(property.network.epochAdjustment ?? '-'); + return DtoMapping.parseServerDuration(property.network.epochAdjustment ?? '-').seconds(); }), ) .pipe(shareReplay(1)); @@ -174,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/model/transaction/Deadline.ts b/src/model/transaction/Deadline.ts index 05433f672c..576f253958 100644 --- a/src/model/transaction/Deadline.ts +++ b/src/model/transaction/Deadline.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { ChronoUnit, Duration, Instant, LocalDateTime, ZoneId } from 'js-joda'; +import { ChronoUnit, Duration, Instant, LocalDateTime, ZoneId } from '@js-joda/core'; import { UInt64 } from '../UInt64'; /** @@ -29,19 +29,19 @@ export class Deadline { /** * 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} epochAdjustment the network's epoch adjustment (seconds). Defined in the network/properties. e.g. 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 { + public static create(epochAdjustment: number, 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'); } - return new Deadline(deadlineDateTime.minusMillis(epochAdjustment.toMillis()).toEpochMilli()); + return new Deadline(deadlineDateTime.minusMillis(Duration.ofSeconds(epochAdjustment).toMillis()).toEpochMilli()); } /** @@ -87,20 +87,26 @@ export class Deadline { /** * Returns deadline as local date time. - * @param epochAdjustment the network's epoch adjustment. Defined in the network/properties. + * @param epochAdjustment the network's epoch adjustment (seconds). Defined in the network/properties. * @returns {LocalDateTime} */ - public toLocalDateTime(epochAdjustment: Duration): LocalDateTime { - return LocalDateTime.ofInstant(Instant.ofEpochMilli(this.adjustedValue).plusMillis(epochAdjustment.toMillis()), ZoneId.SYSTEM); + public toLocalDateTime(epochAdjustment: number): LocalDateTime { + return LocalDateTime.ofInstant( + Instant.ofEpochMilli(this.adjustedValue).plusMillis(Duration.ofSeconds(epochAdjustment).toMillis()), + ZoneId.SYSTEM, + ); } /** * Returns deadline as local date time. - * @param epochAdjustment the network's epoch adjustment. Defined in the network/properties. + * @param epochAdjustment the network's epoch adjustment (seconds). 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); + public toLocalDateTimeGivenTimeZone(epochAdjustment: number, zoneId: ZoneId): LocalDateTime { + return LocalDateTime.ofInstant( + Instant.ofEpochMilli(this.adjustedValue).plusMillis(Duration.ofSeconds(epochAdjustment).toMillis()), + zoneId, + ); } } diff --git a/test/core/utils/TransactionMapping.spec.ts b/test/core/utils/TransactionMapping.spec.ts index 8a61b47541..664dfbec81 100644 --- a/test/core/utils/TransactionMapping.spec.ts +++ b/test/core/utils/TransactionMapping.spec.ts @@ -69,12 +69,11 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); @@ -825,7 +824,7 @@ describe('TransactionMapping - createFromPayload', () => { describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/core/utils/TransactionMappingWithSignatures.spec.ts b/test/core/utils/TransactionMappingWithSignatures.spec.ts index 1bd8cd4ee7..77e87061da 100644 --- a/test/core/utils/TransactionMappingWithSignatures.spec.ts +++ b/test/core/utils/TransactionMappingWithSignatures.spec.ts @@ -66,7 +66,6 @@ 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; @@ -74,7 +73,7 @@ describe('TransactionMapping - createFromPayload with optional sigature and sign const testSignature = '4CBA582B4C898FD6D218499251FE8EE1214D3715545023123F70D25389D577A96E74C1FCD07FF8F0D678A4DA5CAD8CCB173DDD9F7975A6985ADCD7AD625B170F'; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/infrastructure/Listener.spec.ts b/test/infrastructure/Listener.spec.ts index 2a6e78c47d..f30672b38f 100644 --- a/test/infrastructure/Listener.spec.ts +++ b/test/infrastructure/Listener.spec.ts @@ -34,7 +34,6 @@ 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( @@ -44,7 +43,7 @@ describe('Listener', () => { let namespaceRepoMock: NamespaceRepository; let namespaceRepo: NamespaceRepository; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; beforeEach(() => { namespaceRepoMock = mock(); namespaceRepo = instance(namespaceRepoMock); diff --git a/test/infrastructure/MetadataHttp.spec.ts b/test/infrastructure/MetadataHttp.spec.ts index 1443a795d5..d2b5517a50 100644 --- a/test/infrastructure/MetadataHttp.spec.ts +++ b/test/infrastructure/MetadataHttp.spec.ts @@ -14,7 +14,6 @@ * limitations under the License. */ import { expect } from 'chai'; -import { Duration } from 'js-joda'; import { MetadataEntryDTO, MetadataRoutesApi, @@ -43,7 +42,7 @@ import { UInt64 } from '../../src/model/UInt64'; import { MetadataTransactionService } from '../../src/service/MetadataTransactionService'; describe('MetadataHttp', () => { - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; const address = Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'); const mosaicId = new MosaicId('941299B2B7E1291C'); const namespaceId = new NamespaceId('some.address'); diff --git a/test/infrastructure/Page.spec.ts b/test/infrastructure/Page.spec.ts index dc08df2b5c..6d75eed3bf 100644 --- a/test/infrastructure/Page.spec.ts +++ b/test/infrastructure/Page.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -25,7 +24,7 @@ import { TransferTransaction } from '../../src/model/transaction/TransferTransac import { TestingAccount } from '../conf/conf.spec'; describe('Page', () => { - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; it('should create Page', () => { const account = TestingAccount; let page = new Page( diff --git a/test/infrastructure/RepositoryFactory.spec.ts b/test/infrastructure/RepositoryFactory.spec.ts index 65e1274e77..386473a2cd 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.seconds()).to.be.equals(expectedepochAdjustment); + expect(epoch).to.be.equals(expectedepochAdjustment); repositoryFactory.getEpochAdjustment().subscribe((network) => { expect(counter).to.be.equals(1); - expect(network.seconds()).to.be.equals(expectedepochAdjustment); + expect(network).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.seconds()).to.be.equals(expectedepochAdjustment); + expect(networkType).to.be.equals(expectedepochAdjustment); repositoryFactory.getEpochAdjustment().subscribe((network) => { expect(counter).to.be.equals(0); - expect(network.seconds()).to.be.equals(expectedepochAdjustment); + expect(network).to.be.equals(expectedepochAdjustment); done(); }); }); diff --git a/test/infrastructure/SerializeTransactionToJSON.spec.ts b/test/infrastructure/SerializeTransactionToJSON.spec.ts index a4fa7413b0..3bd6886109 100644 --- a/test/infrastructure/SerializeTransactionToJSON.spec.ts +++ b/test/infrastructure/SerializeTransactionToJSON.spec.ts @@ -54,11 +54,10 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/infrastructure/TransactionHttp.spec.ts b/test/infrastructure/TransactionHttp.spec.ts index 309c85e715..240fef5f36 100644 --- a/test/infrastructure/TransactionHttp.spec.ts +++ b/test/infrastructure/TransactionHttp.spec.ts @@ -15,7 +15,6 @@ */ import { expect } from 'chai'; -import { Duration } from 'js-joda'; import { BlockDTO, BlockInfoDTO, @@ -59,7 +58,7 @@ describe('TransactionHttp', () => { cosignature.signerPublicKey = 'signerPubKey'; cosignature.signature = 'signature'; cosignature.version = '0'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { transactionRoutesApi = mock(); diff --git a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts index 4e775c4f3a..dae42f36e1 100644 --- a/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts +++ b/test/infrastructure/transaction/CreateTransactionFromDTO.spec.ts @@ -19,7 +19,7 @@ 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 { LocalDateTime } from '@js-joda/core'; describe('CreateTransactionFromDTO', () => { describe('TransferTransaction', () => { diff --git a/test/model/account/Account.spec.ts b/test/model/account/Account.spec.ts index b893c3d8a4..289d106a6d 100644 --- a/test/model/account/Account.spec.ts +++ b/test/model/account/Account.spec.ts @@ -25,7 +25,6 @@ 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 = { @@ -34,7 +33,7 @@ describe('Account', () => { publicKey: '9801508C58666C746F471538E43002B85B1CD542F9874B2861183919BA8787B6'.toUpperCase(), }; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 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); diff --git a/test/model/message/EncryptedMessage.spec.ts b/test/model/message/EncryptedMessage.spec.ts index d98315ef24..7b153b3442 100644 --- a/test/model/message/EncryptedMessage.spec.ts +++ b/test/model/message/EncryptedMessage.spec.ts @@ -21,7 +21,6 @@ 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; @@ -29,7 +28,7 @@ describe('EncryptedMessage', () => { let sender_nis: Account; let recipient_nis: Account; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { sender = Account.createFromPrivateKey('2602F4236B199B3DF762B2AAB46FC3B77D8DDB214F0B62538D3827576C46C108', NetworkType.MIJIN_TEST); recipient = Account.createFromPrivateKey( diff --git a/test/model/message/PersistentHarvestingDelegationMessage.spec.ts b/test/model/message/PersistentHarvestingDelegationMessage.spec.ts index 25c4c653cd..1f8a7361c1 100644 --- a/test/model/message/PersistentHarvestingDelegationMessage.spec.ts +++ b/test/model/message/PersistentHarvestingDelegationMessage.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -29,7 +28,7 @@ describe('PersistentHarvestingDelegationMessage', () => { let recipient_nis: Account; const signingPrivateKey = 'F0AB1010EFEE19EE5373719881DF5123C13E643C519655F7E97347BFF77175BF'; const vrfPrivateKey = '800F35F1CC66C2B62CE9DD9F31003B9B3E5C7A2F381FB8952A294277A1015D83'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { sender = Account.createFromPrivateKey('2602F4236B199B3DF762B2AAB46FC3B77D8DDB214F0B62538D3827576C46C108', NetworkType.MIJIN_TEST); recipient = Account.createFromPrivateKey( diff --git a/test/model/transaction/AccountKeyLinkTransaction.spec.ts b/test/model/transaction/AccountKeyLinkTransaction.spec.ts index da3c7698bd..c141ae9421 100644 --- a/test/model/transaction/AccountKeyLinkTransaction.spec.ts +++ b/test/model/transaction/AccountKeyLinkTransaction.spec.ts @@ -24,12 +24,11 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/AccountMetadataTransaction.spec.ts b/test/model/transaction/AccountMetadataTransaction.spec.ts index bcfc8c3cb7..0f054c3f93 100644 --- a/test/model/transaction/AccountMetadataTransaction.spec.ts +++ b/test/model/transaction/AccountMetadataTransaction.spec.ts @@ -27,12 +27,11 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/AccountRestrictionTransaction.spec.ts b/test/model/transaction/AccountRestrictionTransaction.spec.ts index 738b332fc4..8c3750c3a3 100644 --- a/test/model/transaction/AccountRestrictionTransaction.spec.ts +++ b/test/model/transaction/AccountRestrictionTransaction.spec.ts @@ -31,12 +31,11 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/AddressAliasTransaction.spec.ts b/test/model/transaction/AddressAliasTransaction.spec.ts index 707d70c5d1..77fbea5e87 100644 --- a/test/model/transaction/AddressAliasTransaction.spec.ts +++ b/test/model/transaction/AddressAliasTransaction.spec.ts @@ -26,12 +26,11 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/AggregateTransaction.spec.ts b/test/model/transaction/AggregateTransaction.spec.ts index 829ac08dc1..91e7595ecf 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, Duration } from 'js-joda'; +import { ChronoUnit } from '@js-joda/core'; import { Convert } from '../../../src/core/format'; import { TransactionMapping } from '../../../src/core/utils/TransactionMapping'; import { CreateTransactionFromDTO } from '../../../src/infrastructure/transaction/CreateTransactionFromDTO'; @@ -58,7 +58,7 @@ describe('AggregateTransaction', () => { const unresolvedAddress = new NamespaceId('address'); const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/CosignatureTransaction.spec.ts b/test/model/transaction/CosignatureTransaction.spec.ts index aabaaf5bf4..127a3cfb39 100644 --- a/test/model/transaction/CosignatureTransaction.spec.ts +++ b/test/model/transaction/CosignatureTransaction.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -29,7 +28,7 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('CosignatureTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/Deadline.spec.ts b/test/model/transaction/Deadline.spec.ts index bcb8c0d14c..0111f61f78 100644 --- a/test/model/transaction/Deadline.spec.ts +++ b/test/model/transaction/Deadline.spec.ts @@ -15,12 +15,11 @@ */ import { expect } from 'chai'; -import { ChronoUnit, Instant, LocalDateTime, ZoneId } from 'js-joda'; +import { ChronoUnit, Instant, LocalDateTime, ZoneId } from '@js-joda/core'; import { Deadline } from '../../../src/model/transaction/Deadline'; -import { Duration } from 'js-joda'; describe('Deadline', () => { - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; it('should createComplete timestamp today', () => { const deadline = Deadline.create(epochAdjustment); diff --git a/test/model/transaction/HashLockTransaction.spec.ts b/test/model/transaction/HashLockTransaction.spec.ts index b361138e11..0e1c32fbab 100644 --- a/test/model/transaction/HashLockTransaction.spec.ts +++ b/test/model/transaction/HashLockTransaction.spec.ts @@ -14,7 +14,6 @@ * 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'; @@ -27,7 +26,7 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('HashLockTransaction', () => { const account = TestingAccount; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; it('creation with an aggregate bonded tx', () => { const aggregateTransaction = AggregateTransaction.createBonded(Deadline.create(epochAdjustment), [], NetworkType.MIJIN_TEST, []); const signedTransaction = account.sign(aggregateTransaction, generationHash); diff --git a/test/model/transaction/LockFundsTransaction.spec.ts b/test/model/transaction/LockFundsTransaction.spec.ts index d36ea5104f..fe0fc3aade 100644 --- a/test/model/transaction/LockFundsTransaction.spec.ts +++ b/test/model/transaction/LockFundsTransaction.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -41,7 +40,7 @@ describe('LockFundsTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; statement = new Statement( diff --git a/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts b/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts index c4ce9023ba..a3bae93f1c 100644 --- a/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts +++ b/test/model/transaction/MosaicAddressRestrictionTransaction.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -40,7 +39,7 @@ describe('MosaicAddressRestrictionTransaction', () => { const unresolvedAddress = new NamespaceId('address'); const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; statement = new Statement( diff --git a/test/model/transaction/MosaicAliasTransaction.spec.ts b/test/model/transaction/MosaicAliasTransaction.spec.ts index 787b8c9aeb..23f11ebdc3 100644 --- a/test/model/transaction/MosaicAliasTransaction.spec.ts +++ b/test/model/transaction/MosaicAliasTransaction.spec.ts @@ -29,12 +29,11 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/MosaicDefinitionTransaction.spec.ts b/test/model/transaction/MosaicDefinitionTransaction.spec.ts index 1b1e6ecef3..c9ee0cdf3a 100644 --- a/test/model/transaction/MosaicDefinitionTransaction.spec.ts +++ b/test/model/transaction/MosaicDefinitionTransaction.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -30,7 +29,7 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('MosaicDefinitionTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts b/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts index fd468036cb..6da18c6a79 100644 --- a/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts +++ b/test/model/transaction/MosaicGlobalRestrictionTransaction.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -39,7 +38,7 @@ describe('MosaicGlobalRestrictionTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; statement = new Statement( diff --git a/test/model/transaction/MosaicMetadataTransaction.spec.ts b/test/model/transaction/MosaicMetadataTransaction.spec.ts index f9ef79a171..ee0a489d8b 100644 --- a/test/model/transaction/MosaicMetadataTransaction.spec.ts +++ b/test/model/transaction/MosaicMetadataTransaction.spec.ts @@ -33,7 +33,6 @@ 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; @@ -41,7 +40,7 @@ describe('MosaicMetadataTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; statement = new Statement( diff --git a/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts b/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts index e69dfec814..52419cc082 100644 --- a/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts +++ b/test/model/transaction/MosaicSupplyChangeTransaction.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -39,7 +38,7 @@ describe('MosaicSupplyChangeTransaction', () => { let statement: Statement; const unresolvedMosaicId = new NamespaceId('mosaic'); const resolvedMosaicId = new MosaicId('0DC67FBE1CAD29E5'); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; statement = new Statement( diff --git a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts index 5a817d2912..8fbabf7dfd 100644 --- a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts +++ b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts @@ -24,7 +24,6 @@ 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; @@ -37,7 +36,7 @@ describe('MultisigAccountModificationTransaction', () => { 'B1B5581FC81A6970DEE418D2C2978F2724228B7B36C5C6DF71B0162BB04778B4', NetworkType.MIJIN_TEST, ); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/NamespaceMetadataTransaction.spec.ts b/test/model/transaction/NamespaceMetadataTransaction.spec.ts index e366bee763..7694aca284 100644 --- a/test/model/transaction/NamespaceMetadataTransaction.spec.ts +++ b/test/model/transaction/NamespaceMetadataTransaction.spec.ts @@ -27,12 +27,11 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts index 244e35014f..b998d6d339 100644 --- a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts +++ b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -28,7 +27,7 @@ import { TestingAccount } from '../../conf/conf.spec'; describe('NamespaceRegistrationTransaction', () => { let account: Account; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/NodeKeyLinkTransaction.spec.ts b/test/model/transaction/NodeKeyLinkTransaction.spec.ts index f93711619f..9ebbf0a7ca 100644 --- a/test/model/transaction/NodeKeyLinkTransaction.spec.ts +++ b/test/model/transaction/NodeKeyLinkTransaction.spec.ts @@ -24,12 +24,11 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts b/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts index 6445821b0d..f6cc23d0b9 100644 --- a/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts +++ b/test/model/transaction/PersistentDelegationRequestTransaction.spec.ts @@ -15,7 +15,6 @@ */ 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'; @@ -32,7 +31,7 @@ describe('PersistentDelegationRequestTransaction', () => { const recipientPublicKey = '9DBF67474D6E1F8B131B4EB1F5BA0595AFFAE1123607BC1048F342193D7E669F'; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; const messageMarker = MessageMarker.PersistentDelegationUnlock; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; diff --git a/test/model/transaction/SecretLockTransaction.spec.ts b/test/model/transaction/SecretLockTransaction.spec.ts index b39d968bd9..81eb78fa3e 100644 --- a/test/model/transaction/SecretLockTransaction.spec.ts +++ b/test/model/transaction/SecretLockTransaction.spec.ts @@ -36,7 +36,6 @@ 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; @@ -45,7 +44,7 @@ describe('SecretLockTransaction', () => { const unresolvedMosaicId = new NamespaceId('mosaic'); const mosaicId = new MosaicId('0DC67FBE1CAD29E5'); const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; statement = new Statement( diff --git a/test/model/transaction/SecretProofTransaction.spec.ts b/test/model/transaction/SecretProofTransaction.spec.ts index a1c37a0834..cb41389d63 100644 --- a/test/model/transaction/SecretProofTransaction.spec.ts +++ b/test/model/transaction/SecretProofTransaction.spec.ts @@ -34,14 +34,13 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; statement = new Statement( diff --git a/test/model/transaction/Transaction.spec.ts b/test/model/transaction/Transaction.spec.ts index c4a983f095..ff83fbabde 100644 --- a/test/model/transaction/Transaction.spec.ts +++ b/test/model/transaction/Transaction.spec.ts @@ -32,11 +32,10 @@ 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); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/TransferTransaction.spec.ts b/test/model/transaction/TransferTransaction.spec.ts index 0fdab15185..9f59b8dc3e 100644 --- a/test/model/transaction/TransferTransaction.spec.ts +++ b/test/model/transaction/TransferTransaction.spec.ts @@ -39,7 +39,6 @@ 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; @@ -52,7 +51,7 @@ describe('TransferTransaction', () => { const unresolvedAddress = new NamespaceId('address'); const unresolvedMosaicId = new NamespaceId('mosaic'); const mosaicId = new MosaicId('0DC67FBE1CAD29E5'); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; }); diff --git a/test/model/transaction/VotingKeyLinkTransaction.spec.ts b/test/model/transaction/VotingKeyLinkTransaction.spec.ts index 66268b5415..b303dabc77 100644 --- a/test/model/transaction/VotingKeyLinkTransaction.spec.ts +++ b/test/model/transaction/VotingKeyLinkTransaction.spec.ts @@ -24,7 +24,6 @@ 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; @@ -32,7 +31,7 @@ describe('VotingKeyLinkTransaction', () => { const startEpoch = 1; const endEpoch = 10; const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; before(() => { account = TestingAccount; votingKey = '344B9146A1F8DBBD8AFC830A2AAB7A83692E73AD775159B811355B1D2C0C27120243B10A16D4B5001B2AF0ED456C82D0'; diff --git a/test/model/transaction/VrfKeyLinkTransaction.spec.ts b/test/model/transaction/VrfKeyLinkTransaction.spec.ts index d623afa913..3430e7e192 100644 --- a/test/model/transaction/VrfKeyLinkTransaction.spec.ts +++ b/test/model/transaction/VrfKeyLinkTransaction.spec.ts @@ -24,7 +24,6 @@ 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; @@ -32,7 +31,7 @@ describe('VrfKeyLinkTransaction', () => { before(() => { account = TestingAccount; }); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; it('should default maxFee field be set to 0', () => { const vrfKeyLinkTransaction = VrfKeyLinkTransaction.create( diff --git a/test/service/AggregateTransactionService.spec.ts b/test/service/AggregateTransactionService.spec.ts index b49a93307c..8dd6950a81 100644 --- a/test/service/AggregateTransactionService.spec.ts +++ b/test/service/AggregateTransactionService.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit, Duration } from 'js-joda'; +import { ChronoUnit } from '@js-joda/core'; import { of as observableOf } from 'rxjs'; import { deepEqual, instance, mock, when } from 'ts-mockito'; import { MultisigRepository } from '../../src/infrastructure/MultisigRepository'; @@ -91,7 +91,7 @@ describe('AggregateTransactionService', () => { NetworkType.MIJIN_TEST, ); const generationHash = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; function givenMultisig2AccountInfo(): MultisigAccountInfo { return new MultisigAccountInfo(multisig2.address, 2, 1, [multisig1.address, account1.address], []); diff --git a/test/service/MetadataTransactionservice.spec.ts b/test/service/MetadataTransactionservice.spec.ts index 907ea7e41a..ef913041ad 100644 --- a/test/service/MetadataTransactionservice.spec.ts +++ b/test/service/MetadataTransactionservice.spec.ts @@ -35,7 +35,6 @@ 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; @@ -44,7 +43,7 @@ describe('MetadataTransactionService', () => { const value = 'TEST'; const deltaValue = 'dalta'; const targetIdHex = '941299B2B7E1291C'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; function mockMetadata(type: MetadataType): Metadata { let targetId; diff --git a/test/service/MosaicRestrictionTransactionservice.spec.ts b/test/service/MosaicRestrictionTransactionservice.spec.ts index c177c9dfbf..89a42bfe1d 100644 --- a/test/service/MosaicRestrictionTransactionservice.spec.ts +++ b/test/service/MosaicRestrictionTransactionservice.spec.ts @@ -37,7 +37,6 @@ 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; @@ -52,7 +51,7 @@ describe('MosaicRestrictionTransactionService', () => { const globalRestrictionValue = '1000'; const globalRestrictionType = MosaicRestrictionType.LE; const addressRestrictionValue = '10'; - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; function mockGlobalRestriction(): Page { const restriction = new MosaicGlobalRestriction( diff --git a/test/service/TransactionService.spec.ts b/test/service/TransactionService.spec.ts index caef819213..9de7803dc3 100644 --- a/test/service/TransactionService.spec.ts +++ b/test/service/TransactionService.spec.ts @@ -15,7 +15,7 @@ */ import { expect } from 'chai'; -import { ChronoUnit, Duration } from 'js-joda'; +import { ChronoUnit } from '@js-joda/core'; import { EMPTY, of as observableOf } from 'rxjs'; import { deepEqual, instance, mock, when } from 'ts-mockito'; import { IListener } from '../../src/infrastructure/IListener'; @@ -44,7 +44,7 @@ import { TransactionService } from '../../src/service/TransactionService'; describe('TransactionService', () => { const generationHash = '82DB2528834C9926F0FCCE042466B24A266F5B685CB66D2869AF6648C043E950'; const account = Account.generateNewAccount(NetworkType.MIJIN_TEST); - const epochAdjustment = Duration.ofSeconds(1573430400); + const epochAdjustment = 1573430400; const transferTransaction = TransferTransaction.create( Deadline.create(epochAdjustment, 1, ChronoUnit.HOURS), Address.createFromRawAddress('SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ'), From 1de3c1c089e79fafa969fbdca23e7b755cf34743 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Tue, 13 Oct 2020 14:59:23 +0100 Subject: [PATCH 2/2] Removed peer dependancy --- package.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/package.json b/package.json index d2a46893e4..089d9cf783 100644 --- a/package.json +++ b/package.json @@ -110,10 +110,6 @@ "tweetnacl": "^1.0.3", "ws": "^7.3.1" }, - "peerDependencies": { - "utf8": "^2.1.2", - "rxjs": "^6.5.3" - }, "nyc": { "exclude-after-remap": false, "exclude": [