@opaquecash/stellar 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -0
- package/dist/crypto/index.cjs +2854 -0
- package/dist/crypto/index.cjs.map +1 -0
- package/dist/crypto/index.d.cts +345 -0
- package/dist/crypto/index.d.ts +345 -0
- package/dist/crypto/index.js +2784 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/index-Cy3ABCai.d.cts +520 -0
- package/dist/index-Dqr8RiOd.d.ts +520 -0
- package/dist/index.cjs +5146 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +822 -0
- package/dist/index.d.ts +822 -0
- package/dist/index.js +4989 -0
- package/dist/index.js.map +1 -0
- package/dist/notes-CTR_oi8Y.d.cts +56 -0
- package/dist/notes-CTR_oi8Y.d.ts +56 -0
- package/dist/relayer-protocol/index.cjs +455 -0
- package/dist/relayer-protocol/index.cjs.map +1 -0
- package/dist/relayer-protocol/index.d.cts +3 -0
- package/dist/relayer-protocol/index.d.ts +3 -0
- package/dist/relayer-protocol/index.js +431 -0
- package/dist/relayer-protocol/index.js.map +1 -0
- package/package.json +106 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
import { GhostEntryLike, Hex, StealthAnnouncement, ScanMatch } from './crypto/index.cjs';
|
|
2
|
+
export { AttestationDataError, DomainSeparationOpts, EncryptedGhostPayload, FieldDef, FieldType, LEGACY_SETUP_MESSAGE, MAX_ATTESTATION_DATA_LEN, MAX_FIELDS, MAX_FIELD_NAME_LEN, MAX_STRING_VALUE_LEN, MemoRisk, MemoType, MemoValidationResult, Network, PaymentLink, PaymentLinkError, PaymentLinkParams, SchemaParseError, addressToAuthorityBytes, bigIntToBytes32, buildDomainSeparatedMessage, buildGhostAnnouncementPayload, bytesToBigInt, bytesToHex, checkViewTagMatch, computeSchemaId, computeSchemaIdFromBytes, computeStealthAddressAndViewTag, concatBytes, convertLegacyLink, createPaymentLink, decodeAttestationData, decodePaymentLink, decryptGhostEntries, deriveAnnouncerEphemeralKey, deriveKeysFromSignature, deriveStealthStellarAddress, deriveStealthStellarAddressFromStealthPrivKey, deriveStealthStellarKeypair, deriveStealthStellarKeypairFromStealthPrivKey, encodeAttestationData, encodeCanonicalFieldDefs, encodePaymentLink, encryptGhostEntries, exportEncryptedBackup, fieldDefsToCanonicalString, formatStroopsToXlm, formatXlm, hexToBytes, importEncryptedBackup, isOpaquePaymentLink, isValidAmount, isValidAssetCode, isValidIso8601, isValidMetaAddress, isValidNetwork, isValidStellarPublicKey, isValidUrl, keysToStealthMetaAddress, memoRiskFor, memoWarningCopy, parseFieldDefinitions, parseHorizonBalanceToStroops, parseStealthMetaAddress, parseXlmToStroops, recipientSharedSecretHash, reconstructStealthPrivateKey, scanAnnouncements, stealthIdFromPrivateKey, stealthMetaAddressToHex, toHex32, validateMemo } from './crypto/index.cjs';
|
|
3
|
+
import { P as PoolNote } from './notes-CTR_oi8Y.cjs';
|
|
4
|
+
export { B as BN254_R, D as DerivedDeposit, a as POOL_TREE_DEPTH, d as deriveDeposit, g as getPoseidon, h as hashFields, n as newNoteSecrets, r as randomFieldElement, u as unspentTotal } from './notes-CTR_oi8Y.cjs';
|
|
5
|
+
import { C as ContractInvoker, O as OpaqueSigner, A as ArtifactResolver, G as Groth16ProofLike, R as ResolvedConfig, P as PoolWithdrawProof, a as RelayerJobDraft, b as PoolWithdrawPayload, V as VerifiedBid, c as RelayerBid, d as RelayerJobStatus, e as OpaqueConfig, L as Logger, T as Telemetry, f as RpcClient } from './index-Cy3ABCai.cjs';
|
|
6
|
+
export { g as ArtifactId, h as ArtifactKind, i as ContractAddresses, j as ContractCallEvent, D as DEFAULT_ARTIFACT_PATHS, k as DEPLOYMENTS, E as EncryptedPayload, I as InvokeOptions, J as JobAdvert, N as NETWORK_PRESETS, l as NEW_ACCOUNT_MIN_RESERVE_STROOPS, m as NetworkDeployment, n as NetworkPreset, o as OpaqueNetwork, p as PoolMerkleTree, q as PoolWiring, r as RELAY_CHAIN_STELLAR, s as RELAY_PAYLOAD_DOMAIN, t as ReadOptions, u as RelayerGateway, v as RelayerMessage, w as RelayerWiring, x as RpcClientOptions, S as ScannerSyncEvent, y as SerializablePoolWithdrawPayload, z as SerializedProof, B as SignTxFn, F as SignerContext, H as TESTNET_DEPLOYMENT, X as X25519Keypair, K as bidSigningDigest, M as buildRelayedWithdrawPayload, Q as buildRelayerJobDraft, U as callbackSigner, W as computeWithdrawContext, Y as consoleLogger, Z as decodePoolWithdrawPayload, _ as encodePoolWithdrawPayload, $ as fileArtifactResolver, a0 as generateX25519Keypair, a1 as hashPoolWithdrawPayload, a2 as hashPoolWithdrawPayloadHex, a3 as keypairSigner, a4 as makeAdvert, a5 as makeBid, a6 as noopTelemetry, a7 as openBox, a8 as parsePoolWithdrawPayload, a9 as pickStakeWeightedBid, aa as poolWithdrawPayloadPreimage, ab as provePoolWithdraw, ac as randomJobId, ad as resolveConfig, ae as sealBox, af as serializeGroth16Proof, ag as serializePoolWithdrawPayload, ah as silentLogger, ai as urlArtifactResolver, aj as validateAdvert, ak as validateBid, al as verifyBid } from './index-Cy3ABCai.cjs';
|
|
7
|
+
import { xdr } from '@stellar/stellar-sdk';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Typed error hierarchy for the SDK. Every thrown error carries a stable,
|
|
11
|
+
* machine-readable `code` so callers can branch without string-matching
|
|
12
|
+
* messages. Soroban contract failures map to {@link ContractError} with the
|
|
13
|
+
* decoded contract error code (and a name when the contract's error enum is
|
|
14
|
+
* known to the SDK).
|
|
15
|
+
*/
|
|
16
|
+
declare class OpaqueError extends Error {
|
|
17
|
+
/** Stable, machine-readable error code (e.g. "CONFIG", "CONTRACT"). */
|
|
18
|
+
readonly code: string;
|
|
19
|
+
constructor(message: string, code: string, options?: {
|
|
20
|
+
cause?: unknown;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Configuration is missing or invalid (e.g. mainnet without RPC URLs). */
|
|
24
|
+
declare class ConfigError extends OpaqueError {
|
|
25
|
+
constructor(message: string, options?: {
|
|
26
|
+
cause?: unknown;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/** A signer adapter failed to produce a signature. */
|
|
30
|
+
declare class SignerError extends OpaqueError {
|
|
31
|
+
constructor(message: string, options?: {
|
|
32
|
+
cause?: unknown;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** An RPC or Horizon request failed (network, timeout, or HTTP status). */
|
|
36
|
+
declare class RpcError extends OpaqueError {
|
|
37
|
+
readonly httpStatus?: number;
|
|
38
|
+
constructor(message: string, options?: {
|
|
39
|
+
httpStatus?: number;
|
|
40
|
+
cause?: unknown;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** A transaction failed during pre-flight simulation. */
|
|
44
|
+
declare class SimulationError extends OpaqueError {
|
|
45
|
+
readonly diagnostics?: string;
|
|
46
|
+
constructor(message: string, options?: {
|
|
47
|
+
diagnostics?: string;
|
|
48
|
+
cause?: unknown;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** A Soroban contract invocation reverted with a contract error code. */
|
|
52
|
+
declare class ContractError extends OpaqueError {
|
|
53
|
+
readonly contract: string;
|
|
54
|
+
readonly contractCode: number;
|
|
55
|
+
/** Human-readable name when the contract's error enum is known. */
|
|
56
|
+
readonly errorName?: string;
|
|
57
|
+
constructor(opts: {
|
|
58
|
+
contract: string;
|
|
59
|
+
contractCode: number;
|
|
60
|
+
errorName?: string;
|
|
61
|
+
message?: string;
|
|
62
|
+
cause?: unknown;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** The published reputation/pool root is unavailable or not yet indexed. */
|
|
66
|
+
declare class RootUnavailableError extends OpaqueError {
|
|
67
|
+
constructor(message: string, options?: {
|
|
68
|
+
cause?: unknown;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** A circuit artifact failed to resolve or failed its integrity check. */
|
|
72
|
+
declare class ArtifactError extends OpaqueError {
|
|
73
|
+
constructor(message: string, options?: {
|
|
74
|
+
cause?: unknown;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A capability that depends on a layer not yet wired in this build (e.g. the
|
|
79
|
+
* proving layer, the WASM scanner, or the relayer gateway client). Thrown so the
|
|
80
|
+
* surface is discoverable and the failure is explicit rather than silent.
|
|
81
|
+
*/
|
|
82
|
+
declare class NotWiredError extends OpaqueError {
|
|
83
|
+
constructor(capability: string, hint?: string);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Known contract error enums, keyed by contract package name. Populated as the
|
|
87
|
+
* SDK binds each contract; an unknown code still surfaces as a numeric
|
|
88
|
+
* {@link ContractError}. Source of truth is each contract's `#[contracterror]`.
|
|
89
|
+
*/
|
|
90
|
+
declare const CONTRACT_ERROR_NAMES: Record<string, Record<number, string>>;
|
|
91
|
+
/** Look up a contract error name for a code, if the SDK knows the enum. */
|
|
92
|
+
declare function contractErrorName(contractPackage: string, code: number): string | undefined;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* ScVal conversion helpers for building Soroban contract-call arguments.
|
|
96
|
+
* Thin, typed wrappers over `@stellar/stellar-sdk` so callers never hand-roll
|
|
97
|
+
* `nativeToScVal` type tags.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/** Stellar address (G/C-strkey) -> ScVal address. */
|
|
101
|
+
declare function addressToScVal(addr: string): xdr.ScVal;
|
|
102
|
+
/** Raw bytes -> ScVal bytes. */
|
|
103
|
+
declare function bytesToScVal(bytes: Uint8Array): xdr.ScVal;
|
|
104
|
+
/** Number/bigint -> ScVal u32. */
|
|
105
|
+
declare function u32ToScVal(n: number): xdr.ScVal;
|
|
106
|
+
/** Number/bigint -> ScVal u64. */
|
|
107
|
+
declare function u64ToScVal(n: bigint | number): xdr.ScVal;
|
|
108
|
+
/** Bigint -> ScVal i128 (Soroban's signed amount type). */
|
|
109
|
+
declare function i128ToScVal(n: bigint): xdr.ScVal;
|
|
110
|
+
/** Bigint -> ScVal u128. */
|
|
111
|
+
declare function u128ToScVal(n: bigint): xdr.ScVal;
|
|
112
|
+
/** String -> ScVal symbol. */
|
|
113
|
+
declare function symbolToScVal(s: string): xdr.ScVal;
|
|
114
|
+
/** String -> ScVal string. */
|
|
115
|
+
declare function stringToScVal(s: string): xdr.ScVal;
|
|
116
|
+
/** Boolean -> ScVal bool. */
|
|
117
|
+
declare function boolToScVal(b: boolean): xdr.ScVal;
|
|
118
|
+
/** Optional address -> ScVal address, or a void ScVal when null/undefined. */
|
|
119
|
+
declare function optionAddressToScVal(addr: string | null | undefined): xdr.ScVal;
|
|
120
|
+
/** Decode an ScVal into its native JS representation. */
|
|
121
|
+
declare function fromScVal(v: xdr.ScVal): unknown;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Decode Soroban diagnostic events and ScErrors from a failed transaction into
|
|
125
|
+
* short, human-readable strings, and extract a contract error code when present.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/** Render an ScError into a short token like `ContractError#4` or `sceBudget`. */
|
|
129
|
+
declare function describeScError(e: xdr.ScError): string;
|
|
130
|
+
/**
|
|
131
|
+
* Decode an array of diagnostic events (XDR) into a compact, de-duplicated
|
|
132
|
+
* string. Bounded to keep error messages readable.
|
|
133
|
+
*/
|
|
134
|
+
declare function decodeDiagnostics(events: unknown[]): string;
|
|
135
|
+
/**
|
|
136
|
+
* Best-effort extraction of a contract error code from diagnostic events.
|
|
137
|
+
* Returns the first `ContractError#N` code found, or null.
|
|
138
|
+
*/
|
|
139
|
+
declare function extractContractErrorCode(events: unknown[]): number | null;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Bindings for the stealth-registry and stealth-announcer contracts: publish a
|
|
143
|
+
* meta-address and announce a one-time stealth transfer.
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
/** secp256k1 stealth scheme id, as registered on-chain. */
|
|
147
|
+
declare const SCHEME_ID_SECP256K1 = 1n;
|
|
148
|
+
declare class StealthRegistry {
|
|
149
|
+
private readonly rpc;
|
|
150
|
+
readonly contractId: string;
|
|
151
|
+
constructor(rpc: ContractInvoker, contractId: string);
|
|
152
|
+
/** Register a stealth meta-address for the signer's account. */
|
|
153
|
+
registerKeys(opts: {
|
|
154
|
+
stealthMetaAddress: Uint8Array;
|
|
155
|
+
schemeId?: bigint;
|
|
156
|
+
signer: OpaqueSigner;
|
|
157
|
+
}): Promise<string>;
|
|
158
|
+
}
|
|
159
|
+
declare class StealthAnnouncer {
|
|
160
|
+
private readonly rpc;
|
|
161
|
+
readonly contractId: string;
|
|
162
|
+
constructor(rpc: ContractInvoker, contractId: string);
|
|
163
|
+
/** Announce a one-time stealth transfer (stealth id + ephemeral key + view tag). */
|
|
164
|
+
announce(opts: {
|
|
165
|
+
stealthAddress: Uint8Array;
|
|
166
|
+
ephemeralPubKey: Uint8Array;
|
|
167
|
+
metadata: Uint8Array;
|
|
168
|
+
schemeId?: bigint;
|
|
169
|
+
signer: OpaqueSigner;
|
|
170
|
+
}): Promise<string>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
declare class SchemaRegistry {
|
|
174
|
+
private readonly rpc;
|
|
175
|
+
readonly contractId: string;
|
|
176
|
+
constructor(rpc: ContractInvoker, contractId: string);
|
|
177
|
+
/** Register a schema. The signer is the schema authority. */
|
|
178
|
+
registerSchema(opts: {
|
|
179
|
+
schemaId: Uint8Array;
|
|
180
|
+
name: string;
|
|
181
|
+
fieldDefinitions: string;
|
|
182
|
+
revocable: boolean;
|
|
183
|
+
version?: number;
|
|
184
|
+
resolver?: string | null;
|
|
185
|
+
schemaExpiryLedger: number;
|
|
186
|
+
signer: OpaqueSigner;
|
|
187
|
+
}): Promise<string>;
|
|
188
|
+
deprecateSchema(opts: {
|
|
189
|
+
schemaId: Uint8Array;
|
|
190
|
+
signer: OpaqueSigner;
|
|
191
|
+
}): Promise<string>;
|
|
192
|
+
addDelegate(opts: {
|
|
193
|
+
schemaId: Uint8Array;
|
|
194
|
+
delegate: string;
|
|
195
|
+
signer: OpaqueSigner;
|
|
196
|
+
}): Promise<string>;
|
|
197
|
+
removeDelegate(opts: {
|
|
198
|
+
schemaId: Uint8Array;
|
|
199
|
+
delegate: string;
|
|
200
|
+
signer: OpaqueSigner;
|
|
201
|
+
}): Promise<string>;
|
|
202
|
+
private assertDelegate;
|
|
203
|
+
}
|
|
204
|
+
declare class AttestationEngine {
|
|
205
|
+
private readonly rpc;
|
|
206
|
+
readonly contractId: string;
|
|
207
|
+
constructor(rpc: ContractInvoker, contractId: string);
|
|
208
|
+
/** Attest to a stealth identity under a schema. The signer is the issuer. */
|
|
209
|
+
attest(opts: {
|
|
210
|
+
schemaId: Uint8Array;
|
|
211
|
+
stealthAddressHash: Uint8Array;
|
|
212
|
+
data: Uint8Array;
|
|
213
|
+
expirationLedger: number;
|
|
214
|
+
refUid: Uint8Array;
|
|
215
|
+
signer: OpaqueSigner;
|
|
216
|
+
}): Promise<string>;
|
|
217
|
+
revokeAttestation(opts: {
|
|
218
|
+
uid: Uint8Array;
|
|
219
|
+
signer: OpaqueSigner;
|
|
220
|
+
}): Promise<string>;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
interface VerifyProofV2Inputs {
|
|
224
|
+
proofA: Uint8Array;
|
|
225
|
+
proofB: Uint8Array;
|
|
226
|
+
proofC: Uint8Array;
|
|
227
|
+
merkleRoot: Uint8Array;
|
|
228
|
+
attestationId: Uint8Array;
|
|
229
|
+
externalNullifier: Uint8Array;
|
|
230
|
+
nullifierHash: Uint8Array;
|
|
231
|
+
}
|
|
232
|
+
declare class Groth16Verifier {
|
|
233
|
+
private readonly rpc;
|
|
234
|
+
readonly contractId: string;
|
|
235
|
+
constructor(rpc: ContractInvoker, contractId: string);
|
|
236
|
+
/** Submit a Groth16 V2 proof. The public signals are passed as an ScMap. */
|
|
237
|
+
verifyProofV2(opts: VerifyProofV2Inputs & {
|
|
238
|
+
signer: OpaqueSigner;
|
|
239
|
+
}): Promise<string>;
|
|
240
|
+
}
|
|
241
|
+
interface VerifyReputationInputs {
|
|
242
|
+
proofA: Uint8Array;
|
|
243
|
+
proofB: Uint8Array;
|
|
244
|
+
proofC: Uint8Array;
|
|
245
|
+
merkleRoot: Uint8Array;
|
|
246
|
+
attestationId: Uint8Array;
|
|
247
|
+
externalNullifier: bigint;
|
|
248
|
+
nullifierHash: Uint8Array;
|
|
249
|
+
expirationLedger?: number;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* High-level reputation-verifier binding. `verify_reputation` enforces root
|
|
253
|
+
* validity + nullifier-replay protection and calls the groth16-verifier; this is
|
|
254
|
+
* the on-chain entry point for proving reputation (vs. the lower-level
|
|
255
|
+
* {@link Groth16Verifier}).
|
|
256
|
+
*/
|
|
257
|
+
declare class ReputationVerifier {
|
|
258
|
+
private readonly rpc;
|
|
259
|
+
readonly contractId: string;
|
|
260
|
+
constructor(rpc: ContractInvoker, contractId: string);
|
|
261
|
+
/** Submit a V2 reputation proof for on-chain verification. */
|
|
262
|
+
verifyReputation(opts: VerifyReputationInputs & {
|
|
263
|
+
groth16VerifierId: string;
|
|
264
|
+
signer: OpaqueSigner;
|
|
265
|
+
}): Promise<string>;
|
|
266
|
+
/** Read the latest published reputation Merkle root (bytes), or null if none. */
|
|
267
|
+
getLatestRoot(source: string): Promise<Uint8Array | null>;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
interface PoolWithdrawInputs {
|
|
271
|
+
proofA: Uint8Array;
|
|
272
|
+
proofB: Uint8Array;
|
|
273
|
+
proofC: Uint8Array;
|
|
274
|
+
withdrawnValue: bigint;
|
|
275
|
+
stateRoot: Uint8Array;
|
|
276
|
+
aspRoot: Uint8Array;
|
|
277
|
+
nullifierHash: Uint8Array;
|
|
278
|
+
newCommitment: Uint8Array;
|
|
279
|
+
recipient: string;
|
|
280
|
+
fee: bigint;
|
|
281
|
+
relayer: string;
|
|
282
|
+
}
|
|
283
|
+
declare class PrivacyPool {
|
|
284
|
+
private readonly rpc;
|
|
285
|
+
readonly contractId: string;
|
|
286
|
+
constructor(rpc: ContractInvoker, contractId: string);
|
|
287
|
+
/** Deposit `value` stroops under a precomputed commitment at `expectedIndex`. */
|
|
288
|
+
deposit(opts: {
|
|
289
|
+
value: bigint;
|
|
290
|
+
commitment: Uint8Array;
|
|
291
|
+
expectedIndex: number;
|
|
292
|
+
signer: OpaqueSigner;
|
|
293
|
+
}): Promise<string>;
|
|
294
|
+
/** Withdraw to `recipient` (minus `fee` to `relayer`) with a v3 proof. */
|
|
295
|
+
withdraw(opts: PoolWithdrawInputs & {
|
|
296
|
+
signer: OpaqueSigner;
|
|
297
|
+
}): Promise<string>;
|
|
298
|
+
/** Publish a tree root (admin only). `kind` selects the state vs ASP root. */
|
|
299
|
+
updateRoot(opts: {
|
|
300
|
+
kind: "state" | "asp";
|
|
301
|
+
root: Uint8Array;
|
|
302
|
+
datasetHash: Uint8Array;
|
|
303
|
+
signer: OpaqueSigner;
|
|
304
|
+
}): Promise<string>;
|
|
305
|
+
/** Read the next deposit leaf index (the value `deposit` will assign). */
|
|
306
|
+
getDepositCount(source: string): Promise<number>;
|
|
307
|
+
/** Read the latest published state (or ASP) root, or null if none. */
|
|
308
|
+
getLatestRoot(opts: {
|
|
309
|
+
source: string;
|
|
310
|
+
kind: "state" | "asp";
|
|
311
|
+
}): Promise<Uint8Array | null>;
|
|
312
|
+
/**
|
|
313
|
+
* Reconstruct the pool's commitment leaves from on-chain events. Returns the
|
|
314
|
+
* commitment at each state-tree index (`stateLeaves`, deposits + withdrawal
|
|
315
|
+
* remainders) and the state index of each deposit in event order
|
|
316
|
+
* (`depositIndices`, == ASP-tree order). Feed these into the withdrawal prover.
|
|
317
|
+
*/
|
|
318
|
+
reconstructState(opts?: {
|
|
319
|
+
startLedger?: number;
|
|
320
|
+
}): Promise<{
|
|
321
|
+
stateLeaves: bigint[];
|
|
322
|
+
depositIndices: number[];
|
|
323
|
+
}>;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Binding for the relayer-registry contract job lifecycle the wallet drives:
|
|
328
|
+
* create a blind withdrawal job (escrow fee), cancel it, or slash an
|
|
329
|
+
* accepted-but-unsubmitted job after the deadline. Relayer-side methods
|
|
330
|
+
* (register, accept, submit) live in the relayer node.
|
|
331
|
+
*/
|
|
332
|
+
|
|
333
|
+
declare class RelayerRegistry {
|
|
334
|
+
private readonly rpc;
|
|
335
|
+
readonly contractId: string;
|
|
336
|
+
constructor(rpc: ContractInvoker, contractId: string);
|
|
337
|
+
/** Create a blind job with an escrowed fee and a payload hash + deadline. */
|
|
338
|
+
createJob(opts: {
|
|
339
|
+
jobId: Uint8Array;
|
|
340
|
+
payloadHash: Uint8Array;
|
|
341
|
+
deadlineLedger: number;
|
|
342
|
+
fee: bigint;
|
|
343
|
+
signer: OpaqueSigner;
|
|
344
|
+
}): Promise<string>;
|
|
345
|
+
/** Cancel a never-accepted job after its deadline; refunds the escrow fee. */
|
|
346
|
+
cancelJob(opts: {
|
|
347
|
+
jobId: Uint8Array;
|
|
348
|
+
signer: OpaqueSigner;
|
|
349
|
+
}): Promise<string>;
|
|
350
|
+
/** Slash an accepted-but-unsubmitted job after its deadline. */
|
|
351
|
+
slashJob(opts: {
|
|
352
|
+
jobId: Uint8Array;
|
|
353
|
+
signer: OpaqueSigner;
|
|
354
|
+
}): Promise<string>;
|
|
355
|
+
private jobAction;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Storage abstractions. The SDK never imports a state container (no zustand, no
|
|
360
|
+
* IndexedDB): pool notes, ghost entries, and scan cursors persist through these
|
|
361
|
+
* interfaces. In-memory defaults are provided; a host app plugs its own
|
|
362
|
+
* (zustand/IndexedDB in the browser, fs/sqlite on a server).
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
/** Persistence for privacy-pool notes (spending material). */
|
|
366
|
+
interface NoteStore {
|
|
367
|
+
list(): Promise<PoolNote[]>;
|
|
368
|
+
add(note: PoolNote): Promise<void>;
|
|
369
|
+
/** Mark the note with this commitment as spent. */
|
|
370
|
+
markSpent(commitment: string): Promise<void>;
|
|
371
|
+
}
|
|
372
|
+
/** Persistence for stealth "ghost" entries (ephemeral keys + metadata). */
|
|
373
|
+
interface VaultStore {
|
|
374
|
+
listGhosts(): Promise<GhostEntryLike[]>;
|
|
375
|
+
saveGhost(entry: GhostEntryLike): Promise<void>;
|
|
376
|
+
}
|
|
377
|
+
/** Persistence for the announcement-scan cursor (last processed ledger). */
|
|
378
|
+
interface ScanStore {
|
|
379
|
+
getCursor(): Promise<number | null>;
|
|
380
|
+
setCursor(ledger: number): Promise<void>;
|
|
381
|
+
}
|
|
382
|
+
/** In-memory {@link NoteStore}. Notes are keyed by commitment. */
|
|
383
|
+
declare class MemoryNoteStore implements NoteStore {
|
|
384
|
+
private notes;
|
|
385
|
+
list(): Promise<PoolNote[]>;
|
|
386
|
+
add(note: PoolNote): Promise<void>;
|
|
387
|
+
markSpent(commitment: string): Promise<void>;
|
|
388
|
+
}
|
|
389
|
+
/** In-memory {@link VaultStore}. Ghost entries are keyed by stealth address. */
|
|
390
|
+
declare class MemoryVaultStore implements VaultStore {
|
|
391
|
+
private entries;
|
|
392
|
+
listGhosts(): Promise<GhostEntryLike[]>;
|
|
393
|
+
saveGhost(entry: GhostEntryLike): Promise<void>;
|
|
394
|
+
}
|
|
395
|
+
/** In-memory {@link ScanStore}. */
|
|
396
|
+
declare class MemoryScanStore implements ScanStore {
|
|
397
|
+
private cursor;
|
|
398
|
+
getCursor(): Promise<number | null>;
|
|
399
|
+
setCursor(ledger: number): Promise<void>;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Typed interface to the Rust/WASM DKSAP scanner. The scanner does the
|
|
404
|
+
* performance-critical view-tag filtering, stealth-key reconstruction, and
|
|
405
|
+
* reputation-witness generation. The binary ships with the package and is loaded
|
|
406
|
+
* lazily by an environment-specific {@link ScannerLoader} (browser instantiates
|
|
407
|
+
* via `WebAssembly`, Node reads the file); both resolve to this interface.
|
|
408
|
+
*
|
|
409
|
+
* Pure-TS equivalents for the simplest operations live in `crypto/dksap`
|
|
410
|
+
* (`checkViewTagMatch`, `reconstructStealthPrivateKey`) for environments that
|
|
411
|
+
* cannot load WASM.
|
|
412
|
+
*/
|
|
413
|
+
interface ScannerModule {
|
|
414
|
+
derive_stealth_address_wasm(viewPrivkeyBytes: Uint8Array, spendPubkeyBytes: Uint8Array, ephemeralPubkeyBytes: Uint8Array): {
|
|
415
|
+
stealthAddress: string;
|
|
416
|
+
viewTag: number;
|
|
417
|
+
};
|
|
418
|
+
check_announcement_view_tag_wasm(viewTag: number, viewPrivkeyBytes: Uint8Array, ephemeralPubkeyBytes: Uint8Array): string;
|
|
419
|
+
reconstruct_signing_key_wasm(masterSpendPrivBytes: Uint8Array, masterViewPrivBytes: Uint8Array, ephemeralPubkeyBytes: Uint8Array): Uint8Array;
|
|
420
|
+
scan_attestations_wasm(announcementsJson: string, viewPrivkeyBytes: Uint8Array, spendPubkeyBytes: Uint8Array): string;
|
|
421
|
+
scan_attestations_v2_wasm(announcementsJson: string, schemasJson: string, viewPrivkeyBytes: Uint8Array, spendPubkeyBytes: Uint8Array, currentSlot: bigint, trustedIssuersJson: string): string;
|
|
422
|
+
generate_reputation_witness(attestationsJson: string, targetTraitId: string, stealthPrivkeyBytes: Uint8Array, externalNullifier: string): string;
|
|
423
|
+
encode_attestation_metadata_wasm(viewTag: number, attestationId: bigint): string;
|
|
424
|
+
}
|
|
425
|
+
/** Lazily load and instantiate the scanner module. */
|
|
426
|
+
type ScannerLoader = () => Promise<ScannerModule>;
|
|
427
|
+
|
|
428
|
+
interface ReputationProveInput {
|
|
429
|
+
/** Attestation id (== schema id) of the trait being proven. */
|
|
430
|
+
attestationId: number;
|
|
431
|
+
/** The holder's stealth private key bytes. */
|
|
432
|
+
stealthPrivKey: Uint8Array;
|
|
433
|
+
/** Application-chosen external nullifier (must fit in u64 for the contract). */
|
|
434
|
+
externalNullifier: bigint;
|
|
435
|
+
}
|
|
436
|
+
interface ReputationWitnessV2 {
|
|
437
|
+
stealth_pk: string;
|
|
438
|
+
schema_id: string;
|
|
439
|
+
issuer_pk_x: string;
|
|
440
|
+
trait_data_hash: string;
|
|
441
|
+
nonce: string;
|
|
442
|
+
merkle_path: string[];
|
|
443
|
+
merkle_path_indices: number[];
|
|
444
|
+
merkle_root: string;
|
|
445
|
+
attestation_id: string;
|
|
446
|
+
external_nullifier: string;
|
|
447
|
+
nullifier_hash: string;
|
|
448
|
+
}
|
|
449
|
+
/** Build the canonical V2 reputation witness for a holder's own attestation. */
|
|
450
|
+
declare function buildReputationWitnessV2(input: ReputationProveInput): Promise<ReputationWitnessV2>;
|
|
451
|
+
interface SnarkjsLike {
|
|
452
|
+
groth16: {
|
|
453
|
+
fullProve(input: Record<string, unknown>, wasm: string | Uint8Array, zkey: string | Uint8Array): Promise<{
|
|
454
|
+
proof: Groth16ProofLike;
|
|
455
|
+
publicSignals: string[];
|
|
456
|
+
}>;
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
interface ReputationProof extends VerifyReputationInputs {
|
|
460
|
+
publicSignals: string[];
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Generate a V2 reputation proof and return a bundle ready for
|
|
464
|
+
* `reputation.verifyOnChain` / the reputation-verifier contract.
|
|
465
|
+
*/
|
|
466
|
+
declare function proveReputationV2(opts: {
|
|
467
|
+
input: ReputationProveInput;
|
|
468
|
+
artifacts: ArtifactResolver;
|
|
469
|
+
snarkjs?: SnarkjsLike;
|
|
470
|
+
}): Promise<ReputationProof>;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* The capability surface the services depend on. {@link OpaqueClient} implements
|
|
474
|
+
* it; services depend on this interface (not the client class) so they stay
|
|
475
|
+
* decoupled and unit-testable with a lightweight stub context.
|
|
476
|
+
*/
|
|
477
|
+
|
|
478
|
+
interface ContractBindings {
|
|
479
|
+
stealthRegistry: StealthRegistry;
|
|
480
|
+
stealthAnnouncer: StealthAnnouncer;
|
|
481
|
+
schemaRegistry: SchemaRegistry;
|
|
482
|
+
attestationEngine: AttestationEngine;
|
|
483
|
+
groth16Verifier: Groth16Verifier;
|
|
484
|
+
reputationVerifier: ReputationVerifier;
|
|
485
|
+
privacyPool: PrivacyPool;
|
|
486
|
+
relayerRegistry: RelayerRegistry;
|
|
487
|
+
}
|
|
488
|
+
interface OpaqueClientContext {
|
|
489
|
+
readonly config: ResolvedConfig;
|
|
490
|
+
readonly rpc: ContractInvoker;
|
|
491
|
+
readonly contracts: ContractBindings;
|
|
492
|
+
readonly notes: NoteStore;
|
|
493
|
+
readonly vault: VaultStore;
|
|
494
|
+
readonly scanStore: ScanStore;
|
|
495
|
+
readonly signer?: OpaqueSigner;
|
|
496
|
+
/** Circuit artifact resolver, when proof generation is enabled. */
|
|
497
|
+
readonly artifacts?: ArtifactResolver;
|
|
498
|
+
/** Returns the configured signer or throws if none is set. */
|
|
499
|
+
requireSigner(): OpaqueSigner;
|
|
500
|
+
/** Send a native XLM transfer (create-account or payment) via Horizon. */
|
|
501
|
+
sendNativeTransfer(opts: {
|
|
502
|
+
destination: string;
|
|
503
|
+
amountStroops: bigint;
|
|
504
|
+
signer: OpaqueSigner;
|
|
505
|
+
}): Promise<string>;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
declare class SchemasService {
|
|
509
|
+
private readonly ctx;
|
|
510
|
+
constructor(ctx: OpaqueClientContext);
|
|
511
|
+
/** Register a schema. The signer is the authority; returns the schema id. */
|
|
512
|
+
register(opts: {
|
|
513
|
+
name: string;
|
|
514
|
+
fieldDefinitions: string;
|
|
515
|
+
revocable: boolean;
|
|
516
|
+
version?: number;
|
|
517
|
+
resolver?: string | null;
|
|
518
|
+
schemaExpiryLedger: number;
|
|
519
|
+
}): Promise<{
|
|
520
|
+
schemaId: Uint8Array;
|
|
521
|
+
txHash: string;
|
|
522
|
+
}>;
|
|
523
|
+
/** Attest to a stealth identity under a schema. The signer is the issuer. */
|
|
524
|
+
attest(opts: {
|
|
525
|
+
schemaId: Uint8Array;
|
|
526
|
+
stealthAddressHash: Uint8Array;
|
|
527
|
+
fieldValues: Record<string, string>;
|
|
528
|
+
fieldDefinitions: string;
|
|
529
|
+
expirationLedger: number;
|
|
530
|
+
refUid?: Uint8Array;
|
|
531
|
+
}): Promise<string>;
|
|
532
|
+
revoke(opts: {
|
|
533
|
+
uid: Uint8Array;
|
|
534
|
+
}): Promise<string>;
|
|
535
|
+
deprecate(opts: {
|
|
536
|
+
schemaId: Uint8Array;
|
|
537
|
+
}): Promise<string>;
|
|
538
|
+
addDelegate(opts: {
|
|
539
|
+
schemaId: Uint8Array;
|
|
540
|
+
delegate: string;
|
|
541
|
+
}): Promise<string>;
|
|
542
|
+
removeDelegate(opts: {
|
|
543
|
+
schemaId: Uint8Array;
|
|
544
|
+
delegate: string;
|
|
545
|
+
}): Promise<string>;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Stealth private payments. Derive an identity and meta-address, register it,
|
|
550
|
+
* send a stealth XLM payment (one-time account + announcement), and sweep a
|
|
551
|
+
* detected stealth account. Announcement scanning needs the WASM scanner and is
|
|
552
|
+
* surfaced as a not-wired capability in this build (use the crypto primitives
|
|
553
|
+
* `checkViewTagMatch` / `reconstructStealthPrivateKey` with your own event feed).
|
|
554
|
+
*/
|
|
555
|
+
|
|
556
|
+
interface StealthIdentity {
|
|
557
|
+
viewingKey: Uint8Array;
|
|
558
|
+
spendingKey: Uint8Array;
|
|
559
|
+
metaAddress: Uint8Array;
|
|
560
|
+
metaHex: Hex;
|
|
561
|
+
}
|
|
562
|
+
declare class PaymentsService {
|
|
563
|
+
private readonly ctx;
|
|
564
|
+
constructor(ctx: OpaqueClientContext);
|
|
565
|
+
/** Derive viewing/spending keys + meta-address from a wallet signature. */
|
|
566
|
+
deriveIdentity(signatureHex: string): StealthIdentity;
|
|
567
|
+
/** Register a stealth meta-address for the signer's account. */
|
|
568
|
+
register(opts: {
|
|
569
|
+
metaAddress: Uint8Array;
|
|
570
|
+
}): Promise<string>;
|
|
571
|
+
/** Pure: compute a one-time stealth address + announcement params for a recipient. */
|
|
572
|
+
prepareTransfer(recipientMetaHex: string): {
|
|
573
|
+
ephemeralPriv: Uint8Array;
|
|
574
|
+
ephemeralPubKey: Uint8Array;
|
|
575
|
+
stealthAddress: string;
|
|
576
|
+
stealthStellarAddress: string;
|
|
577
|
+
viewTag: number;
|
|
578
|
+
metadata: Uint8Array;
|
|
579
|
+
};
|
|
580
|
+
/**
|
|
581
|
+
* Send a stealth XLM payment: pay the one-time stealth Stellar account, then
|
|
582
|
+
* publish the announcement so the recipient can detect and sweep it.
|
|
583
|
+
*/
|
|
584
|
+
send(opts: {
|
|
585
|
+
to: string;
|
|
586
|
+
amountXlm: string;
|
|
587
|
+
}): Promise<{
|
|
588
|
+
stealthStellarAddress: string;
|
|
589
|
+
ephemeralPubKey: Uint8Array;
|
|
590
|
+
paymentTxHash: string;
|
|
591
|
+
announceTxHash: string;
|
|
592
|
+
}>;
|
|
593
|
+
/**
|
|
594
|
+
* Sweep a detected stealth account to a destination. The stealth account signs
|
|
595
|
+
* itself (derived from the one-time key), so the connected wallet is never the
|
|
596
|
+
* source. `amountStroops` is the exact amount to move (compute the spendable
|
|
597
|
+
* balance from Horizon, reserving fee + minimum balance).
|
|
598
|
+
*/
|
|
599
|
+
sweep(opts: {
|
|
600
|
+
stealthPrivKey: Uint8Array;
|
|
601
|
+
destination: string;
|
|
602
|
+
amountStroops: bigint;
|
|
603
|
+
}): Promise<string>;
|
|
604
|
+
/**
|
|
605
|
+
* Scan announcements for transfers addressed to `identity`, returning each
|
|
606
|
+
* match with its reconstructed one-time key and Stellar account. The caller
|
|
607
|
+
* supplies the announcements (read from the stealth-announcer contract events).
|
|
608
|
+
*/
|
|
609
|
+
scan(opts: {
|
|
610
|
+
announcements: StealthAnnouncement[];
|
|
611
|
+
identity: Pick<StealthIdentity, "viewingKey" | "spendingKey">;
|
|
612
|
+
}): ScanMatch[];
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
declare class ReputationService {
|
|
616
|
+
private readonly ctx;
|
|
617
|
+
private readonly schemas;
|
|
618
|
+
constructor(ctx: OpaqueClientContext, schemas: SchemasService);
|
|
619
|
+
/** Attest a reputation trait to a stealth identity (delegates to schemas). */
|
|
620
|
+
attest(opts: Parameters<SchemasService["attest"]>[0]): Promise<string>;
|
|
621
|
+
/** Submit a precomputed V2 reputation proof for on-chain verification. */
|
|
622
|
+
verifyOnChain(opts: VerifyReputationInputs): Promise<string>;
|
|
623
|
+
/** Read the latest published reputation Merkle root, or null if none. */
|
|
624
|
+
getLatestRoot(opts?: {
|
|
625
|
+
source?: string;
|
|
626
|
+
}): Promise<Uint8Array | null>;
|
|
627
|
+
/**
|
|
628
|
+
* Generate a V2 reputation proof. Requires an artifact resolver
|
|
629
|
+
* (`new OpaqueClient({ artifacts })`); otherwise throws {@link NotWiredError}.
|
|
630
|
+
*/
|
|
631
|
+
prove(input: ReputationProveInput): Promise<ReputationProof>;
|
|
632
|
+
/** Generate a proof and submit it on-chain in one call. Returns the tx hash. */
|
|
633
|
+
proveAndVerify(input: ReputationProveInput): Promise<string>;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Privacy pool. Deposit (derive a note's commitment and persist the note),
|
|
638
|
+
* withdraw with a precomputed proof, and read pool state (deposit count, roots).
|
|
639
|
+
* Withdrawal proof *generation* needs the proving layer (snarkjs + circuit
|
|
640
|
+
* artifacts) and is surfaced as a not-wired capability in this build: bring a
|
|
641
|
+
* precomputed proof bundle to withdraw().
|
|
642
|
+
*/
|
|
643
|
+
|
|
644
|
+
/** A withdrawal proof bundle (everything except the public recipient/fee/relayer). */
|
|
645
|
+
type WithdrawProofBundle = PoolWithdrawProof;
|
|
646
|
+
declare class PoolService {
|
|
647
|
+
private readonly ctx;
|
|
648
|
+
constructor(ctx: OpaqueClientContext);
|
|
649
|
+
private source;
|
|
650
|
+
/**
|
|
651
|
+
* Deposit `amountXlm` into the pool. Reads the next leaf index, derives the
|
|
652
|
+
* commitment from fresh (or provided) secrets, submits, and persists the note.
|
|
653
|
+
*/
|
|
654
|
+
deposit(opts: {
|
|
655
|
+
amountXlm: string;
|
|
656
|
+
secrets?: {
|
|
657
|
+
nullifier: string;
|
|
658
|
+
secret: string;
|
|
659
|
+
};
|
|
660
|
+
createdAt?: number;
|
|
661
|
+
}): Promise<{
|
|
662
|
+
note: PoolNote;
|
|
663
|
+
txHash: string;
|
|
664
|
+
}>;
|
|
665
|
+
/** Withdraw using a precomputed proof bundle. Marks the note spent on success. */
|
|
666
|
+
withdraw(opts: {
|
|
667
|
+
proof: WithdrawProofBundle;
|
|
668
|
+
recipient: string;
|
|
669
|
+
fee?: bigint;
|
|
670
|
+
relayer?: string;
|
|
671
|
+
/** Note commitment to mark spent once the withdrawal lands. */
|
|
672
|
+
noteCommitment?: string;
|
|
673
|
+
}): Promise<string>;
|
|
674
|
+
/** Read the next deposit leaf index. */
|
|
675
|
+
getDepositCount(opts?: {
|
|
676
|
+
source?: string;
|
|
677
|
+
}): Promise<number>;
|
|
678
|
+
/** Read the latest published state and ASP roots (or null when unpublished). */
|
|
679
|
+
getRoots(opts?: {
|
|
680
|
+
source?: string;
|
|
681
|
+
}): Promise<{
|
|
682
|
+
state: Uint8Array | null;
|
|
683
|
+
asp: Uint8Array | null;
|
|
684
|
+
}>;
|
|
685
|
+
/**
|
|
686
|
+
* Generate a full-withdrawal proof for a note. Requires an artifact resolver
|
|
687
|
+
* (`new OpaqueClient({ artifacts })`). The pool leaves are reconstructed from
|
|
688
|
+
* on-chain Deposit/Withdraw events automatically; pass `stateLeaves` +
|
|
689
|
+
* `depositIndices` to skip the on-chain read (e.g. in tests).
|
|
690
|
+
*/
|
|
691
|
+
proveWithdraw(opts: {
|
|
692
|
+
note: PoolNote;
|
|
693
|
+
recipient: string;
|
|
694
|
+
relayer?: string;
|
|
695
|
+
fee?: bigint;
|
|
696
|
+
scope?: number;
|
|
697
|
+
stateLeaves?: bigint[];
|
|
698
|
+
depositIndices?: number[];
|
|
699
|
+
}): Promise<PoolWithdrawProof>;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Relayer market: the wallet-side withdrawal flow. Build a blind withdrawal
|
|
704
|
+
* payload from a pool proof, create the on-chain escrow job, advertise it,
|
|
705
|
+
* collect and verify bids, pick a relayer, and deliver the encrypted payload.
|
|
706
|
+
*/
|
|
707
|
+
|
|
708
|
+
declare class RelayerService {
|
|
709
|
+
private readonly ctx;
|
|
710
|
+
constructor(ctx: OpaqueClientContext);
|
|
711
|
+
private gateway;
|
|
712
|
+
/** Create a blind withdrawal job (escrows the fee on-chain). */
|
|
713
|
+
createJob(opts: {
|
|
714
|
+
jobId: Uint8Array;
|
|
715
|
+
payloadHash: Uint8Array;
|
|
716
|
+
deadlineLedger: number;
|
|
717
|
+
fee: bigint;
|
|
718
|
+
}): Promise<string>;
|
|
719
|
+
/** Create the on-chain job for a built draft. */
|
|
720
|
+
createJobForDraft(draft: RelayerJobDraft): Promise<string>;
|
|
721
|
+
/** Cancel a never-accepted job after its deadline (refunds the escrow fee). */
|
|
722
|
+
cancelJob(opts: {
|
|
723
|
+
jobId: Uint8Array;
|
|
724
|
+
}): Promise<string>;
|
|
725
|
+
/** Slash an accepted-but-unsubmitted job after its deadline. */
|
|
726
|
+
slashJob(opts: {
|
|
727
|
+
jobId: Uint8Array;
|
|
728
|
+
}): Promise<string>;
|
|
729
|
+
/** Build the blind withdrawal payload from a pool proof. */
|
|
730
|
+
buildWithdrawPayload(opts: {
|
|
731
|
+
proof: PoolWithdrawProof;
|
|
732
|
+
recipient: string;
|
|
733
|
+
}): PoolWithdrawPayload;
|
|
734
|
+
/** Build a job draft (job id, payload hash, advert) from a payload. */
|
|
735
|
+
buildJobDraft(opts: {
|
|
736
|
+
payload: PoolWithdrawPayload;
|
|
737
|
+
fee: bigint;
|
|
738
|
+
deadlineLedger: number;
|
|
739
|
+
jobId?: Uint8Array;
|
|
740
|
+
}): RelayerJobDraft;
|
|
741
|
+
/** A deadline `ledgers` ahead of the current ledger. */
|
|
742
|
+
deadlineLedger(ledgers?: number): Promise<number>;
|
|
743
|
+
/** Advertise a job to the gateway. */
|
|
744
|
+
advertise(draft: RelayerJobDraft): Promise<void>;
|
|
745
|
+
/** Fetch and verify bids for a job (signature + on-chain registry state). */
|
|
746
|
+
fetchBids(jobIdHex: string): Promise<VerifiedBid[]>;
|
|
747
|
+
/** Stake-weighted random choice among verified bids. */
|
|
748
|
+
pickBid(bids: VerifiedBid[]): VerifiedBid | null;
|
|
749
|
+
/** Encrypt the payload to the chosen relayer and deliver it to the gateway. */
|
|
750
|
+
deliverPayload(args: {
|
|
751
|
+
draft: RelayerJobDraft;
|
|
752
|
+
bid: RelayerBid;
|
|
753
|
+
}): Promise<{
|
|
754
|
+
acceptedTx?: string;
|
|
755
|
+
submittedTx?: string;
|
|
756
|
+
} | null>;
|
|
757
|
+
/** Read a job's on-chain status. */
|
|
758
|
+
jobStatus(jobIdHex: string, source?: string): Promise<RelayerJobStatus>;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* The high-level entry point. One config + one signer wires the resolved network,
|
|
763
|
+
* RPC client, contract bindings, storage, and the domain services
|
|
764
|
+
* (`payments`, `pool`, `reputation`, `schemas`, `relayer`). Low-level escape
|
|
765
|
+
* hatches (`rpc`, `contracts`, `soroban`) are exposed for advanced use.
|
|
766
|
+
*/
|
|
767
|
+
|
|
768
|
+
interface OpaqueClientOptions extends OpaqueConfig {
|
|
769
|
+
signer?: OpaqueSigner;
|
|
770
|
+
storage?: {
|
|
771
|
+
notes?: NoteStore;
|
|
772
|
+
vault?: VaultStore;
|
|
773
|
+
scan?: ScanStore;
|
|
774
|
+
};
|
|
775
|
+
logger?: Logger;
|
|
776
|
+
telemetry?: Telemetry;
|
|
777
|
+
/** Circuit artifact resolver; enables proof generation when provided. */
|
|
778
|
+
artifacts?: ArtifactResolver;
|
|
779
|
+
/** Advanced / testing: inject a custom invoker instead of the built-in RpcClient. */
|
|
780
|
+
invoker?: ContractInvoker;
|
|
781
|
+
}
|
|
782
|
+
declare class OpaqueClient implements OpaqueClientContext {
|
|
783
|
+
readonly config: ResolvedConfig;
|
|
784
|
+
readonly rpc: ContractInvoker;
|
|
785
|
+
readonly contracts: ContractBindings;
|
|
786
|
+
readonly notes: NoteStore;
|
|
787
|
+
readonly vault: VaultStore;
|
|
788
|
+
readonly scanStore: ScanStore;
|
|
789
|
+
readonly signer?: OpaqueSigner;
|
|
790
|
+
readonly artifacts?: ArtifactResolver;
|
|
791
|
+
readonly payments: PaymentsService;
|
|
792
|
+
readonly pool: PoolService;
|
|
793
|
+
readonly reputation: ReputationService;
|
|
794
|
+
readonly schemas: SchemasService;
|
|
795
|
+
readonly relayer: RelayerService;
|
|
796
|
+
private readonly rpcClient?;
|
|
797
|
+
constructor(opts: OpaqueClientOptions);
|
|
798
|
+
/** The built-in Soroban/Horizon client, or undefined when a custom invoker was injected. */
|
|
799
|
+
get soroban(): RpcClient | undefined;
|
|
800
|
+
/** Returns the configured signer or throws if none was set. */
|
|
801
|
+
requireSigner(): OpaqueSigner;
|
|
802
|
+
/** Send a native XLM transfer through the built-in RpcClient. */
|
|
803
|
+
sendNativeTransfer(opts: {
|
|
804
|
+
destination: string;
|
|
805
|
+
amountStroops: bigint;
|
|
806
|
+
signer: OpaqueSigner;
|
|
807
|
+
}): Promise<string>;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* `@opaquecash/stellar` — stealth private payments, privacy pools, relayer-market
|
|
812
|
+
* submission, and on-chain ZK reputation for Stellar / Soroban.
|
|
813
|
+
*
|
|
814
|
+
* The high-level `OpaqueClient` and chain services are layered on top of the
|
|
815
|
+
* isomorphic crypto primitives re-exported here. Until the chain layer lands,
|
|
816
|
+
* the crypto surface is the stable, published entry point. Import a narrower
|
|
817
|
+
* surface via subpaths (e.g. `@opaquecash/stellar/crypto`) for the smallest
|
|
818
|
+
* bundle.
|
|
819
|
+
*/
|
|
820
|
+
declare const VERSION = "0.1.0";
|
|
821
|
+
|
|
822
|
+
export { ArtifactError, ArtifactResolver, AttestationEngine, CONTRACT_ERROR_NAMES, ConfigError, type ContractBindings, ContractError, ContractInvoker, GhostEntryLike, Groth16ProofLike, Groth16Verifier, Hex, Logger, MemoryNoteStore, MemoryScanStore, MemoryVaultStore, NotWiredError, type NoteStore, OpaqueClient, type OpaqueClientContext, type OpaqueClientOptions, OpaqueConfig, OpaqueError, OpaqueSigner, PaymentsService, PoolNote, PoolService, type PoolWithdrawInputs, PoolWithdrawPayload, PoolWithdrawProof, PrivacyPool, RelayerBid, RelayerJobDraft, RelayerJobStatus, RelayerRegistry, RelayerService, type ReputationProof, type ReputationProveInput, ReputationService, ReputationVerifier, type ReputationWitnessV2, ResolvedConfig, RootUnavailableError, RpcClient, RpcError, SCHEME_ID_SECP256K1, ScanMatch, type ScanStore, type ScannerLoader, type ScannerModule, SchemaRegistry, SchemasService, SignerError, SimulationError, StealthAnnouncement, StealthAnnouncer, type StealthIdentity, StealthRegistry, Telemetry, VERSION, type VaultStore, VerifiedBid, type VerifyProofV2Inputs, type VerifyReputationInputs, type WithdrawProofBundle, addressToScVal, boolToScVal, buildReputationWitnessV2, bytesToScVal, contractErrorName, decodeDiagnostics, describeScError, extractContractErrorCode, fromScVal, i128ToScVal, optionAddressToScVal, proveReputationV2, stringToScVal, symbolToScVal, u128ToScVal, u32ToScVal, u64ToScVal };
|