-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathfacade.ts
More file actions
57 lines (47 loc) · 1.87 KB
/
Copy pathfacade.ts
File metadata and controls
57 lines (47 loc) · 1.87 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
import * as wasm from '../wasm.js';
import type { EvoSDK } from '../sdk.js';
export class ContractsFacade {
private sdk: EvoSDK;
constructor(sdk: EvoSDK) {
this.sdk = sdk;
}
async fetch(contractId: wasm.IdentifierLike): Promise<wasm.DataContract | undefined> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContract(contractId);
}
async fetchWithProof(contractId: wasm.IdentifierLike):
Promise<wasm.ProofMetadataResponseTyped<wasm.DataContract>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContractWithProofInfo(contractId);
}
async getHistory(query: wasm.DataContractHistoryQuery): Promise<Map<bigint, wasm.DataContract>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContractHistory(query);
}
async getHistoryWithProof(
query: wasm.DataContractHistoryQuery,
): Promise<wasm.ProofMetadataResponseTyped<Map<bigint, wasm.DataContract>>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContractHistoryWithProofInfo(query);
}
async getMany(contractIds: wasm.IdentifierLikeArray): Promise<Map<string, wasm.DataContract | undefined>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContracts(contractIds);
}
async getManyWithProof(
contractIds: wasm.IdentifierLikeArray,
): Promise<wasm.ProofMetadataResponseTyped<
Map<string, wasm.DataContract | undefined>
>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContractsWithProofInfo(contractIds);
}
async publish(options: wasm.ContractPublishOptions): Promise<wasm.DataContract> {
const w = await this.sdk.getWasmSdkConnected();
return w.contractPublish(options);
}
async update(options: wasm.ContractUpdateOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.contractUpdate(options);
}
}