@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.cjs CHANGED
@@ -21396,40 +21396,84 @@ var require_nacl_fast = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21396
21396
  })(typeof module !== "undefined" && module.exports ? module.exports : self.nacl = self.nacl || {});
21397
21397
  }));
21398
21398
  //#endregion
21399
- //#region ../../node_modules/.pnpm/@tonconnect+protocol@2.5.0-alpha.1/node_modules/@tonconnect/protocol/lib/esm/index.mjs
21399
+ //#region ../../node_modules/.pnpm/@tonconnect+protocol@3.0.0/node_modules/@tonconnect/protocol/lib/esm/index.mjs
21400
21400
  var import_nacl_util = /* @__PURE__ */ __toESM(require_nacl_util(), 1);
21401
21401
  var import_nacl_fast = /* @__PURE__ */ __toESM(require_nacl_fast(), 1);
21402
+ /**
21403
+ * Error codes the wallet may return in {@link ConnectEventError}.
21404
+ *
21405
+ * @see [Connect event error codes (Connect spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/connect.md#connect-event-error-codes)
21406
+ */
21402
21407
  var CONNECT_EVENT_ERROR_CODES$1;
21403
21408
  (function(CONNECT_EVENT_ERROR_CODES) {
21409
+ /** Unexpected wallet-side failure. */
21404
21410
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21411
+ /** Request payload is malformed. */
21405
21412
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
21413
+ /** Wallet could not fetch the `tonconnect-manifest.json`. */
21406
21414
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["MANIFEST_NOT_FOUND_ERROR"] = 2] = "MANIFEST_NOT_FOUND_ERROR";
21415
+ /** Manifest was fetched but fails JSON / schema validation. */
21407
21416
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["MANIFEST_CONTENT_ERROR"] = 3] = "MANIFEST_CONTENT_ERROR";
21417
+ /** Wallet does not know the app / session. */
21408
21418
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21419
+ /** User explicitly declined the connect prompt. */
21409
21420
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
21421
+ /** Wallet does not support the requested method. */
21410
21422
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21411
21423
  })(CONNECT_EVENT_ERROR_CODES$1 || (CONNECT_EVENT_ERROR_CODES$1 = {}));
21424
+ /**
21425
+ * Per-item error codes returned inside a {@link ConnectItemReplyError}.
21426
+ *
21427
+ * @see [Connect item error codes (Connect spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/connect.md#connect-item-error-codes)
21428
+ */
21412
21429
  var CONNECT_ITEM_ERROR_CODES$1;
