mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Use BigNumber internally to compute fee
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as _ from 'lodash'
|
||||
import {convertKeysFromSnakeCaseToCamelCase} from './utils'
|
||||
import Connection from './connection'
|
||||
import BigNumber from 'bignumber.js'
|
||||
|
||||
export type GetServerInfoResponse = {
|
||||
buildVersion: string,
|
||||
@@ -60,13 +61,12 @@ function getServerInfo(connection: Connection): Promise<GetServerInfoResponse> {
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: This was originally annotated to return a number, but actually
|
||||
// returned a toString'ed number. Should this actually be returning a number?
|
||||
function computeFeeFromServerInfo(cushion: number,
|
||||
serverInfo: GetServerInfoResponse
|
||||
): string {
|
||||
return (Number(serverInfo.validatedLedger.baseFeeXRP)
|
||||
* Number(serverInfo.loadFactor) * cushion).toString()
|
||||
return (new BigNumber(serverInfo.validatedLedger.baseFeeXRP)).
|
||||
times(serverInfo.loadFactor).
|
||||
times(cushion).toString()
|
||||
}
|
||||
|
||||
function getFee(connection: Connection, cushion: number): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user