-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathfacade.ts
More file actions
70 lines (58 loc) · 2.17 KB
/
facade.ts
File metadata and controls
70 lines (58 loc) · 2.17 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
import * as wasm from '../wasm.js';
import type { EvoSDK } from '../sdk.js';
export class DocumentsFacade {
private sdk: EvoSDK;
constructor(sdk: EvoSDK) {
this.sdk = sdk;
}
// Query many documents
async query(query: wasm.DocumentsQuery): Promise<Map<string, wasm.Document | undefined>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDocuments(query);
}
async queryWithProof(
query: wasm.DocumentsQuery,
): Promise<wasm.ProofMetadataResponseTyped<
Map<string, wasm.Document | undefined>
>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDocumentsWithProofInfo(query);
}
async get(contractId: wasm.IdentifierLike, type: string, documentId: wasm.IdentifierLike):
Promise<wasm.Document | undefined> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDocument(contractId, type, documentId);
}
async getWithProof(
contractId: wasm.IdentifierLike,
type: string,
documentId: wasm.IdentifierLike,
): Promise<wasm.ProofMetadataResponseTyped<wasm.Document | undefined>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDocumentWithProofInfo(contractId, type, documentId);
}
async create(options: wasm.DocumentCreateOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentCreate(options);
}
async replace(options: wasm.DocumentReplaceOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentReplace(options);
}
async delete(options: wasm.DocumentDeleteOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentDelete(options);
}
async transfer(options: wasm.DocumentTransferOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentTransfer(options);
}
async purchase(options: wasm.DocumentPurchaseOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentPurchase(options);
}
async setPrice(options: wasm.DocumentSetPriceOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentSetPrice(options);
}
}