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