-
Notifications
You must be signed in to change notification settings - Fork 19
/
BlockConfirmationsAdapter.ts
32 lines (26 loc) · 1.06 KB
/
BlockConfirmationsAdapter.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
import { IDataAdapter } from "plugin-api/IDataAdapter";
import { LatestBlockWatcher } from "app/shared/adapter/block/LatestBlockWatcher";
import { blockContextType } from "app/shared/context/blockContextType";
import { BlockStateStore } from "app/shared/data/BlockStateStore";
import { IBlockContext } from "app/shared/context/IBlockContext";
export interface IBlockConfirmations {
count: number;
confirmed: boolean;
}
export class BlockConfirmationsAdapter implements IDataAdapter<IBlockContext, IBlockConfirmations> {
contextType = blockContextType;
constructor(private blockStateStore: BlockStateStore) {
}
async load(context: IBlockContext) {
let count = this.blockStateStore.getConfirmations(context.blockNumber);
let confirmed = this.blockStateStore.isConfirmed(context.blockNumber);
let confirmations: IBlockConfirmations = {
count,
confirmed
};
return confirmations;
}
createWatcher(context: IBlockContext) {
return new LatestBlockWatcher(this.blockStateStore);
}
}