Skip to content

Commit d60bb24

Browse files
authored
Merge pull request #444 from NEMStudios/task/g443_open_api_0.8.3
Applied openAPI 0.8.3
2 parents c76f413 + 9aa2d4c commit d60bb24

File tree

8 files changed

+71
-5
lines changed

8 files changed

+71
-5
lines changed

e2e/infrastructure/NetworkHttp.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,14 @@ describe('NetworkHttp', () => {
4444
expect(networkName.description.toLowerCase()).to.be.not.null;
4545
});
4646
});
47+
48+
describe('getNetworkFees', () => {
49+
it('should return network fees', async () => {
50+
const fees = await networkRepository.getNetworkFees().toPromise();
51+
expect(fees.averageFeeMultiplier).to.be.not.null;
52+
expect(fees.highestFeeMultiplier).to.be.not.null;
53+
expect(fees.lowestFeeMultiplier).to.be.not.null;
54+
expect(fees.medianFeeMultiplier).to.be.not.null;
55+
});
56+
});
4757
});

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"js-sha3": "^0.8.0",
6767
"long": "^4.0.0",
6868
"merkletreejs": "^0.1.7",
69-
"nem2-sdk-openapi-typescript-node-client": "0.8.2",
69+
"nem2-sdk-openapi-typescript-node-client": "0.8.3",
7070
"request": "^2.88.0",
7171
"request-promise-native": "^1.0.5",
7272
"ripemd160": "^2.0.2",

src/infrastructure/NetworkHttp.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { NetworkRoutesApi } from 'nem2-sdk-openapi-typescript-node-client';
1818
import { from as observableFrom, Observable, throwError } from 'rxjs';
1919
import { catchError, map } from 'rxjs/operators';
20+
import { NetworkFees } from '../model/blockchain/NetworkFees';
2021
import { NetworkName } from '../model/blockchain/NetworkName';
2122
import { NetworkType } from '../model/blockchain/NetworkType';
2223
import { NodeInfo } from '../model/node/NodeInfo';
@@ -71,4 +72,18 @@ export class NetworkHttp extends Http implements NetworkRepository {
7172
catchError((error) => throwError(this.errorHandling(error))),
7273
);
7374
}
75+
76+
/**
77+
* Returns information about the average, median, highest and lower fee multiplier over the last
78+
* \"numBlocksTransactionFeeStats\". The setting \"numBlocksTransactionFeeStats\" is adjustable
79+
* via a configuration file (rest/resources/rest.json) per REST instance.
80+
* @summary Get transaction fees information
81+
*/
82+
public getNetworkFees(): Observable<NetworkFees> {
83+
return observableFrom(this.networkRouteApi.getNetworkFees()).pipe(
84+
map((({body}) =>
85+
new NetworkFees(body.averageFeeMultiplier, body.medianFeeMultiplier, body.highestFeeMultiplier, body.lowestFeeMultiplier))),
86+
catchError((error) => throwError(this.errorHandling(error))),
87+
);
88+
}
7489
}

src/infrastructure/NetworkRepository.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import {Observable} from 'rxjs';
18+
import { NetworkFees } from '../model/blockchain/NetworkFees';
1819
import { NetworkName } from '../model/blockchain/NetworkName';
1920
import {NetworkType} from '../model/blockchain/NetworkType';
2021

@@ -37,4 +38,11 @@ export interface NetworkRepository {
3738
* @return current network type name and description
3839
*/
3940
getNetworkName(): Observable<NetworkName>;
41+
42+
/**
43+
* Returns information about the average, median, highest and lower fee multiplier over the last "numBlocksTransactionFeeStats".
44+
* @return the NetworkFees
45+
*/
46+
getNetworkFees(): Observable<NetworkFees> ;
47+
4048
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2019 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+
/**
18+
* Network Fees
19+
*/
20+
export class NetworkFees {
21+
22+
/**
23+
* @param averageFeeMultiplier - Average fee multiplier over the last \"numBlocksTransactionFeeStats\".
24+
* @param medianFeeMultiplier - Median fee multiplier over the last \"numBlocksTransactionFeeStats\".
25+
* @param highestFeeMultiplier - Fee multiplier applied to transactions contained in block.
26+
* @param lowestFeeMultiplier - Fee multiplier applied to transactions contained in block.
27+
*/
28+
constructor(public readonly averageFeeMultiplier: number,
29+
public readonly medianFeeMultiplier: number,
30+
public readonly highestFeeMultiplier: number,
31+
public readonly lowestFeeMultiplier: number) {
32+
}
33+
}

src/model/blockchain/NetworkName.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
/**
18-
* The block merkle proof info
18+
* Network Name
1919
*/
2020
export class NetworkName {
2121

src/model/blockchain/NetworkSetting.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)