Skip to content

Commit 28c7d5c

Browse files
committed
Applied openAPI 0.8.7 changes
1 parent c0fc1a3 commit 28c7d5c

26 files changed

+1379
-773
lines changed

e2e/infrastructure/IntegrationTestHelper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export class IntegrationTestHelper {
5757
console.log(`Running tests against: ${json.apiUrl}`);
5858
this.apiUrl = json.apiUrl;
5959
this.repositoryFactory = new RepositoryFactoryHttp(json.apiUrl);
60-
this.transactionService = new TransactionService(this.repositoryFactory.createTransactionRepository(), this.repositoryFactory.createReceiptRepository());
60+
this.transactionService = new TransactionService(
61+
this.repositoryFactory.createTransactionRepository(), this.repositoryFactory.createReceiptRepository());
6162
combineLatest(this.repositoryFactory.getGenerationHash(),
6263
this.repositoryFactory.getNetworkType()).subscribe(([generationHash, networkType]) => {
6364
this.networkType = networkType;

e2e/infrastructure/MosaicHttp.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ describe('MosaicHttp', () => {
8787
expect(mosaicDefinitionTransaction.nonce).to.deep.equal(listenedTransaction.nonce);
8888
expect(mosaicDefinitionTransaction.getMosaicNonceIntValue()).to.be.equal(listenedTransaction.getMosaicNonceIntValue());
8989

90-
const savedTransaction = await helper.repositoryFactory.createTransactionRepository().getTransaction(signedTransaction.hash).toPromise() as MosaicDefinitionTransaction;
90+
const savedTransaction = await helper.repositoryFactory.createTransactionRepository()
91+
.getTransaction(signedTransaction.hash).toPromise() as MosaicDefinitionTransaction;
9192
expect(mosaicDefinitionTransaction.nonce.toHex()).to.be.equal(savedTransaction.nonce.toHex());
9293
expect(mosaicDefinitionTransaction.nonce).to.deep.equal(savedTransaction.nonce);
9394
expect(mosaicDefinitionTransaction.getMosaicNonceIntValue()).to.be.equal(savedTransaction.getMosaicNonceIntValue());

e2e/infrastructure/NetworkHttp.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('NetworkHttp', () => {
4747

4848
describe('getNetworkFees', () => {
4949
it('should return network fees', async () => {
50-
const fees = await networkRepository.getNetworkFees().toPromise();
50+
const fees = await networkRepository.getTransactionFees().toPromise();
5151
expect(fees.averageFeeMultiplier).to.be.not.null;
5252
expect(fees.highestFeeMultiplier).to.be.not.null;
5353
expect(fees.lowestFeeMultiplier).to.be.not.null;

package-lock.json

Lines changed: 684 additions & 737 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@
4545
"@types/ws": "^3.2.0",
4646
"assert": "^1.4.1",
4747
"chai": "^4.1.2",
48-
"coveralls": "^3.0.6",
48+
"coveralls": "^3.0.9",
4949
"gulp": "^4.0.2",
5050
"gulp-typescript": "^5.0.1",
5151
"mocha": "^4.0.1",
52-
"nyc": "^14.1.1",
52+
"nyc": "^15.0.0",
5353
"secure-random": "^1.1.1",
5454
"ts-mockito": "^2.4.0",
55-
"ts-node": "^5.0.1",
56-
"tslint": "^5.20.1",
57-
"typescript": "^2.9.2",
55+
"ts-node": "^8.6.2",
56+
"tslint": "^6.0.0",
57+
"typescript": "^3.7.5",
5858
"typescript-require": "^0.2.10"
5959
},
6060
"dependencies": {
61-
"bluebird": "^3.5.5",
61+
"bluebird": "^3.7.2",
6262
"catbuffer-typescript": "0.0.11",
6363
"crypto-js": "^3.1.9-1",
6464
"diff": "^4.0.2",
@@ -74,10 +74,10 @@
7474
"ripemd160": "^2.0.2",
7575
"rxjs": "^6.5.3",
7676
"rxjs-compat": "^6.5.3",
77-
"symbol-openapi-typescript-node-client": "0.8.5",
77+
"symbol-openapi-typescript-node-client": "0.8.7",
7878
"tweetnacl": "^1.0.3",
79-
"utf8": "^2.1.2",
80-
"ws": "^5.2.0"
79+
"utf8": "^3.0.0",
80+
"ws": "^7.2.3"
8181
},
8282
"peerDependencies": {
8383
"js-joda": "^1.6.2",

src/infrastructure/NetworkHttp.ts

Lines changed: 88 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,26 @@
1616

1717
import { Observable } from 'rxjs';
1818
import { map } from 'rxjs/operators';
19-
import { NetworkRoutesApi } from 'symbol-openapi-typescript-node-client';
20-
import { NetworkFees } from '../model/network/NetworkFees';
19+
import { NetworkConfigurationDTO, NetworkRoutesApi } from 'symbol-openapi-typescript-node-client';
20+
import { AccountLinkNetworkProperties } from '../model/network/AccountLinkNetworkProperties';
21+
import { AccountRestrictionNetworkProperties } from '../model/network/AccountRestrictionNetworkProperties';
22+
import { AggregateNetworkProperties } from '../model/network/AggregateNetworkProperties';
23+
import { ChainProperties } from '../model/network/ChainProperties';
24+
import { HashLockNetworkProperties } from '../model/network/HashLockNetworkProperties';
25+
import { MetadataNetworkProperties } from '../model/network/MetadataNetworkProperties';
26+
import { MosaicNetworkProperties } from '../model/network/MosaicNetworkProperties';
27+
import { MosaicRestrictionNetworkProperties } from '../model/network/MosaicRestrictionNetworkProperties';
28+
import { MultisigNetworkProperties } from '../model/network/MultisigNetworkProperties';
29+
import { NamespaceNetworkProperties } from '../model/network/NamespaceNetworkProperties';
30+
import { NetworkConfiguration } from '../model/network/NetworkConfiguration';
2131
import { NetworkName } from '../model/network/NetworkName';
32+
import { NetworkProperties } from '../model/network/NetworkProperties';
2233
import { NetworkType } from '../model/network/NetworkType';
34+
import { PluginProperties } from '../model/network/PluginProperties';
35+
import { RentalFees } from '../model/network/RentalFees';
36+
import { SecretLockNetworkProperties } from '../model/network/SecretLockNetworkProperties';
37+
import { TransactionFees } from '../model/network/TransactionFees';
38+
import { TransferNetworkProperties } from '../model/network/TransferNetworkProperties';
2339
import { NodeInfo } from '../model/node/NodeInfo';
2440
import { Http } from './Http';
2541
import { NetworkRepository } from './NetworkRepository';
@@ -67,14 +83,81 @@ export class NetworkHttp extends Http implements NetworkRepository {
6783
return this.call(this.networkRoutesApi.getNetworkType(), (body) => new NetworkName(body.name, body.description));
6884
}
6985

86+
/**
87+
* Returns the content from a catapult-server network configuration file (resources/config-network.properties).
88+
* To enable this feature, the REST setting \"network.propertiesFilePath\" must define where the file is located.
89+
* This is adjustable via the configuration file (rest/resources/rest.json) per REST instance.
90+
* @summary Get the network properties
91+
*/
92+
public getNetworkProperties(): Observable<NetworkConfiguration> {
93+
return this.call(this.networkRoutesApi.getNetworkProperties(), (body) =>
94+
this.mapNetworkConfigurationDto(body),
95+
);
96+
}
97+
98+
/**
99+
* Returns the estimated effective rental fees for namespaces and mosaics. This endpoint is only available
100+
* if the REST instance has access to catapult-server ``resources/config-network.properties`` file.
101+
* To activate this feature, add the setting \"network.propertiesFilePath\" in the configuration file (rest/resources/rest.json).
102+
* @summary Get rental fees information
103+
*/
104+
public getRentalFees(): Observable<RentalFees> {
105+
return this.call(this.networkRoutesApi.getRentalFees(), (body) =>
106+
new RentalFees(body.effectiveRootNamespaceRentalFeePerBlock,
107+
body.effectiveChildNamespaceRentalFee,
108+
body.effectiveMosaicRentalFee));
109+
}
110+
70111
/**
71112
* Returns information about the average, median, highest and lower fee multiplier over the last
72113
* \"numBlocksTransactionFeeStats\". The setting \"numBlocksTransactionFeeStats\" is adjustable
73114
* via a configuration file (rest/resources/rest.json) per REST instance.
74115
* @summary Get transaction fees information
75116
*/
76-
public getNetworkFees(): Observable<NetworkFees> {
77-
return this.call(this.networkRoutesApi.getNetworkFees(), (body) =>
78-
new NetworkFees(body.averageFeeMultiplier, body.medianFeeMultiplier, body.highestFeeMultiplier, body.lowestFeeMultiplier));
117+
public getTransactionFees(): Observable<TransactionFees> {
118+
return this.call(this.networkRoutesApi.getTransactionFees(), (body) =>
119+
new TransactionFees(body.averageFeeMultiplier, body.medianFeeMultiplier, body.highestFeeMultiplier, body.lowestFeeMultiplier));
120+
}
121+
122+
/**
123+
* Map dto to sdk models
124+
* @param dto dto object returned from rest
125+
*/
126+
private mapNetworkConfigurationDto(dto: NetworkConfigurationDTO): NetworkConfiguration {
127+
return new NetworkConfiguration(
128+
new NetworkProperties(dto.network.identifier, dto.network.nodeEqualityStrategy,
129+
dto.network.publicKey, dto.network.generationHash, dto.network.epochAdjustment),
130+
new ChainProperties(dto.chain.enableVerifiableState, dto.chain.enableVerifiableReceipts,
131+
dto.chain.currencyMosaicId, dto.chain.harvestingMosaicId, dto.chain.blockGenerationTargetTime,
132+
dto.chain.blockTimeSmoothingFactor, dto.chain.importanceGrouping, dto.chain.importanceActivityPercentage,
133+
dto.chain.maxDifficultyBlocks, dto.chain.maxDifficultyBlocks, dto.chain.defaultDynamicFeeMultiplier,
134+
dto.chain.maxTransactionLifetime, dto.chain.maxBlockFutureTime, dto.chain.initialCurrencyAtomicUnits,
135+
dto.chain.maxMosaicAtomicUnits, dto.chain.totalChainImportance, dto.chain.minHarvesterBalance,
136+
dto.chain.maxHarvesterBalance, dto.chain.harvestBeneficiaryPercentage, dto.chain.blockPruneInterval,
137+
dto.chain.maxTransactionsPerBlock),
138+
new PluginProperties(
139+
new AccountLinkNetworkProperties(dto.plugins.accountlink?.dummy),
140+
new AggregateNetworkProperties(dto.plugins.aggregate?.maxTransactionsPerAggregate,
141+
dto.plugins.aggregate?.maxCosignaturesPerAggregate, dto.plugins.aggregate?.enableStrictCosignatureCheck,
142+
dto.plugins.aggregate?.enableBondedAggregateSupport, dto.plugins.aggregate?.maxBondedTransactionLifetime),
143+
new HashLockNetworkProperties(dto.plugins.lockhash?.lockedFundsPerAggregate, dto.plugins.lockhash?.maxHashLockDuration),
144+
new SecretLockNetworkProperties(dto.plugins.locksecret?.maxSecretLockDuration, dto.plugins.locksecret?.maxProofSize,
145+
dto.plugins.locksecret?.maxProofSize),
146+
new MetadataNetworkProperties(dto.plugins.metadata?.maxValueSize),
147+
new MosaicNetworkProperties(dto.plugins.mosaic?.maxMosaicsPerAccount, dto.plugins.mosaic?.maxMosaicDuration,
148+
dto.plugins.mosaic?.maxMosaicDivisibility, dto.plugins.mosaic?.mosaicRentalFeeSinkPublicKey,
149+
dto.plugins.mosaic?.mosaicRentalFee),
150+
new MultisigNetworkProperties(dto.plugins.multisig?.maxMultisigDepth, dto.plugins.multisig?.maxCosignatoriesPerAccount,
151+
dto.plugins.multisig?.maxCosignedAccountsPerAccount),
152+
new NamespaceNetworkProperties(dto.plugins.namespace?.maxNameSize, dto.plugins.namespace?.maxChildNamespaces,
153+
dto.plugins.namespace?.maxNamespaceDepth, dto.plugins.namespace?.minNamespaceDuration,
154+
dto.plugins.namespace?.maxNamespaceDuration, dto.plugins.namespace?.namespaceGracePeriodDuration,
155+
dto.plugins.namespace?.reservedRootNamespaceNames, dto.plugins.namespace?.namespaceRentalFeeSinkPublicKey,
156+
dto.plugins.namespace?.rootNamespaceRentalFeePerBlock, dto.plugins.namespace?.childNamespaceRentalFee),
157+
new AccountRestrictionNetworkProperties(dto.plugins.restrictionaccount?.maxAccountRestrictionValues),
158+
new MosaicRestrictionNetworkProperties(dto.plugins.restrictionmosaic?.maxMosaicRestrictionValues),
159+
new TransferNetworkProperties(dto.plugins.transfer?.maxMessageSize),
160+
),
161+
);
79162
}
80163
}

src/infrastructure/NetworkRepository.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
*/
1616

1717
import {Observable} from 'rxjs';
18-
import { NetworkFees } from '../model/network/NetworkFees';
18+
import { NetworkConfiguration } from '../model/network/NetworkConfiguration';
1919
import { NetworkName } from '../model/network/NetworkName';
2020
import {NetworkType} from '../model/network/NetworkType';
21+
import { RentalFees } from '../model/network/RentalFees';
22+
import { TransactionFees } from '../model/network/TransactionFees';
2123

2224
/**
2325
* Network interface repository.
@@ -26,23 +28,39 @@ import {NetworkType} from '../model/network/NetworkType';
2628
*/
2729
export interface NetworkRepository {
2830

31+
/**
32+
* Get current network type name and description
33+
*
34+
* @return current network type name and description
35+
*/
36+
getNetworkName(): Observable<NetworkName>;
37+
38+
/**
39+
* Returns the content from a catapult-server network configuration file (resources/config-network.properties).
40+
* To enable this feature, the REST setting \"network.propertiesFilePath\" must define where the file is located.
41+
* This is adjustable via the configuration file (rest/resources/rest.json) per REST instance.
42+
* @summary Get the network properties
43+
*/
44+
getNetworkProperties(): Observable<NetworkConfiguration>;
45+
2946
/**
3047
* Get current network type.
3148
* @return network type enum.
3249
*/
3350
getNetworkType(): Observable<NetworkType>;
3451

3552
/**
36-
* Get current network type name and description
37-
*
38-
* @return current network type name and description
53+
* Returns the estimated effective rental fees for namespaces and mosaics. This endpoint is only available
54+
* if the REST instance has access to catapult-server ``resources/config-network.properties`` file.
55+
* To activate this feature, add the setting \"network.propertiesFilePath\" in the configuration file (rest/resources/rest.json).
56+
* @summary Get rental fees information
3957
*/
40-
getNetworkName(): Observable<NetworkName>;
58+
getRentalFees(): Observable<RentalFees>;
4159

4260
/**
43-
* Returns information about the average, median, highest and lower fee multiplier over the last "numBlocksTransactionFeeStats".
44-
* @return the NetworkFees
61+
* Returns the average, median, highest and lower fee multiplier over the last \"numBlocksTransactionFeeStats\".
62+
* The setting \"numBlocksTransactionFeeStats\" is adjustable via the configuration file (rest/resources/rest.json) per REST instance.
63+
* @summary Get transaction fees information
4564
*/
46-
getNetworkFees(): Observable<NetworkFees> ;
47-
65+
getTransactionFees(): Observable<TransactionFees>;
4866
}

src/model/model.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ export * from './account/AccountNames';
3232
export * from './blockchain/BlockchainScore';
3333
export * from './blockchain/StorageInfo';
3434
export * from './blockchain/BlockInfo';
35-
export * from './network/NetworkType';
3635
export * from './blockchain/MerklePathItem';
3736
export * from './blockchain/MerkleProofInfo';
38-
export * from './network/NetworkName';
3937

4038
// Diagnostic
4139
export * from './node/ServerInfo';
@@ -72,6 +70,28 @@ export * from './namespace/NamespaceRegistrationType';
7270
export * from './namespace/AliasAction';
7371
export * from './namespace/EmptyAlias';
7472

73+
// Network
74+
75+
export * from './network/AccountLinkNetworkProperties';
76+
export * from './network/AccountRestrictionNetworkProperties';
77+
export * from './network/AggregateNetworkProperties';
78+
export * from './network/ChainProperties';
79+
export * from './network/HashLockNetworkProperties';
80+
export * from './network/MetadataNetworkProperties';
81+
export * from './network/MosaicNetworkProperties';
82+
export * from './network/MosaicRestrictionNetworkProperties';
83+
export * from './network/MultisigNetworkProperties';
84+
export * from './network/NamespaceNetworkProperties';
85+
export * from './network/NetworkConfiguration';
86+
export * from './network/NetworkName';
87+
export * from './network/NetworkProperties';
88+
export * from './network/NetworkType';
89+
export * from './network/PluginProperties';
90+
export * from './network/RentalFees';
91+
export * from './network/SecretLockNetworkProperties';
92+
export * from './network/TransactionFees';
93+
export * from './network/TransferNetworkProperties';
94+
7595
// Node
7696
export * from './node/NodeInfo';
7797
export * from './node/NodeTime';
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2020 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export class AccountLinkNetworkProperties {
18+
19+
/**
20+
* @param dummy - to trigger plugin load.
21+
*/
22+
constructor(public readonly dummy?: string) {
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2020 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export class AccountRestrictionNetworkProperties {
18+
19+
/**
20+
* @param maxAccountRestrictionValues - Maximum number of account restriction values.
21+
*/
22+
constructor(public readonly maxAccountRestrictionValues?: string) {
23+
}
24+
}

0 commit comments

Comments
 (0)