From 306857ae077e12a8b85dcd8f5781a21fa4393fa5 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 21 Nov 2019 21:06:21 +0100 Subject: [PATCH] Remove contracts v1 fees (#1596) * Remove contracts v1 fees * Fix linting --- packages/api-derive/src/contracts/fees.ts | 48 +---------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/packages/api-derive/src/contracts/fees.ts b/packages/api-derive/src/contracts/fees.ts index 51257ec1e1..b530ed90f5 100644 --- a/packages/api-derive/src/contracts/fees.ts +++ b/packages/api-derive/src/contracts/fees.ts @@ -31,48 +31,6 @@ function parseResult ([callBaseFee, contractFee, createBaseFee, creationFee, ren }; } -// Only for 1.0 support. rentByteFee, rentDepositOffset, tombstoneDeposit are not available in substrate 1.0. -// TODO remove this once 1.0 support is dropped -function queryV1 (api: ApiInterfaceRx): Observable { - return ( - api.queryMulti([ - api.query.contract.callBaseFee, - api.query.contract.contractFee, - api.query.contract.createBaseFee, - api.query.contract.creationFee, - api.query.contract.transactionBaseFee, - api.query.contract.transactionByteFee, - api.query.contract.transferFee - ]) as unknown as Observable - ).pipe( - map(([callBaseFee, contractFee, createBaseFee, creationFee, transactionBaseFee, transactionByteFee, transferFee]): DerivedContractFees => - // We've done this on purpose, i.e. so we can just copy the name/order from the parse above and - // see gaps, in this case those are filled with `ZERO` - parseResult([ - callBaseFee, contractFee, createBaseFee, creationFee, ZERO, ZERO, ZERO, transactionBaseFee, transactionByteFee, transferFee - ]) - ) - ); -} - -// query via query (early v2, non-current, support to be dropped]) -function queryQuery (api: ApiInterfaceRx): Observable { - const queryBase = api.query.contracts || api.query.contract; - - return api.queryMulti([ - queryBase.callBaseFee, - queryBase.contractFee, - queryBase.createBaseFee, - queryBase.creationFee, - queryBase.rentByteFee, - queryBase.rentDepositOffset, - queryBase.tombstoneDeposit, - queryBase.transactionBaseFee, - queryBase.transactionByteFee, - queryBase.transferFee - ]) as unknown as Observable; -} - // query via constants (current applicable path) function queryConstants (api: ApiInterfaceRx): Observable { return of([ @@ -104,14 +62,10 @@ function queryConstants (api: ApiInterfaceRx): Observable { */ export function fees (api: ApiInterfaceRx): () => Observable { return memo((): Observable => { - if (api.query.contract && !api.query.contract.rentByteFee) { - return queryV1(api); - } - return ( api.consts.contracts ? queryConstants(api) - : queryQuery(api) + : of([ZERO, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO, ZERO]) ).pipe( map(([callBaseFee, contractFee, createBaseFee, creationFee, rentByteFee, rentDepositOffset, tombstoneDeposit, transactionBaseFee, transactionByteFee, transferFee]): DerivedContractFees => // We've done this on purpose, i.e. so we can just copy the name/order from the parse above and see gaps