@sip-protocol/sdk 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ __export(index_exports, {
46
46
  HardwareWalletError: () => HardwareWalletError,
47
47
  IntentBuilder: () => IntentBuilder,
48
48
  IntentError: () => IntentError,
49
- IntentStatus: () => import_types33.IntentStatus,
49
+ IntentStatus: () => import_types34.IntentStatus,
50
50
  LedgerWalletAdapter: () => LedgerWalletAdapter,
51
51
  MockEthereumAdapter: () => MockEthereumAdapter,
52
52
  MockLedgerAdapter: () => MockLedgerAdapter,
@@ -55,26 +55,26 @@ __export(index_exports, {
55
55
  MockSolver: () => MockSolver,
56
56
  MockTrezorAdapter: () => MockTrezorAdapter,
57
57
  MockWalletAdapter: () => MockWalletAdapter,
58
- NATIVE_TOKENS: () => import_types33.NATIVE_TOKENS,
58
+ NATIVE_TOKENS: () => import_types34.NATIVE_TOKENS,
59
59
  NEARIntentsAdapter: () => NEARIntentsAdapter,
60
60
  NetworkError: () => NetworkError,
61
61
  ORACLE_DOMAIN: () => ORACLE_DOMAIN,
62
62
  OneClickClient: () => OneClickClient,
63
- OneClickDepositMode: () => import_types37.OneClickDepositMode,
64
- OneClickErrorCode: () => import_types37.OneClickErrorCode,
65
- OneClickSwapStatus: () => import_types37.OneClickSwapStatus,
66
- OneClickSwapType: () => import_types37.OneClickSwapType,
63
+ OneClickDepositMode: () => import_types38.OneClickDepositMode,
64
+ OneClickErrorCode: () => import_types38.OneClickErrorCode,
65
+ OneClickSwapStatus: () => import_types38.OneClickSwapStatus,
66
+ OneClickSwapType: () => import_types38.OneClickSwapType,
67
67
  PaymentBuilder: () => PaymentBuilder,
68
- PaymentStatus: () => import_types34.PaymentStatus,
69
- PrivacyLevel: () => import_types33.PrivacyLevel,
68
+ PaymentStatus: () => import_types35.PaymentStatus,
69
+ PrivacyLevel: () => import_types34.PrivacyLevel,
70
70
  ProofError: () => ProofError,
71
71
  ProofGenerationError: () => ProofGenerationError,
72
72
  ProofNotImplementedError: () => ProofNotImplementedError,
73
- ProposalStatus: () => import_types35.ProposalStatus,
74
- ReportStatus: () => import_types36.ReportStatus,
73
+ ProposalStatus: () => import_types36.ProposalStatus,
74
+ ReportStatus: () => import_types37.ReportStatus,
75
75
  SIP: () => SIP,
76
76
  SIPError: () => SIPError,
77
- SIP_VERSION: () => import_types33.SIP_VERSION,
77
+ SIP_VERSION: () => import_types34.SIP_VERSION,
78
78
  STABLECOIN_ADDRESSES: () => STABLECOIN_ADDRESSES,
79
79
  STABLECOIN_DECIMALS: () => STABLECOIN_DECIMALS,
80
80
  STABLECOIN_INFO: () => STABLECOIN_INFO,
@@ -83,11 +83,12 @@ __export(index_exports, {
83
83
  TrezorWalletAdapter: () => TrezorWalletAdapter,
84
84
  ValidationError: () => ValidationError,
85
85
  WalletError: () => WalletError,
86
- WalletErrorCode: () => import_types32.WalletErrorCode,
87
- ZcashErrorCode: () => import_types38.ZcashErrorCode,
86
+ WalletErrorCode: () => import_types33.WalletErrorCode,
87
+ ZcashErrorCode: () => import_types39.ZcashErrorCode,
88
88
  ZcashRPCClient: () => ZcashRPCClient,
89
89
  ZcashRPCError: () => ZcashRPCError,
90
90
  ZcashShieldedService: () => ZcashShieldedService,
91
+ ZcashSwapService: () => ZcashSwapService,
91
92
  addBlindings: () => addBlindings,
92
93
  addCommitments: () => addCommitments,
93
94
  addOracle: () => addOracle,
@@ -122,6 +123,7 @@ __export(index_exports, {
122
123
  createWalletFactory: () => createWalletFactory,
123
124
  createZcashClient: () => createZcashClient,
124
125
  createZcashShieldedService: () => createZcashShieldedService,
126
+ createZcashSwapService: () => createZcashSwapService,
125
127
  decodeStealthMetaAddress: () => decodeStealthMetaAddress,
126
128
  decryptMemo: () => decryptMemo,
127
129
  decryptWithViewing: () => decryptWithViewing,
@@ -182,7 +184,7 @@ __export(index_exports, {
182
184
  isExpired: () => isExpired,
183
185
  isNonNegativeAmount: () => isNonNegativeAmount,
184
186
  isPaymentExpired: () => isPaymentExpired,
185
- isPrivate: () => import_types33.isPrivate,
187
+ isPrivate: () => import_types34.isPrivate,
186
188
  isPrivateWalletAdapter: () => isPrivateWalletAdapter,
187
189
  isSIPError: () => isSIPError,
188
190
  isStablecoin: () => isStablecoin,
@@ -218,7 +220,7 @@ __export(index_exports, {
218
220
  subtractBlindings: () => subtractBlindings,
219
221
  subtractCommitments: () => subtractCommitments,
220
222
  supportsSharedArrayBuffer: () => supportsSharedArrayBuffer,
221
- supportsViewingKey: () => import_types33.supportsViewingKey,
223
+ supportsViewingKey: () => import_types34.supportsViewingKey,
222
224
  supportsWebBluetooth: () => supportsWebBluetooth,
223
225
  supportsWebHID: () => supportsWebHID,
224
226
  supportsWebUSB: () => supportsWebUSB,
@@ -2456,22 +2458,43 @@ var DEFAULT_ASSET_MAPPINGS = {
2456
2458
  // NEAR assets
2457
2459
  "near:NEAR": "nep141:wrap.near",
2458
2460
  "near:wNEAR": "nep141:wrap.near",
2461
+ "near:USDC": "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1",
2459
2462
  // Ethereum assets (via OMFT bridge)
2460
2463
  "ethereum:ETH": "nep141:eth.omft.near",
2461
- "ethereum:USDC": "nep141:17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1",
2462
- "ethereum:USDT": "nep141:usdt.tether-token.near",
2464
+ "ethereum:USDC": "nep141:eth-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.omft.near",
2465
+ "ethereum:USDT": "nep141:eth-0xdac17f958d2ee523a2206206994597c13d831ec7.omft.near",
2463
2466
  // Solana assets (via OMFT bridge)
2464
2467
  "solana:SOL": "nep141:sol.omft.near",
2468
+ "solana:USDC": "nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near",
2469
+ "solana:USDT": "nep141:sol-c800a4bd850783ccb82c2b2c7e84175443606352.omft.near",
2465
2470
  // Zcash assets
2466
2471
  "zcash:ZEC": "nep141:zec.omft.near",
2467
2472
  // Arbitrum assets
2468
2473
  "arbitrum:ETH": "nep141:arb.omft.near",
2474
+ "arbitrum:ARB": "nep141:arb-0x912ce59144191c1204e64559fe8253a0e49e6548.omft.near",
2475
+ "arbitrum:USDC": "nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near",
2469
2476
  // Base assets
2470
2477
  "base:ETH": "nep141:base.omft.near",
2471
- // Polygon assets (support both MATIC and POL symbols)
2472
- "polygon:MATIC": "nep141:matic.omft.near",
2473
- "polygon:POL": "nep141:matic.omft.near"
2478
+ "base:USDC": "nep141:base-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913.omft.near",
2479
+ // Optimism assets (via HOT bridge - uses nep245)
2480
+ "optimism:ETH": "nep245:v2_1.omni.hot.tg:10_11111111111111111111",
2481
+ "optimism:OP": "nep245:v2_1.omni.hot.tg:10_vLAiSt9KfUGKpw5cD3vsSyNYBo7",
2482
+ "optimism:USDC": "nep245:v2_1.omni.hot.tg:10_A2ewyUyDp6qsue1jqZsGypkCxRJ",
2483
+ // Polygon assets (via HOT bridge - uses nep245)
2484
+ "polygon:POL": "nep245:v2_1.omni.hot.tg:137_11111111111111111111",
2485
+ "polygon:MATIC": "nep245:v2_1.omni.hot.tg:137_11111111111111111111",
2474
2486
  // POL is the rebranded MATIC
2487
+ "polygon:USDC": "nep245:v2_1.omni.hot.tg:137_qiStmoQJDQPTebaPjgx5VBxZv6L",
2488
+ // BNB Chain assets (via HOT bridge - uses nep245)
2489
+ "bsc:BNB": "nep245:v2_1.omni.hot.tg:56_11111111111111111111",
2490
+ "bsc:USDC": "nep245:v2_1.omni.hot.tg:56_2w93GqMcEmQFDru84j3HZZWt557r",
2491
+ // Avalanche assets (via HOT bridge - uses nep245)
2492
+ "avalanche:AVAX": "nep245:v2_1.omni.hot.tg:43114_11111111111111111111",
2493
+ "avalanche:USDC": "nep245:v2_1.omni.hot.tg:43114_3atVJH3r5c4GqiSYmg9fECvjc47o",
2494
+ // Bitcoin
2495
+ "bitcoin:BTC": "nep141:btc.omft.near",
2496
+ // Aptos
2497
+ "aptos:APT": "nep141:aptos.omft.near"
2475
2498
  };
2476
2499
  var CHAIN_BLOCKCHAIN_MAP = {
2477
2500
  near: "near",
@@ -3751,10 +3774,10 @@ function hasEnoughOracles(registry) {
3751
3774
  }
3752
3775
 
3753
3776
  // src/index.ts
3754
- var import_types33 = require("@sip-protocol/types");
3755
3777
  var import_types34 = require("@sip-protocol/types");
3756
3778
  var import_types35 = require("@sip-protocol/types");
3757
3779
  var import_types36 = require("@sip-protocol/types");
3780
+ var import_types37 = require("@sip-protocol/types");
3758
3781
 
3759
3782
  // src/solver/mock-solver.ts
3760
3783
  var import_types7 = require("@sip-protocol/types");
@@ -3939,7 +3962,7 @@ function createMockSolver(config) {
3939
3962
  }
3940
3963
 
3941
3964
  // src/index.ts
3942
- var import_types37 = require("@sip-protocol/types");
3965
+ var import_types38 = require("@sip-protocol/types");
3943
3966
 
3944
3967
  // src/zcash/rpc-client.ts
3945
3968
  var import_types8 = require("@sip-protocol/types");
@@ -4783,14 +4806,444 @@ function createZcashShieldedService(config) {
4783
4806
  return new ZcashShieldedService(config);
4784
4807
  }
4785
4808
 
4786
- // src/zcash/index.ts
4809
+ // src/zcash/swap-service.ts
4787
4810
  var import_types10 = require("@sip-protocol/types");
4811
+ var MOCK_PRICES = {
4812
+ ETH: 2500,
4813
+ SOL: 120,
4814
+ NEAR: 5,
4815
+ MATIC: 0.8,
4816
+ USDC: 1,
4817
+ USDT: 1,
4818
+ ZEC: 35
4819
+ };
4820
+ var TOKEN_DECIMALS = {
4821
+ ETH: 18,
4822
+ SOL: 9,
4823
+ NEAR: 24,
4824
+ MATIC: 18,
4825
+ USDC: 6,
4826
+ USDT: 6,
4827
+ ZEC: 8
4828
+ // zatoshis
4829
+ };
4830
+ var ZcashSwapService = class {
4831
+ config;
4832
+ zcashService;
4833
+ bridgeProvider;
4834
+ priceFeed;
4835
+ quotes = /* @__PURE__ */ new Map();
4836
+ swaps = /* @__PURE__ */ new Map();
4837
+ constructor(config) {
4838
+ this.config = {
4839
+ mode: config.mode,
4840
+ defaultSlippage: config.defaultSlippage ?? 100,
4841
+ // 1%
4842
+ quoteValiditySeconds: config.quoteValiditySeconds ?? 60
4843
+ };
4844
+ this.zcashService = config.zcashService;
4845
+ this.bridgeProvider = config.bridgeProvider;
4846
+ this.priceFeed = config.priceFeed;
4847
+ }
4848
+ // ─── Quote Methods ───────────────────────────────────────────────────────────
4849
+ /**
4850
+ * Get a quote for swapping to ZEC
4851
+ */
4852
+ async getQuote(params) {
4853
+ this.validateQuoteParams(params);
4854
+ if (this.zcashService) {
4855
+ const addressInfo = await this.zcashService.validateAddress(params.recipientZAddress);
4856
+ if (!addressInfo.isvalid) {
4857
+ throw new ValidationError(
4858
+ "Invalid Zcash address",
4859
+ "recipientZAddress",
4860
+ { received: params.recipientZAddress },
4861
+ "SIP_2007" /* INVALID_ADDRESS */
4862
+ );
4863
+ }
4864
+ } else {
4865
+ if (!this.isValidZAddressFormat(params.recipientZAddress)) {
4866
+ throw new ValidationError(
4867
+ "Invalid Zcash address format. Expected z-address (zs1...) or unified address (u1...)",
4868
+ "recipientZAddress",
4869
+ { received: params.recipientZAddress },
4870
+ "SIP_2007" /* INVALID_ADDRESS */
4871
+ );
4872
+ }
4873
+ }
4874
+ if (this.config.mode === "production" && this.bridgeProvider) {
4875
+ return this.getProductionQuote(params);
4876
+ }
4877
+ return this.getDemoQuote(params);
4878
+ }
4879
+ /**
4880
+ * Get quote in demo mode (uses mock prices)
4881
+ */
4882
+ async getDemoQuote(params) {
4883
+ const { sourceChain, sourceToken, amount, recipientZAddress, slippage } = params;
4884
+ const sourcePrice = this.priceFeed ? await this.priceFeed.getPrice(sourceToken) : MOCK_PRICES[sourceToken] ?? 1;
4885
+ const zecPrice = this.priceFeed ? await this.priceFeed.getZecPrice() : MOCK_PRICES.ZEC;
4886
+ const sourceDecimals = TOKEN_DECIMALS[sourceToken] ?? 18;
4887
+ const amountInUsd = Number(amount) / 10 ** sourceDecimals * sourcePrice;
4888
+ const swapFeeUsd = amountInUsd * 5e-3;
4889
+ const networkFeeUsd = 2;
4890
+ const totalFeeUsd = swapFeeUsd + networkFeeUsd;
4891
+ const netAmountUsd = amountInUsd - totalFeeUsd;
4892
+ const zecAmount = netAmountUsd / zecPrice;
4893
+ const zecZatoshis = BigInt(Math.floor(zecAmount * 1e8));
4894
+ const slippageBps = slippage ?? this.config.defaultSlippage;
4895
+ const minimumOutput = zecZatoshis * BigInt(1e4 - slippageBps) / 10000n;
4896
+ const swapFee = BigInt(Math.floor(swapFeeUsd / sourcePrice * 10 ** sourceDecimals));
4897
+ const networkFee = BigInt(Math.floor(networkFeeUsd / sourcePrice * 10 ** sourceDecimals));
4898
+ const quoteId = `zec_quote_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
4899
+ const validUntil = Math.floor(Date.now() / 1e3) + this.config.quoteValiditySeconds;
4900
+ const quote = {
4901
+ quoteId,
4902
+ sourceChain,
4903
+ sourceToken,
4904
+ amountIn: amount,
4905
+ amountInFormatted: this.formatAmount(amount, sourceDecimals),
4906
+ amountOut: zecZatoshis,
4907
+ amountOutFormatted: this.formatAmount(zecZatoshis, 8),
4908
+ exchangeRate: zecPrice / sourcePrice,
4909
+ networkFee,
4910
+ swapFee,
4911
+ totalFee: networkFee + swapFee,
4912
+ slippage: slippageBps,
4913
+ minimumOutput,
4914
+ validUntil,
4915
+ depositAddress: this.generateMockDepositAddress(sourceChain),
4916
+ estimatedTime: this.getEstimatedTime(sourceChain),
4917
+ privacyLevel: import_types10.PrivacyLevel.SHIELDED
4918
+ };
4919
+ this.quotes.set(quoteId, quote);
4920
+ return quote;
4921
+ }
4922
+ /**
4923
+ * Get quote in production mode (uses bridge provider)
4924
+ */
4925
+ async getProductionQuote(params) {
4926
+ if (!this.bridgeProvider) {
4927
+ throw new IntentError(
4928
+ "Bridge provider not configured for production mode",
4929
+ "SIP_5004" /* INTENT_INVALID_STATE */
4930
+ );
4931
+ }
4932
+ const bridgeQuote = await this.bridgeProvider.getQuote({
4933
+ sourceChain: params.sourceChain,
4934
+ sourceToken: params.sourceToken,
4935
+ amount: params.amount,
4936
+ recipientAddress: params.recipientZAddress
4937
+ });
4938
+ const sourceDecimals = TOKEN_DECIMALS[params.sourceToken] ?? 18;
4939
+ const slippageBps = params.slippage ?? this.config.defaultSlippage;
4940
+ const minimumOutput = bridgeQuote.amountOut * BigInt(1e4 - slippageBps) / 10000n;
4941
+ const quote = {
4942
+ quoteId: bridgeQuote.quoteId,
4943
+ sourceChain: params.sourceChain,
4944
+ sourceToken: params.sourceToken,
4945
+ amountIn: bridgeQuote.amountIn,
4946
+ amountInFormatted: this.formatAmount(bridgeQuote.amountIn, sourceDecimals),
4947
+ amountOut: bridgeQuote.amountOut,
4948
+ amountOutFormatted: this.formatAmount(bridgeQuote.amountOut, 8),
4949
+ exchangeRate: bridgeQuote.exchangeRate,
4950
+ networkFee: 0n,
4951
+ // Included in bridge fee
4952
+ swapFee: bridgeQuote.fee,
4953
+ totalFee: bridgeQuote.fee,
4954
+ slippage: slippageBps,
4955
+ minimumOutput,
4956
+ validUntil: bridgeQuote.validUntil,
4957
+ depositAddress: "",
4958
+ // Will be set by bridge
4959
+ estimatedTime: this.getEstimatedTime(params.sourceChain),
4960
+ privacyLevel: import_types10.PrivacyLevel.SHIELDED
4961
+ };
4962
+ this.quotes.set(quote.quoteId, quote);
4963
+ return quote;
4964
+ }
4965
+ // ─── Swap Execution ──────────────────────────────────────────────────────────
4966
+ /**
4967
+ * Execute a swap to Zcash shielded pool
4968
+ */
4969
+ async executeSwapToShielded(params) {
4970
+ let quote;
4971
+ if (params.quoteId) {
4972
+ quote = this.quotes.get(params.quoteId);
4973
+ if (!quote) {
4974
+ throw new ValidationError(
4975
+ "Quote not found or expired",
4976
+ "quoteId",
4977
+ { received: params.quoteId },
4978
+ "SIP_2000" /* VALIDATION_FAILED */
4979
+ );
4980
+ }
4981
+ }
4982
+ if (!quote) {
4983
+ quote = await this.getQuote({
4984
+ sourceChain: params.sourceChain,
4985
+ sourceToken: params.sourceToken,
4986
+ amount: params.amount,
4987
+ recipientZAddress: params.recipientZAddress,
4988
+ slippage: params.slippage
4989
+ });
4990
+ }
4991
+ if (quote.validUntil < Math.floor(Date.now() / 1e3)) {
4992
+ throw new IntentError(
4993
+ "Quote has expired",
4994
+ "SIP_5001" /* INTENT_EXPIRED */,
4995
+ { context: { quoteId: quote.quoteId, validUntil: quote.validUntil } }
4996
+ );
4997
+ }
4998
+ const requestId = `zec_swap_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
4999
+ const result = {
5000
+ requestId,
5001
+ quoteId: quote.quoteId,
5002
+ status: "pending_deposit",
5003
+ amountIn: params.amount,
5004
+ recipientZAddress: params.recipientZAddress,
5005
+ timestamp: Math.floor(Date.now() / 1e3)
5006
+ };
5007
+ this.swaps.set(requestId, result);
5008
+ if (this.config.mode === "production" && this.bridgeProvider) {
5009
+ return this.executeProductionSwap(result, quote, params);
5010
+ }
5011
+ return this.executeDemoSwap(result, quote, params);
5012
+ }
5013
+ /**
5014
+ * Execute swap in demo mode
5015
+ */
5016
+ async executeDemoSwap(result, quote, params) {
5017
+ result.status = "deposit_confirmed";
5018
+ result.sourceTxHash = `0x${this.randomHex(64)}`;
5019
+ this.swaps.set(result.requestId, { ...result });
5020
+ await this.delay(100);
5021
+ result.status = "swapping";
5022
+ this.swaps.set(result.requestId, { ...result });
5023
+ await this.delay(100);
5024
+ result.status = "sending_zec";
5025
+ this.swaps.set(result.requestId, { ...result });
5026
+ if (this.zcashService) {
5027
+ try {
5028
+ const zecAmount = Number(quote.amountOut) / 1e8;
5029
+ const sendResult = await this.zcashService.sendShielded({
5030
+ to: params.recipientZAddress,
5031
+ amount: zecAmount,
5032
+ memo: params.memo ?? `SIP Swap: ${params.sourceToken} \u2192 ZEC`
5033
+ });
5034
+ result.status = "completed";
5035
+ result.zcashTxId = sendResult.txid;
5036
+ result.amountOut = quote.amountOut;
5037
+ } catch (error) {
5038
+ result.status = "completed";
5039
+ result.zcashTxId = this.randomHex(64);
5040
+ result.amountOut = quote.amountOut;
5041
+ }
5042
+ } else {
5043
+ result.status = "completed";
5044
+ result.zcashTxId = this.randomHex(64);
5045
+ result.amountOut = quote.amountOut;
5046
+ }
5047
+ this.swaps.set(result.requestId, { ...result });
5048
+ return result;
5049
+ }
5050
+ /**
5051
+ * Execute swap in production mode
5052
+ */
5053
+ async executeProductionSwap(result, quote, params) {
5054
+ if (!this.bridgeProvider) {
5055
+ throw new IntentError(
5056
+ "Bridge provider not configured",
5057
+ "SIP_5004" /* INTENT_INVALID_STATE */
5058
+ );
5059
+ }
5060
+ try {
5061
+ const bridgeResult = await this.bridgeProvider.executeSwap({
5062
+ sourceChain: params.sourceChain,
5063
+ sourceToken: params.sourceToken,
5064
+ amount: params.amount,
5065
+ recipientAddress: params.recipientZAddress,
5066
+ quoteId: quote.quoteId,
5067
+ depositAddress: quote.depositAddress
5068
+ });
5069
+ result.sourceTxHash = bridgeResult.txHash;
5070
+ result.status = bridgeResult.status === "completed" ? "completed" : "swapping";
5071
+ if (bridgeResult.amountReceived) {
5072
+ result.amountOut = bridgeResult.amountReceived;
5073
+ }
5074
+ } catch (error) {
5075
+ result.status = "failed";
5076
+ result.error = error instanceof Error ? error.message : "Bridge execution failed";
5077
+ }
5078
+ this.swaps.set(result.requestId, { ...result });
5079
+ return result;
5080
+ }
5081
+ // ─── Status Methods ──────────────────────────────────────────────────────────
5082
+ /**
5083
+ * Get swap status
5084
+ */
5085
+ async getSwapStatus(requestId) {
5086
+ return this.swaps.get(requestId) ?? null;
5087
+ }
5088
+ /**
5089
+ * Wait for swap completion
5090
+ */
5091
+ async waitForCompletion(requestId, timeout = 3e5, pollInterval = 5e3) {
5092
+ const startTime = Date.now();
5093
+ while (Date.now() - startTime < timeout) {
5094
+ const status = await this.getSwapStatus(requestId);
5095
+ if (!status) {
5096
+ throw new IntentError(
5097
+ "Swap not found",
5098
+ "SIP_5003" /* INTENT_NOT_FOUND */,
5099
+ { context: { requestId } }
5100
+ );
5101
+ }
5102
+ if (status.status === "completed") {
5103
+ return status;
5104
+ }
5105
+ if (status.status === "failed" || status.status === "expired") {
5106
+ throw new IntentError(
5107
+ `Swap ${status.status}: ${status.error ?? "Unknown error"}`,
5108
+ "SIP_5000" /* INTENT_FAILED */,
5109
+ { context: { requestId, status } }
5110
+ );
5111
+ }
5112
+ await this.delay(pollInterval);
5113
+ }
5114
+ throw new NetworkError(
5115
+ "Swap completion timeout",
5116
+ "SIP_6001" /* NETWORK_TIMEOUT */,
5117
+ { context: { requestId, timeout } }
5118
+ );
5119
+ }
5120
+ // ─── Utility Methods ─────────────────────────────────────────────────────────
5121
+ /**
5122
+ * Get supported source chains
5123
+ */
5124
+ async getSupportedChains() {
5125
+ if (this.bridgeProvider) {
5126
+ return this.bridgeProvider.getSupportedChains();
5127
+ }
5128
+ return ["ethereum", "solana", "near", "polygon", "arbitrum", "base"];
5129
+ }
5130
+ /**
5131
+ * Get supported source tokens for a chain
5132
+ */
5133
+ getSupportedTokens(chain) {
5134
+ const tokensByChain = {
5135
+ ethereum: ["ETH", "USDC", "USDT"],
5136
+ solana: ["SOL", "USDC", "USDT"],
5137
+ near: ["NEAR", "USDC", "USDT"],
5138
+ polygon: ["MATIC", "USDC", "USDT"],
5139
+ arbitrum: ["ETH", "USDC", "USDT"],
5140
+ base: ["ETH", "USDC"]
5141
+ };
5142
+ return tokensByChain[chain] ?? [];
5143
+ }
5144
+ /**
5145
+ * Check if a swap route is supported
5146
+ */
5147
+ isRouteSupported(chain, token) {
5148
+ return this.getSupportedTokens(chain).includes(token);
5149
+ }
5150
+ // ─── Private Helpers ─────────────────────────────────────────────────────────
5151
+ validateQuoteParams(params) {
5152
+ if (!params.sourceChain) {
5153
+ throw new ValidationError("Source chain is required", "sourceChain", void 0, "SIP_2000" /* VALIDATION_FAILED */);
5154
+ }
5155
+ if (!params.sourceToken) {
5156
+ throw new ValidationError("Source token is required", "sourceToken", void 0, "SIP_2000" /* VALIDATION_FAILED */);
5157
+ }
5158
+ if (!params.amount || params.amount <= 0n) {
5159
+ throw new ValidationError("Amount must be positive", "amount", { received: params.amount }, "SIP_2004" /* INVALID_AMOUNT */);
5160
+ }
5161
+ if (!params.recipientZAddress) {
5162
+ throw new ValidationError("Recipient z-address is required", "recipientZAddress", void 0, "SIP_2000" /* VALIDATION_FAILED */);
5163
+ }
5164
+ if (!this.isRouteSupported(params.sourceChain, params.sourceToken)) {
5165
+ throw new ValidationError(
5166
+ `Unsupported swap route: ${params.sourceChain}:${params.sourceToken} \u2192 ZEC`,
5167
+ "sourceToken",
5168
+ { chain: params.sourceChain, token: params.sourceToken },
5169
+ "SIP_2000" /* VALIDATION_FAILED */
5170
+ );
5171
+ }
5172
+ }
5173
+ isValidZAddressFormat(address) {
5174
+ return address.startsWith("zs1") || address.startsWith("u1") || address.startsWith("ztestsapling") || address.startsWith("utest");
5175
+ }
5176
+ generateMockDepositAddress(chain) {
5177
+ switch (chain) {
5178
+ case "ethereum":
5179
+ case "polygon":
5180
+ case "arbitrum":
5181
+ case "base":
5182
+ return `0x${this.randomHex(40)}`;
5183
+ case "solana":
5184
+ return this.randomBase58(44);
5185
+ case "near":
5186
+ return `deposit_${this.randomHex(8)}.near`;
5187
+ default:
5188
+ return `0x${this.randomHex(40)}`;
5189
+ }
5190
+ }
5191
+ getEstimatedTime(chain) {
5192
+ const times = {
5193
+ ethereum: 900,
5194
+ // ~15 min (confirmations + processing)
5195
+ solana: 300,
5196
+ // ~5 min
5197
+ near: 300,
5198
+ // ~5 min
5199
+ polygon: 600,
5200
+ // ~10 min
5201
+ arbitrum: 600,
5202
+ // ~10 min
5203
+ base: 600
5204
+ // ~10 min
5205
+ };
5206
+ return times[chain] ?? 600;
5207
+ }
5208
+ formatAmount(amount, decimals) {
5209
+ const divisor = 10 ** decimals;
5210
+ const whole = amount / BigInt(divisor);
5211
+ const fraction = amount % BigInt(divisor);
5212
+ const fractionStr = fraction.toString().padStart(decimals, "0").replace(/0+$/, "");
5213
+ return fractionStr ? `${whole}.${fractionStr}` : whole.toString();
5214
+ }
5215
+ randomHex(length) {
5216
+ const chars = "0123456789abcdef";
5217
+ let result = "";
5218
+ for (let i = 0; i < length; i++) {
5219
+ result += chars[Math.floor(Math.random() * chars.length)];
5220
+ }
5221
+ return result;
5222
+ }
5223
+ randomBase58(length) {
5224
+ const chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
5225
+ let result = "";
5226
+ for (let i = 0; i < length; i++) {
5227
+ result += chars[Math.floor(Math.random() * chars.length)];
5228
+ }
5229
+ return result;
5230
+ }
5231
+ delay(ms) {
5232
+ return new Promise((resolve) => setTimeout(resolve, ms));
5233
+ }
5234
+ };
5235
+ function createZcashSwapService(config) {
5236
+ return new ZcashSwapService(config);
5237
+ }
5238
+
5239
+ // src/zcash/index.ts
5240
+ var import_types11 = require("@sip-protocol/types");
4788
5241
 
4789
5242
  // src/index.ts
4790
- var import_types38 = require("@sip-protocol/types");
5243
+ var import_types39 = require("@sip-protocol/types");
4791
5244
 
4792
5245
  // src/payment/payment.ts
4793
- var import_types11 = require("@sip-protocol/types");
5246
+ var import_types12 = require("@sip-protocol/types");
4794
5247
  var import_sha2569 = require("@noble/hashes/sha256");
4795
5248
  var import_utils11 = require("@noble/hashes/utils");
4796
5249
  var import_chacha2 = require("@noble/ciphers/chacha.js");
@@ -4977,7 +5430,7 @@ var PaymentBuilder = class {
4977
5430
  _amount;
4978
5431
  _recipientMetaAddress;
4979
5432
  _recipientAddress;
4980
- _privacy = import_types11.PrivacyLevel.SHIELDED;
5433
+ _privacy = import_types12.PrivacyLevel.SHIELDED;
4981
5434
  _viewingKey;
4982
5435
  _sourceChain;
4983
5436
  _destinationChain;
@@ -5260,7 +5713,7 @@ async function createShieldedPayment(params, options) {
5260
5713
  } else {
5261
5714
  resolvedToken = token;
5262
5715
  }
5263
- if (privacy !== import_types11.PrivacyLevel.TRANSPARENT && !recipientMetaAddress) {
5716
+ if (privacy !== import_types12.PrivacyLevel.TRANSPARENT && !recipientMetaAddress) {
5264
5717
  throw new ValidationError(
5265
5718
  "recipientMetaAddress is required for shielded/compliant privacy modes",
5266
5719
  "recipientMetaAddress",
@@ -5268,7 +5721,7 @@ async function createShieldedPayment(params, options) {
5268
5721
  "SIP_2008" /* MISSING_REQUIRED */
5269
5722
  );
5270
5723
  }
5271
- if (privacy === import_types11.PrivacyLevel.TRANSPARENT && !recipientAddress) {
5724
+ if (privacy === import_types12.PrivacyLevel.TRANSPARENT && !recipientAddress) {
5272
5725
  throw new ValidationError(
5273
5726
  "recipientAddress is required for transparent mode",
5274
5727
  "recipientAddress",
@@ -5276,7 +5729,7 @@ async function createShieldedPayment(params, options) {
5276
5729
  "SIP_2008" /* MISSING_REQUIRED */
5277
5730
  );
5278
5731
  }
5279
- if (privacy === import_types11.PrivacyLevel.COMPLIANT && !viewingKey) {
5732
+ if (privacy === import_types12.PrivacyLevel.COMPLIANT && !viewingKey) {
5280
5733
  throw new ValidationError(
5281
5734
  "viewingKey is required for compliant mode",
5282
5735
  "viewingKey",
@@ -5298,7 +5751,7 @@ async function createShieldedPayment(params, options) {
5298
5751
  const now = Math.floor(Date.now() / 1e3);
5299
5752
  const payment = {
5300
5753
  paymentId,
5301
- version: import_types11.SIP_VERSION,
5754
+ version: import_types12.SIP_VERSION,
5302
5755
  privacyLevel: privacy,
5303
5756
  createdAt: now,
5304
5757
  expiry: now + ttl,
@@ -5309,7 +5762,7 @@ async function createShieldedPayment(params, options) {
5309
5762
  purpose,
5310
5763
  viewingKeyHash
5311
5764
  };
5312
- if (privacy !== import_types11.PrivacyLevel.TRANSPARENT && recipientMetaAddress) {
5765
+ if (privacy !== import_types12.PrivacyLevel.TRANSPARENT && recipientMetaAddress) {
5313
5766
  const metaAddress = decodeStealthMetaAddress(recipientMetaAddress);
5314
5767
  const { stealthAddress } = generateStealthAddress(metaAddress);
5315
5768
  payment.recipientStealth = stealthAddress;
@@ -5326,7 +5779,7 @@ async function createShieldedPayment(params, options) {
5326
5779
  payment.recipientAddress = recipientAddress;
5327
5780
  payment.memo = memo;
5328
5781
  }
5329
- if (privacy !== import_types11.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
5782
+ if (privacy !== import_types12.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
5330
5783
  const hexToUint8 = (hex) => {
5331
5784
  const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
5332
5785
  return (0, import_utils11.hexToBytes)(cleanHex);
@@ -5392,7 +5845,7 @@ function decryptMemo(encryptedMemo, viewingKey) {
5392
5845
  function trackPayment(payment) {
5393
5846
  return {
5394
5847
  ...payment,
5395
- status: import_types11.PaymentStatus.DRAFT
5848
+ status: import_types12.PaymentStatus.DRAFT
5396
5849
  };
5397
5850
  }
5398
5851
  function isPaymentExpired(payment) {
@@ -5425,7 +5878,7 @@ function getPaymentSummary(payment) {
5425
5878
  }
5426
5879
 
5427
5880
  // src/treasury/treasury.ts
5428
- var import_types12 = require("@sip-protocol/types");
5881
+ var import_types13 = require("@sip-protocol/types");
5429
5882
  var import_secp256k13 = require("@noble/curves/secp256k1");
5430
5883
  var import_sha25610 = require("@noble/hashes/sha256");
5431
5884
  var import_utils12 = require("@noble/hashes/utils");
@@ -5458,7 +5911,7 @@ var Treasury = class _Treasury {
5458
5911
  ...m,
5459
5912
  addedAt: now
5460
5913
  })),
5461
- defaultPrivacy: params.defaultPrivacy ?? import_types12.PrivacyLevel.SHIELDED,
5914
+ defaultPrivacy: params.defaultPrivacy ?? import_types13.PrivacyLevel.SHIELDED,
5462
5915
  masterViewingKey,
5463
5916
  dailyLimit: params.dailyLimit,
5464
5917
  transactionLimit: params.transactionLimit,
@@ -5537,7 +5990,7 @@ var Treasury = class _Treasury {
5537
5990
  proposalId,
5538
5991
  treasuryId: this.config.treasuryId,
5539
5992
  type: "payment",
5540
- status: import_types12.ProposalStatus.PENDING,
5993
+ status: import_types13.ProposalStatus.PENDING,
5541
5994
  proposer: "",
5542
5995
  // Should be set by caller
5543
5996
  title: params.title,
@@ -5570,7 +6023,7 @@ var Treasury = class _Treasury {
5570
6023
  proposalId,
5571
6024
  treasuryId: this.config.treasuryId,
5572
6025
  type: "batch_payment",
5573
- status: import_types12.ProposalStatus.PENDING,
6026
+ status: import_types13.ProposalStatus.PENDING,
5574
6027
  proposer: "",
5575
6028
  title: params.title,
5576
6029
  description: params.description,
@@ -5604,7 +6057,7 @@ var Treasury = class _Treasury {
5604
6057
  * Get pending proposals
5605
6058
  */
5606
6059
  getPendingProposals() {
5607
- return this.getAllProposals().filter((p) => p.status === import_types12.ProposalStatus.PENDING);
6060
+ return this.getAllProposals().filter((p) => p.status === import_types13.ProposalStatus.PENDING);
5608
6061
  }
5609
6062
  /**
5610
6063
  * Sign a proposal
@@ -5635,7 +6088,7 @@ var Treasury = class _Treasury {
5635
6088
  "SIP_2001" /* INVALID_INPUT */
5636
6089
  );
5637
6090
  }
5638
- if (proposal.status !== import_types12.ProposalStatus.PENDING) {
6091
+ if (proposal.status !== import_types13.ProposalStatus.PENDING) {
5639
6092
  throw new ValidationError(
5640
6093
  `proposal is not pending: ${proposal.status}`,
5641
6094
  "proposalId",
@@ -5645,7 +6098,7 @@ var Treasury = class _Treasury {
5645
6098
  }
5646
6099
  const now = Math.floor(Date.now() / 1e3);
5647
6100
  if (now > proposal.expiresAt) {
5648
- proposal.status = import_types12.ProposalStatus.EXPIRED;
6101
+ proposal.status = import_types13.ProposalStatus.EXPIRED;
5649
6102
  throw new ValidationError(
5650
6103
  "proposal has expired",
5651
6104
  "proposalId",
@@ -5677,9 +6130,9 @@ var Treasury = class _Treasury {
5677
6130
  const approvals = proposal.signatures.filter((s) => s.approved).length;
5678
6131
  const rejections = proposal.signatures.filter((s) => !s.approved).length;
5679
6132
  if (approvals >= proposal.requiredSignatures) {
5680
- proposal.status = import_types12.ProposalStatus.APPROVED;
6133
+ proposal.status = import_types13.ProposalStatus.APPROVED;
5681
6134
  } else if (rejections > this.config.totalSigners - proposal.requiredSignatures) {
5682
- proposal.status = import_types12.ProposalStatus.REJECTED;
6135
+ proposal.status = import_types13.ProposalStatus.REJECTED;
5683
6136
  }
5684
6137
  return proposal;
5685
6138
  }
@@ -5696,7 +6149,7 @@ var Treasury = class _Treasury {
5696
6149
  "SIP_2001" /* INVALID_INPUT */
5697
6150
  );
5698
6151
  }
5699
- if (proposal.status !== import_types12.ProposalStatus.APPROVED) {
6152
+ if (proposal.status !== import_types13.ProposalStatus.APPROVED) {
5700
6153
  throw new ValidationError(
5701
6154
  `proposal is not approved: ${proposal.status}`,
5702
6155
  "proposalId",
@@ -5709,8 +6162,8 @@ var Treasury = class _Treasury {
5709
6162
  const payment = await createShieldedPayment({
5710
6163
  token: proposal.payment.token,
5711
6164
  amount: proposal.payment.amount,
5712
- recipientMetaAddress: proposal.payment.privacy !== import_types12.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
5713
- recipientAddress: proposal.payment.privacy === import_types12.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
6165
+ recipientMetaAddress: proposal.payment.privacy !== import_types13.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
6166
+ recipientAddress: proposal.payment.privacy === import_types13.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
5714
6167
  privacy: proposal.payment.privacy,
5715
6168
  viewingKey: this.config.masterViewingKey?.key,
5716
6169
  sourceChain: this.config.chain,
@@ -5723,8 +6176,8 @@ var Treasury = class _Treasury {
5723
6176
  const payment = await createShieldedPayment({
5724
6177
  token: proposal.batchPayment.token,
5725
6178
  amount: recipient.amount,
5726
- recipientMetaAddress: proposal.batchPayment.privacy !== import_types12.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
5727
- recipientAddress: proposal.batchPayment.privacy === import_types12.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
6179
+ recipientMetaAddress: proposal.batchPayment.privacy !== import_types13.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
6180
+ recipientAddress: proposal.batchPayment.privacy === import_types13.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
5728
6181
  privacy: proposal.batchPayment.privacy,
5729
6182
  viewingKey: this.config.masterViewingKey?.key,
5730
6183
  sourceChain: this.config.chain,
@@ -5734,7 +6187,7 @@ var Treasury = class _Treasury {
5734
6187
  payments.push(payment);
5735
6188
  }
5736
6189
  }
5737
- proposal.status = import_types12.ProposalStatus.EXECUTED;
6190
+ proposal.status = import_types13.ProposalStatus.EXECUTED;
5738
6191
  proposal.executedAt = Math.floor(Date.now() / 1e3);
5739
6192
  proposal.resultPayments = payments;
5740
6193
  return payments;
@@ -5763,7 +6216,7 @@ var Treasury = class _Treasury {
5763
6216
  "SIP_2001" /* INVALID_INPUT */
5764
6217
  );
5765
6218
  }
5766
- if (proposal.status !== import_types12.ProposalStatus.PENDING) {
6219
+ if (proposal.status !== import_types13.ProposalStatus.PENDING) {
5767
6220
  throw new ValidationError(
5768
6221
  `proposal is not pending: ${proposal.status}`,
5769
6222
  "proposalId",
@@ -5771,7 +6224,7 @@ var Treasury = class _Treasury {
5771
6224
  "SIP_2001" /* INVALID_INPUT */
5772
6225
  );
5773
6226
  }
5774
- proposal.status = import_types12.ProposalStatus.CANCELLED;
6227
+ proposal.status = import_types13.ProposalStatus.CANCELLED;
5775
6228
  return proposal;
5776
6229
  }
5777
6230
  // ─── Auditor Access ──────────────────────────────────────────────────────────
@@ -5868,7 +6321,7 @@ var Treasury = class _Treasury {
5868
6321
  getCommittedAmount(token) {
5869
6322
  let committed = 0n;
5870
6323
  for (const proposal of this.proposals.values()) {
5871
- if (proposal.status !== import_types12.ProposalStatus.PENDING) continue;
6324
+ if (proposal.status !== import_types13.ProposalStatus.PENDING) continue;
5872
6325
  if (proposal.type === "payment" && proposal.payment) {
5873
6326
  if (proposal.payment.token.symbol === token.symbol && proposal.payment.token.chain === token.chain) {
5874
6327
  committed += proposal.payment.amount;
@@ -6111,7 +6564,7 @@ function validateBatchProposalParams(params, config) {
6111
6564
  }
6112
6565
 
6113
6566
  // src/compliance/compliance-manager.ts
6114
- var import_types13 = require("@sip-protocol/types");
6567
+ var import_types14 = require("@sip-protocol/types");
6115
6568
  var import_utils13 = require("@noble/hashes/utils");
6116
6569
  var DEFAULTS2 = {
6117
6570
  riskThreshold: 70,
@@ -6479,7 +6932,7 @@ var ComplianceManager = class _ComplianceManager {
6479
6932
  title: params.title,
6480
6933
  description: params.description,
6481
6934
  format: params.format,
6482
- status: import_types13.ReportStatus.GENERATING,
6935
+ status: import_types14.ReportStatus.GENERATING,
6483
6936
  requestedBy,
6484
6937
  requestedAt: now,
6485
6938
  startDate: params.startDate,
@@ -6508,10 +6961,10 @@ var ComplianceManager = class _ComplianceManager {
6508
6961
  } else if (params.format === "csv") {
6509
6962
  report.content = this.generateCSV(transactions);
6510
6963
  }
6511
- report.status = import_types13.ReportStatus.COMPLETED;
6964
+ report.status = import_types14.ReportStatus.COMPLETED;
6512
6965
  report.generatedAt = Math.floor(Date.now() / 1e3);
6513
6966
  } catch (error) {
6514
- report.status = import_types13.ReportStatus.FAILED;
6967
+ report.status = import_types14.ReportStatus.FAILED;
6515
6968
  report.error = error instanceof Error ? error.message : "Unknown error";
6516
6969
  }
6517
6970
  this.addAuditLog(requestedBy, "report_generated", {
@@ -6874,10 +7327,10 @@ function validateReportParams(params) {
6874
7327
  }
6875
7328
 
6876
7329
  // src/wallet/errors.ts
6877
- var import_types14 = require("@sip-protocol/types");
7330
+ var import_types15 = require("@sip-protocol/types");
6878
7331
  var WalletError = class extends SIPError {
6879
7332
  walletCode;
6880
- constructor(message, walletCode = import_types14.WalletErrorCode.UNKNOWN, options) {
7333
+ constructor(message, walletCode = import_types15.WalletErrorCode.UNKNOWN, options) {
6881
7334
  super(message, "SIP_7000" /* WALLET_ERROR */, options);
6882
7335
  this.walletCode = walletCode;
6883
7336
  this.name = "WalletError";
@@ -6887,10 +7340,10 @@ var WalletError = class extends SIPError {
6887
7340
  */
6888
7341
  isConnectionError() {
6889
7342
  const codes = [
6890
- import_types14.WalletErrorCode.NOT_INSTALLED,
6891
- import_types14.WalletErrorCode.CONNECTION_REJECTED,
6892
- import_types14.WalletErrorCode.CONNECTION_FAILED,
6893
- import_types14.WalletErrorCode.NOT_CONNECTED
7343
+ import_types15.WalletErrorCode.NOT_INSTALLED,
7344
+ import_types15.WalletErrorCode.CONNECTION_REJECTED,
7345
+ import_types15.WalletErrorCode.CONNECTION_FAILED,
7346
+ import_types15.WalletErrorCode.NOT_CONNECTED
6894
7347
  ];
6895
7348
  return codes.includes(this.walletCode);
6896
7349
  }
@@ -6899,9 +7352,9 @@ var WalletError = class extends SIPError {
6899
7352
  */
6900
7353
  isSigningError() {
6901
7354
  const codes = [
6902
- import_types14.WalletErrorCode.SIGNING_REJECTED,
6903
- import_types14.WalletErrorCode.SIGNING_FAILED,
6904
- import_types14.WalletErrorCode.INVALID_MESSAGE
7355
+ import_types15.WalletErrorCode.SIGNING_REJECTED,
7356
+ import_types15.WalletErrorCode.SIGNING_FAILED,
7357
+ import_types15.WalletErrorCode.INVALID_MESSAGE
6905
7358
  ];
6906
7359
  return codes.includes(this.walletCode);
6907
7360
  }
@@ -6910,10 +7363,10 @@ var WalletError = class extends SIPError {
6910
7363
  */
6911
7364
  isTransactionError() {
6912
7365
  const codes = [
6913
- import_types14.WalletErrorCode.INSUFFICIENT_FUNDS,
6914
- import_types14.WalletErrorCode.TRANSACTION_REJECTED,
6915
- import_types14.WalletErrorCode.TRANSACTION_FAILED,
6916
- import_types14.WalletErrorCode.INVALID_TRANSACTION
7366
+ import_types15.WalletErrorCode.INSUFFICIENT_FUNDS,
7367
+ import_types15.WalletErrorCode.TRANSACTION_REJECTED,
7368
+ import_types15.WalletErrorCode.TRANSACTION_FAILED,
7369
+ import_types15.WalletErrorCode.INVALID_TRANSACTION
6917
7370
  ];
6918
7371
  return codes.includes(this.walletCode);
6919
7372
  }
@@ -6922,9 +7375,9 @@ var WalletError = class extends SIPError {
6922
7375
  */
6923
7376
  isPrivacyError() {
6924
7377
  const codes = [
6925
- import_types14.WalletErrorCode.STEALTH_NOT_SUPPORTED,
6926
- import_types14.WalletErrorCode.VIEWING_KEY_NOT_SUPPORTED,
6927
- import_types14.WalletErrorCode.SHIELDED_NOT_SUPPORTED
7378
+ import_types15.WalletErrorCode.STEALTH_NOT_SUPPORTED,
7379
+ import_types15.WalletErrorCode.VIEWING_KEY_NOT_SUPPORTED,
7380
+ import_types15.WalletErrorCode.SHIELDED_NOT_SUPPORTED
6928
7381
  ];
6929
7382
  return codes.includes(this.walletCode);
6930
7383
  }
@@ -6933,10 +7386,10 @@ var WalletError = class extends SIPError {
6933
7386
  */
6934
7387
  isUserRejection() {
6935
7388
  const codes = [
6936
- import_types14.WalletErrorCode.CONNECTION_REJECTED,
6937
- import_types14.WalletErrorCode.SIGNING_REJECTED,
6938
- import_types14.WalletErrorCode.TRANSACTION_REJECTED,
6939
- import_types14.WalletErrorCode.CHAIN_SWITCH_REJECTED
7389
+ import_types15.WalletErrorCode.CONNECTION_REJECTED,
7390
+ import_types15.WalletErrorCode.SIGNING_REJECTED,
7391
+ import_types15.WalletErrorCode.TRANSACTION_REJECTED,
7392
+ import_types15.WalletErrorCode.CHAIN_SWITCH_REJECTED
6940
7393
  ];
6941
7394
  return codes.includes(this.walletCode);
6942
7395
  }
@@ -6944,15 +7397,15 @@ var WalletError = class extends SIPError {
6944
7397
  function notConnectedError() {
6945
7398
  return new WalletError(
6946
7399
  "Wallet not connected. Call connect() first.",
6947
- import_types14.WalletErrorCode.NOT_CONNECTED
7400
+ import_types15.WalletErrorCode.NOT_CONNECTED
6948
7401
  );
6949
7402
  }
6950
- function featureNotSupportedError(feature, code = import_types14.WalletErrorCode.UNKNOWN) {
7403
+ function featureNotSupportedError(feature, code = import_types15.WalletErrorCode.UNKNOWN) {
6951
7404
  return new WalletError(`${feature} is not supported by this wallet`, code);
6952
7405
  }
6953
7406
 
6954
7407
  // src/wallet/base-adapter.ts
6955
- var import_types15 = require("@sip-protocol/types");
7408
+ var import_types16 = require("@sip-protocol/types");
6956
7409
  var BaseWalletAdapter = class {
6957
7410
  _address = "";
6958
7411
  _publicKey = "";
@@ -7115,12 +7568,12 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
7115
7568
  this._connectionState = "connecting";
7116
7569
  if (this.shouldFailConnect) {
7117
7570
  this.setError(
7118
- import_types15.WalletErrorCode.CONNECTION_FAILED,
7571
+ import_types16.WalletErrorCode.CONNECTION_FAILED,
7119
7572
  "Mock connection failure"
7120
7573
  );
7121
7574
  throw new WalletError(
7122
7575
  "Mock connection failure",
7123
- import_types15.WalletErrorCode.CONNECTION_FAILED
7576
+ import_types16.WalletErrorCode.CONNECTION_FAILED
7124
7577
  );
7125
7578
  }
7126
7579
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -7132,7 +7585,7 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
7132
7585
  async signMessage(message) {
7133
7586
  this.requireConnected();
7134
7587
  if (this.shouldFailSign) {
7135
- throw new WalletError("Mock signing failure", import_types15.WalletErrorCode.SIGNING_FAILED);
7588
+ throw new WalletError("Mock signing failure", import_types16.WalletErrorCode.SIGNING_FAILED);
7136
7589
  }
7137
7590
  const mockSig = new Uint8Array(64);
7138
7591
  for (let i = 0; i < 64; i++) {
@@ -7147,7 +7600,7 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
7147
7600
  async signTransaction(tx) {
7148
7601
  this.requireConnected();
7149
7602
  if (this.shouldFailSign) {
7150
- throw new WalletError("Mock signing failure", import_types15.WalletErrorCode.SIGNING_FAILED);
7603
+ throw new WalletError("Mock signing failure", import_types16.WalletErrorCode.SIGNING_FAILED);
7151
7604
  }
7152
7605
  const signature = await this.signMessage(
7153
7606
  new TextEncoder().encode(JSON.stringify(tx.data))
@@ -7329,7 +7782,7 @@ function isPrivateWalletAdapter(adapter) {
7329
7782
  }
7330
7783
 
7331
7784
  // src/wallet/solana/adapter.ts
7332
- var import_types16 = require("@sip-protocol/types");
7785
+ var import_types17 = require("@sip-protocol/types");
7333
7786
 
7334
7787
  // src/wallet/solana/types.ts
7335
7788
  function getSolanaProvider(wallet = "phantom") {
@@ -7450,19 +7903,19 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7450
7903
  }
7451
7904
  if (!this.provider) {
7452
7905
  this.setError(
7453
- import_types16.WalletErrorCode.NOT_INSTALLED,
7906
+ import_types17.WalletErrorCode.NOT_INSTALLED,
7454
7907
  `${this.walletName} wallet is not installed`
7455
7908
  );
7456
7909
  throw new WalletError(
7457
7910
  `${this.walletName} wallet is not installed`,
7458
- import_types16.WalletErrorCode.NOT_INSTALLED
7911
+ import_types17.WalletErrorCode.NOT_INSTALLED
7459
7912
  );
7460
7913
  }
7461
7914
  const { publicKey } = await this.provider.connect();
7462
7915
  if (!publicKey) {
7463
7916
  throw new WalletError(
7464
7917
  "No public key returned from wallet",
7465
- import_types16.WalletErrorCode.CONNECTION_FAILED
7918
+ import_types17.WalletErrorCode.CONNECTION_FAILED
7466
7919
  );
7467
7920
  }
7468
7921
  this.setupEventHandlers();
@@ -7472,11 +7925,11 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7472
7925
  } catch (error) {
7473
7926
  const message = error instanceof Error ? error.message : "Connection failed";
7474
7927
  if (message.includes("User rejected") || message.includes("rejected")) {
7475
- this.setError(import_types16.WalletErrorCode.CONNECTION_REJECTED, message);
7476
- throw new WalletError(message, import_types16.WalletErrorCode.CONNECTION_REJECTED);
7928
+ this.setError(import_types17.WalletErrorCode.CONNECTION_REJECTED, message);
7929
+ throw new WalletError(message, import_types17.WalletErrorCode.CONNECTION_REJECTED);
7477
7930
  }
7478
- this.setError(import_types16.WalletErrorCode.CONNECTION_FAILED, message);
7479
- throw error instanceof WalletError ? error : new WalletError(message, import_types16.WalletErrorCode.CONNECTION_FAILED, { cause: error });
7931
+ this.setError(import_types17.WalletErrorCode.CONNECTION_FAILED, message);
7932
+ throw error instanceof WalletError ? error : new WalletError(message, import_types17.WalletErrorCode.CONNECTION_FAILED, { cause: error });
7480
7933
  }
7481
7934
  }
7482
7935
  /**
@@ -7499,7 +7952,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7499
7952
  async signMessage(message) {
7500
7953
  this.requireConnected();
7501
7954
  if (!this.provider) {
7502
- throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
7955
+ throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
7503
7956
  }
7504
7957
  try {
7505
7958
  const { signature } = await this.provider.signMessage(message);
@@ -7510,9 +7963,9 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7510
7963
  } catch (error) {
7511
7964
  const message2 = error instanceof Error ? error.message : "Signing failed";
7512
7965
  if (message2.includes("User rejected") || message2.includes("rejected")) {
7513
- throw new WalletError(message2, import_types16.WalletErrorCode.SIGNING_REJECTED);
7966
+ throw new WalletError(message2, import_types17.WalletErrorCode.SIGNING_REJECTED);
7514
7967
  }
7515
- throw new WalletError(message2, import_types16.WalletErrorCode.SIGNING_FAILED, {
7968
+ throw new WalletError(message2, import_types17.WalletErrorCode.SIGNING_FAILED, {
7516
7969
  cause: error
7517
7970
  });
7518
7971
  }
@@ -7525,7 +7978,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7525
7978
  async signTransaction(tx) {
7526
7979
  this.requireConnected();
7527
7980
  if (!this.provider) {
7528
- throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
7981
+ throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
7529
7982
  }
7530
7983
  try {
7531
7984
  const solTx = tx.data;
@@ -7544,9 +7997,9 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7544
7997
  } catch (error) {
7545
7998
  const message = error instanceof Error ? error.message : "Signing failed";
7546
7999
  if (message.includes("User rejected") || message.includes("rejected")) {
7547
- throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_REJECTED);
8000
+ throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_REJECTED);
7548
8001
  }
7549
- throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_FAILED, {
8002
+ throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_FAILED, {
7550
8003
  cause: error
7551
8004
  });
7552
8005
  }
@@ -7557,7 +8010,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7557
8010
  async signAndSendTransaction(tx) {
7558
8011
  this.requireConnected();
7559
8012
  if (!this.provider) {
7560
- throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
8013
+ throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
7561
8014
  }
7562
8015
  try {
7563
8016
  const solTx = tx.data;
@@ -7572,12 +8025,12 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7572
8025
  } catch (error) {
7573
8026
  const message = error instanceof Error ? error.message : "Transaction failed";
7574
8027
  if (message.includes("User rejected") || message.includes("rejected")) {
7575
- throw new WalletError(message, import_types16.WalletErrorCode.TRANSACTION_REJECTED);
8028
+ throw new WalletError(message, import_types17.WalletErrorCode.TRANSACTION_REJECTED);
7576
8029
  }
7577
8030
  if (message.includes("insufficient") || message.includes("Insufficient")) {
7578
- throw new WalletError(message, import_types16.WalletErrorCode.INSUFFICIENT_FUNDS);
8031
+ throw new WalletError(message, import_types17.WalletErrorCode.INSUFFICIENT_FUNDS);
7579
8032
  }
7580
- throw new WalletError(message, import_types16.WalletErrorCode.TRANSACTION_FAILED, {
8033
+ throw new WalletError(message, import_types17.WalletErrorCode.TRANSACTION_FAILED, {
7581
8034
  cause: error
7582
8035
  });
7583
8036
  }
@@ -7590,16 +8043,16 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7590
8043
  async signAllTransactions(transactions) {
7591
8044
  this.requireConnected();
7592
8045
  if (!this.provider) {
7593
- throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
8046
+ throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
7594
8047
  }
7595
8048
  try {
7596
8049
  return await this.provider.signAllTransactions(transactions);
7597
8050
  } catch (error) {
7598
8051
  const message = error instanceof Error ? error.message : "Signing failed";
7599
8052
  if (message.includes("User rejected") || message.includes("rejected")) {
7600
- throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_REJECTED);
8053
+ throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_REJECTED);
7601
8054
  }
7602
- throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_FAILED, {
8055
+ throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_FAILED, {
7603
8056
  cause: error
7604
8057
  });
7605
8058
  }
@@ -7620,7 +8073,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7620
8073
  } catch (error) {
7621
8074
  throw new WalletError(
7622
8075
  "Failed to get balance",
7623
- import_types16.WalletErrorCode.UNKNOWN,
8076
+ import_types17.WalletErrorCode.UNKNOWN,
7624
8077
  { cause: error }
7625
8078
  );
7626
8079
  }
@@ -7633,7 +8086,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7633
8086
  if (asset.chain !== "solana") {
7634
8087
  throw new WalletError(
7635
8088
  `Asset chain ${asset.chain} not supported by Solana adapter`,
7636
- import_types16.WalletErrorCode.UNSUPPORTED_CHAIN
8089
+ import_types17.WalletErrorCode.UNSUPPORTED_CHAIN
7637
8090
  );
7638
8091
  }
7639
8092
  if (!asset.address) {
@@ -7751,7 +8204,7 @@ function createSolanaAdapter(config = {}) {
7751
8204
  }
7752
8205
 
7753
8206
  // src/wallet/solana/mock.ts
7754
- var import_types18 = require("@sip-protocol/types");
8207
+ var import_types19 = require("@sip-protocol/types");
7755
8208
  var MockPublicKey = class {
7756
8209
  base58;
7757
8210
  bytes;
@@ -7817,8 +8270,8 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7817
8270
  this._connectionState = "connecting";
7818
8271
  await this.simulateLatency();
7819
8272
  if (this.shouldFailConnect) {
7820
- this.setError(import_types18.WalletErrorCode.CONNECTION_FAILED, "Mock connection failure");
7821
- throw new WalletError("Mock connection failure", import_types18.WalletErrorCode.CONNECTION_FAILED);
8273
+ this.setError(import_types19.WalletErrorCode.CONNECTION_FAILED, "Mock connection failure");
8274
+ throw new WalletError("Mock connection failure", import_types19.WalletErrorCode.CONNECTION_FAILED);
7822
8275
  }
7823
8276
  const hexPubKey = "0x" + Buffer.from(this.mockPublicKey.toBytes()).toString("hex");
7824
8277
  this.setConnected(this.mockAddress, hexPubKey);
@@ -7837,7 +8290,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7837
8290
  this.requireConnected();
7838
8291
  await this.simulateLatency();
7839
8292
  if (this.shouldFailSign) {
7840
- throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
8293
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
7841
8294
  }
7842
8295
  const mockSig = new Uint8Array(64);
7843
8296
  for (let i = 0; i < 64; i++) {
@@ -7855,7 +8308,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7855
8308
  this.requireConnected();
7856
8309
  await this.simulateLatency();
7857
8310
  if (this.shouldFailSign) {
7858
- throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
8311
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
7859
8312
  }
7860
8313
  const solTx = tx.data;
7861
8314
  this.signedTransactions.push(solTx);
@@ -7875,10 +8328,10 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7875
8328
  this.requireConnected();
7876
8329
  await this.simulateLatency();
7877
8330
  if (this.shouldFailSign) {
7878
- throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
8331
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
7879
8332
  }
7880
8333
  if (this.shouldFailTransaction) {
7881
- throw new WalletError("Mock transaction failure", import_types18.WalletErrorCode.TRANSACTION_FAILED);
8334
+ throw new WalletError("Mock transaction failure", import_types19.WalletErrorCode.TRANSACTION_FAILED);
7882
8335
  }
7883
8336
  const txSig = `mock_tx_${Date.now()}_${Math.random().toString(36).slice(2)}`;
7884
8337
  this.sentTransactions.push(txSig);
@@ -7898,7 +8351,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7898
8351
  this.requireConnected();
7899
8352
  await this.simulateLatency();
7900
8353
  if (this.shouldFailSign) {
7901
- throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
8354
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
7902
8355
  }
7903
8356
  this.signedTransactions.push(...transactions);
7904
8357
  return transactions.map((tx) => {
@@ -7925,7 +8378,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7925
8378
  if (asset.chain !== "solana") {
7926
8379
  throw new WalletError(
7927
8380
  `Asset chain ${asset.chain} not supported by Solana adapter`,
7928
- import_types18.WalletErrorCode.UNSUPPORTED_CHAIN
8381
+ import_types19.WalletErrorCode.UNSUPPORTED_CHAIN
7929
8382
  );
7930
8383
  }
7931
8384
  if (!asset.address) {
@@ -8094,7 +8547,7 @@ function createMockSolanaAdapter(config = {}) {
8094
8547
  }
8095
8548
 
8096
8549
  // src/wallet/ethereum/adapter.ts
8097
- var import_types20 = require("@sip-protocol/types");
8550
+ var import_types21 = require("@sip-protocol/types");
8098
8551
 
8099
8552
  // src/wallet/ethereum/types.ts
8100
8553
  var EthereumChainId = {
@@ -8236,7 +8689,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8236
8689
  this._connectionState = "error";
8237
8690
  throw new WalletError(
8238
8691
  `${this.walletType} wallet not found. Please install the extension.`,
8239
- import_types20.WalletErrorCode.NOT_INSTALLED
8692
+ import_types21.WalletErrorCode.NOT_INSTALLED
8240
8693
  );
8241
8694
  }
8242
8695
  const accounts = await this.provider.request({
@@ -8246,7 +8699,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8246
8699
  this._connectionState = "error";
8247
8700
  throw new WalletError(
8248
8701
  "No accounts returned from wallet",
8249
- import_types20.WalletErrorCode.CONNECTION_REJECTED
8702
+ import_types21.WalletErrorCode.CONNECTION_REJECTED
8250
8703
  );
8251
8704
  }
8252
8705
  const address = normalizeAddress(accounts[0]);
@@ -8266,12 +8719,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8266
8719
  if (rpcError.code === 4001) {
8267
8720
  throw new WalletError(
8268
8721
  "User rejected connection request",
8269
- import_types20.WalletErrorCode.CONNECTION_REJECTED
8722
+ import_types21.WalletErrorCode.CONNECTION_REJECTED
8270
8723
  );
8271
8724
  }
8272
8725
  throw new WalletError(
8273
8726
  `Failed to connect: ${rpcError.message || String(error)}`,
8274
- import_types20.WalletErrorCode.CONNECTION_FAILED
8727
+ import_types21.WalletErrorCode.CONNECTION_FAILED
8275
8728
  );
8276
8729
  }
8277
8730
  }
@@ -8291,7 +8744,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8291
8744
  if (!this.provider) {
8292
8745
  throw new WalletError(
8293
8746
  "Provider not available",
8294
- import_types20.WalletErrorCode.NOT_CONNECTED
8747
+ import_types21.WalletErrorCode.NOT_CONNECTED
8295
8748
  );
8296
8749
  }
8297
8750
  try {
@@ -8309,12 +8762,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8309
8762
  if (rpcError.code === 4001) {
8310
8763
  throw new WalletError(
8311
8764
  "User rejected signing request",
8312
- import_types20.WalletErrorCode.SIGNING_REJECTED
8765
+ import_types21.WalletErrorCode.SIGNING_REJECTED
8313
8766
  );
8314
8767
  }
8315
8768
  throw new WalletError(
8316
8769
  `Failed to sign message: ${rpcError.message || String(error)}`,
8317
- import_types20.WalletErrorCode.SIGNING_FAILED
8770
+ import_types21.WalletErrorCode.SIGNING_FAILED
8318
8771
  );
8319
8772
  }
8320
8773
  }
@@ -8326,7 +8779,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8326
8779
  if (!this.provider) {
8327
8780
  throw new WalletError(
8328
8781
  "Provider not available",
8329
- import_types20.WalletErrorCode.NOT_CONNECTED
8782
+ import_types21.WalletErrorCode.NOT_CONNECTED
8330
8783
  );
8331
8784
  }
8332
8785
  try {
@@ -8343,12 +8796,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8343
8796
  if (rpcError.code === 4001) {
8344
8797
  throw new WalletError(
8345
8798
  "User rejected signing request",
8346
- import_types20.WalletErrorCode.SIGNING_REJECTED
8799
+ import_types21.WalletErrorCode.SIGNING_REJECTED
8347
8800
  );
8348
8801
  }
8349
8802
  throw new WalletError(
8350
8803
  `Failed to sign typed data: ${rpcError.message || String(error)}`,
8351
- import_types20.WalletErrorCode.SIGNING_FAILED
8804
+ import_types21.WalletErrorCode.SIGNING_FAILED
8352
8805
  );
8353
8806
  }
8354
8807
  }
@@ -8360,7 +8813,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8360
8813
  if (!this.provider) {
8361
8814
  throw new WalletError(
8362
8815
  "Provider not available",
8363
- import_types20.WalletErrorCode.NOT_CONNECTED
8816
+ import_types21.WalletErrorCode.NOT_CONNECTED
8364
8817
  );
8365
8818
  }
8366
8819
  try {
@@ -8388,7 +8841,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8388
8841
  if (rpcError.code === 4001) {
8389
8842
  throw new WalletError(
8390
8843
  "User rejected transaction signing",
8391
- import_types20.WalletErrorCode.SIGNING_REJECTED
8844
+ import_types21.WalletErrorCode.SIGNING_REJECTED
8392
8845
  );
8393
8846
  }
8394
8847
  if (rpcError.code === -32601 || rpcError.message?.includes("not supported")) {
@@ -8406,7 +8859,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8406
8859
  }
8407
8860
  throw new WalletError(
8408
8861
  `Failed to sign transaction: ${rpcError.message || String(error)}`,
8409
- import_types20.WalletErrorCode.TRANSACTION_FAILED
8862
+ import_types21.WalletErrorCode.TRANSACTION_FAILED
8410
8863
  );
8411
8864
  }
8412
8865
  }
@@ -8418,7 +8871,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8418
8871
  if (!this.provider) {
8419
8872
  throw new WalletError(
8420
8873
  "Provider not available",
8421
- import_types20.WalletErrorCode.NOT_CONNECTED
8874
+ import_types21.WalletErrorCode.NOT_CONNECTED
8422
8875
  );
8423
8876
  }
8424
8877
  try {
@@ -8440,12 +8893,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8440
8893
  if (rpcError.code === 4001) {
8441
8894
  throw new WalletError(
8442
8895
  "User rejected transaction",
8443
- import_types20.WalletErrorCode.TRANSACTION_REJECTED
8896
+ import_types21.WalletErrorCode.TRANSACTION_REJECTED
8444
8897
  );
8445
8898
  }
8446
8899
  throw new WalletError(
8447
8900
  `Failed to send transaction: ${rpcError.message || String(error)}`,
8448
- import_types20.WalletErrorCode.TRANSACTION_FAILED
8901
+ import_types21.WalletErrorCode.TRANSACTION_FAILED
8449
8902
  );
8450
8903
  }
8451
8904
  }
@@ -8480,7 +8933,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8480
8933
  } catch (error) {
8481
8934
  throw new WalletError(
8482
8935
  `Failed to fetch balance: ${String(error)}`,
8483
- import_types20.WalletErrorCode.UNKNOWN
8936
+ import_types21.WalletErrorCode.UNKNOWN
8484
8937
  );
8485
8938
  }
8486
8939
  }
@@ -8492,7 +8945,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8492
8945
  if (asset.chain !== "ethereum") {
8493
8946
  throw new WalletError(
8494
8947
  `Asset chain ${asset.chain} not supported by Ethereum adapter`,
8495
- import_types20.WalletErrorCode.UNSUPPORTED_CHAIN
8948
+ import_types21.WalletErrorCode.UNSUPPORTED_CHAIN
8496
8949
  );
8497
8950
  }
8498
8951
  if (!asset.address) {
@@ -8517,7 +8970,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8517
8970
  } catch (error) {
8518
8971
  throw new WalletError(
8519
8972
  `Failed to fetch token balance: ${String(error)}`,
8520
- import_types20.WalletErrorCode.UNKNOWN
8973
+ import_types21.WalletErrorCode.UNKNOWN
8521
8974
  );
8522
8975
  }
8523
8976
  }
@@ -8529,7 +8982,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8529
8982
  if (!this.provider) {
8530
8983
  throw new WalletError(
8531
8984
  "Provider not available",
8532
- import_types20.WalletErrorCode.NOT_CONNECTED
8985
+ import_types21.WalletErrorCode.NOT_CONNECTED
8533
8986
  );
8534
8987
  }
8535
8988
  try {
@@ -8544,18 +8997,18 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8544
8997
  if (rpcError.code === 4001) {
8545
8998
  throw new WalletError(
8546
8999
  "User rejected chain switch",
8547
- import_types20.WalletErrorCode.CHAIN_SWITCH_REJECTED
9000
+ import_types21.WalletErrorCode.CHAIN_SWITCH_REJECTED
8548
9001
  );
8549
9002
  }
8550
9003
  if (rpcError.code === 4902) {
8551
9004
  throw new WalletError(
8552
9005
  `Chain ${chainId} not added to wallet`,
8553
- import_types20.WalletErrorCode.UNSUPPORTED_CHAIN
9006
+ import_types21.WalletErrorCode.UNSUPPORTED_CHAIN
8554
9007
  );
8555
9008
  }
8556
9009
  throw new WalletError(
8557
9010
  `Failed to switch chain: ${rpcError.message || String(error)}`,
8558
- import_types20.WalletErrorCode.CHAIN_SWITCH_FAILED
9011
+ import_types21.WalletErrorCode.CHAIN_SWITCH_FAILED
8559
9012
  );
8560
9013
  }
8561
9014
  }
@@ -8591,7 +9044,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8591
9044
  }
8592
9045
  throw new WalletError(
8593
9046
  `Transaction ${txHash} not confirmed after ${maxAttempts * 5} seconds`,
8594
- import_types20.WalletErrorCode.TRANSACTION_FAILED
9047
+ import_types21.WalletErrorCode.TRANSACTION_FAILED
8595
9048
  );
8596
9049
  }
8597
9050
  /**
@@ -8665,7 +9118,7 @@ function createEthereumAdapter(config) {
8665
9118
  }
8666
9119
 
8667
9120
  // src/wallet/ethereum/mock.ts
8668
- var import_types22 = require("@sip-protocol/types");
9121
+ var import_types23 = require("@sip-protocol/types");
8669
9122
  var MockEthereumAdapter = class extends BaseWalletAdapter {
8670
9123
  chain = "ethereum";
8671
9124
  name = "mock-ethereum";
@@ -8706,7 +9159,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8706
9159
  this._connectionState = "error";
8707
9160
  throw new WalletError(
8708
9161
  "Mock connection rejected",
8709
- import_types22.WalletErrorCode.CONNECTION_REJECTED
9162
+ import_types23.WalletErrorCode.CONNECTION_REJECTED
8710
9163
  );
8711
9164
  }
8712
9165
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -8718,7 +9171,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8718
9171
  this._connectionState = "error";
8719
9172
  throw new WalletError(
8720
9173
  `Mock connection failed: ${String(error)}`,
8721
- import_types22.WalletErrorCode.CONNECTION_FAILED
9174
+ import_types23.WalletErrorCode.CONNECTION_FAILED
8722
9175
  );
8723
9176
  }
8724
9177
  }
@@ -8736,7 +9189,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8736
9189
  if (this._shouldFailSign) {
8737
9190
  throw new WalletError(
8738
9191
  "Mock signing rejected",
8739
- import_types22.WalletErrorCode.SIGNING_REJECTED
9192
+ import_types23.WalletErrorCode.SIGNING_REJECTED
8740
9193
  );
8741
9194
  }
8742
9195
  const msgHex = Buffer.from(message).toString("hex");
@@ -8754,7 +9207,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8754
9207
  if (this._shouldFailSign) {
8755
9208
  throw new WalletError(
8756
9209
  "Mock signing rejected",
8757
- import_types22.WalletErrorCode.SIGNING_REJECTED
9210
+ import_types23.WalletErrorCode.SIGNING_REJECTED
8758
9211
  );
8759
9212
  }
8760
9213
  const mockSig = `0x${"1".repeat(130)}`;
@@ -8771,7 +9224,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8771
9224
  if (this._shouldFailSign) {
8772
9225
  throw new WalletError(
8773
9226
  "Mock signing rejected",
8774
- import_types22.WalletErrorCode.SIGNING_REJECTED
9227
+ import_types23.WalletErrorCode.SIGNING_REJECTED
8775
9228
  );
8776
9229
  }
8777
9230
  this._signedTransactions.push(tx);
@@ -8796,7 +9249,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8796
9249
  if (this._shouldFailTransaction) {
8797
9250
  throw new WalletError(
8798
9251
  "Mock transaction failed",
8799
- import_types22.WalletErrorCode.TRANSACTION_FAILED
9252
+ import_types23.WalletErrorCode.TRANSACTION_FAILED
8800
9253
  );
8801
9254
  }
8802
9255
  this._signedTransactions.push(tx);
@@ -8826,7 +9279,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8826
9279
  if (asset.chain !== "ethereum") {
8827
9280
  throw new WalletError(
8828
9281
  `Asset chain ${asset.chain} not supported by Ethereum adapter`,
8829
- import_types22.WalletErrorCode.UNSUPPORTED_CHAIN
9282
+ import_types23.WalletErrorCode.UNSUPPORTED_CHAIN
8830
9283
  );
8831
9284
  }
8832
9285
  if (!asset.address) {
@@ -9105,7 +9558,7 @@ function getAvailableTransports() {
9105
9558
  }
9106
9559
 
9107
9560
  // src/wallet/hardware/ledger.ts
9108
- var import_types25 = require("@sip-protocol/types");
9561
+ var import_types26 = require("@sip-protocol/types");
9109
9562
  var LedgerWalletAdapter = class extends BaseWalletAdapter {
9110
9563
  chain;
9111
9564
  name = "ledger";
@@ -9258,7 +9711,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
9258
9711
  async getBalance() {
9259
9712
  throw new WalletError(
9260
9713
  "Hardware wallets do not track balances. Use an RPC provider.",
9261
- import_types25.WalletErrorCode.UNSUPPORTED_OPERATION
9714
+ import_types26.WalletErrorCode.UNSUPPORTED_OPERATION
9262
9715
  );
9263
9716
  }
9264
9717
  /**
@@ -9269,7 +9722,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
9269
9722
  async getTokenBalance(_asset) {
9270
9723
  throw new WalletError(
9271
9724
  "Hardware wallets do not track balances. Use an RPC provider.",
9272
- import_types25.WalletErrorCode.UNSUPPORTED_OPERATION
9725
+ import_types26.WalletErrorCode.UNSUPPORTED_OPERATION
9273
9726
  );
9274
9727
  }
9275
9728
  // ─── Account Management ─────────────────────────────────────────────────────
@@ -9557,7 +10010,7 @@ function createLedgerAdapter(config) {
9557
10010
  }
9558
10011
 
9559
10012
  // src/wallet/hardware/trezor.ts
9560
- var import_types27 = require("@sip-protocol/types");
10013
+ var import_types28 = require("@sip-protocol/types");
9561
10014
  var TrezorWalletAdapter = class extends BaseWalletAdapter {
9562
10015
  chain;
9563
10016
  name = "trezor";
@@ -9703,7 +10156,7 @@ var TrezorWalletAdapter = class extends BaseWalletAdapter {
9703
10156
  async getBalance() {
9704
10157
  throw new WalletError(
9705
10158
  "Hardware wallets do not track balances. Use an RPC provider.",
9706
- import_types27.WalletErrorCode.UNSUPPORTED_OPERATION
10159
+ import_types28.WalletErrorCode.UNSUPPORTED_OPERATION
9707
10160
  );
9708
10161
  }
9709
10162
  /**
@@ -9714,7 +10167,7 @@ var TrezorWalletAdapter = class extends BaseWalletAdapter {
9714
10167
  async getTokenBalance(_asset) {
9715
10168
  throw new WalletError(
9716
10169
  "Hardware wallets do not track balances. Use an RPC provider.",
9717
- import_types27.WalletErrorCode.UNSUPPORTED_OPERATION
10170
+ import_types28.WalletErrorCode.UNSUPPORTED_OPERATION
9718
10171
  );
9719
10172
  }
9720
10173
  // ─── Account Management ─────────────────────────────────────────────────────
@@ -9995,7 +10448,7 @@ function createTrezorAdapter(config) {
9995
10448
  }
9996
10449
 
9997
10450
  // src/wallet/hardware/mock.ts
9998
- var import_types29 = require("@sip-protocol/types");
10451
+ var import_types30 = require("@sip-protocol/types");
9999
10452
  var import_utils14 = require("@noble/hashes/utils");
10000
10453
  var MockLedgerAdapter = class extends BaseWalletAdapter {
10001
10454
  chain;
@@ -10143,7 +10596,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
10143
10596
  async getBalance() {
10144
10597
  throw new WalletError(
10145
10598
  "Hardware wallets do not track balances",
10146
- import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10599
+ import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
10147
10600
  );
10148
10601
  }
10149
10602
  /**
@@ -10152,7 +10605,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
10152
10605
  async getTokenBalance(_asset) {
10153
10606
  throw new WalletError(
10154
10607
  "Hardware wallets do not track balances",
10155
- import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10608
+ import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
10156
10609
  );
10157
10610
  }
10158
10611
  /**
@@ -10382,13 +10835,13 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
10382
10835
  async getBalance() {
10383
10836
  throw new WalletError(
10384
10837
  "Hardware wallets do not track balances",
10385
- import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10838
+ import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
10386
10839
  );
10387
10840
  }
10388
10841
  async getTokenBalance(_asset) {
10389
10842
  throw new WalletError(
10390
10843
  "Hardware wallets do not track balances",
10391
- import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10844
+ import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
10392
10845
  );
10393
10846
  }
10394
10847
  async getAccounts(startIndex = 0, count = 5) {
@@ -10478,7 +10931,7 @@ function createMockTrezorAdapter(config) {
10478
10931
  }
10479
10932
 
10480
10933
  // src/wallet/index.ts
10481
- var import_types32 = require("@sip-protocol/types");
10934
+ var import_types33 = require("@sip-protocol/types");
10482
10935
  // Annotate the CommonJS export names for ESM import in node:
10483
10936
  0 && (module.exports = {
10484
10937
  ATTESTATION_VERSION,
@@ -10539,6 +10992,7 @@ var import_types32 = require("@sip-protocol/types");
10539
10992
  ZcashRPCClient,
10540
10993
  ZcashRPCError,
10541
10994
  ZcashShieldedService,
10995
+ ZcashSwapService,
10542
10996
  addBlindings,
10543
10997
  addCommitments,
10544
10998
  addOracle,
@@ -10573,6 +11027,7 @@ var import_types32 = require("@sip-protocol/types");
10573
11027
  createWalletFactory,
10574
11028
  createZcashClient,
10575
11029
  createZcashShieldedService,
11030
+ createZcashSwapService,
10576
11031
  decodeStealthMetaAddress,
10577
11032
  decryptMemo,
10578
11033
  decryptWithViewing,