@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
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
import { Keypair, xdr, rpc, Horizon } from '@stellar/stellar-sdk';
|
|
2
|
+
import { h as hashFields, P as PoolNote } from './notes-CTR_oi8Y.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Stellar network presets: passphrase and default RPC / Horizon endpoints per
|
|
6
|
+
* network. Mainnet ships with no default endpoints — callers must supply
|
|
7
|
+
* production providers explicitly.
|
|
8
|
+
*/
|
|
9
|
+
type OpaqueNetwork = "testnet" | "mainnet" | "futurenet" | "local";
|
|
10
|
+
interface NetworkPreset {
|
|
11
|
+
passphrase: string;
|
|
12
|
+
rpcUrls: string[];
|
|
13
|
+
horizonUrls: string[];
|
|
14
|
+
}
|
|
15
|
+
declare const NETWORK_PRESETS: Record<OpaqueNetwork, NetworkPreset>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Per-network on-chain address book.
|
|
19
|
+
*
|
|
20
|
+
* These constants mirror `deployments/v1/<network>.json` in the repo and are the
|
|
21
|
+
* SDK's baked-in defaults. They are intended to be regenerated by a codegen step
|
|
22
|
+
* in CI so a redeploy updates the SDK with a single command. Callers may override
|
|
23
|
+
* any address through {@link OpaqueConfig}.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
interface ContractAddresses {
|
|
27
|
+
stealthRegistry: string;
|
|
28
|
+
stealthAnnouncer: string;
|
|
29
|
+
groth16Verifier: string;
|
|
30
|
+
reputationVerifier: string;
|
|
31
|
+
schemaRegistry: string;
|
|
32
|
+
attestationEngineV2: string;
|
|
33
|
+
poolVerifier: string;
|
|
34
|
+
privacyPool: string;
|
|
35
|
+
relayerRegistry: string;
|
|
36
|
+
}
|
|
37
|
+
interface PoolWiring {
|
|
38
|
+
/** Domain separator bound into pool commitments. */
|
|
39
|
+
scope: number;
|
|
40
|
+
/** Native XLM Stellar Asset Contract id backing the pool. */
|
|
41
|
+
nativeSac: string;
|
|
42
|
+
}
|
|
43
|
+
interface RelayerWiring {
|
|
44
|
+
minimumStake: bigint;
|
|
45
|
+
unstakeCooldownLedgers: number;
|
|
46
|
+
maxDeadlineLedgers: number;
|
|
47
|
+
gatewayUrls: string[];
|
|
48
|
+
}
|
|
49
|
+
interface NetworkDeployment {
|
|
50
|
+
contracts: ContractAddresses;
|
|
51
|
+
pool: PoolWiring;
|
|
52
|
+
relayer: RelayerWiring;
|
|
53
|
+
/** Ledger the contracts were deployed at; event scans start here. */
|
|
54
|
+
deploymentLedger: number;
|
|
55
|
+
}
|
|
56
|
+
/** Generated from deployments/v1/testnet.json. */
|
|
57
|
+
declare const TESTNET_DEPLOYMENT: NetworkDeployment;
|
|
58
|
+
/** Known deployments by network. Testnet is the only live deployment today. */
|
|
59
|
+
declare const DEPLOYMENTS: Partial<Record<OpaqueNetwork, NetworkDeployment>>;
|
|
60
|
+
|
|
61
|
+
interface OpaqueConfig {
|
|
62
|
+
/** Target Stellar network. */
|
|
63
|
+
network: OpaqueNetwork;
|
|
64
|
+
/** Override Soroban RPC endpoints (defaults to the network preset). */
|
|
65
|
+
rpcUrls?: string[];
|
|
66
|
+
/** Override Horizon endpoints (defaults to the network preset). */
|
|
67
|
+
horizonUrls?: string[];
|
|
68
|
+
/** Override individual contract addresses (defaults to the baked deployment). */
|
|
69
|
+
contracts?: Partial<ContractAddresses>;
|
|
70
|
+
/** Override relayer-market gateway endpoints. */
|
|
71
|
+
relayerGatewayUrls?: string[];
|
|
72
|
+
/** Base URL of a reputation-root publisher service, if used. */
|
|
73
|
+
reputationPublisherUrl?: string;
|
|
74
|
+
/** Override the ledger event scans start from (defaults to deployment ledger). */
|
|
75
|
+
startLedger?: number;
|
|
76
|
+
}
|
|
77
|
+
interface ResolvedConfig {
|
|
78
|
+
network: OpaqueNetwork;
|
|
79
|
+
passphrase: string;
|
|
80
|
+
rpcUrls: string[];
|
|
81
|
+
horizonUrls: string[];
|
|
82
|
+
contracts: ContractAddresses;
|
|
83
|
+
pool: PoolWiring;
|
|
84
|
+
relayer: RelayerWiring;
|
|
85
|
+
relayerGatewayUrls: string[];
|
|
86
|
+
reputationPublisherUrl?: string;
|
|
87
|
+
startLedger: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolve user config into a complete, validated configuration: network preset +
|
|
91
|
+
* baked deployment + explicit overrides. Throws {@link ConfigError} when a
|
|
92
|
+
* required endpoint or contract address is missing (e.g. mainnet usage).
|
|
93
|
+
*/
|
|
94
|
+
declare function resolveConfig(config: OpaqueConfig): ResolvedConfig;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Signer abstraction. The SDK never holds or asks for a private key directly: it
|
|
98
|
+
* hands a transaction XDR to an {@link OpaqueSigner} and gets a signed XDR back.
|
|
99
|
+
* This unifies browser wallets (Freighter), raw server keypairs, and any custom
|
|
100
|
+
* signing backend behind one interface.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
interface SignerContext {
|
|
104
|
+
/** Network passphrase the transaction is bound to. */
|
|
105
|
+
networkPassphrase: string;
|
|
106
|
+
}
|
|
107
|
+
/** Low-level callback form: sign a transaction XDR, return the signed XDR. */
|
|
108
|
+
type SignTxFn = (xdr: string) => Promise<string>;
|
|
109
|
+
interface OpaqueSigner {
|
|
110
|
+
/** Stellar public key (G-address) this signer controls. */
|
|
111
|
+
publicKey(): string | Promise<string>;
|
|
112
|
+
/** Sign a base64 transaction XDR and return the signed base64 XDR. */
|
|
113
|
+
signTransaction(xdr: string, ctx: SignerContext): Promise<string>;
|
|
114
|
+
/** Optional: sign an arbitrary message (used for one-time key derivation). */
|
|
115
|
+
signMessage?(message: string): Promise<string>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Build a signer from a raw Ed25519 keypair (server / non-browser use). Accepts a
|
|
119
|
+
* Stellar secret seed (`S...`) or a `Keypair` instance.
|
|
120
|
+
*/
|
|
121
|
+
declare function keypairSigner(secretOrKeypair: string | Keypair): OpaqueSigner;
|
|
122
|
+
/**
|
|
123
|
+
* Build a signer from caller-supplied callbacks. Use this to adapt Freighter or
|
|
124
|
+
* any external signing service.
|
|
125
|
+
*/
|
|
126
|
+
declare function callbackSigner(opts: {
|
|
127
|
+
publicKey: string | (() => string | Promise<string>);
|
|
128
|
+
signTransaction: SignTxFn;
|
|
129
|
+
signMessage?: (message: string) => Promise<string>;
|
|
130
|
+
}): OpaqueSigner;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Pluggable logger. The SDK logs nothing by default (no `console.log` noise in a
|
|
134
|
+
* library); a host app can pass {@link consoleLogger} or its own implementation.
|
|
135
|
+
*/
|
|
136
|
+
interface Logger {
|
|
137
|
+
debug(...args: unknown[]): void;
|
|
138
|
+
info(...args: unknown[]): void;
|
|
139
|
+
warn(...args: unknown[]): void;
|
|
140
|
+
error(...args: unknown[]): void;
|
|
141
|
+
}
|
|
142
|
+
/** Default logger: discards everything. */
|
|
143
|
+
declare const silentLogger: Logger;
|
|
144
|
+
/** Logger that forwards to the global `console`. */
|
|
145
|
+
declare const consoleLogger: Logger;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Pluggable telemetry hooks. The SDK emits structured events at meaningful
|
|
149
|
+
* points (contract calls, scans) so a host app can wire its own metrics without
|
|
150
|
+
* the SDK depending on any monitoring library. All hooks are optional; the
|
|
151
|
+
* default is a no-op.
|
|
152
|
+
*/
|
|
153
|
+
interface ContractCallEvent {
|
|
154
|
+
contractId: string;
|
|
155
|
+
method: string;
|
|
156
|
+
success: boolean;
|
|
157
|
+
durationMs: number;
|
|
158
|
+
error?: string;
|
|
159
|
+
}
|
|
160
|
+
interface ScannerSyncEvent {
|
|
161
|
+
fromLedger: number;
|
|
162
|
+
toLedger: number;
|
|
163
|
+
}
|
|
164
|
+
interface Telemetry {
|
|
165
|
+
onContractCall?(event: ContractCallEvent): void;
|
|
166
|
+
onScannerSync?(event: ScannerSyncEvent): void;
|
|
167
|
+
}
|
|
168
|
+
/** Default telemetry: records nothing. */
|
|
169
|
+
declare const noopTelemetry: Telemetry;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Soroban RPC client. Holds resolved config, a signer, and observability hooks,
|
|
173
|
+
* and exposes contract `invoke` (write) and `read` (read-only simulate) with
|
|
174
|
+
* multi-endpoint read fallback, bounded polling, typed errors, and decoded
|
|
175
|
+
* diagnostics. No ambient globals: everything comes from {@link ResolvedConfig}.
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/** Minimum starting balance (stroops) to create a fresh Stellar account (1 XLM). */
|
|
179
|
+
declare const NEW_ACCOUNT_MIN_RESERVE_STROOPS = 10000000n;
|
|
180
|
+
interface RpcClientOptions {
|
|
181
|
+
config: ResolvedConfig;
|
|
182
|
+
logger?: Logger;
|
|
183
|
+
telemetry?: Telemetry;
|
|
184
|
+
}
|
|
185
|
+
interface InvokeOptions {
|
|
186
|
+
source: string;
|
|
187
|
+
contractId: string;
|
|
188
|
+
method: string;
|
|
189
|
+
args: xdr.ScVal[];
|
|
190
|
+
signer: OpaqueSigner;
|
|
191
|
+
/** Skip pre-flight simulation (default false). */
|
|
192
|
+
skipSimulation?: boolean;
|
|
193
|
+
/** Contract package name for error naming (e.g. "reputation-verifier"). */
|
|
194
|
+
contractPackage?: string;
|
|
195
|
+
}
|
|
196
|
+
interface ReadOptions {
|
|
197
|
+
source: string;
|
|
198
|
+
contractId: string;
|
|
199
|
+
method: string;
|
|
200
|
+
args: xdr.ScVal[];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The subset of {@link RpcClient} the contract bindings depend on. Bindings are
|
|
204
|
+
* written against this interface so they can be unit-tested with a stub invoker
|
|
205
|
+
* (no network) and dogfooded with the real client in production.
|
|
206
|
+
*/
|
|
207
|
+
interface ContractInvoker {
|
|
208
|
+
invoke(opts: InvokeOptions): Promise<string>;
|
|
209
|
+
readNative<T = unknown>(opts: ReadOptions): Promise<T>;
|
|
210
|
+
simulateRead(opts: ReadOptions): Promise<xdr.ScVal | undefined>;
|
|
211
|
+
getEvents(request: rpc.Server.GetEventsRequest): Promise<rpc.Api.GetEventsResponse>;
|
|
212
|
+
getLatestLedger(): Promise<number>;
|
|
213
|
+
}
|
|
214
|
+
declare class RpcClient {
|
|
215
|
+
readonly config: ResolvedConfig;
|
|
216
|
+
private readonly logger;
|
|
217
|
+
private readonly telemetry;
|
|
218
|
+
private readonly servers;
|
|
219
|
+
constructor(opts: RpcClientOptions);
|
|
220
|
+
/** Primary Soroban RPC server. */
|
|
221
|
+
get server(): rpc.Server;
|
|
222
|
+
/** Horizon server (first configured Horizon URL). */
|
|
223
|
+
horizon(): Horizon.Server;
|
|
224
|
+
/** Whether an account exists on-ledger. */
|
|
225
|
+
accountExists(publicKey: string): Promise<boolean>;
|
|
226
|
+
/**
|
|
227
|
+
* Send a native XLM transfer. Uses `createAccount` when the destination does
|
|
228
|
+
* not exist yet (stealth accounts), otherwise a `payment`. Signs via the
|
|
229
|
+
* provided signer and submits through Horizon.
|
|
230
|
+
*/
|
|
231
|
+
sendNativeTransfer(opts: {
|
|
232
|
+
destination: string;
|
|
233
|
+
amountStroops: bigint;
|
|
234
|
+
signer: OpaqueSigner;
|
|
235
|
+
}): Promise<string>;
|
|
236
|
+
/** Run a read across providers with retry + timeout; throws RpcError on exhaustion. */
|
|
237
|
+
private read;
|
|
238
|
+
private poll;
|
|
239
|
+
/** Fetch contract events (paged) with read fallback. */
|
|
240
|
+
getEvents(request: rpc.Server.GetEventsRequest): Promise<rpc.Api.GetEventsResponse>;
|
|
241
|
+
/** Latest ledger sequence. */
|
|
242
|
+
getLatestLedger(): Promise<number>;
|
|
243
|
+
/** Read-only contract call via simulation. Returns the decoded return ScVal. */
|
|
244
|
+
simulateRead(opts: ReadOptions): Promise<xdr.ScVal | undefined>;
|
|
245
|
+
/** Read-only contract call returning the native-decoded value. */
|
|
246
|
+
readNative<T = unknown>(opts: ReadOptions): Promise<T>;
|
|
247
|
+
/** Invoke a contract method as a signed transaction. Returns the tx hash. */
|
|
248
|
+
invoke(opts: InvokeOptions): Promise<string>;
|
|
249
|
+
private toContractError;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
type ArtifactId = "reputation-v2" | "pool-v3";
|
|
253
|
+
type ArtifactKind = "wasm" | "zkey";
|
|
254
|
+
interface ArtifactResolver {
|
|
255
|
+
/** Resolve an artifact to a URL string or its raw bytes. */
|
|
256
|
+
resolve(id: ArtifactId, kind: ArtifactKind): Promise<string | Uint8Array>;
|
|
257
|
+
}
|
|
258
|
+
/** Default relative paths, matching the published circuit release layout. */
|
|
259
|
+
declare const DEFAULT_ARTIFACT_PATHS: Record<ArtifactId, Record<ArtifactKind, string>>;
|
|
260
|
+
/**
|
|
261
|
+
* Build a resolver that maps artifacts to URLs under a base URL. Pass `paths` to
|
|
262
|
+
* override individual artifact locations.
|
|
263
|
+
*/
|
|
264
|
+
declare function urlArtifactResolver(opts: {
|
|
265
|
+
baseUrl: string;
|
|
266
|
+
paths?: Partial<Record<ArtifactId, Partial<Record<ArtifactKind, string>>>>;
|
|
267
|
+
}): ArtifactResolver;
|
|
268
|
+
/**
|
|
269
|
+
* Build a resolver that maps artifacts to local filesystem paths under a base
|
|
270
|
+
* directory. The returned path strings are consumed directly by snarkjs in Node.
|
|
271
|
+
*/
|
|
272
|
+
declare function fileArtifactResolver(opts: {
|
|
273
|
+
baseDir: string;
|
|
274
|
+
paths?: Partial<Record<ArtifactId, Partial<Record<ArtifactKind, string>>>>;
|
|
275
|
+
}): ArtifactResolver;
|
|
276
|
+
|
|
277
|
+
interface Groth16ProofLike {
|
|
278
|
+
pi_a: string[];
|
|
279
|
+
pi_b: string[][];
|
|
280
|
+
pi_c: string[];
|
|
281
|
+
}
|
|
282
|
+
interface SerializedProof {
|
|
283
|
+
a: Uint8Array;
|
|
284
|
+
b: Uint8Array;
|
|
285
|
+
c: Uint8Array;
|
|
286
|
+
}
|
|
287
|
+
declare function serializeGroth16Proof(proof: Groth16ProofLike): SerializedProof;
|
|
288
|
+
|
|
289
|
+
type Poseidon = Parameters<typeof hashFields>[0];
|
|
290
|
+
/** Depth-20 Poseidon Merkle tree, byte-matching the contract / circuit / ASP. */
|
|
291
|
+
declare class PoolMerkleTree {
|
|
292
|
+
private readonly poseidon;
|
|
293
|
+
private readonly leaves;
|
|
294
|
+
private readonly depth;
|
|
295
|
+
private readonly zero;
|
|
296
|
+
constructor(poseidon: Poseidon, leaves: bigint[], depth?: number);
|
|
297
|
+
private rootFrom;
|
|
298
|
+
root(): bigint;
|
|
299
|
+
private node;
|
|
300
|
+
proof(index: number): {
|
|
301
|
+
siblings: bigint[];
|
|
302
|
+
indices: number[];
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Withdrawal context binding:
|
|
307
|
+
* keccak256(recipient_xdr ‖ withdrawn(16) ‖ fee(16) ‖ relayer_xdr ‖ scope(8)) mod r.
|
|
308
|
+
*/
|
|
309
|
+
declare function computeWithdrawContext(opts: {
|
|
310
|
+
recipient: string;
|
|
311
|
+
withdrawn: bigint;
|
|
312
|
+
fee: bigint;
|
|
313
|
+
relayer: string;
|
|
314
|
+
scope: number;
|
|
315
|
+
}): bigint;
|
|
316
|
+
interface PoolWithdrawProof {
|
|
317
|
+
proofA: Uint8Array;
|
|
318
|
+
proofB: Uint8Array;
|
|
319
|
+
proofC: Uint8Array;
|
|
320
|
+
withdrawnValue: bigint;
|
|
321
|
+
stateRoot: Uint8Array;
|
|
322
|
+
aspRoot: Uint8Array;
|
|
323
|
+
nullifierHash: Uint8Array;
|
|
324
|
+
newCommitment: Uint8Array;
|
|
325
|
+
}
|
|
326
|
+
interface SnarkjsLike {
|
|
327
|
+
groth16: {
|
|
328
|
+
fullProve(input: Record<string, unknown>, wasm: string | Uint8Array, zkey: string | Uint8Array): Promise<{
|
|
329
|
+
proof: Groth16ProofLike;
|
|
330
|
+
publicSignals: string[];
|
|
331
|
+
}>;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Generate a full-withdrawal proof for `note`, paying `recipient` (minus `fee` to
|
|
336
|
+
* `relayer`). The caller supplies the reconstructed pool leaves: `stateLeaves`
|
|
337
|
+
* (commitment per state-tree index) and `depositIndices` (state index of each
|
|
338
|
+
* deposit, in ASP-tree order).
|
|
339
|
+
*/
|
|
340
|
+
declare function provePoolWithdraw(opts: {
|
|
341
|
+
note: PoolNote;
|
|
342
|
+
recipient: string;
|
|
343
|
+
relayer: string;
|
|
344
|
+
fee: bigint;
|
|
345
|
+
scope: number;
|
|
346
|
+
stateLeaves: bigint[];
|
|
347
|
+
depositIndices: number[];
|
|
348
|
+
artifacts: ArtifactResolver;
|
|
349
|
+
snarkjs?: SnarkjsLike;
|
|
350
|
+
}): Promise<PoolWithdrawProof>;
|
|
351
|
+
|
|
352
|
+
declare const RELAY_PAYLOAD_DOMAIN = "opaque-stellar-relay-v1";
|
|
353
|
+
declare const RELAY_CHAIN_STELLAR = 3000;
|
|
354
|
+
type PoolWithdrawPayload = {
|
|
355
|
+
poolId: string;
|
|
356
|
+
proofA: Uint8Array;
|
|
357
|
+
proofB: Uint8Array;
|
|
358
|
+
proofC: Uint8Array;
|
|
359
|
+
withdrawnValue: bigint;
|
|
360
|
+
stateRoot: Uint8Array;
|
|
361
|
+
aspRoot: Uint8Array;
|
|
362
|
+
nullifierHash: Uint8Array;
|
|
363
|
+
newCommitment: Uint8Array;
|
|
364
|
+
recipient: string;
|
|
365
|
+
poolFee: bigint;
|
|
366
|
+
poolRelayer: string;
|
|
367
|
+
};
|
|
368
|
+
type SerializablePoolWithdrawPayload = {
|
|
369
|
+
poolId: string;
|
|
370
|
+
proofA: string;
|
|
371
|
+
proofB: string;
|
|
372
|
+
proofC: string;
|
|
373
|
+
withdrawnValue: string;
|
|
374
|
+
stateRoot: string;
|
|
375
|
+
aspRoot: string;
|
|
376
|
+
nullifierHash: string;
|
|
377
|
+
newCommitment: string;
|
|
378
|
+
recipient: string;
|
|
379
|
+
poolFee: string;
|
|
380
|
+
poolRelayer: string;
|
|
381
|
+
};
|
|
382
|
+
declare function poolWithdrawPayloadPreimage(payload: PoolWithdrawPayload): Uint8Array;
|
|
383
|
+
declare function hashPoolWithdrawPayload(payload: PoolWithdrawPayload): Uint8Array;
|
|
384
|
+
declare function hashPoolWithdrawPayloadHex(payload: PoolWithdrawPayload): string;
|
|
385
|
+
declare function serializePoolWithdrawPayload(payload: PoolWithdrawPayload): SerializablePoolWithdrawPayload;
|
|
386
|
+
declare function parsePoolWithdrawPayload(payload: SerializablePoolWithdrawPayload): PoolWithdrawPayload;
|
|
387
|
+
declare function encodePoolWithdrawPayload(payload: PoolWithdrawPayload): Uint8Array;
|
|
388
|
+
declare function decodePoolWithdrawPayload(bytes: Uint8Array): PoolWithdrawPayload;
|
|
389
|
+
|
|
390
|
+
type X25519Keypair = {
|
|
391
|
+
publicKey: Uint8Array;
|
|
392
|
+
secretKey: Uint8Array;
|
|
393
|
+
};
|
|
394
|
+
declare function generateX25519Keypair(seed?: Uint8Array): Promise<X25519Keypair>;
|
|
395
|
+
declare function sealBox(plaintext: Uint8Array, recipientPublicKey: Uint8Array): Promise<string>;
|
|
396
|
+
declare function openBox(box: string, recipientSecretKey: Uint8Array): Promise<Uint8Array>;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* `opaque/jobs/v1` wire messages: advert, bid, encrypted payload. Bids are
|
|
400
|
+
* Ed25519-signed by the relayer operator over a domain-separated digest so the
|
|
401
|
+
* SDK can verify them before trusting registry state.
|
|
402
|
+
*/
|
|
403
|
+
|
|
404
|
+
type JobAdvert = {
|
|
405
|
+
t: "advert";
|
|
406
|
+
v: 1;
|
|
407
|
+
jobId: string;
|
|
408
|
+
chain: number;
|
|
409
|
+
fee: string;
|
|
410
|
+
deadline: number;
|
|
411
|
+
payloadHash: string;
|
|
412
|
+
};
|
|
413
|
+
type RelayerBid = {
|
|
414
|
+
t: "bid";
|
|
415
|
+
v: 1;
|
|
416
|
+
jobId: string;
|
|
417
|
+
chain: number;
|
|
418
|
+
operator: string;
|
|
419
|
+
x25519Pk: string;
|
|
420
|
+
sig: string;
|
|
421
|
+
endpoint?: string;
|
|
422
|
+
freeStake?: string;
|
|
423
|
+
};
|
|
424
|
+
type EncryptedPayload = {
|
|
425
|
+
t: "payload";
|
|
426
|
+
v: 1;
|
|
427
|
+
jobId: string;
|
|
428
|
+
to: string;
|
|
429
|
+
box: string;
|
|
430
|
+
};
|
|
431
|
+
type RelayerMessage = JobAdvert | RelayerBid | EncryptedPayload;
|
|
432
|
+
declare function makeAdvert(args: {
|
|
433
|
+
jobId: Uint8Array;
|
|
434
|
+
fee: bigint;
|
|
435
|
+
deadline: number;
|
|
436
|
+
payloadHash: Uint8Array;
|
|
437
|
+
chain?: number;
|
|
438
|
+
}): JobAdvert;
|
|
439
|
+
declare function bidSigningDigest(jobId: Uint8Array, x25519Pk: Uint8Array): Uint8Array;
|
|
440
|
+
declare function makeBid(args: {
|
|
441
|
+
advert: JobAdvert;
|
|
442
|
+
operator: Keypair;
|
|
443
|
+
x25519Pk: Uint8Array;
|
|
444
|
+
endpoint?: string;
|
|
445
|
+
freeStake?: bigint;
|
|
446
|
+
}): RelayerBid;
|
|
447
|
+
declare function verifyBid(bid: RelayerBid): boolean;
|
|
448
|
+
declare function validateAdvert(value: unknown): JobAdvert;
|
|
449
|
+
declare function validateBid(value: unknown): RelayerBid;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Relayer-market gateway client: build a blind withdrawal payload, advertise a
|
|
453
|
+
* job, collect and verify bids (signature + on-chain registry state), pick a
|
|
454
|
+
* relayer, and deliver the payload encrypted to its X25519 key. HTTP transport
|
|
455
|
+
* is the `opaque/jobs/v1` gateway API.
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
type VerifiedBid = RelayerBid & {
|
|
459
|
+
freeStakeValue: bigint;
|
|
460
|
+
};
|
|
461
|
+
type RelayerJobDraft = {
|
|
462
|
+
jobId: Uint8Array;
|
|
463
|
+
jobIdHex: string;
|
|
464
|
+
payload: PoolWithdrawPayload;
|
|
465
|
+
payloadHash: Uint8Array;
|
|
466
|
+
payloadHashHex: string;
|
|
467
|
+
advert: JobAdvert;
|
|
468
|
+
deadlineLedger: number;
|
|
469
|
+
fee: bigint;
|
|
470
|
+
};
|
|
471
|
+
type RelayerJobStatus = "open" | "accepted" | "submitted" | "slashed" | "canceled" | "unknown";
|
|
472
|
+
/** Cryptographically random 32-byte job id. */
|
|
473
|
+
declare function randomJobId(): Uint8Array;
|
|
474
|
+
/**
|
|
475
|
+
* Build the blind withdrawal payload. The pool fee is zero (the registry escrow
|
|
476
|
+
* pays the relayer) and the proof binds the registry as the pool relayer, so the
|
|
477
|
+
* payload hash is deterministic before a relayer is chosen.
|
|
478
|
+
*/
|
|
479
|
+
declare function buildRelayedWithdrawPayload(args: {
|
|
480
|
+
poolId: string;
|
|
481
|
+
registryId: string;
|
|
482
|
+
proof: PoolWithdrawProof;
|
|
483
|
+
recipient: string;
|
|
484
|
+
}): PoolWithdrawPayload;
|
|
485
|
+
declare function buildRelayerJobDraft(args: {
|
|
486
|
+
payload: PoolWithdrawPayload;
|
|
487
|
+
fee: bigint;
|
|
488
|
+
deadlineLedger: number;
|
|
489
|
+
jobId?: Uint8Array;
|
|
490
|
+
}): RelayerJobDraft;
|
|
491
|
+
/** Stake-weighted random choice among verified bids. */
|
|
492
|
+
declare function pickStakeWeightedBid(bids: VerifiedBid[]): VerifiedBid | null;
|
|
493
|
+
declare class RelayerGateway {
|
|
494
|
+
private readonly gatewayUrls;
|
|
495
|
+
private readonly registryId;
|
|
496
|
+
private readonly invoker;
|
|
497
|
+
constructor(opts: {
|
|
498
|
+
gatewayUrls: string[];
|
|
499
|
+
registryId: string;
|
|
500
|
+
invoker: ContractInvoker;
|
|
501
|
+
});
|
|
502
|
+
private url;
|
|
503
|
+
/** A deadline `ledgers` ahead of the current ledger. */
|
|
504
|
+
deadlineLedger(ledgers?: number): Promise<number>;
|
|
505
|
+
publishAdvert(advert: JobAdvert, gateway?: string): Promise<void>;
|
|
506
|
+
fetchBids(jobIdHex: string, gateway?: string): Promise<VerifiedBid[]>;
|
|
507
|
+
deliverPayload(args: {
|
|
508
|
+
draft: RelayerJobDraft;
|
|
509
|
+
bid: RelayerBid;
|
|
510
|
+
gateway?: string;
|
|
511
|
+
}): Promise<{
|
|
512
|
+
acceptedTx?: string;
|
|
513
|
+
submittedTx?: string;
|
|
514
|
+
} | null>;
|
|
515
|
+
jobStatus(jobIdHex: string, source: string): Promise<RelayerJobStatus>;
|
|
516
|
+
private verifyBidRegistryState;
|
|
517
|
+
private registryView;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export { fileArtifactResolver as $, type ArtifactResolver as A, type SignTxFn as B, type ContractInvoker as C, DEFAULT_ARTIFACT_PATHS as D, type EncryptedPayload as E, type SignerContext as F, type Groth16ProofLike as G, TESTNET_DEPLOYMENT as H, type InvokeOptions as I, type JobAdvert as J, bidSigningDigest as K, type Logger as L, buildRelayedWithdrawPayload as M, NETWORK_PRESETS as N, type OpaqueSigner as O, type PoolWithdrawProof as P, buildRelayerJobDraft as Q, type ResolvedConfig as R, type ScannerSyncEvent as S, type Telemetry as T, callbackSigner as U, type VerifiedBid as V, computeWithdrawContext as W, type X25519Keypair as X, consoleLogger as Y, decodePoolWithdrawPayload as Z, encodePoolWithdrawPayload as _, type RelayerJobDraft as a, generateX25519Keypair as a0, hashPoolWithdrawPayload as a1, hashPoolWithdrawPayloadHex as a2, keypairSigner as a3, makeAdvert as a4, makeBid as a5, noopTelemetry as a6, openBox as a7, parsePoolWithdrawPayload as a8, pickStakeWeightedBid as a9, poolWithdrawPayloadPreimage as aa, provePoolWithdraw as ab, randomJobId as ac, resolveConfig as ad, sealBox as ae, serializeGroth16Proof as af, serializePoolWithdrawPayload as ag, silentLogger as ah, urlArtifactResolver as ai, validateAdvert as aj, validateBid as ak, verifyBid as al, type PoolWithdrawPayload as b, type RelayerBid as c, type RelayerJobStatus as d, type OpaqueConfig as e, RpcClient as f, type ArtifactId as g, type ArtifactKind as h, type ContractAddresses as i, type ContractCallEvent as j, DEPLOYMENTS as k, NEW_ACCOUNT_MIN_RESERVE_STROOPS as l, type NetworkDeployment as m, type NetworkPreset as n, type OpaqueNetwork as o, PoolMerkleTree as p, type PoolWiring as q, RELAY_CHAIN_STELLAR as r, RELAY_PAYLOAD_DOMAIN as s, type ReadOptions as t, RelayerGateway as u, type RelayerMessage as v, type RelayerWiring as w, type RpcClientOptions as x, type SerializablePoolWithdrawPayload as y, type SerializedProof as z };
|