@shapeshiftoss/fiosdk
Version:
The Foundation for Interwallet Operability (FIO) is a consortium of leading blockchain wallets, exchanges and payments providers that seeks to accelerate blockchain adoption by reducing the risk, complexity, and inconvenience of sending and receiving cryp
31 lines (25 loc) • 979 B
text/typescript
import { FioFeeResponse } from '../../entities/FioFeeResponse'
import { Constants } from '../../utils/constants'
import { Query } from './Query'
import { validationRules } from '../../utils/validation'
export class GetFee extends Query<FioFeeResponse> {
public ENDPOINT: string = 'chain/get_fee'
public endPoint: string
public fioAddress: string
constructor(endPoint: string, fioAddress: string = '') {
super()
this.endPoint = endPoint
this.fioAddress = fioAddress
if (Constants.feeNoAddressOperation.findIndex((element) => element === endPoint) > -1 && fioAddress.length > 0) {
throw new Error('End point ' + endPoint + ' should not have any fio address, when requesting fee')
}
if (fioAddress) {
this.validationData = { fioAddress }
this.validationRules = validationRules.getFee
}
}
public async getData() {
const data = { end_point: this.endPoint, fio_address: this.fioAddress || null }
return data
}
}