@sip-protocol/sdk 0.2.10 → 0.3.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.
Files changed (43) hide show
  1. package/dist/browser.d.mts +1 -1
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +1334 -199
  4. package/dist/browser.mjs +19 -1
  5. package/dist/chunk-4IFOPYJF.mjs +11950 -0
  6. package/dist/chunk-4VJHI66K.mjs +12120 -0
  7. package/dist/chunk-5BAS4D44.mjs +10283 -0
  8. package/dist/chunk-6WOV2YNG.mjs +10179 -0
  9. package/dist/chunk-7IMRM7LN.mjs +12149 -0
  10. package/dist/chunk-DU7LQDD2.mjs +10148 -0
  11. package/dist/{chunk-AV37IZST.mjs → chunk-JNNXNTSS.mjs} +14 -0
  12. package/dist/chunk-KXN6IWL5.mjs +10736 -0
  13. package/dist/chunk-MR7HRCRS.mjs +10165 -0
  14. package/dist/chunk-NDGUWOOZ.mjs +10157 -0
  15. package/dist/chunk-O4Y2ZUDL.mjs +12721 -0
  16. package/dist/chunk-UPTISVCY.mjs +10304 -0
  17. package/dist/chunk-VITVG25F.mjs +982 -0
  18. package/dist/chunk-VXSHK7US.mjs +10158 -0
  19. package/dist/chunk-W3YXIQ7L.mjs +11950 -0
  20. package/dist/index-Ba7njCU3.d.ts +6925 -0
  21. package/dist/index-Co26-vbG.d.mts +6925 -0
  22. package/dist/{index-CAhjA4kh.d.mts → index-DqZoHYKI.d.mts} +362 -6
  23. package/dist/index-dTtK_DTl.d.ts +6762 -0
  24. package/dist/index-jnkYu-Z4.d.mts +6762 -0
  25. package/dist/{index-BFOKTz2z.d.ts → index-vB1N1mHd.d.ts} +362 -6
  26. package/dist/index.d.mts +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +1334 -199
  29. package/dist/index.mjs +19 -1
  30. package/dist/noir-BHQtFvRk.d.mts +467 -0
  31. package/dist/noir-BHQtFvRk.d.ts +467 -0
  32. package/package.json +14 -14
  33. package/src/index.ts +32 -0
  34. package/src/settlement/README.md +439 -0
  35. package/src/settlement/backends/direct-chain.ts +569 -0
  36. package/src/settlement/backends/index.ts +22 -0
  37. package/src/settlement/backends/near-intents.ts +480 -0
  38. package/src/settlement/backends/zcash-native.ts +516 -0
  39. package/src/settlement/index.ts +47 -0
  40. package/src/settlement/interface.ts +397 -0
  41. package/src/settlement/registry.ts +269 -0
  42. package/src/settlement/router.ts +383 -0
  43. package/LICENSE +0 -21
