@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.
@@ -9257,40 +9257,84 @@ var require_nacl_fast = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9257
9257
  })(typeof module !== "undefined" && module.exports ? module.exports : self.nacl = self.nacl || {});
9258
9258
  }));
9259
9259
  //#endregion
9260
- //#region ../../node_modules/.pnpm/@tonconnect+protocol@2.5.0-alpha.1/node_modules/@tonconnect/protocol/lib/esm/index.mjs
9260
+ //#region ../../node_modules/.pnpm/@tonconnect+protocol@3.0.0/node_modules/@tonconnect/protocol/lib/esm/index.mjs
9261
9261
  var import_nacl_util = /* @__PURE__ */ __toESM(require_nacl_util(), 1);
9262
9262
  var import_nacl_fast = /* @__PURE__ */ __toESM(require_nacl_fast(), 1);
9263
+ /**
9264
+ * Error codes the wallet may return in {@link ConnectEventError}.
9265
+ *
9266
+ * @see [Connect event error codes (Connect spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/connect.md#connect-event-error-codes)
9267
+ */
9263
9268
  var CONNECT_EVENT_ERROR_CODES$1;
9264
9269
  (function(CONNECT_EVENT_ERROR_CODES) {
9270
+ /** Unexpected wallet-side failure. */
9265
9271
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9272
+ /** Request payload is malformed. */
9266
9273
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
9274
+ /** Wallet could not fetch the `tonconnect-manifest.json`. */
9267
9275
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["MANIFEST_NOT_FOUND_ERROR"] = 2] = "MANIFEST_NOT_FOUND_ERROR";
9276
+ /** Manifest was fetched but fails JSON / schema validation. */
9268
9277
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["MANIFEST_CONTENT_ERROR"] = 3] = "MANIFEST_CONTENT_ERROR";
9278
+ /** Wallet does not know the app / session. */
9269
9279
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9280
+ /** User explicitly declined the connect prompt. */
9270
9281
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
9282
+ /** Wallet does not support the requested method. */
9271
9283
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9272
9284
  })(CONNECT_EVENT_ERROR_CODES$1 || (CONNECT_EVENT_ERROR_CODES$1 = {}));
9285
+ /**
9286
+ * Per-item error codes returned inside a {@link ConnectItemReplyError}.
9287
+ *
9288
+ * @see [Connect item error codes (Connect spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/connect.md#connect-item-error-codes)
9289
+ */
9273
9290
  var CONNECT_ITEM_ERROR_CODES$1;
