This commit is contained in:
ian.he
2019-04-11 13:42:06 +12:00
commit 4e30fab9d6
688 changed files with 51707 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
// Copyright 2017-2019 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Observable, combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterface$Rx } from '@plugnet/api/types';
import BN from 'bn.js';
import { DerivedFees } from '../types';
import { drr } from '../util/drr';
export function fees (api: ApiInterface$Rx) {
return (): Observable<DerivedFees> => {
return (combineLatest(
api.query.balances.creationFee(),
api.query.balances.existentialDeposit(),
api.query.fees
? api.query.fees.transactionBaseFee()
: api.query.balances.transactionBaseFee(),
api.query.fees
? api.query.fees.transactionByteFee()
: api.query.balances.transactionByteFee(),
api.query.balances.transferFee()
) as any as Observable<[BN, BN, BN, BN, BN]>).pipe(
map(([creationFee, existentialDeposit, transactionBaseFee, transactionByteFee, transferFee]) => ({
creationFee,
existentialDeposit,
transactionBaseFee,
transactionByteFee,
transferFee
})),
drr()
) ;
};
}