package/dist/browser.js CHANGED
@@ -47,7 +47,7 @@ __export(browser_exports, {
47
47
  HardwareWalletError: () => HardwareWalletError,
48
48
  IntentBuilder: () => IntentBuilder,
49
49
  IntentError: () => IntentError,
50
- IntentStatus: () => import_types34.IntentStatus,
50
+ IntentStatus: () => import_types37.IntentStatus,
51
51
  LedgerWalletAdapter: () => LedgerWalletAdapter,
52
52
  MockEthereumAdapter: () => MockEthereumAdapter,
53
53
  MockLedgerAdapter: () => MockLedgerAdapter,
@@ -56,37 +56,43 @@ __export(browser_exports, {
56
56
  MockSolver: () => MockSolver,
57
57
  MockTrezorAdapter: () => MockTrezorAdapter,
58
58
  MockWalletAdapter: () => MockWalletAdapter,
59
- NATIVE_TOKENS: () => import_types34.NATIVE_TOKENS,
59
+ NATIVE_TOKENS: () => import_types37.NATIVE_TOKENS,
60
60
  NEARIntentsAdapter: () => NEARIntentsAdapter,
61
+ NEARIntentsBackend: () => NEARIntentsBackend,
61
62
  NetworkError: () => NetworkError,
62
63
  ORACLE_DOMAIN: () => ORACLE_DOMAIN,
63
64
  OneClickClient: () => OneClickClient,
64
- OneClickDepositMode: () => import_types38.OneClickDepositMode,
65
- OneClickErrorCode: () => import_types38.OneClickErrorCode,
66
- OneClickSwapStatus: () => import_types38.OneClickSwapStatus,
67
- OneClickSwapType: () => import_types38.OneClickSwapType,
65
+ OneClickDepositMode: () => import_types41.OneClickDepositMode,
66
+ OneClickErrorCode: () => import_types41.OneClickErrorCode,
67
+ OneClickSwapStatus: () => import_types41.OneClickSwapStatus,
68
+ OneClickSwapType: () => import_types41.OneClickSwapType,
68
69
  PaymentBuilder: () => PaymentBuilder,
69
- PaymentStatus: () => import_types35.PaymentStatus,
70
- PrivacyLevel: () => import_types34.PrivacyLevel,
70
+ PaymentStatus: () => import_types38.PaymentStatus,
71
+ PrivacyLevel: () => import_types37.PrivacyLevel,
71
72
  ProofError: () => ProofError,
72
73
  ProofGenerationError: () => ProofGenerationError,
73
74
  ProofNotImplementedError: () => ProofNotImplementedError,
74
75
  ProofWorker: () => ProofWorker,
75
- ProposalStatus: () => import_types36.ProposalStatus,
76
- ReportStatus: () => import_types37.ReportStatus,
76
+ ProposalStatus: () => import_types39.ProposalStatus,
77
+ ReportStatus: () => import_types40.ReportStatus,
77
78
  SIP: () => SIP,
78
79
  SIPError: () => SIPError,
79
- SIP_VERSION: () => import_types34.SIP_VERSION,
80
+ SIP_VERSION: () => import_types37.SIP_VERSION,
80
81
  STABLECOIN_ADDRESSES: () => STABLECOIN_ADDRESSES,
81
82
  STABLECOIN_DECIMALS: () => STABLECOIN_DECIMALS,
82
83
  STABLECOIN_INFO: () => STABLECOIN_INFO,
84
+ SettlementRegistry: () => SettlementRegistry,
85
+ SettlementRegistryError: () => SettlementRegistryError,
86
+ SmartRouter: () => SmartRouter,
83
87
  SolanaWalletAdapter: () => SolanaWalletAdapter,
88
+ SwapStatus: () => SwapStatus,
84
89
  Treasury: () => Treasury,
85
90
  TrezorWalletAdapter: () => TrezorWalletAdapter,
86
91
  ValidationError: () => ValidationError,
87
92
  WalletError: () => WalletError,
88
- WalletErrorCode: () => import_types33.WalletErrorCode,
89
- ZcashErrorCode: () => import_types39.ZcashErrorCode,
93
+ WalletErrorCode: () => import_types36.WalletErrorCode,
94
+ ZcashErrorCode: () => import_types42.ZcashErrorCode,
95
+ ZcashNativeBackend: () => ZcashNativeBackend,
90
96
  ZcashRPCClient: () => ZcashRPCClient,
91
97
  ZcashRPCError: () => ZcashRPCError,
92
98
  ZcashShieldedService: () => ZcashShieldedService,
@@ -116,16 +122,19 @@ __export(browser_exports, {
116
122
  createMockSolver: () => createMockSolver,
117
123
  createMockTrezorAdapter: () => createMockTrezorAdapter,
118
124
  createNEARIntentsAdapter: () => createNEARIntentsAdapter,
125
+ createNEARIntentsBackend: () => createNEARIntentsBackend,
119
126
  createOracleRegistry: () => createOracleRegistry,
120
127
  createProductionSIP: () => createProductionSIP,
121
128
  createSIP: () => createSIP,
122
129
  createShieldedIntent: () => createShieldedIntent,
123
130
  createShieldedPayment: () => createShieldedPayment,
131
+ createSmartRouter: () => createSmartRouter,
124
132
  createSolanaAdapter: () => createSolanaAdapter,
125
133
  createTrezorAdapter: () => createTrezorAdapter,
126
134
  createWalletFactory: () => createWalletFactory,
127
135
  createWorkerBlobURL: () => createWorkerBlobURL,
128
136
  createZcashClient: () => createZcashClient,
137
+ createZcashNativeBackend: () => createZcashNativeBackend,
129
138
  createZcashShieldedService: () => createZcashShieldedService,
130
139
  createZcashSwapService: () => createZcashSwapService,
131
140
  decodeStealthMetaAddress: () => decodeStealthMetaAddress,
@@ -193,7 +202,7 @@ __export(browser_exports, {
193
202
  isExpired: () => isExpired,
194
203
  isNonNegativeAmount: () => isNonNegativeAmount,
195
204
  isPaymentExpired: () => isPaymentExpired,
196
- isPrivate: () => import_types34.isPrivate,
205
+ isPrivate: () => import_types37.isPrivate,
197
206
  isPrivateWalletAdapter: () => isPrivateWalletAdapter,
198
207
  isSIPError: () => isSIPError,
199
208
  isStablecoin: () => isStablecoin,
@@ -231,7 +240,7 @@ __export(browser_exports, {
231
240
  subtractCommitments: () => subtractCommitments,
232
241
  supportsSharedArrayBuffer: () => supportsSharedArrayBuffer,
233
242
  supportsTouch: () => supportsTouch,
234
- supportsViewingKey: () => import_types34.supportsViewingKey,
243
+ supportsViewingKey: () => import_types37.supportsViewingKey,
235
244
  supportsWASMBulkMemory: () => supportsWASMBulkMemory,
236
245
  supportsWASMSimd: () => supportsWASMSimd,
237
246
  supportsWebBluetooth: () => supportsWebBluetooth,
@@ -4061,10 +4070,10 @@ function hasEnoughOracles(registry) {
4061
4070
  }
4062
4071
 
4063
4072
  // src/index.ts
4064
- var import_types34 = require("@sip-protocol/types");
4065
- var import_types35 = require("@sip-protocol/types");
4066
- var import_types36 = require("@sip-protocol/types");
4067
4073
  var import_types37 = require("@sip-protocol/types");
4074
+ var import_types38 = require("@sip-protocol/types");
4075
+ var import_types39 = require("@sip-protocol/types");
4076
+ var import_types40 = require("@sip-protocol/types");
4068
4077
 
4069
4078
  // src/solver/mock-solver.ts
4070
4079
  var import_types7 = require("@sip-protocol/types");
@@ -4249,10 +4258,1127 @@ function createMockSolver(config) {
4249
4258
  }
4250
4259
 
4251
4260
  // src/index.ts
4252
- var import_types38 = require("@sip-protocol/types");
4261
+ var import_types41 = require("@sip-protocol/types");
4262
+
4263
+ // src/settlement/interface.ts
4264
+ var SwapStatus = /* @__PURE__ */ ((SwapStatus2) => {
4265
+ SwapStatus2["PENDING_DEPOSIT"] = "pending_deposit";
4266
+ SwapStatus2["DEPOSIT_CONFIRMED"] = "deposit_confirmed";
4267
+ SwapStatus2["IN_PROGRESS"] = "in_progress";
4268
+ SwapStatus2["SUCCESS"] = "success";
4269
+ SwapStatus2["FAILED"] = "failed";
4270
+ SwapStatus2["CANCELLED"] = "cancelled";
4271
+ SwapStatus2["REFUNDING"] = "refunding";
4272
+ SwapStatus2["REFUNDED"] = "refunded";
4273
+ return SwapStatus2;
4274
+ })(SwapStatus || {});
4275
+
4276
+ // src/settlement/registry.ts
4277
+ var SettlementRegistryError = class extends Error {
4278
+ constructor(message) {
4279
+ super(message);
4280
+ this.name = "SettlementRegistryError";
4281
+ }
4282
+ };
4283
+ var SettlementRegistry = class {
4284
+ backends = /* @__PURE__ */ new Map();
4285
+ /**
4286
+ * Register a settlement backend
4287
+ *
4288
+ * @param backend - Settlement backend to register
4289
+ * @throws {SettlementRegistryError} If backend with same name already exists
4290
+ *
4291
+ * @example
4292
+ * ```typescript
4293
+ * registry.register(nearIntentsBackend)
4294
+ * ```
4295
+ */
4296
+ register(backend) {
4297
+ if (this.backends.has(backend.name)) {
4298
+ throw new SettlementRegistryError(
4299
+ `Backend '${backend.name}' is already registered`
4300
+ );
4301
+ }
4302
+ this.backends.set(backend.name, backend);
4303
+ }
4304
+ /**
4305
+ * Get a settlement backend by name
4306
+ *
4307
+ * @param name - Backend name
4308
+ * @returns Settlement backend
4309
+ * @throws {SettlementRegistryError} If backend is not found
4310
+ *
4311
+ * @example
4312
+ * ```typescript
4313
+ * const backend = registry.get('near-intents')
4314
+ * ```
4315
+ */
4316
+ get(name) {
4317
+ const backend = this.backends.get(name);
4318
+ if (!backend) {
4319
+ throw new SettlementRegistryError(`Backend '${name}' not found`);
4320
+ }
4321
+ return backend;
4322
+ }
4323
+ /**
4324
+ * List all registered backend names
4325
+ *
4326
+ * @returns Array of backend names
4327
+ *
4328
+ * @example
4329
+ * ```typescript
4330
+ * const names = registry.list()
4331
+ * // ['near-intents', 'zcash', 'thorchain']
4332
+ * ```
4333
+ */
4334
+ list() {
4335
+ return Array.from(this.backends.keys());
4336
+ }
4337
+ /**
4338
+ * Get the best backend for a specific route
4339
+ *
4340
+ * Selection criteria (in order of priority):
4341
+ * 1. Backends that support both source and destination chains
4342
+ * 2. Backends with faster average execution time
4343
+ * 3. First registered backend (if no execution time info)
4344
+ *
4345
+ * @param fromChain - Source chain
4346
+ * @param toChain - Destination chain
4347
+ * @returns Best settlement backend for the route
4348
+ * @throws {SettlementRegistryError} If no backend supports the route
4349
+ *
4350
+ * @example
4351
+ * ```typescript
4352
+ * const backend = registry.getBestForRoute('ethereum', 'solana')
4353
+ * const quote = await backend.getQuote({ ... })
4354
+ * ```
4355
+ */
4356
+ getBestForRoute(fromChain, toChain) {
4357
+ const supportedBackends = [];
4358
+ for (const backend of Array.from(this.backends.values())) {
4359
+ const { supportedSourceChains, supportedDestinationChains } = backend.capabilities;
4360
+ const supportsSource = supportedSourceChains.includes(fromChain);
4361
+ const supportsDestination = supportedDestinationChains.includes(toChain);
4362
+ if (supportsSource && supportsDestination) {
4363
+ supportedBackends.push(backend);
4364
+ }
4365
+ }
4366
+ if (supportedBackends.length === 0) {
4367
+ throw new SettlementRegistryError(
4368
+ `No backend supports route from '${fromChain}' to '${toChain}'`
4369
+ );
4370
+ }
4371
+ if (supportedBackends.length === 1) {
4372
+ return supportedBackends[0];
4373
+ }
4374
+ supportedBackends.sort((a, b) => {
4375
+ const timeA = a.capabilities.averageExecutionTime ?? Infinity;
4376
+ const timeB = b.capabilities.averageExecutionTime ?? Infinity;
4377
+ return timeA - timeB;
4378
+ });
4379
+ return supportedBackends[0];
4380
+ }
4381
+ /**
4382
+ * Get all supported routes across all registered backends
4383
+ *
4384
+ * @returns Array of supported routes
4385
+ *
4386
+ * @example
4387
+ * ```typescript
4388
+ * const routes = registry.getSupportedRoutes()
4389
+ * // [
4390
+ * // { fromChain: 'ethereum', toChain: 'solana', backend: 'near-intents' },
4391
+ * // { fromChain: 'solana', toChain: 'ethereum', backend: 'near-intents' },
4392
+ * // { fromChain: 'ethereum', toChain: 'zcash', backend: 'zcash' },
4393
+ * // ...
4394
+ * // ]
4395
+ * ```
4396
+ */
4397
+ getSupportedRoutes() {
4398
+ const routes = [];
4399
+ for (const backend of Array.from(this.backends.values())) {
4400
+ const { supportedSourceChains, supportedDestinationChains } = backend.capabilities;
4401
+ for (const fromChain of supportedSourceChains) {
4402
+ for (const toChain of supportedDestinationChains) {
4403
+ routes.push({
4404
+ fromChain,
4405
+ toChain,
4406
+ backend: backend.name
4407
+ });
4408
+ }
4409
+ }
4410
+ }
4411
+ return routes;
4412
+ }
4413
+ /**
4414
+ * Check if a backend is registered
4415
+ *
4416
+ * @param name - Backend name
4417
+ * @returns True if backend is registered
4418
+ *
4419
+ * @example
4420
+ * ```typescript
4421
+ * if (registry.has('near-intents')) {
4422
+ * const backend = registry.get('near-intents')
4423
+ * }
4424
+ * ```
4425
+ */
4426
+ has(name) {
4427
+ return this.backends.has(name);
4428
+ }
4429
+ /**
4430
+ * Unregister a settlement backend
4431
+ *
4432
+ * @param name - Backend name to unregister
4433
+ * @returns True if backend was unregistered, false if not found
4434
+ *
4435
+ * @example
4436
+ * ```typescript
4437
+ * registry.unregister('near-intents')
4438
+ * ```
4439
+ */
4440
+ unregister(name) {
4441
+ return this.backends.delete(name);
4442
+ }
4443
+ /**
4444
+ * Clear all registered backends
4445
+ *
4446
+ * @example
4447
+ * ```typescript
4448
+ * registry.clear()
4449
+ * ```
4450
+ */
4451
+ clear() {
4452
+ this.backends.clear();
4453
+ }
4454
+ /**
4455
+ * Get number of registered backends
4456
+ *
4457
+ * @returns Number of registered backends
4458
+ *
4459
+ * @example
4460
+ * ```typescript
4461
+ * const count = registry.size()
4462
+ * ```
4463
+ */
4464
+ size() {
4465
+ return this.backends.size;
4466
+ }
4467
+ };
4253
4468
 
4254
- // src/zcash/rpc-client.ts
4469
+ // src/settlement/router.ts
4470
+ var SmartRouter = class {
4471
+ constructor(registry) {
4472
+ this.registry = registry;
4473
+ }
4474
+ /**
4475
+ * Find best routes for a swap
4476
+ *
4477
+ * Queries all compatible backends in parallel and returns sorted routes.
4478
+ *
4479
+ * @param params - Route finding parameters
4480
+ * @returns Sorted routes (best first)
4481
+ * @throws {ValidationError} If no backends support the route
4482
+ */
4483
+ async findBestRoute(params) {
4484
+ const {
4485
+ from,
4486
+ to,
4487
+ amount,
4488
+ privacyLevel,
4489
+ preferSpeed = false,
4490
+ preferLowFees = true,
4491
+ recipientMetaAddress,
4492
+ senderAddress,
4493
+ slippageTolerance,
4494
+ deadline
4495
+ } = params;
4496
+ if (amount <= 0n) {
4497
+ throw new ValidationError("Amount must be greater than zero");
4498
+ }
4499
+ const allBackends = this.registry.list().map((name) => this.registry.get(name));
4500
+ const compatibleBackends = allBackends.filter((backend) => {
4501
+ const { supportedSourceChains, supportedDestinationChains, supportedPrivacyLevels } = backend.capabilities;
4502
+ const supportsRoute = supportedSourceChains.includes(from.chain) && supportedDestinationChains.includes(to.chain);
4503
+ const supportsPrivacy = supportedPrivacyLevels.includes(privacyLevel);
4504
+ return supportsRoute && supportsPrivacy;
4505
+ });
4506
+ if (compatibleBackends.length === 0) {
4507
+ throw new ValidationError(
4508
+ `No backend supports route from ${from.chain} to ${to.chain} with privacy level ${privacyLevel}`
4509
+ );
4510
+ }
4511
+ const quoteParams = {
4512
+ fromChain: from.chain,
4513
+ toChain: to.chain,
4514
+ fromToken: from.token,
4515
+ toToken: to.token,
4516
+ amount,
4517
+ privacyLevel,
4518
+ recipientMetaAddress,
4519
+ senderAddress,
4520
+ slippageTolerance,
4521
+ deadline
4522
+ };
4523
+ const quotePromises = compatibleBackends.map(async (backend) => {
4524
+ try {
4525
+ const quote = await backend.getQuote(quoteParams);
4526
+ return {
4527
+ backend: backend.name,
4528
+ quote,
4529
+ backendInstance: backend,
4530
+ success: true
4531
+ };
4532
+ } catch (error) {
4533
+ return {
4534
+ backend: backend.name,
4535
+ error: error instanceof Error ? error.message : "Unknown error",
4536
+ success: false
4537
+ };
4538
+ }
4539
+ });
4540
+ const results = await Promise.all(quotePromises);
4541
+ const successfulRoutes = results.filter((r) => r.success).map((r) => ({
4542
+ backend: r.backend,
4543
+ quote: r.quote,
4544
+ backendInstance: r.backendInstance,
4545
+ score: 0
4546
+ // Will be calculated below
4547
+ }));
4548
+ if (successfulRoutes.length === 0) {
4549
+ const errors = results.filter((r) => !r.success).map((r) => `${r.backend}: ${r.error}`).join(", ");
4550
+ throw new NetworkError(
4551
+ `All backends failed to provide quotes: ${errors}`
4552
+ );
4553
+ }
4554
+ this.rankRoutes(successfulRoutes, { preferSpeed, preferLowFees });
4555
+ successfulRoutes.sort((a, b) => b.score - a.score);
4556
+ return successfulRoutes;
4557
+ }
4558
+ /**
4559
+ * Compare quotes from multiple routes side-by-side
4560
+ *
4561
+ * @param routes - Routes to compare (from findBestRoute)
4562
+ * @returns Comparison with best routes by different criteria
4563
+ */
4564
+ compareQuotes(routes) {
4565
+ if (routes.length === 0) {
4566
+ return {
4567
+ routes: [],
4568
+ bestByCost: null,
4569
+ bestBySpeed: null,
4570
+ bestByPrivacy: null,
4571
+ metadata: {
4572
+ totalQueried: 0,
4573
+ failures: [],
4574
+ queriedAt: Date.now()
4575
+ }
4576
+ };
4577
+ }
4578
+ const bestByCost = [...routes].sort((a, b) => {
4579
+ const costA = this.calculateTotalCost(a.quote);
4580
+ const costB = this.calculateTotalCost(b.quote);
4581
+ return costA - costB;
4582
+ })[0];
4583
+ const bestBySpeed = [...routes].sort((a, b) => {
4584
+ const timeA = a.quote.estimatedTime ?? Infinity;
4585
+ const timeB = b.quote.estimatedTime ?? Infinity;
4586
+ return timeA - timeB;
4587
+ })[0];
4588
+ const bestByPrivacy = [...routes].find((route) => {
4589
+ const { supportedPrivacyLevels } = route.backendInstance.capabilities;
4590
+ return supportedPrivacyLevels.includes("shielded") || supportedPrivacyLevels.includes("compliant");
4591
+ }) || routes[0];
4592
+ return {
4593
+ routes,
4594
+ bestByCost,
4595
+ bestBySpeed,
4596
+ bestByPrivacy,
4597
+ metadata: {
4598
+ totalQueried: routes.length,
4599
+ failures: [],
4600
+ // Could track from findBestRoute
4601
+ queriedAt: Date.now()
4602
+ }
4603
+ };
4604
+ }
4605
+ /**
4606
+ * Rank routes by score
4607
+ *
4608
+ * Scoring algorithm:
4609
+ * - Base score: 100
4610
+ * - Cost: Lower fees = higher score (up to +50)
4611
+ * - Speed: Faster execution = higher score (up to +30)
4612
+ * - Privacy: Better privacy support = higher score (up to +20)
4613
+ *
4614
+ * @private
4615
+ */
4616
+ rankRoutes(routes, preferences) {
4617
+ const { preferSpeed, preferLowFees } = preferences;
4618
+ const costs = routes.map((r) => this.calculateTotalCost(r.quote));
4619
+ const times = routes.map((r) => r.quote.estimatedTime ?? Infinity);
4620
+ const minCost = Math.min(...costs);
4621
+ const maxCost = Math.max(...costs);
4622
+ const minTime = Math.min(...times.filter((t) => t !== Infinity));
4623
+ const maxTime = Math.max(...times.filter((t) => t !== Infinity));
4624
+ routes.forEach((route, index) => {
4625
+ let score = 100;
4626
+ if (maxCost > minCost) {
4627
+ const costNormalized = 1 - (costs[index] - minCost) / (maxCost - minCost);
4628
+ const costWeight = preferLowFees ? 50 : 30;
4629
+ score += costNormalized * costWeight;
4630
+ }
4631
+ const time = times[index];
4632
+ if (time !== Infinity && maxTime > minTime) {
4633
+ const speedNormalized = 1 - (time - minTime) / (maxTime - minTime);
4634
+ const speedWeight = preferSpeed ? 50 : 30;
4635
+ score += speedNormalized * speedWeight;
4636
+ }
4637
+ const { supportedPrivacyLevels } = route.backendInstance.capabilities;
4638
+ if (supportedPrivacyLevels.includes("shielded")) {
4639
+ score += 20;
4640
+ } else if (supportedPrivacyLevels.includes("compliant")) {
4641
+ score += 10;
4642
+ }
4643
+ route.score = score;
4644
+ });
4645
+ }
4646
+ /**
4647
+ * Calculate total cost from quote
4648
+ *
4649
+ * Returns total fee in USD if available, otherwise estimates from fees
4650
+ *
4651
+ * @private
4652
+ */
4653
+ calculateTotalCost(quote) {
4654
+ if (quote.fees.totalFeeUSD) {
4655
+ return parseFloat(quote.fees.totalFeeUSD);
4656
+ }
4657
+ const networkFee = parseFloat(quote.fees.networkFee) || 0;
4658
+ const protocolFee = parseFloat(quote.fees.protocolFee) || 0;
4659
+ return networkFee + protocolFee;
4660
+ }
4661
+ };
4662
+ function createSmartRouter(registry) {
4663
+ return new SmartRouter(registry);
4664
+ }
4665
+
4666
+ // src/settlement/backends/near-intents.ts
4255
4667
  var import_types8 = require("@sip-protocol/types");
4668
+ function mapOneClickStatus(status) {
4669
+ switch (status) {
4670
+ case import_types8.OneClickSwapStatus.PENDING_DEPOSIT:
4671
+ return "pending_deposit" /* PENDING_DEPOSIT */;
4672
+ case import_types8.OneClickSwapStatus.PROCESSING:
4673
+ return "in_progress" /* IN_PROGRESS */;
4674
+ case import_types8.OneClickSwapStatus.SUCCESS:
4675
+ return "success" /* SUCCESS */;
4676
+ case import_types8.OneClickSwapStatus.FAILED:
4677
+ return "failed" /* FAILED */;
4678
+ case import_types8.OneClickSwapStatus.INCOMPLETE_DEPOSIT:
4679
+ return "failed" /* FAILED */;
4680
+ case import_types8.OneClickSwapStatus.REFUNDED:
4681
+ return "refunded" /* REFUNDED */;
4682
+ default:
4683
+ return "pending_deposit" /* PENDING_DEPOSIT */;
4684
+ }
4685
+ }
4686
+ var NEARIntentsBackend = class {
4687
+ name = "near-intents";
4688
+ capabilities;
4689
+ adapter;
4690
+ quoteCache;
4691
+ constructor(config = {}) {
4692
+ this.adapter = new NEARIntentsAdapter(config);
4693
+ this.quoteCache = /* @__PURE__ */ new Map();
4694
+ this.capabilities = {
4695
+ supportedSourceChains: [
4696
+ "near",
4697
+ "ethereum",
4698
+ "solana",
4699
+ "polygon",
4700
+ "arbitrum",
4701
+ "optimism",
4702
+ "base",
4703
+ "bitcoin",
4704
+ "zcash"
4705
+ ],
4706
+ supportedDestinationChains: [
4707
+ "near",
4708
+ "ethereum",
4709
+ "solana",
4710
+ "polygon",
4711
+ "arbitrum",
4712
+ "optimism",
4713
+ "base",
4714
+ "bitcoin",
4715
+ "zcash"
4716
+ ],
4717
+ supportedPrivacyLevels: [
4718
+ import_types8.PrivacyLevel.TRANSPARENT,
4719
+ import_types8.PrivacyLevel.SHIELDED,
4720
+ import_types8.PrivacyLevel.COMPLIANT
4721
+ ],
4722
+ supportsCancellation: false,
4723
+ supportsRefunds: true,
4724
+ averageExecutionTime: 300,
4725
+ // 5 minutes
4726
+ features: ["stealth-addresses", "cross-chain", "near-intents"]
4727
+ };
4728
+ }
4729
+ /**
4730
+ * Get quote for a cross-chain swap
4731
+ */
4732
+ async getQuote(params) {
4733
+ this.validateQuoteParams(params);
4734
+ const swapRequest = {
4735
+ requestId: this.generateRequestId(),
4736
+ privacyLevel: params.privacyLevel,
4737
+ inputAsset: {
4738
+ chain: params.fromChain,
4739
+ symbol: params.fromToken,
4740
+ decimals: 0
4741
+ // Will be inferred by adapter
4742
+ },
4743
+ outputAsset: {
4744
+ chain: params.toChain,
4745
+ symbol: params.toToken,
4746
+ decimals: 0
4747
+ // Will be inferred by adapter
4748
+ },
4749
+ inputAmount: params.amount,
4750
+ minOutputAmount: params.slippageTolerance ? params.amount - params.amount * BigInt(params.slippageTolerance) / BigInt(1e4) : void 0
4751
+ };
4752
+ const prepared = await this.adapter.prepareSwap(
4753
+ swapRequest,
4754
+ params.recipientMetaAddress,
4755
+ params.senderAddress
4756
+ );
4757
+ const oneClickQuote = await this.adapter.getQuote(prepared);
4758
+ this.quoteCache.set(oneClickQuote.quoteId, params);
4759
+ const quote = {
4760
+ quoteId: oneClickQuote.quoteId,
4761
+ amountIn: oneClickQuote.amountIn,
4762
+ amountOut: oneClickQuote.amountOut,
4763
+ minAmountOut: oneClickQuote.amountOut,
4764
+ // 1Click doesn't provide separate minAmount
4765
+ fees: {
4766
+ networkFee: "0",
4767
+ // 1Click doesn't provide separate fee breakdown
4768
+ protocolFee: "0",
4769
+ totalFeeUSD: oneClickQuote.amountOutUsd
4770
+ },
4771
+ depositAddress: oneClickQuote.depositAddress,
4772
+ recipientAddress: prepared.stealthAddress?.address ?? params.senderAddress ?? "",
4773
+ refundAddress: params.senderAddress,
4774
+ expiresAt: new Date(oneClickQuote.deadline).getTime() / 1e3,
4775
+ estimatedTime: oneClickQuote.timeEstimate,
4776
+ metadata: {
4777
+ prepared,
4778
+ oneClickQuote,
4779
+ stealthAddress: prepared.stealthAddress,
4780
+ ephemeralPublicKey: prepared.stealthAddress?.ephemeralPublicKey,
4781
+ curve: prepared.curve
4782
+ }
4783
+ };
4784
+ return quote;
4785
+ }
4786
+ /**
4787
+ * Execute swap using a quote
4788
+ */
4789
+ async executeSwap(params) {
4790
+ if (!params.quoteId) {
4791
+ throw new ValidationError("quoteId is required", "quoteId");
4792
+ }
4793
+ const quoteParams = this.quoteCache.get(params.quoteId);
4794
+ if (!quoteParams) {
4795
+ throw new ValidationError(
4796
+ "Quote not found. Please call getQuote() before executeSwap()",
4797
+ "quoteId"
4798
+ );
4799
+ }
4800
+ const swapRequest = {
4801
+ requestId: this.generateRequestId(),
4802
+ privacyLevel: quoteParams.privacyLevel,
4803
+ inputAsset: {
4804
+ chain: quoteParams.fromChain,
4805
+ symbol: quoteParams.fromToken,
4806
+ decimals: 0
4807
+ },
4808
+ outputAsset: {
4809
+ chain: quoteParams.toChain,
4810
+ symbol: quoteParams.toToken,
4811
+ decimals: 0
4812
+ },
4813
+ inputAmount: quoteParams.amount
4814
+ };
4815
+ const adapterResult = await this.adapter.initiateSwap(
4816
+ swapRequest,
4817
+ quoteParams.recipientMetaAddress,
4818
+ quoteParams.senderAddress
4819
+ );
4820
+ if (params.depositTxHash) {
4821
+ await this.adapter.notifyDeposit(
4822
+ adapterResult.depositAddress,
4823
+ params.depositTxHash,
4824
+ params.nearAccount
4825
+ );
4826
+ }
4827
+ const result = {
4828
+ swapId: adapterResult.depositAddress,
4829
+ // Use deposit address as swap ID
4830
+ status: mapOneClickStatus(adapterResult.status),
4831
+ quoteId: params.quoteId,
4832
+ depositAddress: adapterResult.depositAddress,
4833
+ depositTxHash: params.depositTxHash,
4834
+ settlementTxHash: adapterResult.settlementTxHash,
4835
+ actualAmountOut: adapterResult.amountOut,
4836
+ metadata: {
4837
+ adapterResult,
4838
+ stealthRecipient: adapterResult.stealthRecipient,
4839
+ ephemeralPublicKey: adapterResult.ephemeralPublicKey
4840
+ }
4841
+ };
4842
+ return result;
4843
+ }
4844
+ /**
4845
+ * Get current swap status
4846
+ */
4847
+ async getStatus(swapId) {
4848
+ const oneClickStatus = await this.adapter.getStatus(swapId);
4849
+ const status = {
4850
+ swapId,
4851
+ status: mapOneClickStatus(oneClickStatus.status),
4852
+ quoteId: "",
4853
+ // 1Click status doesn't include quoteId
4854
+ depositAddress: swapId,
4855
+ amountIn: oneClickStatus.amountIn ?? "0",
4856
+ amountOut: oneClickStatus.amountOut ?? "0",
4857
+ depositTxHash: oneClickStatus.depositTxHash,
4858
+ settlementTxHash: oneClickStatus.settlementTxHash,
4859
+ errorMessage: oneClickStatus.error,
4860
+ updatedAt: Date.now() / 1e3,
4861
+ // 1Click doesn't provide updatedAt
4862
+ metadata: {
4863
+ oneClickStatus
4864
+ }
4865
+ };
4866
+ return status;
4867
+ }
4868
+ /**
4869
+ * Wait for swap completion (optional)
4870
+ */
4871
+ async waitForCompletion(swapId, options) {
4872
+ await this.adapter.waitForCompletion(swapId, {
4873
+ interval: options?.interval,
4874
+ timeout: options?.timeout,
4875
+ onStatus: options?.onStatusChange ? (oneClickStatus) => {
4876
+ const status = {
4877
+ swapId,
4878
+ status: mapOneClickStatus(oneClickStatus.status),
4879
+ quoteId: "",
4880
+ depositAddress: swapId,
4881
+ amountIn: oneClickStatus.amountIn ?? "0",
4882
+ amountOut: oneClickStatus.amountOut ?? "0",
4883
+ depositTxHash: oneClickStatus.depositTxHash,
4884
+ settlementTxHash: oneClickStatus.settlementTxHash,
4885
+ errorMessage: oneClickStatus.error,
4886
+ updatedAt: Date.now() / 1e3,
4887
+ metadata: { oneClickStatus }
4888
+ };
4889
+ options.onStatusChange?.(status);
4890
+ } : void 0
4891
+ });
4892
+ return this.getStatus(swapId);
4893
+ }
4894
+ /**
4895
+ * Get dry quote (preview without creating deposit address)
4896
+ */
4897
+ async getDryQuote(params) {
4898
+ this.validateQuoteParams(params);
4899
+ const swapRequest = {
4900
+ requestId: this.generateRequestId(),
4901
+ privacyLevel: params.privacyLevel,
4902
+ inputAsset: {
4903
+ chain: params.fromChain,
4904
+ symbol: params.fromToken,
4905
+ decimals: 0
4906
+ },
4907
+ outputAsset: {
4908
+ chain: params.toChain,
4909
+ symbol: params.toToken,
4910
+ decimals: 0
4911
+ },
4912
+ inputAmount: params.amount
4913
+ };
4914
+ const prepared = await this.adapter.prepareSwap(
4915
+ swapRequest,
4916
+ params.recipientMetaAddress,
4917
+ params.senderAddress
4918
+ );
4919
+ const oneClickQuote = await this.adapter.getDryQuote(prepared);
4920
+ const quote = {
4921
+ quoteId: oneClickQuote.quoteId,
4922
+ amountIn: oneClickQuote.amountIn,
4923
+ amountOut: oneClickQuote.amountOut,
4924
+ minAmountOut: oneClickQuote.amountOut,
4925
+ fees: {
4926
+ networkFee: "0",
4927
+ protocolFee: "0",
4928
+ totalFeeUSD: oneClickQuote.amountOutUsd
4929
+ },
4930
+ depositAddress: oneClickQuote.depositAddress,
4931
+ recipientAddress: prepared.stealthAddress?.address ?? params.senderAddress ?? "",
4932
+ refundAddress: params.senderAddress,
4933
+ expiresAt: new Date(oneClickQuote.deadline).getTime() / 1e3,
4934
+ estimatedTime: oneClickQuote.timeEstimate,
4935
+ metadata: {
4936
+ prepared,
4937
+ oneClickQuote,
4938
+ stealthAddress: prepared.stealthAddress,
4939
+ ephemeralPublicKey: prepared.stealthAddress?.ephemeralPublicKey,
4940
+ curve: prepared.curve,
4941
+ isDryQuote: true
4942
+ }
4943
+ };
4944
+ return quote;
4945
+ }
4946
+ /**
4947
+ * Notify backend of deposit transaction
4948
+ */
4949
+ async notifyDeposit(swapId, txHash, metadata) {
4950
+ await this.adapter.notifyDeposit(
4951
+ swapId,
4952
+ // swapId is deposit address
4953
+ txHash,
4954
+ metadata?.nearAccount
4955
+ );
4956
+ }
4957
+ // ─── Private Methods ──────────────────────────────────────────────────────────
4958
+ validateQuoteParams(params) {
4959
+ if (!params.fromChain) {
4960
+ throw new ValidationError("fromChain is required", "fromChain");
4961
+ }
4962
+ if (!params.toChain) {
4963
+ throw new ValidationError("toChain is required", "toChain");
4964
+ }
4965
+ if (!params.fromToken) {
4966
+ throw new ValidationError("fromToken is required", "fromToken");
4967
+ }
4968
+ if (!params.toToken) {
4969
+ throw new ValidationError("toToken is required", "toToken");
4970
+ }
4971
+ if (!params.amount || params.amount <= BigInt(0)) {
4972
+ throw new ValidationError("amount must be greater than 0", "amount");
4973
+ }
4974
+ if (!params.privacyLevel) {
4975
+ throw new ValidationError("privacyLevel is required", "privacyLevel");
4976
+ }
4977
+ if (params.privacyLevel !== import_types8.PrivacyLevel.TRANSPARENT && !params.recipientMetaAddress) {
4978
+ throw new ValidationError(
4979
+ "recipientMetaAddress is required for shielded/compliant privacy modes",
4980
+ "recipientMetaAddress"
4981
+ );
4982
+ }
4983
+ if (params.privacyLevel === import_types8.PrivacyLevel.TRANSPARENT && !params.senderAddress) {
4984
+ throw new ValidationError(
4985
+ "senderAddress is required for transparent mode",
4986
+ "senderAddress"
4987
+ );
4988
+ }
4989
+ if (!this.capabilities.supportedSourceChains.includes(params.fromChain)) {
4990
+ throw new ValidationError(
4991
+ `Source chain ${params.fromChain} is not supported`,
4992
+ "fromChain",
4993
+ { supportedChains: this.capabilities.supportedSourceChains }
4994
+ );
4995
+ }
4996
+ if (!this.capabilities.supportedDestinationChains.includes(params.toChain)) {
4997
+ throw new ValidationError(
4998
+ `Destination chain ${params.toChain} is not supported`,
4999
+ "toChain",
5000
+ { supportedChains: this.capabilities.supportedDestinationChains }
5001
+ );
5002
+ }
5003
+ }
5004
+ generateRequestId() {
5005
+ return `req_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
5006
+ }
5007
+ };
5008
+ function createNEARIntentsBackend(config) {
5009
+ return new NEARIntentsBackend(config);
5010
+ }
5011
+
5012
+ // src/settlement/backends/zcash-native.ts
5013
+ var import_types9 = require("@sip-protocol/types");
5014
+ var ZcashNativeBackend = class {
5015
+ name = "zcash-native";
5016
+ capabilities;
5017
+ swapService;
5018
+ config;
5019
+ quotes = /* @__PURE__ */ new Map();
5020
+ swaps = /* @__PURE__ */ new Map();
5021
+ constructor(config) {
5022
+ this.swapService = config.swapService;
5023
+ this.config = {
5024
+ quoteValiditySeconds: config.quoteValiditySeconds ?? 300,
5025
+ networkFeeZatoshis: config.networkFeeZatoshis ?? 1e4
5026
+ };
5027
+ this.capabilities = {
5028
+ supportedSourceChains: ["zcash"],
5029
+ supportedDestinationChains: ["zcash"],
5030
+ supportedPrivacyLevels: [
5031
+ import_types9.PrivacyLevel.TRANSPARENT,
5032
+ import_types9.PrivacyLevel.SHIELDED,
5033
+ import_types9.PrivacyLevel.COMPLIANT
5034
+ ],
5035
+ supportsCancellation: false,
5036
+ supportsRefunds: false,
5037
+ averageExecutionTime: 75,
5038
+ // ~75 seconds for Zcash block confirmation
5039
+ features: [
5040
+ "native-zcash",
5041
+ "shielded-addresses",
5042
+ "transparent-addresses",
5043
+ "instant-quotes"
5044
+ ]
5045
+ };
5046
+ }
5047
+ // ─── Quote Methods ─────────────────────────────────────────────────────────
5048
+ /**
5049
+ * Get a quote for ZEC → ZEC transfer
5050
+ */
5051
+ async getQuote(params) {
5052
+ this.validateQuoteParams(params);
5053
+ const { amount, recipientMetaAddress, senderAddress, privacyLevel } = params;
5054
+ const quoteId = this.generateQuoteId();
5055
+ const now = Math.floor(Date.now() / 1e3);
5056
+ const expiresAt = now + this.config.quoteValiditySeconds;
5057
+ const networkFee = BigInt(this.config.networkFeeZatoshis);
5058
+ const protocolFee = BigInt(0);
5059
+ const totalFee = networkFee;
5060
+ const amountOut = amount - totalFee;
5061
+ if (amountOut <= BigInt(0)) {
5062
+ throw new ValidationError(
5063
+ "Amount too small to cover network fees",
5064
+ "amount",
5065
+ { amount: amount.toString(), networkFee: networkFee.toString() },
5066
+ "SIP_2004" /* INVALID_AMOUNT */
5067
+ );
5068
+ }
5069
+ const minAmountOut = amountOut * BigInt(99) / BigInt(100);
5070
+ let depositAddress;
5071
+ let recipientAddress;
5072
+ if (privacyLevel === import_types9.PrivacyLevel.SHIELDED || privacyLevel === import_types9.PrivacyLevel.COMPLIANT) {
5073
+ if (typeof recipientMetaAddress === "string") {
5074
+ recipientAddress = recipientMetaAddress;
5075
+ } else if (recipientMetaAddress) {
5076
+ recipientAddress = `zs1${this.randomHex(72)}`;
5077
+ } else {
5078
+ throw new ValidationError(
5079
+ "Recipient address required for shielded transfers",
5080
+ "recipientMetaAddress",
5081
+ void 0,
5082
+ "SIP_2000" /* VALIDATION_FAILED */
5083
+ );
5084
+ }
5085
+ depositAddress = `zs1${this.randomHex(72)}`;
5086
+ } else {
5087
+ if (senderAddress) {
5088
+ depositAddress = senderAddress;
5089
+ } else {
5090
+ depositAddress = `t1${this.randomBase58(33)}`;
5091
+ }
5092
+ if (typeof recipientMetaAddress === "string") {
5093
+ recipientAddress = recipientMetaAddress;
5094
+ } else {
5095
+ throw new ValidationError(
5096
+ "Recipient address required",
5097
+ "recipientMetaAddress",
5098
+ void 0,
5099
+ "SIP_2000" /* VALIDATION_FAILED */
5100
+ );
5101
+ }
5102
+ }
5103
+ const quote = {
5104
+ quoteId,
5105
+ amountIn: amount.toString(),
5106
+ amountOut: amountOut.toString(),
5107
+ minAmountOut: minAmountOut.toString(),
5108
+ fees: {
5109
+ networkFee: networkFee.toString(),
5110
+ protocolFee: protocolFee.toString()
5111
+ },
5112
+ depositAddress,
5113
+ recipientAddress,
5114
+ expiresAt,
5115
+ estimatedTime: this.capabilities.averageExecutionTime,
5116
+ metadata: {
5117
+ backend: this.name,
5118
+ privacyLevel,
5119
+ zcashNetwork: "mainnet"
5120
+ }
5121
+ };
5122
+ this.quotes.set(quoteId, quote);
5123
+ return quote;
5124
+ }
5125
+ /**
5126
+ * Get a dry quote (preview without creating deposit address)
5127
+ */
5128
+ async getDryQuote(params) {
5129
+ return this.getQuote(params);
5130
+ }
5131
+ // ─── Swap Execution ────────────────────────────────────────────────────────
5132
+ /**
5133
+ * Execute a ZEC → ZEC swap/transfer
5134
+ */
5135
+ async executeSwap(params) {
5136
+ const { quoteId, depositTxHash } = params;
5137
+ const quote = this.quotes.get(quoteId);
5138
+ if (!quote) {
5139
+ throw new ValidationError(
5140
+ "Quote not found or expired",
5141
+ "quoteId",
5142
+ { quoteId },
5143
+ "SIP_2000" /* VALIDATION_FAILED */
5144
+ );
5145
+ }
5146
+ const now = Math.floor(Date.now() / 1e3);
5147
+ if (now > quote.expiresAt) {
5148
+ throw new ValidationError(
5149
+ "Quote has expired",
5150
+ "quoteId",
5151
+ { quoteId, expiresAt: quote.expiresAt, now },
5152
+ "SIP_2000" /* VALIDATION_FAILED */
5153
+ );
5154
+ }
5155
+ const swapId = this.generateSwapId();
5156
+ const result = {
5157
+ swapId,
5158
+ status: depositTxHash ? "deposit_confirmed" /* DEPOSIT_CONFIRMED */ : "pending_deposit" /* PENDING_DEPOSIT */,
5159
+ quoteId,
5160
+ depositAddress: quote.depositAddress,
5161
+ depositTxHash,
5162
+ metadata: {
5163
+ backend: this.name,
5164
+ recipientAddress: quote.recipientAddress
5165
+ }
5166
+ };
5167
+ this.swaps.set(swapId, result);
5168
+ if (depositTxHash) {
5169
+ this.simulateSwapExecution(swapId, quote);
5170
+ }
5171
+ return result;
5172
+ }
5173
+ // ─── Status Methods ────────────────────────────────────────────────────────
5174
+ /**
5175
+ * Get swap status
5176
+ */
5177
+ async getStatus(swapId) {
5178
+ const swap = this.swaps.get(swapId);
5179
+ if (!swap) {
5180
+ throw new ValidationError(
5181
+ "Swap not found",
5182
+ "swapId",
5183
+ { swapId },
5184
+ "SIP_2000" /* VALIDATION_FAILED */
5185
+ );
5186
+ }
5187
+ const quote = this.quotes.get(swap.quoteId);
5188
+ if (!quote) {
5189
+ throw new ValidationError(
5190
+ "Quote not found for swap",
5191
+ "quoteId",
5192
+ { quoteId: swap.quoteId },
5193
+ "SIP_2000" /* VALIDATION_FAILED */
5194
+ );
5195
+ }
5196
+ const status = {
5197
+ swapId: swap.swapId,
5198
+ status: swap.status,
5199
+ quoteId: swap.quoteId,
5200
+ depositAddress: swap.depositAddress,
5201
+ amountIn: quote.amountIn,
5202
+ amountOut: quote.amountOut,
5203
+ depositTxHash: swap.depositTxHash,
5204
+ settlementTxHash: swap.settlementTxHash,
5205
+ actualAmountOut: swap.actualAmountOut,
5206
+ errorMessage: swap.errorMessage,
5207
+ updatedAt: Math.floor(Date.now() / 1e3),
5208
+ metadata: swap.metadata
5209
+ };
5210
+ return status;
5211
+ }
5212
+ /**
5213
+ * Wait for swap completion
5214
+ */
5215
+ async waitForCompletion(swapId, options) {
5216
+ const interval = options?.interval ?? 5e3;
5217
+ const timeout = options?.timeout ?? 6e5;
5218
+ const startTime = Date.now();
5219
+ while (Date.now() - startTime < timeout) {
5220
+ const status2 = await this.getStatus(swapId);
5221
+ if (options?.onStatusChange) {
5222
+ options.onStatusChange(status2);
5223
+ }
5224
+ if (status2.status === "success" /* SUCCESS */) {
5225
+ return status2;
5226
+ }
5227
+ if (status2.status === "failed" /* FAILED */ || status2.status === "cancelled" /* CANCELLED */ || status2.status === "refunded" /* REFUNDED */) {
5228
+ return status2;
5229
+ }
5230
+ await this.delay(interval);
5231
+ }
5232
+ const status = await this.getStatus(swapId);
5233
+ return status;
5234
+ }
5235
+ /**
5236
+ * Notify backend of deposit
5237
+ */
5238
+ async notifyDeposit(swapId, txHash, metadata) {
5239
+ const swap = this.swaps.get(swapId);
5240
+ if (!swap) {
5241
+ throw new ValidationError(
5242
+ "Swap not found",
5243
+ "swapId",
5244
+ { swapId },
5245
+ "SIP_2000" /* VALIDATION_FAILED */
5246
+ );
5247
+ }
5248
+ swap.depositTxHash = txHash;
5249
+ swap.status = "deposit_confirmed" /* DEPOSIT_CONFIRMED */;
5250
+ if (metadata) {
5251
+ swap.metadata = { ...swap.metadata, ...metadata };
5252
+ }
5253
+ this.swaps.set(swapId, swap);
5254
+ const quote = this.quotes.get(swap.quoteId);
5255
+ if (quote) {
5256
+ this.simulateSwapExecution(swapId, quote);
5257
+ }
5258
+ }
5259
+ // ─── Private Helpers ───────────────────────────────────────────────────────
5260
+ validateQuoteParams(params) {
5261
+ if (params.fromChain !== "zcash") {
5262
+ throw new ValidationError(
5263
+ "Source chain must be zcash",
5264
+ "fromChain",
5265
+ { received: params.fromChain, expected: "zcash" },
5266
+ "SIP_2000" /* VALIDATION_FAILED */
5267
+ );
5268
+ }
5269
+ if (params.toChain !== "zcash") {
5270
+ throw new ValidationError(
5271
+ "Destination chain must be zcash",
5272
+ "toChain",
5273
+ { received: params.toChain, expected: "zcash" },
5274
+ "SIP_2000" /* VALIDATION_FAILED */
5275
+ );
5276
+ }
5277
+ if (params.fromToken !== "ZEC") {
5278
+ throw new ValidationError(
5279
+ "Source token must be ZEC",
5280
+ "fromToken",
5281
+ { received: params.fromToken, expected: "ZEC" },
5282
+ "SIP_2000" /* VALIDATION_FAILED */
5283
+ );
5284
+ }
5285
+ if (params.toToken !== "ZEC") {
5286
+ throw new ValidationError(
5287
+ "Destination token must be ZEC",
5288
+ "toToken",
5289
+ { received: params.toToken, expected: "ZEC" },
5290
+ "SIP_2000" /* VALIDATION_FAILED */
5291
+ );
5292
+ }
5293
+ if (!params.amount || params.amount <= BigInt(0)) {
5294
+ throw new ValidationError(
5295
+ "Amount must be positive",
5296
+ "amount",
5297
+ { received: params.amount },
5298
+ "SIP_2004" /* INVALID_AMOUNT */
5299
+ );
5300
+ }
5301
+ if (!this.capabilities.supportedPrivacyLevels.includes(params.privacyLevel)) {
5302
+ throw new ValidationError(
5303
+ "Unsupported privacy level",
5304
+ "privacyLevel",
5305
+ { received: params.privacyLevel, supported: this.capabilities.supportedPrivacyLevels },
5306
+ "SIP_2000" /* VALIDATION_FAILED */
5307
+ );
5308
+ }
5309
+ }
5310
+ simulateSwapExecution(swapId, quote) {
5311
+ setTimeout(() => {
5312
+ const swap = this.swaps.get(swapId);
5313
+ if (!swap) return;
5314
+ swap.status = "in_progress" /* IN_PROGRESS */;
5315
+ this.swaps.set(swapId, swap);
5316
+ setTimeout(() => {
5317
+ const finalSwap = this.swaps.get(swapId);
5318
+ if (!finalSwap) return;
5319
+ finalSwap.status = "success" /* SUCCESS */;
5320
+ finalSwap.settlementTxHash = this.randomHex(64);
5321
+ finalSwap.actualAmountOut = quote.amountOut;
5322
+ this.swaps.set(swapId, finalSwap);
5323
+ }, 2e3);
5324
+ }, 1e3);
5325
+ }
5326
+ generateQuoteId() {
5327
+ return `zec_native_quote_${Date.now()}_${this.randomHex(8)}`;
5328
+ }
5329
+ generateSwapId() {
5330
+ return `zec_native_swap_${Date.now()}_${this.randomHex(8)}`;
5331
+ }
5332
+ randomHex(length) {
5333
+ const chars = "0123456789abcdef";
5334
+ let result = "";
5335
+ for (let i = 0; i < length; i++) {
5336
+ result += chars[Math.floor(Math.random() * chars.length)];
5337
+ }
5338
+ return result;
5339
+ }
5340
+ randomBase58(length) {
5341
+ const chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
5342
+ let result = "";
5343
+ for (let i = 0; i < length; i++) {
5344
+ result += chars[Math.floor(Math.random() * chars.length)];
5345
+ }
5346
+ return result;
5347
+ }
5348
+ delay(ms) {
5349
+ return new Promise((resolve) => setTimeout(resolve, ms));
5350
+ }
5351
+ };
5352
+ function createZcashNativeBackend(config) {
5353
+ return new ZcashNativeBackend(config);
5354
+ }
5355
+
5356
+ // src/settlement/backends/direct-chain.ts
5357
+ var import_types10 = require("@sip-protocol/types");
5358
+ var import_utils11 = require("@noble/hashes/utils");
5359
+ var DEFAULT_GAS_FEES = {
5360
+ ethereum: 21000n * 50n * 1000000000n,
5361
+ // 21k gas * 50 gwei = 0.00105 ETH
5362
+ solana: 5000n,
5363
+ // 5000 lamports = 0.000005 SOL
5364
+ near: 300000000000000000000n,
5365
+ // 0.3 NEAR in yoctoNEAR
5366
+ zcash: 10000n,
5367
+ // 0.0001 ZEC in zatoshi
5368
+ polygon: 21000n * 30n * 1000000000n,
5369
+ // 21k gas * 30 gwei POL
5370
+ arbitrum: 2100000000n,
5371
+ // 21k gas * 0.1 gwei ETH = 2100 gwei = 2.1e9 wei
5372
+ optimism: 21000000n,
5373
+ // 21k gas * 0.001 gwei ETH = 21 gwei = 21e6 wei
5374
+ base: 2100000000n,
5375
+ // 21k gas * 0.1 gwei ETH = 2100 gwei = 2.1e9 wei
5376
+ bitcoin: 10000n
5377
+ // 10000 sats = 0.0001 BTC (estimate for 1 input, 2 outputs)
5378
+ };
5379
+
5380
+ // src/zcash/rpc-client.ts
5381
+ var import_types11 = require("@sip-protocol/types");
4256
5382
  var DEFAULT_CONFIG = {
4257
5383
  host: "127.0.0.1",
4258
5384
  port: 8232,
@@ -4272,19 +5398,19 @@ var ZcashRPCError = class extends Error {
4272
5398
  * Check if error is due to insufficient funds
4273
5399
  */
4274
5400
  isInsufficientFunds() {
4275
- return this.code === import_types8.ZcashErrorCode.WALLET_INSUFFICIENT_FUNDS;
5401
+ return this.code === import_types11.ZcashErrorCode.WALLET_INSUFFICIENT_FUNDS;
4276
5402
  }
4277
5403
  /**
4278
5404
  * Check if error is due to invalid address
4279
5405
  */
4280
5406
  isInvalidAddress() {
4281
- return this.code === import_types8.ZcashErrorCode.INVALID_ADDRESS_OR_KEY;
5407
+ return this.code === import_types11.ZcashErrorCode.INVALID_ADDRESS_OR_KEY;
4282
5408
  }
4283
5409
  /**
4284
5410
  * Check if error is due to wallet being locked
4285
5411
  */
4286
5412
  isWalletLocked() {
4287
- return this.code === import_types8.ZcashErrorCode.WALLET_UNLOCK_NEEDED;
5413
+ return this.code === import_types11.ZcashErrorCode.WALLET_UNLOCK_NEEDED;
4288
5414
  }
4289
5415
  };
4290
5416
  var ZcashRPCClient = class {
@@ -4671,7 +5797,7 @@ function createZcashClient(config) {
4671
5797
  }
4672
5798
 
4673
5799
  // src/zcash/shielded-service.ts
4674
- var import_types9 = require("@sip-protocol/types");
5800
+ var import_types12 = require("@sip-protocol/types");
4675
5801
  var ZcashShieldedService = class _ZcashShieldedService {
4676
5802
  client;
4677
5803
  config;
@@ -4857,7 +5983,7 @@ var ZcashShieldedService = class _ZcashShieldedService {
4857
5983
  * Higher-level method that handles privacy level mapping.
4858
5984
  */
4859
5985
  async sendWithPrivacy(to, amount, privacyLevel, memo) {
4860
- if (privacyLevel === import_types9.PrivacyLevel.TRANSPARENT) {
5986
+ if (privacyLevel === import_types12.PrivacyLevel.TRANSPARENT) {
4861
5987
  throw new ValidationError(
4862
5988
  "Transparent mode not supported for Zcash shielded service. Use standard RPC client.",
4863
5989
  "privacyLevel",
@@ -4951,7 +6077,7 @@ var ZcashShieldedService = class _ZcashShieldedService {
4951
6077
  const viewingKey = await this.exportViewingKey();
4952
6078
  return {
4953
6079
  viewingKey,
4954
- privacyLevel: import_types9.PrivacyLevel.COMPLIANT,
6080
+ privacyLevel: import_types12.PrivacyLevel.COMPLIANT,
4955
6081
  disclaimer: "This viewing key provides read-only access to transaction history. It cannot be used to spend funds. Share only with authorized auditors."
4956
6082
  };
4957
6083
  }
@@ -5037,11 +6163,11 @@ var ZcashShieldedService = class _ZcashShieldedService {
5037
6163
  */
5038
6164
  mapPrivacyLevelToPolicy(level) {
5039
6165
  switch (level) {
5040
- case import_types9.PrivacyLevel.TRANSPARENT:
6166
+ case import_types12.PrivacyLevel.TRANSPARENT:
5041
6167
  return "NoPrivacy";
5042
- case import_types9.PrivacyLevel.SHIELDED:
6168
+ case import_types12.PrivacyLevel.SHIELDED:
5043
6169
  return "FullPrivacy";
5044
- case import_types9.PrivacyLevel.COMPLIANT:
6170
+ case import_types12.PrivacyLevel.COMPLIANT:
5045
6171
  return "FullPrivacy";
5046
6172
  default:
5047
6173
  return "FullPrivacy";
@@ -5094,7 +6220,7 @@ function createZcashShieldedService(config) {
5094
6220
  }
5095
6221
 
5096
6222
  // src/zcash/swap-service.ts
5097
- var import_types10 = require("@sip-protocol/types");
6223
+ var import_types13 = require("@sip-protocol/types");
5098
6224
  var MOCK_PRICES = {
5099
6225
  ETH: 2500,
5100
6226
  SOL: 120,
@@ -5201,7 +6327,7 @@ var ZcashSwapService = class {
5201
6327
  validUntil,
5202
6328
  depositAddress: this.generateMockDepositAddress(sourceChain),
5203
6329
  estimatedTime: this.getEstimatedTime(sourceChain),
5204
- privacyLevel: import_types10.PrivacyLevel.SHIELDED
6330
+ privacyLevel: import_types13.PrivacyLevel.SHIELDED
5205
6331
  };
5206
6332
  this.quotes.set(quoteId, quote);
5207
6333
  return quote;
@@ -5244,7 +6370,7 @@ var ZcashSwapService = class {
5244
6370
  depositAddress: "",
5245
6371
  // Will be set by bridge
5246
6372
  estimatedTime: this.getEstimatedTime(params.sourceChain),
5247
- privacyLevel: import_types10.PrivacyLevel.SHIELDED
6373
+ privacyLevel: import_types13.PrivacyLevel.SHIELDED
5248
6374
  };
5249
6375
  this.quotes.set(quote.quoteId, quote);
5250
6376
  return quote;
@@ -5524,15 +6650,15 @@ function createZcashSwapService(config) {
5524
6650
  }
5525
6651
 
5526
6652
  // src/zcash/index.ts
5527
- var import_types11 = require("@sip-protocol/types");
6653
+ var import_types14 = require("@sip-protocol/types");
5528
6654
 
5529
6655
  // src/index.ts
5530
- var import_types39 = require("@sip-protocol/types");
6656
+ var import_types42 = require("@sip-protocol/types");
5531
6657
 
5532
6658
  // src/payment/payment.ts
5533
- var import_types12 = require("@sip-protocol/types");
6659
+ var import_types15 = require("@sip-protocol/types");
5534
6660
  var import_sha2569 = require("@noble/hashes/sha256");
5535
- var import_utils11 = require("@noble/hashes/utils");
6661
+ var import_utils12 = require("@noble/hashes/utils");
5536
6662
  var import_chacha2 = require("@noble/ciphers/chacha.js");
5537
6663
  var import_hkdf2 = require("@noble/hashes/hkdf");
5538
6664
 
@@ -5717,7 +6843,7 @@ var PaymentBuilder = class {
5717
6843
  _amount;
5718
6844
  _recipientMetaAddress;
5719
6845
  _recipientAddress;
5720
- _privacy = import_types12.PrivacyLevel.SHIELDED;
6846
+ _privacy = import_types15.PrivacyLevel.SHIELDED;
5721
6847
  _viewingKey;
5722
6848
  _sourceChain;
5723
6849
  _destinationChain;
@@ -6000,7 +7126,7 @@ async function createShieldedPayment(params, options) {
6000
7126
  } else {
6001
7127
  resolvedToken = token;
6002
7128
  }
6003
- if (privacy !== import_types12.PrivacyLevel.TRANSPARENT && !recipientMetaAddress) {
7129
+ if (privacy !== import_types15.PrivacyLevel.TRANSPARENT && !recipientMetaAddress) {
6004
7130
  throw new ValidationError(
6005
7131
  "recipientMetaAddress is required for shielded/compliant privacy modes",
6006
7132
  "recipientMetaAddress",
@@ -6008,7 +7134,7 @@ async function createShieldedPayment(params, options) {
6008
7134
  "SIP_2008" /* MISSING_REQUIRED */
6009
7135
  );
6010
7136
  }
6011
- if (privacy === import_types12.PrivacyLevel.TRANSPARENT && !recipientAddress) {
7137
+ if (privacy === import_types15.PrivacyLevel.TRANSPARENT && !recipientAddress) {
6012
7138
  throw new ValidationError(
6013
7139
  "recipientAddress is required for transparent mode",
6014
7140
  "recipientAddress",
@@ -6016,7 +7142,7 @@ async function createShieldedPayment(params, options) {
6016
7142
  "SIP_2008" /* MISSING_REQUIRED */
6017
7143
  );
6018
7144
  }
6019
- if (privacy === import_types12.PrivacyLevel.COMPLIANT && !viewingKey) {
7145
+ if (privacy === import_types15.PrivacyLevel.COMPLIANT && !viewingKey) {
6020
7146
  throw new ValidationError(
6021
7147
  "viewingKey is required for compliant mode",
6022
7148
  "viewingKey",
@@ -6028,8 +7154,8 @@ async function createShieldedPayment(params, options) {
6028
7154
  let viewingKeyHash;
6029
7155
  if (viewingKey) {
6030
7156
  const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
6031
- const keyBytes = (0, import_utils11.hexToBytes)(keyHex);
6032
- viewingKeyHash = `0x${(0, import_utils11.bytesToHex)((0, import_sha2569.sha256)(keyBytes))}`;
7157
+ const keyBytes = (0, import_utils12.hexToBytes)(keyHex);
7158
+ viewingKeyHash = `0x${(0, import_utils12.bytesToHex)((0, import_sha2569.sha256)(keyBytes))}`;
6033
7159
  }
6034
7160
  const privacyConfig = getPrivacyConfig(
6035
7161
  privacy,
@@ -6038,7 +7164,7 @@ async function createShieldedPayment(params, options) {
6038
7164
  const now = Math.floor(Date.now() / 1e3);
6039
7165
  const payment = {
6040
7166
  paymentId,
6041
- version: import_types12.SIP_VERSION,
7167
+ version: import_types15.SIP_VERSION,
6042
7168
  privacyLevel: privacy,
6043
7169
  createdAt: now,
6044
7170
  expiry: now + ttl,
@@ -6049,7 +7175,7 @@ async function createShieldedPayment(params, options) {
6049
7175
  purpose,
6050
7176
  viewingKeyHash
6051
7177
  };
6052
- if (privacy !== import_types12.PrivacyLevel.TRANSPARENT && recipientMetaAddress) {
7178
+ if (privacy !== import_types15.PrivacyLevel.TRANSPARENT && recipientMetaAddress) {
6053
7179
  const metaAddress = decodeStealthMetaAddress(recipientMetaAddress);
6054
7180
  const { stealthAddress } = generateStealthAddress(metaAddress);
6055
7181
  payment.recipientStealth = stealthAddress;
@@ -6066,10 +7192,10 @@ async function createShieldedPayment(params, options) {
6066
7192
  payment.recipientAddress = recipientAddress;
6067
7193
  payment.memo = memo;
6068
7194
  }
6069
- if (privacy !== import_types12.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
7195
+ if (privacy !== import_types15.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
6070
7196
  const hexToUint8 = (hex) => {
6071
7197
  const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
6072
- return (0, import_utils11.hexToBytes)(cleanHex);
7198
+ return (0, import_utils12.hexToBytes)(cleanHex);
6073
7199
  };
6074
7200
  const fundingResult = await proofProvider.generateFundingProof({
6075
7201
  balance: amount,
@@ -6096,17 +7222,17 @@ async function createShieldedPayment(params, options) {
6096
7222
  }
6097
7223
  function encryptMemo(memo, viewingKey) {
6098
7224
  const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
6099
- const keyBytes = (0, import_utils11.hexToBytes)(keyHex);
7225
+ const keyBytes = (0, import_utils12.hexToBytes)(keyHex);
6100
7226
  const encKey = (0, import_hkdf2.hkdf)(import_sha2569.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
6101
7227
  try {
6102
- const nonce = (0, import_utils11.randomBytes)(24);
7228
+ const nonce = (0, import_utils12.randomBytes)(24);
6103
7229
  const cipher = (0, import_chacha2.xchacha20poly1305)(encKey, nonce);
6104
7230
  const plaintext = new TextEncoder().encode(memo);
6105
7231
  const ciphertext = cipher.encrypt(plaintext);
6106
7232
  const result = new Uint8Array(nonce.length + ciphertext.length);
6107
7233
  result.set(nonce);
6108
7234
  result.set(ciphertext, nonce.length);
6109
- return `0x${(0, import_utils11.bytesToHex)(result)}`;
7235
+ return `0x${(0, import_utils12.bytesToHex)(result)}`;
6110
7236
  } finally {
6111
7237
  secureWipe(keyBytes);
6112
7238
  secureWipe(encKey);
@@ -6114,11 +7240,11 @@ function encryptMemo(memo, viewingKey) {
6114
7240
  }
6115
7241
  function decryptMemo(encryptedMemo, viewingKey) {
6116
7242
  const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
6117
- const keyBytes = (0, import_utils11.hexToBytes)(keyHex);
7243
+ const keyBytes = (0, import_utils12.hexToBytes)(keyHex);
6118
7244
  const encKey = (0, import_hkdf2.hkdf)(import_sha2569.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
6119
7245
  try {
6120
7246
  const dataHex = encryptedMemo.startsWith("0x") ? encryptedMemo.slice(2) : encryptedMemo;
6121
- const data = (0, import_utils11.hexToBytes)(dataHex);
7247
+ const data = (0, import_utils12.hexToBytes)(dataHex);
6122
7248
  const nonce = data.slice(0, 24);
6123
7249
  const ciphertext = data.slice(24);
6124
7250
  const cipher = (0, import_chacha2.xchacha20poly1305)(encKey, nonce);
@@ -6132,7 +7258,7 @@ function decryptMemo(encryptedMemo, viewingKey) {
6132
7258
  function trackPayment(payment) {
6133
7259
  return {
6134
7260
  ...payment,
6135
- status: import_types12.PaymentStatus.DRAFT
7261
+ status: import_types15.PaymentStatus.DRAFT
6136
7262
  };
6137
7263
  }
6138
7264
  function isPaymentExpired(payment) {
@@ -6165,10 +7291,10 @@ function getPaymentSummary(payment) {
6165
7291
  }
6166
7292
 
6167
7293
  // src/treasury/treasury.ts
6168
- var import_types13 = require("@sip-protocol/types");
7294
+ var import_types16 = require("@sip-protocol/types");
6169
7295
  var import_secp256k13 = require("@noble/curves/secp256k1");
6170
7296
  var import_sha25610 = require("@noble/hashes/sha256");
6171
- var import_utils12 = require("@noble/hashes/utils");
7297
+ var import_utils13 = require("@noble/hashes/utils");
6172
7298
  var DEFAULT_PROPOSAL_TTL = 7 * 24 * 60 * 60;
6173
7299
  var Treasury = class _Treasury {
6174
7300
  config;
@@ -6198,7 +7324,7 @@ var Treasury = class _Treasury {
6198
7324
  ...m,
6199
7325
  addedAt: now
6200
7326
  })),
6201
- defaultPrivacy: params.defaultPrivacy ?? import_types13.PrivacyLevel.SHIELDED,
7327
+ defaultPrivacy: params.defaultPrivacy ?? import_types16.PrivacyLevel.SHIELDED,
6202
7328
  masterViewingKey,
6203
7329
  dailyLimit: params.dailyLimit,
6204
7330
  transactionLimit: params.transactionLimit,
@@ -6277,7 +7403,7 @@ var Treasury = class _Treasury {
6277
7403
  proposalId,
6278
7404
  treasuryId: this.config.treasuryId,
6279
7405
  type: "payment",
6280
- status: import_types13.ProposalStatus.PENDING,
7406
+ status: import_types16.ProposalStatus.PENDING,
6281
7407
  proposer: "",
6282
7408
  // Should be set by caller
6283
7409
  title: params.title,
@@ -6310,7 +7436,7 @@ var Treasury = class _Treasury {
6310
7436
  proposalId,
6311
7437
  treasuryId: this.config.treasuryId,
6312
7438
  type: "batch_payment",
6313
- status: import_types13.ProposalStatus.PENDING,
7439
+ status: import_types16.ProposalStatus.PENDING,
6314
7440
  proposer: "",
6315
7441
  title: params.title,
6316
7442
  description: params.description,
@@ -6344,7 +7470,7 @@ var Treasury = class _Treasury {
6344
7470
  * Get pending proposals
6345
7471
  */
6346
7472
  getPendingProposals() {
6347
- return this.getAllProposals().filter((p) => p.status === import_types13.ProposalStatus.PENDING);
7473
+ return this.getAllProposals().filter((p) => p.status === import_types16.ProposalStatus.PENDING);
6348
7474
  }
6349
7475
  /**
6350
7476
  * Sign a proposal
@@ -6375,7 +7501,7 @@ var Treasury = class _Treasury {
6375
7501
  "SIP_2001" /* INVALID_INPUT */
6376
7502
  );
6377
7503
  }
6378
- if (proposal.status !== import_types13.ProposalStatus.PENDING) {
7504
+ if (proposal.status !== import_types16.ProposalStatus.PENDING) {
6379
7505
  throw new ValidationError(
6380
7506
  `proposal is not pending: ${proposal.status}`,
6381
7507
  "proposalId",
@@ -6385,7 +7511,7 @@ var Treasury = class _Treasury {
6385
7511
  }
6386
7512
  const now = Math.floor(Date.now() / 1e3);
6387
7513
  if (now > proposal.expiresAt) {
6388
- proposal.status = import_types13.ProposalStatus.EXPIRED;
7514
+ proposal.status = import_types16.ProposalStatus.EXPIRED;
6389
7515
  throw new ValidationError(
6390
7516
  "proposal has expired",
6391
7517
  "proposalId",
@@ -6417,9 +7543,9 @@ var Treasury = class _Treasury {
6417
7543
  const approvals = proposal.signatures.filter((s) => s.approved).length;
6418
7544
  const rejections = proposal.signatures.filter((s) => !s.approved).length;
6419
7545
  if (approvals >= proposal.requiredSignatures) {
6420
- proposal.status = import_types13.ProposalStatus.APPROVED;
7546
+ proposal.status = import_types16.ProposalStatus.APPROVED;
6421
7547
  } else if (rejections > this.config.totalSigners - proposal.requiredSignatures) {
6422
- proposal.status = import_types13.ProposalStatus.REJECTED;
7548
+ proposal.status = import_types16.ProposalStatus.REJECTED;
6423
7549
  }
6424
7550
  return proposal;
6425
7551
  }
@@ -6436,7 +7562,7 @@ var Treasury = class _Treasury {
6436
7562
  "SIP_2001" /* INVALID_INPUT */
6437
7563
  );
6438
7564
  }
6439
- if (proposal.status !== import_types13.ProposalStatus.APPROVED) {
7565
+ if (proposal.status !== import_types16.ProposalStatus.APPROVED) {
6440
7566
  throw new ValidationError(
6441
7567
  `proposal is not approved: ${proposal.status}`,
6442
7568
  "proposalId",
@@ -6449,8 +7575,8 @@ var Treasury = class _Treasury {
6449
7575
  const payment = await createShieldedPayment({
6450
7576
  token: proposal.payment.token,
6451
7577
  amount: proposal.payment.amount,
6452
- recipientMetaAddress: proposal.payment.privacy !== import_types13.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
6453
- recipientAddress: proposal.payment.privacy === import_types13.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
7578
+ recipientMetaAddress: proposal.payment.privacy !== import_types16.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
7579
+ recipientAddress: proposal.payment.privacy === import_types16.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
6454
7580
  privacy: proposal.payment.privacy,
6455
7581
  viewingKey: this.config.masterViewingKey?.key,
6456
7582
  sourceChain: this.config.chain,
@@ -6463,8 +7589,8 @@ var Treasury = class _Treasury {
6463
7589
  const payment = await createShieldedPayment({
6464
7590
  token: proposal.batchPayment.token,
6465
7591
  amount: recipient.amount,
6466
- recipientMetaAddress: proposal.batchPayment.privacy !== import_types13.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
6467
- recipientAddress: proposal.batchPayment.privacy === import_types13.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
7592
+ recipientMetaAddress: proposal.batchPayment.privacy !== import_types16.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
7593
+ recipientAddress: proposal.batchPayment.privacy === import_types16.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
6468
7594
  privacy: proposal.batchPayment.privacy,
6469
7595
  viewingKey: this.config.masterViewingKey?.key,
6470
7596
  sourceChain: this.config.chain,
@@ -6474,7 +7600,7 @@ var Treasury = class _Treasury {
6474
7600
  payments.push(payment);
6475
7601
  }
6476
7602
  }
6477
- proposal.status = import_types13.ProposalStatus.EXECUTED;
7603
+ proposal.status = import_types16.ProposalStatus.EXECUTED;
6478
7604
  proposal.executedAt = Math.floor(Date.now() / 1e3);
6479
7605
  proposal.resultPayments = payments;
6480
7606
  return payments;
@@ -6503,7 +7629,7 @@ var Treasury = class _Treasury {
6503
7629
  "SIP_2001" /* INVALID_INPUT */
6504
7630
  );
6505
7631
  }
6506
- if (proposal.status !== import_types13.ProposalStatus.PENDING) {
7632
+ if (proposal.status !== import_types16.ProposalStatus.PENDING) {
6507
7633
  throw new ValidationError(
6508
7634
  `proposal is not pending: ${proposal.status}`,
6509
7635
  "proposalId",
@@ -6511,7 +7637,7 @@ var Treasury = class _Treasury {
6511
7637
  "SIP_2001" /* INVALID_INPUT */
6512
7638
  );
6513
7639
  }
6514
- proposal.status = import_types13.ProposalStatus.CANCELLED;
7640
+ proposal.status = import_types16.ProposalStatus.CANCELLED;
6515
7641
  return proposal;
6516
7642
  }
6517
7643
  // ─── Auditor Access ──────────────────────────────────────────────────────────
@@ -6608,7 +7734,7 @@ var Treasury = class _Treasury {
6608
7734
  getCommittedAmount(token) {
6609
7735
  let committed = 0n;
6610
7736
  for (const proposal of this.proposals.values()) {
6611
- if (proposal.status !== import_types13.ProposalStatus.PENDING) continue;
7737
+ if (proposal.status !== import_types16.ProposalStatus.PENDING) continue;
6612
7738
  if (proposal.type === "payment" && proposal.payment) {
6613
7739
  if (proposal.payment.token.symbol === token.symbol && proposal.payment.token.chain === token.chain) {
6614
7740
  committed += proposal.payment.amount;
@@ -6659,12 +7785,12 @@ var Treasury = class _Treasury {
6659
7785
  }
6660
7786
  };
6661
7787
  function generateTreasuryId() {
6662
- const bytes = (0, import_utils12.randomBytes)(16);
6663
- return `treasury_${(0, import_utils12.bytesToHex)(bytes)}`;
7788
+ const bytes = (0, import_utils13.randomBytes)(16);
7789
+ return `treasury_${(0, import_utils13.bytesToHex)(bytes)}`;
6664
7790
  }
6665
7791
  function generateProposalId() {
6666
- const bytes = (0, import_utils12.randomBytes)(16);
6667
- return `prop_${(0, import_utils12.bytesToHex)(bytes)}`;
7792
+ const bytes = (0, import_utils13.randomBytes)(16);
7793
+ return `prop_${(0, import_utils13.bytesToHex)(bytes)}`;
6668
7794
  }
6669
7795
  function computeProposalHash(proposal) {
6670
7796
  const data = JSON.stringify({
@@ -6680,7 +7806,7 @@ function computeProposalHash(proposal) {
6680
7806
  }
6681
7807
  function signMessage(messageHash, privateKey) {
6682
7808
  const keyHex = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
6683
- const keyBytes = (0, import_utils12.hexToBytes)(keyHex);
7809
+ const keyBytes = (0, import_utils13.hexToBytes)(keyHex);
6684
7810
  try {
6685
7811
  const signature = import_secp256k13.secp256k1.sign(messageHash, keyBytes);
6686
7812
  return `0x${signature.toCompactHex()}`;
@@ -6692,8 +7818,8 @@ function verifySignature(messageHash, signature, publicKey) {
6692
7818
  const sigHex = signature.startsWith("0x") ? signature.slice(2) : signature;
6693
7819
  const pubKeyHex = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
6694
7820
  try {
6695
- const sigBytes = (0, import_utils12.hexToBytes)(sigHex);
6696
- const pubKeyBytes = (0, import_utils12.hexToBytes)(pubKeyHex);
7821
+ const sigBytes = (0, import_utils13.hexToBytes)(sigHex);
7822
+ const pubKeyBytes = (0, import_utils13.hexToBytes)(pubKeyHex);
6697
7823
  return import_secp256k13.secp256k1.verify(sigBytes, messageHash, pubKeyBytes);
6698
7824
  } catch {
6699
7825
  return false;
@@ -6851,8 +7977,8 @@ function validateBatchProposalParams(params, config) {
6851
7977
  }
6852
7978
 
6853
7979
  // src/compliance/compliance-manager.ts
6854
- var import_types14 = require("@sip-protocol/types");
6855
- var import_utils13 = require("@noble/hashes/utils");
7980
+ var import_types17 = require("@sip-protocol/types");
7981
+ var import_utils14 = require("@noble/hashes/utils");
6856
7982
  var DEFAULTS2 = {
6857
7983
  riskThreshold: 70,
6858
7984
  highValueThreshold: 10000000000n,
@@ -7219,7 +8345,7 @@ var ComplianceManager = class _ComplianceManager {
7219
8345
  title: params.title,
7220
8346
  description: params.description,
7221
8347
  format: params.format,
7222
- status: import_types14.ReportStatus.GENERATING,
8348
+ status: import_types17.ReportStatus.GENERATING,
7223
8349
  requestedBy,
7224
8350
  requestedAt: now,
7225
8351
  startDate: params.startDate,
@@ -7248,10 +8374,10 @@ var ComplianceManager = class _ComplianceManager {
7248
8374
  } else if (params.format === "csv") {
7249
8375
  report.content = this.generateCSV(transactions);
7250
8376
  }
7251
- report.status = import_types14.ReportStatus.COMPLETED;
8377
+ report.status = import_types17.ReportStatus.COMPLETED;
7252
8378
  report.generatedAt = Math.floor(Date.now() / 1e3);
7253
8379
  } catch (error) {
7254
- report.status = import_types14.ReportStatus.FAILED;
8380
+ report.status = import_types17.ReportStatus.FAILED;
7255
8381
  report.error = error instanceof Error ? error.message : "Unknown error";
7256
8382
  }
7257
8383
  this.addAuditLog(requestedBy, "report_generated", {
@@ -7526,7 +8652,7 @@ var ComplianceManager = class _ComplianceManager {
7526
8652
  }
7527
8653
  };
7528
8654
  function generateId(prefix) {
7529
- return `${prefix}_${(0, import_utils13.bytesToHex)((0, import_utils13.randomBytes)(12))}`;
8655
+ return `${prefix}_${(0, import_utils14.bytesToHex)((0, import_utils14.randomBytes)(12))}`;
7530
8656
  }
7531
8657
  function validateRegisterAuditorParams(params) {
7532
8658
  if (!params.organization?.trim()) {
@@ -7614,10 +8740,10 @@ function validateReportParams(params) {
7614
8740
  }
7615
8741
 
7616
8742
  // src/wallet/errors.ts
7617
- var import_types15 = require("@sip-protocol/types");
8743
+ var import_types18 = require("@sip-protocol/types");
7618
8744
  var WalletError = class extends SIPError {
7619
8745
  walletCode;
7620
- constructor(message, walletCode = import_types15.WalletErrorCode.UNKNOWN, options) {
8746
+ constructor(message, walletCode = import_types18.WalletErrorCode.UNKNOWN, options) {
7621
8747
  super(message, "SIP_7000" /* WALLET_ERROR */, options);
7622
8748
  this.walletCode = walletCode;
7623
8749
  this.name = "WalletError";
@@ -7627,10 +8753,10 @@ var WalletError = class extends SIPError {
7627
8753
  */
7628
8754
  isConnectionError() {
7629
8755
  const codes = [
7630
- import_types15.WalletErrorCode.NOT_INSTALLED,
7631
- import_types15.WalletErrorCode.CONNECTION_REJECTED,
7632
- import_types15.WalletErrorCode.CONNECTION_FAILED,
7633
- import_types15.WalletErrorCode.NOT_CONNECTED
8756
+ import_types18.WalletErrorCode.NOT_INSTALLED,
8757
+ import_types18.WalletErrorCode.CONNECTION_REJECTED,
8758
+ import_types18.WalletErrorCode.CONNECTION_FAILED,
8759
+ import_types18.WalletErrorCode.NOT_CONNECTED
7634
8760
  ];
7635
8761
  return codes.includes(this.walletCode);
7636
8762
  }
@@ -7639,9 +8765,9 @@ var WalletError = class extends SIPError {
7639
8765
  */
7640
8766
  isSigningError() {
7641
8767
  const codes = [
7642
- import_types15.WalletErrorCode.SIGNING_REJECTED,
7643
- import_types15.WalletErrorCode.SIGNING_FAILED,
7644
- import_types15.WalletErrorCode.INVALID_MESSAGE
8768
+ import_types18.WalletErrorCode.SIGNING_REJECTED,
8769
+ import_types18.WalletErrorCode.SIGNING_FAILED,
8770
+ import_types18.WalletErrorCode.INVALID_MESSAGE
7645
8771
  ];
7646
8772
  return codes.includes(this.walletCode);
7647
8773
  }
@@ -7650,10 +8776,10 @@ var WalletError = class extends SIPError {
7650
8776
  */
7651
8777
  isTransactionError() {
7652
8778
  const codes = [
7653
- import_types15.WalletErrorCode.INSUFFICIENT_FUNDS,
7654
- import_types15.WalletErrorCode.TRANSACTION_REJECTED,
7655
- import_types15.WalletErrorCode.TRANSACTION_FAILED,
7656
- import_types15.WalletErrorCode.INVALID_TRANSACTION
8779
+ import_types18.WalletErrorCode.INSUFFICIENT_FUNDS,
8780
+ import_types18.WalletErrorCode.TRANSACTION_REJECTED,
8781
+ import_types18.WalletErrorCode.TRANSACTION_FAILED,
8782
+ import_types18.WalletErrorCode.INVALID_TRANSACTION
7657
8783
  ];
7658
8784
  return codes.includes(this.walletCode);
7659
8785
  }
@@ -7662,9 +8788,9 @@ var WalletError = class extends SIPError {
7662
8788
  */
7663
8789
  isPrivacyError() {
7664
8790
  const codes = [
7665
- import_types15.WalletErrorCode.STEALTH_NOT_SUPPORTED,
7666
- import_types15.WalletErrorCode.VIEWING_KEY_NOT_SUPPORTED,
7667
- import_types15.WalletErrorCode.SHIELDED_NOT_SUPPORTED
8791
+ import_types18.WalletErrorCode.STEALTH_NOT_SUPPORTED,
8792
+ import_types18.WalletErrorCode.VIEWING_KEY_NOT_SUPPORTED,
8793
+ import_types18.WalletErrorCode.SHIELDED_NOT_SUPPORTED
7668
8794
  ];
7669
8795
  return codes.includes(this.walletCode);
7670
8796
  }
@@ -7673,10 +8799,10 @@ var WalletError = class extends SIPError {
7673
8799
  */
7674
8800
  isUserRejection() {
7675
8801
  const codes = [
7676
- import_types15.WalletErrorCode.CONNECTION_REJECTED,
7677
- import_types15.WalletErrorCode.SIGNING_REJECTED,
7678
- import_types15.WalletErrorCode.TRANSACTION_REJECTED,
7679
- import_types15.WalletErrorCode.CHAIN_SWITCH_REJECTED
8802
+ import_types18.WalletErrorCode.CONNECTION_REJECTED,
8803
+ import_types18.WalletErrorCode.SIGNING_REJECTED,
8804
+ import_types18.WalletErrorCode.TRANSACTION_REJECTED,
8805
+ import_types18.WalletErrorCode.CHAIN_SWITCH_REJECTED
7680
8806
  ];
7681
8807
  return codes.includes(this.walletCode);
7682
8808
  }
@@ -7684,15 +8810,15 @@ var WalletError = class extends SIPError {
7684
8810
  function notConnectedError() {
7685
8811
  return new WalletError(
7686
8812
  "Wallet not connected. Call connect() first.",
7687
- import_types15.WalletErrorCode.NOT_CONNECTED
8813
+ import_types18.WalletErrorCode.NOT_CONNECTED
7688
8814
  );
7689
8815
  }
7690
- function featureNotSupportedError(feature, code = import_types15.WalletErrorCode.UNKNOWN) {
8816
+ function featureNotSupportedError(feature, code = import_types18.WalletErrorCode.UNKNOWN) {
7691
8817
  return new WalletError(`${feature} is not supported by this wallet`, code);
7692
8818
  }
7693
8819
 
7694
8820
  // src/wallet/base-adapter.ts
7695
- var import_types16 = require("@sip-protocol/types");
8821
+ var import_types19 = require("@sip-protocol/types");
7696
8822
  var BaseWalletAdapter = class {
7697
8823
  _address = "";
7698
8824
  _publicKey = "";
@@ -7855,12 +8981,12 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
7855
8981
  this._connectionState = "connecting";
7856
8982
  if (this.shouldFailConnect) {
7857
8983
  this.setError(
7858
- import_types16.WalletErrorCode.CONNECTION_FAILED,
8984
+ import_types19.WalletErrorCode.CONNECTION_FAILED,
7859
8985
  "Mock connection failure"
7860
8986
  );
7861
8987
  throw new WalletError(
7862
8988
  "Mock connection failure",
7863
- import_types16.WalletErrorCode.CONNECTION_FAILED
8989
+ import_types19.WalletErrorCode.CONNECTION_FAILED
7864
8990
  );
7865
8991
  }
7866
8992
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -7872,7 +8998,7 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
7872
8998
  async signMessage(message) {
7873
8999
  this.requireConnected();
7874
9000
  if (this.shouldFailSign) {
7875
- throw new WalletError("Mock signing failure", import_types16.WalletErrorCode.SIGNING_FAILED);
9001
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_FAILED);
7876
9002
  }
7877
9003
  const mockSig = new Uint8Array(64);
7878
9004
  for (let i = 0; i < 64; i++) {
@@ -7887,7 +9013,7 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
7887
9013
  async signTransaction(tx) {
7888
9014
  this.requireConnected();
7889
9015
  if (this.shouldFailSign) {
7890
- throw new WalletError("Mock signing failure", import_types16.WalletErrorCode.SIGNING_FAILED);
9016
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_FAILED);
7891
9017
  }
7892
9018
  const signature = await this.signMessage(
7893
9019
  new TextEncoder().encode(JSON.stringify(tx.data))
@@ -8069,7 +9195,7 @@ function isPrivateWalletAdapter(adapter) {
8069
9195
  }
8070
9196
 
8071
9197
  // src/wallet/solana/adapter.ts
8072
- var import_types17 = require("@sip-protocol/types");
9198
+ var import_types20 = require("@sip-protocol/types");
8073
9199
 
8074
9200
  // src/wallet/solana/types.ts
8075
9201
  function getSolanaProvider(wallet = "phantom") {
@@ -8190,19 +9316,19 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8190
9316
  }
8191
9317
  if (!this.provider) {
8192
9318
  this.setError(
8193
- import_types17.WalletErrorCode.NOT_INSTALLED,
9319
+ import_types20.WalletErrorCode.NOT_INSTALLED,
8194
9320
  `${this.walletName} wallet is not installed`
8195
9321
  );
8196
9322
  throw new WalletError(
8197
9323
  `${this.walletName} wallet is not installed`,
8198
- import_types17.WalletErrorCode.NOT_INSTALLED
9324
+ import_types20.WalletErrorCode.NOT_INSTALLED
8199
9325
  );
8200
9326
  }
8201
9327
  const { publicKey } = await this.provider.connect();
8202
9328
  if (!publicKey) {
8203
9329
  throw new WalletError(
8204
9330
  "No public key returned from wallet",
8205
- import_types17.WalletErrorCode.CONNECTION_FAILED
9331
+ import_types20.WalletErrorCode.CONNECTION_FAILED
8206
9332
  );
8207
9333
  }
8208
9334
  this.setupEventHandlers();
@@ -8212,11 +9338,11 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8212
9338
  } catch (error) {
8213
9339
  const message = error instanceof Error ? error.message : "Connection failed";
8214
9340
  if (message.includes("User rejected") || message.includes("rejected")) {
8215
- this.setError(import_types17.WalletErrorCode.CONNECTION_REJECTED, message);
8216
- throw new WalletError(message, import_types17.WalletErrorCode.CONNECTION_REJECTED);
9341
+ this.setError(import_types20.WalletErrorCode.CONNECTION_REJECTED, message);
9342
+ throw new WalletError(message, import_types20.WalletErrorCode.CONNECTION_REJECTED);
8217
9343
  }
8218
- this.setError(import_types17.WalletErrorCode.CONNECTION_FAILED, message);
8219
- throw error instanceof WalletError ? error : new WalletError(message, import_types17.WalletErrorCode.CONNECTION_FAILED, { cause: error });
9344
+ this.setError(import_types20.WalletErrorCode.CONNECTION_FAILED, message);
9345
+ throw error instanceof WalletError ? error : new WalletError(message, import_types20.WalletErrorCode.CONNECTION_FAILED, { cause: error });
8220
9346
  }
8221
9347
  }
8222
9348
  /**
@@ -8239,7 +9365,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8239
9365
  async signMessage(message) {
8240
9366
  this.requireConnected();
8241
9367
  if (!this.provider) {
8242
- throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
9368
+ throw new WalletError("Provider not available", import_types20.WalletErrorCode.NOT_CONNECTED);
8243
9369
  }
8244
9370
  try {
8245
9371
  const { signature } = await this.provider.signMessage(message);
@@ -8250,9 +9376,9 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8250
9376
  } catch (error) {
8251
9377
  const message2 = error instanceof Error ? error.message : "Signing failed";
8252
9378
  if (message2.includes("User rejected") || message2.includes("rejected")) {
8253
- throw new WalletError(message2, import_types17.WalletErrorCode.SIGNING_REJECTED);
9379
+ throw new WalletError(message2, import_types20.WalletErrorCode.SIGNING_REJECTED);
8254
9380
  }
8255
- throw new WalletError(message2, import_types17.WalletErrorCode.SIGNING_FAILED, {
9381
+ throw new WalletError(message2, import_types20.WalletErrorCode.SIGNING_FAILED, {
8256
9382
  cause: error
8257
9383
  });
8258
9384
  }
@@ -8265,7 +9391,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8265
9391
  async signTransaction(tx) {
8266
9392
  this.requireConnected();
8267
9393
  if (!this.provider) {
8268
- throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
9394
+ throw new WalletError("Provider not available", import_types20.WalletErrorCode.NOT_CONNECTED);
8269
9395
  }
8270
9396
  try {
8271
9397
  const solTx = tx.data;
@@ -8284,9 +9410,9 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8284
9410
  } catch (error) {
8285
9411
  const message = error instanceof Error ? error.message : "Signing failed";
8286
9412
  if (message.includes("User rejected") || message.includes("rejected")) {
8287
- throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_REJECTED);
9413
+ throw new WalletError(message, import_types20.WalletErrorCode.SIGNING_REJECTED);
8288
9414
  }
8289
- throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_FAILED, {
9415
+ throw new WalletError(message, import_types20.WalletErrorCode.SIGNING_FAILED, {
8290
9416
  cause: error
8291
9417
  });
8292
9418
  }
@@ -8297,7 +9423,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8297
9423
  async signAndSendTransaction(tx) {
8298
9424
  this.requireConnected();
8299
9425
  if (!this.provider) {
8300
- throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
9426
+ throw new WalletError("Provider not available", import_types20.WalletErrorCode.NOT_CONNECTED);
8301
9427
  }
8302
9428
  try {
8303
9429
  const solTx = tx.data;
@@ -8312,12 +9438,12 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8312
9438
  } catch (error) {
8313
9439
  const message = error instanceof Error ? error.message : "Transaction failed";
8314
9440
  if (message.includes("User rejected") || message.includes("rejected")) {
8315
- throw new WalletError(message, import_types17.WalletErrorCode.TRANSACTION_REJECTED);
9441
+ throw new WalletError(message, import_types20.WalletErrorCode.TRANSACTION_REJECTED);
8316
9442
  }
8317
9443
  if (message.includes("insufficient") || message.includes("Insufficient")) {
8318
- throw new WalletError(message, import_types17.WalletErrorCode.INSUFFICIENT_FUNDS);
9444
+ throw new WalletError(message, import_types20.WalletErrorCode.INSUFFICIENT_FUNDS);
8319
9445
  }
8320
- throw new WalletError(message, import_types17.WalletErrorCode.TRANSACTION_FAILED, {
9446
+ throw new WalletError(message, import_types20.WalletErrorCode.TRANSACTION_FAILED, {
8321
9447
  cause: error
8322
9448
  });
8323
9449
  }
@@ -8330,16 +9456,16 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8330
9456
  async signAllTransactions(transactions) {
8331
9457
  this.requireConnected();
8332
9458
  if (!this.provider) {
8333
- throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
9459
+ throw new WalletError("Provider not available", import_types20.WalletErrorCode.NOT_CONNECTED);
8334
9460
  }
8335
9461
  try {
8336
9462
  return await this.provider.signAllTransactions(transactions);
8337
9463
  } catch (error) {
8338
9464
  const message = error instanceof Error ? error.message : "Signing failed";
8339
9465
  if (message.includes("User rejected") || message.includes("rejected")) {
8340
- throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_REJECTED);
9466
+ throw new WalletError(message, import_types20.WalletErrorCode.SIGNING_REJECTED);
8341
9467
  }
8342
- throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_FAILED, {
9468
+ throw new WalletError(message, import_types20.WalletErrorCode.SIGNING_FAILED, {
8343
9469
  cause: error
8344
9470
  });
8345
9471
  }
@@ -8360,7 +9486,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8360
9486
  } catch (error) {
8361
9487
  throw new WalletError(
8362
9488
  "Failed to get balance",
8363
- import_types17.WalletErrorCode.UNKNOWN,
9489
+ import_types20.WalletErrorCode.UNKNOWN,
8364
9490
  { cause: error }
8365
9491
  );
8366
9492
  }
@@ -8373,7 +9499,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
8373
9499
  if (asset.chain !== "solana") {
8374
9500
  throw new WalletError(
8375
9501
  `Asset chain ${asset.chain} not supported by Solana adapter`,
8376
- import_types17.WalletErrorCode.UNSUPPORTED_CHAIN
9502
+ import_types20.WalletErrorCode.UNSUPPORTED_CHAIN
8377
9503
  );
8378
9504
  }
8379
9505
  if (!asset.address) {
@@ -8491,7 +9617,7 @@ function createSolanaAdapter(config = {}) {
8491
9617
  }
8492
9618
 
8493
9619
  // src/wallet/solana/mock.ts
8494
- var import_types19 = require("@sip-protocol/types");
9620
+ var import_types22 = require("@sip-protocol/types");
8495
9621
  var MockPublicKey = class {
8496
9622
  base58;
8497
9623
  bytes;
@@ -8557,8 +9683,8 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
8557
9683
  this._connectionState = "connecting";
8558
9684
  await this.simulateLatency();
8559
9685
  if (this.shouldFailConnect) {
8560
- this.setError(import_types19.WalletErrorCode.CONNECTION_FAILED, "Mock connection failure");
8561
- throw new WalletError("Mock connection failure", import_types19.WalletErrorCode.CONNECTION_FAILED);
9686
+ this.setError(import_types22.WalletErrorCode.CONNECTION_FAILED, "Mock connection failure");
9687
+ throw new WalletError("Mock connection failure", import_types22.WalletErrorCode.CONNECTION_FAILED);
8562
9688
  }
8563
9689
  const hexPubKey = "0x" + Buffer.from(this.mockPublicKey.toBytes()).toString("hex");
8564
9690
  this.setConnected(this.mockAddress, hexPubKey);
@@ -8577,7 +9703,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
8577
9703
  this.requireConnected();
8578
9704
  await this.simulateLatency();
8579
9705
  if (this.shouldFailSign) {
8580
- throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
9706
+ throw new WalletError("Mock signing failure", import_types22.WalletErrorCode.SIGNING_REJECTED);
8581
9707
  }
8582
9708
  const mockSig = new Uint8Array(64);
8583
9709
  for (let i = 0; i < 64; i++) {
@@ -8595,7 +9721,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
8595
9721
  this.requireConnected();
8596
9722
  await this.simulateLatency();
8597
9723
  if (this.shouldFailSign) {
8598
- throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
9724
+ throw new WalletError("Mock signing failure", import_types22.WalletErrorCode.SIGNING_REJECTED);
8599
9725
  }
8600
9726
  const solTx = tx.data;
8601
9727
  this.signedTransactions.push(solTx);
@@ -8615,10 +9741,10 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
8615
9741
  this.requireConnected();
8616
9742
  await this.simulateLatency();
8617
9743
  if (this.shouldFailSign) {
8618
- throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
9744
+ throw new WalletError("Mock signing failure", import_types22.WalletErrorCode.SIGNING_REJECTED);
8619
9745
  }
8620
9746
  if (this.shouldFailTransaction) {
8621
- throw new WalletError("Mock transaction failure", import_types19.WalletErrorCode.TRANSACTION_FAILED);
9747
+ throw new WalletError("Mock transaction failure", import_types22.WalletErrorCode.TRANSACTION_FAILED);
8622
9748
  }
8623
9749
  const txSig = `mock_tx_${Date.now()}_${Math.random().toString(36).slice(2)}`;
8624
9750
  this.sentTransactions.push(txSig);
@@ -8638,7 +9764,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
8638
9764
  this.requireConnected();
8639
9765
  await this.simulateLatency();
8640
9766
  if (this.shouldFailSign) {
8641
- throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
9767
+ throw new WalletError("Mock signing failure", import_types22.WalletErrorCode.SIGNING_REJECTED);
8642
9768
  }
8643
9769
  this.signedTransactions.push(...transactions);
8644
9770
  return transactions.map((tx) => {
@@ -8665,7 +9791,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
8665
9791
  if (asset.chain !== "solana") {
8666
9792
  throw new WalletError(
8667
9793
  `Asset chain ${asset.chain} not supported by Solana adapter`,
8668
- import_types19.WalletErrorCode.UNSUPPORTED_CHAIN
9794
+ import_types22.WalletErrorCode.UNSUPPORTED_CHAIN
8669
9795
  );
8670
9796
  }
8671
9797
  if (!asset.address) {
@@ -8834,7 +9960,7 @@ function createMockSolanaAdapter(config = {}) {
8834
9960
  }
8835
9961
 
8836
9962
  // src/wallet/ethereum/adapter.ts
8837
- var import_types21 = require("@sip-protocol/types");
9963
+ var import_types24 = require("@sip-protocol/types");
8838
9964
 
8839
9965
  // src/wallet/ethereum/types.ts
8840
9966
  var EthereumChainId = {
@@ -8976,7 +10102,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8976
10102
  this._connectionState = "error";
8977
10103
  throw new WalletError(
8978
10104
  `${this.walletType} wallet not found. Please install the extension.`,
8979
- import_types21.WalletErrorCode.NOT_INSTALLED
10105
+ import_types24.WalletErrorCode.NOT_INSTALLED
8980
10106
  );
8981
10107
  }
8982
10108
  const accounts = await this.provider.request({
@@ -8986,7 +10112,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8986
10112
  this._connectionState = "error";
8987
10113
  throw new WalletError(
8988
10114
  "No accounts returned from wallet",
8989
- import_types21.WalletErrorCode.CONNECTION_REJECTED
10115
+ import_types24.WalletErrorCode.CONNECTION_REJECTED
8990
10116
  );
8991
10117
  }
8992
10118
  const address = normalizeAddress(accounts[0]);
@@ -9006,12 +10132,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9006
10132
  if (rpcError.code === 4001) {
9007
10133
  throw new WalletError(
9008
10134
  "User rejected connection request",
9009
- import_types21.WalletErrorCode.CONNECTION_REJECTED
10135
+ import_types24.WalletErrorCode.CONNECTION_REJECTED
9010
10136
  );
9011
10137
  }
9012
10138
  throw new WalletError(
9013
10139
  `Failed to connect: ${rpcError.message || String(error)}`,
9014
- import_types21.WalletErrorCode.CONNECTION_FAILED
10140
+ import_types24.WalletErrorCode.CONNECTION_FAILED
9015
10141
  );
9016
10142
  }
9017
10143
  }
@@ -9031,7 +10157,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9031
10157
  if (!this.provider) {
9032
10158
  throw new WalletError(
9033
10159
  "Provider not available",
9034
- import_types21.WalletErrorCode.NOT_CONNECTED
10160
+ import_types24.WalletErrorCode.NOT_CONNECTED
9035
10161
  );
9036
10162
  }
9037
10163
  try {
@@ -9049,12 +10175,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9049
10175
  if (rpcError.code === 4001) {
9050
10176
  throw new WalletError(
9051
10177
  "User rejected signing request",
9052
- import_types21.WalletErrorCode.SIGNING_REJECTED
10178
+ import_types24.WalletErrorCode.SIGNING_REJECTED
9053
10179
  );
9054
10180
  }
9055
10181
  throw new WalletError(
9056
10182
  `Failed to sign message: ${rpcError.message || String(error)}`,
9057
- import_types21.WalletErrorCode.SIGNING_FAILED
10183
+ import_types24.WalletErrorCode.SIGNING_FAILED
9058
10184
  );
9059
10185
  }
9060
10186
  }
@@ -9066,7 +10192,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9066
10192
  if (!this.provider) {
9067
10193
  throw new WalletError(
9068
10194
  "Provider not available",
9069
- import_types21.WalletErrorCode.NOT_CONNECTED
10195
+ import_types24.WalletErrorCode.NOT_CONNECTED
9070
10196
  );
9071
10197
  }
9072
10198
  try {
@@ -9083,12 +10209,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9083
10209
  if (rpcError.code === 4001) {
9084
10210
  throw new WalletError(
9085
10211
  "User rejected signing request",
9086
- import_types21.WalletErrorCode.SIGNING_REJECTED
10212
+ import_types24.WalletErrorCode.SIGNING_REJECTED
9087
10213
  );
9088
10214
  }
9089
10215
  throw new WalletError(
9090
10216
  `Failed to sign typed data: ${rpcError.message || String(error)}`,
9091
- import_types21.WalletErrorCode.SIGNING_FAILED
10217
+ import_types24.WalletErrorCode.SIGNING_FAILED
9092
10218
  );
9093
10219
  }
9094
10220
  }
@@ -9100,7 +10226,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9100
10226
  if (!this.provider) {
9101
10227
  throw new WalletError(
9102
10228
  "Provider not available",
9103
- import_types21.WalletErrorCode.NOT_CONNECTED
10229
+ import_types24.WalletErrorCode.NOT_CONNECTED
9104
10230
  );
9105
10231
  }
9106
10232
  try {
@@ -9128,7 +10254,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9128
10254
  if (rpcError.code === 4001) {
9129
10255
  throw new WalletError(
9130
10256
  "User rejected transaction signing",
9131
- import_types21.WalletErrorCode.SIGNING_REJECTED
10257
+ import_types24.WalletErrorCode.SIGNING_REJECTED
9132
10258
  );
9133
10259
  }
9134
10260
  if (rpcError.code === -32601 || rpcError.message?.includes("not supported")) {
@@ -9146,7 +10272,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9146
10272
  }
9147
10273
  throw new WalletError(
9148
10274
  `Failed to sign transaction: ${rpcError.message || String(error)}`,
9149
- import_types21.WalletErrorCode.TRANSACTION_FAILED
10275
+ import_types24.WalletErrorCode.TRANSACTION_FAILED
9150
10276
  );
9151
10277
  }
9152
10278
  }
@@ -9158,7 +10284,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9158
10284
  if (!this.provider) {
9159
10285
  throw new WalletError(
9160
10286
  "Provider not available",
9161
- import_types21.WalletErrorCode.NOT_CONNECTED
10287
+ import_types24.WalletErrorCode.NOT_CONNECTED
9162
10288
  );
9163
10289
  }
9164
10290
  try {
@@ -9180,12 +10306,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9180
10306
  if (rpcError.code === 4001) {
9181
10307
  throw new WalletError(
9182
10308
  "User rejected transaction",
9183
- import_types21.WalletErrorCode.TRANSACTION_REJECTED
10309
+ import_types24.WalletErrorCode.TRANSACTION_REJECTED
9184
10310
  );
9185
10311
  }
9186
10312
  throw new WalletError(
9187
10313
  `Failed to send transaction: ${rpcError.message || String(error)}`,
9188
- import_types21.WalletErrorCode.TRANSACTION_FAILED
10314
+ import_types24.WalletErrorCode.TRANSACTION_FAILED
9189
10315
  );
9190
10316
  }
9191
10317
  }
@@ -9220,7 +10346,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9220
10346
  } catch (error) {
9221
10347
  throw new WalletError(
9222
10348
  `Failed to fetch balance: ${String(error)}`,
9223
- import_types21.WalletErrorCode.UNKNOWN
10349
+ import_types24.WalletErrorCode.UNKNOWN
9224
10350
  );
9225
10351
  }
9226
10352
  }
@@ -9232,7 +10358,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9232
10358
  if (asset.chain !== "ethereum") {
9233
10359
  throw new WalletError(
9234
10360
  `Asset chain ${asset.chain} not supported by Ethereum adapter`,
9235
- import_types21.WalletErrorCode.UNSUPPORTED_CHAIN
10361
+ import_types24.WalletErrorCode.UNSUPPORTED_CHAIN
9236
10362
  );
9237
10363
  }
9238
10364
  if (!asset.address) {
@@ -9257,7 +10383,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9257
10383
  } catch (error) {
9258
10384
  throw new WalletError(
9259
10385
  `Failed to fetch token balance: ${String(error)}`,
9260
- import_types21.WalletErrorCode.UNKNOWN
10386
+ import_types24.WalletErrorCode.UNKNOWN
9261
10387
  );
9262
10388
  }
9263
10389
  }
@@ -9269,7 +10395,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9269
10395
  if (!this.provider) {
9270
10396
  throw new WalletError(
9271
10397
  "Provider not available",
9272
- import_types21.WalletErrorCode.NOT_CONNECTED
10398
+ import_types24.WalletErrorCode.NOT_CONNECTED
9273
10399
  );
9274
10400
  }
9275
10401
  try {
@@ -9284,18 +10410,18 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9284
10410
  if (rpcError.code === 4001) {
9285
10411
  throw new WalletError(
9286
10412
  "User rejected chain switch",
9287
- import_types21.WalletErrorCode.CHAIN_SWITCH_REJECTED
10413
+ import_types24.WalletErrorCode.CHAIN_SWITCH_REJECTED
9288
10414
  );
9289
10415
  }
9290
10416
  if (rpcError.code === 4902) {
9291
10417
  throw new WalletError(
9292
10418
  `Chain ${chainId} not added to wallet`,
9293
- import_types21.WalletErrorCode.UNSUPPORTED_CHAIN
10419
+ import_types24.WalletErrorCode.UNSUPPORTED_CHAIN
9294
10420
  );
9295
10421
  }
9296
10422
  throw new WalletError(
9297
10423
  `Failed to switch chain: ${rpcError.message || String(error)}`,
9298
- import_types21.WalletErrorCode.CHAIN_SWITCH_FAILED
10424
+ import_types24.WalletErrorCode.CHAIN_SWITCH_FAILED
9299
10425
  );
9300
10426
  }
9301
10427
  }
@@ -9331,7 +10457,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
9331
10457
  }
9332
10458
  throw new WalletError(
9333
10459
  `Transaction ${txHash} not confirmed after ${maxAttempts * 5} seconds`,
9334
- import_types21.WalletErrorCode.TRANSACTION_FAILED
10460
+ import_types24.WalletErrorCode.TRANSACTION_FAILED
9335
10461
  );
9336
10462
  }
9337
10463
  /**
@@ -9405,7 +10531,7 @@ function createEthereumAdapter(config) {
9405
10531
  }
9406
10532
 
9407
10533
  // src/wallet/ethereum/mock.ts
9408
- var import_types23 = require("@sip-protocol/types");
10534
+ var import_types26 = require("@sip-protocol/types");
9409
10535
  var MockEthereumAdapter = class extends BaseWalletAdapter {
9410
10536
  chain = "ethereum";
9411
10537
  name = "mock-ethereum";
@@ -9446,7 +10572,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
9446
10572
  this._connectionState = "error";
9447
10573
  throw new WalletError(
9448
10574
  "Mock connection rejected",
9449
- import_types23.WalletErrorCode.CONNECTION_REJECTED
10575
+ import_types26.WalletErrorCode.CONNECTION_REJECTED
9450
10576
  );
9451
10577
  }
9452
10578
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -9458,7 +10584,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
9458
10584
  this._connectionState = "error";
9459
10585
  throw new WalletError(
9460
10586
  `Mock connection failed: ${String(error)}`,
9461
- import_types23.WalletErrorCode.CONNECTION_FAILED
10587
+ import_types26.WalletErrorCode.CONNECTION_FAILED
9462
10588
  );
9463
10589
  }
9464
10590
  }
@@ -9476,7 +10602,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
9476
10602
  if (this._shouldFailSign) {
9477
10603
  throw new WalletError(
9478
10604
  "Mock signing rejected",
9479
- import_types23.WalletErrorCode.SIGNING_REJECTED
10605
+ import_types26.WalletErrorCode.SIGNING_REJECTED
9480
10606
  );
9481
10607
  }
9482
10608
  const msgHex = Buffer.from(message).toString("hex");
@@ -9494,7 +10620,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
9494
10620
  if (this._shouldFailSign) {
9495
10621
  throw new WalletError(
9496
10622
  "Mock signing rejected",
9497
- import_types23.WalletErrorCode.SIGNING_REJECTED
10623
+ import_types26.WalletErrorCode.SIGNING_REJECTED
9498
10624
  );
9499
10625
  }
9500
10626
  const mockSig = `0x${"1".repeat(130)}`;
@@ -9511,7 +10637,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
9511
10637
  if (this._shouldFailSign) {
9512
10638
  throw new WalletError(
9513
10639
  "Mock signing rejected",
9514
- import_types23.WalletErrorCode.SIGNING_REJECTED
10640
+ import_types26.WalletErrorCode.SIGNING_REJECTED
9515
10641
  );
9516
10642
  }
9517
10643
  this._signedTransactions.push(tx);
@@ -9536,7 +10662,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
9536
10662
  if (this._shouldFailTransaction) {
9537
10663
  throw new WalletError(
9538
10664
  "Mock transaction failed",
9539
- import_types23.WalletErrorCode.TRANSACTION_FAILED
10665
+ import_types26.WalletErrorCode.TRANSACTION_FAILED
9540
10666
  );
9541
10667
  }
9542
10668
  this._signedTransactions.push(tx);
@@ -9566,7 +10692,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
9566
10692
  if (asset.chain !== "ethereum") {
9567
10693
  throw new WalletError(
9568
10694
  `Asset chain ${asset.chain} not supported by Ethereum adapter`,
9569
- import_types23.WalletErrorCode.UNSUPPORTED_CHAIN
10695
+ import_types26.WalletErrorCode.UNSUPPORTED_CHAIN
9570
10696
  );
9571
10697
  }
9572
10698
  if (!asset.address) {
@@ -9845,7 +10971,7 @@ function getAvailableTransports() {
9845
10971
  }
9846
10972
 
9847
10973
  // src/wallet/hardware/ledger.ts
9848
- var import_types26 = require("@sip-protocol/types");
10974
+ var import_types29 = require("@sip-protocol/types");
9849
10975
  var LedgerWalletAdapter = class extends BaseWalletAdapter {
9850
10976
  chain;
9851
10977
  name = "ledger";
@@ -9998,7 +11124,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
9998
11124
  async getBalance() {
9999
11125
  throw new WalletError(
10000
11126
  "Hardware wallets do not track balances. Use an RPC provider.",
10001
- import_types26.WalletErrorCode.UNSUPPORTED_OPERATION
11127
+ import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10002
11128
  );
10003
11129
  }
10004
11130
  /**
@@ -10009,7 +11135,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
10009
11135
  async getTokenBalance(_asset) {
10010
11136
  throw new WalletError(
10011
11137
  "Hardware wallets do not track balances. Use an RPC provider.",
10012
- import_types26.WalletErrorCode.UNSUPPORTED_OPERATION
11138
+ import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10013
11139
  );
10014
11140
  }
10015
11141
  // ─── Account Management ─────────────────────────────────────────────────────
@@ -10297,7 +11423,7 @@ function createLedgerAdapter(config) {
10297
11423
  }
10298
11424
 
10299
11425
  // src/wallet/hardware/trezor.ts
10300
- var import_types28 = require("@sip-protocol/types");
11426
+ var import_types31 = require("@sip-protocol/types");
10301
11427
  var TrezorWalletAdapter = class extends BaseWalletAdapter {
10302
11428
  chain;
10303
11429
  name = "trezor";
@@ -10443,7 +11569,7 @@ var TrezorWalletAdapter = class extends BaseWalletAdapter {
10443
11569
  async getBalance() {
10444
11570
  throw new WalletError(
10445
11571
  "Hardware wallets do not track balances. Use an RPC provider.",
10446
- import_types28.WalletErrorCode.UNSUPPORTED_OPERATION
11572
+ import_types31.WalletErrorCode.UNSUPPORTED_OPERATION
10447
11573
  );
10448
11574
  }
10449
11575
  /**
@@ -10454,7 +11580,7 @@ var TrezorWalletAdapter = class extends BaseWalletAdapter {
10454
11580
  async getTokenBalance(_asset) {
10455
11581
  throw new WalletError(
10456
11582
  "Hardware wallets do not track balances. Use an RPC provider.",
10457
- import_types28.WalletErrorCode.UNSUPPORTED_OPERATION
11583
+ import_types31.WalletErrorCode.UNSUPPORTED_OPERATION
10458
11584
  );
10459
11585
  }
10460
11586
  // ─── Account Management ─────────────────────────────────────────────────────
@@ -10735,8 +11861,8 @@ function createTrezorAdapter(config) {
10735
11861
  }
10736
11862
 
10737
11863
  // src/wallet/hardware/mock.ts
10738
- var import_types30 = require("@sip-protocol/types");
10739
- var import_utils14 = require("@noble/hashes/utils");
11864
+ var import_types33 = require("@sip-protocol/types");
11865
+ var import_utils15 = require("@noble/hashes/utils");
10740
11866
  var MockLedgerAdapter = class extends BaseWalletAdapter {
10741
11867
  chain;
10742
11868
  name = "mock-ledger";
@@ -10883,7 +12009,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
10883
12009
  async getBalance() {
10884
12010
  throw new WalletError(
10885
12011
  "Hardware wallets do not track balances",
10886
- import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
12012
+ import_types33.WalletErrorCode.UNSUPPORTED_OPERATION
10887
12013
  );
10888
12014
  }
10889
12015
  /**
@@ -10892,7 +12018,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
10892
12018
  async getTokenBalance(_asset) {
10893
12019
  throw new WalletError(
10894
12020
  "Hardware wallets do not track balances",
10895
- import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
12021
+ import_types33.WalletErrorCode.UNSUPPORTED_OPERATION
10896
12022
  );
10897
12023
  }
10898
12024
  /**
@@ -10981,15 +12107,15 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
10981
12107
  }
10982
12108
  }
10983
12109
  generateMockAddress(index) {
10984
- const bytes = (0, import_utils14.randomBytes)(20);
12110
+ const bytes = (0, import_utils15.randomBytes)(20);
10985
12111
  bytes[0] = index;
10986
- return `0x${(0, import_utils14.bytesToHex)(bytes)}`;
12112
+ return `0x${(0, import_utils15.bytesToHex)(bytes)}`;
10987
12113
  }
10988
12114
  generateMockPublicKey(index) {
10989
- const bytes = (0, import_utils14.randomBytes)(33);
12115
+ const bytes = (0, import_utils15.randomBytes)(33);
10990
12116
  bytes[0] = 2;
10991
12117
  bytes[1] = index;
10992
- return `0x${(0, import_utils14.bytesToHex)(bytes)}`;
12118
+ return `0x${(0, import_utils15.bytesToHex)(bytes)}`;
10993
12119
  }
10994
12120
  generateMockSignature(data) {
10995
12121
  const sig = new Uint8Array(65);
@@ -10998,7 +12124,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
10998
12124
  sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 11;
10999
12125
  }
11000
12126
  sig[64] = 27;
11001
- return `0x${(0, import_utils14.bytesToHex)(sig)}`;
12127
+ return `0x${(0, import_utils15.bytesToHex)(sig)}`;
11002
12128
  }
11003
12129
  delay(ms) {
11004
12130
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -11122,13 +12248,13 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
11122
12248
  async getBalance() {
11123
12249
  throw new WalletError(
11124
12250
  "Hardware wallets do not track balances",
11125
- import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
12251
+ import_types33.WalletErrorCode.UNSUPPORTED_OPERATION
11126
12252
  );
11127
12253
  }
11128
12254
  async getTokenBalance(_asset) {
11129
12255
  throw new WalletError(
11130
12256
  "Hardware wallets do not track balances",
11131
- import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
12257
+ import_types33.WalletErrorCode.UNSUPPORTED_OPERATION
11132
12258
  );
11133
12259
  }
11134
12260
  async getAccounts(startIndex = 0, count = 5) {
@@ -11187,15 +12313,15 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
11187
12313
  }
11188
12314
  }
11189
12315
  generateMockAddress(index) {
11190
- const bytes = (0, import_utils14.randomBytes)(20);
12316
+ const bytes = (0, import_utils15.randomBytes)(20);
11191
12317
  bytes[0] = index + 100;
11192
- return `0x${(0, import_utils14.bytesToHex)(bytes)}`;
12318
+ return `0x${(0, import_utils15.bytesToHex)(bytes)}`;
11193
12319
  }
11194
12320
  generateMockPublicKey(index) {
11195
- const bytes = (0, import_utils14.randomBytes)(33);
12321
+ const bytes = (0, import_utils15.randomBytes)(33);
11196
12322
  bytes[0] = 3;
11197
12323
  bytes[1] = index + 100;
11198
- return `0x${(0, import_utils14.bytesToHex)(bytes)}`;
12324
+ return `0x${(0, import_utils15.bytesToHex)(bytes)}`;
11199
12325
  }
11200
12326
  generateMockSignature(data) {
11201
12327
  const sig = new Uint8Array(65);
@@ -11204,7 +12330,7 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
11204
12330
  sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 17;
11205
12331
  }
11206
12332
  sig[64] = 28;
11207
- return `0x${(0, import_utils14.bytesToHex)(sig)}`;
12333
+ return `0x${(0, import_utils15.bytesToHex)(sig)}`;
11208
12334
  }
11209
12335
  delay(ms) {
11210
12336
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -11218,7 +12344,7 @@ function createMockTrezorAdapter(config) {
11218
12344
  }
11219
12345
 
11220
12346
  // src/wallet/index.ts
11221
- var import_types33 = require("@sip-protocol/types");
12347
+ var import_types36 = require("@sip-protocol/types");
11222
12348
 
11223
12349
  // src/proofs/browser.ts
11224
12350
  var import_noir_js = require("@noir-lang/noir_js");
@@ -13193,6 +14319,7 @@ var ProofWorker = class _ProofWorker {
13193
14319
  MockWalletAdapter,
13194
14320
  NATIVE_TOKENS,
13195
14321
  NEARIntentsAdapter,
14322
+ NEARIntentsBackend,
13196
14323
  NetworkError,
13197
14324
  ORACLE_DOMAIN,
13198
14325
  OneClickClient,
@@ -13215,13 +14342,18 @@ var ProofWorker = class _ProofWorker {
13215
14342
  STABLECOIN_ADDRESSES,
13216
14343
  STABLECOIN_DECIMALS,
13217
14344
  STABLECOIN_INFO,
14345
+ SettlementRegistry,
14346
+ SettlementRegistryError,
14347
+ SmartRouter,
13218
14348
  SolanaWalletAdapter,
14349
+ SwapStatus,
13219
14350
  Treasury,
13220
14351
  TrezorWalletAdapter,
13221
14352
  ValidationError,
13222
14353
  WalletError,
13223
14354
  WalletErrorCode,
13224
14355
  ZcashErrorCode,
14356
+ ZcashNativeBackend,
13225
14357
  ZcashRPCClient,
13226
14358
  ZcashRPCError,
13227
14359
  ZcashShieldedService,
@@ -13251,16 +14383,19 @@ var ProofWorker = class _ProofWorker {
13251
14383
  createMockSolver,
13252
14384
  createMockTrezorAdapter,
13253
14385
  createNEARIntentsAdapter,
14386
+ createNEARIntentsBackend,
13254
14387
  createOracleRegistry,
13255
14388
  createProductionSIP,
13256
14389
  createSIP,
13257
14390
  createShieldedIntent,
13258
14391
  createShieldedPayment,
14392
+ createSmartRouter,
13259
14393
  createSolanaAdapter,
13260
14394
  createTrezorAdapter,
13261
14395
  createWalletFactory,
13262
14396
  createWorkerBlobURL,
13263
14397
  createZcashClient,
14398
+ createZcashNativeBackend,
13264
14399
  createZcashShieldedService,
13265
14400
  createZcashSwapService,
13266
14401
  decodeStealthMetaAddress,