9274
9291
  (function(CONNECT_ITEM_ERROR_CODES) {
9292
+ /** Unexpected wallet-side failure. */
9275
9293
  CONNECT_ITEM_ERROR_CODES[CONNECT_ITEM_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9294
+ /** Wallet does not support this connect item. */
9276
9295
  CONNECT_ITEM_ERROR_CODES[CONNECT_ITEM_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9277
9296
  })(CONNECT_ITEM_ERROR_CODES$1 || (CONNECT_ITEM_ERROR_CODES$1 = {}));
9297
+ /**
9298
+ * Error codes the wallet may return from `sendTransaction`.
9299
+ *
9300
+ * @see [`sendTransaction` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#sendtransaction)
9301
+ */
9278
9302
  var SEND_TRANSACTION_ERROR_CODES$1;
9279
9303
  (function(SEND_TRANSACTION_ERROR_CODES) {
9304
+ /** Unexpected wallet-side failure. */
9280
9305
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9306
+ /** Request payload is malformed. */
9281
9307
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
9308
+ /** Wallet does not know the dApp / session. */
9282
9309
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9310
+ /** User explicitly declined the transaction. */
9283
9311
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
9312
+ /** Wallet does not support the method. */
9284
9313
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9285
9314
  })(SEND_TRANSACTION_ERROR_CODES$1 || (SEND_TRANSACTION_ERROR_CODES$1 = {}));
9315
+ /**
9316
+ * Error codes the wallet may return from `signData`.
9317
+ *
9318
+ * @see [`signData` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#signdata)
9319
+ */
9286
9320
  var SIGN_DATA_ERROR_CODES$1;
9287
9321
  (function(SIGN_DATA_ERROR_CODES) {
9322
+ /** Unexpected wallet-side failure. */
9288
9323
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9324
+ /** Invalid request payload. */
9289
9325
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
9326
+ /** Wallet does not know the dApp / session. */
9290
9327
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9328
+ /** User explicitly declined. */
9291
9329
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
9330
+ /** Wallet does not support `signData` method or the requested `type`. */
9292
9331
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9293
9332
  })(SIGN_DATA_ERROR_CODES$1 || (SIGN_DATA_ERROR_CODES$1 = {}));
9333
+ /**
9334
+ * Error codes the wallet may return from `disconnect`.
9335
+
9336
+ * @see [`disconnect` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#disconnect)
9337
+ */
9294
9338
  var DISCONNECT_ERROR_CODES$1;
9295
9339
  (function(DISCONNECT_ERROR_CODES) {
9296
9340
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
@@ -9298,14 +9342,27 @@ var DISCONNECT_ERROR_CODES$1;
9298
9342
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9299
9343
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9300
9344
  })(DISCONNECT_ERROR_CODES$1 || (DISCONNECT_ERROR_CODES$1 = {}));
9345
+ /**
9346
+ * Error codes the wallet may return from `signMessage`.
9347
+ *
9348
+ * @see [`signMessage` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#signmessage)
9349
+ */
9301
9350
  var SIGN_MESSAGE_ERROR_CODES;
9302
9351
  (function(SIGN_MESSAGE_ERROR_CODES) {
9352
+ /** Unexpected wallet-side failure. */
9303
9353
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9354
+ /** Invalid request payload. */
9304
9355
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
9356
+ /** Wallet does not know the dApp / session. */
9305
9357
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9358
+ /** User explicitly declined. */
9306
9359
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
9360
+ /** Wallet does not support `signMessage`. */
9307
9361
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9308
9362
  })(SIGN_MESSAGE_ERROR_CODES || (SIGN_MESSAGE_ERROR_CODES = {}));
9363
+ /**
9364
+ * Two baseline TON network IDs.
9365
+ */
9309
9366
  var CHAIN$1;
9310
9367
  (function(CHAIN) {
9311
9368
  CHAIN["MAINNET"] = "-239";
@@ -9347,6 +9404,20 @@ function decode$1(value, urlSafe = false) {
9347
9404
  }
9348
9405
  };
9349
9406
  }
9407
+ /**
9408
+ * UTF-8 base64 codec used by `@tonconnect/protocol`. Wraps the NaCl
9409
+ * helpers with optional URL-safe encoding and a typed decoder that can
9410
+ * yield a string, an object (JSON-parsed), or the raw byte array.
9411
+ *
9412
+ * @example
9413
+ * ```ts
9414
+ * import { Base64 } from '@tonconnect/protocol';
9415
+ *
9416
+ * const encoded = Base64.encode({ hello: 'world' });
9417
+ * const obj = Base64.decode(encoded).toObject<{ hello: string }>();
9418
+ * const bin = Base64.decode(Base64.encode('Hello')).toUint8Array();
9419
+ * ```
9420
+ */
9350
9421
  const Base64$1 = {
9351
9422
  encode: encode$1,
9352
9423
  decode: decode$1
@@ -9470,16 +9541,22 @@ function decodeEmbeddedRequestParam(reqParam) {
9470
9541
  const json = fromBase64Url(reqParam);
9471
9542
  return decodeWireEmbeddedRequest(JSON.parse(json));
9472
9543
  }
9544
+ /** Concatenate two byte arrays into a new `Uint8Array`. */
9473
9545
  function concatUint8Arrays(buffer1, buffer2) {
9474
9546
  const mergedArray = new Uint8Array(buffer1.length + buffer2.length);
9475
9547
  mergedArray.set(buffer1);
9476
9548
  mergedArray.set(buffer2, buffer1.length);
9477
9549
  return mergedArray;
9478
9550
  }
9551
+ /**
9552
+ * Split `array` at `index` and return the two halves as fresh
9553
+ * `Uint8Array`s.
9554
+ */
9479
9555
  function splitToUint8Arrays(array, index) {
9480
9556
  if (index >= array.length) throw new Error("Index is out of buffer");
9481
9557
  return [array.slice(0, index), array.slice(index)];
9482
9558
  }
9559
+ /** Hex-encode a byte array, lowercase, no `0x` prefix. */
9483
9560
  function toHexString(byteArray) {
9484
9561
  let hexString = "";
9485
9562
  byteArray.forEach((byte) => {
@@ -9487,13 +9564,52 @@ function toHexString(byteArray) {
9487
9564
  });
9488
9565
  return hexString;
9489
9566
  }
9567
+ /**
9568
+ * Inverse of {@link toHexString}. Throws when `hexString` has an odd length.
9569
+ */
9490
9570
  function hexToByteArray$1(hexString) {
9491
9571
  if (hexString.length % 2 !== 0) throw new Error(`Cannot convert ${hexString} to bytesArray`);
9492
9572
  const result = new Uint8Array(hexString.length / 2);
9493
9573
  for (let i = 0; i < hexString.length; i += 2) result[i / 2] = parseInt(hexString.slice(i, i + 2), 16);
9494
9574
  return result;
9495
9575
  }
9576
+ /**
9577
+ * Implements the TON Connect session-encryption protocol on top of NaCl's
9578
+ * `crypto_box`.
9579
+ *
9580
+ * The protocol is symmetric: each side encrypts the messages it sends and
9581
+ * decrypts the messages it receives. On the dApp side that means encrypting
9582
+ * outgoing {@link AppMessage} and decrypting incoming {@link WalletMessage};
9583
+ * the wallet does the reverse.
9584
+ *
9585
+ * @example
9586
+ * ```ts
9587
+ * import { SessionCrypto, Base64, hexToByteArray } from '@tonconnect/protocol';
9588
+ *
9589
+ * // Generate a fresh session
9590
+ * const session = new SessionCrypto();
9591
+ * const myClientId = session.sessionId; // hex public key (sent to the peer)
9592
+ *
9593
+ * // Encrypt an outgoing message for the peer
9594
+ * const ciphertext = session.encrypt(
9595
+ * JSON.stringify(message),
9596
+ * hexToByteArray(peerClientId)
9597
+ * );
9598
+ *
9599
+ * // Decrypt an incoming message from the peer
9600
+ * const plaintext = session.decrypt(
9601
+ * Base64.decode(bridgeMessage.message).toUint8Array(),
9602
+ * hexToByteArray(bridgeMessage.from)
9603
+ * );
9604
+ * ```
9605
+ *
9606
+ * @see [Session protocol (Session spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/session.md)
9607
+ */
9496
9608
  var SessionCrypto = class {
9609
+ /**
9610
+ * Reuse an existing {@link KeyPair} (resuming a session) or generate a
9611
+ * fresh one (`crypto_box.keyPair()`) when omitted.
9612
+ */
9497
9613
  constructor(keyPair) {
9498
9614
  this.nonceLength = 24;
9499
9615
  this.keyPair = keyPair ? this.createKeypairFromString(keyPair) : this.createKeypair();
@@ -9511,17 +9627,31 @@ var SessionCrypto = class {
9511
9627
  createNonce() {
9512
9628
  return import_nacl_fast.default.randomBytes(this.nonceLength);
9513
9629
  }
9630
+ /**
9631
+ * Encrypt `message` for `receiverPublicKey` using a fresh 24-byte random
9632
+ * nonce. Returns `nonce || ciphertext` as raw bytes; base64-encode this
9633
+ * value before placing it in the bridge `POST /message` body.
9634
+ */
9514
9635
  encrypt(message, receiverPublicKey) {
9515
9636
  const encodedMessage = new TextEncoder().encode(message);
9516
9637
  const nonce = this.createNonce();
9517
9638
  return concatUint8Arrays(nonce, import_nacl_fast.default.box(encodedMessage, nonce, receiverPublicKey, this.keyPair.secretKey));
9518
9639
  }
9640
+ /**
9641
+ * Decrypt the `nonce || ciphertext` blob received from the bridge.
9642
+ * Throws if `nacl.box.open` rejects the message — wrong key, truncated
9643
+ * input or tampered ciphertext.
9644
+ */
9519
9645
  decrypt(message, senderPublicKey) {
9520
9646
  const [nonce, internalMessage] = splitToUint8Arrays(message, this.nonceLength);
9521
9647
  const decrypted = import_nacl_fast.default.box.open(internalMessage, nonce, senderPublicKey, this.keyPair.secretKey);
9522
9648
  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()}`);
9523
9649
  return new TextDecoder().decode(decrypted);
9524
9650
  }
9651
+ /**
9652
+ * Export the underlying keypair as a {@link KeyPair} of hex strings.
9653
+ * Persist this in dApp / wallet storage to resume the session later.
9654
+ */
9525
9655
  stringifyKeypair() {
9526
9656
  return {
9527
9657
  publicKey: toHexString(this.keyPair.publicKey),
@@ -30124,7 +30254,7 @@ async function CallForSuccess(toCall, attempts = 20, delayMs = 100, shouldRetry)
30124
30254
  return await toCall();
30125
30255
  } catch (err) {
30126
30256
  lastError = err;
30127
- if (shouldRetry && !shouldRetry(err)) throw err;
30257
+ if (typeof shouldRetry === "function" && shouldRetry(err) === false) throw err;
30128
30258
  i++;
30129
30259
  await delay(delayMs);
30130
30260
  }
@@ -30245,7 +30375,7 @@ var MemoryStorageAdapter = class {
30245
30375
  * LICENSE file in the root directory of this source tree.
30246
30376
  *
30247
30377
  */
30248
- const log$36 = globalLogger.createChild("StorageAdapter");
30378
+ const log$37 = globalLogger.createChild("StorageAdapter");
30249
30379
  /**
30250
30380
  * Create storage adapter based on environment and preferences
30251
30381
  */
@@ -30253,7 +30383,7 @@ function createStorageAdapter(config = {}) {
30253
30383
  if (typeof localStorage !== "undefined") try {
30254
30384
  return new LocalStorageAdapter(config);
30255
30385
  } catch (error) {
30256
- log$36.warn("Failed to create LocalStorageAdapter, falling back to memory", { error });
30386
+ log$37.warn("Failed to create LocalStorageAdapter, falling back to memory", { error });
30257
30387
  }
30258
30388
  if (config.allowMemory) return new MemoryStorageAdapter(config);
30259
30389
  else throw new Error("No storage adapter available");
@@ -30267,7 +30397,7 @@ function createStorageAdapter(config = {}) {
30267
30397
  * LICENSE file in the root directory of this source tree.
30268
30398
  *
30269
30399
  */
30270
- const log$35 = globalLogger.createChild("Storage");
30400
+ const log$36 = globalLogger.createChild("Storage");
30271
30401
  /**
30272
30402
  * High-level storage interface with generic type support
30273
30403
  * Wraps StorageAdapter to provide type-safe get/set operations
@@ -30288,7 +30418,7 @@ var Storage = class {
30288
30418
  if (value === null) return null;
30289
30419
  return JSON.parse(value);
30290
30420
  } catch (error) {
30291
- log$35.warn("Failed to parse stored value", {
30421
+ log$36.warn("Failed to parse stored value", {
30292
30422
  key,
30293
30423
  error
30294
30424
  });
@@ -30305,7 +30435,7 @@ var Storage = class {
30305
30435
  const serialized = JSON.stringify(value);
30306
30436
  await this.adapter.set(key, serialized);
30307
30437
  } catch (error) {
30308
- log$35.error("Failed to serialize value for storage", {
30438
+ log$36.error("Failed to serialize value for storage", {
30309
30439
  key,
30310
30440
  error
30311
30441
  });
@@ -30684,7 +30814,7 @@ var WalletManager = class {
30684
30814
  * LICENSE file in the root directory of this source tree.
30685
30815
  *
30686
30816
  */
30687
- const log$34 = globalLogger.createChild("TONConnectStoredSessionManager");
30817
+ const log$35 = globalLogger.createChild("TONConnectStoredSessionManager");
30688
30818
  var TONConnectStoredSessionManager = class {
30689
30819
  sessions = /* @__PURE__ */ new Map();
30690
30820
  storage;
@@ -30817,16 +30947,16 @@ var TONConnectStoredSessionManager = class {
30817
30947
  const wallet = this.walletManager.getWallet(session.walletId);
30818
30948
  if (wallet) session.walletAddress = wallet.getAddress();
30819
30949
  else {
30820
- log$34.warn("Session Wallet not found for session", { sessionId: session.sessionId });
30950
+ log$35.warn("Session Wallet not found for session", { sessionId: session.sessionId });
30821
30951
  continue;
30822
30952
  }
30823
30953
  }
30824
30954
  this.sessions.set(session.sessionId, session);
30825
30955
  }
30826
- log$34.debug("Loaded session metadata", { count: storedSessions.length });
30956
+ log$35.debug("Loaded session metadata", { count: storedSessions.length });
30827
30957
  }
30828
30958
  } catch (error) {
30829
- log$34.warn("Failed to load sessions from storage", { error });
30959
+ log$35.warn("Failed to load sessions from storage", { error });
30830
30960
  }
30831
30961
  }
30832
30962
  /**
@@ -30837,7 +30967,7 @@ var TONConnectStoredSessionManager = class {
30837
30967
  const sessionsToStore = Array.from(this.sessions.values());
30838
30968
  await this.storage.set(this.storageKey, sessionsToStore);
30839
30969
  } catch (error) {
30840
- log$34.warn("Failed to persist sessions to storage", { error });
30970
+ log$35.warn("Failed to persist sessions to storage", { error });
30841
30971
  }
30842
30972
  }
30843
30973
  async migrateSessions() {
@@ -71008,7 +71138,7 @@ globalLogger.createChild("ExtensionTransport");
71008
71138
  * LICENSE file in the root directory of this source tree.
71009
71139
  *
71010
71140
  */
71011
- const log$32 = globalLogger.createChild("BridgeManager");
71141
+ const log$33 = globalLogger.createChild("BridgeManager");
71012
71142
  var BridgeManager = class {
71013
71143
  config;
71014
71144
  bridgeProvider;
@@ -71050,7 +71180,7 @@ var BridgeManager = class {
71050
71180
  this.walletKitConfig = walletKitConfig;
71051
71181
  this.jsBridgeTransport = config?.jsBridgeTransport;
71052
71182
  if (this.config.bridgeUrl && !this.config.disableHttpConnection) this.bridgeProvider = new C(this.config.bridgeUrl, this.queueBridgeEvent.bind(this), (error) => {
71053
- log$32.error("Bridge listener error", { error: error.toString() });
71183
+ log$33.error("Bridge listener error", { error: error.toString() });
71054
71184
  this.analytics?.emitBridgeClientConnectError({
71055
71185
  error_message: `${error?.toString() || "Unknown error"}${error?.errorCode ? ` (Code: ${error?.errorCode})` : ""}`,
71056
71186
  trace_id: error?.traceId,
@@ -71064,12 +71194,12 @@ var BridgeManager = class {
71064
71194
  */
71065
71195
  async start() {
71066
71196
  if (this.isActive === true) {
71067
- log$32.warn("Bridge already started");
71197
+ log$33.warn("Bridge already started");
71068
71198
  return;
71069
71199
  }
71070
71200
  this.isActive = true;
71071
71201
  if (this.isConnected === true) {
71072
- log$32.warn("Bridge already connected");
71202
+ log$33.warn("Bridge already connected");
71073
71203
  return;
71074
71204
  }
71075
71205
  try {
@@ -71081,7 +71211,7 @@ var BridgeManager = class {
71081
71211
  }
71082
71212
  } catch (error) {
71083
71213
  this.isActive = false;
71084
- log$32.error("Failed to start bridge", { error });
71214
+ log$33.error("Failed to start bridge", { error });
71085
71215
  throw error;
71086
71216
  }
71087
71217
  const requestProcessing = () => {
@@ -71094,10 +71224,10 @@ var BridgeManager = class {
71094
71224
  * Create new session for a dApp connection
71095
71225
  */
71096
71226
  async createSession(appSessionId) {
71097
- log$32.info("[BRIDGE] Creating session", { appSessionId });
71227
+ log$33.info("[BRIDGE] Creating session", { appSessionId });
71098
71228
  if (!await this.sessionManager.getSession(appSessionId)) throw new WalletKitError(ERROR_CODES.SESSION_NOT_FOUND, `Session not found`, void 0, { appSessionId });
71099
71229
  if (this.bridgeProvider && this.isConnected) {
71100
- log$32.info("[BRIDGE] Updating clients");
71230
+ log$33.info("[BRIDGE] Updating clients");
71101
71231
  await this.updateClients();
71102
71232
  }
71103
71233
  }
@@ -71106,7 +71236,7 @@ var BridgeManager = class {
71106
71236
  */
71107
71237
  async removeSession(appSessionId) {
71108
71238
  if (this.bridgeProvider && this.isConnected) await this.updateClients();
71109
- log$32.debug("Session removed", { appSessionId });
71239
+ log$33.debug("Session removed", { appSessionId });
71110
71240
  }
71111
71241
  /**
71112
71242
  * Send response to dApp
@@ -71131,12 +71261,12 @@ var BridgeManager = class {
71131
71261
  }
71132
71262
  try {
71133
71263
  await this.bridgeProvider.send(response, sessionCrypto, sessionId, { traceId: event?.traceId });
71134
- log$32.debug("Response sent successfully", {
71264
+ log$33.debug("Response sent successfully", {
71135
71265
  sessionId,
71136
71266
  requestId: event.id
71137
71267
  });
71138
71268
  } catch (error) {
71139
- log$32.error("Failed to send response through bridge", {
71269
+ log$33.error("Failed to send response through bridge", {
71140
71270
  sessionId,
71141
71271
  requestId: event.id,
71142
71272
  error
@@ -71218,7 +71348,7 @@ var BridgeManager = class {
71218
71348
  await this.bridgeProvider?.restoreConnection(clients, { lastEventId: this.lastEventId });
71219
71349
  this.isConnected = true;
71220
71350
  this.reconnectAttempts = 0;
71221
- log$32.info("Bridge connected successfully");
71351
+ log$33.info("Bridge connected successfully");
71222
71352
  if (this.analytics) {
71223
71353
  const client = clients[0];
71224
71354
  this.analytics.emitBridgeClientConnectEstablished({
@@ -71227,7 +71357,7 @@ var BridgeManager = class {
71227
71357
  });
71228
71358
  }
71229
71359
  } catch (error) {
71230
- log$32.error("Bridge connection failed", { error: error?.toString() });
71360
+ log$33.error("Bridge connection failed", { error: error?.toString() });
71231
71361
  this.analytics?.emitBridgeClientConnectError({
71232
71362
  error_message: `${error?.toString() || "Unknown error"}${error?.errorCode ? ` (Code: ${error?.errorCode})` : ""}`,
71233
71363
  trace_id: error?.traceId ?? connectTraceId,
@@ -71236,9 +71366,9 @@ var BridgeManager = class {
71236
71366
  if (!this.config.disableHttpConnection) {
71237
71367
  if (this.reconnectAttempts < (this.config.maxReconnectAttempts || 5)) {
71238
71368
  this.reconnectAttempts++;
71239
- log$32.info("Bridge reconnection attempt", { attempt: this.reconnectAttempts });
71369
+ log$33.info("Bridge reconnection attempt", { attempt: this.reconnectAttempts });
71240
71370
  setTimeout(() => {
71241
- this.connectToSSEBridge().catch((error) => log$32.error("Bridge reconnection failed", { error }));
71371
+ this.connectToSSEBridge().catch((error) => log$33.error("Bridge reconnection failed", { error }));
71242
71372
  }, this.config.reconnectInterval);
71243
71373
  }
71244
71374
  }
@@ -71259,10 +71389,10 @@ var BridgeManager = class {
71259
71389
  * Add client to existing bridge connection
71260
71390
  */
71261
71391
  async updateClients() {
71262
- log$32.debug("Updating clients");
71392
+ log$33.debug("Updating clients");
71263
71393
  if (this.bridgeProvider) {
71264
71394
  const clients = await this.getClients();
71265
- log$32.info("[BRIDGE] Restoring connection", { clients: clients.length });
71395
+ log$33.info("[BRIDGE] Restoring connection", { clients: clients.length });
71266
71396
  await this.bridgeProvider.restoreConnection(clients, { lastEventId: this.lastEventId });
71267
71397
  }
71268
71398
  }
@@ -71270,17 +71400,17 @@ var BridgeManager = class {
71270
71400
  * Queue incoming bridge events for processing
71271
71401
  */
71272
71402
  queueBridgeEvent(event) {
71273
- log$32.debug("Bridge event queued", {
71403
+ log$33.debug("Bridge event queued", {
71274
71404
  eventId: event?.id,
71275
71405
  event
71276
71406
  });
71277
71407
  this.eventQueue.push(event);
71278
71408
  this.processBridgeEvents().catch((error) => {
71279
- log$32.error("Error in background event processing", { error });
71409
+ log$33.error("Error in background event processing", { error });
71280
71410
  });
71281
71411
  }
71282
71412
  queueJsBridgeEvent(messageInfo, event) {
71283
- log$32.debug("JS Bridge event queued", { eventId: messageInfo?.messageId });
71413
+ log$33.debug("JS Bridge event queued", { eventId: messageInfo?.messageId });
71284
71414
  if (!event) return;
71285
71415
  if (!event.traceId) event.traceId = v7();
71286
71416
  if (event.method == "connect") this.eventQueue.push({
@@ -71309,7 +71439,7 @@ var BridgeManager = class {
71309
71439
  walletId: messageInfo.walletId
71310
71440
  });
71311
71441
  this.processBridgeEvents().catch((error) => {
71312
- log$32.error("Error in background event processing", { error });
71442
+ log$33.error("Error in background event processing", { error });
71313
71443
  });
71314
71444
  }
71315
71445
  /**
@@ -71321,7 +71451,7 @@ var BridgeManager = class {
71321
71451
  */
71322
71452
  async processBridgeEvents() {
71323
71453
  if (this.isProcessing) {
71324
- log$32.debug("Event processing already in progress, skipping");
71454
+ log$33.debug("Event processing already in progress, skipping");
71325
71455
  return;
71326
71456
  }
71327
71457
  this.isProcessing = true;
@@ -71334,7 +71464,7 @@ var BridgeManager = class {
71334
71464
  }
71335
71465
  }
71336
71466
  } catch (error) {
71337
- log$32.error("Error during event processing", { error });
71467
+ log$33.error("Error during event processing", { error });
71338
71468
  this.isProcessing = false;
71339
71469
  this.restartConnection();
71340
71470
  return;
@@ -71347,7 +71477,7 @@ var BridgeManager = class {
71347
71477
  */
71348
71478
  async handleBridgeEvent(event) {
71349
71479
  try {
71350
- log$32.info("Bridge event received", { event });
71480
+ log$33.info("Bridge event received", { event });
71351
71481
  const rawEvent = {
71352
71482
  id: event.id || crypto.randomUUID(),
71353
71483
  method: event.method || "unknown",
@@ -71401,12 +71531,12 @@ var BridgeManager = class {
71401
71531
  try {
71402
71532
  await this.eventStore.storeEvent(rawEvent);
71403
71533
  if (this.eventEmitter) this.eventEmitter.emit("bridgeStorageUpdated", {}, "bridge-manager");
71404
- log$32.info("Event stored durably", {
71534
+ log$33.info("Event stored durably", {
71405
71535
  eventId: rawEvent.id,
71406
71536
  method: rawEvent.method
71407
71537
  });
71408
71538
  } catch (error) {
71409
- log$32.error("Failed to store event durably", {
71539
+ log$33.error("Failed to store event durably", {
71410
71540
  eventId: rawEvent.id,
71411
71541
  error: error.message
71412
71542
  });
@@ -71415,13 +71545,13 @@ var BridgeManager = class {
71415
71545
  method: rawEvent.method
71416
71546
  });
71417
71547
  }
71418
- log$32.info("Bridge event processed", { rawEvent });
71548
+ log$33.info("Bridge event processed", { rawEvent });
71419
71549
  if (event?.lastEventId && event.lastEventId !== this.lastEventId) {
71420
71550
  this.lastEventId = event.lastEventId;
71421
71551
  await this.saveLastEventId();
71422
71552
  }
71423
71553
  } catch (error) {
71424
- log$32.error("Error handling bridge event", { error });
71554
+ log$33.error("Error handling bridge event", { error });
71425
71555
  }
71426
71556
  }
71427
71557
  /**
@@ -71432,11 +71562,11 @@ var BridgeManager = class {
71432
71562
  const savedEventId = await this.storage.get(this.storageKey);
71433
71563
  if (savedEventId) {
71434
71564
  this.lastEventId = savedEventId;
71435
- log$32.debug("Loaded last event ID from storage", { lastEventId: this.lastEventId });
71565
+ log$33.debug("Loaded last event ID from storage", { lastEventId: this.lastEventId });
71436
71566
  }
71437
71567
  } catch (error) {
71438
71568
  const storageError = WalletKitError.fromError(ERROR_CODES.STORAGE_READ_FAILED, "Failed to load last event ID from storage", error);
71439
- log$32.warn("Failed to load last event ID from storage", { error: storageError });
71569
+ log$33.warn("Failed to load last event ID from storage", { error: storageError });
71440
71570
  }
71441
71571
  }
71442
71572
  /**
@@ -71446,11 +71576,11 @@ var BridgeManager = class {
71446
71576
  try {
71447
71577
  if (this.lastEventId) {
71448
71578
  await this.storage.set(this.storageKey, this.lastEventId);
71449
- log$32.debug("Saved last event ID to storage", { lastEventId: this.lastEventId });
71579
+ log$33.debug("Saved last event ID to storage", { lastEventId: this.lastEventId });
71450
71580
  }
71451
71581
  } catch (error) {
71452
71582
  const storageError = WalletKitError.fromError(ERROR_CODES.STORAGE_WRITE_FAILED, "Failed to save last event ID to storage", error);
71453
- log$32.warn("Failed to save last event ID to storage", { error: storageError });
71583
+ log$33.warn("Failed to save last event ID to storage", { error: storageError });
71454
71584
  }
71455
71585
  }
71456
71586
  };
@@ -71505,7 +71635,7 @@ function isValidHost(host) {
71505
71635
  * LICENSE file in the root directory of this source tree.
71506
71636
  *
71507
71637
  */
71508
- const log$31 = globalLogger.createChild("ManifestUtils");
71638
+ const log$32 = globalLogger.createChild("ManifestUtils");
71509
71639
  async function fetchManifest(manifestUrl, proxyUrl) {
71510
71640
  try {
71511
71641
  if (!isValidHost(new URL(manifestUrl).host)) return {
@@ -71524,14 +71654,14 @@ async function fetchManifest(manifestUrl, proxyUrl) {
71524
71654
  manifest: null,
71525
71655
  manifestFetchErrorCode: CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR
71526
71656
  };
71527
- log$31.info("Direct manifest fetch failed, trying proxy", { manifestUrl });
71657
+ log$32.info("Direct manifest fetch failed, trying proxy", { manifestUrl });
71528
71658
  return tryFetchManifest(`${proxyUrl}${manifestUrl}`);
71529
71659
  }
71530
71660
  async function tryFetchManifest(url) {
71531
71661
  try {
71532
71662
  const response = await fetch(url);
71533
71663
  if (!response.ok) {
71534
- log$31.error("Failed to fetch manifest not ok", {
71664
+ log$32.error("Failed to fetch manifest not ok", {
71535
71665
  url,
71536
71666
  status: response.status
71537
71667
  });
@@ -71545,7 +71675,7 @@ async function tryFetchManifest(url) {
71545
71675
  manifestFetchErrorCode: void 0
71546
71676
  };
71547
71677
  } catch (e) {
71548
- log$31.error("Failed to fetch manifest catched", {
71678
+ log$32.error("Failed to fetch manifest catched", {
71549
71679
  url,
71550
71680
  error: e
71551
71681
  });
@@ -71564,7 +71694,7 @@ async function tryFetchManifest(url) {
71564
71694
  * LICENSE file in the root directory of this source tree.
71565
71695
  *
71566
71696
  */
71567
- const log$30 = globalLogger.createChild("ConnectHandler");
71697
+ const log$31 = globalLogger.createChild("ConnectHandler");
71568
71698
  var ConnectHandler = class extends BasicHandler {
71569
71699
  config;
71570
71700
  analytics;
@@ -71585,7 +71715,7 @@ var ConnectHandler = class extends BasicHandler {
71585
71715
  manifest = result.manifest;
71586
71716
  manifestFetchErrorCode = result.manifestFetchErrorCode;
71587
71717
  } catch (error) {
71588
- log$30.warn("Failed to fetch manifest", { error });
71718
+ log$31.warn("Failed to fetch manifest", { error });
71589
71719
  }
71590
71720
  const preview = this.createPreview(event, manifestUrl, manifest, manifestFetchErrorCode);
71591
71721
  const connectEvent = {
@@ -71646,14 +71776,14 @@ var ConnectHandler = class extends BasicHandler {
71646
71776
  if (!finalManifestFetchErrorCode && dAppUrl) try {
71647
71777
  const parsedDAppUrl = new URL(dAppUrl);
71648
71778
  if (!isValidHost(parsedDAppUrl.host)) {
71649
- log$30.warn("Invalid dApp URL in manifest - invalid host format", {
71779
+ log$31.warn("Invalid dApp URL in manifest - invalid host format", {
71650
71780
  dAppUrl,
71651
71781
  host: parsedDAppUrl.host
71652
71782
  });
71653
71783
  finalManifestFetchErrorCode = CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR;
71654
71784
  }
71655
71785
  } catch (_) {
71656
- log$30.warn("Invalid dApp URL in manifest - failed to parse", { dAppUrl });
71786
+ log$31.warn("Invalid dApp URL in manifest - failed to parse", { dAppUrl });
71657
71787
  finalManifestFetchErrorCode = CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR;
71658
71788
  }
71659
71789
  }
@@ -72313,7 +72443,7 @@ function createTransferTransaction(params) {
72313
72443
  * LICENSE file in the root directory of this source tree.
72314
72444
  *
72315
72445
  */
72316
- const log$29 = globalLogger.createChild("ItemsResolver");
72446
+ const log$30 = globalLogger.createChild("ItemsResolver");
72317
72447
  /**
72318
72448
  * Resolve structured items (ton/jetton/nft) into raw TransactionRequestMessages.
72319
72449
  * After resolution, downstream code only needs to handle messages.
@@ -72331,7 +72461,7 @@ async function resolveItemsToMessages(items, wallet) {
72331
72461
  messages.push(resolveNftItem(item, wallet));
72332
72462
  break;
72333
72463
  default:
72334
- log$29.warn("Unknown item type, skipping", { item });
72464
+ log$30.warn("Unknown item type, skipping", { item });
72335
72465
  break;
72336
72466
  }
72337
72467
  return messages;
@@ -72393,7 +72523,7 @@ function resolveNftItem(item, wallet) {
72393
72523
  * LICENSE file in the root directory of this source tree.
72394
72524
  *
72395
72525
  */
72396
- const log$28 = globalLogger.createChild("EventsUtils");
72526
+ const log$29 = globalLogger.createChild("EventsUtils");
72397
72527
  /**
72398
72528
  * Helper to get wallet from event
72399
72529
  */
@@ -72452,7 +72582,7 @@ function parseTonConnectTransactionRequest(event, wallet) {
72452
72582
  validation: validateTransactionRequestForWallet(request, wallet, event.isLocal)
72453
72583
  };
72454
72584
  } catch (error) {
72455
- log$28.error("Failed to parse transaction request", { error });
72585
+ log$29.error("Failed to parse transaction request", { error });
72456
72586
  errors.push("Failed to parse transaction request");
72457
72587
  return {
72458
72588
  result: void 0,
@@ -74825,7 +74955,7 @@ async function computeMoneyFlow(client, response, options = {}) {
74825
74955
  * LICENSE file in the root directory of this source tree.
74826
74956
  *
74827
74957
  */
74828
- const log$27 = globalLogger.createChild("TransactionPreview");
74958
+ const log$28 = globalLogger.createChild("TransactionPreview");
74829
74959
  const SIGN_MODE_EMULATION_VALUE = 2000000000n;
74830
74960
  async function createTransactionPreview(client, request, wallet, options = {}) {
74831
74961
  const isSignMode = (options.mode ?? "send") === "sign";
@@ -74877,7 +75007,7 @@ async function createTransactionPreviewIfPossible(config, client, request, walle
74877
75007
  try {
74878
75008
  preview = await CallForSuccess(() => createTransactionPreview(client, request, wallet, options));
74879
75009
  } catch (error) {
74880
- log$27.error("Failed to create transaction preview", { error });
75010
+ log$28.error("Failed to create transaction preview", { error });
74881
75011
  preview = {
74882
75012
  error: {
74883
75013
  code: ERROR_CODES.UNKNOWN_EMULATION_ERROR,
@@ -75152,7 +75282,7 @@ async function getTransactionStatus(client, params) {
75152
75282
  * LICENSE file in the root directory of this source tree.
75153
75283
  *
75154
75284
  */
75155
- const log$26 = globalLogger.createChild("TransactionHandler");
75285
+ const log$27 = globalLogger.createChild("TransactionHandler");
75156
75286
  var TransactionHandler = class extends BasicHandler {
75157
75287
  config;
75158
75288
  walletManager;
@@ -75174,7 +75304,7 @@ var TransactionHandler = class extends BasicHandler {
75174
75304
  async handle(event) {
75175
75305
  const wallet = getWalletFromEvent(this.walletManager, event);
75176
75306
  if (!wallet) {
75177
- log$26.error("Wallet not found", { event });
75307
+ log$27.error("Wallet not found", { event });
75178
75308
  return {
75179
75309
  error: {
75180
75310
  code: SEND_TRANSACTION_ERROR_CODES$1.UNKNOWN_APP_ERROR,
@@ -75185,7 +75315,7 @@ var TransactionHandler = class extends BasicHandler {
75185
75315
  }
75186
75316
  const requestValidation = this.parseTonConnectTransactionRequest(event, wallet);
75187
75317
  if (!requestValidation.result || !requestValidation?.validation?.isValid) {
75188
- log$26.error("Failed to parse transaction request", {
75318
+ log$27.error("Failed to parse transaction request", {
75189
75319
  event,
75190
75320
  requestValidation
75191
75321
  });
@@ -75237,7 +75367,7 @@ var TransactionHandler = class extends BasicHandler {
75237
75367
  * LICENSE file in the root directory of this source tree.
75238
75368
  *
75239
75369
  */
75240
- const log$25 = globalLogger.createChild("SignDataHandler");
75370
+ const log$26 = globalLogger.createChild("SignDataHandler");
75241
75371
  var SignDataHandler = class extends BasicHandler {
75242
75372
  analytics;
75243
75373
  walletManager;
@@ -75258,12 +75388,12 @@ var SignDataHandler = class extends BasicHandler {
75258
75388
  const wallet = walletId ? this.walletManager.getWallet(walletId) : void 0;
75259
75389
  const payload = this.parseDataToSign(event);
75260
75390
  if (!payload) {
75261
- log$25.error("No data to sign found in request", { event });
75391
+ log$26.error("No data to sign found in request", { event });
75262
75392
  throw new WalletKitError(ERROR_CODES.INVALID_REQUEST_EVENT, "No data to sign found in request", void 0, { eventId: event.id });
75263
75393
  }
75264
75394
  const preview = this.createDataPreview(payload.data, event);
75265
75395
  if (!preview) {
75266
- log$25.error("No preview found for data", { data: payload });
75396
+ log$26.error("No preview found for data", { data: payload });
75267
75397
  throw new WalletKitError(ERROR_CODES.RESPONSE_CREATION_FAILED, "Failed to create preview for sign data request", void 0, {
75268
75398
  eventId: event.id,
75269
75399
  data: payload
@@ -75320,7 +75450,7 @@ var SignDataHandler = class extends BasicHandler {
75320
75450
  }
75321
75451
  };
75322
75452
  } catch (error) {
75323
- log$25.error("Error deserializing cell", { error });
75453
+ log$26.error("Error deserializing cell", { error });
75324
75454
  return {
75325
75455
  type: "cell",
75326
75456
  value: {
@@ -75340,7 +75470,7 @@ var SignDataHandler = class extends BasicHandler {
75340
75470
  * LICENSE file in the root directory of this source tree.
75341
75471
  *
75342
75472
  */
75343
- const log$24 = globalLogger.createChild("SignMessageHandler");
75473
+ const log$25 = globalLogger.createChild("SignMessageHandler");
75344
75474
  var SignMessageHandler = class extends BasicHandler {
75345
75475
  config;
75346
75476
  walletManager;
@@ -75362,7 +75492,7 @@ var SignMessageHandler = class extends BasicHandler {
75362
75492
  async handle(event) {
75363
75493
  const wallet = getWalletFromEvent(this.walletManager, event);
75364
75494
  if (!wallet) {
75365
- log$24.error("Wallet not found", { event });
75495
+ log$25.error("Wallet not found", { event });
75366
75496
  return {
75367
75497
  error: {
75368
75498
  code: SIGN_MESSAGE_ERROR_CODES.UNKNOWN_APP_ERROR,
@@ -75373,7 +75503,7 @@ var SignMessageHandler = class extends BasicHandler {
75373
75503
  }
75374
75504
  const requestValidation = this.parseTonConnectTransactionRequest(event, wallet);
75375
75505
  if (!requestValidation.result || !requestValidation?.validation?.isValid) {
75376
- log$24.error("Failed to parse sign message request", {
75506
+ log$25.error("Failed to parse sign message request", {
75377
75507
  event,
75378
75508
  requestValidation
75379
75509
  });
@@ -75466,7 +75596,7 @@ var DisconnectHandler = class extends BasicHandler {
75466
75596
  * LICENSE file in the root directory of this source tree.
75467
75597
  *
75468
75598
  */
75469
- const log$23 = globalLogger.createChild("EventRouter");
75599
+ const log$24 = globalLogger.createChild("EventRouter");
75470
75600
  var EventRouter = class {
75471
75601
  config;
75472
75602
  eventEmitter;
@@ -75498,7 +75628,7 @@ var EventRouter = class {
75498
75628
  async routeEvent(event) {
75499
75629
  const validation = validateBridgeEvent(event);
75500
75630
  if (!validation.isValid) {
75501
- log$23.error("Invalid bridge event", { errors: validation.errors });
75631
+ log$24.error("Invalid bridge event", { errors: validation.errors });
75502
75632
  return;
75503
75633
  }
75504
75634
  try {
@@ -75513,7 +75643,7 @@ var EventRouter = class {
75513
75643
  try {
75514
75644
  await this.bridgeManager.sendResponse(event, result);
75515
75645
  } catch (error) {
75516
- log$23.error("Error sending response for error event", {
75646
+ log$24.error("Error sending response for error event", {
75517
75647
  error,
75518
75648
  event,
75519
75649
  result
@@ -75525,7 +75655,7 @@ var EventRouter = class {
75525
75655
  break;
75526
75656
  }
75527
75657
  } catch (error) {
75528
- log$23.error("Error routing event", { error });
75658
+ log$24.error("Error routing event", { error });
75529
75659
  throw error;
75530
75660
  }
75531
75661
  }
@@ -75652,7 +75782,7 @@ var EventRouter = class {
75652
75782
  * LICENSE file in the root directory of this source tree.
75653
75783
  *
75654
75784
  */
75655
- const log$22 = globalLogger.createChild("RequestProcessor");
75785
+ const log$23 = globalLogger.createChild("RequestProcessor");
75656
75786
  function hasConnectionResult(event) {
75657
75787
  return "connectionResult" in event;
75658
75788
  }
@@ -75721,7 +75851,7 @@ var RequestProcessor = class {
75721
75851
  }
75722
75852
  return;
75723
75853
  } catch (error) {
75724
- log$22.error("Failed to approve connect request", { error });
75854
+ log$23.error("Failed to approve connect request", { error });
75725
75855
  throw error;
75726
75856
  }
75727
75857
  }
@@ -75856,7 +75986,7 @@ var RequestProcessor = class {
75856
75986
  */
75857
75987
  async rejectConnectRequest(event, reason, errorCode) {
75858
75988
  try {
75859
- log$22.info("Connect request rejected", {
75989
+ log$23.info("Connect request rejected", {
75860
75990
  id: event.id,
75861
75991
  dAppName: event.preview.dAppInfo?.name || "",
75862
75992
  reason: reason || "User rejected connection"
@@ -75873,7 +76003,7 @@ var RequestProcessor = class {
75873
76003
  try {
75874
76004
  await this.bridgeManager.sendResponse(event, response, new SessionCrypto());
75875
76005
  } catch (error) {
75876
- log$22.error("Failed to send connect request rejection response", { error });
76006
+ log$23.error("Failed to send connect request rejection response", { error });
75877
76007
  }
75878
76008
  if (this.analytics) {
75879
76009
  const sessionData = event.from ? await this.sessionManager.getSession(sessionId) : void 0;
@@ -75902,7 +76032,7 @@ var RequestProcessor = class {
75902
76032
  }
75903
76033
  return;
75904
76034
  } catch (error) {
75905
- log$22.error("Failed to reject connect request", { error });
76035
+ log$23.error("Failed to reject connect request", { error });
75906
76036
  throw error;
75907
76037
  }
75908
76038
  }
@@ -75934,7 +76064,7 @@ var RequestProcessor = class {
75934
76064
  return { signedBoc };
75935
76065
  }
75936
76066
  } catch (error) {
75937
- log$22.error("Failed to approve transaction request", { error });
76067
+ log$23.error("Failed to approve transaction request", { error });
75938
76068
  if (error instanceof WalletKitError) throw error;
75939
76069
  if (error?.message?.includes("Ledger device")) throw new WalletKitError(ERROR_CODES.LEDGER_DEVICE_ERROR, "Ledger device error", error);
75940
76070
  throw error;
@@ -75984,7 +76114,7 @@ var RequestProcessor = class {
75984
76114
  }
75985
76115
  return;
75986
76116
  } catch (error) {
75987
- log$22.error("Failed to reject transaction request", { error });
76117
+ log$23.error("Failed to reject transaction request", { error });
75988
76118
  throw error;
75989
76119
  }
75990
76120
  }
@@ -76015,7 +76145,7 @@ var RequestProcessor = class {
76015
76145
  return { internalBoc };
76016
76146
  }
76017
76147
  } catch (error) {
76018
- log$22.error("Failed to approve sign message request", { error });
76148
+ log$23.error("Failed to approve sign message request", { error });
76019
76149
  throw error;
76020
76150
  }
76021
76151
  }
@@ -76033,7 +76163,7 @@ var RequestProcessor = class {
76033
76163
  };
76034
76164
  await this.sendBridgeMessage(event, void 0, response);
76035
76165
  } catch (error) {
76036
- log$22.error("Failed to reject sign message request", { error });
76166
+ log$23.error("Failed to reject sign message request", { error });
76037
76167
  throw error;
76038
76168
  }
76039
76169
  }
@@ -76136,7 +76266,7 @@ var RequestProcessor = class {
76136
76266
  };
76137
76267
  }
76138
76268
  } catch (error) {
76139
- log$22.error("Failed to approve sign data request", { error: error?.message?.toString() ?? error?.toString() });
76269
+ log$23.error("Failed to approve sign data request", { error: error?.message?.toString() ?? error?.toString() });
76140
76270
  if (error instanceof WalletKitError) throw error;
76141
76271
  throw error;
76142
76272
  }
@@ -76171,7 +76301,7 @@ var RequestProcessor = class {
76171
76301
  }
76172
76302
  return;
76173
76303
  } catch (error) {
76174
- log$22.error("Failed to reject sign data request", { error });
76304
+ log$23.error("Failed to reject sign data request", { error });
76175
76305
  throw error;
76176
76306
  }
76177
76307
  }
@@ -76250,7 +76380,7 @@ var RequestProcessor = class {
76250
76380
  */
76251
76381
  async function signTransactionInternal(wallet, request) {
76252
76382
  const signedBoc = await wallet.getSignedSendTransaction(request, { fakeSignature: false });
76253
- log$22.debug("Signing transaction", {
76383
+ log$23.debug("Signing transaction", {
76254
76384
  messagesNumber: request.messages.length,
76255
76385
  fromAddress: request.fromAddress,
76256
76386
  validUntil: request.validUntil
@@ -76306,7 +76436,7 @@ function parseDomain(url) {
76306
76436
  value: parsedUrl.host
76307
76437
  };
76308
76438
  } catch (error) {
76309
- log$22.error("Failed to parse domain", { error });
76439
+ log$23.error("Failed to parse domain", { error });
76310
76440
  return {
76311
76441
  lengthBytes: 0,
76312
76442
  value: ""
@@ -76346,7 +76476,7 @@ function toTonConnectSignDataPayload(payload) {
76346
76476
  const getEventUUID = () => {
76347
76477
  return crypto.randomUUID();
76348
76478
  };
76349
- const log$21 = globalLogger.createChild("EventStore");
76479
+ const log$22 = globalLogger.createChild("EventStore");
76350
76480
  const MAX_EVENT_SIZE_BYTES = 100 * 1024;
76351
76481
  /**
76352
76482
  * Concrete implementation of EventStore using Storage
@@ -76382,7 +76512,7 @@ var StorageEventStore = class {
76382
76512
  sizeBytes
76383
76513
  };
76384
76514
  await this.saveEvent(storedEvent);
76385
- log$21.info("Event stored", {
76515
+ log$22.info("Event stored", {
76386
76516
  eventId: storedEvent.id,
76387
76517
  eventType,
76388
76518
  sizeBytes,
@@ -76410,11 +76540,11 @@ var StorageEventStore = class {
76410
76540
  const allEvents = await this.getAllEventsFromStorage();
76411
76541
  const event = allEvents[eventId];
76412
76542
  if (!event) {
76413
- log$21.warn("Cannot lock non-existent event", { eventId });
76543
+ log$22.warn("Cannot lock non-existent event", { eventId });
76414
76544
  return;
76415
76545
  }
76416
76546
  if (event.status !== "new") {
76417
- log$21.debug("Cannot lock event - not in new status", {
76547
+ log$22.debug("Cannot lock event - not in new status", {
76418
76548
  eventId,
76419
76549
  status: event.status,
76420
76550
  lockedBy: event.lockedBy
@@ -76429,7 +76559,7 @@ var StorageEventStore = class {
76429
76559
  };
76430
76560
  allEvents[eventId] = updatedEvent;
76431
76561
  await this.storage.set(this.storageKey, allEvents);
76432
- log$21.debug("Event lock acquired", {
76562
+ log$22.debug("Event lock acquired", {
76433
76563
  eventId,
76434
76564
  walletAddress: walletId
76435
76565
  });
@@ -76456,7 +76586,7 @@ var StorageEventStore = class {
76456
76586
  };
76457
76587
  allEvents[eventId] = updatedEvent;
76458
76588
  await this.storage.set(this.storageKey, allEvents);
76459
- log$21.debug("Event retry count incremented", {
76589
+ log$22.debug("Event retry count incremented", {
76460
76590
  eventId,
76461
76591
  retryCount: updatedEvent.retryCount,
76462
76592
  error
@@ -76480,7 +76610,7 @@ var StorageEventStore = class {
76480
76610
  if (status === "completed") updatedEvent.completedAt = Date.now();
76481
76611
  allEvents[eventId] = updatedEvent;
76482
76612
  await this.storage.set(this.storageKey, allEvents);
76483
- log$21.debug("Event status updated", {
76613
+ log$22.debug("Event status updated", {
76484
76614
  eventId,
76485
76615
  oldStatus,
76486
76616
  newStatus: status
@@ -76495,7 +76625,7 @@ var StorageEventStore = class {
76495
76625
  try {
76496
76626
  return (await this.getAllEventsFromStorage())[eventId] || null;
76497
76627
  } catch (error) {
76498
- log$21.warn("Failed to get event", {
76628
+ log$22.warn("Failed to get event", {
76499
76629
  eventId,
76500
76630
  error
76501
76631
  });
@@ -76517,14 +76647,14 @@ var StorageEventStore = class {
76517
76647
  };
76518
76648
  await this.saveEvent(recoveredEvent);
76519
76649
  recoveredCount++;
76520
- log$21.info("Recovered stale event", {
76650
+ log$22.info("Recovered stale event", {
76521
76651
  eventId: event.id,
76522
76652
  lockedBy: event.lockedBy,
76523
76653
  staleMinutes: Math.round((now - event.processingStartedAt) / 6e4),
76524
76654
  retryCount: event.retryCount || 0
76525
76655
  });
76526
76656
  }
76527
- if (recoveredCount > 0) log$21.info("Event recovery completed", { recoveredCount });
76657
+ if (recoveredCount > 0) log$22.info("Event recovery completed", { recoveredCount });
76528
76658
  return recoveredCount;
76529
76659
  }
76530
76660
  /**
@@ -76537,7 +76667,7 @@ var StorageEventStore = class {
76537
76667
  const eventsToRemove = [];
76538
76668
  for (const event of events) if (event.status === "completed" && event.completedAt && event.completedAt < cutoffTime || event.status === "errored" && event.createdAt < cutoffTime) {
76539
76669
  eventsToRemove.push(event.id);
76540
- log$21.debug("Marked event for cleanup", {
76670
+ log$22.debug("Marked event for cleanup", {
76541
76671
  eventId: event.id,
76542
76672
  status: event.status
76543
76673
  });
@@ -76551,7 +76681,7 @@ var StorageEventStore = class {
76551
76681
  }
76552
76682
  await this.storage.set(this.storageKey, allEvents);
76553
76683
  });
76554
- log$21.info("Event cleanup completed", { cleanedUpCount });
76684
+ log$22.info("Event cleanup completed", { cleanedUpCount });
76555
76685
  }
76556
76686
  return cleanedUpCount;
76557
76687
  }
@@ -76563,7 +76693,7 @@ var StorageEventStore = class {
76563
76693
  const allEvents = await this.getAllEventsFromStorage();
76564
76694
  return Object.values(allEvents);
76565
76695
  } catch (error) {
76566
- log$21.warn("Failed to get all events", { error });
76696
+ log$22.warn("Failed to get all events", { error });
76567
76697
  return [];
76568
76698
  }
76569
76699
  }
@@ -76585,7 +76715,7 @@ var StorageEventStore = class {
76585
76715
  try {
76586
76716
  return await this.storage.get(this.storageKey) || {};
76587
76717
  } catch (error) {
76588
- log$21.warn("Failed to get events from storage", { error });
76718
+ log$22.warn("Failed to get events from storage", { error });
76589
76719
  return {};
76590
76720
  }
76591
76721
  }
@@ -76624,7 +76754,7 @@ var StorageEventStore = class {
76624
76754
  * LICENSE file in the root directory of this source tree.
76625
76755
  *
76626
76756
  */
76627
- const log$20 = globalLogger.createChild("EventProcessor");
76757
+ const log$21 = globalLogger.createChild("EventProcessor");
76628
76758
  /**
76629
76759
  * Processes durable events for wallets based on their active sessions and enabled event types
76630
76760
  */
@@ -76659,14 +76789,14 @@ var StorageEventProcessor = class {
76659
76789
  */
76660
76790
  async startProcessing(walletId) {
76661
76791
  if (this.processorConfig.disableEvents) return;
76662
- if (walletId) if (this.registeredWallets.has(walletId)) log$20.debug("Processing already registered for wallet", { walletId });
76792
+ if (walletId) if (this.registeredWallets.has(walletId)) log$21.debug("Processing already registered for wallet", { walletId });
76663
76793
  else {
76664
76794
  this.registeredWallets.add(walletId);
76665
- log$20.info("Registered wallet for event processing", { walletId });
76795
+ log$21.info("Registered wallet for event processing", { walletId });
76666
76796
  }
76667
76797
  if (!this.isProcessing) {
76668
76798
  this.isProcessing = true;
76669
- log$20.info("Started global event processing loop");
76799
+ log$21.info("Started global event processing loop");
76670
76800
  this.processEventsLoop();
76671
76801
  } else this.triggerProcessing();
76672
76802
  }
@@ -76677,7 +76807,7 @@ var StorageEventProcessor = class {
76677
76807
  if (this.processorConfig.disableEvents) return;
76678
76808
  if (walletId) {
76679
76809
  this.registeredWallets.delete(walletId);
76680
- log$20.info("Unregistered wallet from event processing", { walletId });
76810
+ log$21.info("Unregistered wallet from event processing", { walletId });
76681
76811
  }
76682
76812
  if (this.registeredWallets.size === 0 && this.isProcessing && !walletId) {
76683
76813
  this.isProcessing = false;
@@ -76685,12 +76815,12 @@ var StorageEventProcessor = class {
76685
76815
  this.wakeUpResolver();
76686
76816
  this.wakeUpResolver = void 0;
76687
76817
  }
76688
- log$20.info("Stopped global event processing loop (no more wallets)");
76818
+ log$21.info("Stopped global event processing loop (no more wallets)");
76689
76819
  }
76690
76820
  }
76691
76821
  async clearRegisteredWallets() {
76692
76822
  this.registeredWallets.clear();
76693
- log$20.info("Cleared registered wallets from event processing");
76823
+ log$21.info("Cleared registered wallets from event processing");
76694
76824
  }
76695
76825
  /**
76696
76826
  * Process next available event from any source (wallet or no-wallet)
@@ -76720,7 +76850,7 @@ var StorageEventProcessor = class {
76720
76850
  const walletId = allSessions.find((s) => s.sessionId === eventToUse.sessionId)?.walletId || "no-wallet";
76721
76851
  return await this.processEvent(eventToUse, walletId);
76722
76852
  } catch (error) {
76723
- log$20.error("Error in processNextAvailableEvent", { error: error.message });
76853
+ log$21.error("Error in processNextAvailableEvent", { error: error.message });
76724
76854
  return false;
76725
76855
  }
76726
76856
  }
@@ -76730,9 +76860,9 @@ var StorageEventProcessor = class {
76730
76860
  async completeEvent(eventId) {
76731
76861
  try {
76732
76862
  await this.eventStore.updateEventStatus(eventId, "completed", "processing");
76733
- log$20.debug("Event marked as completed", { eventId });
76863
+ log$21.debug("Event marked as completed", { eventId });
76734
76864
  } catch (error) {
76735
- log$20.error("Failed to mark event as completed", {
76865
+ log$21.error("Failed to mark event as completed", {
76736
76866
  eventId,
76737
76867
  error: error.message
76738
76868
  });
@@ -76743,14 +76873,14 @@ var StorageEventProcessor = class {
76743
76873
  */
76744
76874
  startRecoveryLoop() {
76745
76875
  if (this.recoveryTimeoutId) {
76746
- log$20.debug("Recovery loop already running");
76876
+ log$21.debug("Recovery loop already running");
76747
76877
  return;
76748
76878
  }
76749
76879
  const recoveryLoop = async () => {
76750
76880
  try {
76751
76881
  if (await this.eventStore.recoverStaleEvents(this.config.processingTimeoutMs) > 0) this.triggerProcessing();
76752
76882
  } catch (error) {
76753
- log$20.error("Error in recovery loop", { error: error.message });
76883
+ log$21.error("Error in recovery loop", { error: error.message });
76754
76884
  }
76755
76885
  if (this.recoveryTimeoutId !== void 0) this.recoveryTimeoutId = setTimeout(recoveryLoop, this.config.recoveryIntervalMs);
76756
76886
  };
@@ -76758,13 +76888,13 @@ var StorageEventProcessor = class {
76758
76888
  try {
76759
76889
  await this.eventStore.cleanupOldEvents(this.config.retentionMs);
76760
76890
  } catch (error) {
76761
- log$20.error("Error in cleanup loop", { error: error.message });
76891
+ log$21.error("Error in cleanup loop", { error: error.message });
76762
76892
  }
76763
76893
  if (this.cleanupTimeoutId !== void 0) this.cleanupTimeoutId = setTimeout(cleanupLoop, this.config.cleanupIntervalMs);
76764
76894
  };
76765
76895
  this.recoveryTimeoutId = setTimeout(recoveryLoop, this.config.recoveryIntervalMs);
76766
76896
  this.cleanupTimeoutId = setTimeout(cleanupLoop, this.config.cleanupIntervalMs);
76767
- log$20.info("Recovery and cleanup loops started");
76897
+ log$21.info("Recovery and cleanup loops started");
76768
76898
  }
76769
76899
  /**
76770
76900
  * Stop the recovery process
@@ -76778,7 +76908,7 @@ var StorageEventProcessor = class {
76778
76908
  clearTimeout(this.cleanupTimeoutId);
76779
76909
  this.cleanupTimeoutId = void 0;
76780
76910
  }
76781
- log$20.info("Recovery and cleanup loops stopped");
76911
+ log$21.info("Recovery and cleanup loops stopped");
76782
76912
  }
76783
76913
  /**
76784
76914
  * Process a single event with retry logic
@@ -76786,7 +76916,7 @@ var StorageEventProcessor = class {
76786
76916
  */
76787
76917
  async processEvent(event, walletId) {
76788
76918
  if (!await this.eventStore.acquireLock(event.id, walletId)) {
76789
- log$20.debug("Failed to acquire lock on event", {
76919
+ log$21.debug("Failed to acquire lock on event", {
76790
76920
  eventId: event.id,
76791
76921
  walletId
76792
76922
  });
@@ -76794,7 +76924,7 @@ var StorageEventProcessor = class {
76794
76924
  }
76795
76925
  const retryCount = event.retryCount || 0;
76796
76926
  if (retryCount >= this.config.maxRetries) {
76797
- log$20.error("Event exceeded max retries, marking as errored", {
76927
+ log$21.error("Event exceeded max retries, marking as errored", {
76798
76928
  eventId: event.id,
76799
76929
  retryCount,
76800
76930
  maxRetries: this.config.maxRetries
@@ -76802,14 +76932,14 @@ var StorageEventProcessor = class {
76802
76932
  try {
76803
76933
  await this.eventStore.updateEventStatus(event.id, "errored", "processing");
76804
76934
  } catch (error) {
76805
- log$20.error("Failed to mark event as errored", {
76935
+ log$21.error("Failed to mark event as errored", {
76806
76936
  eventId: event.id,
76807
76937
  error: error.message
76808
76938
  });
76809
76939
  }
76810
76940
  return false;
76811
76941
  }
76812
- log$20.info("Processing event", {
76942
+ log$21.info("Processing event", {
76813
76943
  eventId: event.id,
76814
76944
  eventType: event.eventType,
76815
76945
  walletId,
@@ -76829,11 +76959,11 @@ var StorageEventProcessor = class {
76829
76959
  ...walletAddress ? { walletAddress } : {}
76830
76960
  });
76831
76961
  await this.eventStore.updateEventStatus(event.id, "completed", "processing");
76832
- log$20.info("Event processing completed", { eventId: event.id });
76962
+ log$21.info("Event processing completed", { eventId: event.id });
76833
76963
  return true;
76834
76964
  } catch (error) {
76835
76965
  const errorMessage = error.message ?? "Unknown error";
76836
- log$20.error("Error processing event", {
76966
+ log$21.error("Error processing event", {
76837
76967
  eventId: event.id,
76838
76968
  error: errorMessage,
76839
76969
  retryCount
@@ -76841,7 +76971,7 @@ var StorageEventProcessor = class {
76841
76971
  try {
76842
76972
  await this.eventStore.releaseLock(event.id, errorMessage);
76843
76973
  } catch (updateError) {
76844
- log$20.error("Failed to increment retry count", {
76974
+ log$21.error("Failed to increment retry count", {
76845
76975
  eventId: event.id,
76846
76976
  error: updateError.message
76847
76977
  });
@@ -76856,18 +76986,18 @@ var StorageEventProcessor = class {
76856
76986
  while (this.isProcessing) try {
76857
76987
  if (!await this.processNextAvailableEvent()) await this.waitForWakeUpOrTimeout(500);
76858
76988
  } catch (error) {
76859
- log$20.error("Error in global processing loop", { error: error.message });
76989
+ log$21.error("Error in global processing loop", { error: error.message });
76860
76990
  await this.waitForWakeUpOrTimeout(500);
76861
76991
  }
76862
76992
  this.wakeUpResolver = void 0;
76863
- log$20.debug("Global processing loop ended");
76993
+ log$21.debug("Global processing loop ended");
76864
76994
  }
76865
76995
  /**
76866
76996
  * Trigger the global processing loop
76867
76997
  */
76868
76998
  triggerProcessing() {
76869
76999
  if (this.isProcessing && this.wakeUpResolver) {
76870
- log$20.debug("Waking up global processing loop");
77000
+ log$21.debug("Waking up global processing loop");
76871
77001
  this.wakeUpResolver();
76872
77002
  }
76873
77003
  }
@@ -76910,7 +77040,7 @@ var StorageEventProcessor = class {
76910
77040
  * LICENSE file in the root directory of this source tree.
76911
77041
  *
76912
77042
  */
76913
- const log$19 = globalLogger.createChild("WalletTonClass");
77043
+ const log$20 = globalLogger.createChild("WalletTonClass");
76914
77044
  var WalletTonClass = class {
76915
77045
  async createTransferTonTransaction(param) {
76916
77046
  if (!isValidAddress(param.recipientAddress)) throw new Error(`Invalid to address: ${param.recipientAddress}`);
@@ -76971,7 +77101,7 @@ var WalletTonClass = class {
76971
77101
  normalizedHash
76972
77102
  };
76973
77103
  } catch (error) {
76974
- log$19.error("Failed to send transaction", { error });
77104
+ log$20.error("Failed to send transaction", { error });
76975
77105
  if (error instanceof WalletKitError) throw error;
76976
77106
  if (error?.message?.includes("Ledger device")) throw new WalletKitError(ERROR_CODES.LEDGER_DEVICE_ERROR, "Ledger device error", error);
76977
77107
  throw error;
@@ -77001,7 +77131,7 @@ var WalletJettonClass = class {
77001
77131
  payload: createJettonTransferPayload({
77002
77132
  amount: BigInt(params.transferAmount),
77003
77133
  destination: params.recipientAddress,
77004
- responseDestination: this.getAddress(),
77134
+ responseDestination: params.responseDestination || this.getAddress(),
77005
77135
  comment: params.comment
77006
77136
  }),
77007
77137
  fromAddress: this.getAddress()
@@ -77073,7 +77203,7 @@ var WalletNftClass = class {
77073
77203
  * LICENSE file in the root directory of this source tree.
77074
77204
  *
77075
77205
  */
77076
- const log$18 = globalLogger.createChild("Initializer");
77206
+ const log$19 = globalLogger.createChild("Initializer");
77077
77207
  /**
77078
77208
  * Handles initialization of all TonWalletKit components
77079
77209
  */
@@ -77092,12 +77222,12 @@ var Initializer = class {
77092
77222
  */
77093
77223
  async initialize(options, networkManager) {
77094
77224
  try {
77095
- log$18.info("Initializing TonWalletKit...");
77225
+ log$19.info("Initializing TonWalletKit...");
77096
77226
  this.networkManager = networkManager;
77097
77227
  const storage = this.initializeStorage(options);
77098
77228
  const { walletManager, sessionManager, bridgeManager, eventRouter, eventProcessor } = await this.initializeManagers(options, storage);
77099
77229
  const { requestProcessor } = this.initializeProcessors(sessionManager, bridgeManager, walletManager);
77100
- log$18.info("TonWalletKit initialized successfully");
77230
+ log$19.info("TonWalletKit initialized successfully");
77101
77231
  return {
77102
77232
  walletManager,
77103
77233
  sessionManager,
@@ -77108,7 +77238,7 @@ var Initializer = class {
77108
77238
  eventProcessor
77109
77239
  };
77110
77240
  } catch (error) {
77111
- log$18.error("Failed to initialize TonWalletKit", { error });
77241
+ log$19.error("Failed to initialize TonWalletKit", { error });
77112
77242
  throw error;
77113
77243
  }
77114
77244
  }
@@ -77144,9 +77274,9 @@ var Initializer = class {
77144
77274
  const bridgeManager = new BridgeManager(options?.walletManifest, options?.bridge, sessionManager, storage, eventStore, eventRouter, options, this.eventEmitter, this.analyticsManager);
77145
77275
  eventRouter.setBridgeManager(bridgeManager);
77146
77276
  bridgeManager.start().then(() => {
77147
- log$18.info("Bridge manager started successfully");
77277
+ log$19.info("Bridge manager started successfully");
77148
77278
  }).catch((e) => {
77149
- log$18.error("Could not start bridge manager", { error: e?.toString?.() });
77279
+ log$19.error("Could not start bridge manager", { error: e?.toString?.() });
77150
77280
  });
77151
77281
  const eventProcessor = new StorageEventProcessor(options?.eventProcessor, eventStore, DEFAULT_DURABLE_EVENTS_CONFIG, walletManager, sessionManager, eventRouter, this.eventEmitter);
77152
77282
  return {
@@ -77168,7 +77298,7 @@ var Initializer = class {
77168
77298
  */
77169
77299
  async cleanup(components) {
77170
77300
  try {
77171
- log$18.info("Cleaning up TonWalletKit components...");
77301
+ log$19.info("Cleaning up TonWalletKit components...");
77172
77302
  if (components.eventProcessor) {
77173
77303
  components.eventProcessor.stopRecoveryLoop();
77174
77304
  await components.eventProcessor.clearRegisteredWallets();
@@ -77176,9 +77306,9 @@ var Initializer = class {
77176
77306
  }
77177
77307
  if (components.bridgeManager) await components.bridgeManager.close();
77178
77308
  if (components.eventRouter) components.eventRouter.clearCallbacks();
77179
- log$18.info("TonWalletKit cleanup completed");
77309
+ log$19.info("TonWalletKit cleanup completed");
77180
77310
  } catch (error) {
77181
- log$18.error("Error during cleanup", { error });
77311
+ log$19.error("Error during cleanup", { error });
77182
77312
  }
77183
77313
  }
77184
77314
  };
@@ -77213,7 +77343,7 @@ async function wrapWalletInterface(wallet) {
77213
77343
  * LICENSE file in the root directory of this source tree.
77214
77344
  *
77215
77345
  */
77216
- const log$17 = globalLogger.createChild("JettonsManager");
77346
+ const log$18 = globalLogger.createChild("JettonsManager");
77217
77347
  const TON_ADDRESS = "TON";
77218
77348
  function isTonAddress(address) {
77219
77349
  return address.toLowerCase() === "ton";
@@ -77253,7 +77383,7 @@ var JettonsManager = class {
77253
77383
  ttl: 1e3 * 60 * 10
77254
77384
  });
77255
77385
  for (const network of this.networkManager.getConfiguredNetworks()) this.addTonToCache(network);
77256
- log$17.info("JettonsManager initialized", { cacheSize });
77386
+ log$18.info("JettonsManager initialized", { cacheSize });
77257
77387
  }
77258
77388
  /**
77259
77389
  * Add TON native token to cache for a specific network
@@ -77274,19 +77404,19 @@ var JettonsManager = class {
77274
77404
  const cacheKey = this.normalizedCacheKey(targetNetwork, jettonAddress);
77275
77405
  const cachedInfo = this.cache.get(cacheKey);
77276
77406
  if (cachedInfo) {
77277
- log$17.debug("Jetton info found in cache", {
77407
+ log$18.debug("Jetton info found in cache", {
77278
77408
  jettonAddress,
77279
77409
  network: targetNetwork
77280
77410
  });
77281
77411
  return cachedInfo;
77282
77412
  }
77283
- log$17.debug("Jetton info not found in cache", {
77413
+ log$18.debug("Jetton info not found in cache", {
77284
77414
  jettonAddress,
77285
77415
  network: targetNetwork
77286
77416
  });
77287
77417
  const address = asMaybeAddressFriendly(jettonAddress);
77288
77418
  if (!address) {
77289
- log$17.error("Invalid jetton address format", {
77419
+ log$18.error("Invalid jetton address format", {
77290
77420
  jettonAddress,
77291
77421
  network: targetNetwork
77292
77422
  });
@@ -77321,7 +77451,7 @@ var JettonsManager = class {
77321
77451
  }
77322
77452
  return null;
77323
77453
  } catch (error) {
77324
- log$17.error("Error getting jetton info", {
77454
+ log$18.error("Error getting jetton info", {
77325
77455
  error,
77326
77456
  jettonAddress,
77327
77457
  network: targetNetwork
@@ -77340,7 +77470,7 @@ var JettonsManager = class {
77340
77470
  const targetNetwork = network;
77341
77471
  try {
77342
77472
  const apiClient = this.networkManager.getClient(targetNetwork);
77343
- log$17.debug("Getting address jettons", {
77473
+ log$18.debug("Getting address jettons", {
77344
77474
  userAddress,
77345
77475
  network: targetNetwork,
77346
77476
  offset,
@@ -77354,13 +77484,13 @@ var JettonsManager = class {
77354
77484
  if (!response.jettons) return [];
77355
77485
  const addressJettons = [];
77356
77486
  for (const item of response.jettons) addressJettons.push(item);
77357
- log$17.debug("Retrieved address jettons", {
77487
+ log$18.debug("Retrieved address jettons", {
77358
77488
  count: addressJettons.length,
77359
77489
  network: targetNetwork
77360
77490
  });
77361
77491
  return addressJettons;
77362
77492
  } catch (error) {
77363
- log$17.error("Failed to get address jettons", {
77493
+ log$18.error("Failed to get address jettons", {
77364
77494
  error,
77365
77495
  userAddress,
77366
77496
  network: targetNetwork
@@ -77384,14 +77514,14 @@ var JettonsManager = class {
77384
77514
  uri: emulationInfo.extra.uri
77385
77515
  };
77386
77516
  this.cache.set(cacheKey, jettonInfo);
77387
- log$17.debug("Added jetton info from emulation to cache", {
77517
+ log$18.debug("Added jetton info from emulation to cache", {
77388
77518
  jettonAddress,
77389
77519
  network,
77390
77520
  name: jettonInfo.name,
77391
77521
  symbol: jettonInfo.symbol
77392
77522
  });
77393
77523
  } catch (error) {
77394
- log$17.error("Error adding jetton from emulation", {
77524
+ log$18.error("Error adding jetton from emulation", {
77395
77525
  error,
77396
77526
  jettonAddress,
77397
77527
  network
@@ -77408,7 +77538,7 @@ var JettonsManager = class {
77408
77538
  if (!addressMetadata.is_indexed || !addressMetadata.token_info) continue;
77409
77539
  const jettonMasterInfo = addressMetadata.token_info.find((info) => typeof info === "object" && info !== null && "type" in info && info.type === "jetton_masters");
77410
77540
  if (jettonMasterInfo) {
77411
- log$17.debug("Adding jetton from emulation metadata", {
77541
+ log$18.debug("Adding jetton from emulation metadata", {
77412
77542
  jettonAddress,
77413
77543
  network
77414
77544
  });
@@ -77416,12 +77546,12 @@ var JettonsManager = class {
77416
77546
  addedCount++;
77417
77547
  }
77418
77548
  }
77419
- if (addedCount > 0) log$17.info("Added jettons from emulation metadata", {
77549
+ if (addedCount > 0) log$18.info("Added jettons from emulation metadata", {
77420
77550
  addedCount,
77421
77551
  network
77422
77552
  });
77423
77553
  } catch (error) {
77424
- log$17.error("Error adding jettons from emulation metadata", {
77554
+ log$18.error("Error adding jettons from emulation metadata", {
77425
77555
  error,
77426
77556
  network
77427
77557
  });
@@ -77462,11 +77592,11 @@ var JettonsManager = class {
77462
77592
  if (network) {
77463
77593
  for (const key of this.cache.keys()) if (key.startsWith(`${network.chainId}:`)) this.cache.delete(key);
77464
77594
  this.addTonToCache(network);
77465
- log$17.info("Jetton cache cleared for network", { network });
77595
+ log$18.info("Jetton cache cleared for network", { network });
77466
77596
  } else {
77467
77597
  this.cache.clear();
77468
77598
  for (const net of this.networkManager.getConfiguredNetworks()) this.addTonToCache(net);
77469
- log$17.info("Jetton cache cleared for all networks");
77599
+ log$18.info("Jetton cache cleared for all networks");
77470
77600
  }
77471
77601
  }
77472
77602
  };
@@ -77666,7 +77796,7 @@ var DefiManager = class {
77666
77796
  * LICENSE file in the root directory of this source tree.
77667
77797
  *
77668
77798
  */
77669
- const log$16 = globalLogger.createChild("SwapManager");
77799
+ const log$17 = globalLogger.createChild("SwapManager");
77670
77800
  /**
77671
77801
  * SwapManager - manages swap providers and delegates swap operations
77672
77802
  *
@@ -77684,7 +77814,7 @@ var SwapManager = class extends DefiManager {
77684
77814
  * @returns Promise resolving to swap quote
77685
77815
  */
77686
77816
  async getQuote(params, providerId) {
77687
- log$16.debug("Getting swap quote", {
77817
+ log$17.debug("Getting swap quote", {
77688
77818
  fromToken: params.from,
77689
77819
  toToken: params.to,
77690
77820
  amount: params.amount,
@@ -77693,14 +77823,14 @@ var SwapManager = class extends DefiManager {
77693
77823
  });
77694
77824
  try {
77695
77825
  const quote = await this.getProvider(providerId || this.defaultProviderId).getQuote(params);
77696
- log$16.debug("Received swap quote", {
77826
+ log$17.debug("Received swap quote", {
77697
77827
  fromAmount: quote.fromAmount,
77698
77828
  toAmount: quote.toAmount,
77699
77829
  priceImpact: quote.priceImpact
77700
77830
  });
77701
77831
  return quote;
77702
77832
  } catch (error) {
77703
- log$16.error("Failed to get swap quote", {
77833
+ log$17.error("Failed to get swap quote", {
77704
77834
  error,
77705
77835
  params
77706
77836
  });
@@ -77714,16 +77844,16 @@ var SwapManager = class extends DefiManager {
77714
77844
  */
77715
77845
  async buildSwapTransaction(params) {
77716
77846
  const providerId = params.quote.providerId || this.defaultProviderId;
77717
- log$16.debug("Building swap transaction", {
77847
+ log$17.debug("Building swap transaction", {
77718
77848
  providerId,
77719
77849
  userAddress: params.userAddress
77720
77850
  });
77721
77851
  try {
77722
77852
  const transaction = await this.getProvider(providerId).buildSwapTransaction(params);
77723
- log$16.debug("Built swap transaction", params.quote);
77853
+ log$17.debug("Built swap transaction", params.quote);
77724
77854
  return transaction;
77725
77855
  } catch (error) {
77726
- log$16.error("Failed to build swap transaction", {
77856
+ log$17.error("Failed to build swap transaction", {
77727
77857
  error,
77728
77858
  params
77729
77859
  });
@@ -77765,7 +77895,7 @@ var StakingError = class extends DefiError {
77765
77895
  * LICENSE file in the root directory of this source tree.
77766
77896
  *
77767
77897
  */
77768
- const log$15 = globalLogger.createChild("StakingManager");
77898
+ const log$16 = globalLogger.createChild("StakingManager");
77769
77899
  /**
77770
77900
  * StakingManager - manages staking providers and delegates staking operations
77771
77901
  *
@@ -77782,13 +77912,13 @@ var StakingManager = class extends DefiManager {
77782
77912
  * @param providerId - Optional provider id to use
77783
77913
  */
77784
77914
  async getQuote(params, providerId) {
77785
- log$15.debug("Getting staking quote", params);
77915
+ log$16.debug("Getting staking quote", params);
77786
77916
  try {
77787
77917
  const quote = await this.getProvider(providerId).getQuote(params);
77788
- log$15.debug("Received staking quote", quote);
77918
+ log$16.debug("Received staking quote", quote);
77789
77919
  return quote;
77790
77920
  } catch (error) {
77791
- log$15.error("Failed to get staking quote", {
77921
+ log$16.error("Failed to get staking quote", {
77792
77922
  error,
77793
77923
  params
77794
77924
  });
@@ -77801,11 +77931,11 @@ var StakingManager = class extends DefiManager {
77801
77931
  * @param providerId - Optional provider id to use
77802
77932
  */
77803
77933
  async buildStakeTransaction(params, providerId) {
77804
- log$15.debug("Building staking transaction", params);
77934
+ log$16.debug("Building staking transaction", params);
77805
77935
  try {
77806
77936
  return await this.getProvider(providerId).buildStakeTransaction(params);
77807
77937
  } catch (error) {
77808
- log$15.error("Failed to build staking transaction", {
77938
+ log$16.error("Failed to build staking transaction", {
77809
77939
  error,
77810
77940
  params
77811
77941
  });
@@ -77819,7 +77949,7 @@ var StakingManager = class extends DefiManager {
77819
77949
  * @param providerId - Optional provider id to use
77820
77950
  */
77821
77951
  async getStakedBalance(userAddress, network, providerId) {
77822
- log$15.debug("Getting staking balance", {
77952
+ log$16.debug("Getting staking balance", {
77823
77953
  userAddress,
77824
77954
  network,
77825
77955
  provider: providerId || this.defaultProviderId
@@ -77827,7 +77957,7 @@ var StakingManager = class extends DefiManager {
77827
77957
  try {
77828
77958
  return await this.getProvider(providerId).getStakedBalance(userAddress, network);
77829
77959
  } catch (error) {
77830
- log$15.error("Failed to get staking balance", {
77960
+ log$16.error("Failed to get staking balance", {
77831
77961
  error,
77832
77962
  userAddress,
77833
77963
  network
@@ -77841,14 +77971,14 @@ var StakingManager = class extends DefiManager {
77841
77971
  * @param providerId - Optional provider id to use
77842
77972
  */
77843
77973
  async getStakingProviderInfo(network, providerId) {
77844
- log$15.debug("Getting staking info", {
77974
+ log$16.debug("Getting staking info", {
77845
77975
  network,
77846
77976
  provider: providerId || this.defaultProviderId
77847
77977
  });
77848
77978
  try {
77849
77979
  return await this.getProvider(providerId).getStakingProviderInfo(network);
77850
77980
  } catch (error) {
77851
- log$15.error("Failed to get staking info", {
77981
+ log$16.error("Failed to get staking info", {
77852
77982
  error,
77853
77983
  network
77854
77984
  });
@@ -77861,14 +77991,14 @@ var StakingManager = class extends DefiManager {
77861
77991
  * @param providerId - Optional provider id to use
77862
77992
  */
77863
77993
  getStakingProviderMetadata(network, providerId) {
77864
- log$15.debug("Getting staking metadata", {
77994
+ log$16.debug("Getting staking metadata", {
77865
77995
  network,
77866
77996
  provider: providerId || this.defaultProviderId
77867
77997
  });
77868
77998
  try {
77869
77999
  return this.getProvider(providerId).getStakingProviderMetadata(network);
77870
78000
  } catch (error) {
77871
- log$15.error("Failed to get staking metadata", {
78001
+ log$16.error("Failed to get staking metadata", {
77872
78002
  error,
77873
78003
  network
77874
78004
  });
@@ -77877,7 +78007,7 @@ var StakingManager = class extends DefiManager {
77877
78007
  }
77878
78008
  createError(message, code, details) {
77879
78009
  const errorCode = Object.values(StakingErrorCode).includes(code) ? code : StakingErrorCode.InvalidParams;
77880
- log$15.error(message, {
78010
+ log$16.error(message, {
77881
78011
  code,
77882
78012
  details
77883
78013
  });
@@ -77885,6 +78015,128 @@ var StakingManager = class extends DefiManager {
77885
78015
  }
77886
78016
  };
77887
78017
  //#endregion
78018
+ //#region ../walletkit/dist/esm/defi/gasless/errors.js
78019
+ /**
78020
+ * Copyright (c) TonTech.
78021
+ *
78022
+ * This source code is licensed under the MIT license found in the
78023
+ * LICENSE file in the root directory of this source tree.
78024
+ *
78025
+ */
78026
+ var GaslessErrorCode;
78027
+ (function(GaslessErrorCode) {
78028
+ GaslessErrorCode["UnsupportedFeeAsset"] = "UNSUPPORTED_FEE_ASSET";
78029
+ GaslessErrorCode["UnsupportedOperation"] = "UNSUPPORTED_OPERATION";
78030
+ GaslessErrorCode["QuoteFailed"] = "QUOTE_FAILED";
78031
+ GaslessErrorCode["SendFailed"] = "SEND_FAILED";
78032
+ GaslessErrorCode["ConfigFailed"] = "CONFIG_FAILED";
78033
+ GaslessErrorCode["SignMessageNotSupported"] = "SIGN_MESSAGE_NOT_SUPPORTED";
78034
+ GaslessErrorCode["TooManyMessages"] = "TOO_MANY_MESSAGES";
78035
+ GaslessErrorCode["QuoteExpired"] = "QUOTE_EXPIRED";
78036
+ GaslessErrorCode["WalletMismatch"] = "WALLET_MISMATCH";
78037
+ GaslessErrorCode["FeeAssetNotOwned"] = "FEE_ASSET_NOT_OWNED";
78038
+ })(GaslessErrorCode || (GaslessErrorCode = {}));
78039
+ var GaslessError = class extends DefiError {
78040
+ code;
78041
+ constructor(message, code, details) {
78042
+ super(message, code, details);
78043
+ this.name = "GaslessError";
78044
+ this.code = code;
78045
+ }
78046
+ };
78047
+ //#endregion
78048
+ //#region ../walletkit/dist/esm/defi/gasless/GaslessManager.js
78049
+ /**
78050
+ * Copyright (c) TonTech.
78051
+ *
78052
+ * This source code is licensed under the MIT license found in the
78053
+ * LICENSE file in the root directory of this source tree.
78054
+ *
78055
+ */
78056
+ const log$15 = globalLogger.createChild("GaslessManager");
78057
+ /**
78058
+ * GaslessManager — manages gasless relay providers and delegates gasless operations.
78059
+ *
78060
+ * Allows registration of multiple gasless providers and provides a unified API.
78061
+ * Providers can be switched dynamically.
78062
+ */
78063
+ var GaslessManager = class extends DefiManager {
78064
+ constructor(createFactoryContext) {
78065
+ super(createFactoryContext);
78066
+ }
78067
+ /**
78068
+ * Get static metadata for a gasless provider (display name, logo, url).
78069
+ */
78070
+ async getMetadata(providerId) {
78071
+ const selectedProviderId = providerId ?? this.defaultProviderId;
78072
+ log$15.debug("Getting gasless provider metadata", { providerId: selectedProviderId });
78073
+ try {
78074
+ return await this.getProvider(selectedProviderId).getMetadata();
78075
+ } catch (error) {
78076
+ log$15.error("Failed to get gasless provider metadata", { error });
78077
+ throw error;
78078
+ }
78079
+ }
78080
+ /**
78081
+ * Fetch the relayer's configuration (relay address + accepted fee assets).
78082
+ *
78083
+ * `network` defaults to the provider's first supported network.
78084
+ */
78085
+ async getConfig(network, providerId) {
78086
+ const provider = this.getProvider(providerId ?? this.defaultProviderId);
78087
+ const targetNetwork = network ?? provider.getSupportedNetworks()[0];
78088
+ log$15.debug("Getting gasless config", {
78089
+ network: targetNetwork?.chainId,
78090
+ providerId: providerId ?? this.defaultProviderId
78091
+ });
78092
+ try {
78093
+ return await provider.getConfig(targetNetwork);
78094
+ } catch (error) {
78095
+ log$15.error("Failed to get gasless config", { error });
78096
+ throw error;
78097
+ }
78098
+ }
78099
+ /**
78100
+ * Quote fees and obtain relayer-wrapped messages for signing.
78101
+ */
78102
+ async getQuote(params, providerId) {
78103
+ log$15.debug("Quoting gasless transaction", {
78104
+ network: params.network.chainId,
78105
+ walletAddress: params.walletAddress,
78106
+ feeAsset: params.feeAsset,
78107
+ messagesCount: params.messages.length,
78108
+ providerId: providerId ?? this.defaultProviderId
78109
+ });
78110
+ try {
78111
+ return await this.getProvider(providerId ?? this.defaultProviderId).getQuote(params);
78112
+ } catch (error) {
78113
+ log$15.error("Failed to quote gasless transaction", {
78114
+ error,
78115
+ params
78116
+ });
78117
+ throw error;
78118
+ }
78119
+ }
78120
+ /**
78121
+ * Submit a signed transaction BoC to the relayer.
78122
+ */
78123
+ async sendTransaction(params, providerId) {
78124
+ log$15.debug("Sending gasless transaction", {
78125
+ network: params.network.chainId,
78126
+ providerId: providerId ?? this.defaultProviderId
78127
+ });
78128
+ try {
78129
+ return await this.getProvider(providerId ?? this.defaultProviderId).sendTransaction(params);
78130
+ } catch (error) {
78131
+ log$15.error("Failed to send gasless transaction", { error });
78132
+ throw error;
78133
+ }
78134
+ }
78135
+ createError(message, code, details) {
78136
+ return new GaslessError(message, code, details);
78137
+ }
78138
+ };
78139
+ //#endregion
77888
78140
  //#region ../walletkit/dist/esm/core/EventEmitter.js
77889
78141
  /**
77890
78142
  * Copyright (c) TonTech.
@@ -79676,6 +79928,7 @@ var TonWalletKit = class {
79676
79928
  swapManager;
79677
79929
  streamingManager;
79678
79930
  stakingManager;
79931
+ gaslessManager;
79679
79932
  initializer;
79680
79933
  eventProcessor;
79681
79934
  bridgeManager;
@@ -79702,6 +79955,7 @@ var TonWalletKit = class {
79702
79955
  this.jettonsManager = new JettonsManager(1e4, this.eventEmitter, this.networkManager);
79703
79956
  this.swapManager = new SwapManager(() => this.createFactoryContext());
79704
79957
  this.stakingManager = new StakingManager(() => this.createFactoryContext());
79958
+ this.gaslessManager = new GaslessManager(() => this.createFactoryContext());
79705
79959
  this.eventEmitter.on("restoreConnection", async ({ payload: event }) => {
79706
79960
  if (!event.domain) {
79707
79961
  log$8.error("Domain is required for restore connection");
@@ -80188,6 +80442,9 @@ var TonWalletKit = class {
80188
80442
  case "streaming":
80189
80443
  this.streamingManager.registerProvider(provider);
80190
80444
  break;
80445
+ case "gasless":
80446
+ this.gaslessManager.registerProvider(provider);
80447
+ break;
80191
80448
  default: throw new Error("Unknown provider type");
80192
80449
  }
80193
80450
  }
@@ -80222,6 +80479,12 @@ var TonWalletKit = class {
80222
80479
  return this.stakingManager;
80223
80480
  }
80224
80481
  /**
80482
+ * Gasless API access
80483
+ */
80484
+ get gasless() {
80485
+ return this.gaslessManager;
80486
+ }
80487
+ /**
80225
80488
  * Get the event emitter for this kit instance
80226
80489
  * Allows external components to listen to and emit events
80227
80490
  */