21413
21430
  (function(CONNECT_ITEM_ERROR_CODES) {
21431
+ /** Unexpected wallet-side failure. */
21414
21432
  CONNECT_ITEM_ERROR_CODES[CONNECT_ITEM_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21433
+ /** Wallet does not support this connect item. */
21415
21434
  CONNECT_ITEM_ERROR_CODES[CONNECT_ITEM_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21416
21435
  })(CONNECT_ITEM_ERROR_CODES$1 || (CONNECT_ITEM_ERROR_CODES$1 = {}));
21436
+ /**
21437
+ * Error codes the wallet may return from `sendTransaction`.
21438
+ *
21439
+ * @see [`sendTransaction` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#sendtransaction)
21440
+ */
21417
21441
  var SEND_TRANSACTION_ERROR_CODES$1;
21418
21442
  (function(SEND_TRANSACTION_ERROR_CODES) {
21443
+ /** Unexpected wallet-side failure. */
21419
21444
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21445
+ /** Request payload is malformed. */
21420
21446
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
21447
+ /** Wallet does not know the dApp / session. */
21421
21448
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21449
+ /** User explicitly declined the transaction. */
21422
21450
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
21451
+ /** Wallet does not support the method. */
21423
21452
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21424
21453
  })(SEND_TRANSACTION_ERROR_CODES$1 || (SEND_TRANSACTION_ERROR_CODES$1 = {}));
21454
+ /**
21455
+ * Error codes the wallet may return from `signData`.
21456
+ *
21457
+ * @see [`signData` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#signdata)
21458
+ */
21425
21459
  var SIGN_DATA_ERROR_CODES$1;
21426
21460
  (function(SIGN_DATA_ERROR_CODES) {
21461
+ /** Unexpected wallet-side failure. */
21427
21462
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21463
+ /** Invalid request payload. */
21428
21464
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
21465
+ /** Wallet does not know the dApp / session. */
21429
21466
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21467
+ /** User explicitly declined. */
21430
21468
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
21469
+ /** Wallet does not support `signData` method or the requested `type`. */
21431
21470
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21432
21471
  })(SIGN_DATA_ERROR_CODES$1 || (SIGN_DATA_ERROR_CODES$1 = {}));
21472
+ /**
21473
+ * Error codes the wallet may return from `disconnect`.
21474
+
21475
+ * @see [`disconnect` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#disconnect)
21476
+ */
21433
21477
  var DISCONNECT_ERROR_CODES$1;
21434
21478
  (function(DISCONNECT_ERROR_CODES) {
21435
21479
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
@@ -21437,14 +21481,27 @@ var DISCONNECT_ERROR_CODES$1;
21437
21481
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21438
21482
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21439
21483
  })(DISCONNECT_ERROR_CODES$1 || (DISCONNECT_ERROR_CODES$1 = {}));
21484
+ /**
21485
+ * Error codes the wallet may return from `signMessage`.
21486
+ *
21487
+ * @see [`signMessage` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#signmessage)
21488
+ */
21440
21489
  var SIGN_MESSAGE_ERROR_CODES;
21441
21490
  (function(SIGN_MESSAGE_ERROR_CODES) {
21491
+ /** Unexpected wallet-side failure. */
21442
21492
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
21493
+ /** Invalid request payload. */
21443
21494
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
21495
+ /** Wallet does not know the dApp / session. */
21444
21496
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
21497
+ /** User explicitly declined. */
21445
21498
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
21499
+ /** Wallet does not support `signMessage`. */
21446
21500
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
21447
21501
  })(SIGN_MESSAGE_ERROR_CODES || (SIGN_MESSAGE_ERROR_CODES = {}));
21502
+ /**
21503
+ * Two baseline TON network IDs.
21504
+ */
21448
21505
  var CHAIN$1;
21449
21506
  (function(CHAIN) {
21450
21507
  CHAIN["MAINNET"] = "-239";
@@ -21486,6 +21543,20 @@ function decode$1(value, urlSafe = false) {
21486
21543
  }
21487
21544
  };
21488
21545
  }
21546
+ /**
21547
+ * UTF-8 base64 codec used by `@tonconnect/protocol`. Wraps the NaCl
21548
+ * helpers with optional URL-safe encoding and a typed decoder that can
21549
+ * yield a string, an object (JSON-parsed), or the raw byte array.
21550
+ *
21551
+ * @example
21552
+ * ```ts
21553
+ * import { Base64 } from '@tonconnect/protocol';
21554
+ *
21555
+ * const encoded = Base64.encode({ hello: 'world' });
21556
+ * const obj = Base64.decode(encoded).toObject<{ hello: string }>();
21557
+ * const bin = Base64.decode(Base64.encode('Hello')).toUint8Array();
21558
+ * ```
21559
+ */
21489
21560
  const Base64$1 = {
21490
21561
  encode: encode$1,
21491
21562
  decode: decode$1
@@ -21609,16 +21680,22 @@ function decodeEmbeddedRequestParam(reqParam) {
21609
21680
  const json = fromBase64Url(reqParam);
21610
21681
  return decodeWireEmbeddedRequest(JSON.parse(json));
21611
21682
  }
21683
+ /** Concatenate two byte arrays into a new `Uint8Array`. */
21612
21684
  function concatUint8Arrays(buffer1, buffer2) {
21613
21685
  const mergedArray = new Uint8Array(buffer1.length + buffer2.length);
21614
21686
  mergedArray.set(buffer1);
21615
21687
  mergedArray.set(buffer2, buffer1.length);
21616
21688
  return mergedArray;
21617
21689
  }
21690
+ /**
21691
+ * Split `array` at `index` and return the two halves as fresh
21692
+ * `Uint8Array`s.
21693
+ */
21618
21694
  function splitToUint8Arrays(array, index) {
21619
21695
  if (index >= array.length) throw new Error("Index is out of buffer");
21620
21696
  return [array.slice(0, index), array.slice(index)];
21621
21697
  }
21698
+ /** Hex-encode a byte array, lowercase, no `0x` prefix. */
21622
21699
  function toHexString(byteArray) {
21623
21700
  let hexString = "";
21624
21701
  byteArray.forEach((byte) => {
@@ -21626,13 +21703,52 @@ function toHexString(byteArray) {
21626
21703
  });
21627
21704
  return hexString;
21628
21705
  }
21706
+ /**
21707
+ * Inverse of {@link toHexString}. Throws when `hexString` has an odd length.
21708
+ */
21629
21709
  function hexToByteArray$1(hexString) {
21630
21710
  if (hexString.length % 2 !== 0) throw new Error(`Cannot convert ${hexString} to bytesArray`);
21631
21711
  const result = new Uint8Array(hexString.length / 2);
21632
21712
  for (let i = 0; i < hexString.length; i += 2) result[i / 2] = parseInt(hexString.slice(i, i + 2), 16);
21633
21713
  return result;
21634
21714
  }
21715
+ /**
21716
+ * Implements the TON Connect session-encryption protocol on top of NaCl's
21717
+ * `crypto_box`.
21718
+ *
21719
+ * The protocol is symmetric: each side encrypts the messages it sends and
21720
+ * decrypts the messages it receives. On the dApp side that means encrypting
21721
+ * outgoing {@link AppMessage} and decrypting incoming {@link WalletMessage};
21722
+ * the wallet does the reverse.
21723
+ *
21724
+ * @example
21725
+ * ```ts
21726
+ * import { SessionCrypto, Base64, hexToByteArray } from '@tonconnect/protocol';
21727
+ *
21728
+ * // Generate a fresh session
21729
+ * const session = new SessionCrypto();
21730
+ * const myClientId = session.sessionId; // hex public key (sent to the peer)
21731
+ *
21732
+ * // Encrypt an outgoing message for the peer
21733
+ * const ciphertext = session.encrypt(
21734
+ * JSON.stringify(message),
21735
+ * hexToByteArray(peerClientId)
21736
+ * );
21737
+ *
21738
+ * // Decrypt an incoming message from the peer
21739
+ * const plaintext = session.decrypt(
21740
+ * Base64.decode(bridgeMessage.message).toUint8Array(),
21741
+ * hexToByteArray(bridgeMessage.from)
21742
+ * );
21743
+ * ```
21744
+ *
21745
+ * @see [Session protocol (Session spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/session.md)
21746
+ */
21635
21747
  var SessionCrypto = class {
21748
+ /**
21749
+ * Reuse an existing {@link KeyPair} (resuming a session) or generate a
21750
+ * fresh one (`crypto_box.keyPair()`) when omitted.
21751
+ */
21636
21752
  constructor(keyPair) {
21637
21753
  this.nonceLength = 24;
21638
21754
  this.keyPair = keyPair ? this.createKeypairFromString(keyPair) : this.createKeypair();
@@ -21650,17 +21766,31 @@ var SessionCrypto = class {
21650
21766
  createNonce() {
21651
21767
  return import_nacl_fast.default.randomBytes(this.nonceLength);
21652
21768
  }
21769
+ /**
21770
+ * Encrypt `message` for `receiverPublicKey` using a fresh 24-byte random
21771
+ * nonce. Returns `nonce || ciphertext` as raw bytes; base64-encode this
21772
+ * value before placing it in the bridge `POST /message` body.
21773
+ */
21653
21774
  encrypt(message, receiverPublicKey) {
21654
21775
  const encodedMessage = new TextEncoder().encode(message);
21655
21776
  const nonce = this.createNonce();
21656
21777
  return concatUint8Arrays(nonce, import_nacl_fast.default.box(encodedMessage, nonce, receiverPublicKey, this.keyPair.secretKey));
21657
21778
  }
21779
+ /**
21780
+ * Decrypt the `nonce || ciphertext` blob received from the bridge.
21781
+ * Throws if `nacl.box.open` rejects the message — wrong key, truncated
21782
+ * input or tampered ciphertext.
21783
+ */
21658
21784
  decrypt(message, senderPublicKey) {
21659
21785
  const [nonce, internalMessage] = splitToUint8Arrays(message, this.nonceLength);
21660
21786
  const decrypted = import_nacl_fast.default.box.open(internalMessage, nonce, senderPublicKey, this.keyPair.secretKey);
21661
21787
  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()}`);
21662
21788
  return new TextDecoder().decode(decrypted);
21663
21789
  }
21790
+ /**
21791
+ * Export the underlying keypair as a {@link KeyPair} of hex strings.
21792
+ * Persist this in dApp / wallet storage to resume the session later.
21793
+ */
21664
21794
  stringifyKeypair() {
21665
21795
  return {
21666
21796
  publicKey: toHexString(this.keyPair.publicKey),
@@ -42263,7 +42393,7 @@ async function CallForSuccess(toCall, attempts = 20, delayMs = 100, shouldRetry)
42263
42393
  return await toCall();
42264
42394
  } catch (err) {
42265
42395
  lastError = err;
42266
- if (shouldRetry && !shouldRetry(err)) throw err;
42396
+ if (typeof shouldRetry === "function" && shouldRetry(err) === false) throw err;
42267
42397
  i++;
42268
42398
  await delay(delayMs);
42269
42399
  }
@@ -42384,7 +42514,7 @@ var MemoryStorageAdapter = class {
42384
42514
  * LICENSE file in the root directory of this source tree.
42385
42515
  *
42386
42516
  */
42387
- const log$36 = globalLogger.createChild("StorageAdapter");
42517
+ const log$37 = globalLogger.createChild("StorageAdapter");
42388
42518
  /**
42389
42519
  * Create storage adapter based on environment and preferences
42390
42520
  */
@@ -42392,7 +42522,7 @@ function createStorageAdapter(config = {}) {
42392
42522
  if (typeof localStorage !== "undefined") try {
42393
42523
  return new LocalStorageAdapter(config);
42394
42524
  } catch (error) {
42395
- log$36.warn("Failed to create LocalStorageAdapter, falling back to memory", { error });
42525
+ log$37.warn("Failed to create LocalStorageAdapter, falling back to memory", { error });
42396
42526
  }
42397
42527
  if (config.allowMemory) return new MemoryStorageAdapter(config);
42398
42528
  else throw new Error("No storage adapter available");
@@ -42406,7 +42536,7 @@ function createStorageAdapter(config = {}) {
42406
42536
  * LICENSE file in the root directory of this source tree.
42407
42537
  *
42408
42538
  */
42409
- const log$35 = globalLogger.createChild("Storage");
42539
+ const log$36 = globalLogger.createChild("Storage");
42410
42540
  /**
42411
42541
  * High-level storage interface with generic type support
42412
42542
  * Wraps StorageAdapter to provide type-safe get/set operations
@@ -42427,7 +42557,7 @@ var Storage = class {
42427
42557
  if (value === null) return null;
42428
42558
  return JSON.parse(value);
42429
42559
  } catch (error) {
42430
- log$35.warn("Failed to parse stored value", {
42560
+ log$36.warn("Failed to parse stored value", {
42431
42561
  key,
42432
42562
  error
42433
42563
  });
@@ -42444,7 +42574,7 @@ var Storage = class {
42444
42574
  const serialized = JSON.stringify(value);
42445
42575
  await this.adapter.set(key, serialized);
42446
42576
  } catch (error) {
42447
- log$35.error("Failed to serialize value for storage", {
42577
+ log$36.error("Failed to serialize value for storage", {
42448
42578
  key,
42449
42579
  error
42450
42580
  });
@@ -42823,7 +42953,7 @@ var WalletManager = class {
42823
42953
  * LICENSE file in the root directory of this source tree.
42824
42954
  *
42825
42955
  */
42826
- const log$34 = globalLogger.createChild("TONConnectStoredSessionManager");
42956
+ const log$35 = globalLogger.createChild("TONConnectStoredSessionManager");
42827
42957
  var TONConnectStoredSessionManager = class {
42828
42958
  sessions = /* @__PURE__ */ new Map();
42829
42959
  storage;
@@ -42956,16 +43086,16 @@ var TONConnectStoredSessionManager = class {
42956
43086
  const wallet = this.walletManager.getWallet(session.walletId);
42957
43087
  if (wallet) session.walletAddress = wallet.getAddress();
42958
43088
  else {
42959
- log$34.warn("Session Wallet not found for session", { sessionId: session.sessionId });
43089
+ log$35.warn("Session Wallet not found for session", { sessionId: session.sessionId });
42960
43090
  continue;
42961
43091
  }
42962
43092
  }
42963
43093
  this.sessions.set(session.sessionId, session);
42964
43094
  }
42965
- log$34.debug("Loaded session metadata", { count: storedSessions.length });
43095
+ log$35.debug("Loaded session metadata", { count: storedSessions.length });
42966
43096
  }
42967
43097
  } catch (error) {
42968
- log$34.warn("Failed to load sessions from storage", { error });
43098
+ log$35.warn("Failed to load sessions from storage", { error });
42969
43099
  }
42970
43100
  }
42971
43101
  /**
@@ -42976,7 +43106,7 @@ var TONConnectStoredSessionManager = class {
42976
43106
  const sessionsToStore = Array.from(this.sessions.values());
42977
43107
  await this.storage.set(this.storageKey, sessionsToStore);
42978
43108
  } catch (error) {
42979
- log$34.warn("Failed to persist sessions to storage", { error });
43109
+ log$35.warn("Failed to persist sessions to storage", { error });
42980
43110
  }
42981
43111
  }
42982
43112
  async migrateSessions() {
@@ -83147,7 +83277,7 @@ globalLogger.createChild("ExtensionTransport");
83147
83277
  * LICENSE file in the root directory of this source tree.
83148
83278
  *
83149
83279
  */
83150
- const log$32 = globalLogger.createChild("BridgeManager");
83280
+ const log$33 = globalLogger.createChild("BridgeManager");
83151
83281
  var BridgeManager = class {
83152
83282
  config;
83153
83283
  bridgeProvider;
@@ -83189,7 +83319,7 @@ var BridgeManager = class {
83189
83319
  this.walletKitConfig = walletKitConfig;
83190
83320
  this.jsBridgeTransport = config?.jsBridgeTransport;
83191
83321
  if (this.config.bridgeUrl && !this.config.disableHttpConnection) this.bridgeProvider = new C(this.config.bridgeUrl, this.queueBridgeEvent.bind(this), (error) => {
83192
- log$32.error("Bridge listener error", { error: error.toString() });
83322
+ log$33.error("Bridge listener error", { error: error.toString() });
83193
83323
  this.analytics?.emitBridgeClientConnectError({
83194
83324
  error_message: `${error?.toString() || "Unknown error"}${error?.errorCode ? ` (Code: ${error?.errorCode})` : ""}`,
83195
83325
  trace_id: error?.traceId,
@@ -83203,12 +83333,12 @@ var BridgeManager = class {
83203
83333
  */
83204
83334
  async start() {
83205
83335
  if (this.isActive === true) {
83206
- log$32.warn("Bridge already started");
83336
+ log$33.warn("Bridge already started");
83207
83337
  return;
83208
83338
  }
83209
83339
  this.isActive = true;
83210
83340
  if (this.isConnected === true) {
83211
- log$32.warn("Bridge already connected");
83341
+ log$33.warn("Bridge already connected");
83212
83342
  return;
83213
83343
  }
83214
83344
  try {
@@ -83220,7 +83350,7 @@ var BridgeManager = class {
83220
83350
  }
83221
83351
  } catch (error) {
83222
83352
  this.isActive = false;
83223
- log$32.error("Failed to start bridge", { error });
83353
+ log$33.error("Failed to start bridge", { error });
83224
83354
  throw error;
83225
83355
  }
83226
83356
  const requestProcessing = () => {
@@ -83233,10 +83363,10 @@ var BridgeManager = class {
83233
83363
  * Create new session for a dApp connection
83234
83364
  */
83235
83365
  async createSession(appSessionId) {
83236
- log$32.info("[BRIDGE] Creating session", { appSessionId });
83366
+ log$33.info("[BRIDGE] Creating session", { appSessionId });
83237
83367
  if (!await this.sessionManager.getSession(appSessionId)) throw new WalletKitError(ERROR_CODES.SESSION_NOT_FOUND, `Session not found`, void 0, { appSessionId });
83238
83368
  if (this.bridgeProvider && this.isConnected) {
83239
- log$32.info("[BRIDGE] Updating clients");
83369
+ log$33.info("[BRIDGE] Updating clients");
83240
83370
  await this.updateClients();
83241
83371
  }
83242
83372
  }
@@ -83245,7 +83375,7 @@ var BridgeManager = class {
83245
83375
  */
83246
83376
  async removeSession(appSessionId) {
83247
83377
  if (this.bridgeProvider && this.isConnected) await this.updateClients();
83248
- log$32.debug("Session removed", { appSessionId });
83378
+ log$33.debug("Session removed", { appSessionId });
83249
83379
  }
83250
83380
  /**
83251
83381
  * Send response to dApp
@@ -83270,12 +83400,12 @@ var BridgeManager = class {
83270
83400
  }
83271
83401
  try {
83272
83402
  await this.bridgeProvider.send(response, sessionCrypto, sessionId, { traceId: event?.traceId });
83273
- log$32.debug("Response sent successfully", {
83403
+ log$33.debug("Response sent successfully", {
83274
83404
  sessionId,
83275
83405
  requestId: event.id
83276
83406
  });
83277
83407
  } catch (error) {
83278
- log$32.error("Failed to send response through bridge", {
83408
+ log$33.error("Failed to send response through bridge", {
83279
83409
  sessionId,
83280
83410
  requestId: event.id,
83281
83411
  error
@@ -83357,7 +83487,7 @@ var BridgeManager = class {
83357
83487
  await this.bridgeProvider?.restoreConnection(clients, { lastEventId: this.lastEventId });
83358
83488
  this.isConnected = true;
83359
83489
  this.reconnectAttempts = 0;
83360
- log$32.info("Bridge connected successfully");
83490
+ log$33.info("Bridge connected successfully");
83361
83491
  if (this.analytics) {
83362
83492
  const client = clients[0];
83363
83493
  this.analytics.emitBridgeClientConnectEstablished({
@@ -83366,7 +83496,7 @@ var BridgeManager = class {
83366
83496
  });
83367
83497
  }
83368
83498
  } catch (error) {
83369
- log$32.error("Bridge connection failed", { error: error?.toString() });
83499
+ log$33.error("Bridge connection failed", { error: error?.toString() });
83370
83500
  this.analytics?.emitBridgeClientConnectError({
83371
83501
  error_message: `${error?.toString() || "Unknown error"}${error?.errorCode ? ` (Code: ${error?.errorCode})` : ""}`,
83372
83502
  trace_id: error?.traceId ?? connectTraceId,
@@ -83375,9 +83505,9 @@ var BridgeManager = class {
83375
83505
  if (!this.config.disableHttpConnection) {
83376
83506
  if (this.reconnectAttempts < (this.config.maxReconnectAttempts || 5)) {
83377
83507
  this.reconnectAttempts++;
83378
- log$32.info("Bridge reconnection attempt", { attempt: this.reconnectAttempts });
83508
+ log$33.info("Bridge reconnection attempt", { attempt: this.reconnectAttempts });
83379
83509
  setTimeout(() => {
83380
- this.connectToSSEBridge().catch((error) => log$32.error("Bridge reconnection failed", { error }));
83510
+ this.connectToSSEBridge().catch((error) => log$33.error("Bridge reconnection failed", { error }));
83381
83511
  }, this.config.reconnectInterval);
83382
83512
  }
83383
83513
  }
@@ -83398,10 +83528,10 @@ var BridgeManager = class {
83398
83528
  * Add client to existing bridge connection
83399
83529
  */
83400
83530
  async updateClients() {
83401
- log$32.debug("Updating clients");
83531
+ log$33.debug("Updating clients");
83402
83532
  if (this.bridgeProvider) {
83403
83533
  const clients = await this.getClients();
83404
- log$32.info("[BRIDGE] Restoring connection", { clients: clients.length });
83534
+ log$33.info("[BRIDGE] Restoring connection", { clients: clients.length });
83405
83535
  await this.bridgeProvider.restoreConnection(clients, { lastEventId: this.lastEventId });
83406
83536
  }
83407
83537
  }
@@ -83409,17 +83539,17 @@ var BridgeManager = class {
83409
83539
  * Queue incoming bridge events for processing
83410
83540
  */
83411
83541
  queueBridgeEvent(event) {
83412
- log$32.debug("Bridge event queued", {
83542
+ log$33.debug("Bridge event queued", {
83413
83543
  eventId: event?.id,
83414
83544
  event
83415
83545
  });
83416
83546
  this.eventQueue.push(event);
83417
83547
  this.processBridgeEvents().catch((error) => {
83418
- log$32.error("Error in background event processing", { error });
83548
+ log$33.error("Error in background event processing", { error });
83419
83549
  });
83420
83550
  }
83421
83551
  queueJsBridgeEvent(messageInfo, event) {
83422
- log$32.debug("JS Bridge event queued", { eventId: messageInfo?.messageId });
83552
+ log$33.debug("JS Bridge event queued", { eventId: messageInfo?.messageId });
83423
83553
  if (!event) return;
83424
83554
  if (!event.traceId) event.traceId = v7();
83425
83555
  if (event.method == "connect") this.eventQueue.push({
@@ -83448,7 +83578,7 @@ var BridgeManager = class {
83448
83578
  walletId: messageInfo.walletId
83449
83579
  });
83450
83580
  this.processBridgeEvents().catch((error) => {
83451
- log$32.error("Error in background event processing", { error });
83581
+ log$33.error("Error in background event processing", { error });
83452
83582
  });
83453
83583
  }
83454
83584
  /**
@@ -83460,7 +83590,7 @@ var BridgeManager = class {
83460
83590
  */
83461
83591
  async processBridgeEvents() {
83462
83592
  if (this.isProcessing) {
83463
- log$32.debug("Event processing already in progress, skipping");
83593
+ log$33.debug("Event processing already in progress, skipping");
83464
83594
  return;
83465
83595
  }
83466
83596
  this.isProcessing = true;
@@ -83473,7 +83603,7 @@ var BridgeManager = class {
83473
83603
  }
83474
83604
  }
83475
83605
  } catch (error) {
83476
- log$32.error("Error during event processing", { error });
83606
+ log$33.error("Error during event processing", { error });
83477
83607
  this.isProcessing = false;
83478
83608
  this.restartConnection();
83479
83609
  return;
@@ -83486,7 +83616,7 @@ var BridgeManager = class {
83486
83616
  */
83487
83617
  async handleBridgeEvent(event) {
83488
83618
  try {
83489
- log$32.info("Bridge event received", { event });
83619
+ log$33.info("Bridge event received", { event });
83490
83620
  const rawEvent = {
83491
83621
  id: event.id || crypto.randomUUID(),
83492
83622
  method: event.method || "unknown",
@@ -83540,12 +83670,12 @@ var BridgeManager = class {
83540
83670
  try {
83541
83671
  await this.eventStore.storeEvent(rawEvent);
83542
83672
  if (this.eventEmitter) this.eventEmitter.emit("bridgeStorageUpdated", {}, "bridge-manager");
83543
- log$32.info("Event stored durably", {
83673
+ log$33.info("Event stored durably", {
83544
83674
  eventId: rawEvent.id,
83545
83675
  method: rawEvent.method
83546
83676
  });
83547
83677
  } catch (error) {
83548
- log$32.error("Failed to store event durably", {
83678
+ log$33.error("Failed to store event durably", {
83549
83679
  eventId: rawEvent.id,
83550
83680
  error: error.message
83551
83681
  });
@@ -83554,13 +83684,13 @@ var BridgeManager = class {
83554
83684
  method: rawEvent.method
83555
83685
  });
83556
83686
  }
83557
- log$32.info("Bridge event processed", { rawEvent });
83687
+ log$33.info("Bridge event processed", { rawEvent });
83558
83688
  if (event?.lastEventId && event.lastEventId !== this.lastEventId) {
83559
83689
  this.lastEventId = event.lastEventId;
83560
83690
  await this.saveLastEventId();
83561
83691
  }
83562
83692
  } catch (error) {
83563
- log$32.error("Error handling bridge event", { error });
83693
+ log$33.error("Error handling bridge event", { error });
83564
83694
  }
83565
83695
  }
83566
83696
  /**
@@ -83571,11 +83701,11 @@ var BridgeManager = class {
83571
83701
  const savedEventId = await this.storage.get(this.storageKey);
83572
83702
  if (savedEventId) {
83573
83703
  this.lastEventId = savedEventId;
83574
- log$32.debug("Loaded last event ID from storage", { lastEventId: this.lastEventId });
83704
+ log$33.debug("Loaded last event ID from storage", { lastEventId: this.lastEventId });
83575
83705
  }
83576
83706
  } catch (error) {
83577
83707
  const storageError = WalletKitError.fromError(ERROR_CODES.STORAGE_READ_FAILED, "Failed to load last event ID from storage", error);
83578
- log$32.warn("Failed to load last event ID from storage", { error: storageError });
83708
+ log$33.warn("Failed to load last event ID from storage", { error: storageError });
83579
83709
  }
83580
83710
  }
83581
83711
  /**
@@ -83585,11 +83715,11 @@ var BridgeManager = class {
83585
83715
  try {
83586
83716
  if (this.lastEventId) {
83587
83717
  await this.storage.set(this.storageKey, this.lastEventId);
83588
- log$32.debug("Saved last event ID to storage", { lastEventId: this.lastEventId });
83718
+ log$33.debug("Saved last event ID to storage", { lastEventId: this.lastEventId });
83589
83719
  }
83590
83720
  } catch (error) {
83591
83721
  const storageError = WalletKitError.fromError(ERROR_CODES.STORAGE_WRITE_FAILED, "Failed to save last event ID to storage", error);
83592
- log$32.warn("Failed to save last event ID to storage", { error: storageError });
83722
+ log$33.warn("Failed to save last event ID to storage", { error: storageError });
83593
83723
  }
83594
83724
  }
83595
83725
  };
@@ -83644,7 +83774,7 @@ function isValidHost(host) {
83644
83774
  * LICENSE file in the root directory of this source tree.
83645
83775
  *
83646
83776
  */
83647
- const log$31 = globalLogger.createChild("ManifestUtils");
83777
+ const log$32 = globalLogger.createChild("ManifestUtils");
83648
83778
  async function fetchManifest(manifestUrl, proxyUrl) {
83649
83779
  try {
83650
83780
  if (!isValidHost(new URL(manifestUrl).host)) return {
@@ -83663,14 +83793,14 @@ async function fetchManifest(manifestUrl, proxyUrl) {
83663
83793
  manifest: null,
83664
83794
  manifestFetchErrorCode: CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR
83665
83795
  };
83666
- log$31.info("Direct manifest fetch failed, trying proxy", { manifestUrl });
83796
+ log$32.info("Direct manifest fetch failed, trying proxy", { manifestUrl });
83667
83797
  return tryFetchManifest(`${proxyUrl}${manifestUrl}`);
83668
83798
  }
83669
83799
  async function tryFetchManifest(url) {
83670
83800
  try {
83671
83801
  const response = await fetch(url);
83672
83802
  if (!response.ok) {
83673
- log$31.error("Failed to fetch manifest not ok", {
83803
+ log$32.error("Failed to fetch manifest not ok", {
83674
83804
  url,
83675
83805
  status: response.status
83676
83806
  });
@@ -83684,7 +83814,7 @@ async function tryFetchManifest(url) {
83684
83814
  manifestFetchErrorCode: void 0
83685
83815
  };
83686
83816
  } catch (e) {
83687
- log$31.error("Failed to fetch manifest catched", {
83817
+ log$32.error("Failed to fetch manifest catched", {
83688
83818
  url,
83689
83819
  error: e
83690
83820
  });
@@ -83703,7 +83833,7 @@ async function tryFetchManifest(url) {
83703
83833
  * LICENSE file in the root directory of this source tree.
83704
83834
  *
83705
83835
  */
83706
- const log$30 = globalLogger.createChild("ConnectHandler");
83836
+ const log$31 = globalLogger.createChild("ConnectHandler");
83707
83837
  var ConnectHandler = class extends BasicHandler {
83708
83838
  config;
83709
83839
  analytics;
@@ -83724,7 +83854,7 @@ var ConnectHandler = class extends BasicHandler {
83724
83854
  manifest = result.manifest;
83725
83855
  manifestFetchErrorCode = result.manifestFetchErrorCode;
83726
83856
  } catch (error) {
83727
- log$30.warn("Failed to fetch manifest", { error });
83857
+ log$31.warn("Failed to fetch manifest", { error });
83728
83858
  }
83729
83859
  const preview = this.createPreview(event, manifestUrl, manifest, manifestFetchErrorCode);
83730
83860
  const connectEvent = {
@@ -83785,14 +83915,14 @@ var ConnectHandler = class extends BasicHandler {
83785
83915
  if (!finalManifestFetchErrorCode && dAppUrl) try {
83786
83916
  const parsedDAppUrl = new URL(dAppUrl);
83787
83917
  if (!isValidHost(parsedDAppUrl.host)) {
83788
- log$30.warn("Invalid dApp URL in manifest - invalid host format", {
83918
+ log$31.warn("Invalid dApp URL in manifest - invalid host format", {
83789
83919
  dAppUrl,
83790
83920
  host: parsedDAppUrl.host
83791
83921
  });
83792
83922
  finalManifestFetchErrorCode = CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR;
83793
83923
  }
83794
83924
  } catch (_) {
83795
- log$30.warn("Invalid dApp URL in manifest - failed to parse", { dAppUrl });
83925
+ log$31.warn("Invalid dApp URL in manifest - failed to parse", { dAppUrl });
83796
83926
  finalManifestFetchErrorCode = CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR;
83797
83927
  }
83798
83928
  }
@@ -84452,7 +84582,7 @@ function createTransferTransaction(params) {
84452
84582
  * LICENSE file in the root directory of this source tree.
84453
84583
  *
84454
84584
  */
84455
- const log$29 = globalLogger.createChild("ItemsResolver");
84585
+ const log$30 = globalLogger.createChild("ItemsResolver");
84456
84586
  /**
84457
84587
  * Resolve structured items (ton/jetton/nft) into raw TransactionRequestMessages.
84458
84588
  * After resolution, downstream code only needs to handle messages.
@@ -84470,7 +84600,7 @@ async function resolveItemsToMessages(items, wallet) {
84470
84600
  messages.push(resolveNftItem(item, wallet));
84471
84601
  break;
84472
84602
  default:
84473
- log$29.warn("Unknown item type, skipping", { item });
84603
+ log$30.warn("Unknown item type, skipping", { item });
84474
84604
  break;
84475
84605
  }
84476
84606
  return messages;
@@ -84532,7 +84662,7 @@ function resolveNftItem(item, wallet) {
84532
84662
  * LICENSE file in the root directory of this source tree.
84533
84663
  *
84534
84664
  */
84535
- const log$28 = globalLogger.createChild("EventsUtils");
84665
+ const log$29 = globalLogger.createChild("EventsUtils");
84536
84666
  /**
84537
84667
  * Helper to get wallet from event
84538
84668
  */
@@ -84591,7 +84721,7 @@ function parseTonConnectTransactionRequest(event, wallet) {
84591
84721
  validation: validateTransactionRequestForWallet(request, wallet, event.isLocal)
84592
84722
  };
84593
84723
  } catch (error) {
84594
- log$28.error("Failed to parse transaction request", { error });
84724
+ log$29.error("Failed to parse transaction request", { error });
84595
84725
  errors.push("Failed to parse transaction request");
84596
84726
  return {
84597
84727
  result: void 0,
@@ -86964,7 +87094,7 @@ async function computeMoneyFlow(client, response, options = {}) {
86964
87094
  * LICENSE file in the root directory of this source tree.
86965
87095
  *
86966
87096
  */
86967
- const log$27 = globalLogger.createChild("TransactionPreview");
87097
+ const log$28 = globalLogger.createChild("TransactionPreview");
86968
87098
  const SIGN_MODE_EMULATION_VALUE = 2000000000n;
86969
87099
  async function createTransactionPreview(client, request, wallet, options = {}) {
86970
87100
  const isSignMode = (options.mode ?? "send") === "sign";
@@ -87016,7 +87146,7 @@ async function createTransactionPreviewIfPossible(config, client, request, walle
87016
87146
  try {
87017
87147
  preview = await CallForSuccess(() => createTransactionPreview(client, request, wallet, options));
87018
87148
  } catch (error) {
87019
- log$27.error("Failed to create transaction preview", { error });
87149
+ log$28.error("Failed to create transaction preview", { error });
87020
87150
  preview = {
87021
87151
  error: {
87022
87152
  code: ERROR_CODES.UNKNOWN_EMULATION_ERROR,
@@ -87291,7 +87421,7 @@ async function getTransactionStatus(client, params) {
87291
87421
  * LICENSE file in the root directory of this source tree.
87292
87422
  *
87293
87423
  */
87294
- const log$26 = globalLogger.createChild("TransactionHandler");
87424
+ const log$27 = globalLogger.createChild("TransactionHandler");
87295
87425
  var TransactionHandler = class extends BasicHandler {
87296
87426
  config;
87297
87427
  walletManager;
@@ -87313,7 +87443,7 @@ var TransactionHandler = class extends BasicHandler {
87313
87443
  async handle(event) {
87314
87444
  const wallet = getWalletFromEvent(this.walletManager, event);
87315
87445
  if (!wallet) {
87316
- log$26.error("Wallet not found", { event });
87446
+ log$27.error("Wallet not found", { event });
87317
87447
  return {
87318
87448
  error: {
87319
87449
  code: SEND_TRANSACTION_ERROR_CODES$1.UNKNOWN_APP_ERROR,
@@ -87324,7 +87454,7 @@ var TransactionHandler = class extends BasicHandler {
87324
87454
  }
87325
87455
  const requestValidation = this.parseTonConnectTransactionRequest(event, wallet);
87326
87456
  if (!requestValidation.result || !requestValidation?.validation?.isValid) {
87327
- log$26.error("Failed to parse transaction request", {
87457
+ log$27.error("Failed to parse transaction request", {
87328
87458
  event,
87329
87459
  requestValidation
87330
87460
  });
@@ -87376,7 +87506,7 @@ var TransactionHandler = class extends BasicHandler {
87376
87506
  * LICENSE file in the root directory of this source tree.
87377
87507
  *
87378
87508
  */
87379
- const log$25 = globalLogger.createChild("SignDataHandler");
87509
+ const log$26 = globalLogger.createChild("SignDataHandler");
87380
87510
  var SignDataHandler = class extends BasicHandler {
87381
87511
  analytics;
87382
87512
  walletManager;
@@ -87397,12 +87527,12 @@ var SignDataHandler = class extends BasicHandler {
87397
87527
  const wallet = walletId ? this.walletManager.getWallet(walletId) : void 0;
87398
87528
  const payload = this.parseDataToSign(event);
87399
87529
  if (!payload) {
87400
- log$25.error("No data to sign found in request", { event });
87530
+ log$26.error("No data to sign found in request", { event });
87401
87531
  throw new WalletKitError(ERROR_CODES.INVALID_REQUEST_EVENT, "No data to sign found in request", void 0, { eventId: event.id });
87402
87532
  }
87403
87533
  const preview = this.createDataPreview(payload.data, event);
87404
87534
  if (!preview) {
87405
- log$25.error("No preview found for data", { data: payload });
87535
+ log$26.error("No preview found for data", { data: payload });
87406
87536
  throw new WalletKitError(ERROR_CODES.RESPONSE_CREATION_FAILED, "Failed to create preview for sign data request", void 0, {
87407
87537
  eventId: event.id,
87408
87538
  data: payload
@@ -87459,7 +87589,7 @@ var SignDataHandler = class extends BasicHandler {
87459
87589
  }
87460
87590
  };
87461
87591
  } catch (error) {
87462
- log$25.error("Error deserializing cell", { error });
87592
+ log$26.error("Error deserializing cell", { error });
87463
87593
  return {
87464
87594
  type: "cell",
87465
87595
  value: {
@@ -87479,7 +87609,7 @@ var SignDataHandler = class extends BasicHandler {
87479
87609
  * LICENSE file in the root directory of this source tree.
87480
87610
  *
87481
87611
  */
87482
- const log$24 = globalLogger.createChild("SignMessageHandler");
87612
+ const log$25 = globalLogger.createChild("SignMessageHandler");
87483
87613
  var SignMessageHandler = class extends BasicHandler {
87484
87614
  config;
87485
87615
  walletManager;
@@ -87501,7 +87631,7 @@ var SignMessageHandler = class extends BasicHandler {
87501
87631
  async handle(event) {
87502
87632
  const wallet = getWalletFromEvent(this.walletManager, event);
87503
87633
  if (!wallet) {
87504
- log$24.error("Wallet not found", { event });
87634
+ log$25.error("Wallet not found", { event });
87505
87635
  return {
87506
87636
  error: {
87507
87637
  code: SIGN_MESSAGE_ERROR_CODES.UNKNOWN_APP_ERROR,
@@ -87512,7 +87642,7 @@ var SignMessageHandler = class extends BasicHandler {
87512
87642
  }
87513
87643
  const requestValidation = this.parseTonConnectTransactionRequest(event, wallet);
87514
87644
  if (!requestValidation.result || !requestValidation?.validation?.isValid) {
87515
- log$24.error("Failed to parse sign message request", {
87645
+ log$25.error("Failed to parse sign message request", {
87516
87646
  event,
87517
87647
  requestValidation
87518
87648
  });
@@ -87605,7 +87735,7 @@ var DisconnectHandler = class extends BasicHandler {
87605
87735
  * LICENSE file in the root directory of this source tree.
87606
87736
  *
87607
87737
  */
87608
- const log$23 = globalLogger.createChild("EventRouter");
87738
+ const log$24 = globalLogger.createChild("EventRouter");
87609
87739
  var EventRouter = class {
87610
87740
  config;
87611
87741
  eventEmitter;
@@ -87637,7 +87767,7 @@ var EventRouter = class {
87637
87767
  async routeEvent(event) {
87638
87768
  const validation = validateBridgeEvent(event);
87639
87769
  if (!validation.isValid) {
87640
- log$23.error("Invalid bridge event", { errors: validation.errors });
87770
+ log$24.error("Invalid bridge event", { errors: validation.errors });
87641
87771
  return;
87642
87772
  }
87643
87773
  try {
@@ -87652,7 +87782,7 @@ var EventRouter = class {
87652
87782
  try {
87653
87783
  await this.bridgeManager.sendResponse(event, result);
87654
87784
  } catch (error) {
87655
- log$23.error("Error sending response for error event", {
87785
+ log$24.error("Error sending response for error event", {
87656
87786
  error,
87657
87787
  event,
87658
87788
  result
@@ -87664,7 +87794,7 @@ var EventRouter = class {
87664
87794
  break;
87665
87795
  }
87666
87796
  } catch (error) {
87667
- log$23.error("Error routing event", { error });
87797
+ log$24.error("Error routing event", { error });
87668
87798
  throw error;
87669
87799
  }
87670
87800
  }
@@ -87791,7 +87921,7 @@ var EventRouter = class {
87791
87921
  * LICENSE file in the root directory of this source tree.
87792
87922
  *
87793
87923
  */
87794
- const log$22 = globalLogger.createChild("RequestProcessor");
87924
+ const log$23 = globalLogger.createChild("RequestProcessor");
87795
87925
  function hasConnectionResult(event) {
87796
87926
  return "connectionResult" in event;
87797
87927
  }
@@ -87860,7 +87990,7 @@ var RequestProcessor = class {
87860
87990
  }
87861
87991
  return;
87862
87992
  } catch (error) {
87863
- log$22.error("Failed to approve connect request", { error });
87993
+ log$23.error("Failed to approve connect request", { error });
87864
87994
  throw error;
87865
87995
  }
87866
87996
  }
@@ -87995,7 +88125,7 @@ var RequestProcessor = class {
87995
88125
  */
87996
88126
  async rejectConnectRequest(event, reason, errorCode) {
87997
88127
  try {
87998
- log$22.info("Connect request rejected", {
88128
+ log$23.info("Connect request rejected", {
87999
88129
  id: event.id,
88000
88130
  dAppName: event.preview.dAppInfo?.name || "",
88001
88131
  reason: reason || "User rejected connection"
@@ -88012,7 +88142,7 @@ var RequestProcessor = class {
88012
88142
  try {
88013
88143
  await this.bridgeManager.sendResponse(event, response, new SessionCrypto());
88014
88144
  } catch (error) {
88015
- log$22.error("Failed to send connect request rejection response", { error });
88145
+ log$23.error("Failed to send connect request rejection response", { error });
88016
88146
  }
88017
88147
  if (this.analytics) {
88018
88148
  const sessionData = event.from ? await this.sessionManager.getSession(sessionId) : void 0;
@@ -88041,7 +88171,7 @@ var RequestProcessor = class {
88041
88171
  }
88042
88172
  return;
88043
88173
  } catch (error) {
88044
- log$22.error("Failed to reject connect request", { error });
88174
+ log$23.error("Failed to reject connect request", { error });
88045
88175
  throw error;
88046
88176
  }
88047
88177
  }
@@ -88073,7 +88203,7 @@ var RequestProcessor = class {
88073
88203
  return { signedBoc };
88074
88204
  }
88075
88205
  } catch (error) {
88076
- log$22.error("Failed to approve transaction request", { error });
88206
+ log$23.error("Failed to approve transaction request", { error });
88077
88207
  if (error instanceof WalletKitError) throw error;
88078
88208
  if (error?.message?.includes("Ledger device")) throw new WalletKitError(ERROR_CODES.LEDGER_DEVICE_ERROR, "Ledger device error", error);
88079
88209
  throw error;
@@ -88123,7 +88253,7 @@ var RequestProcessor = class {
88123
88253
  }
88124
88254
  return;
88125
88255
  } catch (error) {
88126
- log$22.error("Failed to reject transaction request", { error });
88256
+ log$23.error("Failed to reject transaction request", { error });
88127
88257
  throw error;
88128
88258
  }
88129
88259
  }
@@ -88154,7 +88284,7 @@ var RequestProcessor = class {
88154
88284
  return { internalBoc };
88155
88285
  }
88156
88286
  } catch (error) {
88157
- log$22.error("Failed to approve sign message request", { error });
88287
+ log$23.error("Failed to approve sign message request", { error });
88158
88288
  throw error;
88159
88289
  }
88160
88290
  }
@@ -88172,7 +88302,7 @@ var RequestProcessor = class {
88172
88302
  };
88173
88303
  await this.sendBridgeMessage(event, void 0, response);
88174
88304
  } catch (error) {
88175
- log$22.error("Failed to reject sign message request", { error });
88305
+ log$23.error("Failed to reject sign message request", { error });
88176
88306
  throw error;
88177
88307
  }
88178
88308
  }
@@ -88275,7 +88405,7 @@ var RequestProcessor = class {
88275
88405
  };
88276
88406
  }
88277
88407
  } catch (error) {
88278
- log$22.error("Failed to approve sign data request", { error: error?.message?.toString() ?? error?.toString() });
88408
+ log$23.error("Failed to approve sign data request", { error: error?.message?.toString() ?? error?.toString() });
88279
88409
  if (error instanceof WalletKitError) throw error;
88280
88410
  throw error;
88281
88411
  }
@@ -88310,7 +88440,7 @@ var RequestProcessor = class {
88310
88440
  }
88311
88441
  return;
88312
88442
  } catch (error) {
88313
- log$22.error("Failed to reject sign data request", { error });
88443
+ log$23.error("Failed to reject sign data request", { error });
88314
88444
  throw error;
88315
88445
  }
88316
88446
  }
@@ -88389,7 +88519,7 @@ var RequestProcessor = class {
88389
88519
  */
88390
88520
  async function signTransactionInternal(wallet, request) {
88391
88521
  const signedBoc = await wallet.getSignedSendTransaction(request, { fakeSignature: false });
88392
- log$22.debug("Signing transaction", {
88522
+ log$23.debug("Signing transaction", {
88393
88523
  messagesNumber: request.messages.length,
88394
88524
  fromAddress: request.fromAddress,
88395
88525
  validUntil: request.validUntil
@@ -88445,7 +88575,7 @@ function parseDomain(url) {
88445
88575
  value: parsedUrl.host
88446
88576
  };
88447
88577
  } catch (error) {
88448
- log$22.error("Failed to parse domain", { error });
88578
+ log$23.error("Failed to parse domain", { error });
88449
88579
  return {
88450
88580
  lengthBytes: 0,
88451
88581
  value: ""
@@ -88485,7 +88615,7 @@ function toTonConnectSignDataPayload(payload) {
88485
88615
  const getEventUUID = () => {
88486
88616
  return crypto.randomUUID();
88487
88617
  };
88488
- const log$21 = globalLogger.createChild("EventStore");
88618
+ const log$22 = globalLogger.createChild("EventStore");
88489
88619
  const MAX_EVENT_SIZE_BYTES = 100 * 1024;
88490
88620
  /**
88491
88621
  * Concrete implementation of EventStore using Storage
@@ -88521,7 +88651,7 @@ var StorageEventStore = class {
88521
88651
  sizeBytes
88522
88652
  };
88523
88653
  await this.saveEvent(storedEvent);
88524
- log$21.info("Event stored", {
88654
+ log$22.info("Event stored", {
88525
88655
  eventId: storedEvent.id,
88526
88656
  eventType,
88527
88657
  sizeBytes,
@@ -88549,11 +88679,11 @@ var StorageEventStore = class {
88549
88679
  const allEvents = await this.getAllEventsFromStorage();
88550
88680
  const event = allEvents[eventId];
88551
88681
  if (!event) {
88552
- log$21.warn("Cannot lock non-existent event", { eventId });
88682
+ log$22.warn("Cannot lock non-existent event", { eventId });
88553
88683
  return;
88554
88684
  }
88555
88685
  if (event.status !== "new") {
88556
- log$21.debug("Cannot lock event - not in new status", {
88686
+ log$22.debug("Cannot lock event - not in new status", {
88557
88687
  eventId,
88558
88688
  status: event.status,
88559
88689
  lockedBy: event.lockedBy
@@ -88568,7 +88698,7 @@ var StorageEventStore = class {
88568
88698
  };
88569
88699
  allEvents[eventId] = updatedEvent;
88570
88700
  await this.storage.set(this.storageKey, allEvents);
88571
- log$21.debug("Event lock acquired", {
88701
+ log$22.debug("Event lock acquired", {
88572
88702
  eventId,
88573
88703
  walletAddress: walletId
88574
88704
  });
@@ -88595,7 +88725,7 @@ var StorageEventStore = class {
88595
88725
  };
88596
88726
  allEvents[eventId] = updatedEvent;
88597
88727
  await this.storage.set(this.storageKey, allEvents);
88598
- log$21.debug("Event retry count incremented", {
88728
+ log$22.debug("Event retry count incremented", {
88599
88729
  eventId,
88600
88730
  retryCount: updatedEvent.retryCount,
88601
88731
  error
@@ -88619,7 +88749,7 @@ var StorageEventStore = class {
88619
88749
  if (status === "completed") updatedEvent.completedAt = Date.now();
88620
88750
  allEvents[eventId] = updatedEvent;
88621
88751
  await this.storage.set(this.storageKey, allEvents);
88622
- log$21.debug("Event status updated", {
88752
+ log$22.debug("Event status updated", {
88623
88753
  eventId,
88624
88754
  oldStatus,
88625
88755
  newStatus: status
@@ -88634,7 +88764,7 @@ var StorageEventStore = class {
88634
88764
  try {
88635
88765
  return (await this.getAllEventsFromStorage())[eventId] || null;
88636
88766
  } catch (error) {
88637
- log$21.warn("Failed to get event", {
88767
+ log$22.warn("Failed to get event", {
88638
88768
  eventId,
88639
88769
  error
88640
88770
  });
@@ -88656,14 +88786,14 @@ var StorageEventStore = class {
88656
88786
  };
88657
88787
  await this.saveEvent(recoveredEvent);
88658
88788
  recoveredCount++;
88659
- log$21.info("Recovered stale event", {
88789
+ log$22.info("Recovered stale event", {
88660
88790
  eventId: event.id,
88661
88791
  lockedBy: event.lockedBy,
88662
88792
  staleMinutes: Math.round((now - event.processingStartedAt) / 6e4),
88663
88793
  retryCount: event.retryCount || 0
88664
88794
  });
88665
88795
  }
88666
- if (recoveredCount > 0) log$21.info("Event recovery completed", { recoveredCount });
88796
+ if (recoveredCount > 0) log$22.info("Event recovery completed", { recoveredCount });
88667
88797
  return recoveredCount;
88668
88798
  }
88669
88799
  /**
@@ -88676,7 +88806,7 @@ var StorageEventStore = class {
88676
88806
  const eventsToRemove = [];
88677
88807
  for (const event of events) if (event.status === "completed" && event.completedAt && event.completedAt < cutoffTime || event.status === "errored" && event.createdAt < cutoffTime) {
88678
88808
  eventsToRemove.push(event.id);
88679
- log$21.debug("Marked event for cleanup", {
88809
+ log$22.debug("Marked event for cleanup", {
88680
88810
  eventId: event.id,
88681
88811
  status: event.status
88682
88812
  });
@@ -88690,7 +88820,7 @@ var StorageEventStore = class {
88690
88820
  }
88691
88821
  await this.storage.set(this.storageKey, allEvents);
88692
88822
  });
88693
- log$21.info("Event cleanup completed", { cleanedUpCount });
88823
+ log$22.info("Event cleanup completed", { cleanedUpCount });
88694
88824
  }
88695
88825
  return cleanedUpCount;
88696
88826
  }
@@ -88702,7 +88832,7 @@ var StorageEventStore = class {
88702
88832
  const allEvents = await this.getAllEventsFromStorage();
88703
88833
  return Object.values(allEvents);
88704
88834
  } catch (error) {
88705
- log$21.warn("Failed to get all events", { error });
88835
+ log$22.warn("Failed to get all events", { error });
88706
88836
  return [];
88707
88837
  }
88708
88838
  }
@@ -88724,7 +88854,7 @@ var StorageEventStore = class {
88724
88854
  try {
88725
88855
  return await this.storage.get(this.storageKey) || {};
88726
88856
  } catch (error) {
88727
- log$21.warn("Failed to get events from storage", { error });
88857
+ log$22.warn("Failed to get events from storage", { error });
88728
88858
  return {};
88729
88859
  }
88730
88860
  }
@@ -88763,7 +88893,7 @@ var StorageEventStore = class {
88763
88893
  * LICENSE file in the root directory of this source tree.
88764
88894
  *
88765
88895
  */
88766
- const log$20 = globalLogger.createChild("EventProcessor");
88896
+ const log$21 = globalLogger.createChild("EventProcessor");
88767
88897
  /**
88768
88898
  * Processes durable events for wallets based on their active sessions and enabled event types
88769
88899
  */
@@ -88798,14 +88928,14 @@ var StorageEventProcessor = class {
88798
88928
  */
88799
88929
  async startProcessing(walletId) {
88800
88930
  if (this.processorConfig.disableEvents) return;
88801
- if (walletId) if (this.registeredWallets.has(walletId)) log$20.debug("Processing already registered for wallet", { walletId });
88931
+ if (walletId) if (this.registeredWallets.has(walletId)) log$21.debug("Processing already registered for wallet", { walletId });
88802
88932
  else {
88803
88933
  this.registeredWallets.add(walletId);
88804
- log$20.info("Registered wallet for event processing", { walletId });
88934
+ log$21.info("Registered wallet for event processing", { walletId });
88805
88935
  }
88806
88936
  if (!this.isProcessing) {
88807
88937
  this.isProcessing = true;
88808
- log$20.info("Started global event processing loop");
88938
+ log$21.info("Started global event processing loop");
88809
88939
  this.processEventsLoop();
88810
88940
  } else this.triggerProcessing();
88811
88941
  }
@@ -88816,7 +88946,7 @@ var StorageEventProcessor = class {
88816
88946
  if (this.processorConfig.disableEvents) return;
88817
88947
  if (walletId) {
88818
88948
  this.registeredWallets.delete(walletId);
88819
- log$20.info("Unregistered wallet from event processing", { walletId });
88949
+ log$21.info("Unregistered wallet from event processing", { walletId });
88820
88950
  }
88821
88951
  if (this.registeredWallets.size === 0 && this.isProcessing && !walletId) {
88822
88952
  this.isProcessing = false;
@@ -88824,12 +88954,12 @@ var StorageEventProcessor = class {
88824
88954
  this.wakeUpResolver();
88825
88955
  this.wakeUpResolver = void 0;
88826
88956
  }
88827
- log$20.info("Stopped global event processing loop (no more wallets)");
88957
+ log$21.info("Stopped global event processing loop (no more wallets)");
88828
88958
  }
88829
88959
  }
88830
88960
  async clearRegisteredWallets() {
88831
88961
  this.registeredWallets.clear();
88832
- log$20.info("Cleared registered wallets from event processing");
88962
+ log$21.info("Cleared registered wallets from event processing");
88833
88963
  }
88834
88964
  /**
88835
88965
  * Process next available event from any source (wallet or no-wallet)
@@ -88859,7 +88989,7 @@ var StorageEventProcessor = class {
88859
88989
  const walletId = allSessions.find((s) => s.sessionId === eventToUse.sessionId)?.walletId || "no-wallet";
88860
88990
  return await this.processEvent(eventToUse, walletId);
88861
88991
  } catch (error) {
88862
- log$20.error("Error in processNextAvailableEvent", { error: error.message });
88992
+ log$21.error("Error in processNextAvailableEvent", { error: error.message });
88863
88993
  return false;
88864
88994
  }
88865
88995
  }
@@ -88869,9 +88999,9 @@ var StorageEventProcessor = class {
88869
88999
  async completeEvent(eventId) {
88870
89000
  try {
88871
89001
  await this.eventStore.updateEventStatus(eventId, "completed", "processing");
88872
- log$20.debug("Event marked as completed", { eventId });
89002
+ log$21.debug("Event marked as completed", { eventId });
88873
89003
  } catch (error) {
88874
- log$20.error("Failed to mark event as completed", {
89004
+ log$21.error("Failed to mark event as completed", {
88875
89005
  eventId,
88876
89006
  error: error.message
88877
89007
  });
@@ -88882,14 +89012,14 @@ var StorageEventProcessor = class {
88882
89012
  */
88883
89013
  startRecoveryLoop() {
88884
89014
  if (this.recoveryTimeoutId) {
88885
- log$20.debug("Recovery loop already running");
89015
+ log$21.debug("Recovery loop already running");
88886
89016
  return;
88887
89017
  }
88888
89018
  const recoveryLoop = async () => {
88889
89019
  try {
88890
89020
  if (await this.eventStore.recoverStaleEvents(this.config.processingTimeoutMs) > 0) this.triggerProcessing();
88891
89021
  } catch (error) {
88892
- log$20.error("Error in recovery loop", { error: error.message });
89022
+ log$21.error("Error in recovery loop", { error: error.message });
88893
89023
  }
88894
89024
  if (this.recoveryTimeoutId !== void 0) this.recoveryTimeoutId = setTimeout(recoveryLoop, this.config.recoveryIntervalMs);
88895
89025
  };
@@ -88897,13 +89027,13 @@ var StorageEventProcessor = class {
88897
89027
  try {
88898
89028
  await this.eventStore.cleanupOldEvents(this.config.retentionMs);
88899
89029
  } catch (error) {
88900
- log$20.error("Error in cleanup loop", { error: error.message });
89030
+ log$21.error("Error in cleanup loop", { error: error.message });
88901
89031
  }
88902
89032
  if (this.cleanupTimeoutId !== void 0) this.cleanupTimeoutId = setTimeout(cleanupLoop, this.config.cleanupIntervalMs);
88903
89033
  };
88904
89034
  this.recoveryTimeoutId = setTimeout(recoveryLoop, this.config.recoveryIntervalMs);
88905
89035
  this.cleanupTimeoutId = setTimeout(cleanupLoop, this.config.cleanupIntervalMs);
88906
- log$20.info("Recovery and cleanup loops started");
89036
+ log$21.info("Recovery and cleanup loops started");
88907
89037
  }
88908
89038
  /**
88909
89039
  * Stop the recovery process
@@ -88917,7 +89047,7 @@ var StorageEventProcessor = class {
88917
89047
  clearTimeout(this.cleanupTimeoutId);
88918
89048
  this.cleanupTimeoutId = void 0;
88919
89049
  }
88920
- log$20.info("Recovery and cleanup loops stopped");
89050
+ log$21.info("Recovery and cleanup loops stopped");
88921
89051
  }
88922
89052
  /**
88923
89053
  * Process a single event with retry logic
@@ -88925,7 +89055,7 @@ var StorageEventProcessor = class {
88925
89055
  */
88926
89056
  async processEvent(event, walletId) {
88927
89057
  if (!await this.eventStore.acquireLock(event.id, walletId)) {
88928
- log$20.debug("Failed to acquire lock on event", {
89058
+ log$21.debug("Failed to acquire lock on event", {
88929
89059
  eventId: event.id,
88930
89060
  walletId
88931
89061
  });
@@ -88933,7 +89063,7 @@ var StorageEventProcessor = class {
88933
89063
  }
88934
89064
  const retryCount = event.retryCount || 0;
88935
89065
  if (retryCount >= this.config.maxRetries) {
88936
- log$20.error("Event exceeded max retries, marking as errored", {
89066
+ log$21.error("Event exceeded max retries, marking as errored", {
88937
89067
  eventId: event.id,
88938
89068
  retryCount,
88939
89069
  maxRetries: this.config.maxRetries
@@ -88941,14 +89071,14 @@ var StorageEventProcessor = class {
88941
89071
  try {
88942
89072
  await this.eventStore.updateEventStatus(event.id, "errored", "processing");
88943
89073
  } catch (error) {
88944
- log$20.error("Failed to mark event as errored", {
89074
+ log$21.error("Failed to mark event as errored", {
88945
89075
  eventId: event.id,
88946
89076
  error: error.message
88947
89077
  });
88948
89078
  }
88949
89079
  return false;
88950
89080
  }
88951
- log$20.info("Processing event", {
89081
+ log$21.info("Processing event", {
88952
89082
  eventId: event.id,
88953
89083
  eventType: event.eventType,
88954
89084
  walletId,
@@ -88968,11 +89098,11 @@ var StorageEventProcessor = class {
88968
89098
  ...walletAddress ? { walletAddress } : {}
88969
89099
  });
88970
89100
  await this.eventStore.updateEventStatus(event.id, "completed", "processing");
88971
- log$20.info("Event processing completed", { eventId: event.id });
89101
+ log$21.info("Event processing completed", { eventId: event.id });
88972
89102
  return true;
88973
89103
  } catch (error) {
88974
89104
  const errorMessage = error.message ?? "Unknown error";
88975
- log$20.error("Error processing event", {
89105
+ log$21.error("Error processing event", {
88976
89106
  eventId: event.id,
88977
89107
  error: errorMessage,
88978
89108
  retryCount
@@ -88980,7 +89110,7 @@ var StorageEventProcessor = class {
88980
89110
  try {
88981
89111
  await this.eventStore.releaseLock(event.id, errorMessage);
88982
89112
  } catch (updateError) {
88983
- log$20.error("Failed to increment retry count", {
89113
+ log$21.error("Failed to increment retry count", {
88984
89114
  eventId: event.id,
88985
89115
  error: updateError.message
88986
89116
  });
@@ -88995,18 +89125,18 @@ var StorageEventProcessor = class {
88995
89125
  while (this.isProcessing) try {
88996
89126
  if (!await this.processNextAvailableEvent()) await this.waitForWakeUpOrTimeout(500);
88997
89127
  } catch (error) {
88998
- log$20.error("Error in global processing loop", { error: error.message });
89128
+ log$21.error("Error in global processing loop", { error: error.message });
88999
89129
  await this.waitForWakeUpOrTimeout(500);
89000
89130
  }
89001
89131
  this.wakeUpResolver = void 0;
89002
- log$20.debug("Global processing loop ended");
89132
+ log$21.debug("Global processing loop ended");
89003
89133
  }
89004
89134
  /**
89005
89135
  * Trigger the global processing loop
89006
89136
  */
89007
89137
  triggerProcessing() {
89008
89138
  if (this.isProcessing && this.wakeUpResolver) {
89009
- log$20.debug("Waking up global processing loop");
89139
+ log$21.debug("Waking up global processing loop");
89010
89140
  this.wakeUpResolver();
89011
89141
  }
89012
89142
  }
@@ -89049,7 +89179,7 @@ var StorageEventProcessor = class {
89049
89179
  * LICENSE file in the root directory of this source tree.
89050
89180
  *
89051
89181
  */
89052
- const log$19 = globalLogger.createChild("WalletTonClass");
89182
+ const log$20 = globalLogger.createChild("WalletTonClass");
89053
89183
  var WalletTonClass = class {
89054
89184
  async createTransferTonTransaction(param) {
89055
89185
  if (!isValidAddress(param.recipientAddress)) throw new Error(`Invalid to address: ${param.recipientAddress}`);
@@ -89110,7 +89240,7 @@ var WalletTonClass = class {
89110
89240
  normalizedHash
89111
89241
  };
89112
89242
  } catch (error) {
89113
- log$19.error("Failed to send transaction", { error });
89243
+ log$20.error("Failed to send transaction", { error });
89114
89244
  if (error instanceof WalletKitError) throw error;
89115
89245
  if (error?.message?.includes("Ledger device")) throw new WalletKitError(ERROR_CODES.LEDGER_DEVICE_ERROR, "Ledger device error", error);
89116
89246
  throw error;
@@ -89140,7 +89270,7 @@ var WalletJettonClass = class {
89140
89270
  payload: createJettonTransferPayload({
89141
89271
  amount: BigInt(params.transferAmount),
89142
89272
  destination: params.recipientAddress,
89143
- responseDestination: this.getAddress(),
89273
+ responseDestination: params.responseDestination || this.getAddress(),
89144
89274
  comment: params.comment
89145
89275
  }),
89146
89276
  fromAddress: this.getAddress()
@@ -89212,7 +89342,7 @@ var WalletNftClass = class {
89212
89342
  * LICENSE file in the root directory of this source tree.
89213
89343
  *
89214
89344
  */
89215
- const log$18 = globalLogger.createChild("Initializer");
89345
+ const log$19 = globalLogger.createChild("Initializer");
89216
89346
  /**
89217
89347
  * Handles initialization of all TonWalletKit components
89218
89348
  */
@@ -89231,12 +89361,12 @@ var Initializer = class {
89231
89361
  */
89232
89362
  async initialize(options, networkManager) {
89233
89363
  try {
89234
- log$18.info("Initializing TonWalletKit...");
89364
+ log$19.info("Initializing TonWalletKit...");
89235
89365
  this.networkManager = networkManager;
89236
89366
  const storage = this.initializeStorage(options);
89237
89367
  const { walletManager, sessionManager, bridgeManager, eventRouter, eventProcessor } = await this.initializeManagers(options, storage);
89238
89368
  const { requestProcessor } = this.initializeProcessors(sessionManager, bridgeManager, walletManager);
89239
- log$18.info("TonWalletKit initialized successfully");
89369
+ log$19.info("TonWalletKit initialized successfully");
89240
89370
  return {
89241
89371
  walletManager,
89242
89372
  sessionManager,
@@ -89247,7 +89377,7 @@ var Initializer = class {
89247
89377
  eventProcessor
89248
89378
  };
89249
89379
  } catch (error) {
89250
- log$18.error("Failed to initialize TonWalletKit", { error });
89380
+ log$19.error("Failed to initialize TonWalletKit", { error });
89251
89381
  throw error;
89252
89382
  }
89253
89383
  }
@@ -89283,9 +89413,9 @@ var Initializer = class {
89283
89413
  const bridgeManager = new BridgeManager(options?.walletManifest, options?.bridge, sessionManager, storage, eventStore, eventRouter, options, this.eventEmitter, this.analyticsManager);
89284
89414
  eventRouter.setBridgeManager(bridgeManager);
89285
89415
  bridgeManager.start().then(() => {
89286
- log$18.info("Bridge manager started successfully");
89416
+ log$19.info("Bridge manager started successfully");
89287
89417
  }).catch((e) => {
89288
- log$18.error("Could not start bridge manager", { error: e?.toString?.() });
89418
+ log$19.error("Could not start bridge manager", { error: e?.toString?.() });
89289
89419
  });
89290
89420
  const eventProcessor = new StorageEventProcessor(options?.eventProcessor, eventStore, DEFAULT_DURABLE_EVENTS_CONFIG, walletManager, sessionManager, eventRouter, this.eventEmitter);
89291
89421
  return {
@@ -89307,7 +89437,7 @@ var Initializer = class {
89307
89437
  */
89308
89438
  async cleanup(components) {
89309
89439
  try {
89310
- log$18.info("Cleaning up TonWalletKit components...");
89440
+ log$19.info("Cleaning up TonWalletKit components...");
89311
89441
  if (components.eventProcessor) {
89312
89442
  components.eventProcessor.stopRecoveryLoop();
89313
89443
  await components.eventProcessor.clearRegisteredWallets();
@@ -89315,9 +89445,9 @@ var Initializer = class {
89315
89445
  }
89316
89446
  if (components.bridgeManager) await components.bridgeManager.close();
89317
89447
  if (components.eventRouter) components.eventRouter.clearCallbacks();
89318
- log$18.info("TonWalletKit cleanup completed");
89448
+ log$19.info("TonWalletKit cleanup completed");
89319
89449
  } catch (error) {
89320
- log$18.error("Error during cleanup", { error });
89450
+ log$19.error("Error during cleanup", { error });
89321
89451
  }
89322
89452
  }
89323
89453
  };
@@ -89352,7 +89482,7 @@ async function wrapWalletInterface(wallet) {
89352
89482
  * LICENSE file in the root directory of this source tree.
89353
89483
  *
89354
89484
  */
89355
- const log$17 = globalLogger.createChild("JettonsManager");
89485
+ const log$18 = globalLogger.createChild("JettonsManager");
89356
89486
  const TON_ADDRESS = "TON";
89357
89487
  function isTonAddress(address) {
89358
89488
  return address.toLowerCase() === "ton";
@@ -89392,7 +89522,7 @@ var JettonsManager = class {
89392
89522
  ttl: 1e3 * 60 * 10
89393
89523
  });
89394
89524
  for (const network of this.networkManager.getConfiguredNetworks()) this.addTonToCache(network);
89395
- log$17.info("JettonsManager initialized", { cacheSize });
89525
+ log$18.info("JettonsManager initialized", { cacheSize });
89396
89526
  }
89397
89527
  /**
89398
89528
  * Add TON native token to cache for a specific network
@@ -89413,19 +89543,19 @@ var JettonsManager = class {
89413
89543
  const cacheKey = this.normalizedCacheKey(targetNetwork, jettonAddress);
89414
89544
  const cachedInfo = this.cache.get(cacheKey);
89415
89545
  if (cachedInfo) {
89416
- log$17.debug("Jetton info found in cache", {
89546
+ log$18.debug("Jetton info found in cache", {
89417
89547
  jettonAddress,
89418
89548
  network: targetNetwork
89419
89549
  });
89420
89550
  return cachedInfo;
89421
89551
  }
89422
- log$17.debug("Jetton info not found in cache", {
89552
+ log$18.debug("Jetton info not found in cache", {
89423
89553
  jettonAddress,
89424
89554
  network: targetNetwork
89425
89555
  });
89426
89556
  const address = asMaybeAddressFriendly(jettonAddress);
89427
89557
  if (!address) {
89428
- log$17.error("Invalid jetton address format", {
89558
+ log$18.error("Invalid jetton address format", {
89429
89559
  jettonAddress,
89430
89560
  network: targetNetwork
89431
89561
  });
@@ -89460,7 +89590,7 @@ var JettonsManager = class {
89460
89590
  }
89461
89591
  return null;
89462
89592
  } catch (error) {
89463
- log$17.error("Error getting jetton info", {
89593
+ log$18.error("Error getting jetton info", {
89464
89594
  error,
89465
89595
  jettonAddress,
89466
89596
  network: targetNetwork
@@ -89479,7 +89609,7 @@ var JettonsManager = class {
89479
89609
  const targetNetwork = network;
89480
89610
  try {
89481
89611
  const apiClient = this.networkManager.getClient(targetNetwork);
89482
- log$17.debug("Getting address jettons", {
89612
+ log$18.debug("Getting address jettons", {
89483
89613
  userAddress,
89484
89614
  network: targetNetwork,
89485
89615
  offset,
@@ -89493,13 +89623,13 @@ var JettonsManager = class {
89493
89623
  if (!response.jettons) return [];
89494
89624
  const addressJettons = [];
89495
89625
  for (const item of response.jettons) addressJettons.push(item);
89496
- log$17.debug("Retrieved address jettons", {
89626
+ log$18.debug("Retrieved address jettons", {
89497
89627
  count: addressJettons.length,
89498
89628
  network: targetNetwork
89499
89629
  });
89500
89630
  return addressJettons;
89501
89631
  } catch (error) {
89502
- log$17.error("Failed to get address jettons", {
89632
+ log$18.error("Failed to get address jettons", {
89503
89633
  error,
89504
89634
  userAddress,
89505
89635
  network: targetNetwork
@@ -89523,14 +89653,14 @@ var JettonsManager = class {
89523
89653
  uri: emulationInfo.extra.uri
89524
89654
  };
89525
89655
  this.cache.set(cacheKey, jettonInfo);
89526
- log$17.debug("Added jetton info from emulation to cache", {
89656
+ log$18.debug("Added jetton info from emulation to cache", {
89527
89657
  jettonAddress,
89528
89658
  network,
89529
89659
  name: jettonInfo.name,
89530
89660
  symbol: jettonInfo.symbol
89531
89661
  });
89532
89662
  } catch (error) {
89533
- log$17.error("Error adding jetton from emulation", {
89663
+ log$18.error("Error adding jetton from emulation", {
89534
89664
  error,
89535
89665
  jettonAddress,
89536
89666
  network
@@ -89547,7 +89677,7 @@ var JettonsManager = class {
89547
89677
  if (!addressMetadata.is_indexed || !addressMetadata.token_info) continue;
89548
89678
  const jettonMasterInfo = addressMetadata.token_info.find((info) => typeof info === "object" && info !== null && "type" in info && info.type === "jetton_masters");
89549
89679
  if (jettonMasterInfo) {
89550
- log$17.debug("Adding jetton from emulation metadata", {
89680
+ log$18.debug("Adding jetton from emulation metadata", {
89551
89681
  jettonAddress,
89552
89682
  network
89553
89683
  });
@@ -89555,12 +89685,12 @@ var JettonsManager = class {
89555
89685
  addedCount++;
89556
89686
  }
89557
89687
  }
89558
- if (addedCount > 0) log$17.info("Added jettons from emulation metadata", {
89688
+ if (addedCount > 0) log$18.info("Added jettons from emulation metadata", {
89559
89689
  addedCount,
89560
89690
  network
89561
89691
  });
89562
89692
  } catch (error) {
89563
- log$17.error("Error adding jettons from emulation metadata", {
89693
+ log$18.error("Error adding jettons from emulation metadata", {
89564
89694
  error,
89565
89695
  network
89566
89696
  });
@@ -89601,11 +89731,11 @@ var JettonsManager = class {
89601
89731
  if (network) {
89602
89732
  for (const key of this.cache.keys()) if (key.startsWith(`${network.chainId}:`)) this.cache.delete(key);
89603
89733
  this.addTonToCache(network);
89604
- log$17.info("Jetton cache cleared for network", { network });
89734
+ log$18.info("Jetton cache cleared for network", { network });
89605
89735
  } else {
89606
89736
  this.cache.clear();
89607
89737
  for (const net of this.networkManager.getConfiguredNetworks()) this.addTonToCache(net);
89608
- log$17.info("Jetton cache cleared for all networks");
89738
+ log$18.info("Jetton cache cleared for all networks");
89609
89739
  }
89610
89740
  }
89611
89741
  };
@@ -89805,7 +89935,7 @@ var DefiManager = class {
89805
89935
  * LICENSE file in the root directory of this source tree.
89806
89936
  *
89807
89937
  */
89808
- const log$16 = globalLogger.createChild("SwapManager");
89938
+ const log$17 = globalLogger.createChild("SwapManager");
89809
89939
  /**
89810
89940
  * SwapManager - manages swap providers and delegates swap operations
89811
89941
  *
@@ -89823,7 +89953,7 @@ var SwapManager = class extends DefiManager {
89823
89953
  * @returns Promise resolving to swap quote
89824
89954
  */
89825
89955
  async getQuote(params, providerId) {
89826
- log$16.debug("Getting swap quote", {
89956
+ log$17.debug("Getting swap quote", {
89827
89957
  fromToken: params.from,
89828
89958
  toToken: params.to,
89829
89959
  amount: params.amount,
@@ -89832,14 +89962,14 @@ var SwapManager = class extends DefiManager {
89832
89962
  });
89833
89963
  try {
89834
89964
  const quote = await this.getProvider(providerId || this.defaultProviderId).getQuote(params);
89835
- log$16.debug("Received swap quote", {
89965
+ log$17.debug("Received swap quote", {
89836
89966
  fromAmount: quote.fromAmount,
89837
89967
  toAmount: quote.toAmount,
89838
89968
  priceImpact: quote.priceImpact
89839
89969
  });
89840
89970
  return quote;
89841
89971
  } catch (error) {
89842
- log$16.error("Failed to get swap quote", {
89972
+ log$17.error("Failed to get swap quote", {
89843
89973
  error,
89844
89974
  params
89845
89975
  });
@@ -89853,16 +89983,16 @@ var SwapManager = class extends DefiManager {
89853
89983
  */
89854
89984
  async buildSwapTransaction(params) {
89855
89985
  const providerId = params.quote.providerId || this.defaultProviderId;
89856
- log$16.debug("Building swap transaction", {
89986
+ log$17.debug("Building swap transaction", {
89857
89987
  providerId,
89858
89988
  userAddress: params.userAddress
89859
89989
  });
89860
89990
  try {
89861
89991
  const transaction = await this.getProvider(providerId).buildSwapTransaction(params);
89862
- log$16.debug("Built swap transaction", params.quote);
89992
+ log$17.debug("Built swap transaction", params.quote);
89863
89993
  return transaction;
89864
89994
  } catch (error) {
89865
- log$16.error("Failed to build swap transaction", {
89995
+ log$17.error("Failed to build swap transaction", {
89866
89996
  error,
89867
89997
  params
89868
89998
  });
@@ -89904,7 +90034,7 @@ var StakingError = class extends DefiError {
89904
90034
  * LICENSE file in the root directory of this source tree.
89905
90035
  *
89906
90036
  */
89907
- const log$15 = globalLogger.createChild("StakingManager");
90037
+ const log$16 = globalLogger.createChild("StakingManager");
89908
90038
  /**
89909
90039
  * StakingManager - manages staking providers and delegates staking operations
89910
90040
  *
@@ -89921,13 +90051,13 @@ var StakingManager = class extends DefiManager {
89921
90051
  * @param providerId - Optional provider id to use
89922
90052
  */
89923
90053
  async getQuote(params, providerId) {
89924
- log$15.debug("Getting staking quote", params);
90054
+ log$16.debug("Getting staking quote", params);
89925
90055
  try {
89926
90056
  const quote = await this.getProvider(providerId).getQuote(params);
89927
- log$15.debug("Received staking quote", quote);
90057
+ log$16.debug("Received staking quote", quote);
89928
90058
  return quote;
89929
90059
  } catch (error) {
89930
- log$15.error("Failed to get staking quote", {
90060
+ log$16.error("Failed to get staking quote", {
89931
90061
  error,
89932
90062
  params
89933
90063
  });
@@ -89940,11 +90070,11 @@ var StakingManager = class extends DefiManager {
89940
90070
  * @param providerId - Optional provider id to use
89941
90071
  */
89942
90072
  async buildStakeTransaction(params, providerId) {
89943
- log$15.debug("Building staking transaction", params);
90073
+ log$16.debug("Building staking transaction", params);
89944
90074
  try {
89945
90075
  return await this.getProvider(providerId).buildStakeTransaction(params);
89946
90076
  } catch (error) {
89947
- log$15.error("Failed to build staking transaction", {
90077
+ log$16.error("Failed to build staking transaction", {
89948
90078
  error,
89949
90079
  params
89950
90080
  });
@@ -89958,7 +90088,7 @@ var StakingManager = class extends DefiManager {
89958
90088
  * @param providerId - Optional provider id to use
89959
90089
  */
89960
90090
  async getStakedBalance(userAddress, network, providerId) {
89961
- log$15.debug("Getting staking balance", {
90091
+ log$16.debug("Getting staking balance", {
89962
90092
  userAddress,
89963
90093
  network,
89964
90094
  provider: providerId || this.defaultProviderId
@@ -89966,7 +90096,7 @@ var StakingManager = class extends DefiManager {
89966
90096
  try {
89967
90097
  return await this.getProvider(providerId).getStakedBalance(userAddress, network);
89968
90098
  } catch (error) {
89969
- log$15.error("Failed to get staking balance", {
90099
+ log$16.error("Failed to get staking balance", {
89970
90100
  error,
89971
90101
  userAddress,
89972
90102
  network
@@ -89980,14 +90110,14 @@ var StakingManager = class extends DefiManager {
89980
90110
  * @param providerId - Optional provider id to use
89981
90111
  */
89982
90112
  async getStakingProviderInfo(network, providerId) {
89983
- log$15.debug("Getting staking info", {
90113
+ log$16.debug("Getting staking info", {
89984
90114
  network,
89985
90115
  provider: providerId || this.defaultProviderId
89986
90116
  });
89987
90117
  try {
89988
90118
  return await this.getProvider(providerId).getStakingProviderInfo(network);
89989
90119
  } catch (error) {
89990
- log$15.error("Failed to get staking info", {
90120
+ log$16.error("Failed to get staking info", {
89991
90121
  error,
89992
90122
  network
89993
90123
  });
@@ -90000,14 +90130,14 @@ var StakingManager = class extends DefiManager {
90000
90130
  * @param providerId - Optional provider id to use
90001
90131
  */
90002
90132
  getStakingProviderMetadata(network, providerId) {
90003
- log$15.debug("Getting staking metadata", {
90133
+ log$16.debug("Getting staking metadata", {
90004
90134
  network,
90005
90135
  provider: providerId || this.defaultProviderId
90006
90136
  });
90007
90137
  try {
90008
90138
  return this.getProvider(providerId).getStakingProviderMetadata(network);
90009
90139
  } catch (error) {
90010
- log$15.error("Failed to get staking metadata", {
90140
+ log$16.error("Failed to get staking metadata", {
90011
90141
  error,
90012
90142
  network
90013
90143
  });
@@ -90016,7 +90146,7 @@ var StakingManager = class extends DefiManager {
90016
90146
  }
90017
90147
  createError(message, code, details) {
90018
90148
  const errorCode = Object.values(StakingErrorCode).includes(code) ? code : StakingErrorCode.InvalidParams;
90019
- log$15.error(message, {
90149
+ log$16.error(message, {
90020
90150
  code,
90021
90151
  details
90022
90152
  });
@@ -90024,6 +90154,128 @@ var StakingManager = class extends DefiManager {
90024
90154
  }
90025
90155
  };
90026
90156
  //#endregion
90157
+ //#region ../walletkit/dist/esm/defi/gasless/errors.js
90158
+ /**
90159
+ * Copyright (c) TonTech.
90160
+ *
90161
+ * This source code is licensed under the MIT license found in the
90162
+ * LICENSE file in the root directory of this source tree.
90163
+ *
90164
+ */
90165
+ var GaslessErrorCode;
90166
+ (function(GaslessErrorCode) {
90167
+ GaslessErrorCode["UnsupportedFeeAsset"] = "UNSUPPORTED_FEE_ASSET";
90168
+ GaslessErrorCode["UnsupportedOperation"] = "UNSUPPORTED_OPERATION";
90169
+ GaslessErrorCode["QuoteFailed"] = "QUOTE_FAILED";
90170
+ GaslessErrorCode["SendFailed"] = "SEND_FAILED";
90171
+ GaslessErrorCode["ConfigFailed"] = "CONFIG_FAILED";
90172
+ GaslessErrorCode["SignMessageNotSupported"] = "SIGN_MESSAGE_NOT_SUPPORTED";
90173
+ GaslessErrorCode["TooManyMessages"] = "TOO_MANY_MESSAGES";
90174
+ GaslessErrorCode["QuoteExpired"] = "QUOTE_EXPIRED";
90175
+ GaslessErrorCode["WalletMismatch"] = "WALLET_MISMATCH";
90176
+ GaslessErrorCode["FeeAssetNotOwned"] = "FEE_ASSET_NOT_OWNED";
90177
+ })(GaslessErrorCode || (GaslessErrorCode = {}));
90178
+ var GaslessError = class extends DefiError {
90179
+ code;
90180
+ constructor(message, code, details) {
90181
+ super(message, code, details);
90182
+ this.name = "GaslessError";
90183
+ this.code = code;
90184
+ }
90185
+ };
90186
+ //#endregion
90187
+ //#region ../walletkit/dist/esm/defi/gasless/GaslessManager.js
90188
+ /**
90189
+ * Copyright (c) TonTech.
90190
+ *
90191
+ * This source code is licensed under the MIT license found in the
90192
+ * LICENSE file in the root directory of this source tree.
90193
+ *
90194
+ */
90195
+ const log$15 = globalLogger.createChild("GaslessManager");
90196
+ /**
90197
+ * GaslessManager — manages gasless relay providers and delegates gasless operations.
90198
+ *
90199
+ * Allows registration of multiple gasless providers and provides a unified API.
90200
+ * Providers can be switched dynamically.
90201
+ */
90202
+ var GaslessManager = class extends DefiManager {
90203
+ constructor(createFactoryContext) {
90204
+ super(createFactoryContext);
90205
+ }
90206
+ /**
90207
+ * Get static metadata for a gasless provider (display name, logo, url).
90208
+ */
90209
+ async getMetadata(providerId) {
90210
+ const selectedProviderId = providerId ?? this.defaultProviderId;
90211
+ log$15.debug("Getting gasless provider metadata", { providerId: selectedProviderId });
90212
+ try {
90213
+ return await this.getProvider(selectedProviderId).getMetadata();
90214
+ } catch (error) {
90215
+ log$15.error("Failed to get gasless provider metadata", { error });
90216
+ throw error;
90217
+ }
90218
+ }
90219
+ /**
90220
+ * Fetch the relayer's configuration (relay address + accepted fee assets).
90221
+ *
90222
+ * `network` defaults to the provider's first supported network.
90223
+ */
90224
+ async getConfig(network, providerId) {
90225
+ const provider = this.getProvider(providerId ?? this.defaultProviderId);
90226
+ const targetNetwork = network ?? provider.getSupportedNetworks()[0];
90227
+ log$15.debug("Getting gasless config", {
90228
+ network: targetNetwork?.chainId,
90229
+ providerId: providerId ?? this.defaultProviderId
90230
+ });
90231
+ try {
90232
+ return await provider.getConfig(targetNetwork);
90233
+ } catch (error) {
90234
+ log$15.error("Failed to get gasless config", { error });
90235
+ throw error;
90236
+ }
90237
+ }
90238
+ /**
90239
+ * Quote fees and obtain relayer-wrapped messages for signing.
90240
+ */
90241
+ async getQuote(params, providerId) {
90242
+ log$15.debug("Quoting gasless transaction", {
90243
+ network: params.network.chainId,
90244
+ walletAddress: params.walletAddress,
90245
+ feeAsset: params.feeAsset,
90246
+ messagesCount: params.messages.length,
90247
+ providerId: providerId ?? this.defaultProviderId
90248
+ });
90249
+ try {
90250
+ return await this.getProvider(providerId ?? this.defaultProviderId).getQuote(params);
90251
+ } catch (error) {
90252
+ log$15.error("Failed to quote gasless transaction", {
90253
+ error,
90254
+ params
90255
+ });
90256
+ throw error;
90257
+ }
90258
+ }
90259
+ /**
90260
+ * Submit a signed transaction BoC to the relayer.
90261
+ */
90262
+ async sendTransaction(params, providerId) {
90263
+ log$15.debug("Sending gasless transaction", {
90264
+ network: params.network.chainId,
90265
+ providerId: providerId ?? this.defaultProviderId
90266
+ });
90267
+ try {
90268
+ return await this.getProvider(providerId ?? this.defaultProviderId).sendTransaction(params);
90269
+ } catch (error) {
90270
+ log$15.error("Failed to send gasless transaction", { error });
90271
+ throw error;
90272
+ }
90273
+ }
90274
+ createError(message, code, details) {
90275
+ return new GaslessError(message, code, details);
90276
+ }
90277
+ };
90278
+ //#endregion
90027
90279
  //#region ../walletkit/dist/esm/core/EventEmitter.js
90028
90280
  /**
90029
90281
  * Copyright (c) TonTech.
@@ -91815,6 +92067,7 @@ var TonWalletKit = class {
91815
92067
  swapManager;
91816
92068
  streamingManager;
91817
92069
  stakingManager;
92070
+ gaslessManager;
91818
92071
  initializer;
91819
92072
  eventProcessor;
91820
92073
  bridgeManager;
@@ -91841,6 +92094,7 @@ var TonWalletKit = class {
91841
92094
  this.jettonsManager = new JettonsManager(1e4, this.eventEmitter, this.networkManager);
91842
92095
  this.swapManager = new SwapManager(() => this.createFactoryContext());
91843
92096
  this.stakingManager = new StakingManager(() => this.createFactoryContext());
92097
+ this.gaslessManager = new GaslessManager(() => this.createFactoryContext());
91844
92098
  this.eventEmitter.on("restoreConnection", async ({ payload: event }) => {
91845
92099
  if (!event.domain) {
91846
92100
  log$8.error("Domain is required for restore connection");
@@ -92327,6 +92581,9 @@ var TonWalletKit = class {
92327
92581
  case "streaming":
92328
92582
  this.streamingManager.registerProvider(provider);
92329
92583
  break;
92584
+ case "gasless":
92585
+ this.gaslessManager.registerProvider(provider);
92586
+ break;
92330
92587
  default: throw new Error("Unknown provider type");
92331
92588
  }
92332
92589
  }
@@ -92361,6 +92618,12 @@ var TonWalletKit = class {
92361
92618
  return this.stakingManager;
92362
92619
  }
92363
92620
  /**
92621
+ * Gasless API access
92622
+ */
92623
+ get gasless() {
92624
+ return this.gaslessManager;
92625
+ }
92626
+ /**
92364
92627
  * Get the event emitter for this kit instance
92365
92628
  * Allows external components to listen to and emit events
92366
92629
  */