@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.
@@ -9261,40 +9261,84 @@ var require_nacl_fast = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9261
9261
  })(typeof module !== "undefined" && module.exports ? module.exports : self.nacl = self.nacl || {});
9262
9262
  }));
9263
9263
  //#endregion
9264
- //#region ../../node_modules/.pnpm/@tonconnect+protocol@2.5.0-alpha.1/node_modules/@tonconnect/protocol/lib/esm/index.mjs
9264
+ //#region ../../node_modules/.pnpm/@tonconnect+protocol@3.0.0/node_modules/@tonconnect/protocol/lib/esm/index.mjs
9265
9265
  var import_nacl_util = /* @__PURE__ */ __toESM(require_nacl_util(), 1);
9266
9266
  var import_nacl_fast = /* @__PURE__ */ __toESM(require_nacl_fast(), 1);
9267
+ /**
9268
+ * Error codes the wallet may return in {@link ConnectEventError}.
9269
+ *
9270
+ * @see [Connect event error codes (Connect spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/connect.md#connect-event-error-codes)
9271
+ */
9267
9272
  var CONNECT_EVENT_ERROR_CODES$1;
9268
9273
  (function(CONNECT_EVENT_ERROR_CODES) {
9274
+ /** Unexpected wallet-side failure. */
9269
9275
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9276
+ /** Request payload is malformed. */
9270
9277
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
9278
+ /** Wallet could not fetch the `tonconnect-manifest.json`. */
9271
9279
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["MANIFEST_NOT_FOUND_ERROR"] = 2] = "MANIFEST_NOT_FOUND_ERROR";
9280
+ /** Manifest was fetched but fails JSON / schema validation. */
9272
9281
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["MANIFEST_CONTENT_ERROR"] = 3] = "MANIFEST_CONTENT_ERROR";
9282
+ /** Wallet does not know the app / session. */
9273
9283
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9284
+ /** User explicitly declined the connect prompt. */
9274
9285
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
9286
+ /** Wallet does not support the requested method. */
9275
9287
  CONNECT_EVENT_ERROR_CODES[CONNECT_EVENT_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9276
9288
  })(CONNECT_EVENT_ERROR_CODES$1 || (CONNECT_EVENT_ERROR_CODES$1 = {}));
9289
+ /**
9290
+ * Per-item error codes returned inside a {@link ConnectItemReplyError}.
9291
+ *
9292
+ * @see [Connect item error codes (Connect spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/connect.md#connect-item-error-codes)
9293
+ */
9277
9294
  var CONNECT_ITEM_ERROR_CODES$1;
