-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathfacade.ts
More file actions
73 lines (63 loc) · 2.57 KB
/
facade.ts
File metadata and controls
73 lines (63 loc) · 2.57 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import * as wasm from '../wasm.js';
import type { EvoSDK } from '../sdk.js';
import type {
EpochsQuery,
FinalizedEpochsQuery,
EvonodeProposedBlocksRangeQuery,
} from '../wasm.js';
export class EpochFacade {
private sdk: EvoSDK;
constructor(sdk: EvoSDK) { this.sdk = sdk; }
async epochsInfo(query: EpochsQuery = {}): Promise<Map<number, wasm.ExtendedEpochInfo | undefined>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getEpochsInfo(query);
}
async epochsInfoWithProof(
query: EpochsQuery = {},
): Promise<wasm.ProofMetadataResponseTyped<
Map<number, wasm.ExtendedEpochInfo | undefined>
>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getEpochsInfoWithProofInfo(query);
}
async finalizedInfos(query: FinalizedEpochsQuery): Promise<Map<number, wasm.FinalizedEpochInfo | undefined>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getFinalizedEpochInfos(query);
}
async finalizedInfosWithProof(
query: FinalizedEpochsQuery,
): Promise<wasm.ProofMetadataResponseTyped<
Map<number, wasm.FinalizedEpochInfo | undefined>
>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getFinalizedEpochInfosWithProofInfo(query);
}
async current(): Promise<wasm.ExtendedEpochInfo> {
const w = await this.sdk.getWasmSdkConnected();
return w.getCurrentEpoch();
}
async currentWithProof(): Promise<wasm.ProofMetadataResponseTyped<wasm.ExtendedEpochInfo>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getCurrentEpochWithProofInfo();
}
async evonodesProposedBlocksByIds(epoch: number, ids: wasm.ProTxHashLikeArray):
Promise<Map<string, bigint>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getEvonodesProposedEpochBlocksByIds(epoch, ids);
}
async evonodesProposedBlocksByIdsWithProof(epoch: number, ids: wasm.ProTxHashLikeArray):
Promise<wasm.ProofMetadataResponseTyped<Map<string, bigint>>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getEvonodesProposedEpochBlocksByIdsWithProofInfo(epoch, ids);
}
async evonodesProposedBlocksByRange(query: EvonodeProposedBlocksRangeQuery): Promise<Map<string, bigint>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getEvonodesProposedEpochBlocksByRange(query);
}
async evonodesProposedBlocksByRangeWithProof(
query: EvonodeProposedBlocksRangeQuery,
): Promise<wasm.ProofMetadataResponseTyped<Map<string, bigint>>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getEvonodesProposedEpochBlocksByRangeWithProofInfo(query);
}
}