|
16 | 16 |
|
17 | 17 | import { Observable } from 'rxjs'; |
18 | 18 | 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'; |
21 | 31 | import { NetworkName } from '../model/network/NetworkName'; |
| 32 | +import { NetworkProperties } from '../model/network/NetworkProperties'; |
22 | 33 | 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'; |
23 | 39 | import { NodeInfo } from '../model/node/NodeInfo'; |
24 | 40 | import { Http } from './Http'; |
25 | 41 | import { NetworkRepository } from './NetworkRepository'; |
@@ -67,14 +83,81 @@ export class NetworkHttp extends Http implements NetworkRepository { |
67 | 83 | return this.call(this.networkRoutesApi.getNetworkType(), (body) => new NetworkName(body.name, body.description)); |
68 | 84 | } |
69 | 85 |
|
| 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 | + |
70 | 111 | /** |
71 | 112 | * Returns information about the average, median, highest and lower fee multiplier over the last |
72 | 113 | * \"numBlocksTransactionFeeStats\". The setting \"numBlocksTransactionFeeStats\" is adjustable |
73 | 114 | * via a configuration file (rest/resources/rest.json) per REST instance. |
74 | 115 | * @summary Get transaction fees information |
75 | 116 | */ |
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 | + ); |
79 | 162 | } |
80 | 163 | } |
0 commit comments