@ton/mcp 0.1.15-alpha.19 → 0.1.15-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -21392,40 +21392,84 @@ var require_nacl_fast = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21392
21392
  })(typeof module !== "undefined" && module.exports ? module.exports : self.nacl = self.nacl || {});
21393
21393
  }));
21394
21394
  //#endregion
21395
- //#region ../../node_modules/.pnpm/@tonconnect+protocol@2.5.0-alpha.1/node_modules/@tonconnect/protocol/lib/esm/index.mjs
21395
+ //#region ../../node_modules/.pnpm/@tonconnect+protocol@3.0.0/node_modules/@tonconnect/protocol/lib/esm/index.mjs
21396
21396
  var import_nacl_util = /* @__PURE__ */ __toESM(require_nacl_util(), 1);
21397
21397
  var import_nacl_fast = /* @__PURE__ */ __toESM(require_nacl_fast(), 1);
21398
+ /**
21399
+ * Error codes the wallet may return in {@link ConnectEventError}.
21400
+ *
21401
+ * @see [Connect event error codes (Connect spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/connect.md#connect-event-error-codes)
21402
+ */
21398
21403
  var CONNECT_EVENT_ERROR_CODES$1;
21399
21404
  (function(CONNECT_EVENT_ERROR_CODES) {
21405
+ /** Unexpected wallet-side failure. */
21400
21406
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21407
+ /** Request payload is malformed. */
21401
21408
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
21409
+ /** Wallet could not fetch the `tonconnect-manifest.json`. */
21402
21410
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["MANIFEST_NOT_FOUND_ERROR"] = 2] = "MANIFEST_NOT_FOUND_ERROR";
21411
+ /** Manifest was fetched but fails JSON / schema validation. */
21403
21412
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["MANIFEST_CONTENT_ERROR"] = 3] = "MANIFEST_CONTENT_ERROR";
21413
+ /** Wallet does not know the app / session. */
21404
21414
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21415
+ /** User explicitly declined the connect prompt. */
21405
21416
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
21417
+ /** Wallet does not support the requested method. */
21406
21418
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21407
21419
  })(CONNECT_EVENT_ERROR_CODES$1 || (CONNECT_EVENT_ERROR_CODES$1 = {}));
21420
+ /**
21421
+ * Per-item error codes returned inside a {@link ConnectItemReplyError}.
21422
+ *
21423
+ * @see [Connect item error codes (Connect spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/connect.md#connect-item-error-codes)
21424
+ */
21408
21425
  var CONNECT_ITEM_ERROR_CODES$1;
