-
Notifications
You must be signed in to change notification settings - Fork 19
/
txParentBlockContext.ts
33 lines (27 loc) · 1.17 KB
/
txParentBlockContext.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { IContextDef } from "plugin-api/IContextDef";
import { ITxPageContext } from "app/eth-common/page/tx/txPage";
import { ITxParentBlockContext } from "app/shared/context/ITxParentBlockContext";
import { ITxDetails } from "app/shared/data/tx/details/ITxDetails";
import { isPendingTxDetails } from "app/eth-extended/data/tx/details/isPendingTxDetails";
import { txContextType } from "app/shared/context/txContextType";
import { txParentBlockContextType } from "app/shared/context/txParentBlockContextType";
export const txParentBlockContext: (options: {
txDetailsAdapterUri: string;
}) => IContextDef<ITxPageContext, ITxParentBlockContext> = ({txDetailsAdapterUri}) => ({
parentContextType: txContextType,
contextType: txParentBlockContextType,
dataAdapters: [{
ref: txDetailsAdapterUri
}],
create(parentCtx, parentData) {
let txDetails = parentData.get(txDetailsAdapterUri)!.data as ITxDetails;
if (isPendingTxDetails(txDetails)) {
return void 0;
}
let ctx: ITxParentBlockContext = {
txHash: parentCtx.txHash,
blockNumber: txDetails.block.id
};
return ctx;
}
});