Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ Client Library | v0.7.20-alpha.6 | [nem2-sdk-openapi-typescript-node-client](ht
- Fixed http repository `error handling` issues.
- Fixed bugs in `Alias` interface.
- Fixed `MosaicId significant byte` not detected properly in TransactionPayload.
- Fixed only `MIJIN_TEST` network type allowed in NetworkTypeHttp.
- Fixed only `PRIVATE_TEST` network type allowed in NetworkTypeHttp.
- Applied latest OpenAPI doc (`v0.7.19`).
- Changed `SignedTransaction` class constructor to public.
- Changed `MosaicRestrictionKey` format to be Hexadecimal.
Expand Down
3 changes: 1 addition & 2 deletions e2e/infrastructure/AccountHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(() => {
Expand Down
3 changes: 1 addition & 2 deletions e2e/infrastructure/BlockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(() => {
Expand Down
5 changes: 2 additions & 3 deletions e2e/infrastructure/HashLockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(() => {
Expand Down
3 changes: 1 addition & 2 deletions e2e/infrastructure/IntegrationTestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions e2e/infrastructure/Listener.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(() => {
Expand Down
3 changes: 1 addition & 2 deletions e2e/infrastructure/MetadataHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(() => {
Expand Down
3 changes: 1 addition & 2 deletions e2e/infrastructure/MosaicHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(() => {
Expand Down
3 changes: 1 addition & 2 deletions e2e/infrastructure/MultisigAccounts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(() => {
Expand Down
3 changes: 1 addition & 2 deletions e2e/infrastructure/NamespaceHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(() => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/infrastructure/PersistentHarvesting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('PersistentHarvesting', () => {

const vrfKeyPair = Account.createFromPrivateKey(
'82798EA9A2D2D202AFCCC82C40A287780BCA3C7F7A2FD5B754832804C6BE1BAA',
NetworkType.MIJIN_TEST,
NetworkType.PRIVATE_TEST,
);

before(() => {
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('PersistentHarvesting', () => {
remoteAccount.privateKey,
vrfKeyPair.privateKey,
'cfd84eca83508bbee954668e4aecca736caefa615367da76afe6985d695381db',
NetworkType.MIJIN_TEST,
NetworkType.PRIVATE_TEST,
helper.maxFee,
);

Expand Down
3 changes: 1 addition & 2 deletions e2e/infrastructure/RestrictionHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/infrastructure/TransactionHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 1 addition & 2 deletions e2e/infrastructure/UnresolvedMapping.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(() => {
Expand Down
3 changes: 1 addition & 2 deletions e2e/service/MetadataTransactionService.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down
3 changes: 1 addition & 2 deletions e2e/service/MosaicRestrictionTransactionService.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion e2e/service/TransactionService_AggregateBonded.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion src/core/utils/DtoMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 2 additions & 3 deletions src/infrastructure/RepositoryFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -139,7 +138,7 @@ export interface RepositoryFactory {
createListener(): IListener;

/**
* @returns nemesis block epoch
* @returns nemesis block epoch adjustment in seconds
*/
getEpochAdjustment(): Observable<Duration>;
getEpochAdjustment(): Observable<number>;
}
9 changes: 4 additions & 5 deletions src/infrastructure/RepositoryFactoryHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<Duration>;
private readonly epochAdjustment: Observable<number>;

/**
* Constructor
Expand All @@ -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));
Expand Down Expand Up @@ -174,7 +173,7 @@ export class RepositoryFactoryHttp implements RepositoryFactory {
return new Listener(this.websocketUrl, this.createNamespaceRepository(), this.websocketInjected);
}

getEpochAdjustment(): Observable<Duration> {
getEpochAdjustment(): Observable<number> {
return this.epochAdjustment;
}
}
6 changes: 5 additions & 1 deletion src/model/account/Address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export class Address {
networkType = NetworkType.TEST_NET;
} else if (addressTrimAndUpperCase.charAt(0) === 'N') {
networkType = NetworkType.MAIN_NET;
} else if (addressTrimAndUpperCase.charAt(0) === 'P') {
networkType = NetworkType.PRIVATE;
} else if (addressTrimAndUpperCase.charAt(0) === 'Q') {
networkType = NetworkType.PRIVATE_TEST;
} else {
throw new Error('Address Network unsupported');
}
Expand All @@ -69,7 +73,7 @@ export class Address {

/**
* Determines the validity of an raw address string.
* @param {string} rawAddress The raw address string. Expected format SATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA34I2PMQ
* @param {string} rawAddress The raw address string. Expected format QATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA367I6OQ
* @returns {boolean} true if the raw address string is valid, false otherwise.
*/
public static isValidRawAddress = (rawAddress: string): boolean => {
Expand Down
10 changes: 10 additions & 0 deletions src/model/network/NetworkType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,14 @@ export enum NetworkType {
* @type {number}
*/
MIJIN_TEST = 0x90,
/**
* Private net network
* @type {number}
*/
PRIVATE = 0x78,
/**
* Private test net network
* @type {number}
*/
PRIVATE_TEST = 0x80,
}
Loading