Support TransactionPayment.{TransactionBaseFee, TransactionByteFee} (#1493)
* Support TransactionPayment.{TransactionBaseFee, TransactionByteFee}
* Dedup
* Ordering
This commit is contained in:
@@ -14,14 +14,16 @@ import { drr } from '../util/drr';
|
||||
type Result = [Balance, Balance, Balance, Balance, Balance];
|
||||
|
||||
function queryV2 (api: ApiInterfaceRx): Observable<Result> {
|
||||
const paymentBase = api.consts.transactionPayment || api.consts.balances;
|
||||
|
||||
return of([
|
||||
// get values from api.const for substrate versions post spec_version: 101
|
||||
// https://github.com/paritytech/substrate/pull/2883/files#diff-5e5e1c3aec9ddfde0a9054d062ab3db9R131
|
||||
api.consts.balances.creationFee as Balance,
|
||||
api.consts.balances.existentialDeposit as Balance,
|
||||
api.consts.balances.transactionBaseFee as Balance,
|
||||
api.consts.balances.transactionByteFee as Balance,
|
||||
api.consts.balances.transferFee as Balance
|
||||
api.consts.balances.transferFee as Balance,
|
||||
paymentBase.transactionBaseFee as Balance,
|
||||
paymentBase.transactionByteFee as Balance
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -30,9 +32,9 @@ function queryV1 (api: ApiInterfaceRx): Observable<Result> {
|
||||
// Support older versions and get values from storage
|
||||
api.query.balances.creationFee,
|
||||
api.query.balances.existentialDeposit,
|
||||
api.query.balances.transferFee,
|
||||
api.query.balances.transactionBaseFee,
|
||||
api.query.balances.transactionByteFee,
|
||||
api.query.balances.transferFee
|
||||
api.query.balances.transactionByteFee
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -56,7 +58,7 @@ export function fees (api: ApiInterfaceRx): () => Observable<DerivedFees> {
|
||||
? queryV2(api)
|
||||
: queryV1(api)
|
||||
).pipe(
|
||||
map(([creationFee, existentialDeposit, transactionBaseFee, transactionByteFee, transferFee]): DerivedFees => ({
|
||||
map(([creationFee, existentialDeposit, transferFee, transactionBaseFee, transactionByteFee]): DerivedFees => ({
|
||||
creationFee,
|
||||
existentialDeposit,
|
||||
transactionBaseFee,
|
||||
|
||||
@@ -22,6 +22,7 @@ import { FullIdentification, IdentificationTuple, Keys, SessionIndex, SessionKey
|
||||
import { EraIndex, EraPoints, EraRewards, Exposure, Forcing, IndividualExposure, MomentOf, Points, RewardDestination, SlashJournalEntry, StakingLedger, UnlockChunk, ValidatorPrefs, ValidatorPrefs0to145 } from '@polkadot/types/interfaces/staking';
|
||||
import { DigestOf, DispatchError, Event, EventId, EventIndex, EventRecord, EventRecord0to76, Key, Phase } from '@polkadot/types/interfaces/system';
|
||||
import { TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import { DispatchResult, DispatchResultOf } from '@polkadot/types/interfaces/utility';
|
||||
import { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/types/interfaces/attestations';
|
||||
import { EcdsaSignature, EthereumAddress } from '@polkadot/types/interfaces/claims';
|
||||
@@ -639,6 +640,9 @@ export interface InterfaceRegistry {
|
||||
TreasuryProposal: TreasuryProposal;
|
||||
'Option<TreasuryProposal>': Option<TreasuryProposal>;
|
||||
'Vec<TreasuryProposal>': Vec<TreasuryProposal>;
|
||||
Multiplier: Multiplier;
|
||||
'Option<Multiplier>': Option<Multiplier>;
|
||||
'Vec<Multiplier>': Vec<Multiplier>;
|
||||
DispatchResult: DispatchResult;
|
||||
'Option<DispatchResult>': Option<DispatchResult>;
|
||||
'Vec<DispatchResult>': Vec<DispatchResult>;
|
||||
|
||||
@@ -24,6 +24,7 @@ export { default as session } from './session/definitions';
|
||||
export { default as staking } from './staking/definitions';
|
||||
export { default as system } from './system/definitions';
|
||||
export { default as treasury } from './treasury/definitions';
|
||||
export { default as txpayment } from './txpayment/definitions';
|
||||
export { default as utility } from './utility/definitions';
|
||||
|
||||
// polkadot-specific types
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2019 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export default {
|
||||
types: {
|
||||
Multiplier: 'Fixed64'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
// Auto-generated via `yarn build:interfaces`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
export * from './types';
|
||||
@@ -0,0 +1,7 @@
|
||||
// Auto-generated via `yarn build:interfaces`, do not edit
|
||||
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||
|
||||
import { Fixed64 } from '@polkadot/types/primitive';
|
||||
|
||||
/** Fixed64 */
|
||||
export interface Multiplier extends Fixed64 {}
|
||||
@@ -20,6 +20,7 @@ export * from './session/types';
|
||||
export * from './staking/types';
|
||||
export * from './system/types';
|
||||
export * from './treasury/types';
|
||||
export * from './txpayment/types';
|
||||
export * from './utility/types';
|
||||
export * from './attestations/types';
|
||||
export * from './claims/types';
|
||||
|
||||
Reference in New Issue
Block a user