-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathfacade.ts
More file actions
86 lines (70 loc) · 3.44 KB
/
Copy pathfacade.ts
File metadata and controls
86 lines (70 loc) · 3.44 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
74
75
76
77
78
79
80
81
82
83
84
85
86
import * as wasm from '../wasm.js';
import type { EvoSDK } from '../sdk.js';
/**
* Read-only access to the shielded (Orchard) pool: total balance, encrypted
* notes, anchors, nullifier statuses. Each query has a `*WithProof` variant
* that additionally returns proof + metadata for cryptographic verification.
*
* Building / signing / broadcasting shielded transitions is intentionally
* out of scope here — that requires the Orchard prover and is tracked
* separately. See PR #3235 for the deferral rationale.
*/
export class ShieldedFacade {
private sdk: EvoSDK;
constructor(sdk: EvoSDK) {
this.sdk = sdk;
}
// ── Pool state ────────────────────────────────────────────────────────
async poolState(): Promise<bigint | undefined> {
const w = await this.sdk.getWasmSdkConnected();
return w.getShieldedPoolState();
}
async poolStateWithProof(): Promise<wasm.ProofMetadataResponseTyped<bigint | null>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getShieldedPoolStateWithProofInfo();
}
// ── Encrypted notes ──────────────────────────────────────────────────
async encryptedNotes(startIndex: bigint, count: number): Promise<wasm.ShieldedEncryptedNote[]> {
const w = await this.sdk.getWasmSdkConnected();
return w.getShieldedEncryptedNotes(startIndex, count);
}
async encryptedNotesWithProof(
startIndex: bigint,
count: number,
): Promise<wasm.ProofMetadataResponseTyped<wasm.ShieldedEncryptedNote[]>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getShieldedEncryptedNotesWithProofInfo(startIndex, count);
}
// ── Anchors ──────────────────────────────────────────────────────────
async anchors(): Promise<Uint8Array[]> {
const w = await this.sdk.getWasmSdkConnected();
return w.getShieldedAnchors();
}
async anchorsWithProof(): Promise<wasm.ProofMetadataResponseTyped<Uint8Array[]>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getShieldedAnchorsWithProofInfo();
}
async mostRecentAnchor(): Promise<Uint8Array | undefined> {
const w = await this.sdk.getWasmSdkConnected();
return w.getMostRecentShieldedAnchor();
}
async mostRecentAnchorWithProof(): Promise<wasm.ProofMetadataResponseTyped<Uint8Array | null>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getMostRecentShieldedAnchorWithProofInfo();
}
// ── Nullifiers ───────────────────────────────────────────────────────
/**
* Each nullifier must be a `Uint8Array` of exactly 32 bytes; otherwise
* the underlying call rejects with `InvalidArgument`.
*/
async nullifiers(nullifiers: Uint8Array[]): Promise<wasm.ShieldedNullifierStatus[]> {
const w = await this.sdk.getWasmSdkConnected();
return w.getShieldedNullifiers(nullifiers);
}
async nullifiersWithProof(
nullifiers: Uint8Array[],
): Promise<wasm.ProofMetadataResponseTyped<wasm.ShieldedNullifierStatus[]>> {
const w = await this.sdk.getWasmSdkConnected();
return w.getShieldedNullifiersWithProofInfo(nullifiers);
}
}