21409
21426
  (function(CONNECT_ITEM_ERROR_CODES) {
21427
+ /** Unexpected wallet-side failure. */
21410
21428
  CONNECT_ITEM_ERROR_CODES[CONNECT_ITEM_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21429
+ /** Wallet does not support this connect item. */
21411
21430
  CONNECT_ITEM_ERROR_CODES[CONNECT_ITEM_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21412
21431
  })(CONNECT_ITEM_ERROR_CODES$1 || (CONNECT_ITEM_ERROR_CODES$1 = {}));
21432
+ /**
21433
+ * Error codes the wallet may return from `sendTransaction`.
21434
+ *
21435
+ * @see [`sendTransaction` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#sendtransaction)
21436
+ */
21413
21437
  var SEND_TRANSACTION_ERROR_CODES$1;
21414
21438
  (function(SEND_TRANSACTION_ERROR_CODES) {
21439
+ /** Unexpected wallet-side failure. */
21415
21440
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21441
+ /** Request payload is malformed. */
21416
21442
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
21443
+ /** Wallet does not know the dApp / session. */
21417
21444
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21445
+ /** User explicitly declined the transaction. */
21418
21446
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
21447
+ /** Wallet does not support the method. */
21419
21448
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21420
21449
  })(SEND_TRANSACTION_ERROR_CODES$1 || (SEND_TRANSACTION_ERROR_CODES$1 = {}));
21450
+ /**
21451
+ * Error codes the wallet may return from `signData`.
21452
+ *
21453
+ * @see [`signData` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#signdata)
21454
+ */
21421
21455
  var SIGN_DATA_ERROR_CODES$1;
21422
21456
  (function(SIGN_DATA_ERROR_CODES) {
21457
+ /** Unexpected wallet-side failure. */
21423
21458
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21459
+ /** Invalid request payload. */
21424
21460
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
21461
+ /** Wallet does not know the dApp / session. */
21425
21462
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21463
+ /** User explicitly declined. */
21426
21464
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
21465
+ /** Wallet does not support `signData` method or the requested `type`. */
21427
21466
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21428
21467
  })(SIGN_DATA_ERROR_CODES$1 || (SIGN_DATA_ERROR_CODES$1 = {}));
21468
+ /**
21469
+ * Error codes the wallet may return from `disconnect`.
21470
+
21471
+ * @see [`disconnect` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#disconnect)
21472
+ */
21429
21473
  var DISCONNECT_ERROR_CODES$1;
21430
21474
  (function(DISCONNECT_ERROR_CODES) {
21431
21475
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
@@ -21433,14 +21477,27 @@ var DISCONNECT_ERROR_CODES$1;
21433
21477
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21434
21478
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21435
21479
  })(DISCONNECT_ERROR_CODES$1 || (DISCONNECT_ERROR_CODES$1 = {}));
21480
+ /**
21481
+ * Error codes the wallet may return from `signMessage`.
21482
+ *
21483
+ * @see [`signMessage` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#signmessage)
21484
+ */
21436
21485
  var SIGN_MESSAGE_ERROR_CODES;
21437
21486
  (function(SIGN_MESSAGE_ERROR_CODES) {
21487
+ /** Unexpected wallet-side failure. */
21438
21488
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21489
+ /** Invalid request payload. */
21439
21490
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
21491
+ /** Wallet does not know the dApp / session. */
21440
21492
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21493
+ /** User explicitly declined. */
21441
21494
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
21495
+ /** Wallet does not support `signMessage`. */
21442
21496
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21443
21497
  })(SIGN_MESSAGE_ERROR_CODES || (SIGN_MESSAGE_ERROR_CODES = {}));
21498
+ /**
21499
+ * Two baseline TON network IDs.
21500
+ */
21444
21501
  var CHAIN$1;
21445
21502
  (function(CHAIN) {
21446
21503
  CHAIN["MAINNET"] = "-239";
@@ -21482,6 +21539,20 @@ function decode$1(value, urlSafe = false) {
21482
21539
  }
21483
21540
  };
21484
21541
  }
21542
+ /**
21543
+ * UTF-8 base64 codec used by `@tonconnect/protocol`. Wraps the NaCl
21544
+ * helpers with optional URL-safe encoding and a typed decoder that can
21545
+ * yield a string, an object (JSON-parsed), or the raw byte array.
21546
+ *
21547
+ * @example
21548
+ * ```ts
21549
+ * import { Base64 } from '@tonconnect/protocol';
21550
+ *
21551
+ * const encoded = Base64.encode({ hello: 'world' });
21552
+ * const obj = Base64.decode(encoded).toObject<{ hello: string }>();
21553
+ * const bin = Base64.decode(Base64.encode('Hello')).toUint8Array();
21554
+ * ```
21555
+ */
21485
21556
  const Base64$1 = {
21486
21557
  encode: encode$1,
21487
21558
  decode: decode$1
@@ -21605,16 +21676,22 @@ function decodeEmbeddedRequestParam(reqParam) {
21605
21676
  const json = fromBase64Url(reqParam);
21606
21677
  return decodeWireEmbeddedRequest(JSON.parse(json));
21607
21678
  }
21679
+ /** Concatenate two byte arrays into a new `Uint8Array`. */
21608
21680
  function concatUint8Arrays(buffer1, buffer2) {
21609
21681
  const mergedArray = new Uint8Array(buffer1.length + buffer2.length);
21610
21682
  mergedArray.set(buffer1);
21611
21683
  mergedArray.set(buffer2, buffer1.length);
21612
21684
  return mergedArray;
21613
21685
  }
21686
+ /**
21687
+ * Split `array` at `index` and return the two halves as fresh
21688
+ * `Uint8Array`s.
21689
+ */
21614
21690
  function splitToUint8Arrays(array, index) {
21615
21691
  if (index >= array.length) throw new Error("Index is out of buffer");
21616
21692
  return [array.slice(0, index), array.slice(index)];
21617
21693
  }
21694
+ /** Hex-encode a byte array, lowercase, no `0x` prefix. */
21618
21695
  function toHexString(byteArray) {
21619
21696
  let hexString = "";
21620
21697
  byteArray.forEach((byte) => {
@@ -21622,13 +21699,52 @@ function toHexString(byteArray) {
21622
21699
  });
21623
21700
  return hexString;
21624
21701
  }
21702
+ /**
21703
+ * Inverse of {@link toHexString}. Throws when `hexString` has an odd length.
21704
+ */
21625
21705
  function hexToByteArray$1(hexString) {
21626
21706
  if (hexString.length % 2 !== 0) throw new Error(`Cannot convert ${hexString} to bytesArray`);
21627
21707
  const result = new Uint8Array(hexString.length / 2);
21628
21708
  for (let i = 0; i < hexString.length; i += 2) result[i / 2] = parseInt(hexString.slice(i, i + 2), 16);
21629
21709
  return result;
21630
21710
  }
21711
+ /**
21712
+ * Implements the TON Connect session-encryption protocol on top of NaCl's
21713
+ * `crypto_box`.
21714
+ *
21715
+ * The protocol is symmetric: each side encrypts the messages it sends and
21716
+ * decrypts the messages it receives. On the dApp side that means encrypting
21717
+ * outgoing {@link AppMessage} and decrypting incoming {@link WalletMessage};
21718
+ * the wallet does the reverse.
21719
+ *
21720
+ * @example
21721
+ * ```ts
21722
+ * import { SessionCrypto, Base64, hexToByteArray } from '@tonconnect/protocol';
21723
+ *
21724
+ * // Generate a fresh session
21725
+ * const session = new SessionCrypto();
21726
+ * const myClientId = session.sessionId; // hex public key (sent to the peer)
21727
+ *
21728
+ * // Encrypt an outgoing message for the peer
21729
+ * const ciphertext = session.encrypt(
21730
+ * JSON.stringify(message),
21731
+ * hexToByteArray(peerClientId)
21732
+ * );
21733
+ *
21734
+ * // Decrypt an incoming message from the peer
21735
+ * const plaintext = session.decrypt(
21736
+ * Base64.decode(bridgeMessage.message).toUint8Array(),
21737
+ * hexToByteArray(bridgeMessage.from)
21738
+ * );
21739
+ * ```
21740
+ *
21741
+ * @see [Session protocol (Session spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/session.md)
21742
+ */
21631
21743
  var SessionCrypto = class {
21744
+ /**
21745
+ * Reuse an existing {@link KeyPair} (resuming a session) or generate a
21746
+ * fresh one (`crypto_box.keyPair()`) when omitted.
21747
+ */
21632
21748
  constructor(keyPair) {
21633
21749
  this.nonceLength = 24;
21634
21750
  this.keyPair = keyPair ? this.createKeypairFromString(keyPair) : this.createKeypair();
@@ -21646,17 +21762,31 @@ var SessionCrypto = class {
21646
21762
  createNonce() {
21647
21763
  return import_nacl_fast.default.randomBytes(this.nonceLength);
21648
21764
  }
21765
+ /**
21766
+ * Encrypt `message` for `receiverPublicKey` using a fresh 24-byte random
21767
+ * nonce. Returns `nonce || ciphertext` as raw bytes; base64-encode this
21768
+ * value before placing it in the bridge `POST /message` body.
21769
+ */
21649
21770
  encrypt(message, receiverPublicKey) {
21650
21771
  const encodedMessage = new TextEncoder().encode(message);
21651
21772
  const nonce = this.createNonce();
21652
21773
  return concatUint8Arrays(nonce, import_nacl_fast.default.box(encodedMessage, nonce, receiverPublicKey, this.keyPair.secretKey));
21653
21774
  }
21775
+ /**
21776
+ * Decrypt the `nonce || ciphertext` blob received from the bridge.
21777
+ * Throws if `nacl.box.open` rejects the message — wrong key, truncated
21778
+ * input or tampered ciphertext.
21779
+ */
21654
21780
  decrypt(message, senderPublicKey) {
21655
21781
  const [nonce, internalMessage] = splitToUint8Arrays(message, this.nonceLength);
21656
21782
  const decrypted = import_nacl_fast.default.box.open(internalMessage, nonce, senderPublicKey, this.keyPair.secretKey);
21657
21783
  if (!decrypted) throw new Error(`Decryption error: \n message: ${message.toString()} \n sender pubkey: ${senderPublicKey.toString()} \n keypair pubkey: ${this.keyPair.publicKey.toString()} \n keypair secretkey: ${this.keyPair.secretKey.toString()}`);
21658
21784
  return new TextDecoder().decode(decrypted);
21659
21785
  }
21786
+ /**
21787
+ * Export the underlying keypair as a {@link KeyPair} of hex strings.
21788
+ * Persist this in dApp / wallet storage to resume the session later.
21789
+ */
21660
21790
  stringifyKeypair() {
21661
21791
  return {
21662
21792
  publicKey: toHexString(this.keyPair.publicKey),
@@ -42259,7 +42389,7 @@ async function CallForSuccess(toCall, attempts = 20, delayMs = 100, shouldRetry)
42259
42389
  return await toCall();
42260
42390
  } catch (err) {
42261
42391
  lastError = err;
42262
- if (shouldRetry && !shouldRetry(err)) throw err;
42392
+ if (typeof shouldRetry === "function" && shouldRetry(err) === false) throw err;
42263
42393
  i++;
42264
42394
  await delay(delayMs);
42265
42395
  }
@@ -42380,7 +42510,7 @@ var MemoryStorageAdapter = class {
42380
42510
  * LICENSE file in the root directory of this source tree.
42381
42511
  *
42382
42512
  */
42383
- const log$36 = globalLogger.createChild("StorageAdapter");
42513
+ const log$37 = globalLogger.createChild("StorageAdapter");
42384
42514
  /**
42385
42515
  * Create storage adapter based on environment and preferences
42386
42516
  */
@@ -42388,7 +42518,7 @@ function createStorageAdapter(config = {}) {
42388
42518
  if (typeof localStorage !== "undefined") try {
42389
42519
  return new LocalStorageAdapter(config);
42390
42520
  } catch (error) {
42391
- log$36.warn("Failed to create LocalStorageAdapter, falling back to memory", { error });
42521
+ log$37.warn("Failed to create LocalStorageAdapter, falling back to memory", { error });
42392
42522
  }
42393
42523
  if (config.allowMemory) return new MemoryStorageAdapter(config);
42394
42524
  else throw new Error("No storage adapter available");
@@ -42402,7 +42532,7 @@ function createStorageAdapter(config = {}) {
42402
42532
  * LICENSE file in the root directory of this source tree.
42403
42533
  *
42404
42534
  */
42405
- const log$35 = globalLogger.createChild("Storage");
42535
+ const log$36 = globalLogger.createChild("Storage");
42406
42536
  /**
42407
42537
  * High-level storage interface with generic type support
42408
42538
  * Wraps StorageAdapter to provide type-safe get/set operations
@@ -42423,7 +42553,7 @@ var Storage = class {
42423
42553
  if (value === null) return null;
42424
42554
  return JSON.parse(value);
42425
42555
  } catch (error) {
42426
- log$35.warn("Failed to parse stored value", {
42556
+ log$36.warn("Failed to parse stored value", {
42427
42557
  key,
42428
42558
  error
42429
42559
  });
@@ -42440,7 +42570,7 @@ var Storage = class {
42440
42570
  const serialized = JSON.stringify(value);
42441
42571
  await this.adapter.set(key, serialized);
42442
42572
  } catch (error) {
42443
- log$35.error("Failed to serialize value for storage", {
42573
+ log$36.error("Failed to serialize value for storage", {
42444
42574
  key,
42445
42575
  error
42446
42576
  });
@@ -42819,7 +42949,7 @@ var WalletManager = class {
42819
42949
  * LICENSE file in the root directory of this source tree.
42820
42950
  *
42821
42951
  */
42822
- const log$34 = globalLogger.createChild("TONConnectStoredSessionManager");
42952
+ const log$35 = globalLogger.createChild("TONConnectStoredSessionManager");
42823
42953
  var TONConnectStoredSessionManager = class {
42824
42954
  sessions = /* @__PURE__ */ new Map();
42825
42955
  storage;
@@ -42952,16 +43082,16 @@ var TONConnectStoredSessionManager = class {
42952
43082
  const wallet = this.walletManager.getWallet(session.walletId);
42953
43083
  if (wallet) session.walletAddress = wallet.getAddress();
42954
43084
  else {
42955
- log$34.warn("Session Wallet not found for session", { sessionId: session.sessionId });
43085
+ log$35.warn("Session Wallet not found for session", { sessionId: session.sessionId });
42956
43086
  continue;
42957
43087
  }
42958
43088
  }
42959
43089
  this.sessions.set(session.sessionId, session);
42960
43090
  }
42961
- log$34.debug("Loaded session metadata", { count: storedSessions.length });
43091
+ log$35.debug("Loaded session metadata", { count: storedSessions.length });
42962
43092
  }
42963
43093
  } catch (error) {
42964
- log$34.warn("Failed to load sessions from storage", { error });
43094
+ log$35.warn("Failed to load sessions from storage", { error });
42965
43095
  }
42966
43096
  }
42967
43097
  /**
@@ -42972,7 +43102,7 @@ var TONConnectStoredSessionManager = class {
42972
43102
  const sessionsToStore = Array.from(this.sessions.values());
42973
43103
  await this.storage.set(this.storageKey, sessionsToStore);
42974
43104
  } catch (error) {
42975
- log$34.warn("Failed to persist sessions to storage", { error });
43105
+ log$35.warn("Failed to persist sessions to storage", { error });
42976
43106
  }
42977
43107
  }
42978
43108
  async migrateSessions() {
@@ -83143,7 +83273,7 @@ globalLogger.createChild("ExtensionTransport");
83143
83273
  * LICENSE file in the root directory of this source tree.
83144
83274
  *
83145
83275
  */
83146
- const log$32 = globalLogger.createChild("BridgeManager");
83276
+ const log$33 = globalLogger.createChild("BridgeManager");
83147
83277
  var BridgeManager = class {
83148
83278
  config;
83149
83279
  bridgeProvider;
@@ -83185,7 +83315,7 @@ var BridgeManager = class {
83185
83315
  this.walletKitConfig = walletKitConfig;
83186
83316
  this.jsBridgeTransport = config?.jsBridgeTransport;
83187
83317
  if (this.config.bridgeUrl && !this.config.disableHttpConnection) this.bridgeProvider = new C(this.config.bridgeUrl, this.queueBridgeEvent.bind(this), (error) => {
83188
- log$32.error("Bridge listener error", { error: error.toString() });
83318
+ log$33.error("Bridge listener error", { error: error.toString() });
83189
83319
  this.analytics?.emitBridgeClientConnectError({
83190
83320
  error_message: `${error?.toString() || "Unknown error"}${error?.errorCode ? ` (Code: ${error?.errorCode})` : ""}`,
83191
83321
  trace_id: error?.traceId,
@@ -83199,12 +83329,12 @@ var BridgeManager = class {
83199
83329
  */
83200
83330
  async start() {
83201
83331
  if (this.isActive === true) {
83202
- log$32.warn("Bridge already started");
83332
+ log$33.warn("Bridge already started");
83203
83333
  return;
83204
83334
  }
83205
83335
  this.isActive = true;
83206
83336
  if (this.isConnected === true) {
83207
- log$32.warn("Bridge already connected");
83337
+ log$33.warn("Bridge already connected");
83208
83338
  return;
83209
83339
  }
83210
83340
  try {
@@ -83216,7 +83346,7 @@ var BridgeManager = class {
83216
83346
  }
83217
83347
  } catch (error) {
83218
83348
  this.isActive = false;
83219
- log$32.error("Failed to start bridge", { error });
83349
+ log$33.error("Failed to start bridge", { error });
83220
83350
  throw error;
83221
83351
  }
83222
83352
  const requestProcessing = () => {
@@ -83229,10 +83359,10 @@ var BridgeManager = class {
83229
83359
  * Create new session for a dApp connection
83230
83360
  */
83231
83361
  async createSession(appSessionId) {
83232
- log$32.info("[BRIDGE] Creating session", { appSessionId });
83362
+ log$33.info("[BRIDGE] Creating session", { appSessionId });
83233
83363
  if (!await this.sessionManager.getSession(appSessionId)) throw new WalletKitError(ERROR_CODES.SESSION_NOT_FOUND, `Session not found`, void 0, { appSessionId });
83234
83364
  if (this.bridgeProvider && this.isConnected) {
83235
- log$32.info("[BRIDGE] Updating clients");
83365
+ log$33.info("[BRIDGE] Updating clients");
83236
83366
  await this.updateClients();
83237
83367
  }
83238
83368
  }
@@ -83241,7 +83371,7 @@ var BridgeManager = class {
83241
83371
  */
83242
83372
  async removeSession(appSessionId) {
83243
83373
  if (this.bridgeProvider && this.isConnected) await this.updateClients();
83244
- log$32.debug("Session removed", { appSessionId });
83374
+ log$33.debug("Session removed", { appSessionId });
83245
83375
  }
83246
83376
  /**
83247
83377
  * Send response to dApp
@@ -83266,12 +83396,12 @@ var BridgeManager = class {
83266
83396
  }
83267
83397
  try {
83268
83398
  await this.bridgeProvider.send(response, sessionCrypto, sessionId, { traceId: event?.traceId });
83269
- log$32.debug("Response sent successfully", {
83399
+ log$33.debug("Response sent successfully", {
83270
83400
  sessionId,
83271
83401
  requestId: event.id
83272
83402
  });
83273
83403
  } catch (error) {
83274
- log$32.error("Failed to send response through bridge", {
83404
+ log$33.error("Failed to send response through bridge", {
83275
83405
  sessionId,
83276
83406
  requestId: event.id,
83277
83407
  error
@@ -83353,7 +83483,7 @@ var BridgeManager = class {
83353
83483
  await this.bridgeProvider?.restoreConnection(clients, { lastEventId: this.lastEventId });
83354
83484
  this.isConnected = true;
83355
83485
  this.reconnectAttempts = 0;
83356
- log$32.info("Bridge connected successfully");
83486
+ log$33.info("Bridge connected successfully");
83357
83487
  if (this.analytics) {
83358
83488
  const client = clients[0];
83359
83489
  this.analytics.emitBridgeClientConnectEstablished({
@@ -83362,7 +83492,7 @@ var BridgeManager = class {
83362
83492
  });
83363
83493
  }
83364
83494
  } catch (error) {
83365
- log$32.error("Bridge connection failed", { error: error?.toString() });
83495
+ log$33.error("Bridge connection failed", { error: error?.toString() });
83366
83496
  this.analytics?.emitBridgeClientConnectError({
83367
83497
  error_message: `${error?.toString() || "Unknown error"}${error?.errorCode ? ` (Code: ${error?.errorCode})` : ""}`,
83368
83498
  trace_id: error?.traceId ?? connectTraceId,
@@ -83371,9 +83501,9 @@ var BridgeManager = class {
83371
83501
  if (!this.config.disableHttpConnection) {
83372
83502
  if (this.reconnectAttempts < (this.config.maxReconnectAttempts || 5)) {
83373
83503
  this.reconnectAttempts++;
83374
- log$32.info("Bridge reconnection attempt", { attempt: this.reconnectAttempts });
83504
+ log$33.info("Bridge reconnection attempt", { attempt: this.reconnectAttempts });
83375
83505
  setTimeout(() => {
83376
- this.connectToSSEBridge().catch((error) => log$32.error("Bridge reconnection failed", { error }));
83506
+ this.connectToSSEBridge().catch((error) => log$33.error("Bridge reconnection failed", { error }));
83377
83507
  }, this.config.reconnectInterval);
83378
83508
  }
83379
83509
  }
@@ -83394,10 +83524,10 @@ var BridgeManager = class {
83394
83524
  * Add client to existing bridge connection
83395
83525
  */
83396
83526
  async updateClients() {
83397
- log$32.debug("Updating clients");
83527
+ log$33.debug("Updating clients");
83398
83528
  if (this.bridgeProvider) {
83399
83529
  const clients = await this.getClients();
83400
- log$32.info("[BRIDGE] Restoring connection", { clients: clients.length });
83530
+ log$33.info("[BRIDGE] Restoring connection", { clients: clients.length });
83401
83531
  await this.bridgeProvider.restoreConnection(clients, { lastEventId: this.lastEventId });
83402
83532
  }
83403
83533
  }
@@ -83405,17 +83535,17 @@ var BridgeManager = class {
83405
83535
  * Queue incoming bridge events for processing
83406
83536
  */
83407
83537
  queueBridgeEvent(event) {
83408
- log$32.debug("Bridge event queued", {
83538
+ log$33.debug("Bridge event queued", {
83409
83539
  eventId: event?.id,
83410
83540
  event
83411
83541
  });
83412
83542
  this.eventQueue.push(event);
83413
83543
  this.processBridgeEvents().catch((error) => {
83414
- log$32.error("Error in background event processing", { error });
83544
+ log$33.error("Error in background event processing", { error });
83415
83545
  });
83416
83546
  }
83417
83547
  queueJsBridgeEvent(messageInfo, event) {
83418
- log$32.debug("JS Bridge event queued", { eventId: messageInfo?.messageId });
83548
+ log$33.debug("JS Bridge event queued", { eventId: messageInfo?.messageId });
83419
83549
  if (!event) return;
83420
83550
  if (!event.traceId) event.traceId = v7();
83421
83551
  if (event.method == "connect") this.eventQueue.push({
@@ -83444,7 +83574,7 @@ var BridgeManager = class {
83444
83574
  walletId: messageInfo.walletId
83445
83575
  });
83446
83576
  this.processBridgeEvents().catch((error) => {
83447
- log$32.error("Error in background event processing", { error });
83577
+ log$33.error("Error in background event processing", { error });
83448
83578
  });
83449
83579
  }
83450
83580
  /**
@@ -83456,7 +83586,7 @@ var BridgeManager = class {
83456
83586
  */
83457
83587
  async processBridgeEvents() {
83458
83588
  if (this.isProcessing) {
83459
- log$32.debug("Event processing already in progress, skipping");
83589
+ log$33.debug("Event processing already in progress, skipping");
83460
83590
  return;
83461
83591
  }
83462
83592
  this.isProcessing = true;
@@ -83469,7 +83599,7 @@ var BridgeManager = class {
83469
83599
  }
83470
83600
  }
83471
83601
  } catch (error) {
83472
- log$32.error("Error during event processing", { error });
83602
+ log$33.error("Error during event processing", { error });
83473
83603
  this.isProcessing = false;
83474
83604
  this.restartConnection();
83475
83605
  return;
@@ -83482,7 +83612,7 @@ var BridgeManager = class {
83482
83612
  */
83483
83613
  async handleBridgeEvent(event) {
83484
83614
  try {
83485
- log$32.info("Bridge event received", { event });
83615
+ log$33.info("Bridge event received", { event });
83486
83616
  const rawEvent = {
83487
83617
  id: event.id || crypto.randomUUID(),
83488
83618
  method: event.method || "unknown",
@@ -83536,12 +83666,12 @@ var BridgeManager = class {
83536
83666
  try {
83537
83667
  await this.eventStore.storeEvent(rawEvent);
83538
83668
  if (this.eventEmitter) this.eventEmitter.emit("bridgeStorageUpdated", {}, "bridge-manager");
83539
- log$32.info("Event stored durably", {
83669
+ log$33.info("Event stored durably", {
83540
83670
  eventId: rawEvent.id,
83541
83671
  method: rawEvent.method
83542
83672
  });
83543
83673
  } catch (error) {
83544
- log$32.error("Failed to store event durably", {
83674
+ log$33.error("Failed to store event durably", {
83545
83675
  eventId: rawEvent.id,
83546
83676
  error: error.message
83547
83677
  });
@@ -83550,13 +83680,13 @@ var BridgeManager = class {
83550
83680
  method: rawEvent.method
83551
83681
  });
83552
83682
  }
83553
- log$32.info("Bridge event processed", { rawEvent });
83683
+ log$33.info("Bridge event processed", { rawEvent });
83554
83684
  if (event?.lastEventId && event.lastEventId !== this.lastEventId) {
83555
83685
  this.lastEventId = event.lastEventId;
83556
83686
  await this.saveLastEventId();
83557
83687
  }
83558
83688
  } catch (error) {
83559
- log$32.error("Error handling bridge event", { error });
83689
+ log$33.error("Error handling bridge event", { error });
83560
83690
  }
83561
83691
  }
83562
83692
  /**
@@ -83567,11 +83697,11 @@ var BridgeManager = class {
83567
83697
  const savedEventId = await this.storage.get(this.storageKey);
83568
83698
  if (savedEventId) {
83569
83699
  this.lastEventId = savedEventId;
83570
- log$32.debug("Loaded last event ID from storage", { lastEventId: this.lastEventId });
83700
+ log$33.debug("Loaded last event ID from storage", { lastEventId: this.lastEventId });
83571
83701
  }
83572
83702
  } catch (error) {
83573
83703
  const storageError = WalletKitError.fromError(ERROR_CODES.STORAGE_READ_FAILED, "Failed to load last event ID from storage", error);
83574
- log$32.warn("Failed to load last event ID from storage", { error: storageError });
83704
+ log$33.warn("Failed to load last event ID from storage", { error: storageError });
83575
83705
  }
83576
83706
  }
83577
83707
  /**
@@ -83581,11 +83711,11 @@ var BridgeManager = class {
83581
83711
  try {
83582
83712
  if (this.lastEventId) {
83583
83713
  await this.storage.set(this.storageKey, this.lastEventId);
83584
- log$32.debug("Saved last event ID to storage", { lastEventId: this.lastEventId });
83714
+ log$33.debug("Saved last event ID to storage", { lastEventId: this.lastEventId });
83585
83715
  }
83586
83716
  } catch (error) {
83587
83717
  const storageError = WalletKitError.fromError(ERROR_CODES.STORAGE_WRITE_FAILED, "Failed to save last event ID to storage", error);
83588
- log$32.warn("Failed to save last event ID to storage", { error: storageError });
83718
+ log$33.warn("Failed to save last event ID to storage", { error: storageError });
83589
83719
  }
83590
83720
  }
83591
83721
  };
@@ -83640,7 +83770,7 @@ function isValidHost(host) {
83640
83770
  * LICENSE file in the root directory of this source tree.
83641
83771
  *
83642
83772
  */
83643
- const log$31 = globalLogger.createChild("ManifestUtils");
83773
+ const log$32 = globalLogger.createChild("ManifestUtils");
83644
83774
  async function fetchManifest(manifestUrl, proxyUrl) {
83645
83775
  try {
83646
83776
  if (!isValidHost(new URL(manifestUrl).host)) return {
@@ -83659,14 +83789,14 @@ async function fetchManifest(manifestUrl, proxyUrl) {
83659
83789
  manifest: null,
83660
83790
  manifestFetchErrorCode: CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR
83661
83791
  };
83662
- log$31.info("Direct manifest fetch failed, trying proxy", { manifestUrl });
83792
+ log$32.info("Direct manifest fetch failed, trying proxy", { manifestUrl });
83663
83793
  return tryFetchManifest(`${proxyUrl}${manifestUrl}`);
83664
83794
  }
83665
83795
  async function tryFetchManifest(url) {
83666
83796
  try {
83667
83797
  const response = await fetch(url);
83668
83798
  if (!response.ok) {
83669
- log$31.error("Failed to fetch manifest not ok", {
83799
+ log$32.error("Failed to fetch manifest not ok", {
83670
83800
  url,
83671
83801
  status: response.status
83672
83802
  });
@@ -83680,7 +83810,7 @@ async function tryFetchManifest(url) {
83680
83810
  manifestFetchErrorCode: void 0
83681
83811
  };
83682
83812
  } catch (e) {
83683
- log$31.error("Failed to fetch manifest catched", {
83813
+ log$32.error("Failed to fetch manifest catched", {
83684
83814
  url,
83685
83815
  error: e
83686
83816
  });
@@ -83699,7 +83829,7 @@ async function tryFetchManifest(url) {
83699
83829
  * LICENSE file in the root directory of this source tree.
83700
83830
  *
83701
83831
  */
83702
- const log$30 = globalLogger.createChild("ConnectHandler");
83832
+ const log$31 = globalLogger.createChild("ConnectHandler");
83703
83833
  var ConnectHandler = class extends BasicHandler {
83704
83834
  config;
83705
83835
  analytics;
@@ -83720,7 +83850,7 @@ var ConnectHandler = class extends BasicHandler {
83720
83850
  manifest = result.manifest;
83721
83851
  manifestFetchErrorCode = result.manifestFetchErrorCode;
83722
83852
  } catch (error) {
83723
- log$30.warn("Failed to fetch manifest", { error });
83853
+ log$31.warn("Failed to fetch manifest", { error });
83724
83854
  }
83725
83855
  const preview = this.createPreview(event, manifestUrl, manifest, manifestFetchErrorCode);
83726
83856
  const connectEvent = {
@@ -83781,14 +83911,14 @@ var ConnectHandler = class extends BasicHandler {
83781
83911
  if (!finalManifestFetchErrorCode && dAppUrl) try {
83782
83912
  const parsedDAppUrl = new URL(dAppUrl);
83783
83913
  if (!isValidHost(parsedDAppUrl.host)) {
83784
- log$30.warn("Invalid dApp URL in manifest - invalid host format", {
83914
+ log$31.warn("Invalid dApp URL in manifest - invalid host format", {
83785
83915
  dAppUrl,
83786
83916
  host: parsedDAppUrl.host
83787
83917
  });
83788
83918
  finalManifestFetchErrorCode = CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR;
83789
83919
  }
83790
83920
  } catch (_) {
83791
- log$30.warn("Invalid dApp URL in manifest - failed to parse", { dAppUrl });
83921
+ log$31.warn("Invalid dApp URL in manifest - failed to parse", { dAppUrl });
83792
83922
  finalManifestFetchErrorCode = CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR;
83793
83923
  }
83794
83924
  }
@@ -84448,7 +84578,7 @@ function createTransferTransaction(params) {
84448
84578
  * LICENSE file in the root directory of this source tree.
84449
84579
  *
84450
84580
  */
84451
- const log$29 = globalLogger.createChild("ItemsResolver");
84581
+ const log$30 = globalLogger.createChild("ItemsResolver");
84452
84582
  /**
84453
84583
  * Resolve structured items (ton/jetton/nft) into raw TransactionRequestMessages.
84454
84584
  * After resolution, downstream code only needs to handle messages.
@@ -84466,7 +84596,7 @@ async function resolveItemsToMessages(items, wallet) {
84466
84596
  messages.push(resolveNftItem(item, wallet));
84467
84597
  break;
84468
84598
  default:
84469
- log$29.warn("Unknown item type, skipping", { item });
84599
+ log$30.warn("Unknown item type, skipping", { item });
84470
84600
  break;
84471
84601
  }
84472
84602
  return messages;
@@ -84528,7 +84658,7 @@ function resolveNftItem(item, wallet) {
84528
84658
  * LICENSE file in the root directory of this source tree.
84529
84659
  *
84530
84660
  */
84531
- const log$28 = globalLogger.createChild("EventsUtils");
84661
+ const log$29 = globalLogger.createChild("EventsUtils");
84532
84662
  /**
84533
84663
  * Helper to get wallet from event
84534
84664
  */
@@ -84587,7 +84717,7 @@ function parseTonConnectTransactionRequest(event, wallet) {
84587
84717
  validation: validateTransactionRequestForWallet(request, wallet, event.isLocal)
84588
84718
  };
84589
84719
  } catch (error) {
84590
- log$28.error("Failed to parse transaction request", { error });
84720
+ log$29.error("Failed to parse transaction request", { error });
84591
84721
  errors.push("Failed to parse transaction request");
84592
84722
  return {
84593
84723
  result: void 0,
@@ -86960,7 +87090,7 @@ async function computeMoneyFlow(client, response, options = {}) {
86960
87090
  * LICENSE file in the root directory of this source tree.
86961
87091
  *
86962
87092
  */
86963
- const log$27 = globalLogger.createChild("TransactionPreview");
87093
+ const log$28 = globalLogger.createChild("TransactionPreview");
86964
87094
  const SIGN_MODE_EMULATION_VALUE = 2000000000n;
86965
87095
  async function createTransactionPreview(client, request, wallet, options = {}) {
86966
87096
  const isSignMode = (options.mode ?? "send") === "sign";
@@ -87012,7 +87142,7 @@ async function createTransactionPreviewIfPossible(config, client, request, walle
87012
87142
  try {
87013
87143
  preview = await CallForSuccess(() => createTransactionPreview(client, request, wallet, options));
87014
87144
  } catch (error) {
87015
- log$27.error("Failed to create transaction preview", { error });
87145
+ log$28.error("Failed to create transaction preview", { error });
87016
87146
  preview = {
87017
87147
  error: {
87018
87148
  code: ERROR_CODES.UNKNOWN_EMULATION_ERROR,
@@ -87287,7 +87417,7 @@ async function getTransactionStatus(client, params) {
87287
87417
  * LICENSE file in the root directory of this source tree.
87288
87418
  *
87289
87419
  */
87290
- const log$26 = globalLogger.createChild("TransactionHandler");
87420
+ const log$27 = globalLogger.createChild("TransactionHandler");
87291
87421
  var TransactionHandler = class extends BasicHandler {
87292
87422
  config;
87293
87423
  walletManager;
@@ -87309,7 +87439,7 @@ var TransactionHandler = class extends BasicHandler {
87309
87439
  async handle(event) {
87310
87440
  const wallet = getWalletFromEvent(this.walletManager, event);
87311
87441
  if (!wallet) {
87312
- log$26.error("Wallet not found", { event });
87442
+ log$27.error("Wallet not found", { event });
87313
87443
  return {
87314
87444
  error: {
87315
87445
  code: SEND_TRANSACTION_ERROR_CODES$1.UNKNOWN_APP_ERROR,
@@ -87320,7 +87450,7 @@ var TransactionHandler = class extends BasicHandler {
87320
87450
  }
87321
87451
  const requestValidation = this.parseTonConnectTransactionRequest(event, wallet);
87322
87452
  if (!requestValidation.result || !requestValidation?.validation?.isValid) {
87323
- log$26.error("Failed to parse transaction request", {
87453
+ log$27.error("Failed to parse transaction request", {
87324
87454
  event,
87325
87455
  requestValidation
87326
87456
  });
@@ -87372,7 +87502,7 @@ var TransactionHandler = class extends BasicHandler {
87372
87502
  * LICENSE file in the root directory of this source tree.
87373
87503
  *
87374
87504
  */
87375
- const log$25 = globalLogger.createChild("SignDataHandler");
87505
+ const log$26 = globalLogger.createChild("SignDataHandler");
87376
87506
  var SignDataHandler = class extends BasicHandler {
87377
87507
  analytics;
87378
87508
  walletManager;
@@ -87393,12 +87523,12 @@ var SignDataHandler = class extends BasicHandler {
87393
87523
  const wallet = walletId ? this.walletManager.getWallet(walletId) : void 0;
87394
87524
  const payload = this.parseDataToSign(event);
87395
87525
  if (!payload) {
87396
- log$25.error("No data to sign found in request", { event });
87526
+ log$26.error("No data to sign found in request", { event });
87397
87527
  throw new WalletKitError(ERROR_CODES.INVALID_REQUEST_EVENT, "No data to sign found in request", void 0, { eventId: event.id });
87398
87528
  }
87399
87529
  const preview = this.createDataPreview(payload.data, event);
87400
87530
  if (!preview) {
87401
- log$25.error("No preview found for data", { data: payload });
87531
+ log$26.error("No preview found for data", { data: payload });
87402
87532
  throw new WalletKitError(ERROR_CODES.RESPONSE_CREATION_FAILED, "Failed to create preview for sign data request", void 0, {
87403
87533
  eventId: event.id,
87404
87534
  data: payload
@@ -87455,7 +87585,7 @@ var SignDataHandler = class extends BasicHandler {
87455
87585
  }
87456
87586
  };
87457
87587
  } catch (error) {
87458
- log$25.error("Error deserializing cell", { error });
87588
+ log$26.error("Error deserializing cell", { error });
87459
87589
  return {
87460
87590
  type: "cell",
87461
87591
  value: {
@@ -87475,7 +87605,7 @@ var SignDataHandler = class extends BasicHandler {
87475
87605
  * LICENSE file in the root directory of this source tree.
87476
87606
  *
87477
87607
  */
87478
- const log$24 = globalLogger.createChild("SignMessageHandler");
87608
+ const log$25 = globalLogger.createChild("SignMessageHandler");
87479
87609
  var SignMessageHandler = class extends BasicHandler {
87480
87610
  config;
87481
87611
  walletManager;
@@ -87497,7 +87627,7 @@ var SignMessageHandler = class extends BasicHandler {
87497
87627
  async handle(event) {
87498
87628
  const wallet = getWalletFromEvent(this.walletManager, event);
87499
87629
  if (!wallet) {
87500
- log$24.error("Wallet not found", { event });
87630
+ log$25.error("Wallet not found", { event });
87501
87631
  return {
87502
87632
  error: {
87503
87633
  code: SIGN_MESSAGE_ERROR_CODES.UNKNOWN_APP_ERROR,
@@ -87508,7 +87638,7 @@ var SignMessageHandler = class extends BasicHandler {
87508
87638
  }
87509
87639
  const requestValidation = this.parseTonConnectTransactionRequest(event, wallet);
87510
87640
  if (!requestValidation.result || !requestValidation?.validation?.isValid) {
87511
- log$24.error("Failed to parse sign message request", {
87641
+ log$25.error("Failed to parse sign message request", {
87512
87642
  event,
87513
87643
  requestValidation
87514
87644
  });
@@ -87601,7 +87731,7 @@ var DisconnectHandler = class extends BasicHandler {
87601
87731
  * LICENSE file in the root directory of this source tree.
87602
87732
  *
87603
87733
  */
87604
- const log$23 = globalLogger.createChild("EventRouter");
87734
+ const log$24 = globalLogger.createChild("EventRouter");
87605
87735
  var EventRouter = class {
87606
87736
  config;
87607
87737
  eventEmitter;
@@ -87633,7 +87763,7 @@ var EventRouter = class {
87633
87763
  async routeEvent(event) {
87634
87764
  const validation = validateBridgeEvent(event);
87635
87765
  if (!validation.isValid) {
87636
- log$23.error("Invalid bridge event", { errors: validation.errors });
87766
+ log$24.error("Invalid bridge event", { errors: validation.errors });
87637
87767
  return;
87638
87768
  }
87639
87769
  try {
@@ -87648,7 +87778,7 @@ var EventRouter = class {
87648
87778
  try {
87649
87779
  await this.bridgeManager.sendResponse(event, result);
87650
87780
  } catch (error) {
87651
- log$23.error("Error sending response for error event", {
87781
+ log$24.error("Error sending response for error event", {
87652
87782
  error,
87653
87783
  event,
87654
87784
  result
@@ -87660,7 +87790,7 @@ var EventRouter = class {
87660
87790
  break;
87661
87791
  }
87662
87792
  } catch (error) {
87663
- log$23.error("Error routing event", { error });
87793
+ log$24.error("Error routing event", { error });
87664
87794
  throw error;
87665
87795
  }
87666
87796
  }
@@ -87787,7 +87917,7 @@ var EventRouter = class {
87787
87917
  * LICENSE file in the root directory of this source tree.
87788
87918
  *
87789
87919
  */
87790
- const log$22 = globalLogger.createChild("RequestProcessor");
87920
+ const log$23 = globalLogger.createChild("RequestProcessor");
87791
87921
  function hasConnectionResult(event) {
87792
87922
  return "connectionResult" in event;
87793
87923
  }
@@ -87856,7 +87986,7 @@ var RequestProcessor = class {
87856
87986
  }
87857
87987
  return;
87858
87988
  } catch (error) {
87859
- log$22.error("Failed to approve connect request", { error });
87989
+ log$23.error("Failed to approve connect request", { error });
87860
87990
  throw error;
87861
87991
  }
87862
87992
  }
@@ -87991,7 +88121,7 @@ var RequestProcessor = class {
87991
88121
  */
87992
88122
  async rejectConnectRequest(event, reason, errorCode) {
87993
88123
  try {
87994
- log$22.info("Connect request rejected", {
88124
+ log$23.info("Connect request rejected", {
87995
88125
  id: event.id,
87996
88126
  dAppName: event.preview.dAppInfo?.name || "",
87997
88127
  reason: reason || "User rejected connection"
@@ -88008,7 +88138,7 @@ var RequestProcessor = class {
88008
88138
  try {
88009
88139
  await this.bridgeManager.sendResponse(event, response, new SessionCrypto());
88010
88140
  } catch (error) {
88011
- log$22.error("Failed to send connect request rejection response", { error });
88141
+ log$23.error("Failed to send connect request rejection response", { error });
88012
88142
  }
88013
88143
  if (this.analytics) {
88014
88144
  const sessionData = event.from ? await this.sessionManager.getSession(sessionId) : void 0;
@@ -88037,7 +88167,7 @@ var RequestProcessor = class {
88037
88167
  }
88038
88168
  return;
88039
88169
  } catch (error) {
88040
- log$22.error("Failed to reject connect request", { error });
88170
+ log$23.error("Failed to reject connect request", { error });
88041
88171
  throw error;
88042
88172
  }
88043
88173
  }
@@ -88069,7 +88199,7 @@ var RequestProcessor = class {
88069
88199
  return { signedBoc };
88070
88200
  }
88071
88201
  } catch (error) {
88072
- log$22.error("Failed to approve transaction request", { error });
88202
+ log$23.error("Failed to approve transaction request", { error });
88073
88203
  if (error instanceof WalletKitError) throw error;
88074
88204
  if (error?.message?.includes("Ledger device")) throw new WalletKitError(ERROR_CODES.LEDGER_DEVICE_ERROR, "Ledger device error", error);
88075
88205
  throw error;
@@ -88119,7 +88249,7 @@ var RequestProcessor = class {
88119
88249
  }
88120
88250
  return;
88121
88251
  } catch (error) {
88122
- log$22.error("Failed to reject transaction request", { error });
88252
+ log$23.error("Failed to reject transaction request", { error });
88123
88253
  throw error;
88124
88254
  }
88125
88255
  }
@@ -88150,7 +88280,7 @@ var RequestProcessor = class {
88150
88280
  return { internalBoc };
88151
88281
  }
88152
88282
  } catch (error) {
88153
- log$22.error("Failed to approve sign message request", { error });
88283
+ log$23.error("Failed to approve sign message request", { error });
88154
88284
  throw error;
88155
88285
  }
88156
88286
  }
@@ -88168,7 +88298,7 @@ var RequestProcessor = class {
88168
88298
  };
88169
88299
  await this.sendBridgeMessage(event, void 0, response);
88170
88300
  } catch (error) {
88171
- log$22.error("Failed to reject sign message request", { error });
88301
+ log$23.error("Failed to reject sign message request", { error });
88172
88302
  throw error;
88173
88303
  }
88174
88304
  }
@@ -88271,7 +88401,7 @@ var RequestProcessor = class {
88271
88401
  };
88272
88402
  }
88273
88403
  } catch (error) {
88274
- log$22.error("Failed to approve sign data request", { error: error?.message?.toString() ?? error?.toString() });
88404
+ log$23.error("Failed to approve sign data request", { error: error?.message?.toString() ?? error?.toString() });
88275
88405
  if (error instanceof WalletKitError) throw error;
88276
88406
  throw error;
88277
88407
  }
@@ -88306,7 +88436,7 @@ var RequestProcessor = class {
88306
88436
  }
88307
88437
  return;
88308
88438
  } catch (error) {
88309
- log$22.error("Failed to reject sign data request", { error });
88439
+ log$23.error("Failed to reject sign data request", { error });
88310
88440
  throw error;
88311
88441
  }
88312
88442
  }
@@ -88385,7 +88515,7 @@ var RequestProcessor = class {
88385
88515
  */
88386
88516
  async function signTransactionInternal(wallet, request) {
88387
88517
  const signedBoc = await wallet.getSignedSendTransaction(request, { fakeSignature: false });
88388
- log$22.debug("Signing transaction", {
88518
+ log$23.debug("Signing transaction", {
88389
88519
  messagesNumber: request.messages.length,
88390
88520
  fromAddress: request.fromAddress,
88391
88521
  validUntil: request.validUntil
@@ -88441,7 +88571,7 @@ function parseDomain(url) {
88441
88571
  value: parsedUrl.host
88442
88572
  };
88443
88573
  } catch (error) {
88444
- log$22.error("Failed to parse domain", { error });
88574
+ log$23.error("Failed to parse domain", { error });
88445
88575
  return {
88446
88576
  lengthBytes: 0,
88447
88577
  value: ""
@@ -88481,7 +88611,7 @@ function toTonConnectSignDataPayload(payload) {
88481
88611
  const getEventUUID = () => {
88482
88612
  return crypto.randomUUID();
88483
88613
  };
88484
- const log$21 = globalLogger.createChild("EventStore");
88614
+ const log$22 = globalLogger.createChild("EventStore");
88485
88615
  const MAX_EVENT_SIZE_BYTES = 100 * 1024;
88486
88616
  /**
88487
88617
  * Concrete implementation of EventStore using Storage
@@ -88517,7 +88647,7 @@ var StorageEventStore = class {
88517
88647
  sizeBytes
88518
88648
  };
88519
88649
  await this.saveEvent(storedEvent);
88520
- log$21.info("Event stored", {
88650
+ log$22.info("Event stored", {
88521
88651
  eventId: storedEvent.id,
88522
88652
  eventType,
88523
88653
  sizeBytes,
@@ -88545,11 +88675,11 @@ var StorageEventStore = class {
88545
88675
  const allEvents = await this.getAllEventsFromStorage();
88546
88676
  const event = allEvents[eventId];
88547
88677
  if (!event) {
88548
- log$21.warn("Cannot lock non-existent event", { eventId });
88678
+ log$22.warn("Cannot lock non-existent event", { eventId });
88549
88679
  return;
88550
88680
  }
88551
88681
  if (event.status !== "new") {
88552
- log$21.debug("Cannot lock event - not in new status", {
88682
+ log$22.debug("Cannot lock event - not in new status", {
88553
88683
  eventId,
88554
88684
  status: event.status,
88555
88685
  lockedBy: event.lockedBy
@@ -88564,7 +88694,7 @@ var StorageEventStore = class {
88564
88694
  };
88565
88695
  allEvents[eventId] = updatedEvent;
88566
88696
  await this.storage.set(this.storageKey, allEvents);
88567
- log$21.debug("Event lock acquired", {
88697
+ log$22.debug("Event lock acquired", {
88568
88698
  eventId,
88569
88699
  walletAddress: walletId
88570
88700
  });
@@ -88591,7 +88721,7 @@ var StorageEventStore = class {
88591
88721
  };
88592
88722
  allEvents[eventId] = updatedEvent;
88593
88723
  await this.storage.set(this.storageKey, allEvents);
88594
- log$21.debug("Event retry count incremented", {
88724
+ log$22.debug("Event retry count incremented", {
88595
88725
  eventId,
88596
88726
  retryCount: updatedEvent.retryCount,
88597
88727
  error
@@ -88615,7 +88745,7 @@ var StorageEventStore = class {
88615
88745
  if (status === "completed") updatedEvent.completedAt = Date.now();
88616
88746
  allEvents[eventId] = updatedEvent;
88617
88747
  await this.storage.set(this.storageKey, allEvents);
88618
- log$21.debug("Event status updated", {
88748
+ log$22.debug("Event status updated", {
88619
88749
  eventId,
88620
88750
  oldStatus,
88621
88751
  newStatus: status
@@ -88630,7 +88760,7 @@ var StorageEventStore = class {
88630
88760
  try {
88631
88761
  return (await this.getAllEventsFromStorage())[eventId] || null;
88632
88762
  } catch (error) {
88633
- log$21.warn("Failed to get event", {
88763
+ log$22.warn("Failed to get event", {
88634
88764
  eventId,
88635
88765
  error
88636
88766
  });
@@ -88652,14 +88782,14 @@ var StorageEventStore = class {
88652
88782
  };
88653
88783
  await this.saveEvent(recoveredEvent);
88654
88784
  recoveredCount++;
88655
- log$21.info("Recovered stale event", {
88785
+ log$22.info("Recovered stale event", {
88656
88786
  eventId: event.id,
88657
88787
  lockedBy: event.lockedBy,
88658
88788
  staleMinutes: Math.round((now - event.processingStartedAt) / 6e4),
88659
88789
  retryCount: event.retryCount || 0
88660
88790
  });
88661
88791
  }
88662
- if (recoveredCount > 0) log$21.info("Event recovery completed", { recoveredCount });
88792
+ if (recoveredCount > 0) log$22.info("Event recovery completed", { recoveredCount });
88663
88793
  return recoveredCount;
88664
88794
  }
88665
88795
  /**
@@ -88672,7 +88802,7 @@ var StorageEventStore = class {
88672
88802
  const eventsToRemove = [];
88673
88803
  for (const event of events) if (event.status === "completed" && event.completedAt && event.completedAt < cutoffTime || event.status === "errored" && event.createdAt < cutoffTime) {
88674
88804
  eventsToRemove.push(event.id);
88675
- log$21.debug("Marked event for cleanup", {
88805
+ log$22.debug("Marked event for cleanup", {
88676
88806
  eventId: event.id,
88677
88807
  status: event.status
88678
88808
  });
@@ -88686,7 +88816,7 @@ var StorageEventStore = class {
88686
88816
  }
88687
88817
  await this.storage.set(this.storageKey, allEvents);
88688
88818
  });
88689
- log$21.info("Event cleanup completed", { cleanedUpCount });
88819
+ log$22.info("Event cleanup completed", { cleanedUpCount });
88690
88820
  }
88691
88821
  return cleanedUpCount;
88692
88822
  }
@@ -88698,7 +88828,7 @@ var StorageEventStore = class {
88698
88828
  const allEvents = await this.getAllEventsFromStorage();
88699
88829
  return Object.values(allEvents);
88700
88830
  } catch (error) {
88701
- log$21.warn("Failed to get all events", { error });
88831
+ log$22.warn("Failed to get all events", { error });
88702
88832
  return [];
88703
88833
  }
88704
88834
  }
@@ -88720,7 +88850,7 @@ var StorageEventStore = class {
88720
88850
  try {
88721
88851
  return await this.storage.get(this.storageKey) || {};
88722
88852
  } catch (error) {
88723
- log$21.warn("Failed to get events from storage", { error });
88853
+ log$22.warn("Failed to get events from storage", { error });
88724
88854
  return {};
88725
88855
  }
88726
88856
  }
@@ -88759,7 +88889,7 @@ var StorageEventStore = class {
88759
88889
  * LICENSE file in the root directory of this source tree.
88760
88890
  *
88761
88891
  */
88762
- const log$20 = globalLogger.createChild("EventProcessor");
88892
+ const log$21 = globalLogger.createChild("EventProcessor");
88763
88893
  /**
88764
88894
  * Processes durable events for wallets based on their active sessions and enabled event types
88765
88895
  */
@@ -88794,14 +88924,14 @@ var StorageEventProcessor = class {
88794
88924
  */
88795
88925
  async startProcessing(walletId) {
88796
88926
  if (this.processorConfig.disableEvents) return;
88797
- if (walletId) if (this.registeredWallets.has(walletId)) log$20.debug("Processing already registered for wallet", { walletId });
88927
+ if (walletId) if (this.registeredWallets.has(walletId)) log$21.debug("Processing already registered for wallet", { walletId });
88798
88928
  else {
88799
88929
  this.registeredWallets.add(walletId);
88800
- log$20.info("Registered wallet for event processing", { walletId });
88930
+ log$21.info("Registered wallet for event processing", { walletId });
88801
88931
  }
88802
88932
  if (!this.isProcessing) {
88803
88933
  this.isProcessing = true;
88804
- log$20.info("Started global event processing loop");
88934
+ log$21.info("Started global event processing loop");
88805
88935
  this.processEventsLoop();
88806
88936
  } else this.triggerProcessing();
88807
88937
  }
@@ -88812,7 +88942,7 @@ var StorageEventProcessor = class {
88812
88942
  if (this.processorConfig.disableEvents) return;
88813
88943
  if (walletId) {
88814
88944
  this.registeredWallets.delete(walletId);
88815
- log$20.info("Unregistered wallet from event processing", { walletId });
88945
+ log$21.info("Unregistered wallet from event processing", { walletId });
88816
88946
  }
88817
88947
  if (this.registeredWallets.size === 0 && this.isProcessing && !walletId) {
88818
88948
  this.isProcessing = false;
@@ -88820,12 +88950,12 @@ var StorageEventProcessor = class {
88820
88950
  this.wakeUpResolver();
88821
88951
  this.wakeUpResolver = void 0;
88822
88952
  }
88823
- log$20.info("Stopped global event processing loop (no more wallets)");
88953
+ log$21.info("Stopped global event processing loop (no more wallets)");
88824
88954
  }
88825
88955
  }
88826
88956
  async clearRegisteredWallets() {
88827
88957
  this.registeredWallets.clear();
88828
- log$20.info("Cleared registered wallets from event processing");
88958
+ log$21.info("Cleared registered wallets from event processing");
88829
88959
  }
88830
88960
  /**
88831
88961
  * Process next available event from any source (wallet or no-wallet)
@@ -88855,7 +88985,7 @@ var StorageEventProcessor = class {
88855
88985
  const walletId = allSessions.find((s) => s.sessionId === eventToUse.sessionId)?.walletId || "no-wallet";
88856
88986
  return await this.processEvent(eventToUse, walletId);
88857
88987
  } catch (error) {
88858
- log$20.error("Error in processNextAvailableEvent", { error: error.message });
88988
+ log$21.error("Error in processNextAvailableEvent", { error: error.message });
88859
88989
  return false;
88860
88990
  }
88861
88991
  }
@@ -88865,9 +88995,9 @@ var StorageEventProcessor = class {
88865
88995
  async completeEvent(eventId) {
88866
88996
  try {
88867
88997
  await this.eventStore.updateEventStatus(eventId, "completed", "processing");
88868
- log$20.debug("Event marked as completed", { eventId });
88998
+ log$21.debug("Event marked as completed", { eventId });
88869
88999
  } catch (error) {
88870
- log$20.error("Failed to mark event as completed", {
89000
+ log$21.error("Failed to mark event as completed", {
88871
89001
  eventId,
88872
89002
  error: error.message
88873
89003
  });
@@ -88878,14 +89008,14 @@ var StorageEventProcessor = class {
88878
89008
  */
88879
89009
  startRecoveryLoop() {
88880
89010
  if (this.recoveryTimeoutId) {
88881
- log$20.debug("Recovery loop already running");
89011
+ log$21.debug("Recovery loop already running");
88882
89012
  return;
88883
89013
  }
88884
89014
  const recoveryLoop = async () => {
88885
89015
  try {
88886
89016
  if (await this.eventStore.recoverStaleEvents(this.config.processingTimeoutMs) > 0) this.triggerProcessing();
88887
89017
  } catch (error) {
88888
- log$20.error("Error in recovery loop", { error: error.message });
89018
+ log$21.error("Error in recovery loop", { error: error.message });
88889
89019
  }
88890
89020
  if (this.recoveryTimeoutId !== void 0) this.recoveryTimeoutId = setTimeout(recoveryLoop, this.config.recoveryIntervalMs);
88891
89021
  };
@@ -88893,13 +89023,13 @@ var StorageEventProcessor = class {
88893
89023
  try {
88894
89024
  await this.eventStore.cleanupOldEvents(this.config.retentionMs);
88895
89025
  } catch (error) {
88896
- log$20.error("Error in cleanup loop", { error: error.message });
89026
+ log$21.error("Error in cleanup loop", { error: error.message });
88897
89027
  }
88898
89028
  if (this.cleanupTimeoutId !== void 0) this.cleanupTimeoutId = setTimeout(cleanupLoop, this.config.cleanupIntervalMs);
88899
89029
  };
88900
89030
  this.recoveryTimeoutId = setTimeout(recoveryLoop, this.config.recoveryIntervalMs);
88901
89031
  this.cleanupTimeoutId = setTimeout(cleanupLoop, this.config.cleanupIntervalMs);
88902
- log$20.info("Recovery and cleanup loops started");
89032
+ log$21.info("Recovery and cleanup loops started");
88903
89033
  }
88904
89034
  /**
88905
89035
  * Stop the recovery process
@@ -88913,7 +89043,7 @@ var StorageEventProcessor = class {
88913
89043
  clearTimeout(this.cleanupTimeoutId);
88914
89044
  this.cleanupTimeoutId = void 0;
88915
89045
  }
88916
- log$20.info("Recovery and cleanup loops stopped");
89046
+ log$21.info("Recovery and cleanup loops stopped");
88917
89047
  }
88918
89048
  /**
88919
89049
  * Process a single event with retry logic
@@ -88921,7 +89051,7 @@ var StorageEventProcessor = class {
88921
89051
  */
88922
89052
  async processEvent(event, walletId) {
88923
89053
  if (!await this.eventStore.acquireLock(event.id, walletId)) {
88924
- log$20.debug("Failed to acquire lock on event", {
89054
+ log$21.debug("Failed to acquire lock on event", {
88925
89055
  eventId: event.id,
88926
89056
  walletId
88927
89057
  });
@@ -88929,7 +89059,7 @@ var StorageEventProcessor = class {
88929
89059
  }
88930
89060
  const retryCount = event.retryCount || 0;
88931
89061
  if (retryCount >= this.config.maxRetries) {
88932
- log$20.error("Event exceeded max retries, marking as errored", {
89062
+ log$21.error("Event exceeded max retries, marking as errored", {
88933
89063
  eventId: event.id,
88934
89064
  retryCount,
88935
89065
  maxRetries: this.config.maxRetries
@@ -88937,14 +89067,14 @@ var StorageEventProcessor = class {
88937
89067
  try {
88938
89068
  await this.eventStore.updateEventStatus(event.id, "errored", "processing");
88939
89069
  } catch (error) {
88940
- log$20.error("Failed to mark event as errored", {
89070
+ log$21.error("Failed to mark event as errored", {
88941
89071
  eventId: event.id,
88942
89072
  error: error.message
88943
89073
  });
88944
89074
  }
88945
89075
  return false;
88946
89076
  }
88947
- log$20.info("Processing event", {
89077
+ log$21.info("Processing event", {
88948
89078
  eventId: event.id,
88949
89079
  eventType: event.eventType,
88950
89080
  walletId,
@@ -88964,11 +89094,11 @@ var StorageEventProcessor = class {
88964
89094
  ...walletAddress ? { walletAddress } : {}
88965
89095
  });
88966
89096
  await this.eventStore.updateEventStatus(event.id, "completed", "processing");
88967
- log$20.info("Event processing completed", { eventId: event.id });
89097
+ log$21.info("Event processing completed", { eventId: event.id });
88968
89098
  return true;
88969
89099
  } catch (error) {
88970
89100
  const errorMessage = error.message ?? "Unknown error";
88971
- log$20.error("Error processing event", {
89101
+ log$21.error("Error processing event", {
88972
89102
  eventId: event.id,
88973
89103
  error: errorMessage,
88974
89104
  retryCount
@@ -88976,7 +89106,7 @@ var StorageEventProcessor = class {
88976
89106
  try {
88977
89107
  await this.eventStore.releaseLock(event.id, errorMessage);
88978
89108
  } catch (updateError) {
88979
- log$20.error("Failed to increment retry count", {
89109
+ log$21.error("Failed to increment retry count", {
88980
89110
  eventId: event.id,
88981
89111
  error: updateError.message
88982
89112
  });
@@ -88991,18 +89121,18 @@ var StorageEventProcessor = class {
88991
89121
  while (this.isProcessing) try {
88992
89122
  if (!await this.processNextAvailableEvent()) await this.waitForWakeUpOrTimeout(500);
88993
89123
  } catch (error) {
88994
- log$20.error("Error in global processing loop", { error: error.message });
89124
+ log$21.error("Error in global processing loop", { error: error.message });
88995
89125
  await this.waitForWakeUpOrTimeout(500);
88996
89126
  }
88997
89127
  this.wakeUpResolver = void 0;
88998
- log$20.debug("Global processing loop ended");
89128
+ log$21.debug("Global processing loop ended");
88999
89129
  }
89000
89130
  /**
89001
89131
  * Trigger the global processing loop
89002
89132
  */
89003
89133
  triggerProcessing() {
89004
89134
  if (this.isProcessing && this.wakeUpResolver) {
89005
- log$20.debug("Waking up global processing loop");
89135
+ log$21.debug("Waking up global processing loop");
89006
89136
  this.wakeUpResolver();
89007
89137
  }
89008
89138
  }
@@ -89045,7 +89175,7 @@ var StorageEventProcessor = class {
89045
89175
  * LICENSE file in the root directory of this source tree.
89046
89176
  *
89047
89177
  */
89048
- const log$19 = globalLogger.createChild("WalletTonClass");
89178
+ const log$20 = globalLogger.createChild("WalletTonClass");
89049
89179
  var WalletTonClass = class {
89050
89180
  async createTransferTonTransaction(param) {
89051
89181
  if (!isValidAddress(param.recipientAddress)) throw new Error(`Invalid to address: ${param.recipientAddress}`);
@@ -89106,7 +89236,7 @@ var WalletTonClass = class {
89106
89236
  normalizedHash
89107
89237
  };
89108
89238
  } catch (error) {
89109
- log$19.error("Failed to send transaction", { error });
89239
+ log$20.error("Failed to send transaction", { error });
89110
89240
  if (error instanceof WalletKitError) throw error;
89111
89241
  if (error?.message?.includes("Ledger device")) throw new WalletKitError(ERROR_CODES.LEDGER_DEVICE_ERROR, "Ledger device error", error);
89112
89242
  throw error;
@@ -89136,7 +89266,7 @@ var WalletJettonClass = class {
89136
89266
  payload: createJettonTransferPayload({
89137
89267
  amount: BigInt(params.transferAmount),
89138
89268
  destination: params.recipientAddress,
89139
- responseDestination: this.getAddress(),
89269
+ responseDestination: params.responseDestination || this.getAddress(),
89140
89270
  comment: params.comment
89141
89271
  }),
89142
89272
  fromAddress: this.getAddress()
@@ -89208,7 +89338,7 @@ var WalletNftClass = class {
89208
89338
  * LICENSE file in the root directory of this source tree.
89209
89339
  *
89210
89340
  */
89211
- const log$18 = globalLogger.createChild("Initializer");
89341
+ const log$19 = globalLogger.createChild("Initializer");
89212
89342
  /**
89213
89343
  * Handles initialization of all TonWalletKit components
89214
89344
  */
@@ -89227,12 +89357,12 @@ var Initializer = class {
89227
89357
  */
89228
89358
  async initialize(options, networkManager) {
89229
89359
  try {
89230
- log$18.info("Initializing TonWalletKit...");
89360
+ log$19.info("Initializing TonWalletKit...");
89231
89361
  this.networkManager = networkManager;
89232
89362
  const storage = this.initializeStorage(options);
89233
89363
  const { walletManager, sessionManager, bridgeManager, eventRouter, eventProcessor } = await this.initializeManagers(options, storage);
89234
89364
  const { requestProcessor } = this.initializeProcessors(sessionManager, bridgeManager, walletManager);
89235
- log$18.info("TonWalletKit initialized successfully");
89365
+ log$19.info("TonWalletKit initialized successfully");
89236
89366
  return {
89237
89367
  walletManager,
89238
89368
  sessionManager,
@@ -89243,7 +89373,7 @@ var Initializer = class {
89243
89373
  eventProcessor
89244
89374
  };
89245
89375
  } catch (error) {
89246
- log$18.error("Failed to initialize TonWalletKit", { error });
89376
+ log$19.error("Failed to initialize TonWalletKit", { error });
89247
89377
  throw error;
89248
89378
  }
89249
89379
  }
@@ -89279,9 +89409,9 @@ var Initializer = class {
89279
89409
  const bridgeManager = new BridgeManager(options?.walletManifest, options?.bridge, sessionManager, storage, eventStore, eventRouter, options, this.eventEmitter, this.analyticsManager);
89280
89410
  eventRouter.setBridgeManager(bridgeManager);
89281
89411
  bridgeManager.start().then(() => {
89282
- log$18.info("Bridge manager started successfully");
89412
+ log$19.info("Bridge manager started successfully");
89283
89413
  }).catch((e) => {
89284
- log$18.error("Could not start bridge manager", { error: e?.toString?.() });
89414
+ log$19.error("Could not start bridge manager", { error: e?.toString?.() });
89285
89415
  });
89286
89416
  const eventProcessor = new StorageEventProcessor(options?.eventProcessor, eventStore, DEFAULT_DURABLE_EVENTS_CONFIG, walletManager, sessionManager, eventRouter, this.eventEmitter);
89287
89417
  return {
@@ -89303,7 +89433,7 @@ var Initializer = class {
89303
89433
  */
89304
89434
  async cleanup(components) {
89305
89435
  try {
89306
- log$18.info("Cleaning up TonWalletKit components...");
89436
+ log$19.info("Cleaning up TonWalletKit components...");
89307
89437
  if (components.eventProcessor) {
89308
89438
  components.eventProcessor.stopRecoveryLoop();
89309
89439
  await components.eventProcessor.clearRegisteredWallets();
@@ -89311,9 +89441,9 @@ var Initializer = class {
89311
89441
  }
89312
89442
  if (components.bridgeManager) await components.bridgeManager.close();
89313
89443
  if (components.eventRouter) components.eventRouter.clearCallbacks();
89314
- log$18.info("TonWalletKit cleanup completed");
89444
+ log$19.info("TonWalletKit cleanup completed");
89315
89445
  } catch (error) {
89316
- log$18.error("Error during cleanup", { error });
89446
+ log$19.error("Error during cleanup", { error });
89317
89447
  }
89318
89448
  }
89319
89449
  };
@@ -89348,7 +89478,7 @@ async function wrapWalletInterface(wallet) {
89348
89478
  * LICENSE file in the root directory of this source tree.
89349
89479
  *
89350
89480
  */
89351
- const log$17 = globalLogger.createChild("JettonsManager");
89481
+ const log$18 = globalLogger.createChild("JettonsManager");
89352
89482
  const TON_ADDRESS = "TON";
89353
89483
  function isTonAddress(address) {
89354
89484
  return address.toLowerCase() === "ton";
@@ -89388,7 +89518,7 @@ var JettonsManager = class {
89388
89518
  ttl: 1e3 * 60 * 10
89389
89519
  });
89390
89520
  for (const network of this.networkManager.getConfiguredNetworks()) this.addTonToCache(network);
89391
- log$17.info("JettonsManager initialized", { cacheSize });
89521
+ log$18.info("JettonsManager initialized", { cacheSize });
89392
89522
  }
89393
89523
  /**
89394
89524
  * Add TON native token to cache for a specific network
@@ -89409,19 +89539,19 @@ var JettonsManager = class {
89409
89539
  const cacheKey = this.normalizedCacheKey(targetNetwork, jettonAddress);
89410
89540
  const cachedInfo = this.cache.get(cacheKey);
89411
89541
  if (cachedInfo) {
89412
- log$17.debug("Jetton info found in cache", {
89542
+ log$18.debug("Jetton info found in cache", {
89413
89543
  jettonAddress,
89414
89544
  network: targetNetwork
89415
89545
  });
89416
89546
  return cachedInfo;
89417
89547
  }
89418
- log$17.debug("Jetton info not found in cache", {
89548
+ log$18.debug("Jetton info not found in cache", {
89419
89549
  jettonAddress,
89420
89550
  network: targetNetwork
89421
89551
  });
89422
89552
  const address = asMaybeAddressFriendly(jettonAddress);
89423
89553
  if (!address) {
89424
- log$17.error("Invalid jetton address format", {
89554
+ log$18.error("Invalid jetton address format", {
89425
89555
  jettonAddress,
89426
89556
  network: targetNetwork
89427
89557
  });
@@ -89456,7 +89586,7 @@ var JettonsManager = class {
89456
89586
  }
89457
89587
  return null;
89458
89588
  } catch (error) {
89459
- log$17.error("Error getting jetton info", {
89589
+ log$18.error("Error getting jetton info", {
89460
89590
  error,
89461
89591
  jettonAddress,
89462
89592
  network: targetNetwork
@@ -89475,7 +89605,7 @@ var JettonsManager = class {
89475
89605
  const targetNetwork = network;
89476
89606
  try {
89477
89607
  const apiClient = this.networkManager.getClient(targetNetwork);
89478
- log$17.debug("Getting address jettons", {
89608
+ log$18.debug("Getting address jettons", {
89479
89609
  userAddress,
89480
89610
  network: targetNetwork,
89481
89611
  offset,
@@ -89489,13 +89619,13 @@ var JettonsManager = class {
89489
89619
  if (!response.jettons) return [];
89490
89620
  const addressJettons = [];
89491
89621
  for (const item of response.jettons) addressJettons.push(item);
89492
- log$17.debug("Retrieved address jettons", {
89622
+ log$18.debug("Retrieved address jettons", {
89493
89623
  count: addressJettons.length,
89494
89624
  network: targetNetwork
89495
89625
  });
89496
89626
  return addressJettons;
89497
89627
  } catch (error) {
89498
- log$17.error("Failed to get address jettons", {
89628
+ log$18.error("Failed to get address jettons", {
89499
89629
  error,
89500
89630
  userAddress,
89501
89631
  network: targetNetwork
@@ -89519,14 +89649,14 @@ var JettonsManager = class {
89519
89649
  uri: emulationInfo.extra.uri
89520
89650
  };
89521
89651
  this.cache.set(cacheKey, jettonInfo);
89522
- log$17.debug("Added jetton info from emulation to cache", {
89652
+ log$18.debug("Added jetton info from emulation to cache", {
89523
89653
  jettonAddress,
89524
89654
  network,
89525
89655
  name: jettonInfo.name,
89526
89656
  symbol: jettonInfo.symbol
89527
89657
  });
89528
89658
  } catch (error) {
89529
- log$17.error("Error adding jetton from emulation", {
89659
+ log$18.error("Error adding jetton from emulation", {
89530
89660
  error,
89531
89661
  jettonAddress,
89532
89662
  network
@@ -89543,7 +89673,7 @@ var JettonsManager = class {
89543
89673
  if (!addressMetadata.is_indexed || !addressMetadata.token_info) continue;
89544
89674
  const jettonMasterInfo = addressMetadata.token_info.find((info) => typeof info === "object" && info !== null && "type" in info && info.type === "jetton_masters");
89545
89675
  if (jettonMasterInfo) {
89546
- log$17.debug("Adding jetton from emulation metadata", {
89676
+ log$18.debug("Adding jetton from emulation metadata", {
89547
89677
  jettonAddress,
89548
89678
  network
89549
89679
  });
@@ -89551,12 +89681,12 @@ var JettonsManager = class {
89551
89681
  addedCount++;
89552
89682
  }
89553
89683
  }
89554
- if (addedCount > 0) log$17.info("Added jettons from emulation metadata", {
89684
+ if (addedCount > 0) log$18.info("Added jettons from emulation metadata", {
89555
89685
  addedCount,
89556
89686
  network
89557
89687
  });
89558
89688
  } catch (error) {
89559
- log$17.error("Error adding jettons from emulation metadata", {
89689
+ log$18.error("Error adding jettons from emulation metadata", {
89560
89690
  error,
89561
89691
  network
89562
89692
  });
@@ -89597,11 +89727,11 @@ var JettonsManager = class {
89597
89727
  if (network) {
89598
89728
  for (const key of this.cache.keys()) if (key.startsWith(`${network.chainId}:`)) this.cache.delete(key);
89599
89729
  this.addTonToCache(network);
89600
- log$17.info("Jetton cache cleared for network", { network });
89730
+ log$18.info("Jetton cache cleared for network", { network });
89601
89731
  } else {
89602
89732
  this.cache.clear();
89603
89733
  for (const net of this.networkManager.getConfiguredNetworks()) this.addTonToCache(net);
89604
- log$17.info("Jetton cache cleared for all networks");
89734
+ log$18.info("Jetton cache cleared for all networks");
89605
89735
  }
89606
89736
  }
89607
89737
  };
@@ -89801,7 +89931,7 @@ var DefiManager = class {
89801
89931
  * LICENSE file in the root directory of this source tree.
89802
89932
  *
89803
89933
  */
89804
- const log$16 = globalLogger.createChild("SwapManager");
89934
+ const log$17 = globalLogger.createChild("SwapManager");
89805
89935
  /**
89806
89936
  * SwapManager - manages swap providers and delegates swap operations
89807
89937
  *
@@ -89819,7 +89949,7 @@ var SwapManager = class extends DefiManager {
89819
89949
  * @returns Promise resolving to swap quote
89820
89950
  */
89821
89951
  async getQuote(params, providerId) {
89822
- log$16.debug("Getting swap quote", {
89952
+ log$17.debug("Getting swap quote", {
89823
89953
  fromToken: params.from,
89824
89954
  toToken: params.to,
89825
89955
  amount: params.amount,
@@ -89828,14 +89958,14 @@ var SwapManager = class extends DefiManager {
89828
89958
  });
89829
89959
  try {
89830
89960
  const quote = await this.getProvider(providerId || this.defaultProviderId).getQuote(params);
89831
- log$16.debug("Received swap quote", {
89961
+ log$17.debug("Received swap quote", {
89832
89962
  fromAmount: quote.fromAmount,
89833
89963
  toAmount: quote.toAmount,
89834
89964
  priceImpact: quote.priceImpact
89835
89965
  });
89836
89966
  return quote;
89837
89967
  } catch (error) {
89838
- log$16.error("Failed to get swap quote", {
89968
+ log$17.error("Failed to get swap quote", {
89839
89969
  error,
89840
89970
  params
89841
89971
  });
@@ -89849,16 +89979,16 @@ var SwapManager = class extends DefiManager {
89849
89979
  */
89850
89980
  async buildSwapTransaction(params) {
89851
89981
  const providerId = params.quote.providerId || this.defaultProviderId;
89852
- log$16.debug("Building swap transaction", {
89982
+ log$17.debug("Building swap transaction", {
89853
89983
  providerId,
89854
89984
  userAddress: params.userAddress
89855
89985
  });
89856
89986
  try {
89857
89987
  const transaction = await this.getProvider(providerId).buildSwapTransaction(params);
89858
- log$16.debug("Built swap transaction", params.quote);
89988
+ log$17.debug("Built swap transaction", params.quote);
89859
89989
  return transaction;
89860
89990
  } catch (error) {
89861
- log$16.error("Failed to build swap transaction", {
89991
+ log$17.error("Failed to build swap transaction", {
89862
89992
  error,
89863
89993
  params
89864
89994
  });
@@ -89900,7 +90030,7 @@ var StakingError = class extends DefiError {
89900
90030
  * LICENSE file in the root directory of this source tree.
89901
90031
  *
89902
90032
  */
89903
- const log$15 = globalLogger.createChild("StakingManager");
90033
+ const log$16 = globalLogger.createChild("StakingManager");
89904
90034
  /**
89905
90035
  * StakingManager - manages staking providers and delegates staking operations
89906
90036
  *
@@ -89917,13 +90047,13 @@ var StakingManager = class extends DefiManager {
89917
90047
  * @param providerId - Optional provider id to use
89918
90048
  */
89919
90049
  async getQuote(params, providerId) {
89920
- log$15.debug("Getting staking quote", params);
90050
+ log$16.debug("Getting staking quote", params);
89921
90051
  try {
89922
90052
  const quote = await this.getProvider(providerId).getQuote(params);
89923
- log$15.debug("Received staking quote", quote);
90053
+ log$16.debug("Received staking quote", quote);
89924
90054
  return quote;
89925
90055
  } catch (error) {
89926
- log$15.error("Failed to get staking quote", {
90056
+ log$16.error("Failed to get staking quote", {
89927
90057
  error,
89928
90058
  params
89929
90059
  });
@@ -89936,11 +90066,11 @@ var StakingManager = class extends DefiManager {
89936
90066
  * @param providerId - Optional provider id to use
89937
90067
  */
89938
90068
  async buildStakeTransaction(params, providerId) {
89939
- log$15.debug("Building staking transaction", params);
90069
+ log$16.debug("Building staking transaction", params);
89940
90070
  try {
89941
90071
  return await this.getProvider(providerId).buildStakeTransaction(params);
89942
90072
  } catch (error) {
89943
- log$15.error("Failed to build staking transaction", {
90073
+ log$16.error("Failed to build staking transaction", {
89944
90074
  error,
89945
90075
  params
89946
90076
  });
@@ -89954,7 +90084,7 @@ var StakingManager = class extends DefiManager {
89954
90084
  * @param providerId - Optional provider id to use
89955
90085
  */
89956
90086
  async getStakedBalance(userAddress, network, providerId) {
89957
- log$15.debug("Getting staking balance", {
90087
+ log$16.debug("Getting staking balance", {
89958
90088
  userAddress,
89959
90089
  network,
89960
90090
  provider: providerId || this.defaultProviderId
@@ -89962,7 +90092,7 @@ var StakingManager = class extends DefiManager {
89962
90092
  try {
89963
90093
  return await this.getProvider(providerId).getStakedBalance(userAddress, network);
89964
90094
  } catch (error) {
89965
- log$15.error("Failed to get staking balance", {
90095
+ log$16.error("Failed to get staking balance", {
89966
90096
  error,
89967
90097
  userAddress,
89968
90098
  network
@@ -89976,14 +90106,14 @@ var StakingManager = class extends DefiManager {
89976
90106
  * @param providerId - Optional provider id to use
89977
90107
  */
89978
90108
  async getStakingProviderInfo(network, providerId) {
89979
- log$15.debug("Getting staking info", {
90109
+ log$16.debug("Getting staking info", {
89980
90110
  network,
89981
90111
  provider: providerId || this.defaultProviderId
89982
90112
  });
89983
90113
  try {
89984
90114
  return await this.getProvider(providerId).getStakingProviderInfo(network);
89985
90115
  } catch (error) {
89986
- log$15.error("Failed to get staking info", {
90116
+ log$16.error("Failed to get staking info", {
89987
90117
  error,
89988
90118
  network
89989
90119
  });
@@ -89996,14 +90126,14 @@ var StakingManager = class extends DefiManager {
89996
90126
  * @param providerId - Optional provider id to use
89997
90127
  */
89998
90128
  getStakingProviderMetadata(network, providerId) {
89999
- log$15.debug("Getting staking metadata", {
90129
+ log$16.debug("Getting staking metadata", {
90000
90130
  network,
90001
90131
  provider: providerId || this.defaultProviderId
90002
90132
  });
90003
90133
  try {
90004
90134
  return this.getProvider(providerId).getStakingProviderMetadata(network);
90005
90135
  } catch (error) {
90006
- log$15.error("Failed to get staking metadata", {
90136
+ log$16.error("Failed to get staking metadata", {
90007
90137
  error,
90008
90138
  network
90009
90139
  });
@@ -90012,7 +90142,7 @@ var StakingManager = class extends DefiManager {
90012
90142
  }
90013
90143
  createError(message, code, details) {
90014
90144
  const errorCode = Object.values(StakingErrorCode).includes(code) ? code : StakingErrorCode.InvalidParams;
90015
- log$15.error(message, {
90145
+ log$16.error(message, {
90016
90146
  code,
90017
90147
  details
90018
90148
  });
@@ -90020,6 +90150,128 @@ var StakingManager = class extends DefiManager {
90020
90150
  }
90021
90151
  };
90022
90152
  //#endregion
90153
+ //#region ../walletkit/dist/esm/defi/gasless/errors.js
90154
+ /**
90155
+ * Copyright (c) TonTech.
90156
+ *
90157
+ * This source code is licensed under the MIT license found in the
90158
+ * LICENSE file in the root directory of this source tree.
90159
+ *
90160
+ */
90161
+ var GaslessErrorCode;
90162
+ (function(GaslessErrorCode) {
90163
+ GaslessErrorCode["UnsupportedFeeAsset"] = "UNSUPPORTED_FEE_ASSET";
90164
+ GaslessErrorCode["UnsupportedOperation"] = "UNSUPPORTED_OPERATION";
90165
+ GaslessErrorCode["QuoteFailed"] = "QUOTE_FAILED";
90166
+ GaslessErrorCode["SendFailed"] = "SEND_FAILED";
90167
+ GaslessErrorCode["ConfigFailed"] = "CONFIG_FAILED";
90168
+ GaslessErrorCode["SignMessageNotSupported"] = "SIGN_MESSAGE_NOT_SUPPORTED";
90169
+ GaslessErrorCode["TooManyMessages"] = "TOO_MANY_MESSAGES";
90170
+ GaslessErrorCode["QuoteExpired"] = "QUOTE_EXPIRED";
90171
+ GaslessErrorCode["WalletMismatch"] = "WALLET_MISMATCH";
90172
+ GaslessErrorCode["FeeAssetNotOwned"] = "FEE_ASSET_NOT_OWNED";
90173
+ })(GaslessErrorCode || (GaslessErrorCode = {}));
90174
+ var GaslessError = class extends DefiError {
90175
+ code;
90176
+ constructor(message, code, details) {
90177
+ super(message, code, details);
90178
+ this.name = "GaslessError";
90179
+ this.code = code;
90180
+ }
90181
+ };
90182
+ //#endregion
90183
+ //#region ../walletkit/dist/esm/defi/gasless/GaslessManager.js
90184
+ /**
90185
+ * Copyright (c) TonTech.
90186
+ *
90187
+ * This source code is licensed under the MIT license found in the
90188
+ * LICENSE file in the root directory of this source tree.
90189
+ *
90190
+ */
90191
+ const log$15 = globalLogger.createChild("GaslessManager");
90192
+ /**
90193
+ * GaslessManager — manages gasless relay providers and delegates gasless operations.
90194
+ *
90195
+ * Allows registration of multiple gasless providers and provides a unified API.
90196
+ * Providers can be switched dynamically.
90197
+ */
90198
+ var GaslessManager = class extends DefiManager {
90199
+ constructor(createFactoryContext) {
90200
+ super(createFactoryContext);
90201
+ }
90202
+ /**
90203
+ * Get static metadata for a gasless provider (display name, logo, url).
90204
+ */
90205
+ async getMetadata(providerId) {
90206
+ const selectedProviderId = providerId ?? this.defaultProviderId;
90207
+ log$15.debug("Getting gasless provider metadata", { providerId: selectedProviderId });
90208
+ try {
90209
+ return await this.getProvider(selectedProviderId).getMetadata();
90210
+ } catch (error) {
90211
+ log$15.error("Failed to get gasless provider metadata", { error });
90212
+ throw error;
90213
+ }
90214
+ }
90215
+ /**
90216
+ * Fetch the relayer's configuration (relay address + accepted fee assets).
90217
+ *
90218
+ * `network` defaults to the provider's first supported network.
90219
+ */
90220
+ async getConfig(network, providerId) {
90221
+ const provider = this.getProvider(providerId ?? this.defaultProviderId);
90222
+ const targetNetwork = network ?? provider.getSupportedNetworks()[0];
90223
+ log$15.debug("Getting gasless config", {
90224
+ network: targetNetwork?.chainId,
90225
+ providerId: providerId ?? this.defaultProviderId
90226
+ });
90227
+ try {
90228
+ return await provider.getConfig(targetNetwork);
90229
+ } catch (error) {
90230
+ log$15.error("Failed to get gasless config", { error });
90231
+ throw error;
90232
+ }
90233
+ }
90234
+ /**
90235
+ * Quote fees and obtain relayer-wrapped messages for signing.
90236
+ */
90237
+ async getQuote(params, providerId) {
90238
+ log$15.debug("Quoting gasless transaction", {
90239
+ network: params.network.chainId,
90240
+ walletAddress: params.walletAddress,
90241
+ feeAsset: params.feeAsset,
90242
+ messagesCount: params.messages.length,
90243
+ providerId: providerId ?? this.defaultProviderId
90244
+ });
90245
+ try {
90246
+ return await this.getProvider(providerId ?? this.defaultProviderId).getQuote(params);
90247
+ } catch (error) {
90248
+ log$15.error("Failed to quote gasless transaction", {
90249
+ error,
90250
+ params
90251
+ });
90252
+ throw error;
90253
+ }
90254
+ }
90255
+ /**
90256
+ * Submit a signed transaction BoC to the relayer.
90257
+ */
90258
+ async sendTransaction(params, providerId) {
90259
+ log$15.debug("Sending gasless transaction", {
90260
+ network: params.network.chainId,
90261
+ providerId: providerId ?? this.defaultProviderId
90262
+ });
90263
+ try {
90264
+ return await this.getProvider(providerId ?? this.defaultProviderId).sendTransaction(params);
90265
+ } catch (error) {
90266
+ log$15.error("Failed to send gasless transaction", { error });
90267
+ throw error;
90268
+ }
90269
+ }
90270
+ createError(message, code, details) {
90271
+ return new GaslessError(message, code, details);
90272
+ }
90273
+ };
90274
+ //#endregion
90023
90275
  //#region ../walletkit/dist/esm/core/EventEmitter.js
90024
90276
  /**
90025
90277
  * Copyright (c) TonTech.
@@ -91811,6 +92063,7 @@ var TonWalletKit = class {
91811
92063
  swapManager;
91812
92064
  streamingManager;
91813
92065
  stakingManager;
92066
+ gaslessManager;
91814
92067
  initializer;
91815
92068
  eventProcessor;
91816
92069
  bridgeManager;
@@ -91837,6 +92090,7 @@ var TonWalletKit = class {
91837
92090
  this.jettonsManager = new JettonsManager(1e4, this.eventEmitter, this.networkManager);
91838
92091
  this.swapManager = new SwapManager(() => this.createFactoryContext());
91839
92092
  this.stakingManager = new StakingManager(() => this.createFactoryContext());
92093
+ this.gaslessManager = new GaslessManager(() => this.createFactoryContext());
91840
92094
  this.eventEmitter.on("restoreConnection", async ({ payload: event }) => {
91841
92095
  if (!event.domain) {
91842
92096
  log$8.error("Domain is required for restore connection");
@@ -92323,6 +92577,9 @@ var TonWalletKit = class {
92323
92577
  case "streaming":
92324
92578
  this.streamingManager.registerProvider(provider);
92325
92579
  break;
92580
+ case "gasless":
92581
+ this.gaslessManager.registerProvider(provider);
92582
+ break;
92326
92583
  default: throw new Error("Unknown provider type");
92327
92584
  }
92328
92585
  }
@@ -92357,6 +92614,12 @@ var TonWalletKit = class {
92357
92614
  return this.stakingManager;
92358
92615
  }
92359
92616
  /**
92617
+ * Gasless API access
92618
+ */
92619
+ get gasless() {
92620
+ return this.gaslessManager;
92621
+ }
92622
+ /**
92360
92623
  * Get the event emitter for this kit instance
92361
92624
  * Allows external components to listen to and emit events
92362
92625
  */