From e117619e34b505f95ab03f08ef4d1b92c45186f9 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 4 Mar 2021 08:57:22 +0100 Subject: [PATCH] Use the parent header for era info (#3260) --- packages/api-derive/src/tx/signingInfo.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/api-derive/src/tx/signingInfo.ts b/packages/api-derive/src/tx/signingInfo.ts index c056ced6cf..c29e150622 100644 --- a/packages/api-derive/src/tx/signingInfo.ts +++ b/packages/api-derive/src/tx/signingInfo.ts @@ -33,10 +33,16 @@ function nextNonce (api: ApiInterfaceRx, address: string): Observable { function signingHeader (api: ApiInterfaceRx): Observable
{ return combineLatest([ api.rpc.chain.getHeader(), - api.rpc.chain.getFinalizedHead().pipe( - switchMap((hash) => api.rpc.chain.getHeader(hash)) - ) + api.rpc.chain.getFinalizedHead() ]).pipe( + switchMap(([{ parentHash }, finHash]) => + // retrieve the headers - in the case of the current block, we use the parent + // to minimize (not completely remove) the impact that forks do have on the system + combineLatest([ + api.rpc.chain.getHeader(parentHash), + api.rpc.chain.getHeader(finHash) + ]) + ), map(([current, finalized]) => // determine the hash to use, current when lag > max, else finalized current.number.unwrap().sub(finalized.number.unwrap()).gt(MAX_FINALITY_LAG)