@sip-protocol/sdk 0.2.8 → 0.2.10

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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -0
  3. package/dist/browser.d.mts +100 -2
  4. package/dist/browser.d.ts +100 -2
  5. package/dist/browser.js +1362 -268
  6. package/dist/browser.mjs +502 -16
  7. package/dist/{chunk-UPTISVCY.mjs → chunk-AV37IZST.mjs} +731 -15
  8. package/dist/{chunk-VITVG25F.mjs → chunk-XLEPIR2P.mjs} +2 -100
  9. package/dist/index-BFOKTz2z.d.ts +6062 -0
  10. package/dist/index-CAhjA4kh.d.mts +6062 -0
  11. package/dist/index.d.mts +2 -5609
  12. package/dist/index.d.ts +2 -5609
  13. package/dist/index.js +588 -154
  14. package/dist/index.mjs +5 -1
  15. package/dist/{noir-BHQtFvRk.d.mts → noir-BTyLXLlZ.d.mts} +1 -1
  16. package/dist/{noir-BHQtFvRk.d.ts → noir-BTyLXLlZ.d.ts} +1 -1
  17. package/dist/proofs/noir.d.mts +1 -1
  18. package/dist/proofs/noir.d.ts +1 -1
  19. package/dist/proofs/noir.js +11 -112
  20. package/dist/proofs/noir.mjs +10 -13
  21. package/package.json +16 -16
  22. package/src/browser.ts +23 -0
  23. package/src/index.ts +12 -0
  24. package/src/proofs/browser-utils.ts +389 -0
  25. package/src/proofs/browser.ts +246 -19
  26. package/src/proofs/circuits/funding_proof.json +1 -1
  27. package/src/proofs/noir.ts +14 -14
  28. package/src/proofs/worker.ts +426 -0
  29. package/src/zcash/bridge.ts +738 -0
  30. package/src/zcash/index.ts +36 -1
  31. package/src/zcash/swap-service.ts +793 -0
  32. package/dist/chunk-4VJHI66K.mjs +0 -12120
  33. package/dist/chunk-5BAS4D44.mjs +0 -10283
  34. package/dist/chunk-6WOV2YNG.mjs +0 -10179
  35. package/dist/chunk-DU7LQDD2.mjs +0 -10148
  36. package/dist/chunk-MR7HRCRS.mjs +0 -10165
  37. package/dist/chunk-NDGUWOOZ.mjs +0 -10157
  38. package/dist/chunk-O4Y2ZUDL.mjs +0 -12721
  39. package/dist/chunk-VXSHK7US.mjs +0 -10158
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,
@@ -3772,10 +3774,10 @@ function hasEnoughOracles(registry) {
3772
3774
  }
3773
3775
 
3774
3776
  // src/index.ts
3775
- var import_types33 = require("@sip-protocol/types");
3776
3777
  var import_types34 = require("@sip-protocol/types");
3777
3778
  var import_types35 = require("@sip-protocol/types");
3778
3779
  var import_types36 = require("@sip-protocol/types");
3780
+ var import_types37 = require("@sip-protocol/types");
3779
3781
 
3780
3782
  // src/solver/mock-solver.ts
3781
3783
  var import_types7 = require("@sip-protocol/types");
@@ -3960,7 +3962,7 @@ function createMockSolver(config) {
3960
3962
  }
3961
3963
 
3962
3964
  // src/index.ts
3963
- var import_types37 = require("@sip-protocol/types");
3965
+ var import_types38 = require("@sip-protocol/types");
3964
3966
 
3965
3967
  // src/zcash/rpc-client.ts
3966
3968
  var import_types8 = require("@sip-protocol/types");
@@ -4804,14 +4806,444 @@ function createZcashShieldedService(config) {
4804
4806
  return new ZcashShieldedService(config);
4805
4807
  }
4806
4808
 
4807
- // src/zcash/index.ts
4809
+ // src/zcash/swap-service.ts
4808
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");
4809
5241
 
4810
5242
  // src/index.ts
4811
- var import_types38 = require("@sip-protocol/types");
5243
+ var import_types39 = require("@sip-protocol/types");
4812
5244
 
4813
5245
  // src/payment/payment.ts
4814
- var import_types11 = require("@sip-protocol/types");
5246
+ var import_types12 = require("@sip-protocol/types");
4815
5247
  var import_sha2569 = require("@noble/hashes/sha256");
4816
5248
  var import_utils11 = require("@noble/hashes/utils");
4817
5249
  var import_chacha2 = require("@noble/ciphers/chacha.js");
