@toon-protocol/client 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,215 +9,36 @@ import {
9
9
  evmIdentityFromKey,
10
10
  isHiddenServiceUrl
11
11
  } from "./chunk-6O5OXJVR.js";
12
+ import {
13
+ BeforePayRefusedError,
14
+ ChainUnavailableError,
15
+ ChannelNotOpenError,
16
+ ConfigError,
17
+ ConnectorError,
18
+ FacilitatorError,
19
+ InsufficientBalanceError,
20
+ InvalidAddressError,
21
+ NetworkError,
22
+ PROXIED_RPC_DEFAULTS,
23
+ PaymentRequiredError,
24
+ RouteNotPricedError,
25
+ SponsorRefusedError,
26
+ ToonClientError,
27
+ TransactionOutcomeError,
28
+ TransferNotDeliveredError,
29
+ TransferUnsupportedError,
30
+ TransportRequiredError,
31
+ UnknownChainError,
32
+ ValidationError,
33
+ chainUnavailableMessage,
34
+ describeEndpoint,
35
+ directFetch,
36
+ rpcTransport
37
+ } from "./chunk-ABOW5ZCE.js";
12
38
  import {
13
39
  validateSocks5hUrl
14
40
  } from "./chunk-32MD3CXE.js";
15
41
 
16
- // src/client/errors.ts
17
- var ToonClientError = class extends Error {
18
- constructor(message, code, cause) {
19
- super(message, { cause });
20
- this.code = code;
21
- this.name = "ToonClientError";
22
- }
23
- code;
24
- };
25
- var NetworkError = class extends ToonClientError {
26
- constructor(message, cause) {
27
- super(message, "NETWORK_ERROR", cause);
28
- this.name = "NetworkError";
29
- }
30
- };
31
- var ConnectorError = class extends ToonClientError {
32
- constructor(message, cause) {
33
- super(message, "CONNECTOR_ERROR", cause);
34
- this.name = "ConnectorError";
35
- }
36
- };
37
- var ValidationError = class extends ToonClientError {
38
- constructor(message, cause) {
39
- super(message, "VALIDATION_ERROR", cause);
40
- this.name = "ValidationError";
41
- }
42
- };
43
- var ConfigError = class extends ToonClientError {
44
- constructor(message, cause) {
45
- super(message, "CONFIG", cause);
46
- this.name = "ConfigError";
47
- }
48
- };
49
- var ChainUnavailableError = class extends ToonClientError {
50
- /** The CAIP-2 networks the node publishes (`eip155:84532`, `solana:EtWT…`). */
51
- offered;
52
- constructor(message, offered, cause) {
53
- super(message, "CHAIN_UNAVAILABLE", cause);
54
- this.name = "ChainUnavailableError";
55
- this.offered = [...offered];
56
- }
57
- };
58
- var ChannelNotOpenError = class extends ToonClientError {
59
- constructor(message, cause) {
60
- super(message, "CHANNEL_NOT_OPEN", cause);
61
- this.name = "ChannelNotOpenError";
62
- }
63
- };
64
- var RouteNotPricedError = class extends ToonClientError {
65
- constructor(message, cause) {
66
- super(message, "ROUTE_NOT_PRICED", cause);
67
- this.name = "RouteNotPricedError";
68
- }
69
- };
70
- var BeforePayRefusedError = class extends ToonClientError {
71
- /** The reason the hook returned, verbatim. */
72
- reason;
73
- /** The route the refused packet was addressed to. */
74
- destination;
75
- /** The resolved price the hook was shown, in base units. */
76
- amount;
77
- constructor(reason, destination, amount) {
78
- super(
79
- `beforePay refused this send to "${destination}" for ${amount.toString()}: ${reason}`,
80
- "BEFORE_PAY_REFUSED"
81
- );
82
- this.name = "BeforePayRefusedError";
83
- this.reason = reason;
84
- this.destination = destination;
85
- this.amount = amount;
86
- }
87
- };
88
- var PaymentRequiredError = class extends ToonClientError {
89
- /** The route's terms, parsed from the x402 challenge body. */
90
- terms;
91
- constructor(message, terms, cause) {
92
- super(message, "PAYMENT_REQUIRED", cause);
93
- this.name = "PaymentRequiredError";
94
- this.terms = terms;
95
- }
96
- };
97
- var TransportRequiredError = class extends ToonClientError {
98
- /** The carriage the node requires, when the refusal named one. */
99
- required;
100
- /** The route's terms, when the refusal carried them. */
101
- terms;
102
- constructor(message, options = {}) {
103
- super(message, "TRANSPORT_REQUIRED", options.cause);
104
- this.name = "TransportRequiredError";
105
- this.required = options.required;
106
- this.terms = options.terms;
107
- }
108
- };
109
- var ChannelFundingError = class extends ToonClientError {
110
- retryable = true;
111
- constructor(message, cause) {
112
- super(message, "CHANNEL_FUNDING", cause);
113
- this.name = "ChannelFundingError";
114
- }
115
- };
116
- var ChannelResumeError = class extends ToonClientError {
117
- constructor(message, cause) {
118
- super(message, "CHANNEL_RESUME", cause);
119
- this.name = "ChannelResumeError";
120
- }
121
- };
122
- var InsufficientBalanceError = class extends ToonClientError {
123
- constructor(message, cause) {
124
- super(message, "INSUFFICIENT_BALANCE", cause);
125
- this.name = "InsufficientBalanceError";
126
- }
127
- };
128
- var StaleRpcReadError = class extends ToonClientError {
129
- retryable = true;
130
- constructor(message, cause) {
131
- super(message, "STALE_RPC_READ", cause);
132
- this.name = "StaleRpcReadError";
133
- }
134
- };
135
- var UnknownChainError = class extends ToonClientError {
136
- constructor(message, cause) {
137
- super(message, "UNKNOWN_CHAIN", cause);
138
- this.name = "UnknownChainError";
139
- }
140
- };
141
- var InvalidAddressError = class extends ToonClientError {
142
- constructor(message, cause) {
143
- super(message, "INVALID_ADDRESS", cause);
144
- this.name = "InvalidAddressError";
145
- }
146
- };
147
- var TransferNotDeliveredError = class extends ToonClientError {
148
- constructor(message, cause) {
149
- super(message, "TRANSFER_NOT_DELIVERED", cause);
150
- this.name = "TransferNotDeliveredError";
151
- }
152
- };
153
- var TransferUnsupportedError = class extends ToonClientError {
154
- constructor(message, cause) {
155
- super(message, "TRANSFER_UNSUPPORTED", cause);
156
- this.name = "TransferUnsupportedError";
157
- }
158
- };
159
- var FacilitatorError = class extends ToonClientError {
160
- constructor(message, reason, cause) {
161
- super(message, "FACILITATOR", cause);
162
- this.reason = reason;
163
- this.name = "FacilitatorError";
164
- }
165
- reason;
166
- };
167
- var SponsorRefusedError = class extends ToonClientError {
168
- /**
169
- * @param status the endpoint's HTTP status. `502` is its "failed" class — a
170
- * co-signed open that was sent and did not confirm — so, unlike every other
171
- * refusal, it does not prove nothing landed.
172
- */
173
- constructor(message, reason, status, cause) {
174
- super(message, "SPONSOR_REFUSED", cause);
175
- this.reason = reason;
176
- this.status = status;
177
- this.name = "SponsorRefusedError";
178
- }
179
- reason;
180
- status;
181
- };
182
- var INSUFFICIENT_GAS_MARKERS = [
183
- "exceeds the balance of the account",
184
- "insufficient funds for gas",
185
- "insufficient funds for intrinsic transaction cost",
186
- "insufficient funds for transfer"
187
- ];
188
- function isInsufficientGasError(err) {
189
- const parts = [];
190
- let cur = err;
191
- for (let i = 0; i < 10 && cur != null; i++) {
192
- parts.push(cur instanceof Error ? cur.message : String(cur));
193
- cur = cur instanceof Error ? cur.cause : void 0;
194
- }
195
- const text = parts.join(" | ").toLowerCase();
196
- return INSUFFICIENT_GAS_MARKERS.some((m) => text.includes(m));
197
- }
198
- function chainUnavailableMessage(wanted, offered, reason) {
199
- const list = offered.length > 0 ? offered.join(", ") : "(none)";
200
- if (reason === "none") {
201
- return "This connector publishes no settlement chains at all, so there is no channel to open and nothing can be paid for. Check that it is configured with a settlement backend.";
202
- }
203
- if (reason === "not-offered") {
204
- return `This connector does not settle on "${String(wanted)}". It settles on: ${list}. Set \`chain\` to 'evm' or 'solana' to match one of those, or leave it unset to take the first one this client holds a key for.`;
205
- }
206
- return `This client holds no key for any chain this connector settles on (${list}). Supply a \`mnemonic\` \u2014 which derives both an EVM and a Solana key \u2014 or the raw key for one of those chains.`;
207
- }
208
- var TransactionOutcomeError = class extends ToonClientError {
209
- constructor(message, chain, txHash, outcome, cause) {
210
- super(message, "TRANSACTION_OUTCOME", cause);
211
- this.chain = chain;
212
- this.txHash = txHash;
213
- this.outcome = outcome;
214
- this.name = "TransactionOutcomeError";
215
- }
216
- chain;
217
- txHash;
218
- outcome;
219
- };
220
-
221
42
  // src/btp/protocol.ts