9278
9295
  (function(CONNECT_ITEM_ERROR_CODES) {
9296
+ /** Unexpected wallet-side failure. */
9279
9297
  CONNECT_ITEM_ERROR_CODES[CONNECT_ITEM_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9298
+ /** Wallet does not support this connect item. */
9280
9299
  CONNECT_ITEM_ERROR_CODES[CONNECT_ITEM_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9281
9300
  })(CONNECT_ITEM_ERROR_CODES$1 || (CONNECT_ITEM_ERROR_CODES$1 = {}));
9301
+ /**
9302
+ * Error codes the wallet may return from `sendTransaction`.
9303
+ *
9304
+ * @see [`sendTransaction` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#sendtransaction)
9305
+ */
9282
9306
  var SEND_TRANSACTION_ERROR_CODES$1;
9283
9307
  (function(SEND_TRANSACTION_ERROR_CODES) {
9308
+ /** Unexpected wallet-side failure. */
9284
9309
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9310
+ /** Request payload is malformed. */
9285
9311
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
9312
+ /** Wallet does not know the dApp / session. */
9286
9313
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9314
+ /** User explicitly declined the transaction. */
9287
9315
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
9316
+ /** Wallet does not support the method. */
9288
9317
  SEND_TRANSACTION_ERROR_CODES[SEND_TRANSACTION_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9289
9318
  })(SEND_TRANSACTION_ERROR_CODES$1 || (SEND_TRANSACTION_ERROR_CODES$1 = {}));
9319
+ /**
9320
+ * Error codes the wallet may return from `signData`.
9321
+ *
9322
+ * @see [`signData` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#signdata)
9323
+ */
9290
9324
  var SIGN_DATA_ERROR_CODES$1;
9291
9325
  (function(SIGN_DATA_ERROR_CODES) {
9326
+ /** Unexpected wallet-side failure. */
9292
9327
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9328
+ /** Invalid request payload. */
9293
9329
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
9330
+ /** Wallet does not know the dApp / session. */
9294
9331
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9332
+ /** User explicitly declined. */
9295
9333
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
9334
+ /** Wallet does not support `signData` method or the requested `type`. */
9296
9335
  SIGN_DATA_ERROR_CODES[SIGN_DATA_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9297
9336
  })(SIGN_DATA_ERROR_CODES$1 || (SIGN_DATA_ERROR_CODES$1 = {}));
9337
+ /**
9338
+ * Error codes the wallet may return from `disconnect`.
9339
+
9340
+ * @see [`disconnect` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#disconnect)
9341
+ */
9298
9342
  var DISCONNECT_ERROR_CODES$1;
9299
9343
  (function(DISCONNECT_ERROR_CODES) {
9300
9344
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
@@ -9302,14 +9346,27 @@ var DISCONNECT_ERROR_CODES$1;
9302
9346
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9303
9347
  DISCONNECT_ERROR_CODES[DISCONNECT_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9304
9348
  })(DISCONNECT_ERROR_CODES$1 || (DISCONNECT_ERROR_CODES$1 = {}));
9349
+ /**
9350
+ * Error codes the wallet may return from `signMessage`.
9351
+ *
9352
+ * @see [`signMessage` errors (RPC spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/rpc.md#signmessage)
9353
+ */
9305
9354
  var SIGN_MESSAGE_ERROR_CODES;
9306
9355
  (function(SIGN_MESSAGE_ERROR_CODES) {
9356
+ /** Unexpected wallet-side failure. */
9307
9357
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["UNKNOWN_ERROR"] = 0] = "UNKNOWN_ERROR";
9358
+ /** Invalid request payload. */
9308
9359
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["BAD_REQUEST_ERROR"] = 1] = "BAD_REQUEST_ERROR";
9360
+ /** Wallet does not know the dApp / session. */
9309
9361
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["UNKNOWN_APP_ERROR"] = 100] = "UNKNOWN_APP_ERROR";
9362
+ /** User explicitly declined. */
9310
9363
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["USER_REJECTS_ERROR"] = 300] = "USER_REJECTS_ERROR";
9364
+ /** Wallet does not support `signMessage`. */
9311
9365
  SIGN_MESSAGE_ERROR_CODES[SIGN_MESSAGE_ERROR_CODES["METHOD_NOT_SUPPORTED"] = 400] = "METHOD_NOT_SUPPORTED";
9312
9366
  })(SIGN_MESSAGE_ERROR_CODES || (SIGN_MESSAGE_ERROR_CODES = {}));
9367
+ /**
9368
+ * Two baseline TON network IDs.
9369
+ */
9313
9370
  var CHAIN$1;
9314
9371
  (function(CHAIN) {
9315
9372
  CHAIN["MAINNET"] = "-239";
@@ -9351,6 +9408,20 @@ function decode$1(value, urlSafe = false) {
9351
9408
  }
9352
9409
  };
9353
9410
  }
9411
+ /**
9412
+ * UTF-8 base64 codec used by `@tonconnect/protocol`. Wraps the NaCl
9413
+ * helpers with optional URL-safe encoding and a typed decoder that can
9414
+ * yield a string, an object (JSON-parsed), or the raw byte array.
9415
+ *
9416
+ * @example
9417
+ * ```ts
9418
+ * import { Base64 } from '@tonconnect/protocol';
9419
+ *
9420
+ * const encoded = Base64.encode({ hello: 'world' });
9421
+ * const obj = Base64.decode(encoded).toObject<{ hello: string }>();
9422
+ * const bin = Base64.decode(Base64.encode('Hello')).toUint8Array();
9423
+ * ```
9424
+ */
9354
9425
  const Base64$1 = {
9355
9426
  encode: encode$1,
9356
9427
  decode: decode$1
@@ -9474,16 +9545,22 @@ function decodeEmbeddedRequestParam(reqParam) {
9474
9545
  const json = fromBase64Url(reqParam);
9475
9546
  return decodeWireEmbeddedRequest(JSON.parse(json));
9476
9547
  }
9548
+ /** Concatenate two byte arrays into a new `Uint8Array`. */
9477
9549
  function concatUint8Arrays(buffer1, buffer2) {
9478
9550
  const mergedArray = new Uint8Array(buffer1.length + buffer2.length);
9479
9551
  mergedArray.set(buffer1);
9480
9552
  mergedArray.set(buffer2, buffer1.length);
9481
9553
  return mergedArray;
9482
9554
  }
9555
+ /**
9556
+ * Split `array` at `index` and return the two halves as fresh
9557
+ * `Uint8Array`s.
9558
+ */
9483
9559
  function splitToUint8Arrays(array, index) {
9484
9560
  if (index >= array.length) throw new Error("Index is out of buffer");
9485
9561
  return [array.slice(0, index), array.slice(index)];
9486
9562
  }
9563
+ /** Hex-encode a byte array, lowercase, no `0x` prefix. */
9487
9564
  function toHexString(byteArray) {
9488
9565
  let hexString = "";
9489
9566
  byteArray.forEach((byte) => {
@@ -9491,13 +9568,52 @@ function toHexString(byteArray) {
9491
9568
  });
9492
9569
  return hexString;
9493
9570
  }
9571
+ /**
9572
+ * Inverse of {@link toHexString}. Throws when `hexString` has an odd length.
9573
+ */
9494
9574
  function hexToByteArray$1(hexString) {
9495
9575
  if (hexString.length % 2 !== 0) throw new Error(`Cannot convert ${hexString} to bytesArray`);
9496
9576
  const result = new Uint8Array(hexString.length / 2);
9497
9577
  for (let i = 0; i < hexString.length; i += 2) result[i / 2] = parseInt(hexString.slice(i, i + 2), 16);
9498
9578
  return result;
9499
9579
  }
9580
+ /**
9581
+ * Implements the TON Connect session-encryption protocol on top of NaCl's
9582
+ * `crypto_box`.
9583
+ *
9584
+ * The protocol is symmetric: each side encrypts the messages it sends and
9585
+ * decrypts the messages it receives. On the dApp side that means encrypting
9586
+ * outgoing {@link AppMessage} and decrypting incoming {@link WalletMessage};
9587
+ * the wallet does the reverse.
9588
+ *
9589
+ * @example
9590
+ * ```ts
9591
+ * import { SessionCrypto, Base64, hexToByteArray } from '@tonconnect/protocol';
9592
+ *
9593
+ * // Generate a fresh session
9594
+ * const session = new SessionCrypto();
9595
+ * const myClientId = session.sessionId; // hex public key (sent to the peer)
9596
+ *
9597
+ * // Encrypt an outgoing message for the peer
9598
+ * const ciphertext = session.encrypt(
9599
+ * JSON.stringify(message),
9600
+ * hexToByteArray(peerClientId)
9601
+ * );
9602
+ *
9603
+ * // Decrypt an incoming message from the peer
9604
+ * const plaintext = session.decrypt(
9605
+ * Base64.decode(bridgeMessage.message).toUint8Array(),
9606
+ * hexToByteArray(bridgeMessage.from)
9607
+ * );
9608
+ * ```
9609
+ *
9610
+ * @see [Session protocol (Session spec)](https://github.com/ton-blockchain/ton-connect/blob/main/spec/session.md)
9611
+ */
9500
9612
  var SessionCrypto = class {
9613
+ /**
9614
+ * Reuse an existing {@link KeyPair} (resuming a session) or generate a
9615
+ * fresh one (`crypto_box.keyPair()`) when omitted.
9616
+ */
9501
9617
  constructor(keyPair) {
9502
9618
  this.nonceLength = 24;
9503
9619
  this.keyPair = keyPair ? this.createKeypairFromString(keyPair) : this.createKeypair();
@@ -9515,17 +9631,31 @@ var SessionCrypto = class {
9515
9631
  createNonce() {
9516
9632
  return import_nacl_fast.default.randomBytes(this.nonceLength);
9517
9633
  }
9634
+ /**
9635
+ * Encrypt `message` for `receiverPublicKey` using a fresh 24-byte random
9636
+ * nonce. Returns `nonce || ciphertext` as raw bytes; base64-encode this
9637
+ * value before placing it in the bridge `POST /message` body.
9638
+ */
9518
9639
  encrypt(message, receiverPublicKey) {
9519
9640
  const encodedMessage = new TextEncoder().encode(message);
9520
9641
  const nonce = this.createNonce();
9521
9642
  return concatUint8Arrays(nonce, import_nacl_fast.default.box(encodedMessage, nonce, receiverPublicKey, this.keyPair.secretKey));
9522
9643
  }
9644
+ /**
9645
+ * Decrypt the `nonce || ciphertext` blob received from the bridge.
9646
+ * Throws if `nacl.box.open` rejects the message — wrong key, truncated
9647
+ * input or tampered ciphertext.
9648
+ */
9523
9649
  decrypt(message, senderPublicKey) {
9524
9650
  const [nonce, internalMessage] = splitToUint8Arrays(message, this.nonceLength);
9525
9651
  const decrypted = import_nacl_fast.default.box.open(internalMessage, nonce, senderPublicKey, this.keyPair.secretKey);
9526
9652
  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()}`);
9527
9653
  return new TextDecoder().decode(decrypted);
9528
9654
  }
9655
+ /**
9656
+ * Export the underlying keypair as a {@link KeyPair} of hex strings.
9657
+ * Persist this in dApp / wallet storage to resume the session later.
9658
+ */
9529
9659
  stringifyKeypair() {
9530
9660
  return {
9531
9661
  publicKey: toHexString(this.keyPair.publicKey),
@@ -30128,7 +30258,7 @@ async function CallForSuccess(toCall, attempts = 20, delayMs = 100, shouldRetry)
30128
30258
  return await toCall();
30129
30259
  } catch (err) {
30130
30260
  lastError = err;
30131
- if (shouldRetry && !shouldRetry(err)) throw err;
30261
+ if (typeof shouldRetry === "function" && shouldRetry(err) === false) throw err;
30132
30262
  i++;
30133
30263
  await delay(delayMs);
30134
30264
  }
@@ -30249,7 +30379,7 @@ var MemoryStorageAdapter = class {
30249
30379
  * LICENSE file in the root directory of this source tree.
30250
30380
  *
30251
30381
  */
30252
- const log$36 = globalLogger.createChild("StorageAdapter");
30382
+ const log$37 = globalLogger.createChild("StorageAdapter");
30253
30383
  /**
30254
30384
  * Create storage adapter based on environment and preferences
30255
30385
  */
@@ -30257,7 +30387,7 @@ function createStorageAdapter(config = {}) {
30257
30387
  if (typeof localStorage !== "undefined") try {
30258
30388
  return new LocalStorageAdapter(config);
30259
30389
  } catch (error) {
30260
- log$36.warn("Failed to create LocalStorageAdapter, falling back to memory", { error });
30390
+ log$37.warn("Failed to create LocalStorageAdapter, falling back to memory", { error });
30261
30391
  }
30262
30392
  if (config.allowMemory) return new MemoryStorageAdapter(config);
30263
30393
  else throw new Error("No storage adapter available");
@@ -30271,7 +30401,7 @@ function createStorageAdapter(config = {}) {
30271
30401
  * LICENSE file in the root directory of this source tree.
30272
30402
  *
30273
30403
  */
30274
- const log$35 = globalLogger.createChild("Storage");
30404
+ const log$36 = globalLogger.createChild("Storage");
30275
30405
  /**
30276
30406
  * High-level storage interface with generic type support
30277
30407
  * Wraps StorageAdapter to provide type-safe get/set operations
@@ -30292,7 +30422,7 @@ var Storage = class {
30292
30422
  if (value === null) return null;
30293
30423
  return JSON.parse(value);
30294
30424
  } catch (error) {
30295
- log$35.warn("Failed to parse stored value", {
30425
+ log$36.warn("Failed to parse stored value", {
30296
30426
  key,
30297
30427
  error
30298
30428
  });
@@ -30309,7 +30439,7 @@ var Storage = class {
30309
30439
  const serialized = JSON.stringify(value);
30310
30440
  await this.adapter.set(key, serialized);
30311
30441
  } catch (error) {
30312
- log$35.error("Failed to serialize value for storage", {
30442
+ log$36.error("Failed to serialize value for storage", {
30313
30443
  key,
30314
30444
  error
30315
30445
  });
@@ -30688,7 +30818,7 @@ var WalletManager = class {
30688
30818
  * LICENSE file in the root directory of this source tree.
30689
30819
  *
30690
30820
  */
30691
- const log$34 = globalLogger.createChild("TONConnectStoredSessionManager");
30821
+ const log$35 = globalLogger.createChild("TONConnectStoredSessionManager");
30692
30822
  var TONConnectStoredSessionManager = class {
30693
30823
  sessions = /* @__PURE__ */ new Map();
30694
30824
  storage;
@@ -30821,16 +30951,16 @@ var TONConnectStoredSessionManager = class {
30821
30951
  const wallet = this.walletManager.getWallet(session.walletId);
30822
30952
  if (wallet) session.walletAddress = wallet.getAddress();
30823
30953
  else {
30824
- log$34.warn("Session Wallet not found for session", { sessionId: session.sessionId });
30954
+ log$35.warn("Session Wallet not found for session", { sessionId: session.sessionId });
30825
30955
  continue;
30826
30956
  }
30827
30957
  }
30828
30958
  this.sessions.set(session.sessionId, session);
30829
30959
  }
30830
- log$34.debug("Loaded session metadata", { count: storedSessions.length });
30960
+ log$35.debug("Loaded session metadata", { count: storedSessions.length });
30831
30961
  }
30832
30962
  } catch (error) {
30833
- log$34.warn("Failed to load sessions from storage", { error });
30963
+ log$35.warn("Failed to load sessions from storage", { error });
30834
30964
  }
30835
30965
  }
30836
30966
  /**
@@ -30841,7 +30971,7 @@ var TONConnectStoredSessionManager = class {
30841
30971
  const sessionsToStore = Array.from(this.sessions.values());
30842
30972
  await this.storage.set(this.storageKey, sessionsToStore);
30843
30973
  } catch (error) {
30844
- log$34.warn("Failed to persist sessions to storage", { error });
30974
+ log$35.warn("Failed to persist sessions to storage", { error });
30845
30975
  }
30846
30976
  }
30847
30977
  async migrateSessions() {
@@ -71012,7 +71142,7 @@ globalLogger.createChild("ExtensionTransport");
71012
71142
  * LICENSE file in the root directory of this source tree.
71013
71143
  *
71014
71144
  */
71015
- const log$32 = globalLogger.createChild("BridgeManager");
71145
+ const log$33 = globalLogger.createChild("BridgeManager");
71016
71146
  var BridgeManager = class {
71017
71147
  config;
71018
71148
  bridgeProvider;
@@ -71054,7 +71184,7 @@ var BridgeManager = class {
71054
71184
  this.walletKitConfig = walletKitConfig;
71055
71185
  this.jsBridgeTransport = config?.jsBridgeTransport;
71056
71186
  if (this.config.bridgeUrl && !this.config.disableHttpConnection) this.bridgeProvider = new C(this.config.bridgeUrl, this.queueBridgeEvent.bind(this), (error) => {
71057
- log$32.error("Bridge listener error", { error: error.toString() });
71187
+ log$33.error("Bridge listener error", { error: error.toString() });
71058
71188
  this.analytics?.emitBridgeClientConnectError({
71059
71189
  error_message: `${error?.toString() || "Unknown error"}${error?.errorCode ? ` (Code: ${error?.errorCode})` : ""}`,
71060
71190
  trace_id: error?.traceId,
@@ -71068,12 +71198,12 @@ var BridgeManager = class {
71068
71198
  */
71069
71199
  async start() {
71070
71200
  if (this.isActive === true) {
71071
- log$32.warn("Bridge already started");
71201
+ log$33.warn("Bridge already started");
71072
71202
  return;
71073
71203
  }
71074
71204
  this.isActive = true;
71075
71205
  if (this.isConnected === true) {
71076
- log$32.warn("Bridge already connected");
71206
+ log$33.warn("Bridge already connected");
71077
71207
  return;
71078
71208
  }
71079
71209
  try {
@@ -71085,7 +71215,7 @@ var BridgeManager = class {
71085
71215
  }
71086
71216
  } catch (error) {
71087
71217
  this.isActive = false;
71088
- log$32.error("Failed to start bridge", { error });
71218
+ log$33.error("Failed to start bridge", { error });
71089
71219
  throw error;
71090
71220
  }
71091
71221
  const requestProcessing = () => {
@@ -71098,10 +71228,10 @@ var BridgeManager = class {
71098
71228
  * Create new session for a dApp connection
71099
71229
  */
71100
71230
  async createSession(appSessionId) {
71101
- log$32.info("[BRIDGE] Creating session", { appSessionId });
71231
+ log$33.info("[BRIDGE] Creating session", { appSessionId });
71102
71232
  if (!await this.sessionManager.getSession(appSessionId)) throw new WalletKitError(ERROR_CODES.SESSION_NOT_FOUND, `Session not found`, void 0, { appSessionId });
71103
71233
  if (this.bridgeProvider && this.isConnected) {
71104
- log$32.info("[BRIDGE] Updating clients");
71234
+ log$33.info("[BRIDGE] Updating clients");
71105
71235
  await this.updateClients();
71106
71236
  }
71107
71237
  }
@@ -71110,7 +71240,7 @@ var BridgeManager = class {
71110
71240
  */
71111
71241
  async removeSession(appSessionId) {
71112
71242
  if (this.bridgeProvider && this.isConnected) await this.updateClients();
71113
- log$32.debug("Session removed", { appSessionId });
71243
+ log$33.debug("Session removed", { appSessionId });
71114
71244
  }
71115
71245
  /**
71116
71246
  * Send response to dApp
@@ -71135,12 +71265,12 @@ var BridgeManager = class {
71135
71265
  }
71136
71266
  try {
71137
71267
  await this.bridgeProvider.send(response, sessionCrypto, sessionId, { traceId: event?.traceId });
71138
- log$32.debug("Response sent successfully", {
71268
+ log$33.debug("Response sent successfully", {
71139
71269
  sessionId,
71140
71270
  requestId: event.id
71141
71271
  });
71142
71272
  } catch (error) {
71143
- log$32.error("Failed to send response through bridge", {
71273
+ log$33.error("Failed to send response through bridge", {
71144
71274
  sessionId,
71145
71275
  requestId: event.id,
71146
71276
  error
@@ -71222,7 +71352,7 @@ var BridgeManager = class {
71222
71352
  await this.bridgeProvider?.restoreConnection(clients, { lastEventId: this.lastEventId });
71223
71353
  this.isConnected = true;
71224
71354
  this.reconnectAttempts = 0;
71225
- log$32.info("Bridge connected successfully");
71355
+ log$33.info("Bridge connected successfully");
71226
71356
  if (this.analytics) {
71227
71357
  const client = clients[0];
71228
71358
  this.analytics.emitBridgeClientConnectEstablished({
@@ -71231,7 +71361,7 @@ var BridgeManager = class {
71231
71361
  });
71232
71362
  }
71233
71363
  } catch (error) {
71234
- log$32.error("Bridge connection failed", { error: error?.toString() });
71364
+ log$33.error("Bridge connection failed", { error: error?.toString() });
71235
71365
  this.analytics?.emitBridgeClientConnectError({
71236
71366
  error_message: `${error?.toString() || "Unknown error"}${error?.errorCode ? ` (Code: ${error?.errorCode})` : ""}`,
71237
71367
  trace_id: error?.traceId ?? connectTraceId,
@@ -71240,9 +71370,9 @@ var BridgeManager = class {
71240
71370
  if (!this.config.disableHttpConnection) {
71241
71371
  if (this.reconnectAttempts < (this.config.maxReconnectAttempts || 5)) {
71242
71372
  this.reconnectAttempts++;
71243
- log$32.info("Bridge reconnection attempt", { attempt: this.reconnectAttempts });
71373
+ log$33.info("Bridge reconnection attempt", { attempt: this.reconnectAttempts });
71244
71374
  setTimeout(() => {
71245
- this.connectToSSEBridge().catch((error) => log$32.error("Bridge reconnection failed", { error }));
71375
+ this.connectToSSEBridge().catch((error) => log$33.error("Bridge reconnection failed", { error }));
71246
71376
  }, this.config.reconnectInterval);
71247
71377
  }
71248
71378
  }
@@ -71263,10 +71393,10 @@ var BridgeManager = class {
71263
71393
  * Add client to existing bridge connection
71264
71394
  */
71265
71395
  async updateClients() {
71266
- log$32.debug("Updating clients");
71396
+ log$33.debug("Updating clients");
71267
71397
  if (this.bridgeProvider) {
71268
71398
  const clients = await this.getClients();
71269
- log$32.info("[BRIDGE] Restoring connection", { clients: clients.length });
71399
+ log$33.info("[BRIDGE] Restoring connection", { clients: clients.length });
71270
71400
  await this.bridgeProvider.restoreConnection(clients, { lastEventId: this.lastEventId });
71271
71401
  }
71272
71402
  }
@@ -71274,17 +71404,17 @@ var BridgeManager = class {
71274
71404
  * Queue incoming bridge events for processing
71275
71405
  */
71276
71406
  queueBridgeEvent(event) {
71277
- log$32.debug("Bridge event queued", {
71407
+ log$33.debug("Bridge event queued", {
71278
71408
  eventId: event?.id,
71279
71409
  event
71280
71410
  });
71281
71411
  this.eventQueue.push(event);
71282
71412
  this.processBridgeEvents().catch((error) => {
71283
- log$32.error("Error in background event processing", { error });
71413
+ log$33.error("Error in background event processing", { error });
71284
71414
  });
71285
71415
  }
71286
71416
  queueJsBridgeEvent(messageInfo, event) {
71287
- log$32.debug("JS Bridge event queued", { eventId: messageInfo?.messageId });
71417
+ log$33.debug("JS Bridge event queued", { eventId: messageInfo?.messageId });
71288
71418
  if (!event) return;
71289
71419
  if (!event.traceId) event.traceId = v7();
71290
71420
  if (event.method == "connect") this.eventQueue.push({
@@ -71313,7 +71443,7 @@ var BridgeManager = class {
71313
71443
  walletId: messageInfo.walletId
71314
71444
  });
71315
71445
  this.processBridgeEvents().catch((error) => {
71316
- log$32.error("Error in background event processing", { error });
71446
+ log$33.error("Error in background event processing", { error });
71317
71447
  });
71318
71448
  }
71319
71449
  /**
@@ -71325,7 +71455,7 @@ var BridgeManager = class {
71325
71455
  */
71326
71456
  async processBridgeEvents() {
71327
71457
  if (this.isProcessing) {
71328
- log$32.debug("Event processing already in progress, skipping");
71458
+ log$33.debug("Event processing already in progress, skipping");
71329
71459
  return;
71330
71460
  }
71331
71461
  this.isProcessing = true;
@@ -71338,7 +71468,7 @@ var BridgeManager = class {
71338
71468
  }
71339
71469
  }
71340
71470
  } catch (error) {
71341
- log$32.error("Error during event processing", { error });
71471
+ log$33.error("Error during event processing", { error });
71342
71472
  this.isProcessing = false;
71343
71473
  this.restartConnection();
71344
71474
  return;
@@ -71351,7 +71481,7 @@ var BridgeManager = class {
71351
71481
  */
71352
71482
  async handleBridgeEvent(event) {
71353
71483
  try {
71354
- log$32.info("Bridge event received", { event });
71484
+ log$33.info("Bridge event received", { event });
71355
71485
  const rawEvent = {
71356
71486
  id: event.id || crypto.randomUUID(),
71357
71487
  method: event.method || "unknown",
@@ -71405,12 +71535,12 @@ var BridgeManager = class {
71405
71535
  try {
71406
71536
  await this.eventStore.storeEvent(rawEvent);
71407
71537
  if (this.eventEmitter) this.eventEmitter.emit("bridgeStorageUpdated", {}, "bridge-manager");
71408
- log$32.info("Event stored durably", {
71538
+ log$33.info("Event stored durably", {
71409
71539
  eventId: rawEvent.id,
71410
71540
  method: rawEvent.method
71411
71541
  });
71412
71542
  } catch (error) {
71413
- log$32.error("Failed to store event durably", {
71543
+ log$33.error("Failed to store event durably", {
71414
71544
  eventId: rawEvent.id,
71415
71545
  error: error.message
71416
71546
  });
@@ -71419,13 +71549,13 @@ var BridgeManager = class {
71419
71549
  method: rawEvent.method
71420
71550
  });
71421
71551
  }
71422
- log$32.info("Bridge event processed", { rawEvent });
71552
+ log$33.info("Bridge event processed", { rawEvent });
71423
71553
  if (event?.lastEventId && event.lastEventId !== this.lastEventId) {
71424
71554
  this.lastEventId = event.lastEventId;
71425
71555
  await this.saveLastEventId();
71426
71556
  }
71427
71557
  } catch (error) {
71428
- log$32.error("Error handling bridge event", { error });
71558
+ log$33.error("Error handling bridge event", { error });
71429
71559
  }
71430
71560
  }
71431
71561
  /**
@@ -71436,11 +71566,11 @@ var BridgeManager = class {
71436
71566
  const savedEventId = await this.storage.get(this.storageKey);
71437
71567
  if (savedEventId) {
71438
71568
  this.lastEventId = savedEventId;
71439
- log$32.debug("Loaded last event ID from storage", { lastEventId: this.lastEventId });
71569
+ log$33.debug("Loaded last event ID from storage", { lastEventId: this.lastEventId });
71440
71570
  }
71441
71571
  } catch (error) {
71442
71572
  const storageError = WalletKitError.fromError(ERROR_CODES.STORAGE_READ_FAILED, "Failed to load last event ID from storage", error);
71443
- log$32.warn("Failed to load last event ID from storage", { error: storageError });
71573
+ log$33.warn("Failed to load last event ID from storage", { error: storageError });
71444
71574
  }
71445
71575
  }
71446
71576
  /**
@@ -71450,11 +71580,11 @@ var BridgeManager = class {
71450
71580
  try {
71451
71581
  if (this.lastEventId) {
71452
71582
  await this.storage.set(this.storageKey, this.lastEventId);
71453
- log$32.debug("Saved last event ID to storage", { lastEventId: this.lastEventId });
71583
+ log$33.debug("Saved last event ID to storage", { lastEventId: this.lastEventId });
71454
71584
  }
71455
71585
  } catch (error) {
71456
71586
  const storageError = WalletKitError.fromError(ERROR_CODES.STORAGE_WRITE_FAILED, "Failed to save last event ID to storage", error);
71457
- log$32.warn("Failed to save last event ID to storage", { error: storageError });
71587
+ log$33.warn("Failed to save last event ID to storage", { error: storageError });
71458
71588
  }
71459
71589
  }
71460
71590
  };
@@ -71509,7 +71639,7 @@ function isValidHost(host) {
71509
71639
  * LICENSE file in the root directory of this source tree.
71510
71640
  *
71511
71641
  */
71512
- const log$31 = globalLogger.createChild("ManifestUtils");
71642
+ const log$32 = globalLogger.createChild("ManifestUtils");
71513
71643
  async function fetchManifest(manifestUrl, proxyUrl) {
71514
71644
  try {
71515
71645
  if (!isValidHost(new URL(manifestUrl).host)) return {
@@ -71528,14 +71658,14 @@ async function fetchManifest(manifestUrl, proxyUrl) {
71528
71658
  manifest: null,
71529
71659
  manifestFetchErrorCode: CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR
71530
71660
  };
71531
- log$31.info("Direct manifest fetch failed, trying proxy", { manifestUrl });
71661
+ log$32.info("Direct manifest fetch failed, trying proxy", { manifestUrl });
71532
71662
  return tryFetchManifest(`${proxyUrl}${manifestUrl}`);
71533
71663
  }
71534
71664
  async function tryFetchManifest(url) {
71535
71665
  try {
71536
71666
  const response = await fetch(url);
71537
71667
  if (!response.ok) {
71538
- log$31.error("Failed to fetch manifest not ok", {
71668
+ log$32.error("Failed to fetch manifest not ok", {
71539
71669
  url,
71540
71670
  status: response.status
71541
71671
  });
@@ -71549,7 +71679,7 @@ async function tryFetchManifest(url) {
71549
71679
  manifestFetchErrorCode: void 0
71550
71680
  };
71551
71681
  } catch (e) {
71552
- log$31.error("Failed to fetch manifest catched", {
71682
+ log$32.error("Failed to fetch manifest catched", {
71553
71683
  url,
71554
71684
  error: e
71555
71685
  });
@@ -71568,7 +71698,7 @@ async function tryFetchManifest(url) {
71568
71698
  * LICENSE file in the root directory of this source tree.
71569
71699
  *
71570
71700
  */
71571
- const log$30 = globalLogger.createChild("ConnectHandler");
71701
+ const log$31 = globalLogger.createChild("ConnectHandler");
71572
71702
  var ConnectHandler = class extends BasicHandler {
71573
71703
  config;
71574
71704
  analytics;
@@ -71589,7 +71719,7 @@ var ConnectHandler = class extends BasicHandler {
71589
71719
  manifest = result.manifest;
71590
71720
  manifestFetchErrorCode = result.manifestFetchErrorCode;
71591
71721
  } catch (error) {
71592
- log$30.warn("Failed to fetch manifest", { error });
71722
+ log$31.warn("Failed to fetch manifest", { error });
71593
71723
  }
71594
71724
  const preview = this.createPreview(event, manifestUrl, manifest, manifestFetchErrorCode);
71595
71725
  const connectEvent = {
@@ -71650,14 +71780,14 @@ var ConnectHandler = class extends BasicHandler {
71650
71780
  if (!finalManifestFetchErrorCode && dAppUrl) try {
71651
71781
  const parsedDAppUrl = new URL(dAppUrl);
71652
71782
  if (!isValidHost(parsedDAppUrl.host)) {
71653
- log$30.warn("Invalid dApp URL in manifest - invalid host format", {
71783
+ log$31.warn("Invalid dApp URL in manifest - invalid host format", {
71654
71784
  dAppUrl,
71655
71785
  host: parsedDAppUrl.host
71656
71786
  });
71657
71787
  finalManifestFetchErrorCode = CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR;
71658
71788
  }
71659
71789
  } catch (_) {
71660
- log$30.warn("Invalid dApp URL in manifest - failed to parse", { dAppUrl });
71790
+ log$31.warn("Invalid dApp URL in manifest - failed to parse", { dAppUrl });
71661
71791
  finalManifestFetchErrorCode = CONNECT_EVENT_ERROR_CODES$1.MANIFEST_CONTENT_ERROR;
71662
71792
  }
71663
71793
  }
@@ -72317,7 +72447,7 @@ function createTransferTransaction(params) {
72317
72447
  * LICENSE file in the root directory of this source tree.
72318
72448
  *
72319
72449
  */
72320
- const log$29 = globalLogger.createChild("ItemsResolver");
72450
+ const log$30 = globalLogger.createChild("ItemsResolver");
72321
72451
  /**
72322
72452
  * Resolve structured items (ton/jetton/nft) into raw TransactionRequestMessages.
72323
72453
  * After resolution, downstream code only needs to handle messages.
@@ -72335,7 +72465,7 @@ async function resolveItemsToMessages(items, wallet) {
72335
72465
  messages.push(resolveNftItem(item, wallet));
72336
72466
  break;
72337
72467
  default:
72338
- log$29.warn("Unknown item type, skipping", { item });
72468
+ log$30.warn("Unknown item type, skipping", { item });
72339
72469
  break;
72340
72470
  }
72341
72471
  return messages;
@@ -72397,7 +72527,7 @@ function resolveNftItem(item, wallet) {
72397
72527
  * LICENSE file in the root directory of this source tree.
72398
72528
  *
72399
72529
  */
72400
- const log$28 = globalLogger.createChild("EventsUtils");
72530
+ const log$29 = globalLogger.createChild("EventsUtils");
72401
72531
  /**
72402
72532
  * Helper to get wallet from event
72403
72533
  */
@@ -72456,7 +72586,7 @@ function parseTonConnectTransactionRequest(event, wallet) {
72456
72586
  validation: validateTransactionRequestForWallet(request, wallet, event.isLocal)
72457
72587
  };
72458
72588
  } catch (error) {
72459
- log$28.error("Failed to parse transaction request", { error });
72589
+ log$29.error("Failed to parse transaction request", { error });
72460
72590
  errors.push("Failed to parse transaction request");
72461
72591
  return {
72462
72592
  result: void 0,
@@ -74829,7 +74959,7 @@ async function computeMoneyFlow(client, response, options = {}) {
74829
74959
  * LICENSE file in the root directory of this source tree.
74830
74960
  *
74831
74961
  */
74832
- const log$27 = globalLogger.createChild("TransactionPreview");
74962
+ const log$28 = globalLogger.createChild("TransactionPreview");
74833
74963
  const SIGN_MODE_EMULATION_VALUE = 2000000000n;
74834
74964
  async function createTransactionPreview(client, request, wallet, options = {}) {
74835
74965
  const isSignMode = (options.mode ?? "send") === "sign";
@@ -74881,7 +75011,7 @@ async function createTransactionPreviewIfPossible(config, client, request, walle
74881
75011
  try {
74882
75012
  preview = await CallForSuccess(() => createTransactionPreview(client, request, wallet, options));
74883
75013
  } catch (error) {
74884
- log$27.error("Failed to create transaction preview", { error });
75014
+ log$28.error("Failed to create transaction preview", { error });
74885
75015
  preview = {
74886
75016
  error: {
74887
75017
  code: ERROR_CODES.UNKNOWN_EMULATION_ERROR,
@@ -75156,7 +75286,7 @@ async function getTransactionStatus(client, params) {
75156
75286
  * LICENSE file in the root directory of this source tree.
75157
75287
  *
75158
75288
  */
75159
- const log$26 = globalLogger.createChild("TransactionHandler");
75289
+ const log$27 = globalLogger.createChild("TransactionHandler");
75160
75290
  var TransactionHandler = class extends BasicHandler {
75161
75291
  config;
75162
75292
  walletManager;
@@ -75178,7 +75308,7 @@ var TransactionHandler = class extends BasicHandler {
75178
75308
  async handle(event) {
75179
75309
  const wallet = getWalletFromEvent(this.walletManager, event);
75180
75310
  if (!wallet) {
75181
- log$26.error("Wallet not found", { event });
75311
+ log$27.error("Wallet not found", { event });
75182
75312
  return {
75183
75313
  error: {
75184
75314
  code: SEND_TRANSACTION_ERROR_CODES$1.UNKNOWN_APP_ERROR,
@@ -75189,7 +75319,7 @@ var TransactionHandler = class extends BasicHandler {
75189
75319
  }
75190
75320
  const requestValidation = this.parseTonConnectTransactionRequest(event, wallet);
75191
75321
  if (!requestValidation.result || !requestValidation?.validation?.isValid) {
75192
- log$26.error("Failed to parse transaction request", {
75322
+ log$27.error("Failed to parse transaction request", {
75193
75323
  event,
75194
75324
  requestValidation
75195
75325
  });
@@ -75241,7 +75371,7 @@ var TransactionHandler = class extends BasicHandler {
75241
75371
  * LICENSE file in the root directory of this source tree.
75242
75372
  *
75243
75373
  */
75244
- const log$25 = globalLogger.createChild("SignDataHandler");
75374
+ const log$26 = globalLogger.createChild("SignDataHandler");
75245
75375
  var SignDataHandler = class extends BasicHandler {
75246
75376
  analytics;
75247
75377
  walletManager;
@@ -75262,12 +75392,12 @@ var SignDataHandler = class extends BasicHandler {
75262
75392
  const wallet = walletId ? this.walletManager.getWallet(walletId) : void 0;
75263
75393
  const payload = this.parseDataToSign(event);
75264
75394
  if (!payload) {
75265
- log$25.error("No data to sign found in request", { event });
75395
+ log$26.error("No data to sign found in request", { event });
75266
75396
  throw new WalletKitError(ERROR_CODES.INVALID_REQUEST_EVENT, "No data to sign found in request", void 0, { eventId: event.id });
75267
75397
  }
75268
75398
  const preview = this.createDataPreview(payload.data, event);
75269
75399
  if (!preview) {
75270
- log$25.error("No preview found for data", { data: payload });
75400
+ log$26.error("No preview found for data", { data: payload });
75271
75401
  throw new WalletKitError(ERROR_CODES.RESPONSE_CREATION_FAILED, "Failed to create preview for sign data request", void 0, {
75272
75402
  eventId: event.id,
75273
75403
  data: payload
@@ -75324,7 +75454,7 @@ var SignDataHandler = class extends BasicHandler {
75324
75454
  }
75325
75455
  };
75326
75456
  } catch (error) {
75327
- log$25.error("Error deserializing cell", { error });
75457
+ log$26.error("Error deserializing cell", { error });
75328
75458
  return {
75329
75459
  type: "cell",
75330
75460
  value: {
@@ -75344,7 +75474,7 @@ var SignDataHandler = class extends BasicHandler {
75344
75474
  * LICENSE file in the root directory of this source tree.
75345
75475
  *
75346
75476
  */
75347
- const log$24 = globalLogger.createChild("SignMessageHandler");
75477
+ const log$25 = globalLogger.createChild("SignMessageHandler");
75348
75478
  var SignMessageHandler = class extends BasicHandler {
75349
75479
  config;
75350
75480
  walletManager;
@@ -75366,7 +75496,7 @@ var SignMessageHandler = class extends BasicHandler {
75366
75496
  async handle(event) {
75367
75497
  const wallet = getWalletFromEvent(this.walletManager, event);
75368
75498
  if (!wallet) {
75369
- log$24.error("Wallet not found", { event });
75499
+ log$25.error("Wallet not found", { event });
75370
75500
  return {
75371
75501
  error: {
75372
75502
  code: SIGN_MESSAGE_ERROR_CODES.UNKNOWN_APP_ERROR,
@@ -75377,7 +75507,7 @@ var SignMessageHandler = class extends BasicHandler {
75377
75507
  }
75378
75508
  const requestValidation = this.parseTonConnectTransactionRequest(event, wallet);
75379
75509
  if (!requestValidation.result || !requestValidation?.validation?.isValid) {
75380
- log$24.error("Failed to parse sign message request", {
75510
+ log$25.error("Failed to parse sign message request", {
75381
75511
  event,
75382
75512
  requestValidation
75383
75513
  });
@@ -75470,7 +75600,7 @@ var DisconnectHandler = class extends BasicHandler {
75470
75600
  * LICENSE file in the root directory of this source tree.
75471
75601
  *
75472
75602
  */
75473
- const log$23 = globalLogger.createChild("EventRouter");
75603
+ const log$24 = globalLogger.createChild("EventRouter");
75474
75604
  var EventRouter = class {
75475
75605
  config;
75476
75606
  eventEmitter;
@@ -75502,7 +75632,7 @@ var EventRouter = class {
75502
75632
  async routeEvent(event) {
75503
75633
  const validation = validateBridgeEvent(event);
75504
75634
  if (!validation.isValid) {
75505
- log$23.error("Invalid bridge event", { errors: validation.errors });
75635
+ log$24.error("Invalid bridge event", { errors: validation.errors });
75506
75636
  return;
75507
75637
  }
75508
75638
  try {
@@ -75517,7 +75647,7 @@ var EventRouter = class {
75517
75647
  try {
75518
75648
  await this.bridgeManager.sendResponse(event, result);
75519
75649
  } catch (error) {
75520
- log$23.error("Error sending response for error event", {
75650
+ log$24.error("Error sending response for error event", {
75521
75651
  error,
75522
75652
  event,
75523
75653
  result
@@ -75529,7 +75659,7 @@ var EventRouter = class {
75529
75659
  break;
75530
75660
  }
75531
75661
  } catch (error) {
75532
- log$23.error("Error routing event", { error });
75662
+ log$24.error("Error routing event", { error });
75533
75663
  throw error;
75534
75664
  }
75535
75665
  }
@@ -75656,7 +75786,7 @@ var EventRouter = class {
75656
75786
  * LICENSE file in the root directory of this source tree.
75657
75787
  *
75658
75788
  */
75659
- const log$22 = globalLogger.createChild("RequestProcessor");
75789
+ const log$23 = globalLogger.createChild("RequestProcessor");
75660
75790
  function hasConnectionResult(event) {
75661
75791
  return "connectionResult" in event;
75662
75792
  }
@@ -75725,7 +75855,7 @@ var RequestProcessor = class {
75725
75855
  }
75726
75856
  return;
75727
75857
  } catch (error) {
75728
- log$22.error("Failed to approve connect request", { error });
75858
+ log$23.error("Failed to approve connect request", { error });
75729
75859
  throw error;
75730
75860
  }
75731
75861
  }
@@ -75860,7 +75990,7 @@ var RequestProcessor = class {
75860
75990
  */
75861
75991
  async rejectConnectRequest(event, reason, errorCode) {
75862
75992
  try {
75863
- log$22.info("Connect request rejected", {
75993
+ log$23.info("Connect request rejected", {
75864
75994
  id: event.id,
75865
75995
  dAppName: event.preview.dAppInfo?.name || "",
75866
75996
  reason: reason || "User rejected connection"
@@ -75877,7 +76007,7 @@ var RequestProcessor = class {
75877
76007
  try {
75878
76008
  await this.bridgeManager.sendResponse(event, response, new SessionCrypto());
75879
76009
  } catch (error) {
75880
- log$22.error("Failed to send connect request rejection response", { error });
76010
+ log$23.error("Failed to send connect request rejection response", { error });
75881
76011
  }
75882
76012
  if (this.analytics) {
75883
76013
  const sessionData = event.from ? await this.sessionManager.getSession(sessionId) : void 0;
@@ -75906,7 +76036,7 @@ var RequestProcessor = class {
75906
76036
  }
75907
76037
  return;
75908
76038
  } catch (error) {
75909
- log$22.error("Failed to reject connect request", { error });
76039
+ log$23.error("Failed to reject connect request", { error });
75910
76040
  throw error;
75911
76041
  }
75912
76042
  }
@@ -75938,7 +76068,7 @@ var RequestProcessor = class {
75938
76068
  return { signedBoc };
75939
76069
  }
75940
76070
  } catch (error) {
75941
- log$22.error("Failed to approve transaction request", { error });
76071
+ log$23.error("Failed to approve transaction request", { error });
75942
76072
  if (error instanceof WalletKitError) throw error;
75943
76073
  if (error?.message?.includes("Ledger device")) throw new WalletKitError(ERROR_CODES.LEDGER_DEVICE_ERROR, "Ledger device error", error);
75944
76074
  throw error;
@@ -75988,7 +76118,7 @@ var RequestProcessor = class {
75988
76118
  }
75989
76119
  return;
75990
76120
  } catch (error) {
75991
- log$22.error("Failed to reject transaction request", { error });
76121
+ log$23.error("Failed to reject transaction request", { error });
75992
76122
  throw error;
75993
76123
  }
75994
76124
  }
@@ -76019,7 +76149,7 @@ var RequestProcessor = class {
76019
76149
  return { internalBoc };
76020
76150
  }
76021
76151
  } catch (error) {
76022
- log$22.error("Failed to approve sign message request", { error });
76152
+ log$23.error("Failed to approve sign message request", { error });
76023
76153
  throw error;
76024
76154
  }
76025
76155
  }
@@ -76037,7 +76167,7 @@ var RequestProcessor = class {
76037
76167
  };
76038
76168
  await this.sendBridgeMessage(event, void 0, response);
76039
76169
  } catch (error) {
76040
- log$22.error("Failed to reject sign message request", { error });
76170
+ log$23.error("Failed to reject sign message request", { error });
76041
76171
  throw error;
76042
76172
  }
76043
76173
  }
@@ -76140,7 +76270,7 @@ var RequestProcessor = class {
76140
76270
  };
76141
76271
  }
76142
76272
  } catch (error) {
76143
- log$22.error("Failed to approve sign data request", { error: error?.message?.toString() ?? error?.toString() });
76273
+ log$23.error("Failed to approve sign data request", { error: error?.message?.toString() ?? error?.toString() });
76144
76274
  if (error instanceof WalletKitError) throw error;
76145
76275
  throw error;
76146
76276
  }
@@ -76175,7 +76305,7 @@ var RequestProcessor = class {
76175
76305
  }
76176
76306
  return;
76177
76307
  } catch (error) {
76178
- log$22.error("Failed to reject sign data request", { error });
76308
+ log$23.error("Failed to reject sign data request", { error });
76179
76309
  throw error;
76180
76310
  }
76181
76311
  }
@@ -76254,7 +76384,7 @@ var RequestProcessor = class {
76254
76384
  */
76255
76385
  async function signTransactionInternal(wallet, request) {
76256
76386
  const signedBoc = await wallet.getSignedSendTransaction(request, { fakeSignature: false });
76257
- log$22.debug("Signing transaction", {
76387
+ log$23.debug("Signing transaction", {
76258
76388
  messagesNumber: request.messages.length,
76259
76389
  fromAddress: request.fromAddress,
76260
76390
  validUntil: request.validUntil
@@ -76310,7 +76440,7 @@ function parseDomain(url) {
76310
76440
  value: parsedUrl.host
76311
76441
  };
76312
76442
  } catch (error) {
76313
- log$22.error("Failed to parse domain", { error });
76443
+ log$23.error("Failed to parse domain", { error });
76314
76444
  return {
76315
76445
  lengthBytes: 0,
76316
76446
  value: ""
@@ -76350,7 +76480,7 @@ function toTonConnectSignDataPayload(payload) {
76350
76480
  const getEventUUID = () => {
76351
76481
  return crypto.randomUUID();
76352
76482
  };
76353
- const log$21 = globalLogger.createChild("EventStore");
76483
+ const log$22 = globalLogger.createChild("EventStore");
76354
76484
  const MAX_EVENT_SIZE_BYTES = 100 * 1024;
76355
76485
  /**
76356
76486
  * Concrete implementation of EventStore using Storage
@@ -76386,7 +76516,7 @@ var StorageEventStore = class {
76386
76516
  sizeBytes
76387
76517
  };
76388
76518
  await this.saveEvent(storedEvent);
76389
- log$21.info("Event stored", {
76519
+ log$22.info("Event stored", {
76390
76520
  eventId: storedEvent.id,
76391
76521
  eventType,
76392
76522
  sizeBytes,
@@ -76414,11 +76544,11 @@ var StorageEventStore = class {
76414
76544
  const allEvents = await this.getAllEventsFromStorage();
76415
76545
  const event = allEvents[eventId];
76416
76546
  if (!event) {
76417
- log$21.warn("Cannot lock non-existent event", { eventId });
76547
+ log$22.warn("Cannot lock non-existent event", { eventId });
76418
76548
  return;
76419
76549
  }
76420
76550
  if (event.status !== "new") {
76421
- log$21.debug("Cannot lock event - not in new status", {
76551
+ log$22.debug("Cannot lock event - not in new status", {
76422
76552
  eventId,
76423
76553
  status: event.status,
76424
76554
  lockedBy: event.lockedBy
@@ -76433,7 +76563,7 @@ var StorageEventStore = class {
76433
76563
  };
76434
76564
  allEvents[eventId] = updatedEvent;
76435
76565
  await this.storage.set(this.storageKey, allEvents);
76436
- log$21.debug("Event lock acquired", {
76566
+ log$22.debug("Event lock acquired", {
76437
76567
  eventId,
76438
76568
  walletAddress: walletId
76439
76569
  });
@@ -76460,7 +76590,7 @@ var StorageEventStore = class {
76460
76590
  };
76461
76591
  allEvents[eventId] = updatedEvent;
76462
76592
  await this.storage.set(this.storageKey, allEvents);
76463
- log$21.debug("Event retry count incremented", {
76593
+ log$22.debug("Event retry count incremented", {
76464
76594
  eventId,
76465
76595
  retryCount: updatedEvent.retryCount,
76466
76596
  error
@@ -76484,7 +76614,7 @@ var StorageEventStore = class {
76484
76614
  if (status === "completed") updatedEvent.completedAt = Date.now();
76485
76615
  allEvents[eventId] = updatedEvent;
76486
76616
  await this.storage.set(this.storageKey, allEvents);
76487
- log$21.debug("Event status updated", {
76617
+ log$22.debug("Event status updated", {
76488
76618
  eventId,
76489
76619
  oldStatus,
76490
76620
  newStatus: status
@@ -76499,7 +76629,7 @@ var StorageEventStore = class {
76499
76629
  try {
76500
76630
  return (await this.getAllEventsFromStorage())[eventId] || null;
76501
76631
  } catch (error) {
76502
- log$21.warn("Failed to get event", {
76632
+ log$22.warn("Failed to get event", {
76503
76633
  eventId,
76504
76634
  error
76505
76635
  });
@@ -76521,14 +76651,14 @@ var StorageEventStore = class {
76521
76651
  };
76522
76652
  await this.saveEvent(recoveredEvent);
76523
76653
  recoveredCount++;
76524
- log$21.info("Recovered stale event", {
76654
+ log$22.info("Recovered stale event", {
76525
76655
  eventId: event.id,
76526
76656
  lockedBy: event.lockedBy,
76527
76657
  staleMinutes: Math.round((now - event.processingStartedAt) / 6e4),
76528
76658
  retryCount: event.retryCount || 0
76529
76659
  });
76530
76660
  }
76531
- if (recoveredCount > 0) log$21.info("Event recovery completed", { recoveredCount });
76661
+ if (recoveredCount > 0) log$22.info("Event recovery completed", { recoveredCount });
76532
76662
  return recoveredCount;
76533
76663
  }
76534
76664
  /**
@@ -76541,7 +76671,7 @@ var StorageEventStore = class {
76541
76671
  const eventsToRemove = [];
76542
76672
  for (const event of events) if (event.status === "completed" && event.completedAt && event.completedAt < cutoffTime || event.status === "errored" && event.createdAt < cutoffTime) {
76543
76673
  eventsToRemove.push(event.id);
76544
- log$21.debug("Marked event for cleanup", {
76674
+ log$22.debug("Marked event for cleanup", {
76545
76675
  eventId: event.id,
76546
76676
  status: event.status
76547
76677
  });
@@ -76555,7 +76685,7 @@ var StorageEventStore = class {
76555
76685
  }
76556
76686
  await this.storage.set(this.storageKey, allEvents);
76557
76687
  });
76558
- log$21.info("Event cleanup completed", { cleanedUpCount });
76688
+ log$22.info("Event cleanup completed", { cleanedUpCount });
76559
76689
  }
76560
76690
  return cleanedUpCount;
76561
76691
  }
@@ -76567,7 +76697,7 @@ var StorageEventStore = class {
76567
76697
  const allEvents = await this.getAllEventsFromStorage();
76568
76698
  return Object.values(allEvents);
76569
76699
  } catch (error) {
76570
- log$21.warn("Failed to get all events", { error });
76700
+ log$22.warn("Failed to get all events", { error });
76571
76701
  return [];
76572
76702
  }
76573
76703
  }
@@ -76589,7 +76719,7 @@ var StorageEventStore = class {
76589
76719
  try {
76590
76720
  return await this.storage.get(this.storageKey) || {};
76591
76721
  } catch (error) {
76592
- log$21.warn("Failed to get events from storage", { error });
76722
+ log$22.warn("Failed to get events from storage", { error });
76593
76723
  return {};
76594
76724
  }
76595
76725
  }
@@ -76628,7 +76758,7 @@ var StorageEventStore = class {
76628
76758
  * LICENSE file in the root directory of this source tree.
76629
76759
  *
76630
76760
  */
76631
- const log$20 = globalLogger.createChild("EventProcessor");
76761
+ const log$21 = globalLogger.createChild("EventProcessor");
76632
76762
  /**
76633
76763
  * Processes durable events for wallets based on their active sessions and enabled event types
76634
76764
  */
@@ -76663,14 +76793,14 @@ var StorageEventProcessor = class {
76663
76793
  */
76664
76794
  async startProcessing(walletId) {
76665
76795
  if (this.processorConfig.disableEvents) return;
76666
- if (walletId) if (this.registeredWallets.has(walletId)) log$20.debug("Processing already registered for wallet", { walletId });
76796
+ if (walletId) if (this.registeredWallets.has(walletId)) log$21.debug("Processing already registered for wallet", { walletId });
76667
76797
  else {
76668
76798
  this.registeredWallets.add(walletId);
76669
- log$20.info("Registered wallet for event processing", { walletId });
76799
+ log$21.info("Registered wallet for event processing", { walletId });
76670
76800
  }
76671
76801
  if (!this.isProcessing) {
76672
76802
  this.isProcessing = true;
76673
- log$20.info("Started global event processing loop");
76803
+ log$21.info("Started global event processing loop");
76674
76804
  this.processEventsLoop();
76675
76805
  } else this.triggerProcessing();
76676
76806
  }
@@ -76681,7 +76811,7 @@ var StorageEventProcessor = class {
76681
76811
  if (this.processorConfig.disableEvents) return;
76682
76812
  if (walletId) {
76683
76813
  this.registeredWallets.delete(walletId);
76684
- log$20.info("Unregistered wallet from event processing", { walletId });
76814
+ log$21.info("Unregistered wallet from event processing", { walletId });
76685
76815
  }
76686
76816
  if (this.registeredWallets.size === 0 && this.isProcessing && !walletId) {
76687
76817
  this.isProcessing = false;
@@ -76689,12 +76819,12 @@ var StorageEventProcessor = class {
76689
76819
  this.wakeUpResolver();
76690
76820
  this.wakeUpResolver = void 0;
76691
76821
  }
76692
- log$20.info("Stopped global event processing loop (no more wallets)");
76822
+ log$21.info("Stopped global event processing loop (no more wallets)");
76693
76823
  }
76694
76824
  }
76695
76825
  async clearRegisteredWallets() {
76696
76826
  this.registeredWallets.clear();
76697
- log$20.info("Cleared registered wallets from event processing");
76827
+ log$21.info("Cleared registered wallets from event processing");
76698
76828
  }
76699
76829
  /**
76700
76830
  * Process next available event from any source (wallet or no-wallet)
@@ -76724,7 +76854,7 @@ var StorageEventProcessor = class {
76724
76854
  const walletId = allSessions.find((s) => s.sessionId === eventToUse.sessionId)?.walletId || "no-wallet";
76725
76855
  return await this.processEvent(eventToUse, walletId);
76726
76856
  } catch (error) {
76727
- log$20.error("Error in processNextAvailableEvent", { error: error.message });
76857
+ log$21.error("Error in processNextAvailableEvent", { error: error.message });
76728
76858
  return false;
76729
76859
  }
76730
76860
  }
@@ -76734,9 +76864,9 @@ var StorageEventProcessor = class {
76734
76864
  async completeEvent(eventId) {
76735
76865
  try {
76736
76866
  await this.eventStore.updateEventStatus(eventId, "completed", "processing");
76737
- log$20.debug("Event marked as completed", { eventId });
76867
+ log$21.debug("Event marked as completed", { eventId });
76738
76868
  } catch (error) {
76739
- log$20.error("Failed to mark event as completed", {
76869
+ log$21.error("Failed to mark event as completed", {
76740
76870
  eventId,
76741
76871
  error: error.message
76742
76872
  });
@@ -76747,14 +76877,14 @@ var StorageEventProcessor = class {
76747
76877
  */
76748
76878
  startRecoveryLoop() {
76749
76879
  if (this.recoveryTimeoutId) {
76750
- log$20.debug("Recovery loop already running");
76880
+ log$21.debug("Recovery loop already running");
76751
76881
  return;
76752
76882
  }
76753
76883
  const recoveryLoop = async () => {
76754
76884
  try {
76755
76885
  if (await this.eventStore.recoverStaleEvents(this.config.processingTimeoutMs) > 0) this.triggerProcessing();
76756
76886
  } catch (error) {
76757
- log$20.error("Error in recovery loop", { error: error.message });
76887
+ log$21.error("Error in recovery loop", { error: error.message });
76758
76888
  }
76759
76889
  if (this.recoveryTimeoutId !== void 0) this.recoveryTimeoutId = setTimeout(recoveryLoop, this.config.recoveryIntervalMs);
76760
76890
  };
@@ -76762,13 +76892,13 @@ var StorageEventProcessor = class {
76762
76892
  try {
76763
76893
  await this.eventStore.cleanupOldEvents(this.config.retentionMs);
76764
76894
  } catch (error) {
76765
- log$20.error("Error in cleanup loop", { error: error.message });
76895
+ log$21.error("Error in cleanup loop", { error: error.message });
76766
76896
  }
76767
76897
  if (this.cleanupTimeoutId !== void 0) this.cleanupTimeoutId = setTimeout(cleanupLoop, this.config.cleanupIntervalMs);
76768
76898
  };
76769
76899
  this.recoveryTimeoutId = setTimeout(recoveryLoop, this.config.recoveryIntervalMs);
76770
76900
  this.cleanupTimeoutId = setTimeout(cleanupLoop, this.config.cleanupIntervalMs);
76771
- log$20.info("Recovery and cleanup loops started");
76901
+ log$21.info("Recovery and cleanup loops started");
76772
76902
  }
76773
76903
  /**
76774
76904
  * Stop the recovery process
@@ -76782,7 +76912,7 @@ var StorageEventProcessor = class {
76782
76912
  clearTimeout(this.cleanupTimeoutId);
76783
76913
  this.cleanupTimeoutId = void 0;
76784
76914
  }
76785
- log$20.info("Recovery and cleanup loops stopped");
76915
+ log$21.info("Recovery and cleanup loops stopped");
76786
76916
  }
76787
76917
  /**
76788
76918
  * Process a single event with retry logic
@@ -76790,7 +76920,7 @@ var StorageEventProcessor = class {
76790
76920
  */
76791
76921
  async processEvent(event, walletId) {
76792
76922
  if (!await this.eventStore.acquireLock(event.id, walletId)) {
76793
- log$20.debug("Failed to acquire lock on event", {
76923
+ log$21.debug("Failed to acquire lock on event", {
76794
76924
  eventId: event.id,
76795
76925
  walletId
76796
76926
  });
@@ -76798,7 +76928,7 @@ var StorageEventProcessor = class {
76798
76928
  }
76799
76929
  const retryCount = event.retryCount || 0;
76800
76930
  if (retryCount >= this.config.maxRetries) {
76801
- log$20.error("Event exceeded max retries, marking as errored", {
76931
+ log$21.error("Event exceeded max retries, marking as errored", {
76802
76932
  eventId: event.id,
76803
76933
  retryCount,
76804
76934
  maxRetries: this.config.maxRetries
@@ -76806,14 +76936,14 @@ var StorageEventProcessor = class {
76806
76936
  try {
76807
76937
  await this.eventStore.updateEventStatus(event.id, "errored", "processing");
76808
76938
  } catch (error) {
76809
- log$20.error("Failed to mark event as errored", {
76939
+ log$21.error("Failed to mark event as errored", {
76810
76940
  eventId: event.id,
76811
76941
  error: error.message
76812
76942
  });
76813
76943
  }
76814
76944
  return false;
76815
76945
  }
76816
- log$20.info("Processing event", {
76946
+ log$21.info("Processing event", {
76817
76947
  eventId: event.id,
76818
76948
  eventType: event.eventType,
76819
76949
  walletId,
@@ -76833,11 +76963,11 @@ var StorageEventProcessor = class {
76833
76963
  ...walletAddress ? { walletAddress } : {}
76834
76964
  });
76835
76965
  await this.eventStore.updateEventStatus(event.id, "completed", "processing");
76836
- log$20.info("Event processing completed", { eventId: event.id });
76966
+ log$21.info("Event processing completed", { eventId: event.id });
76837
76967
  return true;
76838
76968
  } catch (error) {
76839
76969
  const errorMessage = error.message ?? "Unknown error";
76840
- log$20.error("Error processing event", {
76970
+ log$21.error("Error processing event", {
76841
76971
  eventId: event.id,
76842
76972
  error: errorMessage,
76843
76973
  retryCount
@@ -76845,7 +76975,7 @@ var StorageEventProcessor = class {
76845
76975
  try {
76846
76976
  await this.eventStore.releaseLock(event.id, errorMessage);
76847
76977
  } catch (updateError) {
76848
- log$20.error("Failed to increment retry count", {
76978
+ log$21.error("Failed to increment retry count", {
76849
76979
  eventId: event.id,
76850
76980
  error: updateError.message
76851
76981
  });
@@ -76860,18 +76990,18 @@ var StorageEventProcessor = class {
76860
76990
  while (this.isProcessing) try {
76861
76991
  if (!await this.processNextAvailableEvent()) await this.waitForWakeUpOrTimeout(500);
76862
76992
  } catch (error) {
76863
- log$20.error("Error in global processing loop", { error: error.message });
76993
+ log$21.error("Error in global processing loop", { error: error.message });
76864
76994
  await this.waitForWakeUpOrTimeout(500);
76865
76995
  }
76866
76996
  this.wakeUpResolver = void 0;
76867
- log$20.debug("Global processing loop ended");
76997
+ log$21.debug("Global processing loop ended");
76868
76998
  }
76869
76999
  /**
76870
77000
  * Trigger the global processing loop
76871
77001
  */
76872
77002
  triggerProcessing() {
76873
77003
  if (this.isProcessing && this.wakeUpResolver) {
76874
- log$20.debug("Waking up global processing loop");
77004
+ log$21.debug("Waking up global processing loop");
76875
77005
  this.wakeUpResolver();
76876
77006
  }
76877
77007
  }
@@ -76914,7 +77044,7 @@ var StorageEventProcessor = class {
76914
77044
  * LICENSE file in the root directory of this source tree.
76915
77045
  *
76916
77046
  */
76917
- const log$19 = globalLogger.createChild("WalletTonClass");
77047
+ const log$20 = globalLogger.createChild("WalletTonClass");
76918
77048
  var WalletTonClass = class {
76919
77049
  async createTransferTonTransaction(param) {
76920
77050
  if (!isValidAddress(param.recipientAddress)) throw new Error(`Invalid to address: ${param.recipientAddress}`);
@@ -76975,7 +77105,7 @@ var WalletTonClass = class {
76975
77105
  normalizedHash
76976
77106
  };
76977
77107
  } catch (error) {
76978
- log$19.error("Failed to send transaction", { error });
77108
+ log$20.error("Failed to send transaction", { error });
76979
77109
  if (error instanceof WalletKitError) throw error;
76980
77110
  if (error?.message?.includes("Ledger device")) throw new WalletKitError(ERROR_CODES.LEDGER_DEVICE_ERROR, "Ledger device error", error);
76981
77111
  throw error;
@@ -77005,7 +77135,7 @@ var WalletJettonClass = class {
77005
77135
  payload: createJettonTransferPayload({
77006
77136
  amount: BigInt(params.transferAmount),
77007
77137
  destination: params.recipientAddress,
77008
- responseDestination: this.getAddress(),
77138
+ responseDestination: params.responseDestination || this.getAddress(),
77009
77139
  comment: params.comment
77010
77140
  }),
77011
77141
  fromAddress: this.getAddress()
@@ -77077,7 +77207,7 @@ var WalletNftClass = class {
77077
77207
  * LICENSE file in the root directory of this source tree.
77078
77208
  *
77079
77209
  */
77080
- const log$18 = globalLogger.createChild("Initializer");
77210
+ const log$19 = globalLogger.createChild("Initializer");
77081
77211
  /**
77082
77212
  * Handles initialization of all TonWalletKit components
77083
77213
  */
@@ -77096,12 +77226,12 @@ var Initializer = class {
77096
77226
  */
77097
77227
  async initialize(options, networkManager) {
77098
77228
  try {
77099
- log$18.info("Initializing TonWalletKit...");
77229
+ log$19.info("Initializing TonWalletKit...");
77100
77230
  this.networkManager = networkManager;
77101
77231
  const storage = this.initializeStorage(options);
77102
77232
  const { walletManager, sessionManager, bridgeManager, eventRouter, eventProcessor } = await this.initializeManagers(options, storage);
77103
77233
  const { requestProcessor } = this.initializeProcessors(sessionManager, bridgeManager, walletManager);
77104
- log$18.info("TonWalletKit initialized successfully");
77234
+ log$19.info("TonWalletKit initialized successfully");
77105
77235
  return {
77106
77236
  walletManager,
77107
77237
  sessionManager,
@@ -77112,7 +77242,7 @@ var Initializer = class {
77112
77242
  eventProcessor
77113
77243
  };
77114
77244
  } catch (error) {
77115
- log$18.error("Failed to initialize TonWalletKit", { error });
77245
+ log$19.error("Failed to initialize TonWalletKit", { error });
77116
77246
  throw error;
77117
77247
  }
77118
77248
  }
@@ -77148,9 +77278,9 @@ var Initializer = class {
77148
77278
  const bridgeManager = new BridgeManager(options?.walletManifest, options?.bridge, sessionManager, storage, eventStore, eventRouter, options, this.eventEmitter, this.analyticsManager);
77149
77279
  eventRouter.setBridgeManager(bridgeManager);
77150
77280
  bridgeManager.start().then(() => {
77151
- log$18.info("Bridge manager started successfully");
77281
+ log$19.info("Bridge manager started successfully");
77152
77282
  }).catch((e) => {
77153
- log$18.error("Could not start bridge manager", { error: e?.toString?.() });
77283
+ log$19.error("Could not start bridge manager", { error: e?.toString?.() });
77154
77284
  });
77155
77285
  const eventProcessor = new StorageEventProcessor(options?.eventProcessor, eventStore, DEFAULT_DURABLE_EVENTS_CONFIG, walletManager, sessionManager, eventRouter, this.eventEmitter);
77156
77286
  return {
@@ -77172,7 +77302,7 @@ var Initializer = class {
77172
77302
  */
77173
77303
  async cleanup(components) {
77174
77304
  try {
77175
- log$18.info("Cleaning up TonWalletKit components...");
77305
+ log$19.info("Cleaning up TonWalletKit components...");
77176
77306
  if (components.eventProcessor) {
77177
77307
  components.eventProcessor.stopRecoveryLoop();
77178
77308
  await components.eventProcessor.clearRegisteredWallets();
@@ -77180,9 +77310,9 @@ var Initializer = class {
77180
77310
  }
77181
77311
  if (components.bridgeManager) await components.bridgeManager.close();
77182
77312
  if (components.eventRouter) components.eventRouter.clearCallbacks();
77183
- log$18.info("TonWalletKit cleanup completed");
77313
+ log$19.info("TonWalletKit cleanup completed");
77184
77314
  } catch (error) {
77185
- log$18.error("Error during cleanup", { error });
77315
+ log$19.error("Error during cleanup", { error });
77186
77316
  }
77187
77317
  }
77188
77318
  };
@@ -77217,7 +77347,7 @@ async function wrapWalletInterface(wallet) {
77217
77347
  * LICENSE file in the root directory of this source tree.
77218
77348
  *
77219
77349
  */
77220
- const log$17 = globalLogger.createChild("JettonsManager");
77350
+ const log$18 = globalLogger.createChild("JettonsManager");
77221
77351
  const TON_ADDRESS = "TON";
77222
77352
  function isTonAddress(address) {
77223
77353
  return address.toLowerCase() === "ton";
@@ -77257,7 +77387,7 @@ var JettonsManager = class {
77257
77387
  ttl: 1e3 * 60 * 10
77258
77388
  });
77259
77389
  for (const network of this.networkManager.getConfiguredNetworks()) this.addTonToCache(network);
77260
- log$17.info("JettonsManager initialized", { cacheSize });
77390
+ log$18.info("JettonsManager initialized", { cacheSize });
77261
77391
  }
77262
77392
  /**
77263
77393
  * Add TON native token to cache for a specific network
@@ -77278,19 +77408,19 @@ var JettonsManager = class {
77278
77408
  const cacheKey = this.normalizedCacheKey(targetNetwork, jettonAddress);
77279
77409
  const cachedInfo = this.cache.get(cacheKey);
77280
77410
  if (cachedInfo) {
77281
- log$17.debug("Jetton info found in cache", {
77411
+ log$18.debug("Jetton info found in cache", {
77282
77412
  jettonAddress,
77283
77413
  network: targetNetwork
77284
77414
  });
77285
77415
  return cachedInfo;
77286
77416
  }
77287
- log$17.debug("Jetton info not found in cache", {
77417
+ log$18.debug("Jetton info not found in cache", {
77288
77418
  jettonAddress,
77289
77419
  network: targetNetwork
77290
77420
  });
77291
77421
  const address = asMaybeAddressFriendly(jettonAddress);
77292
77422
  if (!address) {
77293
- log$17.error("Invalid jetton address format", {
77423
+ log$18.error("Invalid jetton address format", {
77294
77424
  jettonAddress,
77295
77425
  network: targetNetwork
77296
77426
  });
@@ -77325,7 +77455,7 @@ var JettonsManager = class {
77325
77455
  }
77326
77456
  return null;
77327
77457
  } catch (error) {
77328
- log$17.error("Error getting jetton info", {
77458
+ log$18.error("Error getting jetton info", {
77329
77459
  error,
77330
77460
  jettonAddress,
77331
77461
  network: targetNetwork
@@ -77344,7 +77474,7 @@ var JettonsManager = class {
77344
77474
  const targetNetwork = network;
77345
77475
  try {
77346
77476
  const apiClient = this.networkManager.getClient(targetNetwork);
77347
- log$17.debug("Getting address jettons", {
77477
+ log$18.debug("Getting address jettons", {
77348
77478
  userAddress,
77349
77479
  network: targetNetwork,
77350
77480
  offset,
@@ -77358,13 +77488,13 @@ var JettonsManager = class {
77358
77488
  if (!response.jettons) return [];
77359
77489
  const addressJettons = [];
77360
77490
  for (const item of response.jettons) addressJettons.push(item);
77361
- log$17.debug("Retrieved address jettons", {
77491
+ log$18.debug("Retrieved address jettons", {
77362
77492
  count: addressJettons.length,
77363
77493
  network: targetNetwork
77364
77494
  });
77365
77495
  return addressJettons;
77366
77496
  } catch (error) {
77367
- log$17.error("Failed to get address jettons", {
77497
+ log$18.error("Failed to get address jettons", {
77368
77498
  error,
77369
77499
  userAddress,
77370
77500
  network: targetNetwork
@@ -77388,14 +77518,14 @@ var JettonsManager = class {
77388
77518
  uri: emulationInfo.extra.uri
77389
77519
  };
77390
77520
  this.cache.set(cacheKey, jettonInfo);
77391
- log$17.debug("Added jetton info from emulation to cache", {
77521
+ log$18.debug("Added jetton info from emulation to cache", {
77392
77522
  jettonAddress,
77393
77523
  network,
77394
77524
  name: jettonInfo.name,
77395
77525
  symbol: jettonInfo.symbol
77396
77526
  });
77397
77527
  } catch (error) {
77398
- log$17.error("Error adding jetton from emulation", {
77528
+ log$18.error("Error adding jetton from emulation", {
77399
77529
  error,
77400
77530
  jettonAddress,
77401
77531
  network
@@ -77412,7 +77542,7 @@ var JettonsManager = class {
77412
77542
  if (!addressMetadata.is_indexed || !addressMetadata.token_info) continue;
77413
77543
  const jettonMasterInfo = addressMetadata.token_info.find((info) => typeof info === "object" && info !== null && "type" in info && info.type === "jetton_masters");
77414
77544
  if (jettonMasterInfo) {
77415
- log$17.debug("Adding jetton from emulation metadata", {
77545
+ log$18.debug("Adding jetton from emulation metadata", {
77416
77546
  jettonAddress,
77417
77547
  network
77418
77548
  });
@@ -77420,12 +77550,12 @@ var JettonsManager = class {
77420
77550
  addedCount++;
77421
77551
  }
77422
77552
  }
77423
- if (addedCount > 0) log$17.info("Added jettons from emulation metadata", {
77553
+ if (addedCount > 0) log$18.info("Added jettons from emulation metadata", {
77424
77554
  addedCount,
77425
77555
  network
77426
77556
  });
77427
77557
  } catch (error) {
77428
- log$17.error("Error adding jettons from emulation metadata", {
77558
+ log$18.error("Error adding jettons from emulation metadata", {
77429
77559
  error,
77430
77560
  network
77431
77561
  });
@@ -77466,11 +77596,11 @@ var JettonsManager = class {
77466
77596
  if (network) {
77467
77597
  for (const key of this.cache.keys()) if (key.startsWith(`${network.chainId}:`)) this.cache.delete(key);
77468
77598
  this.addTonToCache(network);
77469
- log$17.info("Jetton cache cleared for network", { network });
77599
+ log$18.info("Jetton cache cleared for network", { network });
77470
77600
  } else {
77471
77601
  this.cache.clear();
77472
77602
  for (const net of this.networkManager.getConfiguredNetworks()) this.addTonToCache(net);
77473
- log$17.info("Jetton cache cleared for all networks");
77603
+ log$18.info("Jetton cache cleared for all networks");
77474
77604
  }
77475
77605
  }
77476
77606
  };
@@ -77670,7 +77800,7 @@ var DefiManager = class {
77670
77800
  * LICENSE file in the root directory of this source tree.
77671
77801
  *
77672
77802
  */
77673
- const log$16 = globalLogger.createChild("SwapManager");
77803
+ const log$17 = globalLogger.createChild("SwapManager");
77674
77804
  /**
77675
77805
  * SwapManager - manages swap providers and delegates swap operations
77676
77806
  *
@@ -77688,7 +77818,7 @@ var SwapManager = class extends DefiManager {
77688
77818
  * @returns Promise resolving to swap quote
77689
77819
  */
77690
77820
  async getQuote(params, providerId) {
77691
- log$16.debug("Getting swap quote", {
77821
+ log$17.debug("Getting swap quote", {
77692
77822
  fromToken: params.from,
77693
77823
  toToken: params.to,
77694
77824
  amount: params.amount,
@@ -77697,14 +77827,14 @@ var SwapManager = class extends DefiManager {
77697
77827
  });
77698
77828
  try {
77699
77829
  const quote = await this.getProvider(providerId || this.defaultProviderId).getQuote(params);
77700
- log$16.debug("Received swap quote", {
77830
+ log$17.debug("Received swap quote", {
77701
77831
  fromAmount: quote.fromAmount,
77702
77832
  toAmount: quote.toAmount,
77703
77833
  priceImpact: quote.priceImpact
77704
77834
  });
77705
77835
  return quote;
77706
77836
  } catch (error) {
77707
- log$16.error("Failed to get swap quote", {
77837
+ log$17.error("Failed to get swap quote", {
77708
77838
  error,
77709
77839
  params
77710
77840
  });
@@ -77718,16 +77848,16 @@ var SwapManager = class extends DefiManager {
77718
77848
  */
77719
77849
  async buildSwapTransaction(params) {
77720
77850
  const providerId = params.quote.providerId || this.defaultProviderId;
77721
- log$16.debug("Building swap transaction", {
77851
+ log$17.debug("Building swap transaction", {
77722
77852
  providerId,
77723
77853
  userAddress: params.userAddress
77724
77854
  });
77725
77855
  try {
77726
77856
  const transaction = await this.getProvider(providerId).buildSwapTransaction(params);
77727
- log$16.debug("Built swap transaction", params.quote);
77857
+ log$17.debug("Built swap transaction", params.quote);
77728
77858
  return transaction;
77729
77859
  } catch (error) {
77730
- log$16.error("Failed to build swap transaction", {
77860
+ log$17.error("Failed to build swap transaction", {
77731
77861
  error,
77732
77862
  params
77733
77863
  });
@@ -77769,7 +77899,7 @@ var StakingError = class extends DefiError {
77769
77899
  * LICENSE file in the root directory of this source tree.
77770
77900
  *
77771
77901
  */
77772
- const log$15 = globalLogger.createChild("StakingManager");
77902
+ const log$16 = globalLogger.createChild("StakingManager");
77773
77903
  /**
77774
77904
  * StakingManager - manages staking providers and delegates staking operations
77775
77905
  *
@@ -77786,13 +77916,13 @@ var StakingManager = class extends DefiManager {
77786
77916
  * @param providerId - Optional provider id to use
77787
77917
  */
77788
77918
  async getQuote(params, providerId) {
77789
- log$15.debug("Getting staking quote", params);
77919
+ log$16.debug("Getting staking quote", params);
77790
77920
  try {
77791
77921
  const quote = await this.getProvider(providerId).getQuote(params);
77792
- log$15.debug("Received staking quote", quote);
77922
+ log$16.debug("Received staking quote", quote);
77793
77923
  return quote;
77794
77924
  } catch (error) {
77795
- log$15.error("Failed to get staking quote", {
77925
+ log$16.error("Failed to get staking quote", {
77796
77926
  error,
77797
77927
  params
77798
77928
  });
@@ -77805,11 +77935,11 @@ var StakingManager = class extends DefiManager {
77805
77935
  * @param providerId - Optional provider id to use
77806
77936
  */
77807
77937
  async buildStakeTransaction(params, providerId) {
77808
- log$15.debug("Building staking transaction", params);
77938
+ log$16.debug("Building staking transaction", params);
77809
77939
  try {
77810
77940
  return await this.getProvider(providerId).buildStakeTransaction(params);
77811
77941
  } catch (error) {
77812
- log$15.error("Failed to build staking transaction", {
77942
+ log$16.error("Failed to build staking transaction", {
77813
77943
  error,
77814
77944
  params
77815
77945
  });
@@ -77823,7 +77953,7 @@ var StakingManager = class extends DefiManager {
77823
77953
  * @param providerId - Optional provider id to use
77824
77954
  */
77825
77955
  async getStakedBalance(userAddress, network, providerId) {
77826
- log$15.debug("Getting staking balance", {
77956
+ log$16.debug("Getting staking balance", {
77827
77957
  userAddress,
77828
77958
  network,
77829
77959
  provider: providerId || this.defaultProviderId
@@ -77831,7 +77961,7 @@ var StakingManager = class extends DefiManager {
77831
77961
  try {
77832
77962
  return await this.getProvider(providerId).getStakedBalance(userAddress, network);
77833
77963
  } catch (error) {
77834
- log$15.error("Failed to get staking balance", {
77964
+ log$16.error("Failed to get staking balance", {
77835
77965
  error,
77836
77966
  userAddress,
77837
77967
  network
@@ -77845,14 +77975,14 @@ var StakingManager = class extends DefiManager {
77845
77975
  * @param providerId - Optional provider id to use
77846
77976
  */
77847
77977
  async getStakingProviderInfo(network, providerId) {
77848
- log$15.debug("Getting staking info", {
77978
+ log$16.debug("Getting staking info", {
77849
77979
  network,
77850
77980
  provider: providerId || this.defaultProviderId
77851
77981
  });
77852
77982
  try {
77853
77983
  return await this.getProvider(providerId).getStakingProviderInfo(network);
77854
77984
  } catch (error) {
77855
- log$15.error("Failed to get staking info", {
77985
+ log$16.error("Failed to get staking info", {
77856
77986
  error,
77857
77987
  network
77858
77988
  });
@@ -77865,14 +77995,14 @@ var StakingManager = class extends DefiManager {
77865
77995
  * @param providerId - Optional provider id to use
77866
77996
  */
77867
77997
  getStakingProviderMetadata(network, providerId) {
77868
- log$15.debug("Getting staking metadata", {
77998
+ log$16.debug("Getting staking metadata", {
77869
77999
  network,
77870
78000
  provider: providerId || this.defaultProviderId
77871
78001
  });
77872
78002
  try {
77873
78003
  return this.getProvider(providerId).getStakingProviderMetadata(network);
77874
78004
  } catch (error) {
77875
- log$15.error("Failed to get staking metadata", {
78005
+ log$16.error("Failed to get staking metadata", {
77876
78006
  error,
77877
78007
  network
77878
78008
  });
@@ -77881,7 +78011,7 @@ var StakingManager = class extends DefiManager {
77881
78011
  }
77882
78012
  createError(message, code, details) {
77883
78013
  const errorCode = Object.values(StakingErrorCode).includes(code) ? code : StakingErrorCode.InvalidParams;
77884
- log$15.error(message, {
78014
+ log$16.error(message, {
77885
78015
  code,
77886
78016
  details
77887
78017
  });
@@ -77889,6 +78019,128 @@ var StakingManager = class extends DefiManager {
77889
78019
  }
77890
78020
  };
77891
78021
  //#endregion
78022
+ //#region ../walletkit/dist/esm/defi/gasless/errors.js
78023
+ /**
78024
+ * Copyright (c) TonTech.
78025
+ *
78026
+ * This source code is licensed under the MIT license found in the
78027
+ * LICENSE file in the root directory of this source tree.
78028
+ *
78029
+ */
78030
+ var GaslessErrorCode;
78031
+ (function(GaslessErrorCode) {
78032
+ GaslessErrorCode["UnsupportedFeeAsset"] = "UNSUPPORTED_FEE_ASSET";
78033
+ GaslessErrorCode["UnsupportedOperation"] = "UNSUPPORTED_OPERATION";
78034
+ GaslessErrorCode["QuoteFailed"] = "QUOTE_FAILED";
78035
+ GaslessErrorCode["SendFailed"] = "SEND_FAILED";
78036
+ GaslessErrorCode["ConfigFailed"] = "CONFIG_FAILED";
78037
+ GaslessErrorCode["SignMessageNotSupported"] = "SIGN_MESSAGE_NOT_SUPPORTED";
78038
+ GaslessErrorCode["TooManyMessages"] = "TOO_MANY_MESSAGES";
78039
+ GaslessErrorCode["QuoteExpired"] = "QUOTE_EXPIRED";
78040
+ GaslessErrorCode["WalletMismatch"] = "WALLET_MISMATCH";
78041
+ GaslessErrorCode["FeeAssetNotOwned"] = "FEE_ASSET_NOT_OWNED";
78042
+ })(GaslessErrorCode || (GaslessErrorCode = {}));
78043
+ var GaslessError = class extends DefiError {
78044
+ code;
78045
+ constructor(message, code, details) {
78046
+ super(message, code, details);
78047
+ this.name = "GaslessError";
78048
+ this.code = code;
78049
+ }
78050
+ };
78051
+ //#endregion
78052
+ //#region ../walletkit/dist/esm/defi/gasless/GaslessManager.js
78053
+ /**
78054
+ * Copyright (c) TonTech.
78055
+ *
78056
+ * This source code is licensed under the MIT license found in the
78057
+ * LICENSE file in the root directory of this source tree.
78058
+ *
78059
+ */
78060
+ const log$15 = globalLogger.createChild("GaslessManager");
78061
+ /**
78062
+ * GaslessManager — manages gasless relay providers and delegates gasless operations.
78063
+ *
78064
+ * Allows registration of multiple gasless providers and provides a unified API.
78065
+ * Providers can be switched dynamically.
78066
+ */
78067
+ var GaslessManager = class extends DefiManager {
78068
+ constructor(createFactoryContext) {
78069
+ super(createFactoryContext);
78070
+ }
78071
+ /**
78072
+ * Get static metadata for a gasless provider (display name, logo, url).
78073
+ */
78074
+ async getMetadata(providerId) {
78075
+ const selectedProviderId = providerId ?? this.defaultProviderId;
78076
+ log$15.debug("Getting gasless provider metadata", { providerId: selectedProviderId });
78077
+ try {
78078
+ return await this.getProvider(selectedProviderId).getMetadata();
78079
+ } catch (error) {
78080
+ log$15.error("Failed to get gasless provider metadata", { error });
78081
+ throw error;
78082
+ }
78083
+ }
78084
+ /**
78085
+ * Fetch the relayer's configuration (relay address + accepted fee assets).
78086
+ *
78087
+ * `network` defaults to the provider's first supported network.
78088
+ */
78089
+ async getConfig(network, providerId) {
78090
+ const provider = this.getProvider(providerId ?? this.defaultProviderId);
78091
+ const targetNetwork = network ?? provider.getSupportedNetworks()[0];
78092
+ log$15.debug("Getting gasless config", {
78093
+ network: targetNetwork?.chainId,
78094
+ providerId: providerId ?? this.defaultProviderId
78095
+ });
78096
+ try {
78097
+ return await provider.getConfig(targetNetwork);
78098
+ } catch (error) {
78099
+ log$15.error("Failed to get gasless config", { error });
78100
+ throw error;
78101
+ }
78102
+ }
78103
+ /**
78104
+ * Quote fees and obtain relayer-wrapped messages for signing.
78105
+ */
78106
+ async getQuote(params, providerId) {
78107
+ log$15.debug("Quoting gasless transaction", {
78108
+ network: params.network.chainId,
78109
+ walletAddress: params.walletAddress,
78110
+ feeAsset: params.feeAsset,
78111
+ messagesCount: params.messages.length,
78112
+ providerId: providerId ?? this.defaultProviderId
78113
+ });
78114
+ try {
78115
+ return await this.getProvider(providerId ?? this.defaultProviderId).getQuote(params);
78116
+ } catch (error) {
78117
+ log$15.error("Failed to quote gasless transaction", {
78118
+ error,
78119
+ params
78120
+ });
78121
+ throw error;
78122
+ }
78123
+ }
78124
+ /**
78125
+ * Submit a signed transaction BoC to the relayer.
78126
+ */
78127
+ async sendTransaction(params, providerId) {
78128
+ log$15.debug("Sending gasless transaction", {
78129
+ network: params.network.chainId,
78130
+ providerId: providerId ?? this.defaultProviderId
78131
+ });
78132
+ try {
78133
+ return await this.getProvider(providerId ?? this.defaultProviderId).sendTransaction(params);
78134
+ } catch (error) {
78135
+ log$15.error("Failed to send gasless transaction", { error });
78136
+ throw error;
78137
+ }
78138
+ }
78139
+ createError(message, code, details) {
78140
+ return new GaslessError(message, code, details);
78141
+ }
78142
+ };
78143
+ //#endregion
77892
78144
  //#region ../walletkit/dist/esm/core/EventEmitter.js
77893
78145
  /**
77894
78146
  * Copyright (c) TonTech.
@@ -79680,6 +79932,7 @@ var TonWalletKit = class {
79680
79932
  swapManager;
79681
79933
  streamingManager;
79682
79934
  stakingManager;
79935
+ gaslessManager;
79683
79936
  initializer;
79684
79937
  eventProcessor;
79685
79938
  bridgeManager;
@@ -79706,6 +79959,7 @@ var TonWalletKit = class {
79706
79959
  this.jettonsManager = new JettonsManager(1e4, this.eventEmitter, this.networkManager);
79707
79960
  this.swapManager = new SwapManager(() => this.createFactoryContext());
79708
79961
  this.stakingManager = new StakingManager(() => this.createFactoryContext());
79962
+ this.gaslessManager = new GaslessManager(() => this.createFactoryContext());
79709
79963
  this.eventEmitter.on("restoreConnection", async ({ payload: event }) => {
79710
79964
  if (!event.domain) {
79711
79965
  log$8.error("Domain is required for restore connection");
@@ -80192,6 +80446,9 @@ var TonWalletKit = class {
80192
80446
  case "streaming":
80193
80447
  this.streamingManager.registerProvider(provider);
80194
80448
  break;
80449
+ case "gasless":
80450
+ this.gaslessManager.registerProvider(provider);
80451
+ break;
80195
80452
  default: throw new Error("Unknown provider type");
80196
80453
  }
80197
80454
  }
@@ -80226,6 +80483,12 @@ var TonWalletKit = class {
80226
80483
  return this.stakingManager;
80227
80484
  }
80228
80485
  /**
80486
+ * Gasless API access
80487
+ */
80488
+ get gasless() {
80489
+ return this.gaslessManager;
80490
+ }
80491
+ /**
80229
80492
  * Get the event emitter for this kit instance
80230
80493
  * Allows external components to listen to and emit events
80231
80494
  */