@arcanetech/privacy-sdk-stellar 0.2.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.
@@ -0,0 +1,2478 @@
1
+ // src/state/foundation/paths.ts
2
+ var STELLAR_STATE_PATHS = {
3
+ privateRecords: "$.privateRecords",
4
+ pendingClaimsItems: "$.pendingClaims.items",
5
+ pendingClaimsPagination: "$.pendingClaims.pagination",
6
+ pendingClaimsCountByOwner: "$.pendingClaims.countByOwner",
7
+ registryPrivateAddresses: "$.registry.privateAddresses",
8
+ registryRegisteredAddresses: "$.registry.registeredAddresses",
9
+ registryLookups: "$.registry.lookups",
10
+ assets: "$.assets",
11
+ assetsById: "$.assets.byId",
12
+ assetsListOrder: "$.assets.listOrder",
13
+ publicBalances: "$.balances.publicByOwnerAsset",
14
+ poolsByContract: "$.pools.byContract",
15
+ poolsLeafEphemeral: "$.pools.leafEphemeralByContractAndIndex",
16
+ deliveriesIncomingById: "$.deliveries.incomingById",
17
+ deliveriesSync: "$.deliveries.syncByPrivateAddressAsset",
18
+ transactionsByHash: "$.transactions.byHash",
19
+ walletPrivateAddressScalars: "$.wallet.privateAddressScalars",
20
+ walletPrivateAddressRecords: "$.wallet.privateAddressRecords",
21
+ walletDefaultPrivateAddressNonce: "$.wallet.defaultPrivateAddressNonce"
22
+ };
23
+
24
+ // src/state/schemas/shared.ts
25
+ import { z } from "zod";
26
+ var pendingClaimSchema = z.object({
27
+ id: z.string().min(1),
28
+ owner: z.string().min(1),
29
+ asset: z.string().min(1),
30
+ amount: z.coerce.bigint(),
31
+ createdAt: z.string().min(1),
32
+ poolTxId: z.string().optional(),
33
+ commitmentHex: z.string().optional(),
34
+ nullifierHex: z.string().optional(),
35
+ futureNullifierHashHex: z.string().optional(),
36
+ assetHiHex: z.string().optional(),
37
+ assetLoHex: z.string().optional(),
38
+ nullifierFieldHex: z.string().optional(),
39
+ secretHex: z.string().optional(),
40
+ tempPublicKeyXHex: z.string().optional(),
41
+ tempPublicKeyYHex: z.string().optional(),
42
+ encryptedRecoveryBase64: z.string().optional(),
43
+ createdAtLedger: z.number().int().optional()
44
+ });
45
+ var paginationSchema = z.object({
46
+ total: z.number().int().nonnegative(),
47
+ page: z.number().int().positive(),
48
+ pageSize: z.number().int().positive(),
49
+ hasMore: z.boolean()
50
+ });
51
+ var stellarPrivateCoinNoteSchema = z.object({
52
+ value: z.string(),
53
+ nullifier: z.string(),
54
+ secret: z.string(),
55
+ commitment: z.string(),
56
+ asset_hi: z.string(),
57
+ asset_lo: z.string(),
58
+ application_id: z.string().optional()
59
+ });
60
+ var privateRecordSchema = z.object({
61
+ id: z.string().min(1),
62
+ owner: z.string().min(1),
63
+ asset: z.string().min(1),
64
+ amount: z.coerce.bigint(),
65
+ consumed: z.boolean(),
66
+ status: z.enum(["pending", "finalized", "spent"]).optional(),
67
+ poolContract: z.string().optional(),
68
+ commitmentHex: z.string().optional(),
69
+ nullifierHex: z.string().optional(),
70
+ amountDisplay: z.number().optional(),
71
+ deliveryId: z.number().int().optional(),
72
+ privateAddress: z.string().optional(),
73
+ txHash: z.string().optional(),
74
+ coinNote: stellarPrivateCoinNoteSchema.optional(),
75
+ depositScalarHex: z.string().optional(),
76
+ precommitementHex: z.string().optional()
77
+ });
78
+ var assetSchema = z.object({
79
+ id: z.number().int(),
80
+ assetId: z.string().min(1),
81
+ name: z.string().min(1),
82
+ logoUrl: z.string().nullable(),
83
+ issuerAddress: z.string().nullable(),
84
+ clientContract: z.string().nullable(),
85
+ poolContracts: z.array(z.string()),
86
+ poolContract: z.string().min(1),
87
+ mintable: z.boolean(),
88
+ mintAmount: z.string().nullable(),
89
+ decimals: z.number().int().nullable().optional()
90
+ });
91
+ var publicBalanceSchema = z.object({
92
+ owner: z.string().min(1),
93
+ asset: z.string().min(1),
94
+ balance: z.string(),
95
+ trustlineStatus: z.enum(["active", "inactive", "none"])
96
+ });
97
+ var registryLookupSchema = z.object({
98
+ owner: z.string().min(1),
99
+ status: z.enum(["registered", "unregistered"]),
100
+ privateAddressStpl1: z.string().optional(),
101
+ publicKeyXHex: z.string().optional(),
102
+ publicKeyYHex: z.string().optional(),
103
+ updatedAtLedger: z.number().int().optional(),
104
+ cachedAt: z.string().optional()
105
+ });
106
+ var walletPrivateAddressScalarSchema = z.object({
107
+ owner: z.string().min(1),
108
+ nonce: z.string().min(1),
109
+ scalarHex: z.string().min(1),
110
+ updatedAt: z.string().optional()
111
+ });
112
+ var walletPrivateAddressRecordSchema = z.object({
113
+ owner: z.string().min(1),
114
+ nonce: z.string().min(1),
115
+ privateAddress: z.string().min(1),
116
+ createdAt: z.number()
117
+ });
118
+ var poolMerkleStateSchema = z.object({
119
+ poolContract: z.string().min(1),
120
+ commitments: z.array(z.string()),
121
+ commitmentCount: z.number().int().nonnegative(),
122
+ merkleRootHex: z.string().min(1),
123
+ updatedAt: z.number(),
124
+ syncedLedger: z.number().int().optional()
125
+ });
126
+ var leafEphemeralSchema = z.object({
127
+ poolContract: z.string().min(1),
128
+ leafIndex: z.number().int().nonnegative(),
129
+ xHex: z.string().min(1),
130
+ yHex: z.string().min(1),
131
+ cachedAt: z.string().optional()
132
+ });
133
+ var incomingDeliverySchema = z.object({
134
+ id: z.number().int(),
135
+ privateAddress: z.string().min(1),
136
+ asset: z.string().min(1),
137
+ ciphertextBase64: z.string().min(1),
138
+ ephemeralKey: z.string().min(1),
139
+ tagBase64: z.string().min(1),
140
+ createdAt: z.string().min(1),
141
+ processed: z.boolean().optional()
142
+ });
143
+ var deliverySyncStateSchema = z.object({
144
+ privateAddress: z.string().min(1),
145
+ asset: z.string().min(1),
146
+ bloomM: z.number().int().positive(),
147
+ bloomK: z.number().int().positive(),
148
+ bloomBitsBase64: z.string().optional(),
149
+ lastPage: z.number().int().positive().optional(),
150
+ lastPolledAt: z.string().optional()
151
+ });
152
+ var transactionStatusSchema = z.object({
153
+ txHash: z.string().min(1),
154
+ status: z.enum(["pending", "success", "failed"]),
155
+ ledger: z.number().int().optional(),
156
+ createdAt: z.string().optional()
157
+ });
158
+
159
+ // src/state/foundation/coerce.ts
160
+ function withoutUndefinedFields(value) {
161
+ const next = {};
162
+ for (const [key, fieldValue] of Object.entries(value)) {
163
+ if (fieldValue !== void 0) {
164
+ Reflect.set(next, key, fieldValue);
165
+ }
166
+ }
167
+ return next;
168
+ }
169
+
170
+ // src/state/read/normalize/assets.ts
171
+ function normalizeAssetsCatalog(value) {
172
+ if (typeof value !== "object" || value === null) {
173
+ return { byId: {}, listOrder: [] };
174
+ }
175
+ const record = value;
176
+ const byIdRaw = record.byId;
177
+ const listOrderRaw = record.listOrder;
178
+ const byId = {};
179
+ if (typeof byIdRaw === "object" && byIdRaw !== null) {
180
+ for (const [key, entry] of Object.entries(byIdRaw)) {
181
+ const parsed = assetSchema.safeParse(entry);
182
+ if (parsed.success) {
183
+ byId[key] = withoutUndefinedFields(parsed.data);
184
+ }
185
+ }
186
+ }
187
+ const listOrder = Array.isArray(listOrderRaw) ? listOrderRaw.filter((item) => typeof item === "string") : [];
188
+ return { byId, listOrder };
189
+ }
190
+ function normalizeAsset(value) {
191
+ const parsed = assetSchema.safeParse(value);
192
+ return parsed.success ? withoutUndefinedFields(parsed.data) : void 0;
193
+ }
194
+ function normalizePublicBalance(value) {
195
+ const parsed = publicBalanceSchema.safeParse(value);
196
+ return parsed.success ? parsed.data : void 0;
197
+ }
198
+ function normalizePublicBalancesFromEntries(value, owner) {
199
+ if (!Array.isArray(value)) {
200
+ return [];
201
+ }
202
+ return value.map((entry) => {
203
+ if (!Array.isArray(entry) || entry.length < 2) {
204
+ return;
205
+ }
206
+ const [key, balanceValue] = entry;
207
+ if (typeof key !== "string" || !key.startsWith(`${owner}:`)) {
208
+ return;
209
+ }
210
+ return normalizePublicBalance(balanceValue);
211
+ }).filter((balance) => balance !== void 0);
212
+ }
213
+
214
+ // src/state/read/normalize/claims.ts
215
+ function normalizePendingClaimsState(value) {
216
+ if (typeof value !== "object" || value === null) {
217
+ return { items: [] };
218
+ }
219
+ const record = value;
220
+ const items = Array.isArray(record.items) ? record.items.flatMap((item) => {
221
+ const parsed = pendingClaimSchema.safeParse(item);
222
+ return parsed.success ? [withoutUndefinedFields(parsed.data)] : [];
223
+ }) : [];
224
+ const paginationResult = paginationSchema.safeParse(record.pagination);
225
+ if (paginationResult.success) {
226
+ return { items, pagination: paginationResult.data };
227
+ }
228
+ return { items };
229
+ }
230
+ function normalizePendingClaimsCount(value) {
231
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : void 0;
232
+ }
233
+
234
+ // src/state/read/normalize/deliveries.ts
235
+ function normalizeIncomingDeliveries(value) {
236
+ const entries = typeof value === "object" && value !== null && !Array.isArray(value) ? Object.values(value) : value;
237
+ if (!Array.isArray(entries)) {
238
+ return [];
239
+ }
240
+ return entries.flatMap((entry) => {
241
+ const parsed = incomingDeliverySchema.safeParse(entry);
242
+ return parsed.success ? [withoutUndefinedFields(parsed.data)] : [];
243
+ });
244
+ }
245
+ function normalizeDeliverySyncState(value) {
246
+ const parsed = deliverySyncStateSchema.safeParse(value);
247
+ return parsed.success ? withoutUndefinedFields(parsed.data) : void 0;
248
+ }
249
+
250
+ // src/state/read/normalize/pool.ts
251
+ function normalizePoolMerkleState(value) {
252
+ const parsed = poolMerkleStateSchema.safeParse(value);
253
+ return parsed.success ? withoutUndefinedFields(parsed.data) : void 0;
254
+ }
255
+ function normalizeLeafEphemeral(value) {
256
+ const parsed = leafEphemeralSchema.safeParse(value);
257
+ return parsed.success ? withoutUndefinedFields(parsed.data) : void 0;
258
+ }
259
+
260
+ // src/state/read/normalize/registry.ts
261
+ function normalizeCachedPrivateAddress(value) {
262
+ return typeof value === "string" && value.length > 0 ? value : void 0;
263
+ }
264
+ function normalizeRegistryLookup(value) {
265
+ const parsed = registryLookupSchema.safeParse(value);
266
+ return parsed.success ? withoutUndefinedFields(parsed.data) : void 0;
267
+ }
268
+ function normalizeRegistryLookupFromLegacy(input) {
269
+ const lookup = normalizeRegistryLookup(
270
+ typeof input.registered === "object" && input.registered !== null ? input.registered : void 0
271
+ );
272
+ if (lookup) {
273
+ return lookup;
274
+ }
275
+ if (input.registered === void 0 && input.privateAddress === void 0) {
276
+ return void 0;
277
+ }
278
+ const registered2 = Boolean(input.registered);
279
+ const privateAddressStpl1 = normalizeCachedPrivateAddress(input.privateAddress);
280
+ if (!registered2 && privateAddressStpl1 === void 0) {
281
+ return { owner: input.address, status: "unregistered" };
282
+ }
283
+ return withoutUndefinedFields({
284
+ owner: input.address,
285
+ status: registered2 ? "registered" : "unregistered",
286
+ ...privateAddressStpl1 === void 0 ? {} : { privateAddressStpl1 }
287
+ });
288
+ }
289
+
290
+ // src/state/read/normalize/records.ts
291
+ import "zod";
292
+ function normalizePrivateRecords(value) {
293
+ if (!Array.isArray(value)) {
294
+ return [];
295
+ }
296
+ const records = value.flatMap((item) => {
297
+ const parsed = privateRecordSchema.safeParse(item);
298
+ return parsed.success ? [normalizePrivateRecordFields(parsed.data)] : [];
299
+ });
300
+ return deduplicatePrivateRecords(records);
301
+ }
302
+ function normalizeTransactionStatus(value) {
303
+ const parsed = transactionStatusSchema.safeParse(value);
304
+ return parsed.success ? withoutUndefinedFields(parsed.data) : void 0;
305
+ }
306
+ function privateRecordCommitmentKey(record) {
307
+ return (record.commitmentHex?.trim() || record.coinNote?.commitment.trim() || record.id.trim()).replace(/^0x/iu, "").toLowerCase();
308
+ }
309
+ function normalizePrivateRecordFields(record) {
310
+ const normalized = withoutUndefinedFields(record);
311
+ if (!normalized.privateAddress && normalized.owner.trim().startsWith("stpl")) {
312
+ return { ...normalized, privateAddress: normalized.owner.trim() };
313
+ }
314
+ return normalized;
315
+ }
316
+ function preferPrivateRecord(current, incoming, key) {
317
+ if (privateRecordIdKey(incoming) === key) {
318
+ return incoming;
319
+ }
320
+ if (privateRecordIdKey(current) === key) {
321
+ return current;
322
+ }
323
+ return incoming;
324
+ }
325
+ function privateRecordIdKey(record) {
326
+ return record.id.trim().replace(/^0x/iu, "").toLowerCase();
327
+ }
328
+ function deduplicatePrivateRecords(records) {
329
+ const byCommitment = /* @__PURE__ */ new Map();
330
+ for (const record of records) {
331
+ const key = privateRecordCommitmentKey(record);
332
+ const current = byCommitment.get(key);
333
+ byCommitment.set(key, current ? preferPrivateRecord(current, record, key) : record);
334
+ }
335
+ return [...byCommitment.values()];
336
+ }
337
+
338
+ // src/state/read/normalize/wallet.ts
339
+ function normalizeWalletPrivateAddressScalar(value) {
340
+ const parsed = walletPrivateAddressScalarSchema.safeParse(value);
341
+ return parsed.success ? withoutUndefinedFields(parsed.data) : void 0;
342
+ }
343
+ function normalizeWalletPrivateAddressRecord(value) {
344
+ const parsed = walletPrivateAddressRecordSchema.safeParse(value);
345
+ return parsed.success ? withoutUndefinedFields(parsed.data) : void 0;
346
+ }
347
+ function normalizeWalletDefaultPrivateAddressNonce(value) {
348
+ return typeof value === "string" ? value.trim() || void 0 : void 0;
349
+ }
350
+
351
+ // src/state/read/snapshot.ts
352
+ function readSnapshotObject(value) {
353
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
354
+ return void 0;
355
+ }
356
+ return value;
357
+ }
358
+ function resolveSdkSnapshot(value) {
359
+ const record = readSnapshotObject(value);
360
+ if (!record) {
361
+ return void 0;
362
+ }
363
+ const branch = readSnapshotObject(record.privacySdkState);
364
+ return branch ?? record;
365
+ }
366
+ function readWalletSnapshot(value) {
367
+ const sdk = resolveSdkSnapshot(value);
368
+ if (!sdk) {
369
+ return void 0;
370
+ }
371
+ return readSnapshotObject(sdk.wallet);
372
+ }
373
+ function readWalletMap(value, key) {
374
+ const wallet = readWalletSnapshot(value);
375
+ if (!wallet) {
376
+ return void 0;
377
+ }
378
+ if (key === "privateAddressScalars") {
379
+ return readSnapshotObject(wallet.privateAddressScalars);
380
+ }
381
+ if (key === "privateAddressRecords") {
382
+ return readSnapshotObject(wallet.privateAddressRecords);
383
+ }
384
+ return readSnapshotObject(wallet.defaultPrivateAddressNonce);
385
+ }
386
+ function readRecordValue(record, key) {
387
+ for (const [entryKey, entryValue] of Object.entries(record)) {
388
+ if (entryKey === key) {
389
+ return entryValue;
390
+ }
391
+ }
392
+ return void 0;
393
+ }
394
+ function ownerNonceKey(owner, nonce) {
395
+ return `${owner.trim()}:${nonce.trim()}`;
396
+ }
397
+ function readPrivateRecordsFromStateSnapshot(state) {
398
+ const sdk = resolveSdkSnapshot(state);
399
+ if (!sdk) {
400
+ return [];
401
+ }
402
+ return normalizePrivateRecords(sdk.privateRecords);
403
+ }
404
+ function readWalletPrivateAddressScalarFromStateSnapshot(input) {
405
+ const owner = input.owner.trim();
406
+ const nonce = input.nonce.trim();
407
+ if (!owner || !nonce) {
408
+ return void 0;
409
+ }
410
+ const scalars = readWalletMap(input.state, "privateAddressScalars");
411
+ if (!scalars) {
412
+ return void 0;
413
+ }
414
+ const value = scalars[ownerNonceKey(owner, nonce)];
415
+ if (typeof value === "string") {
416
+ const scalarHex = value.trim();
417
+ return scalarHex ? { owner, nonce, scalarHex } : void 0;
418
+ }
419
+ return normalizeWalletPrivateAddressScalar(value);
420
+ }
421
+ function readWalletPrivateAddressRecordFromStateSnapshot(input) {
422
+ const owner = input.owner.trim();
423
+ const nonce = input.nonce.trim();
424
+ if (!owner || !nonce) {
425
+ return void 0;
426
+ }
427
+ const records = readWalletMap(input.state, "privateAddressRecords");
428
+ if (!records) {
429
+ return void 0;
430
+ }
431
+ return normalizeWalletPrivateAddressRecord(records[ownerNonceKey(owner, nonce)]);
432
+ }
433
+ function readWalletDefaultPrivateAddressNonceFromStateSnapshot(input) {
434
+ const owner = input.owner.trim();
435
+ if (!owner) {
436
+ return void 0;
437
+ }
438
+ const defaults = readWalletMap(input.state, "defaultPrivateAddressNonce");
439
+ if (!defaults) {
440
+ return void 0;
441
+ }
442
+ return normalizeWalletDefaultPrivateAddressNonce(readRecordValue(defaults, owner));
443
+ }
444
+ function listWalletPrivateAddressScalarsForOwnerFromStateSnapshot(input) {
445
+ const owner = input.owner.trim();
446
+ if (!owner) {
447
+ return [];
448
+ }
449
+ const scalars = readWalletMap(input.state, "privateAddressScalars");
450
+ if (!scalars) {
451
+ return [];
452
+ }
453
+ const prefix = `${owner}:`;
454
+ return Object.keys(scalars).flatMap((key) => {
455
+ if (!key.startsWith(prefix)) {
456
+ return [];
457
+ }
458
+ const nonce = key.slice(prefix.length).trim();
459
+ if (!nonce) {
460
+ return [];
461
+ }
462
+ const entry = readWalletPrivateAddressScalarFromStateSnapshot({
463
+ state: input.state,
464
+ owner,
465
+ nonce
466
+ });
467
+ return entry ? [entry] : [];
468
+ });
469
+ }
470
+ function listWalletPrivateAddressRecordsForOwnerFromStateSnapshot(input) {
471
+ const owner = input.owner.trim();
472
+ if (!owner) {
473
+ return [];
474
+ }
475
+ const records = readWalletMap(input.state, "privateAddressRecords");
476
+ if (!records) {
477
+ return [];
478
+ }
479
+ const prefix = `${owner}:`;
480
+ return Object.keys(records).flatMap((key) => {
481
+ if (!key.startsWith(prefix)) {
482
+ return [];
483
+ }
484
+ const nonce = key.slice(prefix.length).trim();
485
+ if (!nonce) {
486
+ return [];
487
+ }
488
+ const entry = readWalletPrivateAddressRecordFromStateSnapshot({
489
+ state: input.state,
490
+ owner,
491
+ nonce
492
+ });
493
+ return entry ? [entry] : [];
494
+ });
495
+ }
496
+
497
+ // src/state/filters/register-schemas.ts
498
+ import { registerArrayFilterItemSchema } from "@arcanetech/privacy-sdk-core/state";
499
+
500
+ // src/state/filters/ops.ts
501
+ var stellarArrayFilterSchemaKeys = {
502
+ privateRecord: "privateRecord",
503
+ pendingClaim: "pendingClaim"
504
+ };
505
+ function rejectPrivateRecordsByIds(ids) {
506
+ return {
507
+ opType: "arrayFilter",
508
+ jsonPath: STELLAR_STATE_PATHS.privateRecords,
509
+ itemSchemaKey: stellarArrayFilterSchemaKeys.privateRecord,
510
+ rejectWhen: {
511
+ op: "fieldIn",
512
+ field: "id",
513
+ values: ids
514
+ }
515
+ };
516
+ }
517
+ function rejectConsumedPrivateRecords() {
518
+ return {
519
+ opType: "arrayFilter",
520
+ jsonPath: STELLAR_STATE_PATHS.privateRecords,
521
+ itemSchemaKey: stellarArrayFilterSchemaKeys.privateRecord,
522
+ rejectWhen: {
523
+ op: "fieldEquals",
524
+ field: "consumed",
525
+ value: true
526
+ }
527
+ };
528
+ }
529
+ function rejectPendingClaimsByOwner(owner) {
530
+ return {
531
+ opType: "arrayFilter",
532
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsItems,
533
+ itemSchemaKey: stellarArrayFilterSchemaKeys.pendingClaim,
534
+ rejectWhen: {
535
+ op: "fieldEquals",
536
+ field: "owner",
537
+ value: owner
538
+ }
539
+ };
540
+ }
541
+ function rejectPendingClaimsByIds(ids) {
542
+ return {
543
+ opType: "arrayFilter",
544
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsItems,
545
+ itemSchemaKey: stellarArrayFilterSchemaKeys.pendingClaim,
546
+ rejectWhen: {
547
+ op: "fieldIn",
548
+ field: "id",
549
+ values: ids
550
+ }
551
+ };
552
+ }
553
+ function rejectPendingClaimsByOwnerAndAsset(input) {
554
+ const matches = [];
555
+ if (input.owner !== void 0) {
556
+ matches.push({
557
+ op: "fieldEquals",
558
+ field: "owner",
559
+ value: input.owner
560
+ });
561
+ }
562
+ if (input.asset !== void 0) {
563
+ matches.push({
564
+ op: "fieldEquals",
565
+ field: "asset",
566
+ value: input.asset
567
+ });
568
+ }
569
+ return {
570
+ opType: "arrayFilter",
571
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsItems,
572
+ itemSchemaKey: stellarArrayFilterSchemaKeys.pendingClaim,
573
+ rejectWhen: {
574
+ op: "and",
575
+ matches
576
+ }
577
+ };
578
+ }
579
+
580
+ // src/state/filters/register-schemas.ts
581
+ var registered = false;
582
+ function registerStellarArrayFilterSchemas() {
583
+ if (registered) {
584
+ return;
585
+ }
586
+ registerArrayFilterItemSchema(
587
+ stellarArrayFilterSchemaKeys.privateRecord,
588
+ privateRecordSchema
589
+ );
590
+ registerArrayFilterItemSchema(
591
+ stellarArrayFilterSchemaKeys.pendingClaim,
592
+ pendingClaimSchema
593
+ );
594
+ registered = true;
595
+ }
596
+
597
+ // src/state/bridge/call-types.ts
598
+ import "@arcanetech/privacy-sdk-core/state";
599
+ var stellarStateCallTypes = {
600
+ pendingClaims: "pendingClaims",
601
+ clearPendingClaims: "clearPendingClaims",
602
+ readPendingClaims: "readPendingClaims",
603
+ replacePendingClaimsPage: "replacePendingClaimsPage",
604
+ upsertPendingClaims: "upsertPendingClaims",
605
+ removePendingClaims: "removePendingClaims",
606
+ setPendingClaimsCount: "setPendingClaimsCount",
607
+ readPendingClaimsCount: "readPendingClaimsCount",
608
+ readStellarAddressRegistered: "readStellarAddressRegistered",
609
+ readCachedPrivateAddress: "readCachedPrivateAddress",
610
+ readRegistryLookup: "readRegistryLookup",
611
+ saveRegisteredPrivateAddress: "saveRegisteredPrivateAddress",
612
+ saveRegistryLookup: "saveRegistryLookup",
613
+ invalidateRegisteredAddress: "invalidateRegisteredAddress",
614
+ invalidateRegistryLookup: "invalidateRegistryLookup",
615
+ readAssetsCatalog: "readAssetsCatalog",
616
+ readAsset: "readAsset",
617
+ replaceAssets: "replaceAssets",
618
+ upsertAssets: "upsertAssets",
619
+ readPublicBalance: "readPublicBalance",
620
+ readPublicBalances: "readPublicBalances",
621
+ setPublicBalance: "setPublicBalance",
622
+ setPublicBalances: "setPublicBalances",
623
+ readPoolMerkleState: "readPoolMerkleState",
624
+ setPoolMerkleState: "setPoolMerkleState",
625
+ readLeafEphemeral: "readLeafEphemeral",
626
+ setLeafEphemeral: "setLeafEphemeral",
627
+ listPrivateRecords: "listPrivateRecords",
628
+ savePrivateRecords: "savePrivateRecords",
629
+ replacePrivateRecords: "replacePrivateRecords",
630
+ upsertPrivateRecords: "upsertPrivateRecords",
631
+ pruneConsumedPrivateRecords: "pruneConsumedPrivateRecords",
632
+ readIncomingDeliveries: "readIncomingDeliveries",
633
+ upsertIncomingDeliveries: "upsertIncomingDeliveries",
634
+ readDeliverySyncState: "readDeliverySyncState",
635
+ setDeliverySyncState: "setDeliverySyncState",
636
+ readTransactionStatus: "readTransactionStatus",
637
+ setTransactionStatus: "setTransactionStatus",
638
+ clearTransactionStatus: "clearTransactionStatus",
639
+ saveWalletPrivateAddressScalar: "saveWalletPrivateAddressScalar",
640
+ readWalletPrivateAddressScalar: "readWalletPrivateAddressScalar",
641
+ saveWalletPrivateAddressRecord: "saveWalletPrivateAddressRecord",
642
+ readWalletPrivateAddressRecord: "readWalletPrivateAddressRecord",
643
+ setWalletDefaultPrivateAddressNonce: "setWalletDefaultPrivateAddressNonce",
644
+ readWalletDefaultPrivateAddressNonce: "readWalletDefaultPrivateAddressNonce",
645
+ deleteWalletPrivateAddressScalar: "deleteWalletPrivateAddressScalar"
646
+ };
647
+
648
+ // src/state/schemas/assets/catalog.ts
649
+ import { z as z3 } from "zod";
650
+ var readAssetsCatalogSchema = z3.object({
651
+ type: z3.literal(stellarStateCallTypes.readAssetsCatalog)
652
+ }).transform(({ type }) => ({
653
+ type,
654
+ operations: [
655
+ {
656
+ opType: "primitiveGet",
657
+ jsonPath: STELLAR_STATE_PATHS.assets
658
+ }
659
+ ]
660
+ }));
661
+ var readAssetSchema = z3.object({
662
+ type: z3.literal(stellarStateCallTypes.readAsset),
663
+ assetId: z3.string().min(1)
664
+ }).transform(({ type, assetId }) => ({
665
+ type,
666
+ operations: [
667
+ {
668
+ opType: "recordGet",
669
+ jsonPath: STELLAR_STATE_PATHS.assetsById,
670
+ key: assetId
671
+ }
672
+ ]
673
+ }));
674
+ var replaceAssetsSchema = z3.object({
675
+ type: z3.literal(stellarStateCallTypes.replaceAssets),
676
+ assets: z3.array(assetSchema)
677
+ }).transform(({ type, assets }) => {
678
+ const byId = {};
679
+ const listOrder = [];
680
+ for (const asset of assets) {
681
+ Reflect.set(byId, asset.assetId, withoutUndefinedFields(asset));
682
+ listOrder.push(asset.assetId);
683
+ }
684
+ return {
685
+ type,
686
+ operations: [
687
+ {
688
+ opType: "primitiveSet",
689
+ jsonPath: STELLAR_STATE_PATHS.assets,
690
+ value: { byId, listOrder }
691
+ }
692
+ ]
693
+ };
694
+ });
695
+ var upsertAssetsSchema = z3.object({
696
+ type: z3.literal(stellarStateCallTypes.upsertAssets),
697
+ assets: z3.array(assetSchema)
698
+ }).transform(({ type, assets }) => ({
699
+ type,
700
+ operations: assets.map((asset) => ({
701
+ opType: "recordSet",
702
+ jsonPath: STELLAR_STATE_PATHS.assetsById,
703
+ key: asset.assetId,
704
+ value: asset
705
+ }))
706
+ }));
707
+
708
+ // src/state/definitions/assets.ts
709
+ var stellarAssetsStateDefinitions = [
710
+ {
711
+ type: stellarStateCallTypes.readAssetsCatalog,
712
+ mode: "read",
713
+ schema: readAssetsCatalogSchema
714
+ },
715
+ {
716
+ type: stellarStateCallTypes.readAsset,
717
+ mode: "read",
718
+ schema: readAssetSchema
719
+ },
720
+ {
721
+ type: stellarStateCallTypes.replaceAssets,
722
+ mode: "write",
723
+ schema: replaceAssetsSchema
724
+ },
725
+ {
726
+ type: stellarStateCallTypes.upsertAssets,
727
+ mode: "write",
728
+ schema: upsertAssetsSchema
729
+ }
730
+ ];
731
+
732
+ // src/state/schemas/assets/balances.ts
733
+ import { z as z4 } from "zod";
734
+
735
+ // src/state/foundation/keys.ts
736
+ function ownerAssetKey(owner, asset) {
737
+ return `${owner}:${asset}`;
738
+ }
739
+ function readRecordValue2(record, key) {
740
+ if (!Object.hasOwn(record, key)) {
741
+ return void 0;
742
+ }
743
+ return Reflect.get(record, key);
744
+ }
745
+ function poolLeafKey(poolContract, leafIndex) {
746
+ return `${poolContract}:${leafIndex}`;
747
+ }
748
+ function privateAddressAssetKey(privateAddress, asset) {
749
+ return `${privateAddress}:${asset}`;
750
+ }
751
+ function walletOwnerNonceKey(owner, nonce) {
752
+ return `${owner}:${nonce}`;
753
+ }
754
+
755
+ // src/state/schemas/assets/balances.ts
756
+ var readPublicBalanceSchema = z4.object({
757
+ type: z4.literal(stellarStateCallTypes.readPublicBalance),
758
+ owner: z4.string().min(1),
759
+ asset: z4.string().min(1)
760
+ }).transform(({ type, owner, asset }) => ({
761
+ type,
762
+ operations: [
763
+ {
764
+ opType: "recordGet",
765
+ jsonPath: STELLAR_STATE_PATHS.publicBalances,
766
+ key: ownerAssetKey(owner, asset)
767
+ }
768
+ ]
769
+ }));
770
+ var readPublicBalancesSchema = z4.object({
771
+ type: z4.literal(stellarStateCallTypes.readPublicBalances),
772
+ owner: z4.string().min(1)
773
+ }).transform(({ type }) => ({
774
+ type,
775
+ operations: [
776
+ {
777
+ opType: "recordEntries",
778
+ jsonPath: STELLAR_STATE_PATHS.publicBalances
779
+ }
780
+ ]
781
+ }));
782
+ var setPublicBalanceSchema = z4.object({
783
+ type: z4.literal(stellarStateCallTypes.setPublicBalance),
784
+ balance: publicBalanceSchema
785
+ }).transform(({ type, balance }) => ({
786
+ type,
787
+ operations: [
788
+ {
789
+ opType: "recordSet",
790
+ jsonPath: STELLAR_STATE_PATHS.publicBalances,
791
+ key: ownerAssetKey(balance.owner, balance.asset),
792
+ value: balance
793
+ }
794
+ ]
795
+ }));
796
+ var setPublicBalancesSchema = z4.object({
797
+ type: z4.literal(stellarStateCallTypes.setPublicBalances),
798
+ owner: z4.string().min(1),
799
+ balances: z4.array(publicBalanceSchema)
800
+ }).transform(({ type, owner, balances }) => ({
801
+ type,
802
+ operations: balances.map((balance) => ({
803
+ opType: "recordSet",
804
+ jsonPath: STELLAR_STATE_PATHS.publicBalances,
805
+ key: ownerAssetKey(owner, balance.asset),
806
+ value: { ...balance, owner }
807
+ }))
808
+ }));
809
+
810
+ // src/state/definitions/balances.ts
811
+ var stellarBalancesStateDefinitions = [
812
+ {
813
+ type: stellarStateCallTypes.readPublicBalance,
814
+ mode: "read",
815
+ schema: readPublicBalanceSchema
816
+ },
817
+ {
818
+ type: stellarStateCallTypes.readPublicBalances,
819
+ mode: "read",
820
+ schema: readPublicBalancesSchema
821
+ },
822
+ {
823
+ type: stellarStateCallTypes.setPublicBalance,
824
+ mode: "write",
825
+ schema: setPublicBalanceSchema
826
+ },
827
+ {
828
+ type: stellarStateCallTypes.setPublicBalances,
829
+ mode: "write",
830
+ schema: setPublicBalancesSchema
831
+ }
832
+ ];
833
+
834
+ // src/state/schemas/claims/write.ts
835
+ import { z as z5 } from "zod";
836
+ var pendingClaimsWriteSchema = z5.object({
837
+ type: z5.literal(stellarStateCallTypes.pendingClaims),
838
+ claims: z5.array(pendingClaimSchema),
839
+ paginationInfo: paginationSchema
840
+ }).transform(({ type, claims, paginationInfo }) => ({
841
+ type,
842
+ operations: [
843
+ {
844
+ opType: "arrayPush",
845
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsItems,
846
+ items: claims
847
+ },
848
+ {
849
+ opType: "primitiveSet",
850
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsPagination,
851
+ value: paginationInfo
852
+ }
853
+ ]
854
+ }));
855
+ var clearPendingClaimsSchema = z5.object({
856
+ type: z5.literal(stellarStateCallTypes.clearPendingClaims),
857
+ owner: z5.string().optional(),
858
+ asset: z5.string().optional()
859
+ }).transform(({ type, owner, asset }) => {
860
+ if (owner === void 0 && asset === void 0) {
861
+ return {
862
+ type,
863
+ operations: [
864
+ {
865
+ opType: "arrayClean",
866
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsItems
867
+ }
868
+ ]
869
+ };
870
+ }
871
+ return {
872
+ type,
873
+ operations: [rejectPendingClaimsByOwnerAndAsset({ owner, asset })]
874
+ };
875
+ });
876
+ var readPendingClaimsSchema = z5.object({
877
+ type: z5.literal(stellarStateCallTypes.readPendingClaims)
878
+ }).transform(({ type }) => ({
879
+ type,
880
+ operations: [
881
+ {
882
+ opType: "primitiveGet",
883
+ jsonPath: "$.pendingClaims"
884
+ }
885
+ ]
886
+ }));
887
+
888
+ // src/state/schemas/claims/page.ts
889
+ import { z as z6 } from "zod";
890
+ var pendingClaimBridgeItemSchema = pendingClaimSchema;
891
+ var replacePendingClaimsPageSchema = z6.object({
892
+ type: z6.literal(stellarStateCallTypes.replacePendingClaimsPage),
893
+ owner: z6.string().min(1),
894
+ claims: z6.array(pendingClaimBridgeItemSchema),
895
+ paginationInfo: z6.object({
896
+ total: z6.number().int().nonnegative(),
897
+ page: z6.number().int().positive(),
898
+ pageSize: z6.number().int().positive(),
899
+ hasMore: z6.boolean()
900
+ }),
901
+ count: z6.number().int().nonnegative().optional()
902
+ }).transform(({ type, owner, claims, paginationInfo, count }) => ({
903
+ type,
904
+ operations: [
905
+ rejectPendingClaimsByOwner(owner),
906
+ {
907
+ opType: "arrayPush",
908
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsItems,
909
+ items: claims
910
+ },
911
+ {
912
+ opType: "primitiveSet",
913
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsPagination,
914
+ value: paginationInfo
915
+ },
916
+ {
917
+ opType: "recordSet",
918
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsCountByOwner,
919
+ key: owner,
920
+ value: count ?? paginationInfo.total
921
+ }
922
+ ]
923
+ }));
924
+ var upsertPendingClaimsSchema = z6.object({
925
+ type: z6.literal(stellarStateCallTypes.upsertPendingClaims),
926
+ claims: z6.array(pendingClaimBridgeItemSchema)
927
+ }).transform(({ type, claims }) => ({
928
+ type,
929
+ operations: [
930
+ rejectPendingClaimsByIds(claims.map((claim) => claim.id)),
931
+ {
932
+ opType: "arrayPush",
933
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsItems,
934
+ items: claims
935
+ }
936
+ ]
937
+ }));
938
+ var removePendingClaimsSchema = z6.object({
939
+ type: z6.literal(stellarStateCallTypes.removePendingClaims),
940
+ ids: z6.array(z6.string().min(1))
941
+ }).transform(({ type, ids }) => ({
942
+ type,
943
+ operations: [rejectPendingClaimsByIds(ids)]
944
+ }));
945
+ var readPendingClaimsCountSchema = z6.object({
946
+ type: z6.literal(stellarStateCallTypes.readPendingClaimsCount),
947
+ owner: z6.string().min(1)
948
+ }).transform(({ type, owner }) => ({
949
+ type,
950
+ operations: [
951
+ {
952
+ opType: "recordGet",
953
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsCountByOwner,
954
+ key: owner
955
+ }
956
+ ]
957
+ }));
958
+ var setPendingClaimsCountSchema = z6.object({
959
+ type: z6.literal(stellarStateCallTypes.setPendingClaimsCount),
960
+ owner: z6.string().min(1),
961
+ count: z6.number().int().nonnegative()
962
+ }).transform(({ type, owner, count }) => ({
963
+ type,
964
+ operations: [
965
+ {
966
+ opType: "recordSet",
967
+ jsonPath: STELLAR_STATE_PATHS.pendingClaimsCountByOwner,
968
+ key: owner,
969
+ value: count
970
+ }
971
+ ]
972
+ }));
973
+
974
+ // src/state/definitions/claims.ts
975
+ var stellarClaimsStateDefinitions = [
976
+ {
977
+ type: stellarStateCallTypes.pendingClaims,
978
+ mode: "write",
979
+ schema: pendingClaimsWriteSchema
980
+ },
981
+ {
982
+ type: stellarStateCallTypes.clearPendingClaims,
983
+ mode: "write",
984
+ schema: clearPendingClaimsSchema
985
+ },
986
+ {
987
+ type: stellarStateCallTypes.readPendingClaims,
988
+ mode: "read",
989
+ schema: readPendingClaimsSchema
990
+ },
991
+ {
992
+ type: stellarStateCallTypes.replacePendingClaimsPage,
993
+ mode: "write",
994
+ schema: replacePendingClaimsPageSchema
995
+ },
996
+ {
997
+ type: stellarStateCallTypes.upsertPendingClaims,
998
+ mode: "write",
999
+ schema: upsertPendingClaimsSchema
1000
+ },
1001
+ {
1002
+ type: stellarStateCallTypes.removePendingClaims,
1003
+ mode: "write",
1004
+ schema: removePendingClaimsSchema
1005
+ },
1006
+ {
1007
+ type: stellarStateCallTypes.readPendingClaimsCount,
1008
+ mode: "read",
1009
+ schema: readPendingClaimsCountSchema
1010
+ },
1011
+ {
1012
+ type: stellarStateCallTypes.setPendingClaimsCount,
1013
+ mode: "write",
1014
+ schema: setPendingClaimsCountSchema
1015
+ }
1016
+ ];
1017
+
1018
+ // src/state/schemas/claims/deliveries.ts
1019
+ import { z as z7 } from "zod";
1020
+ var readIncomingDeliveriesSchema = z7.object({
1021
+ type: z7.literal(stellarStateCallTypes.readIncomingDeliveries)
1022
+ }).transform(({ type }) => ({
1023
+ type,
1024
+ operations: [
1025
+ {
1026
+ opType: "primitiveGet",
1027
+ jsonPath: STELLAR_STATE_PATHS.deliveriesIncomingById
1028
+ }
1029
+ ]
1030
+ }));
1031
+ var upsertIncomingDeliveriesSchema = z7.object({
1032
+ type: z7.literal(stellarStateCallTypes.upsertIncomingDeliveries),
1033
+ deliveries: z7.array(incomingDeliverySchema)
1034
+ }).transform(({ type, deliveries }) => ({
1035
+ type,
1036
+ operations: deliveries.map((delivery) => ({
1037
+ opType: "recordSet",
1038
+ jsonPath: STELLAR_STATE_PATHS.deliveriesIncomingById,
1039
+ key: String(delivery.id),
1040
+ value: delivery
1041
+ }))
1042
+ }));
1043
+ var readDeliverySyncStateSchema = z7.object({
1044
+ type: z7.literal(stellarStateCallTypes.readDeliverySyncState),
1045
+ privateAddress: z7.string().min(1),
1046
+ asset: z7.string().min(1)
1047
+ }).transform(({ type, privateAddress, asset }) => ({
1048
+ type,
1049
+ operations: [
1050
+ {
1051
+ opType: "recordGet",
1052
+ jsonPath: STELLAR_STATE_PATHS.deliveriesSync,
1053
+ key: privateAddressAssetKey(privateAddress, asset)
1054
+ }
1055
+ ]
1056
+ }));
1057
+ var setDeliverySyncStateSchema = z7.object({
1058
+ type: z7.literal(stellarStateCallTypes.setDeliverySyncState),
1059
+ syncState: deliverySyncStateSchema
1060
+ }).transform(({ type, syncState }) => ({
1061
+ type,
1062
+ operations: [
1063
+ {
1064
+ opType: "recordSet",
1065
+ jsonPath: STELLAR_STATE_PATHS.deliveriesSync,
1066
+ key: privateAddressAssetKey(syncState.privateAddress, syncState.asset),
1067
+ value: syncState
1068
+ }
1069
+ ]
1070
+ }));
1071
+
1072
+ // src/state/definitions/deliveries.ts
1073
+ var stellarDeliveriesStateDefinitions = [
1074
+ {
1075
+ type: stellarStateCallTypes.readIncomingDeliveries,
1076
+ mode: "read",
1077
+ schema: readIncomingDeliveriesSchema
1078
+ },
1079
+ {
1080
+ type: stellarStateCallTypes.upsertIncomingDeliveries,
1081
+ mode: "write",
1082
+ schema: upsertIncomingDeliveriesSchema
1083
+ },
1084
+ {
1085
+ type: stellarStateCallTypes.readDeliverySyncState,
1086
+ mode: "read",
1087
+ schema: readDeliverySyncStateSchema
1088
+ },
1089
+ {
1090
+ type: stellarStateCallTypes.setDeliverySyncState,
1091
+ mode: "write",
1092
+ schema: setDeliverySyncStateSchema
1093
+ }
1094
+ ];
1095
+
1096
+ // src/state/schemas/pool/merkle.ts
1097
+ import { z as z8 } from "zod";
1098
+ var readPoolMerkleStateSchema = z8.object({
1099
+ type: z8.literal(stellarStateCallTypes.readPoolMerkleState),
1100
+ poolContract: z8.string().min(1)
1101
+ }).transform(({ type, poolContract }) => ({
1102
+ type,
1103
+ operations: [
1104
+ {
1105
+ opType: "recordGet",
1106
+ jsonPath: STELLAR_STATE_PATHS.poolsByContract,
1107
+ key: poolContract
1108
+ }
1109
+ ]
1110
+ }));
1111
+ var setPoolMerkleStateSchema = z8.object({
1112
+ type: z8.literal(stellarStateCallTypes.setPoolMerkleState),
1113
+ state: poolMerkleStateSchema
1114
+ }).transform(({ type, state }) => ({
1115
+ type,
1116
+ operations: [
1117
+ {
1118
+ opType: "recordSet",
1119
+ jsonPath: STELLAR_STATE_PATHS.poolsByContract,
1120
+ key: state.poolContract,
1121
+ value: state
1122
+ }
1123
+ ]
1124
+ }));
1125
+ var readLeafEphemeralSchema = z8.object({
1126
+ type: z8.literal(stellarStateCallTypes.readLeafEphemeral),
1127
+ poolContract: z8.string().min(1),
1128
+ leafIndex: z8.number().int().nonnegative()
1129
+ }).transform(({ type, poolContract, leafIndex }) => ({
1130
+ type,
1131
+ operations: [
1132
+ {
1133
+ opType: "recordGet",
1134
+ jsonPath: STELLAR_STATE_PATHS.poolsLeafEphemeral,
1135
+ key: poolLeafKey(poolContract, leafIndex)
1136
+ }
1137
+ ]
1138
+ }));
1139
+ var setLeafEphemeralSchema = z8.object({
1140
+ type: z8.literal(stellarStateCallTypes.setLeafEphemeral),
1141
+ ephemeral: leafEphemeralSchema
1142
+ }).transform(({ type, ephemeral }) => ({
1143
+ type,
1144
+ operations: [
1145
+ {
1146
+ opType: "recordSet",
1147
+ jsonPath: STELLAR_STATE_PATHS.poolsLeafEphemeral,
1148
+ key: poolLeafKey(ephemeral.poolContract, ephemeral.leafIndex),
1149
+ value: ephemeral
1150
+ }
1151
+ ]
1152
+ }));
1153
+
1154
+ // src/state/definitions/pool.ts
1155
+ var stellarPoolStateDefinitions = [
1156
+ {
1157
+ type: stellarStateCallTypes.readPoolMerkleState,
1158
+ mode: "read",
1159
+ schema: readPoolMerkleStateSchema
1160
+ },
1161
+ {
1162
+ type: stellarStateCallTypes.setPoolMerkleState,
1163
+ mode: "write",
1164
+ schema: setPoolMerkleStateSchema
1165
+ },
1166
+ {
1167
+ type: stellarStateCallTypes.readLeafEphemeral,
1168
+ mode: "read",
1169
+ schema: readLeafEphemeralSchema
1170
+ },
1171
+ {
1172
+ type: stellarStateCallTypes.setLeafEphemeral,
1173
+ mode: "write",
1174
+ schema: setLeafEphemeralSchema
1175
+ }
1176
+ ];
1177
+
1178
+ // src/state/schemas/records/private.ts
1179
+ import { z as z9 } from "zod";
1180
+ var listPrivateRecordsSchema = z9.object({
1181
+ type: z9.literal(stellarStateCallTypes.listPrivateRecords)
1182
+ }).transform(({ type }) => ({
1183
+ type,
1184
+ operations: [
1185
+ {
1186
+ opType: "primitiveGet",
1187
+ jsonPath: STELLAR_STATE_PATHS.privateRecords
1188
+ }
1189
+ ]
1190
+ }));
1191
+ var savePrivateRecordsSchema = z9.object({
1192
+ type: z9.literal(stellarStateCallTypes.savePrivateRecords),
1193
+ records: z9.array(privateRecordSchema)
1194
+ }).transform(({ type, records }) => ({
1195
+ type,
1196
+ operations: [
1197
+ {
1198
+ opType: "arrayPush",
1199
+ jsonPath: STELLAR_STATE_PATHS.privateRecords,
1200
+ items: records
1201
+ }
1202
+ ]
1203
+ }));
1204
+ var replacePrivateRecordsSchema = z9.object({
1205
+ type: z9.literal(stellarStateCallTypes.replacePrivateRecords),
1206
+ records: z9.array(privateRecordSchema)
1207
+ }).transform(({ type, records }) => ({
1208
+ type,
1209
+ operations: [
1210
+ {
1211
+ opType: "arrayClean",
1212
+ jsonPath: STELLAR_STATE_PATHS.privateRecords
1213
+ },
1214
+ {
1215
+ opType: "arrayPush",
1216
+ jsonPath: STELLAR_STATE_PATHS.privateRecords,
1217
+ items: records
1218
+ }
1219
+ ]
1220
+ }));
1221
+ var pruneConsumedPrivateRecordsSchema = z9.object({
1222
+ type: z9.literal(stellarStateCallTypes.pruneConsumedPrivateRecords)
1223
+ }).transform(({ type }) => ({
1224
+ type,
1225
+ operations: [rejectConsumedPrivateRecords()]
1226
+ }));
1227
+
1228
+ // src/state/schemas/records/transactions.ts
1229
+ import { z as z10 } from "zod";
1230
+ var upsertPrivateRecordsSchema = z10.object({
1231
+ type: z10.literal(stellarStateCallTypes.upsertPrivateRecords),
1232
+ records: z10.array(privateRecordSchema)
1233
+ }).transform(({ type, records }) => ({
1234
+ type,
1235
+ operations: [
1236
+ rejectPrivateRecordsByIds(records.map((record) => record.id)),
1237
+ {
1238
+ opType: "arrayPush",
1239
+ jsonPath: STELLAR_STATE_PATHS.privateRecords,
1240
+ items: records
1241
+ }
1242
+ ]
1243
+ }));
1244
+ var readTransactionStatusSchema = z10.object({
1245
+ type: z10.literal(stellarStateCallTypes.readTransactionStatus),
1246
+ txHash: z10.string().min(1)
1247
+ }).transform(({ type, txHash }) => ({
1248
+ type,
1249
+ operations: [
1250
+ {
1251
+ opType: "recordGet",
1252
+ jsonPath: STELLAR_STATE_PATHS.transactionsByHash,
1253
+ key: txHash
1254
+ }
1255
+ ]
1256
+ }));
1257
+ var setTransactionStatusSchema = z10.object({
1258
+ type: z10.literal(stellarStateCallTypes.setTransactionStatus),
1259
+ status: transactionStatusSchema
1260
+ }).transform(({ type, status }) => ({
1261
+ type,
1262
+ operations: [
1263
+ {
1264
+ opType: "recordSet",
1265
+ jsonPath: STELLAR_STATE_PATHS.transactionsByHash,
1266
+ key: status.txHash,
1267
+ value: status
1268
+ }
1269
+ ]
1270
+ }));
1271
+ var clearTransactionStatusSchema = z10.object({
1272
+ type: z10.literal(stellarStateCallTypes.clearTransactionStatus),
1273
+ txHash: z10.string().min(1)
1274
+ }).transform(({ type, txHash }) => ({
1275
+ type,
1276
+ operations: [
1277
+ {
1278
+ opType: "recordDelete",
1279
+ jsonPath: STELLAR_STATE_PATHS.transactionsByHash,
1280
+ key: txHash
1281
+ }
1282
+ ]
1283
+ }));
1284
+
1285
+ // src/state/definitions/records.ts
1286
+ var stellarRecordsStateDefinitions = [
1287
+ {
1288
+ type: stellarStateCallTypes.listPrivateRecords,
1289
+ mode: "read",
1290
+ schema: listPrivateRecordsSchema
1291
+ },
1292
+ {
1293
+ type: stellarStateCallTypes.savePrivateRecords,
1294
+ mode: "write",
1295
+ schema: savePrivateRecordsSchema
1296
+ },
1297
+ {
1298
+ type: stellarStateCallTypes.replacePrivateRecords,
1299
+ mode: "write",
1300
+ schema: replacePrivateRecordsSchema
1301
+ },
1302
+ {
1303
+ type: stellarStateCallTypes.upsertPrivateRecords,
1304
+ mode: "write",
1305
+ schema: upsertPrivateRecordsSchema
1306
+ },
1307
+ {
1308
+ type: stellarStateCallTypes.pruneConsumedPrivateRecords,
1309
+ mode: "write",
1310
+ schema: pruneConsumedPrivateRecordsSchema
1311
+ }
1312
+ ];
1313
+
1314
+ // src/state/schemas/registry/lookup.ts
1315
+ import { z as z11 } from "zod";
1316
+ var readStellarAddressRegisteredSchema = z11.object({
1317
+ type: z11.literal(stellarStateCallTypes.readStellarAddressRegistered),
1318
+ address: z11.string().min(1)
1319
+ }).transform(({ type, address }) => ({
1320
+ type,
1321
+ operations: [
1322
+ {
1323
+ opType: "recordGet",
1324
+ jsonPath: STELLAR_STATE_PATHS.registryRegisteredAddresses,
1325
+ key: address
1326
+ }
1327
+ ]
1328
+ }));
1329
+ var readCachedPrivateAddressSchema = z11.object({
1330
+ type: z11.literal(stellarStateCallTypes.readCachedPrivateAddress),
1331
+ address: z11.string().min(1)
1332
+ }).transform(({ type, address }) => ({
1333
+ type,
1334
+ operations: [
1335
+ {
1336
+ opType: "recordGet",
1337
+ jsonPath: STELLAR_STATE_PATHS.registryPrivateAddresses,
1338
+ key: address
1339
+ }
1340
+ ]
1341
+ }));
1342
+ var saveRegisteredPrivateAddressSchema = z11.object({
1343
+ type: z11.literal(stellarStateCallTypes.saveRegisteredPrivateAddress),
1344
+ address: z11.string().min(1),
1345
+ privateAddress: z11.string().min(1),
1346
+ registered: z11.boolean()
1347
+ }).transform(({ type, address, privateAddress, registered: registered2 }) => {
1348
+ const lookup = registryLookupSchema.parse({
1349
+ owner: address,
1350
+ status: registered2 ? "registered" : "unregistered",
1351
+ privateAddressStpl1: registered2 ? privateAddress : void 0,
1352
+ cachedAt: (/* @__PURE__ */ new Date()).toISOString()
1353
+ });
1354
+ return {
1355
+ type,
1356
+ operations: [
1357
+ {
1358
+ opType: "recordSet",
1359
+ jsonPath: STELLAR_STATE_PATHS.registryPrivateAddresses,
1360
+ key: address,
1361
+ value: privateAddress
1362
+ },
1363
+ {
1364
+ opType: "recordSet",
1365
+ jsonPath: STELLAR_STATE_PATHS.registryRegisteredAddresses,
1366
+ key: address,
1367
+ value: registered2
1368
+ },
1369
+ {
1370
+ opType: "recordSet",
1371
+ jsonPath: STELLAR_STATE_PATHS.registryLookups,
1372
+ key: address,
1373
+ value: lookup
1374
+ }
1375
+ ]
1376
+ };
1377
+ });
1378
+ var invalidateRegisteredAddressSchema = z11.object({
1379
+ type: z11.literal(stellarStateCallTypes.invalidateRegisteredAddress),
1380
+ address: z11.string().min(1)
1381
+ }).transform(({ type, address }) => ({
1382
+ type,
1383
+ operations: [
1384
+ {
1385
+ opType: "recordDelete",
1386
+ jsonPath: STELLAR_STATE_PATHS.registryPrivateAddresses,
1387
+ key: address
1388
+ },
1389
+ {
1390
+ opType: "recordDelete",
1391
+ jsonPath: STELLAR_STATE_PATHS.registryRegisteredAddresses,
1392
+ key: address
1393
+ },
1394
+ {
1395
+ opType: "recordDelete",
1396
+ jsonPath: STELLAR_STATE_PATHS.registryLookups,
1397
+ key: address
1398
+ }
1399
+ ]
1400
+ }));
1401
+ var readRegistryLookupSchema = z11.object({
1402
+ type: z11.literal(stellarStateCallTypes.readRegistryLookup),
1403
+ address: z11.string().min(1)
1404
+ }).transform(({ type, address }) => ({
1405
+ type,
1406
+ operations: [
1407
+ {
1408
+ opType: "recordGet",
1409
+ jsonPath: STELLAR_STATE_PATHS.registryLookups,
1410
+ key: address
1411
+ }
1412
+ ]
1413
+ }));
1414
+ var saveRegistryLookupSchema = z11.object({
1415
+ type: z11.literal(stellarStateCallTypes.saveRegistryLookup),
1416
+ lookup: registryLookupSchema
1417
+ }).transform(({ type, lookup }) => {
1418
+ const operations = [
1419
+ {
1420
+ opType: "recordSet",
1421
+ jsonPath: STELLAR_STATE_PATHS.registryLookups,
1422
+ key: lookup.owner,
1423
+ value: lookup
1424
+ }
1425
+ ];
1426
+ if (lookup.status === "registered" && lookup.privateAddressStpl1) {
1427
+ operations.push(
1428
+ {
1429
+ opType: "recordSet",
1430
+ jsonPath: STELLAR_STATE_PATHS.registryPrivateAddresses,
1431
+ key: lookup.owner,
1432
+ value: lookup.privateAddressStpl1
1433
+ },
1434
+ {
1435
+ opType: "recordSet",
1436
+ jsonPath: STELLAR_STATE_PATHS.registryRegisteredAddresses,
1437
+ key: lookup.owner,
1438
+ value: true
1439
+ }
1440
+ );
1441
+ } else {
1442
+ operations.push({
1443
+ opType: "recordSet",
1444
+ jsonPath: STELLAR_STATE_PATHS.registryRegisteredAddresses,
1445
+ key: lookup.owner,
1446
+ value: false
1447
+ });
1448
+ }
1449
+ return { type, operations };
1450
+ });
1451
+ var invalidateRegistryLookupSchema = z11.object({
1452
+ type: z11.literal(stellarStateCallTypes.invalidateRegistryLookup),
1453
+ address: z11.string().min(1)
1454
+ }).transform(({ type, address }) => ({
1455
+ type,
1456
+ operations: [
1457
+ {
1458
+ opType: "recordDelete",
1459
+ jsonPath: STELLAR_STATE_PATHS.registryLookups,
1460
+ key: address
1461
+ },
1462
+ {
1463
+ opType: "recordDelete",
1464
+ jsonPath: STELLAR_STATE_PATHS.registryPrivateAddresses,
1465
+ key: address
1466
+ },
1467
+ {
1468
+ opType: "recordDelete",
1469
+ jsonPath: STELLAR_STATE_PATHS.registryRegisteredAddresses,
1470
+ key: address
1471
+ }
1472
+ ]
1473
+ }));
1474
+
1475
+ // src/state/definitions/registry.ts
1476
+ var stellarRegistryStateDefinitions = [
1477
+ {
1478
+ type: stellarStateCallTypes.readStellarAddressRegistered,
1479
+ mode: "read",
1480
+ schema: readStellarAddressRegisteredSchema
1481
+ },
1482
+ {
1483
+ type: stellarStateCallTypes.readCachedPrivateAddress,
1484
+ mode: "read",
1485
+ schema: readCachedPrivateAddressSchema
1486
+ },
1487
+ {
1488
+ type: stellarStateCallTypes.readRegistryLookup,
1489
+ mode: "read",
1490
+ schema: readRegistryLookupSchema
1491
+ },
1492
+ {
1493
+ type: stellarStateCallTypes.saveRegisteredPrivateAddress,
1494
+ mode: "write",
1495
+ schema: saveRegisteredPrivateAddressSchema
1496
+ },
1497
+ {
1498
+ type: stellarStateCallTypes.saveRegistryLookup,
1499
+ mode: "write",
1500
+ schema: saveRegistryLookupSchema
1501
+ },
1502
+ {
1503
+ type: stellarStateCallTypes.invalidateRegisteredAddress,
1504
+ mode: "write",
1505
+ schema: invalidateRegisteredAddressSchema
1506
+ },
1507
+ {
1508
+ type: stellarStateCallTypes.invalidateRegistryLookup,
1509
+ mode: "write",
1510
+ schema: invalidateRegistryLookupSchema
1511
+ }
1512
+ ];
1513
+
1514
+ // src/state/definitions/transactions.ts
1515
+ var stellarTransactionStateDefinitions = [
1516
+ {
1517
+ type: stellarStateCallTypes.readTransactionStatus,
1518
+ mode: "read",
1519
+ schema: readTransactionStatusSchema
1520
+ },
1521
+ {
1522
+ type: stellarStateCallTypes.setTransactionStatus,
1523
+ mode: "write",
1524
+ schema: setTransactionStatusSchema
1525
+ },
1526
+ {
1527
+ type: stellarStateCallTypes.clearTransactionStatus,
1528
+ mode: "write",
1529
+ schema: clearTransactionStatusSchema
1530
+ }
1531
+ ];
1532
+
1533
+ // src/state/schemas/wallet/scalar.ts
1534
+ import { z as z12 } from "zod";
1535
+ var saveWalletPrivateAddressScalarSchema = z12.object({
1536
+ type: z12.literal(stellarStateCallTypes.saveWalletPrivateAddressScalar),
1537
+ scalar: walletPrivateAddressScalarSchema
1538
+ }).transform(({ type, scalar }) => ({
1539
+ type,
1540
+ operations: [
1541
+ {
1542
+ opType: "recordSet",
1543
+ jsonPath: STELLAR_STATE_PATHS.walletPrivateAddressScalars,
1544
+ key: walletOwnerNonceKey(scalar.owner, scalar.nonce),
1545
+ value: scalar
1546
+ }
1547
+ ]
1548
+ }));
1549
+ var readWalletPrivateAddressScalarSchema = z12.object({
1550
+ type: z12.literal(stellarStateCallTypes.readWalletPrivateAddressScalar),
1551
+ owner: z12.string().min(1),
1552
+ nonce: z12.string().min(1)
1553
+ }).transform(({ type, owner, nonce }) => ({
1554
+ type,
1555
+ operations: [
1556
+ {
1557
+ opType: "recordGet",
1558
+ jsonPath: STELLAR_STATE_PATHS.walletPrivateAddressScalars,
1559
+ key: walletOwnerNonceKey(owner, nonce)
1560
+ }
1561
+ ]
1562
+ }));
1563
+
1564
+ // src/state/schemas/wallet/private-address.ts
1565
+ import { z as z13 } from "zod";
1566
+ var saveWalletPrivateAddressRecordSchema = z13.object({
1567
+ type: z13.literal(stellarStateCallTypes.saveWalletPrivateAddressRecord),
1568
+ record: walletPrivateAddressRecordSchema
1569
+ }).transform(({ type, record }) => ({
1570
+ type,
1571
+ operations: [
1572
+ {
1573
+ opType: "recordSet",
1574
+ jsonPath: STELLAR_STATE_PATHS.walletPrivateAddressRecords,
1575
+ key: walletOwnerNonceKey(record.owner, record.nonce),
1576
+ value: record
1577
+ }
1578
+ ]
1579
+ }));
1580
+ var readWalletPrivateAddressRecordSchema = z13.object({
1581
+ type: z13.literal(stellarStateCallTypes.readWalletPrivateAddressRecord),
1582
+ owner: z13.string().min(1),
1583
+ nonce: z13.string().min(1)
1584
+ }).transform(({ type, owner, nonce }) => ({
1585
+ type,
1586
+ operations: [
1587
+ {
1588
+ opType: "recordGet",
1589
+ jsonPath: STELLAR_STATE_PATHS.walletPrivateAddressRecords,
1590
+ key: walletOwnerNonceKey(owner, nonce)
1591
+ }
1592
+ ]
1593
+ }));
1594
+ var setWalletDefaultPrivateAddressNonceSchema = z13.object({
1595
+ type: z13.literal(stellarStateCallTypes.setWalletDefaultPrivateAddressNonce),
1596
+ owner: z13.string().min(1),
1597
+ nonce: z13.string().min(1)
1598
+ }).transform(({ type, owner, nonce }) => ({
1599
+ type,
1600
+ operations: [
1601
+ {
1602
+ opType: "recordSet",
1603
+ jsonPath: STELLAR_STATE_PATHS.walletDefaultPrivateAddressNonce,
1604
+ key: owner,
1605
+ value: nonce
1606
+ }
1607
+ ]
1608
+ }));
1609
+ var readWalletDefaultPrivateAddressNonceSchema = z13.object({
1610
+ type: z13.literal(stellarStateCallTypes.readWalletDefaultPrivateAddressNonce),
1611
+ owner: z13.string().min(1)
1612
+ }).transform(({ type, owner }) => ({
1613
+ type,
1614
+ operations: [
1615
+ {
1616
+ opType: "recordGet",
1617
+ jsonPath: STELLAR_STATE_PATHS.walletDefaultPrivateAddressNonce,
1618
+ key: owner
1619
+ }
1620
+ ]
1621
+ }));
1622
+ var deleteWalletPrivateAddressScalarSchema = z13.object({
1623
+ type: z13.literal(stellarStateCallTypes.deleteWalletPrivateAddressScalar),
1624
+ owner: z13.string().min(1),
1625
+ nonce: z13.string().min(1)
1626
+ }).transform(({ type, owner, nonce }) => ({
1627
+ type,
1628
+ operations: [
1629
+ {
1630
+ opType: "recordDelete",
1631
+ jsonPath: STELLAR_STATE_PATHS.walletPrivateAddressScalars,
1632
+ key: walletOwnerNonceKey(owner, nonce)
1633
+ }
1634
+ ]
1635
+ }));
1636
+
1637
+ // src/state/definitions/wallet.ts
1638
+ var stellarWalletStateDefinitions = [
1639
+ {
1640
+ type: stellarStateCallTypes.saveWalletPrivateAddressScalar,
1641
+ mode: "write",
1642
+ schema: saveWalletPrivateAddressScalarSchema
1643
+ },
1644
+ {
1645
+ type: stellarStateCallTypes.readWalletPrivateAddressScalar,
1646
+ mode: "read",
1647
+ schema: readWalletPrivateAddressScalarSchema
1648
+ },
1649
+ {
1650
+ type: stellarStateCallTypes.saveWalletPrivateAddressRecord,
1651
+ mode: "write",
1652
+ schema: saveWalletPrivateAddressRecordSchema
1653
+ },
1654
+ {
1655
+ type: stellarStateCallTypes.readWalletPrivateAddressRecord,
1656
+ mode: "read",
1657
+ schema: readWalletPrivateAddressRecordSchema
1658
+ },
1659
+ {
1660
+ type: stellarStateCallTypes.setWalletDefaultPrivateAddressNonce,
1661
+ mode: "write",
1662
+ schema: setWalletDefaultPrivateAddressNonceSchema
1663
+ },
1664
+ {
1665
+ type: stellarStateCallTypes.readWalletDefaultPrivateAddressNonce,
1666
+ mode: "read",
1667
+ schema: readWalletDefaultPrivateAddressNonceSchema
1668
+ },
1669
+ {
1670
+ type: stellarStateCallTypes.deleteWalletPrivateAddressScalar,
1671
+ mode: "write",
1672
+ schema: deleteWalletPrivateAddressScalarSchema
1673
+ }
1674
+ ];
1675
+
1676
+ // src/state/definitions/index.ts
1677
+ registerStellarArrayFilterSchemas();
1678
+ var stellarStateDefinitions = [
1679
+ ...stellarClaimsStateDefinitions,
1680
+ ...stellarRegistryStateDefinitions,
1681
+ ...stellarAssetsStateDefinitions,
1682
+ ...stellarBalancesStateDefinitions,
1683
+ ...stellarPoolStateDefinitions,
1684
+ ...stellarRecordsStateDefinitions,
1685
+ ...stellarDeliveriesStateDefinitions,
1686
+ ...stellarWalletStateDefinitions,
1687
+ ...stellarTransactionStateDefinitions
1688
+ ];
1689
+
1690
+ // src/state/service/base.ts
1691
+ import {
1692
+ createStateBridge
1693
+ } from "@arcanetech/privacy-sdk-core/state";
1694
+ var StellarStateServiceBase = class {
1695
+ bridge;
1696
+ constructor(adapter) {
1697
+ this.bridge = createStateBridge(adapter);
1698
+ this.bridge.init(stellarStateDefinitions);
1699
+ }
1700
+ };
1701
+
1702
+ // src/state/service/assets/balance-methods.ts
1703
+ function createPublicBalanceMethods(context) {
1704
+ const { bridge } = context;
1705
+ return {
1706
+ async getPublicBalance(input) {
1707
+ const value = await bridge.read({
1708
+ type: stellarStateCallTypes.readPublicBalance,
1709
+ owner: input.owner,
1710
+ asset: input.asset
1711
+ });
1712
+ return normalizePublicBalance(value);
1713
+ },
1714
+ async getPublicBalances(owner) {
1715
+ const entries = await bridge.read({
1716
+ type: stellarStateCallTypes.readPublicBalances,
1717
+ owner
1718
+ });
1719
+ return normalizePublicBalancesFromEntries(entries, owner);
1720
+ },
1721
+ setPublicBalance(balance) {
1722
+ return bridge.write({
1723
+ type: stellarStateCallTypes.setPublicBalance,
1724
+ balance
1725
+ });
1726
+ },
1727
+ setPublicBalances(input) {
1728
+ return bridge.write({
1729
+ type: stellarStateCallTypes.setPublicBalances,
1730
+ owner: input.owner,
1731
+ balances: input.balances
1732
+ });
1733
+ }
1734
+ };
1735
+ }
1736
+
1737
+ // src/state/service/assets/upsert-methods.ts
1738
+ function createAssetsUpsertMethods(_context, deps) {
1739
+ return {
1740
+ async upsertAssets(assets) {
1741
+ if (assets.length === 0) {
1742
+ return;
1743
+ }
1744
+ const catalog = await deps.getAssetsCatalog();
1745
+ const byId = { ...catalog.byId };
1746
+ const listOrder = [...catalog.listOrder];
1747
+ for (const asset of assets) {
1748
+ byId[asset.assetId] = asset;
1749
+ if (!listOrder.includes(asset.assetId)) {
1750
+ listOrder.push(asset.assetId);
1751
+ }
1752
+ }
1753
+ const merged = listOrder.map((assetId) => readRecordValue2(byId, assetId)).filter((asset) => asset !== void 0);
1754
+ await deps.replaceAssets(merged);
1755
+ }
1756
+ };
1757
+ }
1758
+
1759
+ // src/state/service/assets/catalog-methods.ts
1760
+ function createAssetsCatalogMethods(context) {
1761
+ const { bridge } = context;
1762
+ async function getAssetsCatalog() {
1763
+ const value = await bridge.read({
1764
+ type: stellarStateCallTypes.readAssetsCatalog
1765
+ });
1766
+ return normalizeAssetsCatalog(value);
1767
+ }
1768
+ function replaceAssets(assets) {
1769
+ return bridge.write({
1770
+ type: stellarStateCallTypes.replaceAssets,
1771
+ assets
1772
+ });
1773
+ }
1774
+ const coreMethods = {
1775
+ getAssetsCatalog,
1776
+ async getAsset(assetId) {
1777
+ const value = await bridge.read({
1778
+ type: stellarStateCallTypes.readAsset,
1779
+ assetId
1780
+ });
1781
+ return normalizeAsset(value);
1782
+ },
1783
+ async getAssets() {
1784
+ const catalog = await getAssetsCatalog();
1785
+ return catalog.listOrder.map((assetId) => readRecordValue2(catalog.byId, assetId)).filter((asset) => asset !== void 0);
1786
+ },
1787
+ async getAssetsForPool(poolContract) {
1788
+ const assets = await coreMethods.getAssets();
1789
+ return assets.filter((asset) => asset.poolContracts.includes(poolContract));
1790
+ },
1791
+ replaceAssets
1792
+ };
1793
+ return {
1794
+ ...coreMethods,
1795
+ ...createAssetsUpsertMethods(context, {
1796
+ getAssetsCatalog,
1797
+ replaceAssets
1798
+ })
1799
+ };
1800
+ }
1801
+
1802
+ // src/state/service/assets/index.ts
1803
+ function createAssetsService(context) {
1804
+ return {
1805
+ ...createAssetsCatalogMethods(context),
1806
+ ...createPublicBalanceMethods(context)
1807
+ };
1808
+ }
1809
+
1810
+ // src/state/service/claims/read-methods.ts
1811
+ function createClaimsReadMethods(context) {
1812
+ const { bridge } = context;
1813
+ async function getPendingClaims(filter = {}) {
1814
+ const value = await bridge.read({
1815
+ type: stellarStateCallTypes.readPendingClaims
1816
+ });
1817
+ const state = normalizePendingClaimsState(value);
1818
+ const items = state.items.filter((claim) => {
1819
+ if (filter.owner !== void 0 && claim.owner !== filter.owner) {
1820
+ return false;
1821
+ }
1822
+ if (filter.asset !== void 0 && claim.asset !== filter.asset) {
1823
+ return false;
1824
+ }
1825
+ return true;
1826
+ });
1827
+ if (state.pagination !== void 0) {
1828
+ return { items, pagination: state.pagination };
1829
+ }
1830
+ return { items };
1831
+ }
1832
+ return {
1833
+ getPendingClaims,
1834
+ async getPendingClaimsCount(owner) {
1835
+ const value = await bridge.read({
1836
+ type: stellarStateCallTypes.readPendingClaimsCount,
1837
+ owner
1838
+ });
1839
+ const count = normalizePendingClaimsCount(value);
1840
+ if (count !== void 0) {
1841
+ return count;
1842
+ }
1843
+ const claims = await getPendingClaims({ owner });
1844
+ return claims.items.length;
1845
+ }
1846
+ };
1847
+ }
1848
+
1849
+ // src/state/service/claims/write-methods.ts
1850
+ function appendPendingClaims(bridge, claims, paginationInfo) {
1851
+ return bridge.write({
1852
+ type: stellarStateCallTypes.pendingClaims,
1853
+ claims,
1854
+ paginationInfo
1855
+ });
1856
+ }
1857
+ function replacePendingClaimsPage(bridge, input) {
1858
+ return bridge.write({
1859
+ type: stellarStateCallTypes.replacePendingClaimsPage,
1860
+ owner: input.owner,
1861
+ claims: input.claims,
1862
+ paginationInfo: input.paginationInfo,
1863
+ ...input.count === void 0 ? {} : { count: input.count }
1864
+ });
1865
+ }
1866
+ function upsertPendingClaims(bridge, claims) {
1867
+ return bridge.write({
1868
+ type: stellarStateCallTypes.upsertPendingClaims,
1869
+ claims
1870
+ });
1871
+ }
1872
+ function removePendingClaims(bridge, ids) {
1873
+ return bridge.write({
1874
+ type: stellarStateCallTypes.removePendingClaims,
1875
+ ids
1876
+ });
1877
+ }
1878
+ function clearPendingClaims(bridge, input = {}) {
1879
+ return bridge.write({
1880
+ type: stellarStateCallTypes.clearPendingClaims,
1881
+ ...input.owner === void 0 ? {} : { owner: input.owner },
1882
+ ...input.asset === void 0 ? {} : { asset: input.asset }
1883
+ });
1884
+ }
1885
+ function setPendingClaimsCount(bridge, owner, count) {
1886
+ return bridge.write({
1887
+ type: stellarStateCallTypes.setPendingClaimsCount,
1888
+ owner,
1889
+ count
1890
+ });
1891
+ }
1892
+ function createClaimsWriteMethods(context) {
1893
+ const { bridge } = context;
1894
+ return {
1895
+ appendPendingClaims: (claims, paginationInfo) => appendPendingClaims(bridge, claims, paginationInfo),
1896
+ replacePendingClaimsPage: (input) => replacePendingClaimsPage(bridge, input),
1897
+ upsertPendingClaims: (claims) => upsertPendingClaims(bridge, claims),
1898
+ removePendingClaims: (ids) => removePendingClaims(bridge, ids),
1899
+ clearPendingClaims: (input = {}) => clearPendingClaims(bridge, input),
1900
+ setPendingClaimsCount: (owner, count) => setPendingClaimsCount(bridge, owner, count)
1901
+ };
1902
+ }
1903
+
1904
+ // src/state/service/claims/index.ts
1905
+ function createClaimsService(context) {
1906
+ return {
1907
+ ...createClaimsWriteMethods(context),
1908
+ ...createClaimsReadMethods(context)
1909
+ };
1910
+ }
1911
+
1912
+ // src/state/service/deliveries/incoming-methods.ts
1913
+ function createIncomingDeliveryMethods(context) {
1914
+ const { bridge } = context;
1915
+ async function getIncomingDeliveries(filter) {
1916
+ const values = await bridge.read({
1917
+ type: stellarStateCallTypes.readIncomingDeliveries
1918
+ });
1919
+ const deliveries = normalizeIncomingDeliveries(values);
1920
+ return deliveries.filter((delivery) => {
1921
+ if (delivery.privateAddress !== filter.privateAddress) {
1922
+ return false;
1923
+ }
1924
+ if (filter.asset !== void 0 && delivery.asset !== filter.asset) {
1925
+ return false;
1926
+ }
1927
+ if (!filter.includeProcessed && delivery.processed) {
1928
+ return false;
1929
+ }
1930
+ return true;
1931
+ });
1932
+ }
1933
+ function upsertIncomingDeliveries(deliveries) {
1934
+ return bridge.write({
1935
+ type: stellarStateCallTypes.upsertIncomingDeliveries,
1936
+ deliveries
1937
+ });
1938
+ }
1939
+ return {
1940
+ getIncomingDeliveries,
1941
+ upsertIncomingDeliveries,
1942
+ async markDeliveryProcessed(id) {
1943
+ const deliveries = await bridge.read({
1944
+ type: stellarStateCallTypes.readIncomingDeliveries
1945
+ });
1946
+ const match = normalizeIncomingDeliveries(deliveries).find(
1947
+ (delivery) => delivery.id === id
1948
+ );
1949
+ if (!match) {
1950
+ return;
1951
+ }
1952
+ await upsertIncomingDeliveries([{ ...match, processed: true }]);
1953
+ }
1954
+ };
1955
+ }
1956
+
1957
+ // src/state/service/deliveries/sync-methods.ts
1958
+ function createDeliverySyncMethods(context) {
1959
+ const { bridge } = context;
1960
+ return {
1961
+ async getDeliverySyncState(input) {
1962
+ const value = await bridge.read({
1963
+ type: stellarStateCallTypes.readDeliverySyncState,
1964
+ privateAddress: input.privateAddress,
1965
+ asset: input.asset
1966
+ });
1967
+ return normalizeDeliverySyncState(value);
1968
+ },
1969
+ setDeliverySyncState(syncState) {
1970
+ return bridge.write({
1971
+ type: stellarStateCallTypes.setDeliverySyncState,
1972
+ syncState
1973
+ });
1974
+ }
1975
+ };
1976
+ }
1977
+
1978
+ // src/state/service/deliveries/index.ts
1979
+ function createDeliveriesService(context) {
1980
+ return {
1981
+ ...createIncomingDeliveryMethods(context),
1982
+ ...createDeliverySyncMethods(context)
1983
+ };
1984
+ }
1985
+
1986
+ // src/state/service/pool/ephemeral.ts
1987
+ function isMissingStatePathError(error) {
1988
+ if (!(error instanceof Error)) {
1989
+ return false;
1990
+ }
1991
+ return error.message.includes("Record path not found:") || error.message.includes("JSONPath segment not found:");
1992
+ }
1993
+ function createPoolEphemeralService(context) {
1994
+ const { bridge } = context;
1995
+ return {
1996
+ async getLeafEphemeral(input) {
1997
+ try {
1998
+ const value = await bridge.read({
1999
+ type: stellarStateCallTypes.readLeafEphemeral,
2000
+ poolContract: input.poolContract,
2001
+ leafIndex: input.leafIndex
2002
+ });
2003
+ return normalizeLeafEphemeral(value);
2004
+ } catch (error) {
2005
+ if (isMissingStatePathError(error)) {
2006
+ return void 0;
2007
+ }
2008
+ throw error;
2009
+ }
2010
+ },
2011
+ setLeafEphemeral(ephemeral) {
2012
+ return bridge.write({
2013
+ type: stellarStateCallTypes.setLeafEphemeral,
2014
+ ephemeral
2015
+ });
2016
+ }
2017
+ };
2018
+ }
2019
+
2020
+ // src/state/service/pool/merkle.ts
2021
+ function isMissingStatePathError2(error) {
2022
+ if (!(error instanceof Error)) {
2023
+ return false;
2024
+ }
2025
+ return error.message.includes("Record path not found:") || error.message.includes("JSONPath segment not found:");
2026
+ }
2027
+ function createPoolMerkleService(context) {
2028
+ const { bridge } = context;
2029
+ return {
2030
+ async getPoolMerkleState(poolContract) {
2031
+ try {
2032
+ const value = await bridge.read({
2033
+ type: stellarStateCallTypes.readPoolMerkleState,
2034
+ poolContract
2035
+ });
2036
+ return normalizePoolMerkleState(value);
2037
+ } catch (error) {
2038
+ if (isMissingStatePathError2(error)) {
2039
+ return void 0;
2040
+ }
2041
+ throw error;
2042
+ }
2043
+ },
2044
+ setPoolMerkleState(state) {
2045
+ return bridge.write({
2046
+ type: stellarStateCallTypes.setPoolMerkleState,
2047
+ state
2048
+ });
2049
+ },
2050
+ async appendPoolCommitments(input) {
2051
+ const current = await this.getPoolMerkleState(input.poolContract);
2052
+ const mergedCommitments = [...current?.commitments ?? [], ...input.commitments];
2053
+ await this.setPoolMerkleState(
2054
+ withoutUndefinedFields({
2055
+ poolContract: input.poolContract,
2056
+ commitments: mergedCommitments,
2057
+ commitmentCount: mergedCommitments.length,
2058
+ merkleRootHex: input.merkleRootHex,
2059
+ updatedAt: Date.now(),
2060
+ syncedLedger: input.syncedLedger ?? current?.syncedLedger
2061
+ })
2062
+ );
2063
+ }
2064
+ };
2065
+ }
2066
+
2067
+ // src/state/service/records/private-record-upsert.ts
2068
+ function privateCoinNotesEqual(left, right) {
2069
+ if (left === void 0 || right === void 0) {
2070
+ return left === right;
2071
+ }
2072
+ return left.value === right.value && left.nullifier === right.nullifier && left.secret === right.secret && left.commitment === right.commitment && left.asset_hi === right.asset_hi && left.asset_lo === right.asset_lo && left.application_id === right.application_id;
2073
+ }
2074
+ function privateRecordCoreFieldsEqual(left, right) {
2075
+ return left.id === right.id && left.owner === right.owner && left.asset === right.asset && left.amount === right.amount && left.consumed === right.consumed && left.status === right.status && left.poolContract === right.poolContract && left.amountDisplay === right.amountDisplay;
2076
+ }
2077
+ function privateRecordChainFieldsEqual(left, right) {
2078
+ return left.commitmentHex === right.commitmentHex && left.nullifierHex === right.nullifierHex && left.deliveryId === right.deliveryId && left.privateAddress === right.privateAddress && left.txHash === right.txHash;
2079
+ }
2080
+ function privateRecordSecretFieldsEqual(left, right) {
2081
+ return left.depositScalarHex === right.depositScalarHex && left.precommitementHex === right.precommitementHex && privateCoinNotesEqual(left.coinNote, right.coinNote);
2082
+ }
2083
+ function privateRecordsEqual(left, right) {
2084
+ return privateRecordCoreFieldsEqual(left, right) && privateRecordChainFieldsEqual(left, right) && privateRecordSecretFieldsEqual(left, right);
2085
+ }
2086
+ function privateRecordArraysEqual(left, right) {
2087
+ return left.length === right.length && left.every((record, index) => {
2088
+ const rightRecord = right.at(index);
2089
+ return rightRecord !== void 0 && privateRecordsEqual(record, rightRecord);
2090
+ });
2091
+ }
2092
+ function mergePrivateRecords(current, records) {
2093
+ const ids = new Set(records.map((record) => record.id));
2094
+ return [...current.filter((record) => !ids.has(record.id)), ...records];
2095
+ }
2096
+
2097
+ // src/state/service/records/private-methods.ts
2098
+ async function readPrivateRecords(bridge) {
2099
+ const value = await bridge.read({
2100
+ type: stellarStateCallTypes.listPrivateRecords
2101
+ });
2102
+ return normalizePrivateRecords(value);
2103
+ }
2104
+ function writeReplacePrivateRecords(bridge, records) {
2105
+ return bridge.write({
2106
+ type: stellarStateCallTypes.replacePrivateRecords,
2107
+ records
2108
+ });
2109
+ }
2110
+ async function readAvailablePrivateRecords(bridge, filter) {
2111
+ const records = await readPrivateRecords(bridge);
2112
+ return records.filter((record) => matchesPrivateRecordFilter(record, filter, false));
2113
+ }
2114
+ async function applyPrivateRecordsStatus(bridge, records, status) {
2115
+ const current = await readPrivateRecords(bridge);
2116
+ const ids = new Set(records.map((record) => record.id));
2117
+ const next = current.map(
2118
+ (record) => ids.has(record.id) ? {
2119
+ ...record,
2120
+ status,
2121
+ consumed: status === "spent" ? true : record.consumed
2122
+ } : record
2123
+ );
2124
+ await writeReplacePrivateRecords(bridge, next);
2125
+ }
2126
+ function aggregatePrivateAssetRows(records, owner) {
2127
+ const available = records.filter(
2128
+ (record) => record.owner === owner && !record.consumed && record.status !== "spent"
2129
+ );
2130
+ const byAsset = /* @__PURE__ */ new Map();
2131
+ for (const record of available) {
2132
+ const existing = byAsset.get(record.asset);
2133
+ const amountDisplay = record.amountDisplay ?? Number(record.amount);
2134
+ if (existing) {
2135
+ existing.totalAmount += record.amount;
2136
+ existing.totalAmountDisplay += amountDisplay;
2137
+ } else {
2138
+ byAsset.set(record.asset, {
2139
+ assetId: record.asset,
2140
+ poolContract: record.poolContract ?? "",
2141
+ totalAmount: record.amount,
2142
+ totalAmountDisplay: amountDisplay
2143
+ });
2144
+ }
2145
+ }
2146
+ return [...byAsset.values()].toSorted(
2147
+ (left, right) => left.assetId.localeCompare(right.assetId)
2148
+ );
2149
+ }
2150
+ function pruneConsumedPrivateRecords(bridge) {
2151
+ return bridge.write({
2152
+ type: stellarStateCallTypes.pruneConsumedPrivateRecords
2153
+ });
2154
+ }
2155
+ function savePrivateRecords(bridge, records) {
2156
+ return bridge.write({
2157
+ type: stellarStateCallTypes.savePrivateRecords,
2158
+ records
2159
+ });
2160
+ }
2161
+ async function upsertPrivateRecords(bridge, records) {
2162
+ if (records.length === 0) {
2163
+ return;
2164
+ }
2165
+ const current = await readPrivateRecords(bridge);
2166
+ const next = mergePrivateRecords(current, records);
2167
+ if (privateRecordArraysEqual(current, next)) {
2168
+ return;
2169
+ }
2170
+ return bridge.write({
2171
+ type: stellarStateCallTypes.upsertPrivateRecords,
2172
+ records
2173
+ });
2174
+ }
2175
+ async function readPrivateBalance(bridge, input) {
2176
+ const records = await readAvailablePrivateRecords(bridge, {
2177
+ owner: input.owner,
2178
+ asset: input.asset
2179
+ });
2180
+ return records.reduce((total, record) => total + record.amount, 0n);
2181
+ }
2182
+ async function readPrivateAssetRows(bridge, owner) {
2183
+ const records = await readPrivateRecords(bridge);
2184
+ return aggregatePrivateAssetRows(records, owner);
2185
+ }
2186
+ function createPrivateRecordMethods(context) {
2187
+ const { bridge } = context;
2188
+ return {
2189
+ pruneConsumedPrivateRecords: () => pruneConsumedPrivateRecords(bridge),
2190
+ getPrivateRecords: () => readPrivateRecords(bridge),
2191
+ getAvailablePrivateRecords: (filter) => readAvailablePrivateRecords(bridge, filter),
2192
+ listPrivateRecords: (filter) => readAvailablePrivateRecords(bridge, filter),
2193
+ savePrivateRecords: (records) => savePrivateRecords(bridge, records),
2194
+ upsertPrivateRecords: (records) => upsertPrivateRecords(bridge, records),
2195
+ markPrivateRecordsUsed: (records) => applyPrivateRecordsStatus(bridge, records, "spent"),
2196
+ markPrivateRecordsStatus: (records, status) => applyPrivateRecordsStatus(bridge, records, status),
2197
+ getPrivateBalance: (input) => readPrivateBalance(bridge, input),
2198
+ getPrivateAssetRows: (owner) => readPrivateAssetRows(bridge, owner)
2199
+ };
2200
+ }
2201
+ function matchesPrivateRecordFilter(record, filter, includeConsumed) {
2202
+ if (filter.owner !== void 0 && record.owner !== filter.owner) {
2203
+ return false;
2204
+ }
2205
+ if (filter.privateAddress !== void 0 && record.privateAddress !== filter.privateAddress) {
2206
+ return false;
2207
+ }
2208
+ if (filter.owner === void 0 && filter.privateAddress === void 0) {
2209
+ return false;
2210
+ }
2211
+ if (filter.asset !== void 0 && record.asset !== filter.asset) {
2212
+ return false;
2213
+ }
2214
+ if (!includeConsumed && (record.consumed || record.status === "spent")) {
2215
+ return false;
2216
+ }
2217
+ return true;
2218
+ }
2219
+
2220
+ // src/state/service/records/transaction-methods.ts
2221
+ function createTransactionRecordMethods(context) {
2222
+ const { bridge } = context;
2223
+ return {
2224
+ async getTransactionStatus(txHash) {
2225
+ const value = await bridge.read({
2226
+ type: stellarStateCallTypes.readTransactionStatus,
2227
+ txHash
2228
+ });
2229
+ return normalizeTransactionStatus(value);
2230
+ },
2231
+ setTransactionStatus(status) {
2232
+ return bridge.write({
2233
+ type: stellarStateCallTypes.setTransactionStatus,
2234
+ status
2235
+ });
2236
+ },
2237
+ clearTransactionStatus(txHash) {
2238
+ return bridge.write({
2239
+ type: stellarStateCallTypes.clearTransactionStatus,
2240
+ txHash
2241
+ });
2242
+ }
2243
+ };
2244
+ }
2245
+
2246
+ // src/state/service/records/index.ts
2247
+ function createRecordsService(context) {
2248
+ return {
2249
+ ...createPrivateRecordMethods(context),
2250
+ ...createTransactionRecordMethods(context)
2251
+ };
2252
+ }
2253
+
2254
+ // src/state/service/registry/lookup-read.ts
2255
+ async function readRegistryLookup(bridge, address) {
2256
+ try {
2257
+ const value = await bridge.read({
2258
+ type: stellarStateCallTypes.readRegistryLookup,
2259
+ address
2260
+ });
2261
+ const lookup = normalizeRegistryLookup(value);
2262
+ if (lookup) {
2263
+ return lookup;
2264
+ }
2265
+ } catch {
2266
+ }
2267
+ let registered2;
2268
+ let privateAddress;
2269
+ try {
2270
+ registered2 = await bridge.read({
2271
+ type: stellarStateCallTypes.readStellarAddressRegistered,
2272
+ address
2273
+ });
2274
+ } catch {
2275
+ registered2 = void 0;
2276
+ }
2277
+ try {
2278
+ privateAddress = await bridge.read({
2279
+ type: stellarStateCallTypes.readCachedPrivateAddress,
2280
+ address
2281
+ });
2282
+ } catch {
2283
+ privateAddress = void 0;
2284
+ }
2285
+ return normalizeRegistryLookupFromLegacy({
2286
+ address,
2287
+ registered: registered2,
2288
+ privateAddress
2289
+ });
2290
+ }
2291
+ async function readCachedPrivateAddress(bridge, address) {
2292
+ const lookup = await readRegistryLookup(bridge, address);
2293
+ if (lookup?.privateAddressStpl1) {
2294
+ return lookup.privateAddressStpl1;
2295
+ }
2296
+ const value = await bridge.read({
2297
+ type: stellarStateCallTypes.readCachedPrivateAddress,
2298
+ address
2299
+ });
2300
+ return normalizeCachedPrivateAddress(value);
2301
+ }
2302
+ function createRegistryLookupReadMethods(context) {
2303
+ const { bridge } = context;
2304
+ return {
2305
+ getRegistryLookup: (address) => readRegistryLookup(bridge, address),
2306
+ async isStellarAddressRegistered(address) {
2307
+ const lookup = await readRegistryLookup(bridge, address);
2308
+ if (lookup === void 0) {
2309
+ return void 0;
2310
+ }
2311
+ return lookup.status === "registered";
2312
+ },
2313
+ getCachedPrivateAddress: (address) => readCachedPrivateAddress(bridge, address)
2314
+ };
2315
+ }
2316
+
2317
+ // src/state/service/registry/lookup-write.ts
2318
+ function createRegistryLookupWriteMethods(context) {
2319
+ const { bridge } = context;
2320
+ async function invalidateRegistryLookup(address) {
2321
+ return bridge.write({
2322
+ type: stellarStateCallTypes.invalidateRegistryLookup,
2323
+ address
2324
+ });
2325
+ }
2326
+ return {
2327
+ saveRegistryLookup(lookup) {
2328
+ return bridge.write({
2329
+ type: stellarStateCallTypes.saveRegistryLookup,
2330
+ lookup
2331
+ });
2332
+ },
2333
+ saveRegisteredPrivateAddress(input) {
2334
+ return bridge.write({
2335
+ type: stellarStateCallTypes.saveRegisteredPrivateAddress,
2336
+ address: input.address,
2337
+ privateAddress: input.privateAddress,
2338
+ registered: input.registered
2339
+ });
2340
+ },
2341
+ invalidateRegistryLookup,
2342
+ invalidateRegisteredAddress(address) {
2343
+ return invalidateRegistryLookup(address);
2344
+ }
2345
+ };
2346
+ }
2347
+
2348
+ // src/state/service/registry/lookup.ts
2349
+ function createRegistryLookupService(context) {
2350
+ return {
2351
+ ...createRegistryLookupReadMethods(context),
2352
+ ...createRegistryLookupWriteMethods(context)
2353
+ };
2354
+ }
2355
+
2356
+ // src/state/service/registry/wallet-record-methods.ts
2357
+ function createWalletRecordMethods(context) {
2358
+ const { bridge } = context;
2359
+ return {
2360
+ async getWalletPrivateAddressRecord(input) {
2361
+ const value = await bridge.read({
2362
+ type: stellarStateCallTypes.readWalletPrivateAddressRecord,
2363
+ owner: input.owner,
2364
+ nonce: input.nonce
2365
+ });
2366
+ return normalizeWalletPrivateAddressRecord(value);
2367
+ },
2368
+ saveWalletPrivateAddressRecord(record) {
2369
+ return bridge.write({
2370
+ type: stellarStateCallTypes.saveWalletPrivateAddressRecord,
2371
+ record
2372
+ });
2373
+ },
2374
+ async getWalletDefaultPrivateAddressNonce(owner) {
2375
+ const value = await bridge.read({
2376
+ type: stellarStateCallTypes.readWalletDefaultPrivateAddressNonce,
2377
+ owner
2378
+ });
2379
+ return normalizeWalletDefaultPrivateAddressNonce(value);
2380
+ },
2381
+ setWalletDefaultPrivateAddressNonce(input) {
2382
+ return bridge.write({
2383
+ type: stellarStateCallTypes.setWalletDefaultPrivateAddressNonce,
2384
+ owner: input.owner,
2385
+ nonce: input.nonce
2386
+ });
2387
+ }
2388
+ };
2389
+ }
2390
+
2391
+ // src/state/service/registry/wallet-scalar-methods.ts
2392
+ function createWalletScalarMethods(context) {
2393
+ const { bridge } = context;
2394
+ return {
2395
+ async getWalletPrivateAddressScalar(input) {
2396
+ const value = await bridge.read({
2397
+ type: stellarStateCallTypes.readWalletPrivateAddressScalar,
2398
+ owner: input.owner,
2399
+ nonce: input.nonce
2400
+ });
2401
+ return normalizeWalletPrivateAddressScalar(value);
2402
+ },
2403
+ saveWalletPrivateAddressScalar(scalar) {
2404
+ return bridge.write({
2405
+ type: stellarStateCallTypes.saveWalletPrivateAddressScalar,
2406
+ scalar
2407
+ });
2408
+ },
2409
+ deleteWalletPrivateAddressScalar(input) {
2410
+ return bridge.write({
2411
+ type: stellarStateCallTypes.deleteWalletPrivateAddressScalar,
2412
+ owner: input.owner,
2413
+ nonce: input.nonce
2414
+ });
2415
+ }
2416
+ };
2417
+ }
2418
+
2419
+ // src/state/service/registry/wallet-address.ts
2420
+ function createWalletAddressService(context) {
2421
+ return {
2422
+ ...createWalletScalarMethods(context),
2423
+ ...createWalletRecordMethods(context)
2424
+ };
2425
+ }
2426
+
2427
+ // src/state/service/compose.ts
2428
+ function composeStellarStateService(adapter) {
2429
+ const base = new StellarStateServiceBase(adapter);
2430
+ return {
2431
+ bridge: base.bridge,
2432
+ ...createAssetsService(base),
2433
+ ...createRegistryLookupService(base),
2434
+ ...createWalletAddressService(base),
2435
+ ...createPoolMerkleService(base),
2436
+ ...createPoolEphemeralService(base),
2437
+ ...createClaimsService(base),
2438
+ ...createDeliveriesService(base),
2439
+ ...createRecordsService(base)
2440
+ };
2441
+ }
2442
+
2443
+ // src/state/service/index.ts
2444
+ function createStellarStateService(adapter) {
2445
+ return composeStellarStateService(adapter);
2446
+ }
2447
+ function createStellarStorageAdapterFromState(state) {
2448
+ return {
2449
+ listPrivateRecords: (filter) => state.listPrivateRecords(filter),
2450
+ savePrivateRecords: (records) => state.savePrivateRecords(records),
2451
+ markPrivateRecordsUsed: (records) => state.markPrivateRecordsUsed(records)
2452
+ };
2453
+ }
2454
+ export {
2455
+ STELLAR_STATE_PATHS,
2456
+ assetSchema,
2457
+ createStellarStateService,
2458
+ createStellarStorageAdapterFromState,
2459
+ deliverySyncStateSchema,
2460
+ incomingDeliverySchema,
2461
+ leafEphemeralSchema,
2462
+ listWalletPrivateAddressRecordsForOwnerFromStateSnapshot,
2463
+ listWalletPrivateAddressScalarsForOwnerFromStateSnapshot,
2464
+ paginationSchema,
2465
+ pendingClaimSchema,
2466
+ poolMerkleStateSchema,
2467
+ privateRecordSchema,
2468
+ publicBalanceSchema,
2469
+ readPrivateRecordsFromStateSnapshot,
2470
+ readWalletDefaultPrivateAddressNonceFromStateSnapshot,
2471
+ readWalletPrivateAddressRecordFromStateSnapshot,
2472
+ readWalletPrivateAddressScalarFromStateSnapshot,
2473
+ registryLookupSchema,
2474
+ stellarStateCallTypes,
2475
+ stellarStateDefinitions,
2476
+ transactionStatusSchema
2477
+ };
2478
+ //# sourceMappingURL=index.js.map