222
43
  var textEncoder = new TextEncoder();
223
44
  var textDecoder = new TextDecoder();
@@ -1725,6 +1546,7 @@ function headerReader(headers) {
1725
1546
  }
1726
1547
  var HttpIlpClient = class {
1727
1548
  httpEndpoint;
1549
+ endpointSource;
1728
1550
  peerId;
1729
1551
  authToken;
1730
1552
  timeout;
@@ -1733,6 +1555,7 @@ var HttpIlpClient = class {
1733
1555
  createWebSocket;
1734
1556
  constructor(config) {
1735
1557
  this.httpEndpoint = config.httpEndpoint;
1558
+ this.endpointSource = config.endpointSource;
1736
1559
  this.peerId = config.peerId;
1737
1560
  this.authToken = config.authToken;
1738
1561
  this.timeout = config.timeout ?? 3e4;
@@ -1961,14 +1784,16 @@ var HttpIlpClient = class {
1961
1784
  }
1962
1785
  if (error instanceof Error && error.name === "AbortError") {
1963
1786
  return new NetworkError(
1964
- `Request timeout after ${requestTimeout}ms`,
1965
- error
1787
+ `Request timeout after ${requestTimeout}ms reaching ${describeEndpoint(this.httpEndpoint, this.endpointSource)}`,
1788
+ error,
1789
+ this.httpEndpoint
1966
1790
  );
1967
1791
  }
1968
1792
  if (error instanceof TypeError && (error.message.includes("fetch failed") || error.message.includes("ECONNREFUSED") || error.message.includes("ECONNRESET") || error.message.includes("ETIMEDOUT") || error.message.includes("network"))) {
1969
1793
  return new NetworkError(
1970
- `Network connection failed: ${error.message}`,
1971
- error
1794
+ `Network connection failed reaching ${describeEndpoint(this.httpEndpoint, this.endpointSource)}: ${error.message}`,
1795
+ error,
1796
+ this.httpEndpoint
1972
1797
  );
1973
1798
  }
1974
1799
  return new ConnectorError(
@@ -2384,7 +2209,8 @@ var ConnectorEdgeClient = class {
2384
2209
  } catch (error) {
2385
2210
  throw new NetworkError(
2386
2211
  `could not reach the connector client edge at ${url}`,
2387
- error instanceof Error ? error : void 0
2212
+ error instanceof Error ? error : void 0,
2213
+ url
2388
2214
  );
2389
2215
  } finally {
2390
2216
  clearTimeout(timer);
@@ -2420,8 +2246,8 @@ var ConnectorEdgeClient = class {
2420
2246
  * a transport failure throws {@link NetworkError} instead, so a caller can
2421
2247
  * always tell "not mine" from "could not ask".
2422
2248
  *
2423
- * Fetched once per (endpoint, destination) and reused. ADR 0020 makes a
2424
- * price flat per handler, so it does not vary with the packet — a route
2249
+ * Fetched once per (endpoint, destination) and reused. ADR 0020 gives a
2250
+ * handler one set of terms, which do not vary with the packet — a route
2425
2251
  * being repriced is an operator event, and {@link invalidateRoutePrice} is
2426
2252
  * how a caller reacts to one.
2427
2253
  *
@@ -2489,7 +2315,8 @@ var ConnectorEdgeClient = class {
2489
2315
  } catch (error) {
2490
2316
  throw new NetworkError(
2491
2317
  `could not reach the connector client edge at ${base}/ilp`,
2492
- error instanceof Error ? error : void 0
2318
+ error instanceof Error ? error : void 0,
2319
+ `${base}/ilp`
2493
2320
  );
2494
2321
  } finally {
2495
2322
  clearTimeout(timer);
@@ -2543,7 +2370,8 @@ var ConnectorEdgeClient = class {
2543
2370
  } catch (error) {
2544
2371
  throw new NetworkError(
2545
2372
  `could not reach the connector client edge at ${url}`,
2546
- error instanceof Error ? error : void 0
2373
+ error instanceof Error ? error : void 0,
2374
+ url
2547
2375
  );
2548
2376
  } finally {
2549
2377
  clearTimeout(timer);
@@ -2657,7 +2485,8 @@ var ConnectorEdgeClient = class {
2657
2485
  } catch (error) {
2658
2486
  throw new NetworkError(
2659
2487
  `could not reach the connector client edge at ${url}`,
2660
- error instanceof Error ? error : void 0
2488
+ error instanceof Error ? error : void 0,
2489
+ url
2661
2490
  );
2662
2491
  } finally {
2663
2492
  clearTimeout(timer);
@@ -2690,12 +2519,12 @@ function parseConnectorRouteTerms(body) {
2690
2519
  }
2691
2520
 
2692
2521
  // src/btp/transport-select.ts
2693
- function selectTransport(description, preference = "auto", baseUrl = description.readFrom, destination) {
2694
- const http2 = resolveEndpoint2(description.httpEndpoint, baseUrl);
2695
- const btp = resolveEndpoint2(description.btpEndpoint, baseUrl);
2522
+ function selectTransport(description, preference = "auto", baseUrl = description.readFrom, destination, overrides = {}) {
2523
+ const http = overrides.http ?? resolveEndpoint2(description.httpEndpoint, baseUrl);
2524
+ const btp = overrides.btp ?? resolveEndpoint2(description.btpEndpoint, baseUrl);
2696
2525
  const required = requiredTransportFor(description, destination);
2697
2526
  if (preference === "http" || preference === "btp") {
2698
- const url = preference === "http" ? http2 : btp;
2527
+ const url = preference === "http" ? http : btp;
2699
2528
  if (url === void 0) {
2700
2529
  throw new TransportRequiredError(
2701
2530
  `the connector publishes no ${preference} endpoint` + (required !== void 0 ? `; its self-description requires the ${required} transport` : ""),
@@ -2705,7 +2534,7 @@ function selectTransport(description, preference = "auto", baseUrl = description
2705
2534
  return { kind: preference, url };
2706
2535
  }
2707
2536
  if (required !== void 0) {
2708
- const url = required === "http" ? http2 : btp;
2537
+ const url = required === "http" ? http : btp;
2709
2538
  if (url === void 0) {
2710
2539
  throw new TransportRequiredError(
2711
2540
  `the connector requires the ${required} transport but publishes no ${required} endpoint`,
@@ -2714,7 +2543,7 @@ function selectTransport(description, preference = "auto", baseUrl = description
2714
2543
  }
2715
2544
  return { kind: required, url };
2716
2545
  }
2717
- if (http2 !== void 0) return { kind: "http", url: http2 };
2546
+ if (http !== void 0) return { kind: "http", url: http };
2718
2547
  if (btp !== void 0) return { kind: "btp", url: btp };
2719
2548
  throw new TransportRequiredError(
2720
2549
  "the connector publishes neither an httpEndpoint nor a btpEndpoint"
@@ -2744,6 +2573,8 @@ function sleep(ms) {
2744
2573
  var BtpPaidWriteTransport = class {
2745
2574
  session;
2746
2575
  fallback;
2576
+ url;
2577
+ endpointSource;
2747
2578
  maxReconnectAttempts;
2748
2579
  reconnectDelay;
2749
2580
  /**
@@ -2756,6 +2587,8 @@ var BtpPaidWriteTransport = class {
2756
2587
  constructor(config) {
2757
2588
  this.session = config.session;
2758
2589
  this.fallback = config.fallback;
2590
+ this.url = config.url;
2591
+ this.endpointSource = config.endpointSource;
2759
2592
  this.maxReconnectAttempts = config.maxReconnectAttempts ?? 1;
2760
2593
  this.reconnectDelay = config.reconnectDelay ?? 250;
2761
2594
  }
@@ -2802,8 +2635,26 @@ var BtpPaidWriteTransport = class {
2802
2635
  }
2803
2636
  /** Connect if need be, then send once. No claim, so nothing to re-spend. */
2804
2637
  async dispatchUnpaid(params) {
2805
- if (!this.session.isConnected) await this.session.connect();
2806
- return this.session.sendIlpPacket(params);
2638
+ try {
2639
+ if (!this.session.isConnected) await this.session.connect();
2640
+ return await this.session.sendIlpPacket(params);
2641
+ } catch (error) {
2642
+ throw this.nameEndpoint(error);
2643
+ }
2644
+ }
2645
+ /**
2646
+ * A connection-level failure becomes a {@link NetworkError} naming the BTP
2647
+ * URL, with the original kept as `cause`. Anything else passes through.
2648
+ */
2649
+ nameEndpoint(error) {
2650
+ if (this.url === void 0 || error instanceof NetworkError) return error;
2651
+ if (!isConnectionError2(error)) return error;
2652
+ const cause = error instanceof Error ? error : void 0;
2653
+ return new NetworkError(
2654
+ `BTP connection failed reaching ${describeEndpoint(this.url, this.endpointSource)}: ${cause?.message ?? String(error)}`,
2655
+ cause,
2656
+ this.url
2657
+ );
2807
2658
  }
2808
2659
  /**
2809
2660
  * One write's worth of connect/send/reconnect/fallback policy. Runs
@@ -2837,8 +2688,12 @@ var BtpPaidWriteTransport = class {
2837
2688
  if (this.fallback) {
2838
2689
  return this.fallback.sendIlpPacketWithClaim(params, claim);
2839
2690
  }
2840
- throw lastError instanceof Error ? lastError : new NetworkError(
2841
- "BTP paid-write transport exhausted its reconnect budget and no HTTP fallback is configured"
2691
+ const named = this.nameEndpoint(lastError);
2692
+ if (named instanceof Error) throw named;
2693
+ throw new NetworkError(
2694
+ `BTP paid-write transport exhausted its reconnect budget${this.url !== void 0 ? ` reaching ${describeEndpoint(this.url, this.endpointSource)}` : ""} and no HTTP fallback is configured`,
2695
+ void 0,
2696
+ this.url
2842
2697
  );
2843
2698
  }
2844
2699
  };
@@ -3590,6 +3445,7 @@ function resolveConfig(config) {
3590
3445
  const connector = resolveConnector(config.connector);
3591
3446
  const connectorIsHiddenService = isHiddenServiceUrl(connector);
3592
3447
  const socksProxy = resolveSocksProxy(config.socksProxy, connector, connectorIsHiddenService);
3448
+ const carriageEndpoints = resolveCarriageEndpoints(config.carriageEndpoints);
3593
3449
  const accountIndex = resolveAccountIndex(config.accountIndex);
3594
3450
  const keyDerivation = config.keyDerivation ?? "standard";
3595
3451
  const identity = resolveIdentity(config, keyDerivation, accountIndex);
@@ -3632,6 +3488,7 @@ function resolveConfig(config) {
3632
3488
  depositGas: config.depositGas ?? "auto",
3633
3489
  connectorIsHiddenService,
3634
3490
  socksProxy,
3491
+ carriageEndpoints,
3635
3492
  proxyRpc: config.proxyRpc ?? true,
3636
3493
  chainRpc: void 0,
3637
3494
  autoOpenChannel: config.autoOpenChannel ?? true,
@@ -3816,6 +3673,32 @@ function resolveChannelStore(store) {
3816
3673
  );
3817
3674
  return { channelStore: new InMemoryChannelStore(), channelStoreIsEphemeral: true };
3818
3675
  }
3676
+ function resolveCarriageEndpoints(overrides) {
3677
+ const out = {};
3678
+ if (overrides === void 0) return out;
3679
+ const schemes = { http: ["http:", "https:"], btp: ["ws:", "wss:"] };
3680
+ for (const kind of ["http", "btp"]) {
3681
+ const value = overrides[kind];
3682
+ if (value === void 0) continue;
3683
+ const label = `carriageEndpoints.${kind}`;
3684
+ const trimmed = value.trim();
3685
+ let url;
3686
+ try {
3687
+ url = new URL(trimmed);
3688
+ } catch {
3689
+ throw new ConfigError(
3690
+ `${label} must be an absolute URL; got ${JSON.stringify(value)}.`
3691
+ );
3692
+ }
3693
+ if (!schemes[kind].includes(url.protocol)) {
3694
+ throw new ConfigError(
3695
+ `${label} must be a ${schemes[kind].join(" or ")} URL; got ${JSON.stringify(value)}.`
3696
+ );
3697
+ }
3698
+ out[kind] = trimmed;
3699
+ }
3700
+ return out;
3701
+ }
3819
3702
 
3820
3703
  // src/client/channel-facade.ts
3821
3704
  import {
@@ -4288,10 +4171,6 @@ function isAccountNotFoundError(err) {
4288
4171
  err.rpcMessage
4289
4172
  );
4290
4173
  }
4291
- function resolveRpcTarget(target) {
4292
- if (typeof target === "string") return { url: target, fetchImpl: globalThis.fetch };
4293
- return { url: target.url, fetchImpl: target.fetchImpl ?? globalThis.fetch };
4294
- }
4295
4174
  var SOLANA_RPC_RETRY_DELAYS_MS = [250, 500, 1e3];
4296
4175
  var RETRYABLE_HTTP_STATUS = /* @__PURE__ */ new Set([403, 408, 413, 429, 500, 502, 503, 504]);
4297
4176
  var MAX_RETRY_AFTER_MS = 1e4;
@@ -4322,7 +4201,7 @@ var SolanaRpcHttpError = class extends Error {
4322
4201
  retryAfterMs;
4323
4202
  };
4324
4203
  async function solanaRpc(rpcUrl, method, params = []) {
4325
- const { url, fetchImpl } = resolveRpcTarget(rpcUrl);
4204
+ const { url, fetch: fetchImpl } = rpcUrl;
4326
4205
  let mayHaveArrived = false;
4327
4206
  for (let attempt2 = 0; ; attempt2++) {
4328
4207
  try {
@@ -5253,32 +5132,6 @@ async function withdrawSvmBatchChannel(rpc, payer, channelId, config, now = BigI
5253
5132
  };
5254
5133
  }
5255
5134
 
5256
- // src/transport/rpc.ts
5257
- import { http } from "viem";
5258
- var PROXIED_RPC_DEFAULTS = {
5259
- timeout: 3e4,
5260
- retryCount: 3,
5261
- retryDelay: 500
5262
- };
5263
- function rpcTransport(url, dispatcher, options = {}) {
5264
- const { timeout, retryCount, retryDelay } = dispatcher === void 0 ? options : { ...PROXIED_RPC_DEFAULTS, ...definedOnly(options) };
5265
- return http(url, {
5266
- ...timeout !== void 0 ? { timeout } : {},
5267
- ...retryCount !== void 0 ? { retryCount } : {},
5268
- ...retryDelay !== void 0 ? { retryDelay } : {},
5269
- ...dispatcher !== void 0 ? { fetchOptions: { dispatcher } } : {}
5270
- });
5271
- }
5272
- function definedOnly(options) {
5273
- return Object.fromEntries(
5274
- Object.entries(options).filter(([, value]) => value !== void 0)
5275
- );
5276
- }
5277
- function rpcFetch(dispatcher, fetchImpl = globalThis.fetch) {
5278
- if (dispatcher === void 0) return fetchImpl;
5279
- return ((input, init) => fetchImpl(input, { ...init, dispatcher }));
5280
- }
5281
-
5282
5135
  // src/client/channel-facade.ts
5283
5136
  var ClientChannelFacade = class {
5284
5137
  constructor(deps) {
@@ -5479,10 +5332,10 @@ var ClientChannelFacade = class {
5479
5332
  id: evmChainIdOf(network),
5480
5333
  name: network,
5481
5334
  nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
5482
- rpcUrls: { default: { http: [evm.rpcUrl] } }
5335
+ rpcUrls: { default: { http: [evm.rpc.url] } }
5483
5336
  });
5484
5337
  const account = privateKeyToAccount(toHexKey(evm.privateKey));
5485
- const transport = rpcTransport(evm.rpcUrl, evm.rpcDispatcher);
5338
+ const transport = rpcTransport(evm.rpc);
5486
5339
  const publicClient = createPublicClient({ chain, transport });
5487
5340
  const walletClient = createWalletClient({ account, chain, transport });
5488
5341
  return {
@@ -5541,13 +5394,22 @@ function rpcAbortSignal(proxied = false) {
5541
5394
  const ms = rpcTimeoutMs(proxied);
5542
5395
  return ms > 0 ? AbortSignal.timeout(ms) : void 0;
5543
5396
  }
5397
+ function evmReadRoute(opts) {
5398
+ return {
5399
+ url: opts.rpcUrl,
5400
+ fetch: opts.evmRpcFetch ?? directFetch,
5401
+ proxied: opts.proxied ?? opts.evmRpcFetch !== void 0
5402
+ };
5403
+ }
5404
+ function evmReadTransport(opts) {
5405
+ const route = evmReadRoute(opts);
5406
+ const timeout = rpcTimeoutMs(route.proxied);
5407
+ return rpcTransport(route, { ...timeout ? { timeout } : {}, retryCount: 1 });
5408
+ }
5544
5409
  async function readEvmTokenBalance(opts) {
5545
5410
  const chainId = parseEvmChainId(opts.chainKey);
5546
5411
  const client = createPublicClient2({
5547
- transport: rpcTransport(opts.rpcUrl, opts.rpcDispatcher, {
5548
- ...rpcTimeoutMs(opts.rpcDispatcher !== void 0) ? { timeout: rpcTimeoutMs(opts.rpcDispatcher !== void 0) } : {},
5549
- retryCount: 1
5550
- }),
5412
+ transport: evmReadTransport(opts),
5551
5413
  chain: defineChain2({
5552
5414
  id: chainId,
5553
5415
  name: opts.chainKey,
@@ -5570,10 +5432,7 @@ async function readEvmTokenBalance(opts) {
5570
5432
  async function readEvmNativeBalance(opts) {
5571
5433
  const chainId = parseEvmChainId(opts.chainKey);
5572
5434
  const client = createPublicClient2({
5573
- transport: rpcTransport(opts.rpcUrl, opts.rpcDispatcher, {
5574
- ...rpcTimeoutMs(opts.rpcDispatcher !== void 0) ? { timeout: rpcTimeoutMs(opts.rpcDispatcher !== void 0) } : {},
5575
- retryCount: 1
5576
- }),
5435
+ transport: evmReadTransport(opts),
5577
5436
  chain: defineChain2({
5578
5437
  id: chainId,
5579
5438
  name: opts.chainKey,
@@ -5585,7 +5444,7 @@ async function readEvmNativeBalance(opts) {
5585
5444
  return { symbol: "ETH", amount: wei.toString(), decimals: 18 };
5586
5445
  }
5587
5446
  async function readSolanaNativeBalance(opts) {
5588
- const fetchImpl = opts.fetchImpl ?? fetch;
5447
+ const fetchImpl = opts.fetchImpl ?? directFetch;
5589
5448
  const res = await fetchImpl(opts.rpcUrl, {
5590
5449
  method: "POST",
5591
5450
  headers: { "content-type": "application/json" },
@@ -5604,7 +5463,7 @@ async function readSolanaNativeBalance(opts) {
5604
5463
  return { symbol: "SOL", amount: lamports.toString(), decimals: 9 };
5605
5464
  }
5606
5465
  async function readSolanaTokenBalance(opts) {
5607
- const fetchImpl = opts.fetchImpl ?? fetch;
5466
+ const fetchImpl = opts.fetchImpl ?? directFetch;
5608
5467
  const res = await fetchImpl(opts.rpcUrl, {
5609
5468
  method: "POST",
5610
5469
  headers: { "content-type": "application/json" },
@@ -5657,14 +5516,14 @@ async function readWalletBalances(sources) {
5657
5516
  const { fetchImpl, solanaProxied: proxied } = sources;
5658
5517
  const tasks = [];
5659
5518
  if (sources.evm) {
5660
- const { chainKey, rpcUrl, owner, tokenAddress, rpcDispatcher } = sources.evm;
5519
+ const { chainKey, rpcUrl, owner, tokenAddress, evmRpcFetch, proxied: evmProxied } = sources.evm;
5661
5520
  tasks.push(
5662
5521
  (async () => {
5663
5522
  const out = { chain: "evm", chainKey, address: owner, tokens: [] };
5664
5523
  const errors = [];
5665
5524
  const [nativeR, tokenR] = await Promise.allSettled([
5666
- readEvmNativeBalance({ rpcUrl, chainKey, owner, rpcDispatcher }),
5667
- tokenAddress ? readEvmTokenBalance({ rpcUrl, chainKey, tokenAddress, owner, rpcDispatcher }) : Promise.resolve(void 0)
5525
+ readEvmNativeBalance({ rpcUrl, chainKey, owner, evmRpcFetch, proxied: evmProxied }),
5526
+ tokenAddress ? readEvmTokenBalance({ rpcUrl, chainKey, tokenAddress, owner, evmRpcFetch, proxied: evmProxied }) : Promise.resolve(void 0)
5668
5527
  ]);
5669
5528
  foldNative(out, nativeR, errors);
5670
5529
  foldToken(out, tokenR, tokenAddress, errors);
@@ -5784,7 +5643,14 @@ var ERC20_TRANSFER_ABI = [
5784
5643
  }
5785
5644
  ];
5786
5645
  function solanaRpcTarget(cfg) {
5787
- return cfg.rpcFetch === void 0 ? cfg.rpcUrl : { url: cfg.rpcUrl, fetchImpl: cfg.rpcFetch };
5646
+ return { url: cfg.rpcUrl, fetch: cfg.rpcFetch ?? directFetch };
5647
+ }
5648
+ function evmRpcRoute(cfg) {
5649
+ return {
5650
+ url: cfg.rpcUrl,
5651
+ fetch: cfg.evmRpcFetch ?? directFetch,
5652
+ proxied: cfg.proxied ?? cfg.evmRpcFetch !== void 0
5653
+ };
5788
5654
  }
5789
5655
  function evmClients(cfg) {
5790
5656
  const chainId = parseEvmChainId(cfg.chainKey);
@@ -5795,12 +5661,12 @@ function evmClients(cfg) {
5795
5661
  rpcUrls: { default: { http: [cfg.rpcUrl] } }
5796
5662
  });
5797
5663
  const publicClient = createPublicClient3({
5798
- transport: rpcTransport(cfg.rpcUrl, cfg.rpcDispatcher),
5664
+ transport: rpcTransport(evmRpcRoute(cfg)),
5799
5665
  chain: viemChain
5800
5666
  });
5801
5667
  const walletClient = createWalletClient2({
5802
5668
  account: cfg.signer.account,
5803
- transport: rpcTransport(cfg.rpcUrl, cfg.rpcDispatcher),
5669
+ transport: rpcTransport(evmRpcRoute(cfg)),
5804
5670
  chain: viemChain
5805
5671
  });
5806
5672
  return { publicClient, walletClient };
@@ -6125,14 +5991,25 @@ var EvmSigner = class {
6125
5991
  }
6126
5992
  };
6127
5993
 
6128
- // src/client/wallet-facade.ts
6129
- function solanaRpcFetch(config) {
6130
- if (config.socksProxy === void 0) return config.fetch;
6131
- return config.chainRpc?.solana.fetch ?? globalThis.fetch;
6132
- }
6133
- function evmRpcDispatcher(config) {
6134
- return config.chainRpc !== void 0 ? { rpcDispatcher: config.chainRpc.evm.dispatcher } : {};
5994
+ // src/client/chain-access.ts
5995
+ function chainRoutes(config) {
5996
+ const { chainRpc, rpcUrls } = config;
5997
+ if (chainRpc !== void 0) {
5998
+ return {
5999
+ evm: { url: rpcUrls.evm, fetch: chainRpc.evm.fetch, proxied: true },
6000
+ solana: { url: rpcUrls.solana, fetch: chainRpc.solana.fetch, proxied: true }
6001
+ };
6002
+ }
6003
+ return {
6004
+ evm: { url: rpcUrls.evm, fetch: directFetch },
6005
+ solana: {
6006
+ url: rpcUrls.solana,
6007
+ fetch: config.socksProxy === void 0 ? config.fetch : directFetch
6008
+ }
6009
+ };
6135
6010
  }
6011
+
6012
+ // src/client/wallet-facade.ts
6136
6013
  var ClientWalletFacade = class {
6137
6014
  deps;
6138
6015
  evmSigner;
@@ -6151,25 +6028,27 @@ var ClientWalletFacade = class {
6151
6028
  const { config } = this.deps;
6152
6029
  const settlements = await this.settlements();
6153
6030
  const wanted = chain !== void 0 ? [chain] : ["evm", "solana"];
6031
+ const routes = chainRoutes(config);
6154
6032
  const sources = {
6155
- fetchImpl: solanaRpcFetch(config),
6156
- ...config.chainRpc !== void 0 ? { solanaProxied: true } : {}
6033
+ fetchImpl: routes.solana.fetch,
6034
+ solanaProxied: routes.solana.proxied === true
6157
6035
  };
6158
6036
  for (const kind of wanted) {
6159
6037
  const entry = settlements.get(kind);
6160
6038
  if (kind === "evm" && config.identity.evm) {
6161
6039
  sources.evm = {
6162
6040
  chainKey: entry?.chain ?? "evm",
6163
- rpcUrl: config.rpcUrls.evm,
6041
+ rpcUrl: routes.evm.url,
6164
6042
  owner: config.identity.evm.address,
6165
- ...evmRpcDispatcher(config),
6043
+ evmRpcFetch: routes.evm.fetch,
6044
+ proxied: routes.evm.proxied === true,
6166
6045
  ...entry?.tokenAddress ? { tokenAddress: entry.tokenAddress } : {}
6167
6046
  };
6168
6047
  }
6169
6048
  if (kind === "solana" && config.identity.solana) {
6170
6049
  sources.solana = {
6171
6050
  ...entry?.chain ? { chainKey: entry.chain } : {},
6172
- rpcUrl: config.rpcUrls.solana,
6051
+ rpcUrl: routes.solana.url,
6173
6052
  owner: config.identity.solana.publicKey,
6174
6053
  ...entry?.tokenAddress ? { tokenMint: entry.tokenAddress } : {}
6175
6054
  };
@@ -6196,21 +6075,23 @@ var ClientWalletFacade = class {
6196
6075
  const { config } = this.deps;
6197
6076
  const settlements = await this.settlements();
6198
6077
  const entry = settlements.get(params.chain);
6078
+ const routes = chainRoutes(config);
6199
6079
  return sendTransfer(
6200
6080
  {
6201
6081
  ...config.identity.evm ? {
6202
6082
  evm: {
6203
6083
  chainKey: entry?.kind === "evm" ? entry.chain : "evm",
6204
- rpcUrl: config.rpcUrls.evm,
6084
+ rpcUrl: routes.evm.url,
6205
6085
  signer: this.signer(),
6206
- ...evmRpcDispatcher(config),
6086
+ evmRpcFetch: routes.evm.fetch,
6087
+ proxied: routes.evm.proxied === true,
6207
6088
  ...entry?.tokenAddress ? { tokenAddress: entry.tokenAddress } : {}
6208
6089
  }
6209
6090
  } : {},
6210
6091
  ...config.identity.solana ? {
6211
6092
  solana: {
6212
- rpcUrl: config.rpcUrls.solana,
6213
- ...config.chainRpc !== void 0 ? { rpcFetch: config.chainRpc.solana.fetch } : {},
6093
+ rpcUrl: routes.solana.url,
6094
+ rpcFetch: routes.solana.fetch,
6214
6095
  keypair: config.identity.solana.secretKey,
6215
6096
  ...entry?.tokenAddress ? { tokenMint: entry.tokenAddress } : {}
6216
6097
  }
@@ -6368,7 +6249,7 @@ var EIP2612_PERMIT_TYPES = {
6368
6249
  };
6369
6250
  function evmWalletAccess(params) {
6370
6251
  const { account } = params;
6371
- const transport = rpcTransport(params.rpcUrl, params.dispatcher);
6252
+ const transport = rpcTransport(params.rpc);
6372
6253
  const reader = createPublicClient4({ transport });
6373
6254
  let writer;
6374
6255
  const wallet = () => writer ??= reader.getChainId().then(
@@ -6379,7 +6260,7 @@ function evmWalletAccess(params) {
6379
6260
  id,
6380
6261
  name: `eip155:${id}`,
6381
6262
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
6382
- rpcUrls: { default: { http: [params.rpcUrl] } }
6263
+ rpcUrls: { default: { http: [params.rpc.url] } }
6383
6264
  })
6384
6265
  })
6385
6266
  );
@@ -6412,7 +6293,7 @@ async function eip2612Nonce(reader, token, owner) {
6412
6293
  return void 0;
6413
6294
  }
6414
6295
  }
6415
- async function facilitatorExtensions(facilitatorUrl, fetchImpl = fetch) {
6296
+ async function facilitatorExtensions(facilitatorUrl, fetchImpl = directFetch) {
6416
6297
  const url = `${facilitatorUrl.replace(/\/+$/, "")}/supported`;
6417
6298
  let body;
6418
6299
  try {
@@ -6591,7 +6472,7 @@ async function settleDeposit(params) {
6591
6472
  withdrawDelay: payload.channelConfig.withdrawDelay
6592
6473
  }
6593
6474
  };
6594
- const fetchImpl = params.fetchImpl ?? fetch;
6475
+ const fetchImpl = params.fetchImpl ?? directFetch;
6595
6476
  const url = `${params.facilitatorUrl.replace(/\/+$/, "")}/settle`;
6596
6477
  let response;
6597
6478
  let text;
@@ -6699,7 +6580,7 @@ async function requestSponsoredOpen(params) {
6699
6580
  params.sponsorEndpoint,
6700
6581
  `${params.connector.replace(/\/+$/, "")}/`
6701
6582
  ).toString();
6702
- const fetchImpl = params.fetchImpl ?? fetch;
6583
+ const fetchImpl = params.fetchImpl ?? directFetch;
6703
6584
  let response;
6704
6585
  let text;
6705
6586
  try {
@@ -7225,7 +7106,7 @@ var BatchSettlementPayer = class {
7225
7106
  offer: { ...offer, extra: { ...offer.extra, assetTransferMethod: method } },
7226
7107
  payload,
7227
7108
  ...extensions ? { extensions } : {},
7228
- ...this.config.fetch ? { fetchImpl: this.config.fetch } : {}
7109
+ fetchImpl: this.config.fetch
7229
7110
  });
7230
7111
  } catch (err) {
7231
7112
  const retry = mode === "auto" && extensions === void 0 && facilitatorCannotHandle(err) && await holdsEth(evm.wallet);
@@ -7364,7 +7245,7 @@ var BatchSettlementPayer = class {
7364
7245
  connector: this.config.connector,
7365
7246
  sponsorEndpoint,
7366
7247
  transaction,
7367
- ...this.config.fetch ? { fetchImpl: this.config.fetch } : {}
7248
+ fetchImpl: this.config.fetch
7368
7249
  });
7369
7250
  } catch (err) {
7370
7251
  if (isDefinitiveRefusal(err)) manager.abandon(channelId);
@@ -8078,7 +7959,8 @@ var ToonClient = class _ToonClient {
8078
7959
  senderId: init.senderId
8079
7960
  };
8080
7961
  this.manager = new BatchChannelManager(init.config.channelStore);
8081
- const chains = chainAccess(init.config);
7962
+ const routes = chainRoutes(init.config);
7963
+ const chains = chainAccess(init.config, routes.solana);
8082
7964
  this.payer = new BatchSettlementPayer({
8083
7965
  connector: init.config.connector,
8084
7966
  manager: this.manager,
@@ -8089,12 +7971,8 @@ var ToonClient = class _ToonClient {
8089
7971
  ...init.config.facilitatorUrl !== void 0 ? { facilitatorUrl: init.config.facilitatorUrl } : {},
8090
7972
  ...init.config.depositMethod !== void 0 ? { depositMethod: init.config.depositMethod } : {},
8091
7973
  depositGas: init.config.depositGas,
8092
- reader: lazyEvmReader(init.config),
8093
- wallet: evmWalletAccess({
8094
- rpcUrl: init.config.rpcUrls.evm,
8095
- account: chains.evm.account,
8096
- dispatcher: init.config.chainRpc?.evm.dispatcher
8097
- })
7974
+ reader: lazyEvmReader(routes.evm),
7975
+ wallet: evmWalletAccess({ rpc: routes.evm, account: chains.evm.account })
8098
7976
  }
8099
7977
  } : {},
8100
7978
  ...chains.solana !== void 0 ? { solana: chains.solana } : {},
@@ -8111,8 +7989,7 @@ var ToonClient = class _ToonClient {
8111
7989
  ...chains.evm !== void 0 ? {
8112
7990
  evm: {
8113
7991
  privateKey: chains.evm.privateKey,
8114
- rpcUrl: init.config.rpcUrls.evm,
8115
- rpcDispatcher: init.config.chainRpc?.evm.dispatcher
7992
+ rpc: routes.evm
8116
7993
  }
8117
7994
  } : {},
8118
7995
  ...chains.solana !== void 0 ? { solana: chains.solana } : {}
@@ -8135,6 +8012,9 @@ var ToonClient = class _ToonClient {
8135
8012
  */
8136
8013
  static async create(config) {
8137
8014
  const base = resolveConfig(config);
8015
+ for (const override of Object.values(base.carriageEndpoints)) {
8016
+ assertReachableWithoutProxy(override, base.socksProxy, "override");
8017
+ }
8138
8018
  const hiddenService = await openHiddenService(base, config);
8139
8019
  const resolved = hiddenService?.config ?? base;
8140
8020
  const edge = new ConnectorEdgeClient({
@@ -8322,11 +8202,7 @@ var ToonClient = class _ToonClient {
8322
8202
  * this fails loudly, naming the proxy, before anything dials.
8323
8203
  */
8324
8204
  assertEndpointReachable(endpoint) {
8325
- if (this.config.socksProxy !== void 0) return;
8326
- if (!isHiddenServiceUrl(endpoint)) return;
8327
- throw new ConfigError(
8328
- `The connector published the endpoint ${JSON.stringify(endpoint)}, which is a hidden service, but this client has no \`socksProxy\` to reach it through. Set one to a running Anyone Protocol \`anon\` daemon (e.g. "socks5h://127.0.0.1:9050"), or ask the operator for a clearnet endpoint.`
8329
- );
8205
+ assertReachableWithoutProxy(endpoint, this.config.socksProxy, "published");
8330
8206
  }
8331
8207
  /** The port {@link send} runs against. */
8332
8208
  sendContext() {
@@ -8388,20 +8264,37 @@ var ToonClient = class _ToonClient {
8388
8264
  if (this.closed) {
8389
8265
  throw new ConfigError("This client has been closed; construct a new one to send again.");
8390
8266
  }
8391
- const choice = selectTransport(description, this.config.transport, void 0, destination);
8267
+ const overrides = this.config.carriageEndpoints;
8268
+ const choice = selectTransport(
8269
+ description,
8270
+ this.config.transport,
8271
+ void 0,
8272
+ destination,
8273
+ overrides
8274
+ );
8392
8275
  const cached = this.carriages[choice.kind];
8393
8276
  if (cached) return cached;
8394
- const httpEndpoint = choice.kind === "http" ? choice.url : httpEndpointOf(description, this.connector);
8277
+ const httpEndpoint = choice.kind === "http" ? choice.url : overrides.http ?? httpEndpointOf(description, this.connector);
8395
8278
  this.assertEndpointReachable(choice.url);
8396
8279
  this.assertEndpointReachable(httpEndpoint);
8397
- const http2 = new HttpIlpClient({
8280
+ const sourceOf = (kind) => {
8281
+ const published = description[kind === "http" ? "httpEndpoint" : "btpEndpoint"];
8282
+ if (overrides[kind] !== void 0) {
8283
+ return { override: published !== void 0 ? { published } : {} };
8284
+ }
8285
+ return published !== void 0 ? "published" : void 0;
8286
+ };
8287
+ const httpSource = sourceOf("http");
8288
+ const btpSource = sourceOf("btp");
8289
+ const http = new HttpIlpClient({
8398
8290
  httpEndpoint,
8291
+ ...httpSource !== void 0 ? { endpointSource: httpSource } : {},
8399
8292
  timeout: this.config.timeoutMs,
8400
8293
  httpClient: this.config.fetch,
8401
8294
  ...this.config.createWebSocket ? { createWebSocket: this.config.createWebSocket } : {}
8402
8295
  });
8403
8296
  if (choice.kind === "http") {
8404
- const carriage2 = { kind: "http", transport: http2 };
8297
+ const carriage2 = { kind: "http", transport: http };
8405
8298
  this.carriages.http = carriage2;
8406
8299
  return carriage2;
8407
8300
  }
@@ -8422,13 +8315,15 @@ var ToonClient = class _ToonClient {
8422
8315
  kind: "btp",
8423
8316
  transport: new BtpPaidWriteTransport({
8424
8317
  session,
8318
+ url: choice.url,
8319
+ ...btpSource !== void 0 ? { endpointSource: btpSource } : {},
8425
8320
  // HTTP fallback only where the node did not REQUIRE btp *for this
8426
8321
  // destination*: falling back onto a carriage the route refuses would
8427
8322
  // turn a recoverable socket outage into a `402` per request. Read
8428
8323
  // through the same per-route resolution the choice above was made with,
8429
8324
  // so the fallback cannot be enabled against a route the node-wide field
8430
8325
  // happens not to describe (TOON_Network#111).
8431
- ...requiredTransportFor(description, destination) === "btp" ? {} : { fallback: http2 },
8326
+ ...requiredTransportFor(description, destination) === "btp" ? {} : { fallback: http },
8432
8327
  ...this.config.btp.maxReconnectAttempts !== void 0 ? { maxReconnectAttempts: this.config.btp.maxReconnectAttempts } : {},
8433
8328
  ...this.config.btp.reconnectDelay !== void 0 ? { reconnectDelay: this.config.btp.reconnectDelay } : {}
8434
8329
  })
@@ -8470,6 +8365,17 @@ function pickChain(config, description) {
8470
8365
  }
8471
8366
  return match.chain;
8472
8367
  }
8368
+ function assertReachableWithoutProxy(endpoint, socksProxy, chosenBy) {
8369
+ if (socksProxy !== void 0) return;
8370
+ if (!isHiddenServiceUrl(endpoint)) return;
8371
+ const [subject, alternative] = chosenBy === "published" ? [
8372
+ "The connector published the endpoint",
8373
+ "ask the operator for a clearnet endpoint"
8374
+ ] : ["The carriage endpoint override", "use a clearnet override"];
8375
+ throw new ConfigError(
8376
+ `${subject} ${JSON.stringify(endpoint)}, which is a hidden service, but this client has no \`socksProxy\` to reach it through. Set one to a running Anyone Protocol \`anon\` daemon (e.g. "socks5h://127.0.0.1:9050"), or ${alternative}.`
8377
+ );
8378
+ }
8473
8379
  function httpEndpointOf(description, connector) {
8474
8380
  const published = description.httpEndpoint;
8475
8381
  if (published === void 0) return `${connector}/ilp`;
@@ -8478,31 +8384,41 @@ function httpEndpointOf(description, connector) {
8478
8384
  async function openHiddenService(resolved, config) {
8479
8385
  const socksProxy = resolved.socksProxy;
8480
8386
  if (socksProxy === void 0) return void 0;
8481
- const { createChainRpcTransport, createHiddenServiceTransport, probeSocks5Proxy } = await import("./socks-KNSFCLBG.js");
8387
+ const { createChainRpcTransport, createHiddenServiceTransport, probeSocks5Proxy } = await import("./socks-OGGKES7C.js");
8388
+ const { proveProxy } = await import("./canary-FYKD66CX.js");
8482
8389
  await probeSocks5Proxy(socksProxy);
8483
8390
  const edge = createHiddenServiceTransport(socksProxy);
8484
8391
  const rpc = resolved.proxyRpc ? {
8485
8392
  evm: createChainRpcTransport(socksProxy, "evm"),
8486
8393
  solana: createChainRpcTransport(socksProxy, "solana")
8487
8394
  } : void 0;
8395
+ const close = async () => {
8396
+ await Promise.all([edge.close(), rpc?.evm.close(), rpc?.solana.close()]);
8397
+ };
8398
+ try {
8399
+ await proveProxy({
8400
+ edge,
8401
+ ...rpc !== void 0 ? { rpc } : {},
8402
+ ...config.canaryPaths !== void 0 ? { overrides: config.canaryPaths } : {}
8403
+ });
8404
+ } catch (err) {
8405
+ await close().catch(() => void 0);
8406
+ throw err;
8407
+ }
8488
8408
  return {
8489
- transport: {
8490
- async close() {
8491
- await Promise.all([edge.close(), rpc?.evm.close(), rpc?.solana.close()]);
8492
- }
8493
- },
8409
+ transport: { close },
8494
8410
  config: {
8495
8411
  ...resolved,
8496
8412
  fetch: config.fetch ?? edge.fetch,
8497
8413
  createWebSocket: config.createWebSocket ?? edge.createWebSocket,
8498
8414
  chainRpc: rpc === void 0 ? void 0 : {
8499
- evm: { dispatcher: rpc.evm.dispatcher, fetch: rpc.evm.fetch },
8500
- solana: { dispatcher: rpc.solana.dispatcher, fetch: rpc.solana.fetch }
8415
+ evm: { fetch: rpc.evm.fetch },
8416
+ solana: { fetch: rpc.solana.fetch }
8501
8417
  }
8502
8418
  }
8503
8419
  };
8504
8420
  }
8505
- function chainAccess(config) {
8421
+ function chainAccess(config, solanaRpc2) {
8506
8422
  const evmKey = config.identity.evm?.privateKey;
8507
8423
  const solanaKey = config.identity.solana;
8508
8424
  return {
@@ -8513,20 +8429,17 @@ function chainAccess(config) {
8513
8429
  privateKey: solanaKey.secretKey.slice(0, 32),
8514
8430
  publicKey: base58Decode(solanaKey.publicKey)
8515
8431
  },
8516
- rpc: {
8517
- url: config.rpcUrls.solana,
8518
- ...config.chainRpc !== void 0 ? { fetchImpl: config.chainRpc.solana.fetch } : {}
8519
- }
8432
+ rpc: solanaRpc2
8520
8433
  }
8521
8434
  } : {}
8522
8435
  };
8523
8436
  }
8524
- function lazyEvmReader(config) {
8437
+ function lazyEvmReader(route) {
8525
8438
  let client;
8526
8439
  return {
8527
8440
  readContract: (params) => {
8528
8441
  client ??= createPublicClient5({
8529
- transport: rpcTransport(config.rpcUrls.evm, config.chainRpc?.evm.dispatcher)
8442
+ transport: rpcTransport(route)
8530
8443
  });
8531
8444
  return client.readContract(params);
8532
8445
  }
@@ -8534,30 +8447,6 @@ function lazyEvmReader(config) {
8534
8447
  }
8535
8448
 
8536
8449
  export {
8537
- ToonClientError,
8538
- NetworkError,
8539
- ConnectorError,
8540
- ValidationError,
8541
- ConfigError,
8542
- ChainUnavailableError,
8543
- ChannelNotOpenError,
8544
- RouteNotPricedError,
8545
- BeforePayRefusedError,
8546
- PaymentRequiredError,
8547
- TransportRequiredError,
8548
- ChannelFundingError,
8549
- ChannelResumeError,
8550
- InsufficientBalanceError,
8551
- StaleRpcReadError,
8552
- UnknownChainError,
8553
- InvalidAddressError,
8554
- TransferNotDeliveredError,
8555
- TransferUnsupportedError,
8556
- FacilitatorError,
8557
- SponsorRefusedError,
8558
- isInsufficientGasError,
8559
- chainUnavailableMessage,
8560
- TransactionOutcomeError,
8561
8450
  BTPMessageType,
8562
8451
  ILPPacketType,
8563
8452
  serializeIlpPrepare,
@@ -8703,9 +8592,6 @@ export {
8703
8592
  buildSvmWithdrawPayerInstruction,
8704
8593
  requestSvmBatchClose,
8705
8594
  withdrawSvmBatchChannel,
8706
- PROXIED_RPC_DEFAULTS,
8707
- rpcTransport,
8708
- rpcFetch,
8709
8595
  ClientChannelFacade,
8710
8596
  readEvmTokenBalance,
8711
8597
  readEvmNativeBalance,
@@ -8748,4 +8634,4 @@ export {
8748
8634
  toEnvelopeRequest,
8749
8635
  ToonClient
8750
8636
  };
8751
- //# sourceMappingURL=chunk-BHGJXLS7.js.map
8637
+ //# sourceMappingURL=chunk-KGT4XOBZ.js.map