@@ -4998,7 +5430,7 @@ var PaymentBuilder = class {
4998
5430
  _amount;
4999
5431
  _recipientMetaAddress;
5000
5432
  _recipientAddress;
5001
- _privacy = import_types11.PrivacyLevel.SHIELDED;
5433
+ _privacy = import_types12.PrivacyLevel.SHIELDED;
5002
5434
  _viewingKey;
5003
5435
  _sourceChain;
5004
5436
  _destinationChain;
@@ -5281,7 +5713,7 @@ async function createShieldedPayment(params, options) {
5281
5713
  } else {
5282
5714
  resolvedToken = token;
5283
5715
  }
5284
- if (privacy !== import_types11.PrivacyLevel.TRANSPARENT && !recipientMetaAddress) {
5716
+ if (privacy !== import_types12.PrivacyLevel.TRANSPARENT && !recipientMetaAddress) {
5285
5717
  throw new ValidationError(
5286
5718
  "recipientMetaAddress is required for shielded/compliant privacy modes",
5287
5719
  "recipientMetaAddress",
@@ -5289,7 +5721,7 @@ async function createShieldedPayment(params, options) {
5289
5721
  "SIP_2008" /* MISSING_REQUIRED */
5290
5722
  );
5291
5723
  }
5292
- if (privacy === import_types11.PrivacyLevel.TRANSPARENT && !recipientAddress) {
5724
+ if (privacy === import_types12.PrivacyLevel.TRANSPARENT && !recipientAddress) {
5293
5725
  throw new ValidationError(
5294
5726
  "recipientAddress is required for transparent mode",
5295
5727
  "recipientAddress",
@@ -5297,7 +5729,7 @@ async function createShieldedPayment(params, options) {
5297
5729
  "SIP_2008" /* MISSING_REQUIRED */
5298
5730
  );
5299
5731
  }
5300
- if (privacy === import_types11.PrivacyLevel.COMPLIANT && !viewingKey) {
5732
+ if (privacy === import_types12.PrivacyLevel.COMPLIANT && !viewingKey) {
5301
5733
  throw new ValidationError(
5302
5734
  "viewingKey is required for compliant mode",
5303
5735
  "viewingKey",
@@ -5319,7 +5751,7 @@ async function createShieldedPayment(params, options) {
5319
5751
  const now = Math.floor(Date.now() / 1e3);
5320
5752
  const payment = {
5321
5753
  paymentId,
5322
- version: import_types11.SIP_VERSION,
5754
+ version: import_types12.SIP_VERSION,
5323
5755
  privacyLevel: privacy,
5324
5756
  createdAt: now,
5325
5757
  expiry: now + ttl,
@@ -5330,7 +5762,7 @@ async function createShieldedPayment(params, options) {
5330
5762
  purpose,
5331
5763
  viewingKeyHash
5332
5764
  };
5333
- if (privacy !== import_types11.PrivacyLevel.TRANSPARENT && recipientMetaAddress) {
5765
+ if (privacy !== import_types12.PrivacyLevel.TRANSPARENT && recipientMetaAddress) {
5334
5766
  const metaAddress = decodeStealthMetaAddress(recipientMetaAddress);
5335
5767
  const { stealthAddress } = generateStealthAddress(metaAddress);
5336
5768
  payment.recipientStealth = stealthAddress;
@@ -5347,7 +5779,7 @@ async function createShieldedPayment(params, options) {
5347
5779
  payment.recipientAddress = recipientAddress;
5348
5780
  payment.memo = memo;
5349
5781
  }
5350
- if (privacy !== import_types11.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
5782
+ if (privacy !== import_types12.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
5351
5783
  const hexToUint8 = (hex) => {
5352
5784
  const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
5353
5785
  return (0, import_utils11.hexToBytes)(cleanHex);
@@ -5413,7 +5845,7 @@ function decryptMemo(encryptedMemo, viewingKey) {
5413
5845
  function trackPayment(payment) {
5414
5846
  return {
5415
5847
  ...payment,
5416
- status: import_types11.PaymentStatus.DRAFT
5848
+ status: import_types12.PaymentStatus.DRAFT
5417
5849
  };
5418
5850
  }
5419
5851
  function isPaymentExpired(payment) {
@@ -5446,7 +5878,7 @@ function getPaymentSummary(payment) {
5446
5878
  }
5447
5879
 
5448
5880
  // src/treasury/treasury.ts
5449
- var import_types12 = require("@sip-protocol/types");
5881
+ var import_types13 = require("@sip-protocol/types");
5450
5882
  var import_secp256k13 = require("@noble/curves/secp256k1");
5451
5883
  var import_sha25610 = require("@noble/hashes/sha256");
5452
5884
  var import_utils12 = require("@noble/hashes/utils");
@@ -5479,7 +5911,7 @@ var Treasury = class _Treasury {
5479
5911
  ...m,
5480
5912
  addedAt: now
5481
5913
  })),
5482
- defaultPrivacy: params.defaultPrivacy ?? import_types12.PrivacyLevel.SHIELDED,
5914
+ defaultPrivacy: params.defaultPrivacy ?? import_types13.PrivacyLevel.SHIELDED,
5483
5915
  masterViewingKey,
5484
5916
  dailyLimit: params.dailyLimit,
5485
5917
  transactionLimit: params.transactionLimit,
@@ -5558,7 +5990,7 @@ var Treasury = class _Treasury {
5558
5990
  proposalId,
5559
5991
  treasuryId: this.config.treasuryId,
5560
5992
  type: "payment",
5561
- status: import_types12.ProposalStatus.PENDING,
5993
+ status: import_types13.ProposalStatus.PENDING,
5562
5994
  proposer: "",
5563
5995
  // Should be set by caller
5564
5996
  title: params.title,
@@ -5591,7 +6023,7 @@ var Treasury = class _Treasury {
5591
6023
  proposalId,
5592
6024
  treasuryId: this.config.treasuryId,
5593
6025
  type: "batch_payment",
5594
- status: import_types12.ProposalStatus.PENDING,
6026
+ status: import_types13.ProposalStatus.PENDING,
5595
6027
  proposer: "",
5596
6028
  title: params.title,
5597
6029
  description: params.description,
@@ -5625,7 +6057,7 @@ var Treasury = class _Treasury {
5625
6057
  * Get pending proposals
5626
6058
  */
5627
6059
  getPendingProposals() {
5628
- return this.getAllProposals().filter((p) => p.status === import_types12.ProposalStatus.PENDING);
6060
+ return this.getAllProposals().filter((p) => p.status === import_types13.ProposalStatus.PENDING);
5629
6061
  }
5630
6062
  /**
5631
6063
  * Sign a proposal
@@ -5656,7 +6088,7 @@ var Treasury = class _Treasury {
5656
6088
  "SIP_2001" /* INVALID_INPUT */
5657
6089
  );
5658
6090
  }
5659
- if (proposal.status !== import_types12.ProposalStatus.PENDING) {
6091
+ if (proposal.status !== import_types13.ProposalStatus.PENDING) {
5660
6092
  throw new ValidationError(
5661
6093
  `proposal is not pending: ${proposal.status}`,
5662
6094
  "proposalId",
@@ -5666,7 +6098,7 @@ var Treasury = class _Treasury {
5666
6098
  }
5667
6099
  const now = Math.floor(Date.now() / 1e3);
5668
6100
  if (now > proposal.expiresAt) {
5669
- proposal.status = import_types12.ProposalStatus.EXPIRED;
6101
+ proposal.status = import_types13.ProposalStatus.EXPIRED;
5670
6102
  throw new ValidationError(
5671
6103
  "proposal has expired",
5672
6104
  "proposalId",
@@ -5698,9 +6130,9 @@ var Treasury = class _Treasury {
5698
6130
  const approvals = proposal.signatures.filter((s) => s.approved).length;
5699
6131
  const rejections = proposal.signatures.filter((s) => !s.approved).length;
5700
6132
  if (approvals >= proposal.requiredSignatures) {
5701
- proposal.status = import_types12.ProposalStatus.APPROVED;
6133
+ proposal.status = import_types13.ProposalStatus.APPROVED;
5702
6134
  } else if (rejections > this.config.totalSigners - proposal.requiredSignatures) {
5703
- proposal.status = import_types12.ProposalStatus.REJECTED;
6135
+ proposal.status = import_types13.ProposalStatus.REJECTED;
5704
6136
  }
5705
6137
  return proposal;
5706
6138
  }
@@ -5717,7 +6149,7 @@ var Treasury = class _Treasury {
5717
6149
  "SIP_2001" /* INVALID_INPUT */
5718
6150
  );
5719
6151
  }
5720
- if (proposal.status !== import_types12.ProposalStatus.APPROVED) {
6152
+ if (proposal.status !== import_types13.ProposalStatus.APPROVED) {
5721
6153
  throw new ValidationError(
5722
6154
  `proposal is not approved: ${proposal.status}`,
5723
6155
  "proposalId",
@@ -5730,8 +6162,8 @@ var Treasury = class _Treasury {
5730
6162
  const payment = await createShieldedPayment({
5731
6163
  token: proposal.payment.token,
5732
6164
  amount: proposal.payment.amount,
5733
- recipientMetaAddress: proposal.payment.privacy !== import_types12.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
5734
- 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,
5735
6167
  privacy: proposal.payment.privacy,
5736
6168
  viewingKey: this.config.masterViewingKey?.key,
5737
6169
  sourceChain: this.config.chain,
@@ -5744,8 +6176,8 @@ var Treasury = class _Treasury {
5744
6176
  const payment = await createShieldedPayment({
5745
6177
  token: proposal.batchPayment.token,
5746
6178
  amount: recipient.amount,
5747
- recipientMetaAddress: proposal.batchPayment.privacy !== import_types12.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
5748
- 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,
5749
6181
  privacy: proposal.batchPayment.privacy,
5750
6182
  viewingKey: this.config.masterViewingKey?.key,
5751
6183
  sourceChain: this.config.chain,
@@ -5755,7 +6187,7 @@ var Treasury = class _Treasury {
5755
6187
  payments.push(payment);
5756
6188
  }
5757
6189
  }
5758
- proposal.status = import_types12.ProposalStatus.EXECUTED;
6190
+ proposal.status = import_types13.ProposalStatus.EXECUTED;
5759
6191
  proposal.executedAt = Math.floor(Date.now() / 1e3);
5760
6192
  proposal.resultPayments = payments;
5761
6193
  return payments;
@@ -5784,7 +6216,7 @@ var Treasury = class _Treasury {
5784
6216
  "SIP_2001" /* INVALID_INPUT */
5785
6217
  );
5786
6218
  }
5787
- if (proposal.status !== import_types12.ProposalStatus.PENDING) {
6219
+ if (proposal.status !== import_types13.ProposalStatus.PENDING) {
5788
6220
  throw new ValidationError(
5789
6221
  `proposal is not pending: ${proposal.status}`,
5790
6222
  "proposalId",
@@ -5792,7 +6224,7 @@ var Treasury = class _Treasury {
5792
6224
  "SIP_2001" /* INVALID_INPUT */
5793
6225
  );
5794
6226
  }
5795
- proposal.status = import_types12.ProposalStatus.CANCELLED;
6227
+ proposal.status = import_types13.ProposalStatus.CANCELLED;
5796
6228
  return proposal;
5797
6229
  }
5798
6230
  // ─── Auditor Access ──────────────────────────────────────────────────────────
@@ -5889,7 +6321,7 @@ var Treasury = class _Treasury {
5889
6321
  getCommittedAmount(token) {
5890
6322
  let committed = 0n;
5891
6323
  for (const proposal of this.proposals.values()) {
5892
- if (proposal.status !== import_types12.ProposalStatus.PENDING) continue;
6324
+ if (proposal.status !== import_types13.ProposalStatus.PENDING) continue;
5893
6325
  if (proposal.type === "payment" && proposal.payment) {
5894
6326
  if (proposal.payment.token.symbol === token.symbol && proposal.payment.token.chain === token.chain) {
5895
6327
  committed += proposal.payment.amount;
@@ -6132,7 +6564,7 @@ function validateBatchProposalParams(params, config) {
6132
6564
  }
6133
6565
 
6134
6566
  // src/compliance/compliance-manager.ts
6135
- var import_types13 = require("@sip-protocol/types");
6567
+ var import_types14 = require("@sip-protocol/types");
6136
6568
  var import_utils13 = require("@noble/hashes/utils");
6137
6569
  var DEFAULTS2 = {
6138
6570
  riskThreshold: 70,
@@ -6500,7 +6932,7 @@ var ComplianceManager = class _ComplianceManager {
6500
6932
  title: params.title,
6501
6933
  description: params.description,
6502
6934
  format: params.format,
6503
- status: import_types13.ReportStatus.GENERATING,
6935
+ status: import_types14.ReportStatus.GENERATING,
6504
6936
  requestedBy,
6505
6937
  requestedAt: now,
6506
6938
  startDate: params.startDate,
@@ -6529,10 +6961,10 @@ var ComplianceManager = class _ComplianceManager {
6529
6961
  } else if (params.format === "csv") {
6530
6962
  report.content = this.generateCSV(transactions);
6531
6963
  }
6532
- report.status = import_types13.ReportStatus.COMPLETED;
6964
+ report.status = import_types14.ReportStatus.COMPLETED;
6533
6965
  report.generatedAt = Math.floor(Date.now() / 1e3);
6534
6966
  } catch (error) {
6535
- report.status = import_types13.ReportStatus.FAILED;
6967
+ report.status = import_types14.ReportStatus.FAILED;
6536
6968
  report.error = error instanceof Error ? error.message : "Unknown error";
6537
6969
  }
6538
6970
  this.addAuditLog(requestedBy, "report_generated", {
@@ -6895,10 +7327,10 @@ function validateReportParams(params) {
6895
7327
  }
6896
7328
 
6897
7329
  // src/wallet/errors.ts
6898
- var import_types14 = require("@sip-protocol/types");
7330
+ var import_types15 = require("@sip-protocol/types");
6899
7331
  var WalletError = class extends SIPError {
6900
7332
  walletCode;
6901
- constructor(message, walletCode = import_types14.WalletErrorCode.UNKNOWN, options) {
7333
+ constructor(message, walletCode = import_types15.WalletErrorCode.UNKNOWN, options) {
6902
7334
  super(message, "SIP_7000" /* WALLET_ERROR */, options);
6903
7335
  this.walletCode = walletCode;
6904
7336
  this.name = "WalletError";
@@ -6908,10 +7340,10 @@ var WalletError = class extends SIPError {
6908
7340
  */
6909
7341
  isConnectionError() {
6910
7342
  const codes = [
6911
- import_types14.WalletErrorCode.NOT_INSTALLED,
6912
- import_types14.WalletErrorCode.CONNECTION_REJECTED,
6913
- import_types14.WalletErrorCode.CONNECTION_FAILED,
6914
- 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
6915
7347
  ];
6916
7348
  return codes.includes(this.walletCode);
6917
7349
  }
@@ -6920,9 +7352,9 @@ var WalletError = class extends SIPError {
6920
7352
  */
6921
7353
  isSigningError() {
6922
7354
  const codes = [
6923
- import_types14.WalletErrorCode.SIGNING_REJECTED,
6924
- import_types14.WalletErrorCode.SIGNING_FAILED,
6925
- import_types14.WalletErrorCode.INVALID_MESSAGE
7355
+ import_types15.WalletErrorCode.SIGNING_REJECTED,
7356
+ import_types15.WalletErrorCode.SIGNING_FAILED,
7357
+ import_types15.WalletErrorCode.INVALID_MESSAGE
6926
7358
  ];
6927
7359
  return codes.includes(this.walletCode);
6928
7360
  }
@@ -6931,10 +7363,10 @@ var WalletError = class extends SIPError {
6931
7363
  */
6932
7364
  isTransactionError() {
6933
7365
  const codes = [
6934
- import_types14.WalletErrorCode.INSUFFICIENT_FUNDS,
6935
- import_types14.WalletErrorCode.TRANSACTION_REJECTED,
6936
- import_types14.WalletErrorCode.TRANSACTION_FAILED,
6937
- 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
6938
7370
  ];
6939
7371
  return codes.includes(this.walletCode);
6940
7372
  }
@@ -6943,9 +7375,9 @@ var WalletError = class extends SIPError {
6943
7375
  */
6944
7376
  isPrivacyError() {
6945
7377
  const codes = [
6946
- import_types14.WalletErrorCode.STEALTH_NOT_SUPPORTED,
6947
- import_types14.WalletErrorCode.VIEWING_KEY_NOT_SUPPORTED,
6948
- 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
6949
7381
  ];
6950
7382
  return codes.includes(this.walletCode);
6951
7383
  }
@@ -6954,10 +7386,10 @@ var WalletError = class extends SIPError {
6954
7386
  */
6955
7387
  isUserRejection() {
6956
7388
  const codes = [
6957
- import_types14.WalletErrorCode.CONNECTION_REJECTED,
6958
- import_types14.WalletErrorCode.SIGNING_REJECTED,
6959
- import_types14.WalletErrorCode.TRANSACTION_REJECTED,
6960
- 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
6961
7393
  ];
6962
7394
  return codes.includes(this.walletCode);
6963
7395
  }
@@ -6965,15 +7397,15 @@ var WalletError = class extends SIPError {
6965
7397
  function notConnectedError() {
6966
7398
  return new WalletError(
6967
7399
  "Wallet not connected. Call connect() first.",
6968
- import_types14.WalletErrorCode.NOT_CONNECTED
7400
+ import_types15.WalletErrorCode.NOT_CONNECTED
6969
7401
  );
6970
7402
  }
6971
- function featureNotSupportedError(feature, code = import_types14.WalletErrorCode.UNKNOWN) {
7403
+ function featureNotSupportedError(feature, code = import_types15.WalletErrorCode.UNKNOWN) {
6972
7404
  return new WalletError(`${feature} is not supported by this wallet`, code);
6973
7405
  }
6974
7406
 
6975
7407
  // src/wallet/base-adapter.ts
6976
- var import_types15 = require("@sip-protocol/types");
7408
+ var import_types16 = require("@sip-protocol/types");
6977
7409
  var BaseWalletAdapter = class {
6978
7410
  _address = "";
6979
7411
  _publicKey = "";
@@ -7136,12 +7568,12 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
7136
7568
  this._connectionState = "connecting";
7137
7569
  if (this.shouldFailConnect) {
7138
7570
  this.setError(
7139
- import_types15.WalletErrorCode.CONNECTION_FAILED,
7571
+ import_types16.WalletErrorCode.CONNECTION_FAILED,
7140
7572
  "Mock connection failure"
7141
7573
  );
7142
7574
  throw new WalletError(
7143
7575
  "Mock connection failure",
7144
- import_types15.WalletErrorCode.CONNECTION_FAILED
7576
+ import_types16.WalletErrorCode.CONNECTION_FAILED
7145
7577
  );
7146
7578
  }
7147
7579
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -7153,7 +7585,7 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
7153
7585
  async signMessage(message) {
7154
7586
  this.requireConnected();
7155
7587
  if (this.shouldFailSign) {
7156
- throw new WalletError("Mock signing failure", import_types15.WalletErrorCode.SIGNING_FAILED);
7588
+ throw new WalletError("Mock signing failure", import_types16.WalletErrorCode.SIGNING_FAILED);
7157
7589
  }
7158
7590
  const mockSig = new Uint8Array(64);
7159
7591
  for (let i = 0; i < 64; i++) {
@@ -7168,7 +7600,7 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
7168
7600
  async signTransaction(tx) {
7169
7601
  this.requireConnected();
7170
7602
  if (this.shouldFailSign) {
7171
- throw new WalletError("Mock signing failure", import_types15.WalletErrorCode.SIGNING_FAILED);
7603
+ throw new WalletError("Mock signing failure", import_types16.WalletErrorCode.SIGNING_FAILED);
7172
7604
  }
7173
7605
  const signature = await this.signMessage(
7174
7606
  new TextEncoder().encode(JSON.stringify(tx.data))
@@ -7350,7 +7782,7 @@ function isPrivateWalletAdapter(adapter) {
7350
7782
  }
7351
7783
 
7352
7784
  // src/wallet/solana/adapter.ts
7353
- var import_types16 = require("@sip-protocol/types");
7785
+ var import_types17 = require("@sip-protocol/types");
7354
7786
 
7355
7787
  // src/wallet/solana/types.ts
7356
7788
  function getSolanaProvider(wallet = "phantom") {
@@ -7471,19 +7903,19 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7471
7903
  }
7472
7904
  if (!this.provider) {
7473
7905
  this.setError(
7474
- import_types16.WalletErrorCode.NOT_INSTALLED,
7906
+ import_types17.WalletErrorCode.NOT_INSTALLED,
7475
7907
  `${this.walletName} wallet is not installed`
7476
7908
  );
7477
7909
  throw new WalletError(
7478
7910
  `${this.walletName} wallet is not installed`,
7479
- import_types16.WalletErrorCode.NOT_INSTALLED
7911
+ import_types17.WalletErrorCode.NOT_INSTALLED
7480
7912
  );
7481
7913
  }
7482
7914
  const { publicKey } = await this.provider.connect();
7483
7915
  if (!publicKey) {
7484
7916
  throw new WalletError(
7485
7917
  "No public key returned from wallet",
7486
- import_types16.WalletErrorCode.CONNECTION_FAILED
7918
+ import_types17.WalletErrorCode.CONNECTION_FAILED
7487
7919
  );
7488
7920
  }
7489
7921
  this.setupEventHandlers();
@@ -7493,11 +7925,11 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7493
7925
  } catch (error) {
7494
7926
  const message = error instanceof Error ? error.message : "Connection failed";
7495
7927
  if (message.includes("User rejected") || message.includes("rejected")) {
7496
- this.setError(import_types16.WalletErrorCode.CONNECTION_REJECTED, message);
7497
- 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);
7498
7930
  }
7499
- this.setError(import_types16.WalletErrorCode.CONNECTION_FAILED, message);
7500
- 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 });
7501
7933
  }
7502
7934
  }
7503
7935
  /**
@@ -7520,7 +7952,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7520
7952
  async signMessage(message) {
7521
7953
  this.requireConnected();
7522
7954
  if (!this.provider) {
7523
- throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
7955
+ throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
7524
7956
  }
7525
7957
  try {
7526
7958
  const { signature } = await this.provider.signMessage(message);
@@ -7531,9 +7963,9 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7531
7963
  } catch (error) {
7532
7964
  const message2 = error instanceof Error ? error.message : "Signing failed";
7533
7965
  if (message2.includes("User rejected") || message2.includes("rejected")) {
7534
- throw new WalletError(message2, import_types16.WalletErrorCode.SIGNING_REJECTED);
7966
+ throw new WalletError(message2, import_types17.WalletErrorCode.SIGNING_REJECTED);
7535
7967
  }
7536
- throw new WalletError(message2, import_types16.WalletErrorCode.SIGNING_FAILED, {
7968
+ throw new WalletError(message2, import_types17.WalletErrorCode.SIGNING_FAILED, {
7537
7969
  cause: error
7538
7970
  });
7539
7971
  }
@@ -7546,7 +7978,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7546
7978
  async signTransaction(tx) {
7547
7979
  this.requireConnected();
7548
7980
  if (!this.provider) {
7549
- throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
7981
+ throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
7550
7982
  }
7551
7983
  try {
7552
7984
  const solTx = tx.data;
@@ -7565,9 +7997,9 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7565
7997
  } catch (error) {
7566
7998
  const message = error instanceof Error ? error.message : "Signing failed";
7567
7999
  if (message.includes("User rejected") || message.includes("rejected")) {
7568
- throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_REJECTED);
8000
+ throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_REJECTED);
7569
8001
  }
7570
- throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_FAILED, {
8002
+ throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_FAILED, {
7571
8003
  cause: error
7572
8004
  });
7573
8005
  }
@@ -7578,7 +8010,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7578
8010
  async signAndSendTransaction(tx) {
7579
8011
  this.requireConnected();
7580
8012
  if (!this.provider) {
7581
- throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
8013
+ throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
7582
8014
  }
7583
8015
  try {
7584
8016
  const solTx = tx.data;
@@ -7593,12 +8025,12 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7593
8025
  } catch (error) {
7594
8026
  const message = error instanceof Error ? error.message : "Transaction failed";
7595
8027
  if (message.includes("User rejected") || message.includes("rejected")) {
7596
- throw new WalletError(message, import_types16.WalletErrorCode.TRANSACTION_REJECTED);
8028
+ throw new WalletError(message, import_types17.WalletErrorCode.TRANSACTION_REJECTED);
7597
8029
  }
7598
8030
  if (message.includes("insufficient") || message.includes("Insufficient")) {
7599
- throw new WalletError(message, import_types16.WalletErrorCode.INSUFFICIENT_FUNDS);
8031
+ throw new WalletError(message, import_types17.WalletErrorCode.INSUFFICIENT_FUNDS);
7600
8032
  }
7601
- throw new WalletError(message, import_types16.WalletErrorCode.TRANSACTION_FAILED, {
8033
+ throw new WalletError(message, import_types17.WalletErrorCode.TRANSACTION_FAILED, {
7602
8034
  cause: error
7603
8035
  });
7604
8036
  }
@@ -7611,16 +8043,16 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7611
8043
  async signAllTransactions(transactions) {
7612
8044
  this.requireConnected();
7613
8045
  if (!this.provider) {
7614
- throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
8046
+ throw new WalletError("Provider not available", import_types17.WalletErrorCode.NOT_CONNECTED);
7615
8047
  }
7616
8048
  try {
7617
8049
  return await this.provider.signAllTransactions(transactions);
7618
8050
  } catch (error) {
7619
8051
  const message = error instanceof Error ? error.message : "Signing failed";
7620
8052
  if (message.includes("User rejected") || message.includes("rejected")) {
7621
- throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_REJECTED);
8053
+ throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_REJECTED);
7622
8054
  }
7623
- throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_FAILED, {
8055
+ throw new WalletError(message, import_types17.WalletErrorCode.SIGNING_FAILED, {
7624
8056
  cause: error
7625
8057
  });
7626
8058
  }
@@ -7641,7 +8073,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7641
8073
  } catch (error) {
7642
8074
  throw new WalletError(
7643
8075
  "Failed to get balance",
7644
- import_types16.WalletErrorCode.UNKNOWN,
8076
+ import_types17.WalletErrorCode.UNKNOWN,
7645
8077
  { cause: error }
7646
8078
  );
7647
8079
  }
@@ -7654,7 +8086,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
7654
8086
  if (asset.chain !== "solana") {
7655
8087
  throw new WalletError(
7656
8088
  `Asset chain ${asset.chain} not supported by Solana adapter`,
7657
- import_types16.WalletErrorCode.UNSUPPORTED_CHAIN
8089
+ import_types17.WalletErrorCode.UNSUPPORTED_CHAIN
7658
8090
  );
7659
8091
  }
7660
8092
  if (!asset.address) {
@@ -7772,7 +8204,7 @@ function createSolanaAdapter(config = {}) {
7772
8204
  }
7773
8205
 
7774
8206
  // src/wallet/solana/mock.ts
7775
- var import_types18 = require("@sip-protocol/types");
8207
+ var import_types19 = require("@sip-protocol/types");
7776
8208
  var MockPublicKey = class {
7777
8209
  base58;
7778
8210
  bytes;
@@ -7838,8 +8270,8 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7838
8270
  this._connectionState = "connecting";
7839
8271
  await this.simulateLatency();
7840
8272
  if (this.shouldFailConnect) {
7841
- this.setError(import_types18.WalletErrorCode.CONNECTION_FAILED, "Mock connection failure");
7842
- 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);
7843
8275
  }
7844
8276
  const hexPubKey = "0x" + Buffer.from(this.mockPublicKey.toBytes()).toString("hex");
7845
8277
  this.setConnected(this.mockAddress, hexPubKey);
@@ -7858,7 +8290,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7858
8290
  this.requireConnected();
7859
8291
  await this.simulateLatency();
7860
8292
  if (this.shouldFailSign) {
7861
- throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
8293
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
7862
8294
  }
7863
8295
  const mockSig = new Uint8Array(64);
7864
8296
  for (let i = 0; i < 64; i++) {
@@ -7876,7 +8308,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7876
8308
  this.requireConnected();
7877
8309
  await this.simulateLatency();
7878
8310
  if (this.shouldFailSign) {
7879
- throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
8311
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
7880
8312
  }
7881
8313
  const solTx = tx.data;
7882
8314
  this.signedTransactions.push(solTx);
@@ -7896,10 +8328,10 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7896
8328
  this.requireConnected();
7897
8329
  await this.simulateLatency();
7898
8330
  if (this.shouldFailSign) {
7899
- throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
8331
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
7900
8332
  }
7901
8333
  if (this.shouldFailTransaction) {
7902
- throw new WalletError("Mock transaction failure", import_types18.WalletErrorCode.TRANSACTION_FAILED);
8334
+ throw new WalletError("Mock transaction failure", import_types19.WalletErrorCode.TRANSACTION_FAILED);
7903
8335
  }
7904
8336
  const txSig = `mock_tx_${Date.now()}_${Math.random().toString(36).slice(2)}`;
7905
8337
  this.sentTransactions.push(txSig);
@@ -7919,7 +8351,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7919
8351
  this.requireConnected();
7920
8352
  await this.simulateLatency();
7921
8353
  if (this.shouldFailSign) {
7922
- throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
8354
+ throw new WalletError("Mock signing failure", import_types19.WalletErrorCode.SIGNING_REJECTED);
7923
8355
  }
7924
8356
  this.signedTransactions.push(...transactions);
7925
8357
  return transactions.map((tx) => {
@@ -7946,7 +8378,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
7946
8378
  if (asset.chain !== "solana") {
7947
8379
  throw new WalletError(
7948
8380
  `Asset chain ${asset.chain} not supported by Solana adapter`,
7949
- import_types18.WalletErrorCode.UNSUPPORTED_CHAIN
8381
+ import_types19.WalletErrorCode.UNSUPPORTED_CHAIN
7950
8382
  );
7951
8383
  }
7952
8384
  if (!asset.address) {
@@ -8115,7 +8547,7 @@ function createMockSolanaAdapter(config = {}) {
8115
8547
  }
8116
8548
 
8117
8549
  // src/wallet/ethereum/adapter.ts
8118
- var import_types20 = require("@sip-protocol/types");
8550
+ var import_types21 = require("@sip-protocol/types");
8119
8551
 
8120
8552
  // src/wallet/ethereum/types.ts
8121
8553
  var EthereumChainId = {
@@ -8257,7 +8689,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8257
8689
  this._connectionState = "error";
8258
8690
  throw new WalletError(
8259
8691
  `${this.walletType} wallet not found. Please install the extension.`,
8260
- import_types20.WalletErrorCode.NOT_INSTALLED
8692
+ import_types21.WalletErrorCode.NOT_INSTALLED
8261
8693
  );
8262
8694
  }
8263
8695
  const accounts = await this.provider.request({
@@ -8267,7 +8699,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8267
8699
  this._connectionState = "error";
8268
8700
  throw new WalletError(
8269
8701
  "No accounts returned from wallet",
8270
- import_types20.WalletErrorCode.CONNECTION_REJECTED
8702
+ import_types21.WalletErrorCode.CONNECTION_REJECTED
8271
8703
  );
8272
8704
  }
8273
8705
  const address = normalizeAddress(accounts[0]);
@@ -8287,12 +8719,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8287
8719
  if (rpcError.code === 4001) {
8288
8720
  throw new WalletError(
8289
8721
  "User rejected connection request",
8290
- import_types20.WalletErrorCode.CONNECTION_REJECTED
8722
+ import_types21.WalletErrorCode.CONNECTION_REJECTED
8291
8723
  );
8292
8724
  }
8293
8725
  throw new WalletError(
8294
8726
  `Failed to connect: ${rpcError.message || String(error)}`,
8295
- import_types20.WalletErrorCode.CONNECTION_FAILED
8727
+ import_types21.WalletErrorCode.CONNECTION_FAILED
8296
8728
  );
8297
8729
  }
8298
8730
  }
@@ -8312,7 +8744,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8312
8744
  if (!this.provider) {
8313
8745
  throw new WalletError(
8314
8746
  "Provider not available",
8315
- import_types20.WalletErrorCode.NOT_CONNECTED
8747
+ import_types21.WalletErrorCode.NOT_CONNECTED
8316
8748
  );
8317
8749
  }
8318
8750
  try {
@@ -8330,12 +8762,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8330
8762
  if (rpcError.code === 4001) {
8331
8763
  throw new WalletError(
8332
8764
  "User rejected signing request",
8333
- import_types20.WalletErrorCode.SIGNING_REJECTED
8765
+ import_types21.WalletErrorCode.SIGNING_REJECTED
8334
8766
  );
8335
8767
  }
8336
8768
  throw new WalletError(
8337
8769
  `Failed to sign message: ${rpcError.message || String(error)}`,
8338
- import_types20.WalletErrorCode.SIGNING_FAILED
8770
+ import_types21.WalletErrorCode.SIGNING_FAILED
8339
8771
  );
8340
8772
  }
8341
8773
  }
@@ -8347,7 +8779,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8347
8779
  if (!this.provider) {
8348
8780
  throw new WalletError(
8349
8781
  "Provider not available",
8350
- import_types20.WalletErrorCode.NOT_CONNECTED
8782
+ import_types21.WalletErrorCode.NOT_CONNECTED
8351
8783
  );
8352
8784
  }
8353
8785
  try {
@@ -8364,12 +8796,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8364
8796
  if (rpcError.code === 4001) {
8365
8797
  throw new WalletError(
8366
8798
  "User rejected signing request",
8367
- import_types20.WalletErrorCode.SIGNING_REJECTED
8799
+ import_types21.WalletErrorCode.SIGNING_REJECTED
8368
8800
  );
8369
8801
  }
8370
8802
  throw new WalletError(
8371
8803
  `Failed to sign typed data: ${rpcError.message || String(error)}`,
8372
- import_types20.WalletErrorCode.SIGNING_FAILED
8804
+ import_types21.WalletErrorCode.SIGNING_FAILED
8373
8805
  );
8374
8806
  }
8375
8807
  }
@@ -8381,7 +8813,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8381
8813
  if (!this.provider) {
8382
8814
  throw new WalletError(
8383
8815
  "Provider not available",
8384
- import_types20.WalletErrorCode.NOT_CONNECTED
8816
+ import_types21.WalletErrorCode.NOT_CONNECTED
8385
8817
  );
8386
8818
  }
8387
8819
  try {
@@ -8409,7 +8841,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8409
8841
  if (rpcError.code === 4001) {
8410
8842
  throw new WalletError(
8411
8843
  "User rejected transaction signing",
8412
- import_types20.WalletErrorCode.SIGNING_REJECTED
8844
+ import_types21.WalletErrorCode.SIGNING_REJECTED
8413
8845
  );
8414
8846
  }
8415
8847
  if (rpcError.code === -32601 || rpcError.message?.includes("not supported")) {
@@ -8427,7 +8859,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8427
8859
  }
8428
8860
  throw new WalletError(
8429
8861
  `Failed to sign transaction: ${rpcError.message || String(error)}`,
8430
- import_types20.WalletErrorCode.TRANSACTION_FAILED
8862
+ import_types21.WalletErrorCode.TRANSACTION_FAILED
8431
8863
  );
8432
8864
  }
8433
8865
  }
@@ -8439,7 +8871,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8439
8871
  if (!this.provider) {
8440
8872
  throw new WalletError(
8441
8873
  "Provider not available",
8442
- import_types20.WalletErrorCode.NOT_CONNECTED
8874
+ import_types21.WalletErrorCode.NOT_CONNECTED
8443
8875
  );
8444
8876
  }
8445
8877
  try {
@@ -8461,12 +8893,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8461
8893
  if (rpcError.code === 4001) {
8462
8894
  throw new WalletError(
8463
8895
  "User rejected transaction",
8464
- import_types20.WalletErrorCode.TRANSACTION_REJECTED
8896
+ import_types21.WalletErrorCode.TRANSACTION_REJECTED
8465
8897
  );
8466
8898
  }
8467
8899
  throw new WalletError(
8468
8900
  `Failed to send transaction: ${rpcError.message || String(error)}`,
8469
- import_types20.WalletErrorCode.TRANSACTION_FAILED
8901
+ import_types21.WalletErrorCode.TRANSACTION_FAILED
8470
8902
  );
8471
8903
  }
8472
8904
  }
@@ -8501,7 +8933,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8501
8933
  } catch (error) {
8502
8934
  throw new WalletError(
8503
8935
  `Failed to fetch balance: ${String(error)}`,
8504
- import_types20.WalletErrorCode.UNKNOWN
8936
+ import_types21.WalletErrorCode.UNKNOWN
8505
8937
  );
8506
8938
  }
8507
8939
  }
@@ -8513,7 +8945,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8513
8945
  if (asset.chain !== "ethereum") {
8514
8946
  throw new WalletError(
8515
8947
  `Asset chain ${asset.chain} not supported by Ethereum adapter`,
8516
- import_types20.WalletErrorCode.UNSUPPORTED_CHAIN
8948
+ import_types21.WalletErrorCode.UNSUPPORTED_CHAIN
8517
8949
  );
8518
8950
  }
8519
8951
  if (!asset.address) {
@@ -8538,7 +8970,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8538
8970
  } catch (error) {
8539
8971
  throw new WalletError(
8540
8972
  `Failed to fetch token balance: ${String(error)}`,
8541
- import_types20.WalletErrorCode.UNKNOWN
8973
+ import_types21.WalletErrorCode.UNKNOWN
8542
8974
  );
8543
8975
  }
8544
8976
  }
@@ -8550,7 +8982,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8550
8982
  if (!this.provider) {
8551
8983
  throw new WalletError(
8552
8984
  "Provider not available",
8553
- import_types20.WalletErrorCode.NOT_CONNECTED
8985
+ import_types21.WalletErrorCode.NOT_CONNECTED
8554
8986
  );
8555
8987
  }
8556
8988
  try {
@@ -8565,18 +8997,18 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8565
8997
  if (rpcError.code === 4001) {
8566
8998
  throw new WalletError(
8567
8999
  "User rejected chain switch",
8568
- import_types20.WalletErrorCode.CHAIN_SWITCH_REJECTED
9000
+ import_types21.WalletErrorCode.CHAIN_SWITCH_REJECTED
8569
9001
  );
8570
9002
  }
8571
9003
  if (rpcError.code === 4902) {
8572
9004
  throw new WalletError(
8573
9005
  `Chain ${chainId} not added to wallet`,
8574
- import_types20.WalletErrorCode.UNSUPPORTED_CHAIN
9006
+ import_types21.WalletErrorCode.UNSUPPORTED_CHAIN
8575
9007
  );
8576
9008
  }
8577
9009
  throw new WalletError(
8578
9010
  `Failed to switch chain: ${rpcError.message || String(error)}`,
8579
- import_types20.WalletErrorCode.CHAIN_SWITCH_FAILED
9011
+ import_types21.WalletErrorCode.CHAIN_SWITCH_FAILED
8580
9012
  );
8581
9013
  }
8582
9014
  }
@@ -8612,7 +9044,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
8612
9044
  }
8613
9045
  throw new WalletError(
8614
9046
  `Transaction ${txHash} not confirmed after ${maxAttempts * 5} seconds`,
8615
- import_types20.WalletErrorCode.TRANSACTION_FAILED
9047
+ import_types21.WalletErrorCode.TRANSACTION_FAILED
8616
9048
  );
8617
9049
  }
8618
9050
  /**
@@ -8686,7 +9118,7 @@ function createEthereumAdapter(config) {
8686
9118
  }
8687
9119
 
8688
9120
  // src/wallet/ethereum/mock.ts
8689
- var import_types22 = require("@sip-protocol/types");
9121
+ var import_types23 = require("@sip-protocol/types");
8690
9122
  var MockEthereumAdapter = class extends BaseWalletAdapter {
8691
9123
  chain = "ethereum";
8692
9124
  name = "mock-ethereum";
@@ -8727,7 +9159,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8727
9159
  this._connectionState = "error";
8728
9160
  throw new WalletError(
8729
9161
  "Mock connection rejected",
8730
- import_types22.WalletErrorCode.CONNECTION_REJECTED
9162
+ import_types23.WalletErrorCode.CONNECTION_REJECTED
8731
9163
  );
8732
9164
  }
8733
9165
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -8739,7 +9171,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8739
9171
  this._connectionState = "error";
8740
9172
  throw new WalletError(
8741
9173
  `Mock connection failed: ${String(error)}`,
8742
- import_types22.WalletErrorCode.CONNECTION_FAILED
9174
+ import_types23.WalletErrorCode.CONNECTION_FAILED
8743
9175
  );
8744
9176
  }
8745
9177
  }
@@ -8757,7 +9189,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8757
9189
  if (this._shouldFailSign) {
8758
9190
  throw new WalletError(
8759
9191
  "Mock signing rejected",
8760
- import_types22.WalletErrorCode.SIGNING_REJECTED
9192
+ import_types23.WalletErrorCode.SIGNING_REJECTED
8761
9193
  );
8762
9194
  }
8763
9195
  const msgHex = Buffer.from(message).toString("hex");
@@ -8775,7 +9207,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8775
9207
  if (this._shouldFailSign) {
8776
9208
  throw new WalletError(
8777
9209
  "Mock signing rejected",
8778
- import_types22.WalletErrorCode.SIGNING_REJECTED
9210
+ import_types23.WalletErrorCode.SIGNING_REJECTED
8779
9211
  );
8780
9212
  }
8781
9213
  const mockSig = `0x${"1".repeat(130)}`;
@@ -8792,7 +9224,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8792
9224
  if (this._shouldFailSign) {
8793
9225
  throw new WalletError(
8794
9226
  "Mock signing rejected",
8795
- import_types22.WalletErrorCode.SIGNING_REJECTED
9227
+ import_types23.WalletErrorCode.SIGNING_REJECTED
8796
9228
  );
8797
9229
  }
8798
9230
  this._signedTransactions.push(tx);
@@ -8817,7 +9249,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8817
9249
  if (this._shouldFailTransaction) {
8818
9250
  throw new WalletError(
8819
9251
  "Mock transaction failed",
8820
- import_types22.WalletErrorCode.TRANSACTION_FAILED
9252
+ import_types23.WalletErrorCode.TRANSACTION_FAILED
8821
9253
  );
8822
9254
  }
8823
9255
  this._signedTransactions.push(tx);
@@ -8847,7 +9279,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
8847
9279
  if (asset.chain !== "ethereum") {
8848
9280
  throw new WalletError(
8849
9281
  `Asset chain ${asset.chain} not supported by Ethereum adapter`,
8850
- import_types22.WalletErrorCode.UNSUPPORTED_CHAIN
9282
+ import_types23.WalletErrorCode.UNSUPPORTED_CHAIN
8851
9283
  );
8852
9284
  }
8853
9285
  if (!asset.address) {
@@ -9126,7 +9558,7 @@ function getAvailableTransports() {
9126
9558
  }
9127
9559
 
9128
9560
  // src/wallet/hardware/ledger.ts
9129
- var import_types25 = require("@sip-protocol/types");
9561
+ var import_types26 = require("@sip-protocol/types");
9130
9562
  var LedgerWalletAdapter = class extends BaseWalletAdapter {
9131
9563
  chain;
9132
9564
  name = "ledger";
@@ -9279,7 +9711,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
9279
9711
  async getBalance() {
9280
9712
  throw new WalletError(
9281
9713
  "Hardware wallets do not track balances. Use an RPC provider.",
9282
- import_types25.WalletErrorCode.UNSUPPORTED_OPERATION
9714
+ import_types26.WalletErrorCode.UNSUPPORTED_OPERATION
9283
9715
  );
9284
9716
  }
9285
9717
  /**
@@ -9290,7 +9722,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
9290
9722
  async getTokenBalance(_asset) {
9291
9723
  throw new WalletError(
9292
9724
  "Hardware wallets do not track balances. Use an RPC provider.",
9293
- import_types25.WalletErrorCode.UNSUPPORTED_OPERATION
9725
+ import_types26.WalletErrorCode.UNSUPPORTED_OPERATION
9294
9726
  );
9295
9727
  }
9296
9728
  // ─── Account Management ─────────────────────────────────────────────────────
@@ -9578,7 +10010,7 @@ function createLedgerAdapter(config) {
9578
10010
  }
9579
10011
 
9580
10012
  // src/wallet/hardware/trezor.ts
9581
- var import_types27 = require("@sip-protocol/types");
10013
+ var import_types28 = require("@sip-protocol/types");
9582
10014
  var TrezorWalletAdapter = class extends BaseWalletAdapter {
9583
10015
  chain;
9584
10016
  name = "trezor";
@@ -9724,7 +10156,7 @@ var TrezorWalletAdapter = class extends BaseWalletAdapter {
9724
10156
  async getBalance() {
9725
10157
  throw new WalletError(
9726
10158
  "Hardware wallets do not track balances. Use an RPC provider.",
9727
- import_types27.WalletErrorCode.UNSUPPORTED_OPERATION
10159
+ import_types28.WalletErrorCode.UNSUPPORTED_OPERATION
9728
10160
  );
9729
10161
  }
9730
10162
  /**
@@ -9735,7 +10167,7 @@ var TrezorWalletAdapter = class extends BaseWalletAdapter {
9735
10167
  async getTokenBalance(_asset) {
9736
10168
  throw new WalletError(
9737
10169
  "Hardware wallets do not track balances. Use an RPC provider.",
9738
- import_types27.WalletErrorCode.UNSUPPORTED_OPERATION
10170
+ import_types28.WalletErrorCode.UNSUPPORTED_OPERATION
9739
10171
  );
9740
10172
  }
9741
10173
  // ─── Account Management ─────────────────────────────────────────────────────
@@ -10016,7 +10448,7 @@ function createTrezorAdapter(config) {
10016
10448
  }
10017
10449
 
10018
10450
  // src/wallet/hardware/mock.ts
10019
- var import_types29 = require("@sip-protocol/types");
10451
+ var import_types30 = require("@sip-protocol/types");
10020
10452
  var import_utils14 = require("@noble/hashes/utils");
10021
10453
  var MockLedgerAdapter = class extends BaseWalletAdapter {
10022
10454
  chain;
@@ -10164,7 +10596,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
10164
10596
  async getBalance() {
10165
10597
  throw new WalletError(
10166
10598
  "Hardware wallets do not track balances",
10167
- import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10599
+ import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
10168
10600
  );
10169
10601
  }
10170
10602
  /**
@@ -10173,7 +10605,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
10173
10605
  async getTokenBalance(_asset) {
10174
10606
  throw new WalletError(
10175
10607
  "Hardware wallets do not track balances",
10176
- import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10608
+ import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
10177
10609
  );
10178
10610
  }
10179
10611
  /**
@@ -10403,13 +10835,13 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
10403
10835
  async getBalance() {
10404
10836
  throw new WalletError(
10405
10837
  "Hardware wallets do not track balances",
10406
- import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10838
+ import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
10407
10839
  );
10408
10840
  }
10409
10841
  async getTokenBalance(_asset) {
10410
10842
  throw new WalletError(
10411
10843
  "Hardware wallets do not track balances",
10412
- import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
10844
+ import_types30.WalletErrorCode.UNSUPPORTED_OPERATION
10413
10845
  );
10414
10846
  }
10415
10847
  async getAccounts(startIndex = 0, count = 5) {
@@ -10499,7 +10931,7 @@ function createMockTrezorAdapter(config) {
10499
10931
  }
10500
10932
 
10501
10933
  // src/wallet/index.ts
10502
- var import_types32 = require("@sip-protocol/types");
10934
+ var import_types33 = require("@sip-protocol/types");
10503
10935
  // Annotate the CommonJS export names for ESM import in node:
10504
10936
  0 && (module.exports = {
10505
10937
  ATTESTATION_VERSION,
@@ -10560,6 +10992,7 @@ var import_types32 = require("@sip-protocol/types");
10560
10992
  ZcashRPCClient,
10561
10993
  ZcashRPCError,
10562
10994
  ZcashShieldedService,
10995
+ ZcashSwapService,
10563
10996
  addBlindings,
10564
10997
  addCommitments,
10565
10998
  addOracle,
@@ -10594,6 +11027,7 @@ var import_types32 = require("@sip-protocol/types");
10594
11027
  createWalletFactory,
10595
11028
  createZcashClient,
10596
11029
  createZcashShieldedService,
11030
+ createZcashSwapService,
10597
11031
  decodeStealthMetaAddress,
10598
11032
  decryptMemo,
10599
11033
  decryptWithViewing,