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
10 changes: 10 additions & 0 deletions e2e/infrastructure/NetworkHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,14 @@ describe('NetworkHttp', () => {
expect(networkName.description.toLowerCase()).to.be.not.null;
});
});

describe('getNetworkFees', () => {
it('should return network fees', async () => {
const fees = await networkRepository.getNetworkFees().toPromise();
expect(fees.averageFeeMultiplier).to.be.not.null;
expect(fees.highestFeeMultiplier).to.be.not.null;
expect(fees.lowestFeeMultiplier).to.be.not.null;
expect(fees.medianFeeMultiplier).to.be.not.null;
});
});
});
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"js-sha3": "^0.8.0",
"long": "^4.0.0",
"merkletreejs": "^0.1.7",
"nem2-sdk-openapi-typescript-node-client": "0.8.2",
"nem2-sdk-openapi-typescript-node-client": "0.8.3",
"request": "^2.88.0",
"request-promise-native": "^1.0.5",
"ripemd160": "^2.0.2",
Expand Down
15 changes: 15 additions & 0 deletions src/infrastructure/NetworkHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { NetworkRoutesApi } from 'nem2-sdk-openapi-typescript-node-client';
import { from as observableFrom, Observable, throwError } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { NetworkFees } from '../model/blockchain/NetworkFees';
import { NetworkName } from '../model/blockchain/NetworkName';
import { NetworkType } from '../model/blockchain/NetworkType';
import { NodeInfo } from '../model/node/NodeInfo';
Expand Down Expand Up @@ -71,4 +72,18 @@ export class NetworkHttp extends Http implements NetworkRepository {
catchError((error) => throwError(this.errorHandling(error))),
);
}

/**
* Returns information about the average, median, highest and lower fee multiplier over the last
* \"numBlocksTransactionFeeStats\". The setting \"numBlocksTransactionFeeStats\" is adjustable
* via a configuration file (rest/resources/rest.json) per REST instance.
* @summary Get transaction fees information
*/
public getNetworkFees(): Observable<NetworkFees> {
return observableFrom(this.networkRouteApi.getNetworkFees()).pipe(
map((({body}) =>
new NetworkFees(body.averageFeeMultiplier, body.medianFeeMultiplier, body.highestFeeMultiplier, body.lowestFeeMultiplier))),
catchError((error) => throwError(this.errorHandling(error))),
);
}
}
8 changes: 8 additions & 0 deletions src/infrastructure/NetworkRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {Observable} from 'rxjs';
import { NetworkFees } from '../model/blockchain/NetworkFees';
import { NetworkName } from '../model/blockchain/NetworkName';
import {NetworkType} from '../model/blockchain/NetworkType';

Expand All @@ -37,4 +38,11 @@ export interface NetworkRepository {
* @return current network type name and description
*/
getNetworkName(): Observable<NetworkName>;

/**
* Returns information about the average, median, highest and lower fee multiplier over the last "numBlocksTransactionFeeStats".
* @return the NetworkFees
*/
getNetworkFees(): Observable<NetworkFees> ;

}
33 changes: 33 additions & 0 deletions src/model/blockchain/NetworkFees.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2019 NEM
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Network Fees
*/
export class NetworkFees {

/**
* @param averageFeeMultiplier - Average fee multiplier over the last \"numBlocksTransactionFeeStats\".
* @param medianFeeMultiplier - Median fee multiplier over the last \"numBlocksTransactionFeeStats\".
* @param highestFeeMultiplier - Fee multiplier applied to transactions contained in block.
* @param lowestFeeMultiplier - Fee multiplier applied to transactions contained in block.
*/
constructor(public readonly averageFeeMultiplier: number,
public readonly medianFeeMultiplier: number,
public readonly highestFeeMultiplier: number,
public readonly lowestFeeMultiplier: number) {
}
}
2 changes: 1 addition & 1 deletion src/model/blockchain/NetworkName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/**
* The block merkle proof info
* Network Name
*/
export class NetworkName {

Expand Down
Empty file.