@ton/appkit
Advanced tools
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessConfig } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { Network } from '../../types/network'; | ||
| export interface GetGaslessConfigOptions { | ||
| /** Network to query. Defaults to the selected wallet's network, then provider's first supported. */ | ||
| network?: Network; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessConfigReturnType = Promise<GaslessConfig>; | ||
| export type GetGaslessConfigErrorType = Error; | ||
| /** | ||
| * Fetch the gasless relayer's configuration on a network — the relay address | ||
| * (e.g. for jetton-transfer `responseDestination`) and the assets it accepts | ||
| * as fee payment. | ||
| */ | ||
| export declare const getGaslessConfig: (appKit: AppKit, options?: GetGaslessConfigOptions) => GetGaslessConfigReturnType; | ||
| //# sourceMappingURL=get-gasless-config.d.ts.map |
| {"version":3,"file":"get-gasless-config.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,MAAM,WAAW,uBAAuB;IACpC,oGAAoG;IACpG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEhE,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GACzB,QAAQ,MAAM,EACd,UAAS,uBAA4B,KACtC,0BAGF,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessConfig = void 0; | ||
| const get_selected_wallet_1 = require("../wallets/get-selected-wallet"); | ||
| /** | ||
| * Fetch the gasless relayer's configuration on a network — the relay address | ||
| * (e.g. for jetton-transfer `responseDestination`) and the assets it accepts | ||
| * as fee payment. | ||
| */ | ||
| const getGaslessConfig = async (appKit, options = {}) => { | ||
| const network = options.network ?? (0, get_selected_wallet_1.getSelectedWallet)(appKit)?.getNetwork(); | ||
| return appKit.gaslessManager.getConfig(network, options.providerId); | ||
| }; | ||
| exports.getGaslessConfig = getGaslessConfig; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessQuote } from '../../gasless'; | ||
| import type { UserFriendlyAddress } from '../../types/primitives'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessJettonTransferQuoteOptions { | ||
| /** Jetton master address to transfer */ | ||
| jettonAddress: string; | ||
| /** Recipient address */ | ||
| recipientAddress: string; | ||
| /** Human-readable amount of jettons to transfer */ | ||
| amount: string; | ||
| /** Jetton decimals. Auto-fetched from jetton info when omitted. */ | ||
| jettonDecimals?: number; | ||
| /** Optional text comment attached to the transfer */ | ||
| comment?: string; | ||
| /** | ||
| * Asset address used to pay the relayer's fee (jetton master for TonAPI). | ||
| * Omit only for free / sponsored providers — see {@link getGaslessQuote}. | ||
| */ | ||
| feeAsset?: UserFriendlyAddress; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessJettonTransferQuoteReturnType = Promise<GaslessQuote>; | ||
| export type GetGaslessJettonTransferQuoteErrorType = Error; | ||
| /** | ||
| * Build a gasless quote for a jetton transfer. | ||
| * | ||
| * Convenience wrapper that assembles the transfer messages the same way as | ||
| * {@link createTransferJettonTransaction} (resolving the jetton wallet address, | ||
| * decimals and payload) and forwards them to {@link getGaslessQuote}. The result | ||
| * is passed verbatim to `sendGaslessTransaction`, preserving the quote → send | ||
| * two-step flow. | ||
| * | ||
| * The jetton `responseDestination` (excess receiver) is set to the relayer's | ||
| * address — the relayer paid the gas, so the unspent TON goes back to it rather | ||
| * than to the user's wallet. | ||
| * | ||
| * The quote is always bound to the selected wallet's network — the same network | ||
| * the message builder resolves the jetton wallet on — so there is no `network` | ||
| * override (a mismatch would build the message on one chain and quote on another). | ||
| */ | ||
| export declare const getGaslessJettonTransferQuote: (appKit: AppKit, options: GetGaslessJettonTransferQuoteOptions) => GetGaslessJettonTransferQuoteReturnType; | ||
| //# sourceMappingURL=get-gasless-jetton-transfer-quote.d.ts.map |
| {"version":3,"file":"get-gasless-jetton-transfer-quote.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-jetton-transfer-quote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,WAAW,oCAAoC;IACjD,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,uCAAuC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAE5E,MAAM,MAAM,sCAAsC,GAAG,KAAK,CAAC;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,6BAA6B,GACtC,QAAQ,MAAM,EACd,SAAS,oCAAoC,KAC9C,uCAcF,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessJettonTransferQuote = void 0; | ||
| const create_transfer_jetton_transaction_1 = require("../jettons/create-transfer-jetton-transaction"); | ||
| const get_gasless_config_1 = require("./get-gasless-config"); | ||
| const get_gasless_quote_1 = require("./get-gasless-quote"); | ||
| /** | ||
| * Build a gasless quote for a jetton transfer. | ||
| * | ||
| * Convenience wrapper that assembles the transfer messages the same way as | ||
| * {@link createTransferJettonTransaction} (resolving the jetton wallet address, | ||
| * decimals and payload) and forwards them to {@link getGaslessQuote}. The result | ||
| * is passed verbatim to `sendGaslessTransaction`, preserving the quote → send | ||
| * two-step flow. | ||
| * | ||
| * The jetton `responseDestination` (excess receiver) is set to the relayer's | ||
| * address — the relayer paid the gas, so the unspent TON goes back to it rather | ||
| * than to the user's wallet. | ||
| * | ||
| * The quote is always bound to the selected wallet's network — the same network | ||
| * the message builder resolves the jetton wallet on — so there is no `network` | ||
| * override (a mismatch would build the message on one chain and quote on another). | ||
| */ | ||
| const getGaslessJettonTransferQuote = async (appKit, options) => { | ||
| const { jettonAddress, recipientAddress, amount, jettonDecimals, comment, feeAsset, providerId } = options; | ||
| const { relayAddress } = await (0, get_gasless_config_1.getGaslessConfig)(appKit, { providerId }); | ||
| const { messages } = await (0, create_transfer_jetton_transaction_1.createTransferJettonTransaction)(appKit, { | ||
| jettonAddress, | ||
| recipientAddress, | ||
| amount, | ||
| jettonDecimals, | ||
| comment, | ||
| responseDestination: relayAddress, | ||
| }); | ||
| return (0, get_gasless_quote_1.getGaslessQuote)(appKit, { messages, feeAsset, providerId }); | ||
| }; | ||
| exports.getGaslessJettonTransferQuote = getGaslessJettonTransferQuote; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessManager } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type GetGaslessManagerReturnType = GaslessManager; | ||
| /** | ||
| * Get gasless manager instance | ||
| */ | ||
| export declare const getGaslessManager: (appKit: AppKit) => GetGaslessManagerReturnType; | ||
| //# sourceMappingURL=get-gasless-manager.d.ts.map |
| {"version":3,"file":"get-gasless-manager.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,2BAElD,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessManager = void 0; | ||
| /** | ||
| * Get gasless manager instance | ||
| */ | ||
| const getGaslessManager = (appKit) => { | ||
| return appKit.gaslessManager; | ||
| }; | ||
| exports.getGaslessManager = getGaslessManager; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessProviderMetadata } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessProviderMetadataOptions { | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessProviderMetadataReturnType = Promise<GaslessProviderMetadata>; | ||
| export type GetGaslessProviderMetadataErrorType = Error; | ||
| /** | ||
| * Get static metadata for a gasless provider (display name, logo, url). | ||
| */ | ||
| export declare const getGaslessProviderMetadata: (appKit: AppKit, options?: GetGaslessProviderMetadataOptions) => GetGaslessProviderMetadataReturnType; | ||
| //# sourceMappingURL=get-gasless-provider-metadata.d.ts.map |
| {"version":3,"file":"get-gasless-provider-metadata.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-provider-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,iCAAiC;IAC9C,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,oCAAoC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEpF,MAAM,MAAM,mCAAmC,GAAG,KAAK,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,0BAA0B,GACnC,QAAQ,MAAM,EACd,UAAS,iCAAsC,KAChD,oCAEF,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessProviderMetadata = void 0; | ||
| /** | ||
| * Get static metadata for a gasless provider (display name, logo, url). | ||
| */ | ||
| const getGaslessProviderMetadata = async (appKit, options = {}) => { | ||
| return appKit.gaslessManager.getMetadata(options.providerId); | ||
| }; | ||
| exports.getGaslessProviderMetadata = getGaslessProviderMetadata; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessProviderInterface } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessProviderOptions { | ||
| id?: string; | ||
| } | ||
| export type GetGaslessProviderReturnType = GaslessProviderInterface; | ||
| export declare const getGaslessProvider: (appKit: AppKit, options?: GetGaslessProviderOptions) => GetGaslessProviderReturnType; | ||
| //# sourceMappingURL=get-gasless-provider.d.ts.map |
| {"version":3,"file":"get-gasless-provider.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,yBAAyB;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AAEpE,eAAO,MAAM,kBAAkB,GAC3B,QAAQ,MAAM,EACd,UAAS,yBAA8B,KACxC,4BAEF,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessProvider = void 0; | ||
| const getGaslessProvider = (appKit, options = {}) => { | ||
| return appKit.gaslessManager.getProvider(options.id); | ||
| }; | ||
| exports.getGaslessProvider = getGaslessProvider; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessProviderInterface } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type GetGaslessProvidersReturnType = GaslessProviderInterface[]; | ||
| /** | ||
| * Get all registered gasless providers. | ||
| */ | ||
| export declare const getGaslessProviders: (appKit: AppKit) => GetGaslessProvidersReturnType; | ||
| //# sourceMappingURL=get-gasless-providers.d.ts.map |
| {"version":3,"file":"get-gasless-providers.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,6BAA6B,GAAG,wBAAwB,EAAE,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,KAAG,6BAEpD,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessProviders = void 0; | ||
| /** | ||
| * Get all registered gasless providers. | ||
| */ | ||
| const getGaslessProviders = (appKit) => { | ||
| return appKit.gaslessManager.getProviders(); | ||
| }; | ||
| exports.getGaslessProviders = getGaslessProviders; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessQuote } from '../../gasless'; | ||
| import type { Network } from '../../types/network'; | ||
| import type { UserFriendlyAddress } from '../../types/primitives'; | ||
| import type { TransactionRequestMessage } from '../../types/transaction'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessQuoteOptions { | ||
| /** | ||
| * Asset address used to pay the relayer's fee (currently a jetton master | ||
| * for TonAPI; future providers may accept NFT items or other assets). | ||
| * Omit for free / sponsored providers — jetton-only providers will throw | ||
| * `GaslessError(UnsupportedOperation)` in that case. | ||
| */ | ||
| feeAsset?: UserFriendlyAddress; | ||
| /** User's messages to include in the gasless transaction */ | ||
| messages: TransactionRequestMessage[]; | ||
| /** Network to quote on. Defaults to the selected wallet's network. */ | ||
| network?: Network; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessQuoteReturnType = Promise<GaslessQuote>; | ||
| export type GetGaslessQuoteErrorType = Error; | ||
| /** | ||
| * Ask the relayer for a gasless transaction quote. | ||
| * | ||
| * Returns relayer-wrapped messages (ready to be signed via `signMessage`), the | ||
| * fee charged in the fee jetton, and the bundle validity window (`validUntil`). | ||
| * | ||
| * The result is intended to be passed verbatim to `sendGaslessTransaction`, | ||
| * which forwards the signed BoC to the relayer. | ||
| */ | ||
| export declare const getGaslessQuote: (appKit: AppKit, options: GetGaslessQuoteOptions) => GetGaslessQuoteReturnType; | ||
| //# sourceMappingURL=get-gasless-quote.d.ts.map |
| {"version":3,"file":"get-gasless-quote.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-quote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,WAAW,sBAAsB;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,4DAA4D;IAC5D,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IACtC,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAE9D,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE7C;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAU,QAAQ,MAAM,EAAE,SAAS,sBAAsB,KAAG,yBAiBvF,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessQuote = void 0; | ||
| const get_selected_wallet_1 = require("../wallets/get-selected-wallet"); | ||
| /** | ||
| * Ask the relayer for a gasless transaction quote. | ||
| * | ||
| * Returns relayer-wrapped messages (ready to be signed via `signMessage`), the | ||
| * fee charged in the fee jetton, and the bundle validity window (`validUntil`). | ||
| * | ||
| * The result is intended to be passed verbatim to `sendGaslessTransaction`, | ||
| * which forwards the signed BoC to the relayer. | ||
| */ | ||
| const getGaslessQuote = async (appKit, options) => { | ||
| const wallet = (0, get_selected_wallet_1.getSelectedWallet)(appKit); | ||
| if (!wallet) { | ||
| throw new Error('Wallet not connected'); | ||
| } | ||
| return appKit.gaslessManager.getQuote({ | ||
| network: options.network ?? wallet.getNetwork(), | ||
| feeAsset: options.feeAsset, | ||
| walletAddress: wallet.getAddress(), | ||
| walletPublicKey: wallet.getPublicKey(), | ||
| messages: options.messages, | ||
| }, options.providerId); | ||
| }; | ||
| exports.getGaslessQuote = getGaslessQuote; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessQuote, GaslessSendResponse } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface SendGaslessTransactionParameters { | ||
| /** Pre-computed quote obtained via `getGaslessQuote` */ | ||
| quote: GaslessQuote; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| /** | ||
| * Return type is `GaslessSendResponse` — `SendTransactionResponse` plus | ||
| * `internalBoc`. Consumers can drop `result.boc` straight into | ||
| * `getTransactionStatus({ boc })` or build explorer links from | ||
| * `result.normalizedHash` the same way as regular `sendTransaction`. | ||
| */ | ||
| export type SendGaslessTransactionReturnType = GaslessSendResponse; | ||
| export type SendGaslessTransactionErrorType = Error; | ||
| /** | ||
| * Sign a previously computed gasless quote and submit the resulting BoC | ||
| * to the relayer. | ||
| * | ||
| * Quote freshness is owned by the query layer (`getGaslessQuoteQueryOptions` | ||
| * sets a 2-minute `staleTime` matching the relayer `validUntil` window). If a | ||
| * stale quote is submitted anyway, the relayer rejects it and the error | ||
| * surfaces through `gaslessManager.sendTransaction`. | ||
| * | ||
| * @throws GaslessError(QUOTE_EXPIRED) when the quote's relayer-provided | ||
| * `validUntil` window has already passed. Checked before signing so the | ||
| * wallet is never prompted for a quote the relayer would reject anyway. | ||
| * @throws GaslessError(WALLET_MISMATCH) when the quote was issued for a | ||
| * different address than the currently selected wallet (e.g. the active | ||
| * wallet was switched after the quote was fetched). | ||
| * @throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when the wallet does not | ||
| * advertise the `SignMessage` feature. | ||
| * @throws GaslessError(TOO_MANY_MESSAGES) when the quote carries more | ||
| * messages than the wallet's advertised `maxMessages` cap. | ||
| * @throws GaslessError(SEND_FAILED) when the relayer accepts the BoC but | ||
| * omits the broadcasted external message in its response. | ||
| */ | ||
| export declare const sendGaslessTransaction: (appKit: AppKit, parameters: SendGaslessTransactionParameters) => Promise<SendGaslessTransactionReturnType>; | ||
| //# sourceMappingURL=send-gasless-transaction.d.ts.map |
| {"version":3,"file":"send-gasless-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/send-gasless-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,WAAW,gCAAgC;IAC7C,wDAAwD;IACxD,KAAK,EAAE,YAAY,CAAC;IACpB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,MAAM,gCAAgC,GAAG,mBAAmB,CAAC;AAEnE,MAAM,MAAM,+BAA+B,GAAG,KAAK,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,sBAAsB,GAC/B,QAAQ,MAAM,EACd,YAAY,gCAAgC,KAC7C,OAAO,CAAC,gCAAgC,CAuE1C,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.sendGaslessTransaction = void 0; | ||
| const gasless_1 = require("../../gasless"); | ||
| const get_selected_wallet_1 = require("../wallets/get-selected-wallet"); | ||
| const utils_1 = require("../../utils"); | ||
| /** | ||
| * Sign a previously computed gasless quote and submit the resulting BoC | ||
| * to the relayer. | ||
| * | ||
| * Quote freshness is owned by the query layer (`getGaslessQuoteQueryOptions` | ||
| * sets a 2-minute `staleTime` matching the relayer `validUntil` window). If a | ||
| * stale quote is submitted anyway, the relayer rejects it and the error | ||
| * surfaces through `gaslessManager.sendTransaction`. | ||
| * | ||
| * @throws GaslessError(QUOTE_EXPIRED) when the quote's relayer-provided | ||
| * `validUntil` window has already passed. Checked before signing so the | ||
| * wallet is never prompted for a quote the relayer would reject anyway. | ||
| * @throws GaslessError(WALLET_MISMATCH) when the quote was issued for a | ||
| * different address than the currently selected wallet (e.g. the active | ||
| * wallet was switched after the quote was fetched). | ||
| * @throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when the wallet does not | ||
| * advertise the `SignMessage` feature. | ||
| * @throws GaslessError(TOO_MANY_MESSAGES) when the quote carries more | ||
| * messages than the wallet's advertised `maxMessages` cap. | ||
| * @throws GaslessError(SEND_FAILED) when the relayer accepts the BoC but | ||
| * omits the broadcasted external message in its response. | ||
| */ | ||
| const sendGaslessTransaction = async (appKit, parameters) => { | ||
| const { quote, providerId } = parameters; | ||
| const wallet = (0, get_selected_wallet_1.getSelectedWallet)(appKit); | ||
| if (!wallet) { | ||
| throw new Error('Wallet not connected'); | ||
| } | ||
| // Fail fast on a dead quote before prompting the wallet to sign: the relayer | ||
| // owns `validUntil`, so a passed deadline means the relayer would reject the | ||
| // send anyway. Cheaper to surface a typed error here than to round-trip a | ||
| // signature the relayer discards. A non-finite `validUntil` (missing/garbled | ||
| // relayer response) is treated as expired rather than silently bypassing the | ||
| // check (`n > undefined` is always false). | ||
| if (!Number.isFinite(quote.validUntil) || Math.floor(Date.now() / 1000) > quote.validUntil) { | ||
| throw new gasless_1.GaslessError('Gasless quote has expired or is missing a validity window. Fetch a fresh quote before sending.', gasless_1.GaslessErrorCode.QuoteExpired, { validUntil: quote.validUntil }); | ||
| } | ||
| // Guard against the active wallet being switched between quote and send: the | ||
| // quote is bound to the `from` the relayer echoed, and signing with a | ||
| // different wallet would produce a BoC the relayer rejects. Skip when a | ||
| // provider does not echo `from` (treat absence as "no claim", not mismatch). | ||
| if (quote.from && !(0, utils_1.compareAddress)(quote.from, wallet.getAddress())) { | ||
| throw new gasless_1.GaslessError('Gasless quote was issued for a different wallet than the selected one.', gasless_1.GaslessErrorCode.WalletMismatch, { quoteFrom: quote.from, wallet: wallet.getAddress() }); | ||
| } | ||
| // Gasless signs via `signMessage`, so the wallet must advertise the | ||
| // `SignMessage` feature, and the quote's message bundle must fit the wallet's | ||
| // `SignMessage` `maxMessages` cap. Checked before prompting so a wallet that | ||
| // can't satisfy the request fails with a typed error instead of an opaque | ||
| // bridge rejection. | ||
| const features = wallet.getSupportedFeatures() ?? []; | ||
| if (!(0, utils_1.hasSignMessageSupport)(features)) { | ||
| throw new gasless_1.GaslessError('Connected wallet does not support the SignMessage feature required for gasless transactions.', gasless_1.GaslessErrorCode.SignMessageNotSupported); | ||
| } | ||
| const maxMessages = (0, utils_1.getMaxOutgoingMessages)(features, 'SignMessage'); | ||
| if (quote.messages.length > maxMessages) { | ||
| throw new gasless_1.GaslessError(`Quote has ${quote.messages.length} messages but the wallet only supports up to ${maxMessages}.`, gasless_1.GaslessErrorCode.TooManyMessages, { messages: quote.messages.length, maxMessages }); | ||
| } | ||
| const { internalBoc } = await wallet.signMessage({ | ||
| messages: quote.messages, | ||
| validUntil: quote.validUntil, | ||
| }); | ||
| return appKit.gaslessManager.sendTransaction({ | ||
| network: quote.network, | ||
| walletPublicKey: wallet.getPublicKey(), | ||
| internalBoc, | ||
| }, providerId); | ||
| }; | ||
| exports.sendGaslessTransaction = sendGaslessTransaction; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export {}; | ||
| //# sourceMappingURL=send-gasless-transaction.test.d.ts.map |
| {"version":3,"file":"send-gasless-transaction.test.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/send-gasless-transaction.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const vitest_1 = require("vitest"); | ||
| const gasless_1 = require("../../gasless"); | ||
| const network_1 = require("../../types/network"); | ||
| const send_gasless_transaction_1 = require("./send-gasless-transaction"); | ||
| const TEST_ADDRESS = 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'; | ||
| const FAKE_INTERNAL_BOC = 'te6cckEBAQEAAgAAAA=='; | ||
| const makeQuote = (overrides = {}) => ({ | ||
| network: network_1.Network.mainnet(), | ||
| messages: [{ address: TEST_ADDRESS, amount: '60000000' }], | ||
| fee: '1234', | ||
| validUntil: Math.floor(Date.now() / 1000) + 60, | ||
| from: TEST_ADDRESS, | ||
| ...overrides, | ||
| }); | ||
| const SIGN_MESSAGE_FEATURE = { name: 'SignMessage', maxMessages: 4 }; | ||
| const makeWallet = (overrides = {}) => { | ||
| return { | ||
| connectorId: 'tonconnect', | ||
| getAddress: () => TEST_ADDRESS, | ||
| getPublicKey: () => '0xabc', | ||
| getNetwork: () => ({ chainId: '-239' }), | ||
| getWalletId: () => 'wallet-1', | ||
| getSupportedFeatures: () => [SIGN_MESSAGE_FEATURE], | ||
| sendTransaction: vitest_1.vi.fn(), | ||
| signData: vitest_1.vi.fn(), | ||
| signMessage: vitest_1.vi.fn().mockResolvedValue({ internalBoc: FAKE_INTERNAL_BOC }), | ||
| ...overrides, | ||
| }; | ||
| }; | ||
| const DEFAULT_SEND_RESULT = { | ||
| boc: 'external_boc_b64', | ||
| normalizedBoc: 'normalized_b64', | ||
| normalizedHash: '0xabcdef', | ||
| internalBoc: FAKE_INTERNAL_BOC, | ||
| }; | ||
| const makeAppKit = (wallet) => { | ||
| const sendTransaction = vitest_1.vi.fn().mockResolvedValue({ ...DEFAULT_SEND_RESULT }); | ||
| const appKit = { | ||
| walletsManager: { selectedWallet: wallet }, | ||
| gaslessManager: { sendTransaction }, | ||
| }; | ||
| return { appKit, sendTransaction }; | ||
| }; | ||
| (0, vitest_1.describe)('sendGaslessTransaction', () => { | ||
| let wallet; | ||
| (0, vitest_1.beforeEach)(() => { | ||
| wallet = makeWallet(); | ||
| }); | ||
| (0, vitest_1.it)('signs the quote and forwards SendTransactionResponse-shaped fields from the relayer', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const quote = makeQuote(); | ||
| const result = await (0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote }); | ||
| (0, vitest_1.expect)(wallet.signMessage).toHaveBeenCalledWith({ | ||
| messages: quote.messages, | ||
| validUntil: quote.validUntil, | ||
| }); | ||
| (0, vitest_1.expect)(sendTransaction).toHaveBeenCalledWith({ network: quote.network, walletPublicKey: '0xabc', internalBoc: FAKE_INTERNAL_BOC }, undefined); | ||
| (0, vitest_1.expect)(result.internalBoc).toBe(FAKE_INTERNAL_BOC); | ||
| (0, vitest_1.expect)(result.boc).toBe(DEFAULT_SEND_RESULT.boc); | ||
| (0, vitest_1.expect)(result.normalizedBoc).toBe(DEFAULT_SEND_RESULT.normalizedBoc); | ||
| (0, vitest_1.expect)(result.normalizedHash).toBe(DEFAULT_SEND_RESULT.normalizedHash); | ||
| }); | ||
| (0, vitest_1.it)('forwards providerId to gaslessManager.sendTransaction', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| await (0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote: makeQuote(), providerId: 'custom' }); | ||
| (0, vitest_1.expect)(sendTransaction).toHaveBeenCalledWith(vitest_1.expect.anything(), 'custom'); | ||
| }); | ||
| (0, vitest_1.it)('throws plain Error when no wallet is connected', async () => { | ||
| const { appKit } = makeAppKit(null); | ||
| await (0, vitest_1.expect)((0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote: makeQuote() })).rejects.toThrow('Wallet not connected'); | ||
| }); | ||
| (0, vitest_1.it)('throws GaslessError(QUOTE_EXPIRED) before signing when the quote validUntil has passed', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const expiredQuote = makeQuote({ validUntil: Math.floor(Date.now() / 1000) - 1 }); | ||
| await (0, vitest_1.expect)((0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote: expiredQuote })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: gasless_1.GaslessErrorCode.QuoteExpired, | ||
| }); | ||
| (0, vitest_1.expect)(wallet.signMessage).not.toHaveBeenCalled(); | ||
| (0, vitest_1.expect)(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| (0, vitest_1.it)('throws GaslessError(QUOTE_EXPIRED) when validUntil is missing/non-finite', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const quoteWithoutValidUntil = makeQuote({ validUntil: undefined }); | ||
| await (0, vitest_1.expect)((0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote: quoteWithoutValidUntil })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: gasless_1.GaslessErrorCode.QuoteExpired, | ||
| }); | ||
| (0, vitest_1.expect)(wallet.signMessage).not.toHaveBeenCalled(); | ||
| (0, vitest_1.expect)(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| (0, vitest_1.it)('throws GaslessError(WALLET_MISMATCH) before signing when the quote was issued for another wallet', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const otherWalletQuote = makeQuote({ from: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c' }); | ||
| await (0, vitest_1.expect)((0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote: otherWalletQuote })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: gasless_1.GaslessErrorCode.WalletMismatch, | ||
| }); | ||
| (0, vitest_1.expect)(wallet.signMessage).not.toHaveBeenCalled(); | ||
| (0, vitest_1.expect)(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| (0, vitest_1.it)('throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when wallet lacks SignMessage feature', async () => { | ||
| const walletWithoutFeature = makeWallet({ | ||
| getSupportedFeatures: () => [{ name: 'SignData' }], | ||
| }); | ||
| const { appKit } = makeAppKit(walletWithoutFeature); | ||
| await (0, vitest_1.expect)((0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote: makeQuote() })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: gasless_1.GaslessErrorCode.SignMessageNotSupported, | ||
| }); | ||
| (0, vitest_1.expect)(walletWithoutFeature.signMessage).not.toHaveBeenCalled(); | ||
| }); | ||
| (0, vitest_1.it)('throws GaslessError(TOO_MANY_MESSAGES) when quote exceeds wallet maxMessages', async () => { | ||
| const walletWithCap = makeWallet({ | ||
| getSupportedFeatures: () => [{ name: 'SignMessage', maxMessages: 1 }], | ||
| }); | ||
| const { appKit } = makeAppKit(walletWithCap); | ||
| const quote = makeQuote({ | ||
| messages: [ | ||
| { address: TEST_ADDRESS, amount: '1' }, | ||
| { address: TEST_ADDRESS, amount: '2' }, | ||
| ], | ||
| }); | ||
| await (0, vitest_1.expect)((0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: gasless_1.GaslessErrorCode.TooManyMessages, | ||
| }); | ||
| (0, vitest_1.expect)(walletWithCap.signMessage).not.toHaveBeenCalled(); | ||
| }); | ||
| (0, vitest_1.it)('throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when wallet does not advertise any features', async () => { | ||
| // Treat undefined features the same as missing SignMessage — gasless | ||
| // requires SignMessage, so unknown capabilities fail closed instead of | ||
| // attempting to sign and surfacing an uglier bridge-level error. | ||
| const walletWithUnknown = makeWallet({ getSupportedFeatures: () => undefined }); | ||
| const { appKit, sendTransaction } = makeAppKit(walletWithUnknown); | ||
| await (0, vitest_1.expect)((0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote: makeQuote() })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: gasless_1.GaslessErrorCode.SignMessageNotSupported, | ||
| }); | ||
| (0, vitest_1.expect)(walletWithUnknown.signMessage).not.toHaveBeenCalled(); | ||
| (0, vitest_1.expect)(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| (0, vitest_1.it)('propagates errors from gaslessManager.sendTransaction', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| sendTransaction.mockRejectedValueOnce(new Error('relayer offline')); | ||
| await (0, vitest_1.expect)((0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, { quote: makeQuote() })).rejects.toThrow('relayer offline'); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface SetDefaultGaslessProviderParameters { | ||
| providerId: string; | ||
| } | ||
| export type SetDefaultGaslessProviderReturnType = void; | ||
| /** | ||
| * Set the default gasless provider. | ||
| * Subsequent estimate and send calls will use this provider when none is specified. | ||
| */ | ||
| export declare const setDefaultGaslessProvider: (appKit: AppKit, parameters: SetDefaultGaslessProviderParameters) => SetDefaultGaslessProviderReturnType; | ||
| //# sourceMappingURL=set-default-gasless-provider.d.ts.map |
| {"version":3,"file":"set-default-gasless-provider.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/set-default-gasless-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,mCAAmC;IAChD,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,mCAAmC,GAAG,IAAI,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,GAClC,QAAQ,MAAM,EACd,YAAY,mCAAmC,KAChD,mCAEF,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.setDefaultGaslessProvider = void 0; | ||
| /** | ||
| * Set the default gasless provider. | ||
| * Subsequent estimate and send calls will use this provider when none is specified. | ||
| */ | ||
| const setDefaultGaslessProvider = (appKit, parameters) => { | ||
| appKit.gaslessManager.setDefaultProvider(parameters.providerId); | ||
| }; | ||
| exports.setDefaultGaslessProvider = setDefaultGaslessProvider; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface WatchGaslessProvidersParameters { | ||
| onChange: () => void; | ||
| } | ||
| export type WatchGaslessProvidersReturnType = () => void; | ||
| /** | ||
| * Watch for new gasless providers registration and default-provider changes. | ||
| */ | ||
| export declare const watchGaslessProviders: (appKit: AppKit, parameters: WatchGaslessProvidersParameters) => WatchGaslessProvidersReturnType; | ||
| //# sourceMappingURL=watch-gasless-providers.d.ts.map |
| {"version":3,"file":"watch-gasless-providers.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/watch-gasless-providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,+BAA+B;IAC5C,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,+BAA+B,GAAG,MAAM,IAAI,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAC9B,QAAQ,MAAM,EACd,YAAY,+BAA+B,KAC5C,+BAeF,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.watchGaslessProviders = void 0; | ||
| /** | ||
| * Watch for new gasless providers registration and default-provider changes. | ||
| */ | ||
| const watchGaslessProviders = (appKit, parameters) => { | ||
| const { onChange } = parameters; | ||
| const unsubscribeRegistered = appKit.emitter.on('provider:registered', (event) => { | ||
| if (event.payload.type === 'gasless') | ||
| onChange(); | ||
| }); | ||
| const unsubscribeDefaultChanged = appKit.emitter.on('provider:default-changed', (event) => { | ||
| if (event.payload.type === 'gasless') | ||
| onChange(); | ||
| }); | ||
| return () => { | ||
| unsubscribeRegistered(); | ||
| unsubscribeDefaultChanged(); | ||
| }; | ||
| }; | ||
| exports.watchGaslessProviders = watchGaslessProviders; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { TransactionRequest } from '../../types/transaction'; | ||
| import type { SignMessageResponse } from '../../types/signing'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type SignMessageParameters = TransactionRequest; | ||
| export type SignMessageReturnType = SignMessageResponse; | ||
| export type SignMessageErrorType = Error; | ||
| /** | ||
| * Ask the connected wallet to sign a transaction-shaped request without broadcasting it. | ||
| * | ||
| * Returns a signed internal-message BoC that can be relayed on-chain by a third party | ||
| * (e.g. a gasless relayer). Unlike sendTransaction, the message is NOT submitted to the | ||
| * network by the wallet. | ||
| * | ||
| * Throws when the connected wallet does not advertise the `SignMessage` feature, or when | ||
| * the request carries more messages than the wallet's `SignMessage` `maxMessages` cap — | ||
| * surfacing a clear error before prompting instead of an opaque bridge rejection. | ||
| */ | ||
| export declare const signMessage: (appKit: AppKit, parameters: SignMessageParameters) => Promise<SignMessageReturnType>; | ||
| //# sourceMappingURL=sign-message.d.ts.map |
| {"version":3,"file":"sign-message.d.ts","sourceRoot":"","sources":["../../../../src/actions/transaction/sign-message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEvD,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,GACpB,QAAQ,MAAM,EACd,YAAY,qBAAqB,KAClC,OAAO,CAAC,qBAAqB,CAqB/B,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.signMessage = void 0; | ||
| const utils_1 = require("../../utils"); | ||
| const get_selected_wallet_1 = require("../wallets/get-selected-wallet"); | ||
| /** | ||
| * Ask the connected wallet to sign a transaction-shaped request without broadcasting it. | ||
| * | ||
| * Returns a signed internal-message BoC that can be relayed on-chain by a third party | ||
| * (e.g. a gasless relayer). Unlike sendTransaction, the message is NOT submitted to the | ||
| * network by the wallet. | ||
| * | ||
| * Throws when the connected wallet does not advertise the `SignMessage` feature, or when | ||
| * the request carries more messages than the wallet's `SignMessage` `maxMessages` cap — | ||
| * surfacing a clear error before prompting instead of an opaque bridge rejection. | ||
| */ | ||
| const signMessage = async (appKit, parameters) => { | ||
| const wallet = (0, get_selected_wallet_1.getSelectedWallet)(appKit); | ||
| if (!wallet) { | ||
| throw new Error('Wallet not connected'); | ||
| } | ||
| const features = wallet.getSupportedFeatures() ?? []; | ||
| if (!(0, utils_1.hasSignMessageSupport)(features)) { | ||
| throw new Error('Connected wallet does not support the SignMessage feature.'); | ||
| } | ||
| const maxMessages = (0, utils_1.getMaxOutgoingMessages)(features, 'SignMessage'); | ||
| if (parameters.messages.length > maxMessages) { | ||
| throw new Error(`SignMessage request has ${parameters.messages.length} messages but the wallet supports up to ${maxMessages}.`); | ||
| } | ||
| return wallet.signMessage(parameters); | ||
| }; | ||
| exports.signMessage = signMessage; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type GetSignMessageSupportReturnType = boolean; | ||
| /** | ||
| * Whether the currently selected wallet advertises the `SignMessage` feature | ||
| * (required for gasless transactions). | ||
| * | ||
| * Fail-closed: returns `false` when no wallet is selected or the wallet | ||
| * advertises no features. This mirrors the gasless send path, which rejects a | ||
| * `SignMessage` request from a wallet that doesn't list the feature — so the UI | ||
| * should not offer gasless when the send would refuse it. | ||
| */ | ||
| export declare const getSignMessageSupport: (appKit: AppKit) => GetSignMessageSupportReturnType; | ||
| //# sourceMappingURL=get-sign-message-support.d.ts.map |
| {"version":3,"file":"get-sign-message-support.d.ts","sourceRoot":"","sources":["../../../../src/actions/wallets/get-sign-message-support.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,MAAM,+BAA+B,GAAG,OAAO,CAAC;AAEtD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,KAAG,+BAGtD,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getSignMessageSupport = void 0; | ||
| const utils_1 = require("../../utils"); | ||
| const get_selected_wallet_1 = require("./get-selected-wallet"); | ||
| /** | ||
| * Whether the currently selected wallet advertises the `SignMessage` feature | ||
| * (required for gasless transactions). | ||
| * | ||
| * Fail-closed: returns `false` when no wallet is selected or the wallet | ||
| * advertises no features. This mirrors the gasless send path, which rejects a | ||
| * `SignMessage` request from a wallet that doesn't list the feature — so the UI | ||
| * should not offer gasless when the send would refuse it. | ||
| */ | ||
| const getSignMessageSupport = (appKit) => { | ||
| const features = (0, get_selected_wallet_1.getSelectedWallet)(appKit)?.getSupportedFeatures(); | ||
| return features ? (0, utils_1.hasSignMessageSupport)(features) : false; | ||
| }; | ||
| exports.getSignMessageSupport = getSignMessageSupport; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface WatchSignMessageSupportParameters { | ||
| onChange: (supported: boolean) => void; | ||
| } | ||
| export type WatchSignMessageSupportReturnType = () => void; | ||
| /** | ||
| * Watch whether the selected wallet supports `SignMessage`. Re-evaluated on | ||
| * every wallet selection change (features are static per wallet, so the | ||
| * selection change is the only thing that can flip the result). | ||
| */ | ||
| export declare const watchSignMessageSupport: (appKit: AppKit, parameters: WatchSignMessageSupportParameters) => WatchSignMessageSupportReturnType; | ||
| //# sourceMappingURL=watch-sign-message-support.d.ts.map |
| {"version":3,"file":"watch-sign-message-support.d.ts","sourceRoot":"","sources":["../../../../src/actions/wallets/watch-sign-message-support.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,WAAW,iCAAiC;IAC9C,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,MAAM,iCAAiC,GAAG,MAAM,IAAI,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAChC,QAAQ,MAAM,EACd,YAAY,iCAAiC,KAC9C,iCAQF,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.watchSignMessageSupport = void 0; | ||
| const app_kit_1 = require("../../core/app-kit"); | ||
| const get_sign_message_support_1 = require("./get-sign-message-support"); | ||
| /** | ||
| * Watch whether the selected wallet supports `SignMessage`. Re-evaluated on | ||
| * every wallet selection change (features are static per wallet, so the | ||
| * selection change is the only thing that can flip the result). | ||
| */ | ||
| const watchSignMessageSupport = (appKit, parameters) => { | ||
| const { onChange } = parameters; | ||
| const unsubscribe = appKit.emitter.on(app_kit_1.WALLETS_EVENTS.SELECTION_CHANGED, () => { | ||
| onChange((0, get_sign_message_support_1.getSignMessageSupport)(appKit)); | ||
| }); | ||
| return unsubscribe; | ||
| }; | ||
| exports.watchSignMessageSupport = watchSignMessageSupport; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export { GaslessProvider, GaslessError, GaslessErrorCode, GaslessManager } from '@ton/walletkit'; | ||
| export type { GaslessAPI, GaslessProviderInterface, GaslessConfig, GaslessSupportedAsset, GaslessProviderMetadata, GaslessProviderMetadataOverride, GaslessQuoteParams, GaslessQuote, GaslessSendParams, GaslessSendResponse, } from '@ton/walletkit'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjG,YAAY,EACR,UAAU,EACV,wBAAwB,EACxB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,+BAA+B,EAC/B,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,GACtB,MAAM,gBAAgB,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.GaslessManager = exports.GaslessErrorCode = exports.GaslessError = exports.GaslessProvider = void 0; | ||
| var walletkit_1 = require("@ton/walletkit"); | ||
| Object.defineProperty(exports, "GaslessProvider", { enumerable: true, get: function () { return walletkit_1.GaslessProvider; } }); | ||
| Object.defineProperty(exports, "GaslessError", { enumerable: true, get: function () { return walletkit_1.GaslessError; } }); | ||
| Object.defineProperty(exports, "GaslessErrorCode", { enumerable: true, get: function () { return walletkit_1.GaslessErrorCode; } }); | ||
| Object.defineProperty(exports, "GaslessManager", { enumerable: true, get: function () { return walletkit_1.GaslessManager; } }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export * from '@ton/walletkit/gasless/tonapi'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/gasless/tonapi/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,+BAA+B,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("@ton/walletkit/gasless/tonapi"), exports); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GetGaslessConfigErrorType, GetGaslessConfigOptions, GetGaslessConfigReturnType } from '../../actions/gasless/get-gasless-config'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| export type { GetGaslessConfigErrorType }; | ||
| export type GetGaslessConfigQueryConfig<selectData = GetGaslessConfigData> = Compute<ExactPartial<GetGaslessConfigOptions>> & QueryParameter<GetGaslessConfigQueryFnData, GetGaslessConfigErrorType, selectData, GetGaslessConfigQueryKey>; | ||
| export declare const getGaslessConfigQueryOptions: <selectData = GetGaslessConfigData>(appKit: AppKit, options?: GetGaslessConfigQueryConfig<selectData>) => GetGaslessConfigQueryOptions<selectData>; | ||
| export type GetGaslessConfigQueryFnData = Compute<Awaited<GetGaslessConfigReturnType>>; | ||
| export type GetGaslessConfigData = GetGaslessConfigQueryFnData; | ||
| export declare const getGaslessConfigQueryKey: (options?: Compute<ExactPartial<GetGaslessConfigOptions>>) => GetGaslessConfigQueryKey; | ||
| export type GetGaslessConfigQueryKey = readonly ['gaslessConfig', Compute<ExactPartial<GetGaslessConfigOptions>>]; | ||
| export type GetGaslessConfigQueryOptions<selectData = GetGaslessConfigData> = QueryOptions<GetGaslessConfigQueryFnData, GetGaslessConfigErrorType, selectData, GetGaslessConfigQueryKey>; | ||
| //# sourceMappingURL=get-gasless-config.d.ts.map |
| {"version":3,"file":"get-gasless-config.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/get-gasless-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACR,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC7B,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG/D,YAAY,EAAE,yBAAyB,EAAE,CAAC;AAE1C,MAAM,MAAM,2BAA2B,CAAC,UAAU,GAAG,oBAAoB,IAAI,OAAO,CAChF,YAAY,CAAC,uBAAuB,CAAC,CACxC,GACG,cAAc,CAAC,2BAA2B,EAAE,yBAAyB,EAAE,UAAU,EAAE,wBAAwB,CAAC,CAAC;AAEjH,eAAO,MAAM,4BAA4B,GAAI,UAAU,GAAG,oBAAoB,EAC1E,QAAQ,MAAM,EACd,UAAS,2BAA2B,CAAC,UAAU,CAAM,KACtD,4BAA4B,CAAC,UAAU,CAWzC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC;AAEvF,MAAM,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAE/D,eAAO,MAAM,wBAAwB,GACjC,UAAS,OAAO,CAAC,YAAY,CAAC,uBAAuB,CAAC,CAAM,KAC7D,wBAEF,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,SAAS,CAAC,eAAe,EAAE,OAAO,CAAC,YAAY,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAElH,MAAM,MAAM,4BAA4B,CAAC,UAAU,GAAG,oBAAoB,IAAI,YAAY,CACtF,2BAA2B,EAC3B,yBAAyB,EACzB,UAAU,EACV,wBAAwB,CAC3B,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessConfigQueryKey = exports.getGaslessConfigQueryOptions = void 0; | ||
| const get_gasless_config_1 = require("../../actions/gasless/get-gasless-config"); | ||
| const utils_1 = require("../../utils"); | ||
| const getGaslessConfigQueryOptions = (appKit, options = {}) => { | ||
| const resolvedOptions = { ...options, network: (0, utils_1.resolveNetwork)(appKit, options.network) }; | ||
| return { | ||
| ...options.query, | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey; | ||
| return (0, get_gasless_config_1.getGaslessConfig)(appKit, parameters); | ||
| }, | ||
| queryKey: (0, exports.getGaslessConfigQueryKey)(resolvedOptions), | ||
| }; | ||
| }; | ||
| exports.getGaslessConfigQueryOptions = getGaslessConfigQueryOptions; | ||
| const getGaslessConfigQueryKey = (options = {}) => { | ||
| return ['gaslessConfig', (0, utils_1.filterQueryOptions)(options)]; | ||
| }; | ||
| exports.getGaslessConfigQueryKey = getGaslessConfigQueryKey; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GetGaslessJettonTransferQuoteErrorType, GetGaslessJettonTransferQuoteOptions, GetGaslessJettonTransferQuoteReturnType } from '../../actions/gasless/get-gasless-jetton-transfer-quote'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { Network } from '../../types/network'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| export type { GetGaslessJettonTransferQuoteErrorType }; | ||
| export type GetGaslessJettonTransferQuoteQueryConfig<selectData = GetGaslessJettonTransferQuoteData> = Compute<ExactPartial<GetGaslessJettonTransferQuoteOptions>> & QueryParameter<GetGaslessJettonTransferQuoteQueryFnData, GetGaslessJettonTransferQuoteErrorType, selectData, GetGaslessJettonTransferQuoteQueryKey>; | ||
| export declare const getGaslessJettonTransferQuoteQueryOptions: <selectData = GetGaslessJettonTransferQuoteData>(appKit: AppKit, options?: GetGaslessJettonTransferQuoteQueryConfig<selectData>, network?: Network) => GetGaslessJettonTransferQuoteQueryOptions<selectData>; | ||
| export type GetGaslessJettonTransferQuoteQueryFnData = Compute<Awaited<GetGaslessJettonTransferQuoteReturnType>>; | ||
| export type GetGaslessJettonTransferQuoteData = GetGaslessJettonTransferQuoteQueryFnData; | ||
| export declare const getGaslessJettonTransferQuoteQueryKey: (options?: Compute<ExactPartial<GetGaslessJettonTransferQuoteOptions>>, walletAddress?: string, networkChainId?: string) => GetGaslessJettonTransferQuoteQueryKey; | ||
| export type GetGaslessJettonTransferQuoteQueryKey = readonly [ | ||
| 'gaslessJettonTransferQuote', | ||
| Compute<ExactPartial<GetGaslessJettonTransferQuoteOptions>>, | ||
| string | undefined, | ||
| string | undefined | ||
| ]; | ||
| export type GetGaslessJettonTransferQuoteQueryOptions<selectData = GetGaslessJettonTransferQuoteData> = QueryOptions<GetGaslessJettonTransferQuoteQueryFnData, GetGaslessJettonTransferQuoteErrorType, selectData, GetGaslessJettonTransferQuoteQueryKey>; | ||
| //# sourceMappingURL=get-gasless-jetton-transfer-quote.d.ts.map |
| {"version":3,"file":"get-gasless-jetton-transfer-quote.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/get-gasless-jetton-transfer-quote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACR,sCAAsC,EACtC,oCAAoC,EACpC,uCAAuC,EAC1C,MAAM,yDAAyD,CAAC;AAEjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI/D,YAAY,EAAE,sCAAsC,EAAE,CAAC;AAEvD,MAAM,MAAM,wCAAwC,CAAC,UAAU,GAAG,iCAAiC,IAAI,OAAO,CAC1G,YAAY,CAAC,oCAAoC,CAAC,CACrD,GACG,cAAc,CACV,wCAAwC,EACxC,sCAAsC,EACtC,UAAU,EACV,qCAAqC,CACxC,CAAC;AAEN,eAAO,MAAM,yCAAyC,GAAI,UAAU,GAAG,iCAAiC,EACpG,QAAQ,MAAM,EACd,UAAS,wCAAwC,CAAC,UAAU,CAAM,EAClE,UAAU,OAAO,KAClB,yCAAyC,CAAC,UAAU,CAmCtD,CAAC;AAEF,MAAM,MAAM,wCAAwC,GAAG,OAAO,CAAC,OAAO,CAAC,uCAAuC,CAAC,CAAC,CAAC;AAEjH,MAAM,MAAM,iCAAiC,GAAG,wCAAwC,CAAC;AAEzF,eAAO,MAAM,qCAAqC,GAC9C,UAAS,OAAO,CAAC,YAAY,CAAC,oCAAoC,CAAC,CAAM,EACzE,gBAAgB,MAAM,EACtB,iBAAiB,MAAM,KACxB,qCAOF,CAAC;AAEF,MAAM,MAAM,qCAAqC,GAAG,SAAS;IACzD,4BAA4B;IAC5B,OAAO,CAAC,YAAY,CAAC,oCAAoC,CAAC,CAAC;IAC3D,MAAM,GAAG,SAAS;IAClB,MAAM,GAAG,SAAS;CACrB,CAAC;AAEF,MAAM,MAAM,yCAAyC,CAAC,UAAU,GAAG,iCAAiC,IAAI,YAAY,CAChH,wCAAwC,EACxC,sCAAsC,EACtC,UAAU,EACV,qCAAqC,CACxC,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessJettonTransferQuoteQueryKey = exports.getGaslessJettonTransferQuoteQueryOptions = void 0; | ||
| const get_gasless_jetton_transfer_quote_1 = require("../../actions/gasless/get-gasless-jetton-transfer-quote"); | ||
| const get_selected_wallet_1 = require("../../actions/wallets/get-selected-wallet"); | ||
| const utils_1 = require("../../utils"); | ||
| const get_gasless_quote_1 = require("./get-gasless-quote"); | ||
| const getGaslessJettonTransferQuoteQueryOptions = (appKit, options = {}, network) => { | ||
| // Bind the quote to the selected wallet's address and network so a | ||
| // wallet/network switch produces a distinct cache entry and refetch | ||
| // (mirrors `getGaslessQuoteQueryOptions`). The quote is always built on the | ||
| // selected wallet's network — the action resolves it internally, there is no | ||
| // caller override — so `network` here is a key dimension only, never forwarded | ||
| // to the action. | ||
| const wallet = (0, get_selected_wallet_1.getSelectedWallet)(appKit); | ||
| const walletAddress = wallet?.getAddress(); | ||
| const networkChainId = (0, utils_1.resolveNetwork)(appKit, network).chainId; | ||
| return { | ||
| staleTime: get_gasless_quote_1.GASLESS_QUOTE_STALE_TIME_MS, | ||
| ...options.query, | ||
| // Gate on a connected wallet too: the action resolves the jetton wallet | ||
| // via the selected wallet and throws without one, so without this the | ||
| // query would fire into a `Wallet not connected` error instead of idling. | ||
| enabled: Boolean(options.jettonAddress && | ||
| options.recipientAddress && | ||
| options.amount && | ||
| walletAddress && | ||
| (options.query?.enabled ?? true)), | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey; | ||
| return (0, get_gasless_jetton_transfer_quote_1.getGaslessJettonTransferQuote)(appKit, parameters); | ||
| }, | ||
| queryKey: (0, exports.getGaslessJettonTransferQuoteQueryKey)(options, walletAddress, networkChainId), | ||
| }; | ||
| }; | ||
| exports.getGaslessJettonTransferQuoteQueryOptions = getGaslessJettonTransferQuoteQueryOptions; | ||
| const getGaslessJettonTransferQuoteQueryKey = (options = {}, walletAddress, networkChainId) => { | ||
| return [ | ||
| 'gaslessJettonTransferQuote', | ||
| (0, utils_1.filterQueryOptions)(options), | ||
| walletAddress, | ||
| networkChainId, | ||
| ]; | ||
| }; | ||
| exports.getGaslessJettonTransferQuoteQueryKey = getGaslessJettonTransferQuoteQueryKey; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GetGaslessProviderMetadataErrorType, GetGaslessProviderMetadataOptions, GetGaslessProviderMetadataReturnType } from '../../actions/gasless/get-gasless-provider-metadata'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| export type { GetGaslessProviderMetadataErrorType }; | ||
| export type GetGaslessProviderMetadataQueryConfig<selectData = GetGaslessProviderMetadataData> = Compute<ExactPartial<GetGaslessProviderMetadataOptions>> & QueryParameter<GetGaslessProviderMetadataQueryFnData, GetGaslessProviderMetadataErrorType, selectData, GetGaslessProviderMetadataQueryKey>; | ||
| export declare const getGaslessProviderMetadataQueryOptions: <selectData = GetGaslessProviderMetadataData>(appKit: AppKit, options?: GetGaslessProviderMetadataQueryConfig<selectData>) => GetGaslessProviderMetadataQueryOptions<selectData>; | ||
| export type GetGaslessProviderMetadataQueryFnData = Compute<Awaited<GetGaslessProviderMetadataReturnType>>; | ||
| export type GetGaslessProviderMetadataData = GetGaslessProviderMetadataQueryFnData; | ||
| export declare const getGaslessProviderMetadataQueryKey: (options?: Compute<ExactPartial<GetGaslessProviderMetadataOptions>>) => GetGaslessProviderMetadataQueryKey; | ||
| export type GetGaslessProviderMetadataQueryKey = readonly [ | ||
| 'gaslessProviderMetadata', | ||
| Compute<ExactPartial<GetGaslessProviderMetadataOptions>> | ||
| ]; | ||
| export type GetGaslessProviderMetadataQueryOptions<selectData = GetGaslessProviderMetadataData> = QueryOptions<GetGaslessProviderMetadataQueryFnData, GetGaslessProviderMetadataErrorType, selectData, GetGaslessProviderMetadataQueryKey>; | ||
| //# sourceMappingURL=get-gasless-provider-metadata.d.ts.map |
| {"version":3,"file":"get-gasless-provider-metadata.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/get-gasless-provider-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* This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessProviderMetadataQueryKey = exports.getGaslessProviderMetadataQueryOptions = void 0; | ||
| const get_gasless_provider_metadata_1 = require("../../actions/gasless/get-gasless-provider-metadata"); | ||
| const utils_1 = require("../../utils"); | ||
| const getGaslessProviderMetadataQueryOptions = (appKit, options = {}) => { | ||
| return { | ||
| ...options.query, | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey; | ||
| return (0, get_gasless_provider_metadata_1.getGaslessProviderMetadata)(appKit, parameters); | ||
| }, | ||
| queryKey: (0, exports.getGaslessProviderMetadataQueryKey)(options), | ||
| }; | ||
| }; | ||
| exports.getGaslessProviderMetadataQueryOptions = getGaslessProviderMetadataQueryOptions; | ||
| const getGaslessProviderMetadataQueryKey = (options = {}) => { | ||
| return ['gaslessProviderMetadata', (0, utils_1.filterQueryOptions)(options)]; | ||
| }; | ||
| exports.getGaslessProviderMetadataQueryKey = getGaslessProviderMetadataQueryKey; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GetGaslessQuoteErrorType, GetGaslessQuoteOptions, GetGaslessQuoteReturnType } from '../../actions/gasless/get-gasless-quote'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| export type { GetGaslessQuoteErrorType }; | ||
| /** | ||
| * Default time-to-live for a gasless quote. The relayer returns its own | ||
| * `validUntil`; this is the upper bound used by react-query to refresh the | ||
| * quote before it expires. | ||
| */ | ||
| export declare const GASLESS_QUOTE_STALE_TIME_MS: number; | ||
| export type GetGaslessQuoteQueryConfig<selectData = GetGaslessQuoteData> = Compute<ExactPartial<GetGaslessQuoteOptions>> & QueryParameter<GetGaslessQuoteQueryFnData, GetGaslessQuoteErrorType, selectData, GetGaslessQuoteQueryKey>; | ||
| export declare const getGaslessQuoteQueryOptions: <selectData = GetGaslessQuoteData>(appKit: AppKit, options?: GetGaslessQuoteQueryConfig<selectData>) => GetGaslessQuoteQueryOptions<selectData>; | ||
| export type GetGaslessQuoteQueryFnData = Compute<Awaited<GetGaslessQuoteReturnType>>; | ||
| export type GetGaslessQuoteData = GetGaslessQuoteQueryFnData; | ||
| export declare const getGaslessQuoteQueryKey: (options?: Compute<ExactPartial<GetGaslessQuoteOptions>>, walletAddress?: string) => GetGaslessQuoteQueryKey; | ||
| export type GetGaslessQuoteQueryKey = readonly [ | ||
| 'gaslessQuote', | ||
| Compute<ExactPartial<GetGaslessQuoteOptions>>, | ||
| string | undefined | ||
| ]; | ||
| export type GetGaslessQuoteQueryOptions<selectData = GetGaslessQuoteData> = QueryOptions<GetGaslessQuoteQueryFnData, GetGaslessQuoteErrorType, selectData, GetGaslessQuoteQueryKey>; | ||
| //# sourceMappingURL=get-gasless-quote.d.ts.map |
| {"version":3,"file":"get-gasless-quote.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/get-gasless-quote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACR,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EAC5B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG/D,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAAgB,CAAC;AAEzD,MAAM,MAAM,0BAA0B,CAAC,UAAU,GAAG,mBAAmB,IAAI,OAAO,CAC9E,YAAY,CAAC,sBAAsB,CAAC,CACvC,GACG,cAAc,CAAC,0BAA0B,EAAE,wBAAwB,EAAE,UAAU,EAAE,uBAAuB,CAAC,CAAC;AAE9G,eAAO,MAAM,2BAA2B,GAAI,UAAU,GAAG,mBAAmB,EACxE,QAAQ,MAAM,EACd,UAAS,0BAA0B,CAAC,UAAU,CAAM,KACrD,2BAA2B,CAAC,UAAU,CAgCxC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAErF,MAAM,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAE7D,eAAO,MAAM,uBAAuB,GAChC,UAAS,OAAO,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAM,EAC3D,gBAAgB,MAAM,KACvB,uBAEF,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,SAAS;IAC3C,cAAc;IACd,OAAO,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;IAC7C,MAAM,GAAG,SAAS;CACrB,CAAC;AAEF,MAAM,MAAM,2BAA2B,CAAC,UAAU,GAAG,mBAAmB,IAAI,YAAY,CACpF,0BAA0B,EAC1B,wBAAwB,EACxB,UAAU,EACV,uBAAuB,CAC1B,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getGaslessQuoteQueryKey = exports.getGaslessQuoteQueryOptions = exports.GASLESS_QUOTE_STALE_TIME_MS = void 0; | ||
| const get_gasless_quote_1 = require("../../actions/gasless/get-gasless-quote"); | ||
| const get_selected_wallet_1 = require("../../actions/wallets/get-selected-wallet"); | ||
| const utils_1 = require("../../utils"); | ||
| /** | ||
| * Default time-to-live for a gasless quote. The relayer returns its own | ||
| * `validUntil`; this is the upper bound used by react-query to refresh the | ||
| * quote before it expires. | ||
| */ | ||
| exports.GASLESS_QUOTE_STALE_TIME_MS = 2 * 60 * 1000; | ||
| const getGaslessQuoteQueryOptions = (appKit, options = {}) => { | ||
| // The quote is bound to the selected wallet's address and network, both of | ||
| // which `getGaslessQuote` resolves internally. Fold them into the key so a | ||
| // wallet/network switch produces a distinct cache entry and refetch instead | ||
| // of silently serving a quote issued for a different wallet. | ||
| const wallet = (0, get_selected_wallet_1.getSelectedWallet)(appKit); | ||
| const walletAddress = wallet?.getAddress(); | ||
| const resolvedOptions = { ...options, network: options.network ?? wallet?.getNetwork() }; | ||
| return { | ||
| staleTime: exports.GASLESS_QUOTE_STALE_TIME_MS, | ||
| ...options.query, | ||
| // `feeAsset` is intentionally not part of the gate: free / sponsored | ||
| // providers accept an undefined asset, and jetton-only providers throw | ||
| // a typed error themselves. We require messages and a connected wallet — | ||
| // the action resolves the wallet internally and throws without one, so | ||
| // gating here keeps the query idle instead of erroring (matches the | ||
| // jetton/ton transfer-quote options). | ||
| enabled: Boolean(options.messages && options.messages.length > 0 && walletAddress && (options.query?.enabled ?? true)), | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey; | ||
| if (!parameters.messages || parameters.messages.length === 0) { | ||
| throw new Error('messages is required'); | ||
| } | ||
| return (0, get_gasless_quote_1.getGaslessQuote)(appKit, parameters); | ||
| }, | ||
| queryKey: (0, exports.getGaslessQuoteQueryKey)(resolvedOptions, walletAddress), | ||
| }; | ||
| }; | ||
| exports.getGaslessQuoteQueryOptions = getGaslessQuoteQueryOptions; | ||
| const getGaslessQuoteQueryKey = (options = {}, walletAddress) => { | ||
| return ['gaslessQuote', (0, utils_1.filterQueryOptions)(options), walletAddress]; | ||
| }; | ||
| exports.getGaslessQuoteQueryKey = getGaslessQuoteQueryKey; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { MutateOptions, MutationOptions } from '@tanstack/query-core'; | ||
| import type { SendGaslessTransactionErrorType, SendGaslessTransactionParameters, SendGaslessTransactionReturnType } from '../../actions/gasless/send-gasless-transaction'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { MutationParameter } from '../../types/query'; | ||
| import type { Compute } from '../../types/utils'; | ||
| export type { SendGaslessTransactionErrorType }; | ||
| export type SendGaslessTransactionMutationConfig<context = unknown> = MutationParameter<SendGaslessTransactionData, SendGaslessTransactionErrorType, SendGaslessTransactionVariables, context>; | ||
| export declare const sendGaslessTransactionMutationOptions: <context = unknown>(appKit: AppKit, config?: SendGaslessTransactionMutationConfig<context>) => SendGaslessTransactionMutationOptions<context>; | ||
| export type SendGaslessTransactionVariables = Compute<SendGaslessTransactionParameters>; | ||
| export type SendGaslessTransactionData = Compute<Awaited<SendGaslessTransactionReturnType>>; | ||
| export type SendGaslessTransactionMutate<context = unknown> = (variables: SendGaslessTransactionVariables, options?: Compute<MutateOptions<SendGaslessTransactionData, SendGaslessTransactionErrorType, SendGaslessTransactionVariables, context>> | undefined) => void; | ||
| export type SendGaslessTransactionMutateAsync<context = unknown> = (variables: SendGaslessTransactionVariables, options?: Compute<MutateOptions<SendGaslessTransactionData, SendGaslessTransactionErrorType, SendGaslessTransactionVariables, context>> | undefined) => Promise<SendGaslessTransactionData>; | ||
| export type SendGaslessTransactionMutationOptions<context = unknown> = MutationOptions<SendGaslessTransactionData, SendGaslessTransactionErrorType, SendGaslessTransactionVariables, context>; | ||
| //# sourceMappingURL=send-gasless-transaction.d.ts.map |
| {"version":3,"file":"send-gasless-transaction.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/send-gasless-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG3E,OAAO,KAAK,EACR,+BAA+B,EAC/B,gCAAgC,EAChC,gCAAgC,EACnC,MAAM,gDAAgD,CAAC;AACxD,OAAO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C"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.sendGaslessTransactionMutationOptions = void 0; | ||
| const send_gasless_transaction_1 = require("../../actions/gasless/send-gasless-transaction"); | ||
| const sendGaslessTransactionMutationOptions = (appKit, config = {}) => { | ||
| return { | ||
| ...config.mutation, | ||
| mutationFn(variables) { | ||
| return (0, send_gasless_transaction_1.sendGaslessTransaction)(appKit, variables); | ||
| }, | ||
| mutationKey: ['sendGaslessTransaction'], | ||
| }; | ||
| }; | ||
| exports.sendGaslessTransactionMutationOptions = sendGaslessTransactionMutationOptions; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { MutateOptions, MutationOptions } from '@tanstack/query-core'; | ||
| import type { SignMessageErrorType, SignMessageParameters, SignMessageReturnType } from '../../actions/transaction/sign-message'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { MutationParameter } from '../../types/query'; | ||
| import type { Compute } from '../../types/utils'; | ||
| export type { SignMessageErrorType, SignMessageParameters, SignMessageReturnType }; | ||
| export type SignMessageOptions<context = unknown> = MutationParameter<SignMessageData, SignMessageErrorType, SignMessageVariables, context>; | ||
| export declare const signMessageMutationOptions: <context = unknown>(appKit: AppKit, options?: SignMessageOptions<context>) => SignMessageMutationOptions<context>; | ||
| export type SignMessageMutationOptions<context = unknown> = MutationOptions<SignMessageData, SignMessageErrorType, SignMessageVariables, context>; | ||
| export type SignMessageData = Compute<SignMessageReturnType>; | ||
| export type SignMessageVariables = SignMessageParameters; | ||
| export type SignMessageMutate<context = unknown> = (variables: SignMessageVariables, options?: Compute<MutateOptions<SignMessageData, SignMessageErrorType, Compute<SignMessageVariables>, context>> | undefined) => void; | ||
| export type SignMessageMutateAsync<context = unknown> = (variables: SignMessageVariables, options?: Compute<MutateOptions<SignMessageData, SignMessageErrorType, Compute<SignMessageVariables>, context>> | undefined) => Promise<SignMessageData>; | ||
| //# sourceMappingURL=sign-message.d.ts.map |
| {"version":3,"file":"sign-message.d.ts","sourceRoot":"","sources":["../../../../src/queries/transaction/sign-message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG3E,OAAO,KAAK,EACR,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,CAAC;AAEnF,MAAM,MAAM,kBAAkB,CAAC,OAAO,GAAG,OAAO,IAAI,iBAAiB,CACjE,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,CACV,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,GAAG,OAAO,EACxD,QAAQ,MAAM,EACd,UAAS,kBAAkB,CAAC,OAAO,CAAM,KAC1C,0BAA0B,CAAC,OAAO,CAQpC,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,OAAO,GAAG,OAAO,IAAI,eAAe,CACvE,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,CACV,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAEzD,MAAM,MAAM,iBAAiB,CAAC,OAAO,GAAG,OAAO,IAAI,CAC/C,SAAS,EAAE,oBAAoB,EAC/B,OAAO,CAAC,EACF,OAAO,CAAC,aAAa,CAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,CAAC,GACrG,SAAS,KACd,IAAI,CAAC;AAEV,MAAM,MAAM,sBAAsB,CAAC,OAAO,GAAG,OAAO,IAAI,CACpD,SAAS,EAAE,oBAAoB,EAC/B,OAAO,CAAC,EACF,OAAO,CAAC,aAAa,CAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,CAAC,GACrG,SAAS,KACd,OAAO,CAAC,eAAe,CAAC,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.signMessageMutationOptions = void 0; | ||
| const sign_message_1 = require("../../actions/transaction/sign-message"); | ||
| const signMessageMutationOptions = (appKit, options = {}) => { | ||
| return { | ||
| ...options.mutation, | ||
| mutationFn(variables) { | ||
| return (0, sign_message_1.signMessage)(appKit, variables); | ||
| }, | ||
| mutationKey: ['signMessage'], | ||
| }; | ||
| }; | ||
| exports.signMessageMutationOptions = signMessageMutationOptions; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export interface CheckTonBalanceParams { | ||
| /** Outgoing messages of the built transaction — each `amount` is the TON value in nanos. */ | ||
| messages: Array<{ | ||
| amount: string; | ||
| }>; | ||
| /** | ||
| * User's TON balance as a decimal string (`formatUnits(balance, 9)` format). | ||
| * `undefined` means "not loaded yet" — function returns `undefined` (no judgement). | ||
| */ | ||
| tonBalance: string | undefined; | ||
| /** Extra TON headroom on top of total outflow. Caller-supplied — no opinion on default. */ | ||
| gasBufferNanos: bigint; | ||
| } | ||
| export interface TonBalanceShortfall { | ||
| /** Total TON the user wallet must hold for the transaction to land. */ | ||
| requiredNanos: bigint; | ||
| } | ||
| /** | ||
| * Pure balance check: does the user have enough TON for the built transaction? | ||
| * | ||
| * Returns `undefined` when the balance is sufficient OR when it hasn't loaded | ||
| * yet (treating unloaded as "unknown" rather than "zero" avoids false-positive | ||
| * shortfalls flashing on first render). | ||
| * | ||
| * No mode classification — this hook reports only "shortfall exists, here's | ||
| * how much was needed." Callers decide what to suggest (topup, gasless, | ||
| * reduce, etc.). For transfer/swap flows where the user can reduce their own | ||
| * outflow, compose this with `checkTransferBalance`. | ||
| */ | ||
| export declare const checkTonBalance: ({ messages, tonBalance, gasBufferNanos, }: CheckTonBalanceParams) => TonBalanceShortfall | undefined; | ||
| //# sourceMappingURL=check-ton-balance.d.ts.map |
| {"version":3,"file":"check-ton-balance.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/check-ton-balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,qBAAqB;IAClC,4FAA4F;IAC5F,QAAQ,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpC;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,2FAA2F;IAC3F,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAChC,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,2CAI7B,qBAAqB,KAAG,mBAAmB,GAAG,SAShD,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.checkTonBalance = void 0; | ||
| const walletkit_1 = require("@ton/walletkit"); | ||
| /** | ||
| * Pure balance check: does the user have enough TON for the built transaction? | ||
| * | ||
| * Returns `undefined` when the balance is sufficient OR when it hasn't loaded | ||
| * yet (treating unloaded as "unknown" rather than "zero" avoids false-positive | ||
| * shortfalls flashing on first render). | ||
| * | ||
| * No mode classification — this hook reports only "shortfall exists, here's | ||
| * how much was needed." Callers decide what to suggest (topup, gasless, | ||
| * reduce, etc.). For transfer/swap flows where the user can reduce their own | ||
| * outflow, compose this with `checkTransferBalance`. | ||
| */ | ||
| const checkTonBalance = ({ messages, tonBalance, gasBufferNanos, }) => { | ||
| if (tonBalance === undefined) | ||
| return undefined; | ||
| const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n); | ||
| const requiredNanos = totalOutNanos + gasBufferNanos; | ||
| const tonBalanceNanos = (0, walletkit_1.parseUnits)(tonBalance, 9); | ||
| if (tonBalanceNanos >= requiredNanos) | ||
| return undefined; | ||
| return { requiredNanos }; | ||
| }; | ||
| exports.checkTonBalance = checkTonBalance; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export {}; | ||
| //# sourceMappingURL=check-ton-balance.test.d.ts.map |
| {"version":3,"file":"check-ton-balance.test.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/check-ton-balance.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const vitest_1 = require("vitest"); | ||
| const check_ton_balance_1 = require("./check-ton-balance"); | ||
| /** 0.01 TON in nanos — a reasonable buffer for unit tests. */ | ||
| const BUFFER = 10000000n; | ||
| const msg = (amountNanos) => ({ amount: amountNanos.toString() }); | ||
| (0, vitest_1.describe)('checkTonBalance', () => { | ||
| (0, vitest_1.describe)('balance is sufficient', () => { | ||
| (0, vitest_1.it)('returns undefined when balance exceeds outflow + buffer', () => { | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(50000000n)], // 0.05 TON outflow | ||
| tonBalance: '1', // 1 TON | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toBeUndefined(); | ||
| }); | ||
| (0, vitest_1.it)('returns undefined when balance equals exactly (required = balance)', () => { | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(50000000n)], // 0.05 TON | ||
| tonBalance: '0.06', // 0.06 TON = 0.05 + 0.01 buffer | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toBeUndefined(); | ||
| }); | ||
| (0, vitest_1.it)('returns undefined for an empty messages array when balance covers buffer', () => { | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [], | ||
| tonBalance: '0.01', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| (0, vitest_1.describe)('balance is insufficient', () => { | ||
| (0, vitest_1.it)('returns shortfall when balance is below required', () => { | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '0.05', // 0.05 TON — exactly outflow, but no headroom for buffer | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ requiredNanos: 60000000n }); | ||
| }); | ||
| (0, vitest_1.it)('returns shortfall when balance is zero', () => { | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(1000000n)], // 0.001 TON deploy | ||
| tonBalance: '0', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ requiredNanos: 11000000n }); | ||
| }); | ||
| (0, vitest_1.it)('sums multiple message outflows', () => { | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(50000000n), msg(30000000n), msg(10000000n)], | ||
| tonBalance: '0.05', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ requiredNanos: 50000000n + 30000000n + 10000000n + BUFFER }); | ||
| }); | ||
| (0, vitest_1.it)('respects a smaller gasBufferNanos override', () => { | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '0.05', | ||
| gasBufferNanos: 1000000n, // 0.001 TON buffer | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ requiredNanos: 51000000n }); | ||
| }); | ||
| (0, vitest_1.it)('triggers on a 1-nano deficit (boundary)', () => { | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '0.059999999', // 1 nano short of 0.06 = 50_000_000 + 10_000_000 buffer | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ requiredNanos: 60000000n }); | ||
| }); | ||
| }); | ||
| (0, vitest_1.describe)('unloaded balance', () => { | ||
| (0, vitest_1.it)('returns undefined when tonBalance is undefined (not yet loaded)', () => { | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: undefined, | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toBeUndefined(); | ||
| }); | ||
| (0, vitest_1.it)('treats undefined as "unknown", not as zero — no false-positive shortfall', () => { | ||
| // If `undefined` were treated as 0n, a user with insufficient balance would already | ||
| // see a shortfall flash on first render before their real balance loads. | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(1000000000n)], | ||
| tonBalance: undefined, | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| (0, vitest_1.describe)('precision', () => { | ||
| (0, vitest_1.it)('handles bigint values larger than Number.MAX_SAFE_INTEGER', () => { | ||
| const huge = 1000000000000000000n; // 1 quintillion nanos = 1 billion TON | ||
| const result = (0, check_ton_balance_1.checkTonBalance)({ | ||
| messages: [msg(huge)], | ||
| tonBalance: '0', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ requiredNanos: huge + BUFFER }); | ||
| }); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { CheckTonBalanceParams } from './check-ton-balance'; | ||
| /** | ||
| * Default headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one sent after the | ||
| * amount changes. 0.02 TON. | ||
| */ | ||
| export declare const DEFAULT_SAFETY_MARGIN_NANOS = 20000000n; | ||
| export interface CheckTransferBalanceParams extends CheckTonBalanceParams { | ||
| /** The asset being transferred / swapped. TON-from enables the `'reduce'` outcome. */ | ||
| fromToken: { | ||
| address: string; | ||
| }; | ||
| /** Amount of `fromToken` being sent, as a decimal string in `fromToken` units. */ | ||
| fromAmount: string; | ||
| /** | ||
| * Headroom baked into the suggested reduced amount when the recovery mode is `'reduce'`. | ||
| * Defaults to {@link DEFAULT_SAFETY_MARGIN_NANOS}. | ||
| */ | ||
| safetyMarginNanos?: bigint; | ||
| } | ||
| export type TransferShortfall = { | ||
| mode: 'reduce'; | ||
| requiredNanos: bigint; | ||
| suggestedFromAmount: string; | ||
| } | { | ||
| mode: 'topup'; | ||
| requiredNanos: bigint; | ||
| }; | ||
| /** | ||
| * Balance check for user-initiated transfers (send TON / jetton / NFT) and swaps — | ||
| * where the user controls a `fromAmount` and might be able to fix a shortfall by | ||
| * sending less. | ||
| * | ||
| * Returns: | ||
| * - `undefined` when balance is sufficient (or unloaded — see {@link checkTonBalance}). | ||
| * - `{ mode: 'reduce', suggestedFromAmount }` only when `fromToken` is TON and the | ||
| * remaining balance can still cover gas — the user can keep going by spending less. | ||
| * - `{ mode: 'topup' }` otherwise (reducing wouldn't free up TON gas). | ||
| * | ||
| * Gasless availability is intentionally **not** modelled here — that's a UI policy. | ||
| * Caller maps `'topup'` to `'gasless'` when a gasless alternative is on the table. | ||
| */ | ||
| export declare const checkTransferBalance: ({ messages, tonBalance, gasBufferNanos, fromToken, fromAmount, safetyMarginNanos, }: CheckTransferBalanceParams) => TransferShortfall | undefined; | ||
| //# sourceMappingURL=check-transfer-balance.d.ts.map |
| {"version":3,"file":"check-transfer-balance.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/check-transfer-balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,YAAc,CAAC;AAEvD,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACrE,sFAAsF;IACtF,SAAS,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,MAAM,iBAAiB,GACvB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAAI,qFAOlC,0BAA0B,KAAG,iBAAiB,GAAG,SA0BnD,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.checkTransferBalance = exports.DEFAULT_SAFETY_MARGIN_NANOS = void 0; | ||
| const walletkit_1 = require("@ton/walletkit"); | ||
| const check_ton_balance_1 = require("./check-ton-balance"); | ||
| /** | ||
| * Default headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one sent after the | ||
| * amount changes. 0.02 TON. | ||
| */ | ||
| exports.DEFAULT_SAFETY_MARGIN_NANOS = 20000000n; | ||
| /** | ||
| * Balance check for user-initiated transfers (send TON / jetton / NFT) and swaps — | ||
| * where the user controls a `fromAmount` and might be able to fix a shortfall by | ||
| * sending less. | ||
| * | ||
| * Returns: | ||
| * - `undefined` when balance is sufficient (or unloaded — see {@link checkTonBalance}). | ||
| * - `{ mode: 'reduce', suggestedFromAmount }` only when `fromToken` is TON and the | ||
| * remaining balance can still cover gas — the user can keep going by spending less. | ||
| * - `{ mode: 'topup' }` otherwise (reducing wouldn't free up TON gas). | ||
| * | ||
| * Gasless availability is intentionally **not** modelled here — that's a UI policy. | ||
| * Caller maps `'topup'` to `'gasless'` when a gasless alternative is on the table. | ||
| */ | ||
| const checkTransferBalance = ({ messages, tonBalance, gasBufferNanos, fromToken, fromAmount, safetyMarginNanos = exports.DEFAULT_SAFETY_MARGIN_NANOS, }) => { | ||
| const shortfall = (0, check_ton_balance_1.checkTonBalance)({ messages, tonBalance, gasBufferNanos }); | ||
| if (!shortfall) | ||
| return undefined; | ||
| // Reducing the user's own amount only helps when the outflow is in TON. | ||
| // For jetton / NFT outflow, gas is denominated in TON regardless — reducing | ||
| // the jetton-side input doesn't free up any TON. | ||
| if (fromToken.address !== 'ton') { | ||
| return { mode: 'topup', requiredNanos: shortfall.requiredNanos }; | ||
| } | ||
| // We know `tonBalance !== undefined` because checkTonBalance returned a shortfall | ||
| // (it short-circuits on undefined balance). | ||
| const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n); | ||
| const fromAmountNanos = (0, walletkit_1.parseUnits)(fromAmount, 9); | ||
| const gasOnlyNanos = totalOutNanos - fromAmountNanos; | ||
| const nonSpendReservedNanos = gasOnlyNanos + gasBufferNanos + safetyMarginNanos; | ||
| const tonBalanceNanos = (0, walletkit_1.parseUnits)(tonBalance, 9); | ||
| if (tonBalanceNanos <= nonSpendReservedNanos) { | ||
| // Even gas doesn't fit — reducing the spend amount won't help. | ||
| return { mode: 'topup', requiredNanos: shortfall.requiredNanos }; | ||
| } | ||
| const suggestedFromAmount = (0, walletkit_1.formatUnits)(tonBalanceNanos - nonSpendReservedNanos, 9); | ||
| return { mode: 'reduce', requiredNanos: shortfall.requiredNanos, suggestedFromAmount }; | ||
| }; | ||
| exports.checkTransferBalance = checkTransferBalance; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export {}; | ||
| //# sourceMappingURL=check-transfer-balance.test.d.ts.map |
| {"version":3,"file":"check-transfer-balance.test.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/check-transfer-balance.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const vitest_1 = require("vitest"); | ||
| const check_transfer_balance_1 = require("./check-transfer-balance"); | ||
| const BUFFER = 10000000n; // 0.01 TON | ||
| const TON = { address: 'ton' }; | ||
| const JETTON = { address: 'EQA_jetton_master' }; | ||
| const msg = (amountNanos) => ({ amount: amountNanos.toString() }); | ||
| (0, vitest_1.describe)('checkTransferBalance', () => { | ||
| (0, vitest_1.describe)('balance is sufficient', () => { | ||
| (0, vitest_1.it)('returns undefined regardless of fromToken', () => { | ||
| (0, vitest_1.expect)((0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '1', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.04', | ||
| })).toBeUndefined(); | ||
| (0, vitest_1.expect)((0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '1', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| })).toBeUndefined(); | ||
| }); | ||
| (0, vitest_1.it)('returns undefined when balance is unloaded', () => { | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: undefined, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.04', | ||
| }); | ||
| (0, vitest_1.expect)(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| (0, vitest_1.describe)('jetton outflow — always topup', () => { | ||
| (0, vitest_1.it)('returns topup when jetton-from has insufficient TON for gas', () => { | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(50000000n)], // 0.05 TON jetton-transfer gas | ||
| tonBalance: '0.02', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ mode: 'topup', requiredNanos: 60000000n }); | ||
| }); | ||
| (0, vitest_1.it)('returns topup even when balance is zero', () => { | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(1000000n)], | ||
| tonBalance: '0', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '50', | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ mode: 'topup', requiredNanos: 11000000n }); | ||
| }); | ||
| (0, vitest_1.it)('does not consider safetyMarginNanos for jetton outflow', () => { | ||
| // safetyMarginNanos only matters in the reduce calculation — jetton can't reduce. | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '0.02', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| safetyMarginNanos: 1000000000n, // 1 TON — would be huge if applied | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ mode: 'topup', requiredNanos: 60000000n }); | ||
| }); | ||
| }); | ||
| (0, vitest_1.describe)('TON outflow — reduce when gas fits', () => { | ||
| (0, vitest_1.it)('returns reduce with a smaller suggestedFromAmount when balance covers gas', () => { | ||
| // total_out = fromAmount + gas. User has enough for gas + buffer + safety, but | ||
| // not for full fromAmount. Suggest reduced amount. | ||
| const fromAmountNanos = 500000000n; // 0.5 TON intended spend | ||
| const gasOnlyNanos = 50000000n; // 0.05 TON gas attached to other messages | ||
| const tonBalance = '0.4'; // can't afford 0.5 spend, but enough for gas + margin | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(fromAmountNanos + gasOnlyNanos)], | ||
| tonBalance, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.5', | ||
| }); | ||
| // suggested = balance - gasOnly - gasBuffer - safetyMargin | ||
| // = 400_000_000 - 50_000_000 - 10_000_000 - 20_000_000 = 320_000_000n = 0.32 TON | ||
| (0, vitest_1.expect)(result).toEqual({ | ||
| mode: 'reduce', | ||
| requiredNanos: fromAmountNanos + gasOnlyNanos + BUFFER, | ||
| suggestedFromAmount: '0.32', | ||
| }); | ||
| }); | ||
| (0, vitest_1.it)('returns topup when even gas does not fit', () => { | ||
| // Balance below gasOnly + buffer + safetyMargin → reducing won't help. | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(500000000n)], // 0.5 TON total outflow | ||
| tonBalance: '0.001', // way too low for any meaningful gas | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.4', | ||
| }); | ||
| (0, vitest_1.expect)(result?.mode).toBe('topup'); | ||
| (0, vitest_1.expect)(result?.requiredNanos).toBe(510000000n); | ||
| }); | ||
| (0, vitest_1.it)('boundary: balance equals nonSpendReserved exactly → topup', () => { | ||
| // tonBalance <= nonSpendReserved should return topup (cannot leave anything to spend). | ||
| const gasOnly = 50000000n; | ||
| const fromAmount = 100000000n; | ||
| // nonSpendReserved = gasOnly + BUFFER + DEFAULT_SAFETY_MARGIN_NANOS = 80_000_000n | ||
| const balanceAtBoundary = '0.08'; | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(gasOnly + fromAmount)], | ||
| tonBalance: balanceAtBoundary, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.1', | ||
| }); | ||
| (0, vitest_1.expect)(result?.mode).toBe('topup'); | ||
| }); | ||
| (0, vitest_1.it)('boundary: 1-nano above nonSpendReserved → reduce', () => { | ||
| const gasOnly = 50000000n; | ||
| const fromAmount = 100000000n; | ||
| // nonSpendReserved = gasOnly + BUFFER + DEFAULT_SAFETY_MARGIN_NANOS = 80_000_000n | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(gasOnly + fromAmount)], | ||
| tonBalance: '0.080000001', // 1 nano above the boundary | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.1', | ||
| }); | ||
| // suggested = 1 nano | ||
| (0, vitest_1.expect)(result).toEqual({ | ||
| mode: 'reduce', | ||
| requiredNanos: gasOnly + fromAmount + BUFFER, | ||
| suggestedFromAmount: '0.000000001', | ||
| }); | ||
| }); | ||
| }); | ||
| (0, vitest_1.describe)('safetyMarginNanos', () => { | ||
| (0, vitest_1.it)('shrinks the suggested reduced amount when safetyMargin is larger', () => { | ||
| const tonBalance = '0.4'; | ||
| const baseParams = { | ||
| messages: [msg(550000000n)], // 0.55 TON total outflow | ||
| tonBalance, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.5', | ||
| }; | ||
| const lowMargin = (0, check_transfer_balance_1.checkTransferBalance)({ ...baseParams, safetyMarginNanos: 5000000n }); | ||
| const highMargin = (0, check_transfer_balance_1.checkTransferBalance)({ ...baseParams, safetyMarginNanos: 50000000n }); | ||
| // higher safety margin → less suggested | ||
| (0, vitest_1.expect)(lowMargin?.mode).toBe('reduce'); | ||
| (0, vitest_1.expect)(highMargin?.mode).toBe('reduce'); | ||
| if (lowMargin?.mode === 'reduce' && highMargin?.mode === 'reduce') { | ||
| (0, vitest_1.expect)(BigInt(lowMargin.suggestedFromAmount.replace('.', '').padEnd(10, '0'))).toBeGreaterThan(BigInt(highMargin.suggestedFromAmount.replace('.', '').padEnd(10, '0'))); | ||
| } | ||
| }); | ||
| (0, vitest_1.it)('uses DEFAULT_SAFETY_MARGIN_NANOS when not provided', () => { | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(550000000n)], | ||
| tonBalance: '0.4', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.5', | ||
| }); | ||
| (0, vitest_1.expect)(result?.mode).toBe('reduce'); | ||
| // gasOnly = 50_000_000, balance = 400_000_000 | ||
| // suggested = 400 - 50 - 10 - 20 = 320 mTON | ||
| if (result?.mode === 'reduce') { | ||
| (0, vitest_1.expect)(result.suggestedFromAmount).toBe('0.32'); | ||
| } | ||
| }); | ||
| }); | ||
| (0, vitest_1.describe)('composes checkTonBalance', () => { | ||
| (0, vitest_1.it)('returns undefined when checkTonBalance would (sufficient or unloaded)', () => { | ||
| // Same inputs as a sufficient-balance check | ||
| const result = (0, check_transfer_balance_1.checkTransferBalance)({ | ||
| messages: [msg(10000000n)], | ||
| tonBalance: '1', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.005', | ||
| }); | ||
| (0, vitest_1.expect)(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessConfig } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { Network } from '../../types/network'; | ||
| export interface GetGaslessConfigOptions { | ||
| /** Network to query. Defaults to the selected wallet's network, then provider's first supported. */ | ||
| network?: Network; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessConfigReturnType = Promise<GaslessConfig>; | ||
| export type GetGaslessConfigErrorType = Error; | ||
| /** | ||
| * Fetch the gasless relayer's configuration on a network — the relay address | ||
| * (e.g. for jetton-transfer `responseDestination`) and the assets it accepts | ||
| * as fee payment. | ||
| */ | ||
| export declare const getGaslessConfig: (appKit: AppKit, options?: GetGaslessConfigOptions) => GetGaslessConfigReturnType; | ||
| //# sourceMappingURL=get-gasless-config.d.ts.map |
| {"version":3,"file":"get-gasless-config.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,MAAM,WAAW,uBAAuB;IACpC,oGAAoG;IACpG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEhE,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GACzB,QAAQ,MAAM,EACd,UAAS,uBAA4B,KACtC,0BAGF,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
| /** | ||
| * Fetch the gasless relayer's configuration on a network — the relay address | ||
| * (e.g. for jetton-transfer `responseDestination`) and the assets it accepts | ||
| * as fee payment. | ||
| */ | ||
| export const getGaslessConfig = async (appKit, options = {}) => { | ||
| const network = options.network ?? getSelectedWallet(appKit)?.getNetwork(); | ||
| return appKit.gaslessManager.getConfig(network, options.providerId); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessQuote } from '../../gasless'; | ||
| import type { UserFriendlyAddress } from '../../types/primitives'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessJettonTransferQuoteOptions { | ||
| /** Jetton master address to transfer */ | ||
| jettonAddress: string; | ||
| /** Recipient address */ | ||
| recipientAddress: string; | ||
| /** Human-readable amount of jettons to transfer */ | ||
| amount: string; | ||
| /** Jetton decimals. Auto-fetched from jetton info when omitted. */ | ||
| jettonDecimals?: number; | ||
| /** Optional text comment attached to the transfer */ | ||
| comment?: string; | ||
| /** | ||
| * Asset address used to pay the relayer's fee (jetton master for TonAPI). | ||
| * Omit only for free / sponsored providers — see {@link getGaslessQuote}. | ||
| */ | ||
| feeAsset?: UserFriendlyAddress; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessJettonTransferQuoteReturnType = Promise<GaslessQuote>; | ||
| export type GetGaslessJettonTransferQuoteErrorType = Error; | ||
| /** | ||
| * Build a gasless quote for a jetton transfer. | ||
| * | ||
| * Convenience wrapper that assembles the transfer messages the same way as | ||
| * {@link createTransferJettonTransaction} (resolving the jetton wallet address, | ||
| * decimals and payload) and forwards them to {@link getGaslessQuote}. The result | ||
| * is passed verbatim to `sendGaslessTransaction`, preserving the quote → send | ||
| * two-step flow. | ||
| * | ||
| * The jetton `responseDestination` (excess receiver) is set to the relayer's | ||
| * address — the relayer paid the gas, so the unspent TON goes back to it rather | ||
| * than to the user's wallet. | ||
| * | ||
| * The quote is always bound to the selected wallet's network — the same network | ||
| * the message builder resolves the jetton wallet on — so there is no `network` | ||
| * override (a mismatch would build the message on one chain and quote on another). | ||
| */ | ||
| export declare const getGaslessJettonTransferQuote: (appKit: AppKit, options: GetGaslessJettonTransferQuoteOptions) => GetGaslessJettonTransferQuoteReturnType; | ||
| //# sourceMappingURL=get-gasless-jetton-transfer-quote.d.ts.map |
| {"version":3,"file":"get-gasless-jetton-transfer-quote.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-jetton-transfer-quote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,WAAW,oCAAoC;IACjD,wCAAwC;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,uCAAuC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAE5E,MAAM,MAAM,sCAAsC,GAAG,KAAK,CAAC;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,6BAA6B,GACtC,QAAQ,MAAM,EACd,SAAS,oCAAoC,KAC9C,uCAcF,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { createTransferJettonTransaction } from '../jettons/create-transfer-jetton-transaction'; | ||
| import { getGaslessConfig } from './get-gasless-config'; | ||
| import { getGaslessQuote } from './get-gasless-quote'; | ||
| /** | ||
| * Build a gasless quote for a jetton transfer. | ||
| * | ||
| * Convenience wrapper that assembles the transfer messages the same way as | ||
| * {@link createTransferJettonTransaction} (resolving the jetton wallet address, | ||
| * decimals and payload) and forwards them to {@link getGaslessQuote}. The result | ||
| * is passed verbatim to `sendGaslessTransaction`, preserving the quote → send | ||
| * two-step flow. | ||
| * | ||
| * The jetton `responseDestination` (excess receiver) is set to the relayer's | ||
| * address — the relayer paid the gas, so the unspent TON goes back to it rather | ||
| * than to the user's wallet. | ||
| * | ||
| * The quote is always bound to the selected wallet's network — the same network | ||
| * the message builder resolves the jetton wallet on — so there is no `network` | ||
| * override (a mismatch would build the message on one chain and quote on another). | ||
| */ | ||
| export const getGaslessJettonTransferQuote = async (appKit, options) => { | ||
| const { jettonAddress, recipientAddress, amount, jettonDecimals, comment, feeAsset, providerId } = options; | ||
| const { relayAddress } = await getGaslessConfig(appKit, { providerId }); | ||
| const { messages } = await createTransferJettonTransaction(appKit, { | ||
| jettonAddress, | ||
| recipientAddress, | ||
| amount, | ||
| jettonDecimals, | ||
| comment, | ||
| responseDestination: relayAddress, | ||
| }); | ||
| return getGaslessQuote(appKit, { messages, feeAsset, providerId }); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessManager } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type GetGaslessManagerReturnType = GaslessManager; | ||
| /** | ||
| * Get gasless manager instance | ||
| */ | ||
| export declare const getGaslessManager: (appKit: AppKit) => GetGaslessManagerReturnType; | ||
| //# sourceMappingURL=get-gasless-manager.d.ts.map |
| {"version":3,"file":"get-gasless-manager.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,KAAG,2BAElD,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| /** | ||
| * Get gasless manager instance | ||
| */ | ||
| export const getGaslessManager = (appKit) => { | ||
| return appKit.gaslessManager; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessProviderMetadata } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessProviderMetadataOptions { | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessProviderMetadataReturnType = Promise<GaslessProviderMetadata>; | ||
| export type GetGaslessProviderMetadataErrorType = Error; | ||
| /** | ||
| * Get static metadata for a gasless provider (display name, logo, url). | ||
| */ | ||
| export declare const getGaslessProviderMetadata: (appKit: AppKit, options?: GetGaslessProviderMetadataOptions) => GetGaslessProviderMetadataReturnType; | ||
| //# sourceMappingURL=get-gasless-provider-metadata.d.ts.map |
| {"version":3,"file":"get-gasless-provider-metadata.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-provider-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,iCAAiC;IAC9C,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,oCAAoC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAEpF,MAAM,MAAM,mCAAmC,GAAG,KAAK,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,0BAA0B,GACnC,QAAQ,MAAM,EACd,UAAS,iCAAsC,KAChD,oCAEF,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| /** | ||
| * Get static metadata for a gasless provider (display name, logo, url). | ||
| */ | ||
| export const getGaslessProviderMetadata = async (appKit, options = {}) => { | ||
| return appKit.gaslessManager.getMetadata(options.providerId); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessProviderInterface } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessProviderOptions { | ||
| id?: string; | ||
| } | ||
| export type GetGaslessProviderReturnType = GaslessProviderInterface; | ||
| export declare const getGaslessProvider: (appKit: AppKit, options?: GetGaslessProviderOptions) => GetGaslessProviderReturnType; | ||
| //# sourceMappingURL=get-gasless-provider.d.ts.map |
| {"version":3,"file":"get-gasless-provider.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,yBAAyB;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AAEpE,eAAO,MAAM,kBAAkB,GAC3B,QAAQ,MAAM,EACd,UAAS,yBAA8B,KACxC,4BAEF,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export const getGaslessProvider = (appKit, options = {}) => { | ||
| return appKit.gaslessManager.getProvider(options.id); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessProviderInterface } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type GetGaslessProvidersReturnType = GaslessProviderInterface[]; | ||
| /** | ||
| * Get all registered gasless providers. | ||
| */ | ||
| export declare const getGaslessProviders: (appKit: AppKit) => GetGaslessProvidersReturnType; | ||
| //# sourceMappingURL=get-gasless-providers.d.ts.map |
| {"version":3,"file":"get-gasless-providers.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,6BAA6B,GAAG,wBAAwB,EAAE,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,MAAM,KAAG,6BAEpD,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| /** | ||
| * Get all registered gasless providers. | ||
| */ | ||
| export const getGaslessProviders = (appKit) => { | ||
| return appKit.gaslessManager.getProviders(); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessQuote } from '../../gasless'; | ||
| import type { Network } from '../../types/network'; | ||
| import type { UserFriendlyAddress } from '../../types/primitives'; | ||
| import type { TransactionRequestMessage } from '../../types/transaction'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessQuoteOptions { | ||
| /** | ||
| * Asset address used to pay the relayer's fee (currently a jetton master | ||
| * for TonAPI; future providers may accept NFT items or other assets). | ||
| * Omit for free / sponsored providers — jetton-only providers will throw | ||
| * `GaslessError(UnsupportedOperation)` in that case. | ||
| */ | ||
| feeAsset?: UserFriendlyAddress; | ||
| /** User's messages to include in the gasless transaction */ | ||
| messages: TransactionRequestMessage[]; | ||
| /** Network to quote on. Defaults to the selected wallet's network. */ | ||
| network?: Network; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessQuoteReturnType = Promise<GaslessQuote>; | ||
| export type GetGaslessQuoteErrorType = Error; | ||
| /** | ||
| * Ask the relayer for a gasless transaction quote. | ||
| * | ||
| * Returns relayer-wrapped messages (ready to be signed via `signMessage`), the | ||
| * fee charged in the fee jetton, and the bundle validity window (`validUntil`). | ||
| * | ||
| * The result is intended to be passed verbatim to `sendGaslessTransaction`, | ||
| * which forwards the signed BoC to the relayer. | ||
| */ | ||
| export declare const getGaslessQuote: (appKit: AppKit, options: GetGaslessQuoteOptions) => GetGaslessQuoteReturnType; | ||
| //# sourceMappingURL=get-gasless-quote.d.ts.map |
| {"version":3,"file":"get-gasless-quote.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/get-gasless-quote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,WAAW,sBAAsB;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,4DAA4D;IAC5D,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IACtC,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAE9D,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE7C;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAAU,QAAQ,MAAM,EAAE,SAAS,sBAAsB,KAAG,yBAiBvF,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
| /** | ||
| * Ask the relayer for a gasless transaction quote. | ||
| * | ||
| * Returns relayer-wrapped messages (ready to be signed via `signMessage`), the | ||
| * fee charged in the fee jetton, and the bundle validity window (`validUntil`). | ||
| * | ||
| * The result is intended to be passed verbatim to `sendGaslessTransaction`, | ||
| * which forwards the signed BoC to the relayer. | ||
| */ | ||
| export const getGaslessQuote = async (appKit, options) => { | ||
| const wallet = getSelectedWallet(appKit); | ||
| if (!wallet) { | ||
| throw new Error('Wallet not connected'); | ||
| } | ||
| return appKit.gaslessManager.getQuote({ | ||
| network: options.network ?? wallet.getNetwork(), | ||
| feeAsset: options.feeAsset, | ||
| walletAddress: wallet.getAddress(), | ||
| walletPublicKey: wallet.getPublicKey(), | ||
| messages: options.messages, | ||
| }, options.providerId); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessQuote, GaslessSendResponse } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface SendGaslessTransactionParameters { | ||
| /** Pre-computed quote obtained via `getGaslessQuote` */ | ||
| quote: GaslessQuote; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| /** | ||
| * Return type is `GaslessSendResponse` — `SendTransactionResponse` plus | ||
| * `internalBoc`. Consumers can drop `result.boc` straight into | ||
| * `getTransactionStatus({ boc })` or build explorer links from | ||
| * `result.normalizedHash` the same way as regular `sendTransaction`. | ||
| */ | ||
| export type SendGaslessTransactionReturnType = GaslessSendResponse; | ||
| export type SendGaslessTransactionErrorType = Error; | ||
| /** | ||
| * Sign a previously computed gasless quote and submit the resulting BoC | ||
| * to the relayer. | ||
| * | ||
| * Quote freshness is owned by the query layer (`getGaslessQuoteQueryOptions` | ||
| * sets a 2-minute `staleTime` matching the relayer `validUntil` window). If a | ||
| * stale quote is submitted anyway, the relayer rejects it and the error | ||
| * surfaces through `gaslessManager.sendTransaction`. | ||
| * | ||
| * @throws GaslessError(QUOTE_EXPIRED) when the quote's relayer-provided | ||
| * `validUntil` window has already passed. Checked before signing so the | ||
| * wallet is never prompted for a quote the relayer would reject anyway. | ||
| * @throws GaslessError(WALLET_MISMATCH) when the quote was issued for a | ||
| * different address than the currently selected wallet (e.g. the active | ||
| * wallet was switched after the quote was fetched). | ||
| * @throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when the wallet does not | ||
| * advertise the `SignMessage` feature. | ||
| * @throws GaslessError(TOO_MANY_MESSAGES) when the quote carries more | ||
| * messages than the wallet's advertised `maxMessages` cap. | ||
| * @throws GaslessError(SEND_FAILED) when the relayer accepts the BoC but | ||
| * omits the broadcasted external message in its response. | ||
| */ | ||
| export declare const sendGaslessTransaction: (appKit: AppKit, parameters: SendGaslessTransactionParameters) => Promise<SendGaslessTransactionReturnType>; | ||
| //# sourceMappingURL=send-gasless-transaction.d.ts.map |
| {"version":3,"file":"send-gasless-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/send-gasless-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,WAAW,gCAAgC;IAC7C,wDAAwD;IACxD,KAAK,EAAE,YAAY,CAAC;IACpB,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,MAAM,gCAAgC,GAAG,mBAAmB,CAAC;AAEnE,MAAM,MAAM,+BAA+B,GAAG,KAAK,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,sBAAsB,GAC/B,QAAQ,MAAM,EACd,YAAY,gCAAgC,KAC7C,OAAO,CAAC,gCAAgC,CAuE1C,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { GaslessError, GaslessErrorCode } from '../../gasless'; | ||
| import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
| import { compareAddress, getMaxOutgoingMessages, hasSignMessageSupport } from '../../utils'; | ||
| /** | ||
| * Sign a previously computed gasless quote and submit the resulting BoC | ||
| * to the relayer. | ||
| * | ||
| * Quote freshness is owned by the query layer (`getGaslessQuoteQueryOptions` | ||
| * sets a 2-minute `staleTime` matching the relayer `validUntil` window). If a | ||
| * stale quote is submitted anyway, the relayer rejects it and the error | ||
| * surfaces through `gaslessManager.sendTransaction`. | ||
| * | ||
| * @throws GaslessError(QUOTE_EXPIRED) when the quote's relayer-provided | ||
| * `validUntil` window has already passed. Checked before signing so the | ||
| * wallet is never prompted for a quote the relayer would reject anyway. | ||
| * @throws GaslessError(WALLET_MISMATCH) when the quote was issued for a | ||
| * different address than the currently selected wallet (e.g. the active | ||
| * wallet was switched after the quote was fetched). | ||
| * @throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when the wallet does not | ||
| * advertise the `SignMessage` feature. | ||
| * @throws GaslessError(TOO_MANY_MESSAGES) when the quote carries more | ||
| * messages than the wallet's advertised `maxMessages` cap. | ||
| * @throws GaslessError(SEND_FAILED) when the relayer accepts the BoC but | ||
| * omits the broadcasted external message in its response. | ||
| */ | ||
| export const sendGaslessTransaction = async (appKit, parameters) => { | ||
| const { quote, providerId } = parameters; | ||
| const wallet = getSelectedWallet(appKit); | ||
| if (!wallet) { | ||
| throw new Error('Wallet not connected'); | ||
| } | ||
| // Fail fast on a dead quote before prompting the wallet to sign: the relayer | ||
| // owns `validUntil`, so a passed deadline means the relayer would reject the | ||
| // send anyway. Cheaper to surface a typed error here than to round-trip a | ||
| // signature the relayer discards. A non-finite `validUntil` (missing/garbled | ||
| // relayer response) is treated as expired rather than silently bypassing the | ||
| // check (`n > undefined` is always false). | ||
| if (!Number.isFinite(quote.validUntil) || Math.floor(Date.now() / 1000) > quote.validUntil) { | ||
| throw new GaslessError('Gasless quote has expired or is missing a validity window. Fetch a fresh quote before sending.', GaslessErrorCode.QuoteExpired, { validUntil: quote.validUntil }); | ||
| } | ||
| // Guard against the active wallet being switched between quote and send: the | ||
| // quote is bound to the `from` the relayer echoed, and signing with a | ||
| // different wallet would produce a BoC the relayer rejects. Skip when a | ||
| // provider does not echo `from` (treat absence as "no claim", not mismatch). | ||
| if (quote.from && !compareAddress(quote.from, wallet.getAddress())) { | ||
| throw new GaslessError('Gasless quote was issued for a different wallet than the selected one.', GaslessErrorCode.WalletMismatch, { quoteFrom: quote.from, wallet: wallet.getAddress() }); | ||
| } | ||
| // Gasless signs via `signMessage`, so the wallet must advertise the | ||
| // `SignMessage` feature, and the quote's message bundle must fit the wallet's | ||
| // `SignMessage` `maxMessages` cap. Checked before prompting so a wallet that | ||
| // can't satisfy the request fails with a typed error instead of an opaque | ||
| // bridge rejection. | ||
| const features = wallet.getSupportedFeatures() ?? []; | ||
| if (!hasSignMessageSupport(features)) { | ||
| throw new GaslessError('Connected wallet does not support the SignMessage feature required for gasless transactions.', GaslessErrorCode.SignMessageNotSupported); | ||
| } | ||
| const maxMessages = getMaxOutgoingMessages(features, 'SignMessage'); | ||
| if (quote.messages.length > maxMessages) { | ||
| throw new GaslessError(`Quote has ${quote.messages.length} messages but the wallet only supports up to ${maxMessages}.`, GaslessErrorCode.TooManyMessages, { messages: quote.messages.length, maxMessages }); | ||
| } | ||
| const { internalBoc } = await wallet.signMessage({ | ||
| messages: quote.messages, | ||
| validUntil: quote.validUntil, | ||
| }); | ||
| return appKit.gaslessManager.sendTransaction({ | ||
| network: quote.network, | ||
| walletPublicKey: wallet.getPublicKey(), | ||
| internalBoc, | ||
| }, providerId); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export {}; | ||
| //# sourceMappingURL=send-gasless-transaction.test.d.ts.map |
| {"version":3,"file":"send-gasless-transaction.test.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/send-gasless-transaction.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
| import { GaslessErrorCode } from '../../gasless'; | ||
| import { Network } from '../../types/network'; | ||
| import { sendGaslessTransaction } from './send-gasless-transaction'; | ||
| const TEST_ADDRESS = 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'; | ||
| const FAKE_INTERNAL_BOC = 'te6cckEBAQEAAgAAAA=='; | ||
| const makeQuote = (overrides = {}) => ({ | ||
| network: Network.mainnet(), | ||
| messages: [{ address: TEST_ADDRESS, amount: '60000000' }], | ||
| fee: '1234', | ||
| validUntil: Math.floor(Date.now() / 1000) + 60, | ||
| from: TEST_ADDRESS, | ||
| ...overrides, | ||
| }); | ||
| const SIGN_MESSAGE_FEATURE = { name: 'SignMessage', maxMessages: 4 }; | ||
| const makeWallet = (overrides = {}) => { | ||
| return { | ||
| connectorId: 'tonconnect', | ||
| getAddress: () => TEST_ADDRESS, | ||
| getPublicKey: () => '0xabc', | ||
| getNetwork: () => ({ chainId: '-239' }), | ||
| getWalletId: () => 'wallet-1', | ||
| getSupportedFeatures: () => [SIGN_MESSAGE_FEATURE], | ||
| sendTransaction: vi.fn(), | ||
| signData: vi.fn(), | ||
| signMessage: vi.fn().mockResolvedValue({ internalBoc: FAKE_INTERNAL_BOC }), | ||
| ...overrides, | ||
| }; | ||
| }; | ||
| const DEFAULT_SEND_RESULT = { | ||
| boc: 'external_boc_b64', | ||
| normalizedBoc: 'normalized_b64', | ||
| normalizedHash: '0xabcdef', | ||
| internalBoc: FAKE_INTERNAL_BOC, | ||
| }; | ||
| const makeAppKit = (wallet) => { | ||
| const sendTransaction = vi.fn().mockResolvedValue({ ...DEFAULT_SEND_RESULT }); | ||
| const appKit = { | ||
| walletsManager: { selectedWallet: wallet }, | ||
| gaslessManager: { sendTransaction }, | ||
| }; | ||
| return { appKit, sendTransaction }; | ||
| }; | ||
| describe('sendGaslessTransaction', () => { | ||
| let wallet; | ||
| beforeEach(() => { | ||
| wallet = makeWallet(); | ||
| }); | ||
| it('signs the quote and forwards SendTransactionResponse-shaped fields from the relayer', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const quote = makeQuote(); | ||
| const result = await sendGaslessTransaction(appKit, { quote }); | ||
| expect(wallet.signMessage).toHaveBeenCalledWith({ | ||
| messages: quote.messages, | ||
| validUntil: quote.validUntil, | ||
| }); | ||
| expect(sendTransaction).toHaveBeenCalledWith({ network: quote.network, walletPublicKey: '0xabc', internalBoc: FAKE_INTERNAL_BOC }, undefined); | ||
| expect(result.internalBoc).toBe(FAKE_INTERNAL_BOC); | ||
| expect(result.boc).toBe(DEFAULT_SEND_RESULT.boc); | ||
| expect(result.normalizedBoc).toBe(DEFAULT_SEND_RESULT.normalizedBoc); | ||
| expect(result.normalizedHash).toBe(DEFAULT_SEND_RESULT.normalizedHash); | ||
| }); | ||
| it('forwards providerId to gaslessManager.sendTransaction', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| await sendGaslessTransaction(appKit, { quote: makeQuote(), providerId: 'custom' }); | ||
| expect(sendTransaction).toHaveBeenCalledWith(expect.anything(), 'custom'); | ||
| }); | ||
| it('throws plain Error when no wallet is connected', async () => { | ||
| const { appKit } = makeAppKit(null); | ||
| await expect(sendGaslessTransaction(appKit, { quote: makeQuote() })).rejects.toThrow('Wallet not connected'); | ||
| }); | ||
| it('throws GaslessError(QUOTE_EXPIRED) before signing when the quote validUntil has passed', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const expiredQuote = makeQuote({ validUntil: Math.floor(Date.now() / 1000) - 1 }); | ||
| await expect(sendGaslessTransaction(appKit, { quote: expiredQuote })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.QuoteExpired, | ||
| }); | ||
| expect(wallet.signMessage).not.toHaveBeenCalled(); | ||
| expect(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(QUOTE_EXPIRED) when validUntil is missing/non-finite', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const quoteWithoutValidUntil = makeQuote({ validUntil: undefined }); | ||
| await expect(sendGaslessTransaction(appKit, { quote: quoteWithoutValidUntil })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.QuoteExpired, | ||
| }); | ||
| expect(wallet.signMessage).not.toHaveBeenCalled(); | ||
| expect(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(WALLET_MISMATCH) before signing when the quote was issued for another wallet', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const otherWalletQuote = makeQuote({ from: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c' }); | ||
| await expect(sendGaslessTransaction(appKit, { quote: otherWalletQuote })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.WalletMismatch, | ||
| }); | ||
| expect(wallet.signMessage).not.toHaveBeenCalled(); | ||
| expect(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when wallet lacks SignMessage feature', async () => { | ||
| const walletWithoutFeature = makeWallet({ | ||
| getSupportedFeatures: () => [{ name: 'SignData' }], | ||
| }); | ||
| const { appKit } = makeAppKit(walletWithoutFeature); | ||
| await expect(sendGaslessTransaction(appKit, { quote: makeQuote() })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.SignMessageNotSupported, | ||
| }); | ||
| expect(walletWithoutFeature.signMessage).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(TOO_MANY_MESSAGES) when quote exceeds wallet maxMessages', async () => { | ||
| const walletWithCap = makeWallet({ | ||
| getSupportedFeatures: () => [{ name: 'SignMessage', maxMessages: 1 }], | ||
| }); | ||
| const { appKit } = makeAppKit(walletWithCap); | ||
| const quote = makeQuote({ | ||
| messages: [ | ||
| { address: TEST_ADDRESS, amount: '1' }, | ||
| { address: TEST_ADDRESS, amount: '2' }, | ||
| ], | ||
| }); | ||
| await expect(sendGaslessTransaction(appKit, { quote })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.TooManyMessages, | ||
| }); | ||
| expect(walletWithCap.signMessage).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when wallet does not advertise any features', async () => { | ||
| // Treat undefined features the same as missing SignMessage — gasless | ||
| // requires SignMessage, so unknown capabilities fail closed instead of | ||
| // attempting to sign and surfacing an uglier bridge-level error. | ||
| const walletWithUnknown = makeWallet({ getSupportedFeatures: () => undefined }); | ||
| const { appKit, sendTransaction } = makeAppKit(walletWithUnknown); | ||
| await expect(sendGaslessTransaction(appKit, { quote: makeQuote() })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.SignMessageNotSupported, | ||
| }); | ||
| expect(walletWithUnknown.signMessage).not.toHaveBeenCalled(); | ||
| expect(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| it('propagates errors from gaslessManager.sendTransaction', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| sendTransaction.mockRejectedValueOnce(new Error('relayer offline')); | ||
| await expect(sendGaslessTransaction(appKit, { quote: makeQuote() })).rejects.toThrow('relayer offline'); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface SetDefaultGaslessProviderParameters { | ||
| providerId: string; | ||
| } | ||
| export type SetDefaultGaslessProviderReturnType = void; | ||
| /** | ||
| * Set the default gasless provider. | ||
| * Subsequent estimate and send calls will use this provider when none is specified. | ||
| */ | ||
| export declare const setDefaultGaslessProvider: (appKit: AppKit, parameters: SetDefaultGaslessProviderParameters) => SetDefaultGaslessProviderReturnType; | ||
| //# sourceMappingURL=set-default-gasless-provider.d.ts.map |
| {"version":3,"file":"set-default-gasless-provider.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/set-default-gasless-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,mCAAmC;IAChD,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,mCAAmC,GAAG,IAAI,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,GAClC,QAAQ,MAAM,EACd,YAAY,mCAAmC,KAChD,mCAEF,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| /** | ||
| * Set the default gasless provider. | ||
| * Subsequent estimate and send calls will use this provider when none is specified. | ||
| */ | ||
| export const setDefaultGaslessProvider = (appKit, parameters) => { | ||
| appKit.gaslessManager.setDefaultProvider(parameters.providerId); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface WatchGaslessProvidersParameters { | ||
| onChange: () => void; | ||
| } | ||
| export type WatchGaslessProvidersReturnType = () => void; | ||
| /** | ||
| * Watch for new gasless providers registration and default-provider changes. | ||
| */ | ||
| export declare const watchGaslessProviders: (appKit: AppKit, parameters: WatchGaslessProvidersParameters) => WatchGaslessProvidersReturnType; | ||
| //# sourceMappingURL=watch-gasless-providers.d.ts.map |
| {"version":3,"file":"watch-gasless-providers.d.ts","sourceRoot":"","sources":["../../../../src/actions/gasless/watch-gasless-providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,+BAA+B;IAC5C,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,+BAA+B,GAAG,MAAM,IAAI,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAC9B,QAAQ,MAAM,EACd,YAAY,+BAA+B,KAC5C,+BAeF,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| /** | ||
| * Watch for new gasless providers registration and default-provider changes. | ||
| */ | ||
| export const watchGaslessProviders = (appKit, parameters) => { | ||
| const { onChange } = parameters; | ||
| const unsubscribeRegistered = appKit.emitter.on('provider:registered', (event) => { | ||
| if (event.payload.type === 'gasless') | ||
| onChange(); | ||
| }); | ||
| const unsubscribeDefaultChanged = appKit.emitter.on('provider:default-changed', (event) => { | ||
| if (event.payload.type === 'gasless') | ||
| onChange(); | ||
| }); | ||
| return () => { | ||
| unsubscribeRegistered(); | ||
| unsubscribeDefaultChanged(); | ||
| }; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { TransactionRequest } from '../../types/transaction'; | ||
| import type { SignMessageResponse } from '../../types/signing'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type SignMessageParameters = TransactionRequest; | ||
| export type SignMessageReturnType = SignMessageResponse; | ||
| export type SignMessageErrorType = Error; | ||
| /** | ||
| * Ask the connected wallet to sign a transaction-shaped request without broadcasting it. | ||
| * | ||
| * Returns a signed internal-message BoC that can be relayed on-chain by a third party | ||
| * (e.g. a gasless relayer). Unlike sendTransaction, the message is NOT submitted to the | ||
| * network by the wallet. | ||
| * | ||
| * Throws when the connected wallet does not advertise the `SignMessage` feature, or when | ||
| * the request carries more messages than the wallet's `SignMessage` `maxMessages` cap — | ||
| * surfacing a clear error before prompting instead of an opaque bridge rejection. | ||
| */ | ||
| export declare const signMessage: (appKit: AppKit, parameters: SignMessageParameters) => Promise<SignMessageReturnType>; | ||
| //# sourceMappingURL=sign-message.d.ts.map |
| {"version":3,"file":"sign-message.d.ts","sourceRoot":"","sources":["../../../../src/actions/transaction/sign-message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEvD,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW,GACpB,QAAQ,MAAM,EACd,YAAY,qBAAqB,KAClC,OAAO,CAAC,qBAAqB,CAqB/B,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getMaxOutgoingMessages, hasSignMessageSupport } from '../../utils'; | ||
| import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
| /** | ||
| * Ask the connected wallet to sign a transaction-shaped request without broadcasting it. | ||
| * | ||
| * Returns a signed internal-message BoC that can be relayed on-chain by a third party | ||
| * (e.g. a gasless relayer). Unlike sendTransaction, the message is NOT submitted to the | ||
| * network by the wallet. | ||
| * | ||
| * Throws when the connected wallet does not advertise the `SignMessage` feature, or when | ||
| * the request carries more messages than the wallet's `SignMessage` `maxMessages` cap — | ||
| * surfacing a clear error before prompting instead of an opaque bridge rejection. | ||
| */ | ||
| export const signMessage = async (appKit, parameters) => { | ||
| const wallet = getSelectedWallet(appKit); | ||
| if (!wallet) { | ||
| throw new Error('Wallet not connected'); | ||
| } | ||
| const features = wallet.getSupportedFeatures() ?? []; | ||
| if (!hasSignMessageSupport(features)) { | ||
| throw new Error('Connected wallet does not support the SignMessage feature.'); | ||
| } | ||
| const maxMessages = getMaxOutgoingMessages(features, 'SignMessage'); | ||
| if (parameters.messages.length > maxMessages) { | ||
| throw new Error(`SignMessage request has ${parameters.messages.length} messages but the wallet supports up to ${maxMessages}.`); | ||
| } | ||
| return wallet.signMessage(parameters); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type GetSignMessageSupportReturnType = boolean; | ||
| /** | ||
| * Whether the currently selected wallet advertises the `SignMessage` feature | ||
| * (required for gasless transactions). | ||
| * | ||
| * Fail-closed: returns `false` when no wallet is selected or the wallet | ||
| * advertises no features. This mirrors the gasless send path, which rejects a | ||
| * `SignMessage` request from a wallet that doesn't list the feature — so the UI | ||
| * should not offer gasless when the send would refuse it. | ||
| */ | ||
| export declare const getSignMessageSupport: (appKit: AppKit) => GetSignMessageSupportReturnType; | ||
| //# sourceMappingURL=get-sign-message-support.d.ts.map |
| {"version":3,"file":"get-sign-message-support.d.ts","sourceRoot":"","sources":["../../../../src/actions/wallets/get-sign-message-support.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,MAAM,+BAA+B,GAAG,OAAO,CAAC;AAEtD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,KAAG,+BAGtD,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { hasSignMessageSupport } from '../../utils'; | ||
| import { getSelectedWallet } from './get-selected-wallet'; | ||
| /** | ||
| * Whether the currently selected wallet advertises the `SignMessage` feature | ||
| * (required for gasless transactions). | ||
| * | ||
| * Fail-closed: returns `false` when no wallet is selected or the wallet | ||
| * advertises no features. This mirrors the gasless send path, which rejects a | ||
| * `SignMessage` request from a wallet that doesn't list the feature — so the UI | ||
| * should not offer gasless when the send would refuse it. | ||
| */ | ||
| export const getSignMessageSupport = (appKit) => { | ||
| const features = getSelectedWallet(appKit)?.getSupportedFeatures(); | ||
| return features ? hasSignMessageSupport(features) : false; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface WatchSignMessageSupportParameters { | ||
| onChange: (supported: boolean) => void; | ||
| } | ||
| export type WatchSignMessageSupportReturnType = () => void; | ||
| /** | ||
| * Watch whether the selected wallet supports `SignMessage`. Re-evaluated on | ||
| * every wallet selection change (features are static per wallet, so the | ||
| * selection change is the only thing that can flip the result). | ||
| */ | ||
| export declare const watchSignMessageSupport: (appKit: AppKit, parameters: WatchSignMessageSupportParameters) => WatchSignMessageSupportReturnType; | ||
| //# sourceMappingURL=watch-sign-message-support.d.ts.map |
| {"version":3,"file":"watch-sign-message-support.d.ts","sourceRoot":"","sources":["../../../../src/actions/wallets/watch-sign-message-support.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAIjD,MAAM,WAAW,iCAAiC;IAC9C,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,MAAM,iCAAiC,GAAG,MAAM,IAAI,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAChC,QAAQ,MAAM,EACd,YAAY,iCAAiC,KAC9C,iCAQF,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { WALLETS_EVENTS } from '../../core/app-kit'; | ||
| import { getSignMessageSupport } from './get-sign-message-support'; | ||
| /** | ||
| * Watch whether the selected wallet supports `SignMessage`. Re-evaluated on | ||
| * every wallet selection change (features are static per wallet, so the | ||
| * selection change is the only thing that can flip the result). | ||
| */ | ||
| export const watchSignMessageSupport = (appKit, parameters) => { | ||
| const { onChange } = parameters; | ||
| const unsubscribe = appKit.emitter.on(WALLETS_EVENTS.SELECTION_CHANGED, () => { | ||
| onChange(getSignMessageSupport(appKit)); | ||
| }); | ||
| return unsubscribe; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export { GaslessProvider, GaslessError, GaslessErrorCode, GaslessManager } from '@ton/walletkit'; | ||
| export type { GaslessAPI, GaslessProviderInterface, GaslessConfig, GaslessSupportedAsset, GaslessProviderMetadata, GaslessProviderMetadataOverride, GaslessQuoteParams, GaslessQuote, GaslessSendParams, GaslessSendResponse, } from '@ton/walletkit'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/gasless/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjG,YAAY,EACR,UAAU,EACV,wBAAwB,EACxB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACvB,+BAA+B,EAC/B,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,GACtB,MAAM,gBAAgB,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export { GaslessProvider, GaslessError, GaslessErrorCode, GaslessManager } from '@ton/walletkit'; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export * from '@ton/walletkit/gasless/tonapi'; | ||
| //# sourceMappingURL=index.d.ts.map |
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/gasless/tonapi/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,+BAA+B,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export * from '@ton/walletkit/gasless/tonapi'; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GetGaslessConfigErrorType, GetGaslessConfigOptions, GetGaslessConfigReturnType } from '../../actions/gasless/get-gasless-config'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| export type { GetGaslessConfigErrorType }; | ||
| export type GetGaslessConfigQueryConfig<selectData = GetGaslessConfigData> = Compute<ExactPartial<GetGaslessConfigOptions>> & QueryParameter<GetGaslessConfigQueryFnData, GetGaslessConfigErrorType, selectData, GetGaslessConfigQueryKey>; | ||
| export declare const getGaslessConfigQueryOptions: <selectData = GetGaslessConfigData>(appKit: AppKit, options?: GetGaslessConfigQueryConfig<selectData>) => GetGaslessConfigQueryOptions<selectData>; | ||
| export type GetGaslessConfigQueryFnData = Compute<Awaited<GetGaslessConfigReturnType>>; | ||
| export type GetGaslessConfigData = GetGaslessConfigQueryFnData; | ||
| export declare const getGaslessConfigQueryKey: (options?: Compute<ExactPartial<GetGaslessConfigOptions>>) => GetGaslessConfigQueryKey; | ||
| export type GetGaslessConfigQueryKey = readonly ['gaslessConfig', Compute<ExactPartial<GetGaslessConfigOptions>>]; | ||
| export type GetGaslessConfigQueryOptions<selectData = GetGaslessConfigData> = QueryOptions<GetGaslessConfigQueryFnData, GetGaslessConfigErrorType, selectData, GetGaslessConfigQueryKey>; | ||
| //# sourceMappingURL=get-gasless-config.d.ts.map |
| {"version":3,"file":"get-gasless-config.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/get-gasless-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACR,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC7B,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG/D,YAAY,EAAE,yBAAyB,EAAE,CAAC;AAE1C,MAAM,MAAM,2BAA2B,CAAC,UAAU,GAAG,oBAAoB,IAAI,OAAO,CAChF,YAAY,CAAC,uBAAuB,CAAC,CACxC,GACG,cAAc,CAAC,2BAA2B,EAAE,yBAAyB,EAAE,UAAU,EAAE,wBAAwB,CAAC,CAAC;AAEjH,eAAO,MAAM,4BAA4B,GAAI,UAAU,GAAG,oBAAoB,EAC1E,QAAQ,MAAM,EACd,UAAS,2BAA2B,CAAC,UAAU,CAAM,KACtD,4BAA4B,CAAC,UAAU,CAWzC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC;AAEvF,MAAM,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AAE/D,eAAO,MAAM,wBAAwB,GACjC,UAAS,OAAO,CAAC,YAAY,CAAC,uBAAuB,CAAC,CAAM,KAC7D,wBAEF,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,SAAS,CAAC,eAAe,EAAE,OAAO,CAAC,YAAY,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAElH,MAAM,MAAM,4BAA4B,CAAC,UAAU,GAAG,oBAAoB,IAAI,YAAY,CACtF,2BAA2B,EAC3B,yBAAyB,EACzB,UAAU,EACV,wBAAwB,CAC3B,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getGaslessConfig } from '../../actions/gasless/get-gasless-config'; | ||
| import { filterQueryOptions, resolveNetwork } from '../../utils'; | ||
| export const getGaslessConfigQueryOptions = (appKit, options = {}) => { | ||
| const resolvedOptions = { ...options, network: resolveNetwork(appKit, options.network) }; | ||
| return { | ||
| ...options.query, | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey; | ||
| return getGaslessConfig(appKit, parameters); | ||
| }, | ||
| queryKey: getGaslessConfigQueryKey(resolvedOptions), | ||
| }; | ||
| }; | ||
| export const getGaslessConfigQueryKey = (options = {}) => { | ||
| return ['gaslessConfig', filterQueryOptions(options)]; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GetGaslessJettonTransferQuoteErrorType, GetGaslessJettonTransferQuoteOptions, GetGaslessJettonTransferQuoteReturnType } from '../../actions/gasless/get-gasless-jetton-transfer-quote'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { Network } from '../../types/network'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| export type { GetGaslessJettonTransferQuoteErrorType }; | ||
| export type GetGaslessJettonTransferQuoteQueryConfig<selectData = GetGaslessJettonTransferQuoteData> = Compute<ExactPartial<GetGaslessJettonTransferQuoteOptions>> & QueryParameter<GetGaslessJettonTransferQuoteQueryFnData, GetGaslessJettonTransferQuoteErrorType, selectData, GetGaslessJettonTransferQuoteQueryKey>; | ||
| export declare const getGaslessJettonTransferQuoteQueryOptions: <selectData = GetGaslessJettonTransferQuoteData>(appKit: AppKit, options?: GetGaslessJettonTransferQuoteQueryConfig<selectData>, network?: Network) => GetGaslessJettonTransferQuoteQueryOptions<selectData>; | ||
| export type GetGaslessJettonTransferQuoteQueryFnData = Compute<Awaited<GetGaslessJettonTransferQuoteReturnType>>; | ||
| export type GetGaslessJettonTransferQuoteData = GetGaslessJettonTransferQuoteQueryFnData; | ||
| export declare const getGaslessJettonTransferQuoteQueryKey: (options?: Compute<ExactPartial<GetGaslessJettonTransferQuoteOptions>>, walletAddress?: string, networkChainId?: string) => GetGaslessJettonTransferQuoteQueryKey; | ||
| export type GetGaslessJettonTransferQuoteQueryKey = readonly [ | ||
| 'gaslessJettonTransferQuote', | ||
| Compute<ExactPartial<GetGaslessJettonTransferQuoteOptions>>, | ||
| string | undefined, | ||
| string | undefined | ||
| ]; | ||
| export type GetGaslessJettonTransferQuoteQueryOptions<selectData = GetGaslessJettonTransferQuoteData> = QueryOptions<GetGaslessJettonTransferQuoteQueryFnData, GetGaslessJettonTransferQuoteErrorType, selectData, GetGaslessJettonTransferQuoteQueryKey>; | ||
| //# sourceMappingURL=get-gasless-jetton-transfer-quote.d.ts.map |
| {"version":3,"file":"get-gasless-jetton-transfer-quote.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/get-gasless-jetton-transfer-quote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACR,sCAAsC,EACtC,oCAAoC,EACpC,uCAAuC,EAC1C,MAAM,yDAAyD,CAAC;AAEjE,OAAO,KAAK,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| ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getGaslessJettonTransferQuote } from '../../actions/gasless/get-gasless-jetton-transfer-quote'; | ||
| import { getSelectedWallet } from '../../actions/wallets/get-selected-wallet'; | ||
| import { filterQueryOptions, resolveNetwork } from '../../utils'; | ||
| import { GASLESS_QUOTE_STALE_TIME_MS } from './get-gasless-quote'; | ||
| export const getGaslessJettonTransferQuoteQueryOptions = (appKit, options = {}, network) => { | ||
| // Bind the quote to the selected wallet's address and network so a | ||
| // wallet/network switch produces a distinct cache entry and refetch | ||
| // (mirrors `getGaslessQuoteQueryOptions`). The quote is always built on the | ||
| // selected wallet's network — the action resolves it internally, there is no | ||
| // caller override — so `network` here is a key dimension only, never forwarded | ||
| // to the action. | ||
| const wallet = getSelectedWallet(appKit); | ||
| const walletAddress = wallet?.getAddress(); | ||
| const networkChainId = resolveNetwork(appKit, network).chainId; | ||
| return { | ||
| staleTime: GASLESS_QUOTE_STALE_TIME_MS, | ||
| ...options.query, | ||
| // Gate on a connected wallet too: the action resolves the jetton wallet | ||
| // via the selected wallet and throws without one, so without this the | ||
| // query would fire into a `Wallet not connected` error instead of idling. | ||
| enabled: Boolean(options.jettonAddress && | ||
| options.recipientAddress && | ||
| options.amount && | ||
| walletAddress && | ||
| (options.query?.enabled ?? true)), | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey; | ||
| return getGaslessJettonTransferQuote(appKit, parameters); | ||
| }, | ||
| queryKey: getGaslessJettonTransferQuoteQueryKey(options, walletAddress, networkChainId), | ||
| }; | ||
| }; | ||
| export const getGaslessJettonTransferQuoteQueryKey = (options = {}, walletAddress, networkChainId) => { | ||
| return [ | ||
| 'gaslessJettonTransferQuote', | ||
| filterQueryOptions(options), | ||
| walletAddress, | ||
| networkChainId, | ||
| ]; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GetGaslessProviderMetadataErrorType, GetGaslessProviderMetadataOptions, GetGaslessProviderMetadataReturnType } from '../../actions/gasless/get-gasless-provider-metadata'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| export type { GetGaslessProviderMetadataErrorType }; | ||
| export type GetGaslessProviderMetadataQueryConfig<selectData = GetGaslessProviderMetadataData> = Compute<ExactPartial<GetGaslessProviderMetadataOptions>> & QueryParameter<GetGaslessProviderMetadataQueryFnData, GetGaslessProviderMetadataErrorType, selectData, GetGaslessProviderMetadataQueryKey>; | ||
| export declare const getGaslessProviderMetadataQueryOptions: <selectData = GetGaslessProviderMetadataData>(appKit: AppKit, options?: GetGaslessProviderMetadataQueryConfig<selectData>) => GetGaslessProviderMetadataQueryOptions<selectData>; | ||
| export type GetGaslessProviderMetadataQueryFnData = Compute<Awaited<GetGaslessProviderMetadataReturnType>>; | ||
| export type GetGaslessProviderMetadataData = GetGaslessProviderMetadataQueryFnData; | ||
| export declare const getGaslessProviderMetadataQueryKey: (options?: Compute<ExactPartial<GetGaslessProviderMetadataOptions>>) => GetGaslessProviderMetadataQueryKey; | ||
| export type GetGaslessProviderMetadataQueryKey = readonly [ | ||
| 'gaslessProviderMetadata', | ||
| Compute<ExactPartial<GetGaslessProviderMetadataOptions>> | ||
| ]; | ||
| export type GetGaslessProviderMetadataQueryOptions<selectData = GetGaslessProviderMetadataData> = QueryOptions<GetGaslessProviderMetadataQueryFnData, GetGaslessProviderMetadataErrorType, selectData, GetGaslessProviderMetadataQueryKey>; | ||
| //# sourceMappingURL=get-gasless-provider-metadata.d.ts.map |
| {"version":3,"file":"get-gasless-provider-metadata.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/get-gasless-provider-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACR,mCAAmC,EACnC,iCAAiC,EACjC,oCAAoC,EACvC,MAAM,qDAAqD,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG/D,YAAY,EAAE,mCAAmC,EAAE,CAAC;AAEpD,MAAM,MAAM,qCAAqC,CAAC,UAAU,GAAG,8BAA8B,IAAI,OAAO,CACpG,YAAY,CAAC,iCAAiC,CAAC,CAClD,GACG,cAAc,CACV,qCAAqC,EACrC,mCAAmC,EACnC,UAAU,EACV,kCAAkC,CACrC,CAAC;AAEN,eAAO,MAAM,sCAAsC,GAAI,UAAU,GAAG,8BAA8B,EAC9F,QAAQ,MAAM,EACd,UAAS,qCAAqC,CAAC,UAAU,CAAM,KAChE,sCAAsC,CAAC,UAAU,CASnD,CAAC;AAEF,MAAM,MAAM,qCAAqC,GAAG,OAAO,CAAC,OAAO,CAAC,oCAAoC,CAAC,CAAC,CAAC;AAE3G,MAAM,MAAM,8BAA8B,GAAG,qCAAqC,CAAC;AAEnF,eAAO,MAAM,kCAAkC,GAC3C,UAAS,OAAO,CAAC,YAAY,CAAC,iCAAiC,CAAC,CAAM,KACvE,kCAEF,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG,SAAS;IACtD,yBAAyB;IACzB,OAAO,CAAC,YAAY,CAAC,iCAAiC,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,sCAAsC,CAAC,UAAU,GAAG,8BAA8B,IAAI,YAAY,CAC1G,qCAAqC,EACrC,mCAAmC,EACnC,UAAU,EACV,kCAAkC,CACrC,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getGaslessProviderMetadata } from '../../actions/gasless/get-gasless-provider-metadata'; | ||
| import { filterQueryOptions } from '../../utils'; | ||
| export const getGaslessProviderMetadataQueryOptions = (appKit, options = {}) => { | ||
| return { | ||
| ...options.query, | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey; | ||
| return getGaslessProviderMetadata(appKit, parameters); | ||
| }, | ||
| queryKey: getGaslessProviderMetadataQueryKey(options), | ||
| }; | ||
| }; | ||
| export const getGaslessProviderMetadataQueryKey = (options = {}) => { | ||
| return ['gaslessProviderMetadata', filterQueryOptions(options)]; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GetGaslessQuoteErrorType, GetGaslessQuoteOptions, GetGaslessQuoteReturnType } from '../../actions/gasless/get-gasless-quote'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| export type { GetGaslessQuoteErrorType }; | ||
| /** | ||
| * Default time-to-live for a gasless quote. The relayer returns its own | ||
| * `validUntil`; this is the upper bound used by react-query to refresh the | ||
| * quote before it expires. | ||
| */ | ||
| export declare const GASLESS_QUOTE_STALE_TIME_MS: number; | ||
| export type GetGaslessQuoteQueryConfig<selectData = GetGaslessQuoteData> = Compute<ExactPartial<GetGaslessQuoteOptions>> & QueryParameter<GetGaslessQuoteQueryFnData, GetGaslessQuoteErrorType, selectData, GetGaslessQuoteQueryKey>; | ||
| export declare const getGaslessQuoteQueryOptions: <selectData = GetGaslessQuoteData>(appKit: AppKit, options?: GetGaslessQuoteQueryConfig<selectData>) => GetGaslessQuoteQueryOptions<selectData>; | ||
| export type GetGaslessQuoteQueryFnData = Compute<Awaited<GetGaslessQuoteReturnType>>; | ||
| export type GetGaslessQuoteData = GetGaslessQuoteQueryFnData; | ||
| export declare const getGaslessQuoteQueryKey: (options?: Compute<ExactPartial<GetGaslessQuoteOptions>>, walletAddress?: string) => GetGaslessQuoteQueryKey; | ||
| export type GetGaslessQuoteQueryKey = readonly [ | ||
| 'gaslessQuote', | ||
| Compute<ExactPartial<GetGaslessQuoteOptions>>, | ||
| string | undefined | ||
| ]; | ||
| export type GetGaslessQuoteQueryOptions<selectData = GetGaslessQuoteData> = QueryOptions<GetGaslessQuoteQueryFnData, GetGaslessQuoteErrorType, selectData, GetGaslessQuoteQueryKey>; | ||
| //# sourceMappingURL=get-gasless-quote.d.ts.map |
| {"version":3,"file":"get-gasless-quote.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/get-gasless-quote.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EACR,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EAC5B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAG/D,YAAY,EAAE,wBAAwB,EAAE,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,QAAgB,CAAC;AAEzD,MAAM,MAAM,0BAA0B,CAAC,UAAU,GAAG,mBAAmB,IAAI,OAAO,CAC9E,YAAY,CAAC,sBAAsB,CAAC,CACvC,GACG,cAAc,CAAC,0BAA0B,EAAE,wBAAwB,EAAE,UAAU,EAAE,uBAAuB,CAAC,CAAC;AAE9G,eAAO,MAAM,2BAA2B,GAAI,UAAU,GAAG,mBAAmB,EACxE,QAAQ,MAAM,EACd,UAAS,0BAA0B,CAAC,UAAU,CAAM,KACrD,2BAA2B,CAAC,UAAU,CAgCxC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAErF,MAAM,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAE7D,eAAO,MAAM,uBAAuB,GAChC,UAAS,OAAO,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAM,EAC3D,gBAAgB,MAAM,KACvB,uBAEF,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,SAAS;IAC3C,cAAc;IACd,OAAO,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC;IAC7C,MAAM,GAAG,SAAS;CACrB,CAAC;AAEF,MAAM,MAAM,2BAA2B,CAAC,UAAU,GAAG,mBAAmB,IAAI,YAAY,CACpF,0BAA0B,EAC1B,wBAAwB,EACxB,UAAU,EACV,uBAAuB,CAC1B,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getGaslessQuote } from '../../actions/gasless/get-gasless-quote'; | ||
| import { getSelectedWallet } from '../../actions/wallets/get-selected-wallet'; | ||
| import { filterQueryOptions } from '../../utils'; | ||
| /** | ||
| * Default time-to-live for a gasless quote. The relayer returns its own | ||
| * `validUntil`; this is the upper bound used by react-query to refresh the | ||
| * quote before it expires. | ||
| */ | ||
| export const GASLESS_QUOTE_STALE_TIME_MS = 2 * 60 * 1000; | ||
| export const getGaslessQuoteQueryOptions = (appKit, options = {}) => { | ||
| // The quote is bound to the selected wallet's address and network, both of | ||
| // which `getGaslessQuote` resolves internally. Fold them into the key so a | ||
| // wallet/network switch produces a distinct cache entry and refetch instead | ||
| // of silently serving a quote issued for a different wallet. | ||
| const wallet = getSelectedWallet(appKit); | ||
| const walletAddress = wallet?.getAddress(); | ||
| const resolvedOptions = { ...options, network: options.network ?? wallet?.getNetwork() }; | ||
| return { | ||
| staleTime: GASLESS_QUOTE_STALE_TIME_MS, | ||
| ...options.query, | ||
| // `feeAsset` is intentionally not part of the gate: free / sponsored | ||
| // providers accept an undefined asset, and jetton-only providers throw | ||
| // a typed error themselves. We require messages and a connected wallet — | ||
| // the action resolves the wallet internally and throws without one, so | ||
| // gating here keeps the query idle instead of erroring (matches the | ||
| // jetton/ton transfer-quote options). | ||
| enabled: Boolean(options.messages && options.messages.length > 0 && walletAddress && (options.query?.enabled ?? true)), | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey; | ||
| if (!parameters.messages || parameters.messages.length === 0) { | ||
| throw new Error('messages is required'); | ||
| } | ||
| return getGaslessQuote(appKit, parameters); | ||
| }, | ||
| queryKey: getGaslessQuoteQueryKey(resolvedOptions, walletAddress), | ||
| }; | ||
| }; | ||
| export const getGaslessQuoteQueryKey = (options = {}, walletAddress) => { | ||
| return ['gaslessQuote', filterQueryOptions(options), walletAddress]; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { MutateOptions, MutationOptions } from '@tanstack/query-core'; | ||
| import type { SendGaslessTransactionErrorType, SendGaslessTransactionParameters, SendGaslessTransactionReturnType } from '../../actions/gasless/send-gasless-transaction'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { MutationParameter } from '../../types/query'; | ||
| import type { Compute } from '../../types/utils'; | ||
| export type { SendGaslessTransactionErrorType }; | ||
| export type SendGaslessTransactionMutationConfig<context = unknown> = MutationParameter<SendGaslessTransactionData, SendGaslessTransactionErrorType, SendGaslessTransactionVariables, context>; | ||
| export declare const sendGaslessTransactionMutationOptions: <context = unknown>(appKit: AppKit, config?: SendGaslessTransactionMutationConfig<context>) => SendGaslessTransactionMutationOptions<context>; | ||
| export type SendGaslessTransactionVariables = Compute<SendGaslessTransactionParameters>; | ||
| export type SendGaslessTransactionData = Compute<Awaited<SendGaslessTransactionReturnType>>; | ||
| export type SendGaslessTransactionMutate<context = unknown> = (variables: SendGaslessTransactionVariables, options?: Compute<MutateOptions<SendGaslessTransactionData, SendGaslessTransactionErrorType, SendGaslessTransactionVariables, context>> | undefined) => void; | ||
| export type SendGaslessTransactionMutateAsync<context = unknown> = (variables: SendGaslessTransactionVariables, options?: Compute<MutateOptions<SendGaslessTransactionData, SendGaslessTransactionErrorType, SendGaslessTransactionVariables, context>> | undefined) => Promise<SendGaslessTransactionData>; | ||
| export type SendGaslessTransactionMutationOptions<context = unknown> = MutationOptions<SendGaslessTransactionData, SendGaslessTransactionErrorType, SendGaslessTransactionVariables, context>; | ||
| //# sourceMappingURL=send-gasless-transaction.d.ts.map |
| {"version":3,"file":"send-gasless-transaction.d.ts","sourceRoot":"","sources":["../../../../src/queries/gasless/send-gasless-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG3E,OAAO,KAAK,EACR,+BAA+B,EAC/B,gCAAgC,EAChC,gCAAgC,EACnC,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,YAAY,EAAE,+BAA+B,EAAE,CAAC;AAEhD,MAAM,MAAM,oCAAoC,CAAC,OAAO,GAAG,OAAO,IAAI,iBAAiB,CACnF,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,OAAO,CACV,CAAC;AAEF,eAAO,MAAM,qCAAqC,GAAI,OAAO,GAAG,OAAO,EACnE,QAAQ,MAAM,EACd,SAAQ,oCAAoC,CAAC,OAAO,CAAM,KAC3D,qCAAqC,CAAC,OAAO,CAQ/C,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC;AAExF,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAC,CAAC;AAE5F,MAAM,MAAM,4BAA4B,CAAC,OAAO,GAAG,OAAO,IAAI,CAC1D,SAAS,EAAE,+BAA+B,EAC1C,OAAO,CAAC,EACF,OAAO,CACH,aAAa,CACT,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,OAAO,CACV,CACJ,GACD,SAAS,KACd,IAAI,CAAC;AAEV,MAAM,MAAM,iCAAiC,CAAC,OAAO,GAAG,OAAO,IAAI,CAC/D,SAAS,EAAE,+BAA+B,EAC1C,OAAO,CAAC,EACF,OAAO,CACH,aAAa,CACT,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,OAAO,CACV,CACJ,GACD,SAAS,KACd,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAEzC,MAAM,MAAM,qCAAqC,CAAC,OAAO,GAAG,OAAO,IAAI,eAAe,CAClF,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,OAAO,CACV,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { sendGaslessTransaction } from '../../actions/gasless/send-gasless-transaction'; | ||
| export const sendGaslessTransactionMutationOptions = (appKit, config = {}) => { | ||
| return { | ||
| ...config.mutation, | ||
| mutationFn(variables) { | ||
| return sendGaslessTransaction(appKit, variables); | ||
| }, | ||
| mutationKey: ['sendGaslessTransaction'], | ||
| }; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { MutateOptions, MutationOptions } from '@tanstack/query-core'; | ||
| import type { SignMessageErrorType, SignMessageParameters, SignMessageReturnType } from '../../actions/transaction/sign-message'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { MutationParameter } from '../../types/query'; | ||
| import type { Compute } from '../../types/utils'; | ||
| export type { SignMessageErrorType, SignMessageParameters, SignMessageReturnType }; | ||
| export type SignMessageOptions<context = unknown> = MutationParameter<SignMessageData, SignMessageErrorType, SignMessageVariables, context>; | ||
| export declare const signMessageMutationOptions: <context = unknown>(appKit: AppKit, options?: SignMessageOptions<context>) => SignMessageMutationOptions<context>; | ||
| export type SignMessageMutationOptions<context = unknown> = MutationOptions<SignMessageData, SignMessageErrorType, SignMessageVariables, context>; | ||
| export type SignMessageData = Compute<SignMessageReturnType>; | ||
| export type SignMessageVariables = SignMessageParameters; | ||
| export type SignMessageMutate<context = unknown> = (variables: SignMessageVariables, options?: Compute<MutateOptions<SignMessageData, SignMessageErrorType, Compute<SignMessageVariables>, context>> | undefined) => void; | ||
| export type SignMessageMutateAsync<context = unknown> = (variables: SignMessageVariables, options?: Compute<MutateOptions<SignMessageData, SignMessageErrorType, Compute<SignMessageVariables>, context>> | undefined) => Promise<SignMessageData>; | ||
| //# sourceMappingURL=sign-message.d.ts.map |
| {"version":3,"file":"sign-message.d.ts","sourceRoot":"","sources":["../../../../src/queries/transaction/sign-message.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG3E,OAAO,KAAK,EACR,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACxB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,CAAC;AAEnF,MAAM,MAAM,kBAAkB,CAAC,OAAO,GAAG,OAAO,IAAI,iBAAiB,CACjE,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,CACV,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,GAAG,OAAO,EACxD,QAAQ,MAAM,EACd,UAAS,kBAAkB,CAAC,OAAO,CAAM,KAC1C,0BAA0B,CAAC,OAAO,CAQpC,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,OAAO,GAAG,OAAO,IAAI,eAAe,CACvE,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,CACV,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAEzD,MAAM,MAAM,iBAAiB,CAAC,OAAO,GAAG,OAAO,IAAI,CAC/C,SAAS,EAAE,oBAAoB,EAC/B,OAAO,CAAC,EACF,OAAO,CAAC,aAAa,CAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,CAAC,GACrG,SAAS,KACd,IAAI,CAAC;AAEV,MAAM,MAAM,sBAAsB,CAAC,OAAO,GAAG,OAAO,IAAI,CACpD,SAAS,EAAE,oBAAoB,EAC/B,OAAO,CAAC,EACF,OAAO,CAAC,aAAa,CAAC,eAAe,EAAE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,CAAC,GACrG,SAAS,KACd,OAAO,CAAC,eAAe,CAAC,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { signMessage } from '../../actions/transaction/sign-message'; | ||
| export const signMessageMutationOptions = (appKit, options = {}) => { | ||
| return { | ||
| ...options.mutation, | ||
| mutationFn(variables) { | ||
| return signMessage(appKit, variables); | ||
| }, | ||
| mutationKey: ['signMessage'], | ||
| }; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export interface CheckTonBalanceParams { | ||
| /** Outgoing messages of the built transaction — each `amount` is the TON value in nanos. */ | ||
| messages: Array<{ | ||
| amount: string; | ||
| }>; | ||
| /** | ||
| * User's TON balance as a decimal string (`formatUnits(balance, 9)` format). | ||
| * `undefined` means "not loaded yet" — function returns `undefined` (no judgement). | ||
| */ | ||
| tonBalance: string | undefined; | ||
| /** Extra TON headroom on top of total outflow. Caller-supplied — no opinion on default. */ | ||
| gasBufferNanos: bigint; | ||
| } | ||
| export interface TonBalanceShortfall { | ||
| /** Total TON the user wallet must hold for the transaction to land. */ | ||
| requiredNanos: bigint; | ||
| } | ||
| /** | ||
| * Pure balance check: does the user have enough TON for the built transaction? | ||
| * | ||
| * Returns `undefined` when the balance is sufficient OR when it hasn't loaded | ||
| * yet (treating unloaded as "unknown" rather than "zero" avoids false-positive | ||
| * shortfalls flashing on first render). | ||
| * | ||
| * No mode classification — this hook reports only "shortfall exists, here's | ||
| * how much was needed." Callers decide what to suggest (topup, gasless, | ||
| * reduce, etc.). For transfer/swap flows where the user can reduce their own | ||
| * outflow, compose this with `checkTransferBalance`. | ||
| */ | ||
| export declare const checkTonBalance: ({ messages, tonBalance, gasBufferNanos, }: CheckTonBalanceParams) => TonBalanceShortfall | undefined; | ||
| //# sourceMappingURL=check-ton-balance.d.ts.map |
| {"version":3,"file":"check-ton-balance.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/check-ton-balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,qBAAqB;IAClC,4FAA4F;IAC5F,QAAQ,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpC;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,2FAA2F;IAC3F,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAChC,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,2CAI7B,qBAAqB,KAAG,mBAAmB,GAAG,SAShD,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { parseUnits } from '@ton/walletkit'; | ||
| /** | ||
| * Pure balance check: does the user have enough TON for the built transaction? | ||
| * | ||
| * Returns `undefined` when the balance is sufficient OR when it hasn't loaded | ||
| * yet (treating unloaded as "unknown" rather than "zero" avoids false-positive | ||
| * shortfalls flashing on first render). | ||
| * | ||
| * No mode classification — this hook reports only "shortfall exists, here's | ||
| * how much was needed." Callers decide what to suggest (topup, gasless, | ||
| * reduce, etc.). For transfer/swap flows where the user can reduce their own | ||
| * outflow, compose this with `checkTransferBalance`. | ||
| */ | ||
| export const checkTonBalance = ({ messages, tonBalance, gasBufferNanos, }) => { | ||
| if (tonBalance === undefined) | ||
| return undefined; | ||
| const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n); | ||
| const requiredNanos = totalOutNanos + gasBufferNanos; | ||
| const tonBalanceNanos = parseUnits(tonBalance, 9); | ||
| if (tonBalanceNanos >= requiredNanos) | ||
| return undefined; | ||
| return { requiredNanos }; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export {}; | ||
| //# sourceMappingURL=check-ton-balance.test.d.ts.map |
| {"version":3,"file":"check-ton-balance.test.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/check-ton-balance.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { checkTonBalance } from './check-ton-balance'; | ||
| /** 0.01 TON in nanos — a reasonable buffer for unit tests. */ | ||
| const BUFFER = 10000000n; | ||
| const msg = (amountNanos) => ({ amount: amountNanos.toString() }); | ||
| describe('checkTonBalance', () => { | ||
| describe('balance is sufficient', () => { | ||
| it('returns undefined when balance exceeds outflow + buffer', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50000000n)], // 0.05 TON outflow | ||
| tonBalance: '1', // 1 TON | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| it('returns undefined when balance equals exactly (required = balance)', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50000000n)], // 0.05 TON | ||
| tonBalance: '0.06', // 0.06 TON = 0.05 + 0.01 buffer | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| it('returns undefined for an empty messages array when balance covers buffer', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [], | ||
| tonBalance: '0.01', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| describe('balance is insufficient', () => { | ||
| it('returns shortfall when balance is below required', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '0.05', // 0.05 TON — exactly outflow, but no headroom for buffer | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 60000000n }); | ||
| }); | ||
| it('returns shortfall when balance is zero', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(1000000n)], // 0.001 TON deploy | ||
| tonBalance: '0', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 11000000n }); | ||
| }); | ||
| it('sums multiple message outflows', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50000000n), msg(30000000n), msg(10000000n)], | ||
| tonBalance: '0.05', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 50000000n + 30000000n + 10000000n + BUFFER }); | ||
| }); | ||
| it('respects a smaller gasBufferNanos override', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '0.05', | ||
| gasBufferNanos: 1000000n, // 0.001 TON buffer | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 51000000n }); | ||
| }); | ||
| it('triggers on a 1-nano deficit (boundary)', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '0.059999999', // 1 nano short of 0.06 = 50_000_000 + 10_000_000 buffer | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 60000000n }); | ||
| }); | ||
| }); | ||
| describe('unloaded balance', () => { | ||
| it('returns undefined when tonBalance is undefined (not yet loaded)', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: undefined, | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| it('treats undefined as "unknown", not as zero — no false-positive shortfall', () => { | ||
| // If `undefined` were treated as 0n, a user with insufficient balance would already | ||
| // see a shortfall flash on first render before their real balance loads. | ||
| const result = checkTonBalance({ | ||
| messages: [msg(1000000000n)], | ||
| tonBalance: undefined, | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| describe('precision', () => { | ||
| it('handles bigint values larger than Number.MAX_SAFE_INTEGER', () => { | ||
| const huge = 1000000000000000000n; // 1 quintillion nanos = 1 billion TON | ||
| const result = checkTonBalance({ | ||
| messages: [msg(huge)], | ||
| tonBalance: '0', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: huge + BUFFER }); | ||
| }); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { CheckTonBalanceParams } from './check-ton-balance'; | ||
| /** | ||
| * Default headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one sent after the | ||
| * amount changes. 0.02 TON. | ||
| */ | ||
| export declare const DEFAULT_SAFETY_MARGIN_NANOS = 20000000n; | ||
| export interface CheckTransferBalanceParams extends CheckTonBalanceParams { | ||
| /** The asset being transferred / swapped. TON-from enables the `'reduce'` outcome. */ | ||
| fromToken: { | ||
| address: string; | ||
| }; | ||
| /** Amount of `fromToken` being sent, as a decimal string in `fromToken` units. */ | ||
| fromAmount: string; | ||
| /** | ||
| * Headroom baked into the suggested reduced amount when the recovery mode is `'reduce'`. | ||
| * Defaults to {@link DEFAULT_SAFETY_MARGIN_NANOS}. | ||
| */ | ||
| safetyMarginNanos?: bigint; | ||
| } | ||
| export type TransferShortfall = { | ||
| mode: 'reduce'; | ||
| requiredNanos: bigint; | ||
| suggestedFromAmount: string; | ||
| } | { | ||
| mode: 'topup'; | ||
| requiredNanos: bigint; | ||
| }; | ||
| /** | ||
| * Balance check for user-initiated transfers (send TON / jetton / NFT) and swaps — | ||
| * where the user controls a `fromAmount` and might be able to fix a shortfall by | ||
| * sending less. | ||
| * | ||
| * Returns: | ||
| * - `undefined` when balance is sufficient (or unloaded — see {@link checkTonBalance}). | ||
| * - `{ mode: 'reduce', suggestedFromAmount }` only when `fromToken` is TON and the | ||
| * remaining balance can still cover gas — the user can keep going by spending less. | ||
| * - `{ mode: 'topup' }` otherwise (reducing wouldn't free up TON gas). | ||
| * | ||
| * Gasless availability is intentionally **not** modelled here — that's a UI policy. | ||
| * Caller maps `'topup'` to `'gasless'` when a gasless alternative is on the table. | ||
| */ | ||
| export declare const checkTransferBalance: ({ messages, tonBalance, gasBufferNanos, fromToken, fromAmount, safetyMarginNanos, }: CheckTransferBalanceParams) => TransferShortfall | undefined; | ||
| //# sourceMappingURL=check-transfer-balance.d.ts.map |
| {"version":3,"file":"check-transfer-balance.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/check-transfer-balance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,YAAc,CAAC;AAEvD,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACrE,sFAAsF;IACtF,SAAS,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,MAAM,iBAAiB,GACvB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAAI,qFAOlC,0BAA0B,KAAG,iBAAiB,GAAG,SA0BnD,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { formatUnits, parseUnits } from '@ton/walletkit'; | ||
| import { checkTonBalance } from './check-ton-balance'; | ||
| /** | ||
| * Default headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one sent after the | ||
| * amount changes. 0.02 TON. | ||
| */ | ||
| export const DEFAULT_SAFETY_MARGIN_NANOS = 20000000n; | ||
| /** | ||
| * Balance check for user-initiated transfers (send TON / jetton / NFT) and swaps — | ||
| * where the user controls a `fromAmount` and might be able to fix a shortfall by | ||
| * sending less. | ||
| * | ||
| * Returns: | ||
| * - `undefined` when balance is sufficient (or unloaded — see {@link checkTonBalance}). | ||
| * - `{ mode: 'reduce', suggestedFromAmount }` only when `fromToken` is TON and the | ||
| * remaining balance can still cover gas — the user can keep going by spending less. | ||
| * - `{ mode: 'topup' }` otherwise (reducing wouldn't free up TON gas). | ||
| * | ||
| * Gasless availability is intentionally **not** modelled here — that's a UI policy. | ||
| * Caller maps `'topup'` to `'gasless'` when a gasless alternative is on the table. | ||
| */ | ||
| export const checkTransferBalance = ({ messages, tonBalance, gasBufferNanos, fromToken, fromAmount, safetyMarginNanos = DEFAULT_SAFETY_MARGIN_NANOS, }) => { | ||
| const shortfall = checkTonBalance({ messages, tonBalance, gasBufferNanos }); | ||
| if (!shortfall) | ||
| return undefined; | ||
| // Reducing the user's own amount only helps when the outflow is in TON. | ||
| // For jetton / NFT outflow, gas is denominated in TON regardless — reducing | ||
| // the jetton-side input doesn't free up any TON. | ||
| if (fromToken.address !== 'ton') { | ||
| return { mode: 'topup', requiredNanos: shortfall.requiredNanos }; | ||
| } | ||
| // We know `tonBalance !== undefined` because checkTonBalance returned a shortfall | ||
| // (it short-circuits on undefined balance). | ||
| const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n); | ||
| const fromAmountNanos = parseUnits(fromAmount, 9); | ||
| const gasOnlyNanos = totalOutNanos - fromAmountNanos; | ||
| const nonSpendReservedNanos = gasOnlyNanos + gasBufferNanos + safetyMarginNanos; | ||
| const tonBalanceNanos = parseUnits(tonBalance, 9); | ||
| if (tonBalanceNanos <= nonSpendReservedNanos) { | ||
| // Even gas doesn't fit — reducing the spend amount won't help. | ||
| return { mode: 'topup', requiredNanos: shortfall.requiredNanos }; | ||
| } | ||
| const suggestedFromAmount = formatUnits(tonBalanceNanos - nonSpendReservedNanos, 9); | ||
| return { mode: 'reduce', requiredNanos: shortfall.requiredNanos, suggestedFromAmount }; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export {}; | ||
| //# sourceMappingURL=check-transfer-balance.test.d.ts.map |
| {"version":3,"file":"check-transfer-balance.test.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/check-transfer-balance.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { checkTransferBalance } from './check-transfer-balance'; | ||
| const BUFFER = 10000000n; // 0.01 TON | ||
| const TON = { address: 'ton' }; | ||
| const JETTON = { address: 'EQA_jetton_master' }; | ||
| const msg = (amountNanos) => ({ amount: amountNanos.toString() }); | ||
| describe('checkTransferBalance', () => { | ||
| describe('balance is sufficient', () => { | ||
| it('returns undefined regardless of fromToken', () => { | ||
| expect(checkTransferBalance({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '1', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.04', | ||
| })).toBeUndefined(); | ||
| expect(checkTransferBalance({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '1', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| })).toBeUndefined(); | ||
| }); | ||
| it('returns undefined when balance is unloaded', () => { | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: undefined, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.04', | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| describe('jetton outflow — always topup', () => { | ||
| it('returns topup when jetton-from has insufficient TON for gas', () => { | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(50000000n)], // 0.05 TON jetton-transfer gas | ||
| tonBalance: '0.02', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| expect(result).toEqual({ mode: 'topup', requiredNanos: 60000000n }); | ||
| }); | ||
| it('returns topup even when balance is zero', () => { | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(1000000n)], | ||
| tonBalance: '0', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '50', | ||
| }); | ||
| expect(result).toEqual({ mode: 'topup', requiredNanos: 11000000n }); | ||
| }); | ||
| it('does not consider safetyMarginNanos for jetton outflow', () => { | ||
| // safetyMarginNanos only matters in the reduce calculation — jetton can't reduce. | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(50000000n)], | ||
| tonBalance: '0.02', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| safetyMarginNanos: 1000000000n, // 1 TON — would be huge if applied | ||
| }); | ||
| expect(result).toEqual({ mode: 'topup', requiredNanos: 60000000n }); | ||
| }); | ||
| }); | ||
| describe('TON outflow — reduce when gas fits', () => { | ||
| it('returns reduce with a smaller suggestedFromAmount when balance covers gas', () => { | ||
| // total_out = fromAmount + gas. User has enough for gas + buffer + safety, but | ||
| // not for full fromAmount. Suggest reduced amount. | ||
| const fromAmountNanos = 500000000n; // 0.5 TON intended spend | ||
| const gasOnlyNanos = 50000000n; // 0.05 TON gas attached to other messages | ||
| const tonBalance = '0.4'; // can't afford 0.5 spend, but enough for gas + margin | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(fromAmountNanos + gasOnlyNanos)], | ||
| tonBalance, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.5', | ||
| }); | ||
| // suggested = balance - gasOnly - gasBuffer - safetyMargin | ||
| // = 400_000_000 - 50_000_000 - 10_000_000 - 20_000_000 = 320_000_000n = 0.32 TON | ||
| expect(result).toEqual({ | ||
| mode: 'reduce', | ||
| requiredNanos: fromAmountNanos + gasOnlyNanos + BUFFER, | ||
| suggestedFromAmount: '0.32', | ||
| }); | ||
| }); | ||
| it('returns topup when even gas does not fit', () => { | ||
| // Balance below gasOnly + buffer + safetyMargin → reducing won't help. | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(500000000n)], // 0.5 TON total outflow | ||
| tonBalance: '0.001', // way too low for any meaningful gas | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.4', | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| expect(result?.requiredNanos).toBe(510000000n); | ||
| }); | ||
| it('boundary: balance equals nonSpendReserved exactly → topup', () => { | ||
| // tonBalance <= nonSpendReserved should return topup (cannot leave anything to spend). | ||
| const gasOnly = 50000000n; | ||
| const fromAmount = 100000000n; | ||
| // nonSpendReserved = gasOnly + BUFFER + DEFAULT_SAFETY_MARGIN_NANOS = 80_000_000n | ||
| const balanceAtBoundary = '0.08'; | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(gasOnly + fromAmount)], | ||
| tonBalance: balanceAtBoundary, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.1', | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| }); | ||
| it('boundary: 1-nano above nonSpendReserved → reduce', () => { | ||
| const gasOnly = 50000000n; | ||
| const fromAmount = 100000000n; | ||
| // nonSpendReserved = gasOnly + BUFFER + DEFAULT_SAFETY_MARGIN_NANOS = 80_000_000n | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(gasOnly + fromAmount)], | ||
| tonBalance: '0.080000001', // 1 nano above the boundary | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.1', | ||
| }); | ||
| // suggested = 1 nano | ||
| expect(result).toEqual({ | ||
| mode: 'reduce', | ||
| requiredNanos: gasOnly + fromAmount + BUFFER, | ||
| suggestedFromAmount: '0.000000001', | ||
| }); | ||
| }); | ||
| }); | ||
| describe('safetyMarginNanos', () => { | ||
| it('shrinks the suggested reduced amount when safetyMargin is larger', () => { | ||
| const tonBalance = '0.4'; | ||
| const baseParams = { | ||
| messages: [msg(550000000n)], // 0.55 TON total outflow | ||
| tonBalance, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.5', | ||
| }; | ||
| const lowMargin = checkTransferBalance({ ...baseParams, safetyMarginNanos: 5000000n }); | ||
| const highMargin = checkTransferBalance({ ...baseParams, safetyMarginNanos: 50000000n }); | ||
| // higher safety margin → less suggested | ||
| expect(lowMargin?.mode).toBe('reduce'); | ||
| expect(highMargin?.mode).toBe('reduce'); | ||
| if (lowMargin?.mode === 'reduce' && highMargin?.mode === 'reduce') { | ||
| expect(BigInt(lowMargin.suggestedFromAmount.replace('.', '').padEnd(10, '0'))).toBeGreaterThan(BigInt(highMargin.suggestedFromAmount.replace('.', '').padEnd(10, '0'))); | ||
| } | ||
| }); | ||
| it('uses DEFAULT_SAFETY_MARGIN_NANOS when not provided', () => { | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(550000000n)], | ||
| tonBalance: '0.4', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.5', | ||
| }); | ||
| expect(result?.mode).toBe('reduce'); | ||
| // gasOnly = 50_000_000, balance = 400_000_000 | ||
| // suggested = 400 - 50 - 10 - 20 = 320 mTON | ||
| if (result?.mode === 'reduce') { | ||
| expect(result.suggestedFromAmount).toBe('0.32'); | ||
| } | ||
| }); | ||
| }); | ||
| describe('composes checkTonBalance', () => { | ||
| it('returns undefined when checkTonBalance would (sufficient or unloaded)', () => { | ||
| // Same inputs as a sufficient-balance check | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(10000000n)], | ||
| tonBalance: '1', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.005', | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| }); |
+127
| # Gasless | ||
| AppKit supports gasless transactions: a relayer co-signs and broadcasts the transaction, charging the user a fee in a relayer-accepted asset (e.g. USDT) instead of TON. Useful when the user holds jettons but no TON. | ||
| Available providers: | ||
| - **createTonApiGaslessProvider** – relay via the TonAPI gasless REST API (no extra dependencies) | ||
| ## Wallet requirements | ||
| The connected wallet must advertise the `SignMessage` TonConnect feature. Gasless sends the *internal* message BoC to the relayer instead of an external message, so the wallet needs a different signing capability than `sendTransaction`. Check via `wallet.getSupportedFeatures()` — `sendGaslessTransaction` throws `GaslessError(SIGN_MESSAGE_NOT_SUPPORTED)` if the feature is missing. | ||
| ## Setup | ||
| Pass `createTonApiGaslessProvider()` to the `AppKit` constructor. With no arguments, the factory auto-registers every network the kit was configured with: | ||
| ```ts | ||
| // Initialize AppKit with the TonAPI gasless provider. | ||
| // With no arguments, the factory auto-registers every network the kit was configured with. | ||
| const appKit = new AppKit({ | ||
| networks: { | ||
| [Network.mainnet().chainId]: { | ||
| apiClient: { url: 'https://toncenter.com', key: 'your-key' }, | ||
| }, | ||
| }, | ||
| providers: [createTonApiGaslessProvider()], | ||
| }); | ||
| ``` | ||
| To pass per-chain `apiKey` / `endpoint` overrides: | ||
| ```ts | ||
| // Per-chain overrides — pass an `apiKey` and/or `endpoint` per network. | ||
| const appKit = new AppKit({ | ||
| networks: { | ||
| [Network.mainnet().chainId]: { | ||
| apiClient: { url: 'https://toncenter.com', key: 'your-key' }, | ||
| }, | ||
| }, | ||
| providers: [ | ||
| createTonApiGaslessProvider({ | ||
| chains: { | ||
| [Network.mainnet().chainId]: { apiKey: process.env.TON_API_KEY }, | ||
| }, | ||
| }), | ||
| ], | ||
| }); | ||
| ``` | ||
| ## Regular vs. gasless USDT transfer | ||
| Both flows produce the same on-chain outcome — a USDT jetton transfer from the user. The difference is *who pays the TON gas* and *what the wallet signs*. | ||
| ### Regular jetton transfer (user pays TON gas) | ||
| ```ts | ||
| const { messages } = await createTransferJettonTransaction(appKit, { | ||
| jettonAddress: USDT_MASTER, | ||
| recipientAddress: recipient, | ||
| amount, | ||
| jettonDecimals: USDT_DECIMALS, | ||
| }); | ||
| await sendTransaction(appKit, { messages }); | ||
| ``` | ||
| Cost: the user spends **~0.05 TON** on gas (whatever is unused is refunded). Wallet needs the `SendTransaction` feature (almost all do). | ||
| ### Gasless jetton transfer (user pays only the jetton fee) | ||
| ```ts | ||
| // Resolve the relayer's address so unspent gas (the jetton `excess`) goes | ||
| // back to the relayer that paid it, not to the user's wallet. | ||
| const { relayAddress } = await getGaslessConfig(appKit); | ||
| // Reuse the same builder as a regular jetton transfer: it resolves the | ||
| // jetton wallet address, builds the payload and attaches the network gas | ||
| // (which the relayer ends up covering) for us. | ||
| const { messages } = await createTransferJettonTransaction(appKit, { | ||
| jettonAddress: USDT_MASTER, | ||
| recipientAddress: recipient, | ||
| amount, | ||
| jettonDecimals: USDT_DECIMALS, | ||
| responseDestination: relayAddress, | ||
| }); | ||
| // Pay the relayer's fee in USDT. Quote first so the fee and validity window | ||
| // can be reviewed before the wallet signs. | ||
| const quote = await getGaslessQuote(appKit, { | ||
| messages, | ||
| feeAsset: USDT_MASTER, | ||
| }); | ||
| await sendGaslessTransaction(appKit, { quote }); | ||
| ``` | ||
| Cost: the user spends **0 TON** and a small amount of USDT (the relayer fee, shown in `quote.fee`). Wallet needs the `SignMessage` feature. | ||
| ## Migration recipe | ||
| The `messages` array is built the same way for both flows — the relayer wraps your messages on its end and adds the fee transfer. Two changes versus a regular send: | ||
| 1. Set the jetton transfer's `responseDestination` to the relayer's `relayAddress` (from `getGaslessConfig`) so the unspent TON gas returns to the relayer that paid it instead of the user's wallet. | ||
| 2. Replace `sendTransaction(appKit, { messages })` with `getGaslessQuote(appKit, { messages, feeAsset })` followed by `sendGaslessTransaction(appKit, { quote })`. | ||
| `feeAsset` is the jetton master the relayer charges the fee in. The TonAPI provider requires it; discover the relayer-accepted assets via `getGaslessConfig(appKit)` (returns `{ relayAddress, supportedAssets }`), or hardcode the jetton master you want to charge in. The `getGaslessJettonTransferQuote` convenience wrapper handles both points above for you. | ||
| For React projects, the same flow is available as hooks (`useSendTransaction` / `useGaslessQuote` + `useSendGaslessTransaction`). | ||
| ## Error codes | ||
| | Code | When it happens | | ||
| |---|---| | ||
| | `UNSUPPORTED_OPERATION` | The provider does not implement the requested mode (e.g. a jetton-fee provider called without `feeAsset`). | | ||
| | `QUOTE_FAILED` | Relayer rejected the quote (insufficient liquidity, malformed messages, …). | | ||
| | `SEND_FAILED` | Relayer rejected the signed BoC, or all retries were exhausted. | | ||
| | `CONFIG_FAILED` | Failed to fetch the relayer's configuration (relay address + accepted fee assets). | | ||
| | `SIGN_MESSAGE_NOT_SUPPORTED` | Connected wallet does not advertise the `SignMessage` feature. | | ||
| | `TOO_MANY_MESSAGES` | Quote carries more messages than the wallet's `SignMessage.maxMessages` cap. | | ||
| | `QUOTE_EXPIRED` | Quote's `validUntil` window has passed; checked before signing so the wallet is not prompted for a quote the relayer would reject. Fetch a fresh quote. | | ||
| | `WALLET_MISMATCH` | Quote was issued for a different address than the selected wallet (e.g. the active wallet was switched after quoting). | | ||
| <!-- | ||
| This file is auto-generated. Do not edit manually. | ||
| Changes will be overwritten when running the docs update script. | ||
| Source template: template/packages/appkit/docs/gasless.md | ||
| --> | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessConfig } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { Network } from '../../types/network'; | ||
| import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
| export interface GetGaslessConfigOptions { | ||
| /** Network to query. Defaults to the selected wallet's network, then provider's first supported. */ | ||
| network?: Network; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessConfigReturnType = Promise<GaslessConfig>; | ||
| export type GetGaslessConfigErrorType = Error; | ||
| /** | ||
| * Fetch the gasless relayer's configuration on a network — the relay address | ||
| * (e.g. for jetton-transfer `responseDestination`) and the assets it accepts | ||
| * as fee payment. | ||
| */ | ||
| export const getGaslessConfig = async ( | ||
| appKit: AppKit, | ||
| options: GetGaslessConfigOptions = {}, | ||
| ): GetGaslessConfigReturnType => { | ||
| const network = options.network ?? getSelectedWallet(appKit)?.getNetwork(); | ||
| return appKit.gaslessManager.getConfig(network, options.providerId); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessQuote } from '../../gasless'; | ||
| import type { UserFriendlyAddress } from '../../types/primitives'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import { createTransferJettonTransaction } from '../jettons/create-transfer-jetton-transaction'; | ||
| import { getGaslessConfig } from './get-gasless-config'; | ||
| import { getGaslessQuote } from './get-gasless-quote'; | ||
| export interface GetGaslessJettonTransferQuoteOptions { | ||
| /** Jetton master address to transfer */ | ||
| jettonAddress: string; | ||
| /** Recipient address */ | ||
| recipientAddress: string; | ||
| /** Human-readable amount of jettons to transfer */ | ||
| amount: string; | ||
| /** Jetton decimals. Auto-fetched from jetton info when omitted. */ | ||
| jettonDecimals?: number; | ||
| /** Optional text comment attached to the transfer */ | ||
| comment?: string; | ||
| /** | ||
| * Asset address used to pay the relayer's fee (jetton master for TonAPI). | ||
| * Omit only for free / sponsored providers — see {@link getGaslessQuote}. | ||
| */ | ||
| feeAsset?: UserFriendlyAddress; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessJettonTransferQuoteReturnType = Promise<GaslessQuote>; | ||
| export type GetGaslessJettonTransferQuoteErrorType = Error; | ||
| /** | ||
| * Build a gasless quote for a jetton transfer. | ||
| * | ||
| * Convenience wrapper that assembles the transfer messages the same way as | ||
| * {@link createTransferJettonTransaction} (resolving the jetton wallet address, | ||
| * decimals and payload) and forwards them to {@link getGaslessQuote}. The result | ||
| * is passed verbatim to `sendGaslessTransaction`, preserving the quote → send | ||
| * two-step flow. | ||
| * | ||
| * The jetton `responseDestination` (excess receiver) is set to the relayer's | ||
| * address — the relayer paid the gas, so the unspent TON goes back to it rather | ||
| * than to the user's wallet. | ||
| * | ||
| * The quote is always bound to the selected wallet's network — the same network | ||
| * the message builder resolves the jetton wallet on — so there is no `network` | ||
| * override (a mismatch would build the message on one chain and quote on another). | ||
| */ | ||
| export const getGaslessJettonTransferQuote = async ( | ||
| appKit: AppKit, | ||
| options: GetGaslessJettonTransferQuoteOptions, | ||
| ): GetGaslessJettonTransferQuoteReturnType => { | ||
| const { jettonAddress, recipientAddress, amount, jettonDecimals, comment, feeAsset, providerId } = options; | ||
| const { relayAddress } = await getGaslessConfig(appKit, { providerId }); | ||
| const { messages } = await createTransferJettonTransaction(appKit, { | ||
| jettonAddress, | ||
| recipientAddress, | ||
| amount, | ||
| jettonDecimals, | ||
| comment, | ||
| responseDestination: relayAddress, | ||
| }); | ||
| return getGaslessQuote(appKit, { messages, feeAsset, providerId }); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessManager } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type GetGaslessManagerReturnType = GaslessManager; | ||
| /** | ||
| * Get gasless manager instance | ||
| */ | ||
| export const getGaslessManager = (appKit: AppKit): GetGaslessManagerReturnType => { | ||
| return appKit.gaslessManager; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessProviderMetadata } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessProviderMetadataOptions { | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessProviderMetadataReturnType = Promise<GaslessProviderMetadata>; | ||
| export type GetGaslessProviderMetadataErrorType = Error; | ||
| /** | ||
| * Get static metadata for a gasless provider (display name, logo, url). | ||
| */ | ||
| export const getGaslessProviderMetadata = async ( | ||
| appKit: AppKit, | ||
| options: GetGaslessProviderMetadataOptions = {}, | ||
| ): GetGaslessProviderMetadataReturnType => { | ||
| return appKit.gaslessManager.getMetadata(options.providerId); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessProviderInterface } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface GetGaslessProviderOptions { | ||
| id?: string; | ||
| } | ||
| export type GetGaslessProviderReturnType = GaslessProviderInterface; | ||
| export const getGaslessProvider = ( | ||
| appKit: AppKit, | ||
| options: GetGaslessProviderOptions = {}, | ||
| ): GetGaslessProviderReturnType => { | ||
| return appKit.gaslessManager.getProvider(options.id); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessProviderInterface } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export type GetGaslessProvidersReturnType = GaslessProviderInterface[]; | ||
| /** | ||
| * Get all registered gasless providers. | ||
| */ | ||
| export const getGaslessProviders = (appKit: AppKit): GetGaslessProvidersReturnType => { | ||
| return appKit.gaslessManager.getProviders(); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { GaslessQuote } from '../../gasless'; | ||
| import type { Network } from '../../types/network'; | ||
| import type { UserFriendlyAddress } from '../../types/primitives'; | ||
| import type { TransactionRequestMessage } from '../../types/transaction'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
| export interface GetGaslessQuoteOptions { | ||
| /** | ||
| * Asset address used to pay the relayer's fee (currently a jetton master | ||
| * for TonAPI; future providers may accept NFT items or other assets). | ||
| * Omit for free / sponsored providers — jetton-only providers will throw | ||
| * `GaslessError(UnsupportedOperation)` in that case. | ||
| */ | ||
| feeAsset?: UserFriendlyAddress; | ||
| /** User's messages to include in the gasless transaction */ | ||
| messages: TransactionRequestMessage[]; | ||
| /** Network to quote on. Defaults to the selected wallet's network. */ | ||
| network?: Network; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| export type GetGaslessQuoteReturnType = Promise<GaslessQuote>; | ||
| export type GetGaslessQuoteErrorType = Error; | ||
| /** | ||
| * Ask the relayer for a gasless transaction quote. | ||
| * | ||
| * Returns relayer-wrapped messages (ready to be signed via `signMessage`), the | ||
| * fee charged in the fee jetton, and the bundle validity window (`validUntil`). | ||
| * | ||
| * The result is intended to be passed verbatim to `sendGaslessTransaction`, | ||
| * which forwards the signed BoC to the relayer. | ||
| */ | ||
| export const getGaslessQuote = async (appKit: AppKit, options: GetGaslessQuoteOptions): GetGaslessQuoteReturnType => { | ||
| const wallet = getSelectedWallet(appKit); | ||
| if (!wallet) { | ||
| throw new Error('Wallet not connected'); | ||
| } | ||
| return appKit.gaslessManager.getQuote( | ||
| { | ||
| network: options.network ?? wallet.getNetwork(), | ||
| feeAsset: options.feeAsset, | ||
| walletAddress: wallet.getAddress(), | ||
| walletPublicKey: wallet.getPublicKey(), | ||
| messages: options.messages, | ||
| }, | ||
| options.providerId, | ||
| ); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
| import { GaslessErrorCode } from '../../gasless'; | ||
| import type { GaslessQuote } from '../../gasless'; | ||
| import { Network } from '../../types/network'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { Base64String } from '../../types/primitives'; | ||
| import type { Feature, WalletInterface } from '../../types/wallet'; | ||
| import { sendGaslessTransaction } from './send-gasless-transaction'; | ||
| const TEST_ADDRESS = 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'; | ||
| const FAKE_INTERNAL_BOC = 'te6cckEBAQEAAgAAAA==' as Base64String; | ||
| const makeQuote = (overrides: Partial<GaslessQuote> = {}): GaslessQuote => ({ | ||
| network: Network.mainnet(), | ||
| messages: [{ address: TEST_ADDRESS, amount: '60000000' }], | ||
| fee: '1234', | ||
| validUntil: Math.floor(Date.now() / 1000) + 60, | ||
| from: TEST_ADDRESS, | ||
| ...overrides, | ||
| }); | ||
| const SIGN_MESSAGE_FEATURE: Feature = { name: 'SignMessage', maxMessages: 4 }; | ||
| const makeWallet = (overrides: Partial<WalletInterface> = {}): WalletInterface => { | ||
| return { | ||
| connectorId: 'tonconnect', | ||
| getAddress: () => TEST_ADDRESS, | ||
| getPublicKey: () => '0xabc' as never, | ||
| getNetwork: () => ({ chainId: '-239' }) as never, | ||
| getWalletId: () => 'wallet-1', | ||
| getSupportedFeatures: () => [SIGN_MESSAGE_FEATURE], | ||
| sendTransaction: vi.fn(), | ||
| signData: vi.fn(), | ||
| signMessage: vi.fn().mockResolvedValue({ internalBoc: FAKE_INTERNAL_BOC }), | ||
| ...overrides, | ||
| } as WalletInterface; | ||
| }; | ||
| type MockSendResult = { boc: string; normalizedBoc: string; normalizedHash: string; internalBoc: string }; | ||
| const DEFAULT_SEND_RESULT: MockSendResult = { | ||
| boc: 'external_boc_b64', | ||
| normalizedBoc: 'normalized_b64', | ||
| normalizedHash: '0xabcdef', | ||
| internalBoc: FAKE_INTERNAL_BOC, | ||
| }; | ||
| const makeAppKit = (wallet: WalletInterface | null) => { | ||
| const sendTransaction = vi.fn<() => Promise<MockSendResult>>().mockResolvedValue({ ...DEFAULT_SEND_RESULT }); | ||
| const appKit = { | ||
| walletsManager: { selectedWallet: wallet }, | ||
| gaslessManager: { sendTransaction }, | ||
| } as unknown as AppKit; | ||
| return { appKit, sendTransaction }; | ||
| }; | ||
| describe('sendGaslessTransaction', () => { | ||
| let wallet: WalletInterface; | ||
| beforeEach(() => { | ||
| wallet = makeWallet(); | ||
| }); | ||
| it('signs the quote and forwards SendTransactionResponse-shaped fields from the relayer', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const quote = makeQuote(); | ||
| const result = await sendGaslessTransaction(appKit, { quote }); | ||
| expect(wallet.signMessage).toHaveBeenCalledWith({ | ||
| messages: quote.messages, | ||
| validUntil: quote.validUntil, | ||
| }); | ||
| expect(sendTransaction).toHaveBeenCalledWith( | ||
| { network: quote.network, walletPublicKey: '0xabc', internalBoc: FAKE_INTERNAL_BOC }, | ||
| undefined, | ||
| ); | ||
| expect(result.internalBoc).toBe(FAKE_INTERNAL_BOC); | ||
| expect(result.boc).toBe(DEFAULT_SEND_RESULT.boc); | ||
| expect(result.normalizedBoc).toBe(DEFAULT_SEND_RESULT.normalizedBoc); | ||
| expect(result.normalizedHash).toBe(DEFAULT_SEND_RESULT.normalizedHash); | ||
| }); | ||
| it('forwards providerId to gaslessManager.sendTransaction', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| await sendGaslessTransaction(appKit, { quote: makeQuote(), providerId: 'custom' }); | ||
| expect(sendTransaction).toHaveBeenCalledWith(expect.anything(), 'custom'); | ||
| }); | ||
| it('throws plain Error when no wallet is connected', async () => { | ||
| const { appKit } = makeAppKit(null); | ||
| await expect(sendGaslessTransaction(appKit, { quote: makeQuote() })).rejects.toThrow('Wallet not connected'); | ||
| }); | ||
| it('throws GaslessError(QUOTE_EXPIRED) before signing when the quote validUntil has passed', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const expiredQuote = makeQuote({ validUntil: Math.floor(Date.now() / 1000) - 1 }); | ||
| await expect(sendGaslessTransaction(appKit, { quote: expiredQuote })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.QuoteExpired, | ||
| }); | ||
| expect(wallet.signMessage).not.toHaveBeenCalled(); | ||
| expect(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(QUOTE_EXPIRED) when validUntil is missing/non-finite', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const quoteWithoutValidUntil = makeQuote({ validUntil: undefined as unknown as number }); | ||
| await expect(sendGaslessTransaction(appKit, { quote: quoteWithoutValidUntil })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.QuoteExpired, | ||
| }); | ||
| expect(wallet.signMessage).not.toHaveBeenCalled(); | ||
| expect(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(WALLET_MISMATCH) before signing when the quote was issued for another wallet', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| const otherWalletQuote = makeQuote({ from: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c' }); | ||
| await expect(sendGaslessTransaction(appKit, { quote: otherWalletQuote })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.WalletMismatch, | ||
| }); | ||
| expect(wallet.signMessage).not.toHaveBeenCalled(); | ||
| expect(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when wallet lacks SignMessage feature', async () => { | ||
| const walletWithoutFeature = makeWallet({ | ||
| getSupportedFeatures: () => [{ name: 'SignData' } as never], | ||
| }); | ||
| const { appKit } = makeAppKit(walletWithoutFeature); | ||
| await expect(sendGaslessTransaction(appKit, { quote: makeQuote() })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.SignMessageNotSupported, | ||
| }); | ||
| expect(walletWithoutFeature.signMessage).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(TOO_MANY_MESSAGES) when quote exceeds wallet maxMessages', async () => { | ||
| const walletWithCap = makeWallet({ | ||
| getSupportedFeatures: () => [{ name: 'SignMessage', maxMessages: 1 }], | ||
| }); | ||
| const { appKit } = makeAppKit(walletWithCap); | ||
| const quote = makeQuote({ | ||
| messages: [ | ||
| { address: TEST_ADDRESS, amount: '1' }, | ||
| { address: TEST_ADDRESS, amount: '2' }, | ||
| ], | ||
| }); | ||
| await expect(sendGaslessTransaction(appKit, { quote })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.TooManyMessages, | ||
| }); | ||
| expect(walletWithCap.signMessage).not.toHaveBeenCalled(); | ||
| }); | ||
| it('throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when wallet does not advertise any features', async () => { | ||
| // Treat undefined features the same as missing SignMessage — gasless | ||
| // requires SignMessage, so unknown capabilities fail closed instead of | ||
| // attempting to sign and surfacing an uglier bridge-level error. | ||
| const walletWithUnknown = makeWallet({ getSupportedFeatures: () => undefined }); | ||
| const { appKit, sendTransaction } = makeAppKit(walletWithUnknown); | ||
| await expect(sendGaslessTransaction(appKit, { quote: makeQuote() })).rejects.toMatchObject({ | ||
| name: 'GaslessError', | ||
| code: GaslessErrorCode.SignMessageNotSupported, | ||
| }); | ||
| expect(walletWithUnknown.signMessage).not.toHaveBeenCalled(); | ||
| expect(sendTransaction).not.toHaveBeenCalled(); | ||
| }); | ||
| it('propagates errors from gaslessManager.sendTransaction', async () => { | ||
| const { appKit, sendTransaction } = makeAppKit(wallet); | ||
| sendTransaction.mockRejectedValueOnce(new Error('relayer offline')); | ||
| await expect(sendGaslessTransaction(appKit, { quote: makeQuote() })).rejects.toThrow('relayer offline'); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { GaslessError, GaslessErrorCode } from '../../gasless'; | ||
| import type { GaslessQuote, GaslessSendResponse } from '../../gasless'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
| import { compareAddress, getMaxOutgoingMessages, hasSignMessageSupport } from '../../utils'; | ||
| export interface SendGaslessTransactionParameters { | ||
| /** Pre-computed quote obtained via `getGaslessQuote` */ | ||
| quote: GaslessQuote; | ||
| /** Gasless provider id. Uses the default provider when omitted. */ | ||
| providerId?: string; | ||
| } | ||
| /** | ||
| * Return type is `GaslessSendResponse` — `SendTransactionResponse` plus | ||
| * `internalBoc`. Consumers can drop `result.boc` straight into | ||
| * `getTransactionStatus({ boc })` or build explorer links from | ||
| * `result.normalizedHash` the same way as regular `sendTransaction`. | ||
| */ | ||
| export type SendGaslessTransactionReturnType = GaslessSendResponse; | ||
| export type SendGaslessTransactionErrorType = Error; | ||
| /** | ||
| * Sign a previously computed gasless quote and submit the resulting BoC | ||
| * to the relayer. | ||
| * | ||
| * Quote freshness is owned by the query layer (`getGaslessQuoteQueryOptions` | ||
| * sets a 2-minute `staleTime` matching the relayer `validUntil` window). If a | ||
| * stale quote is submitted anyway, the relayer rejects it and the error | ||
| * surfaces through `gaslessManager.sendTransaction`. | ||
| * | ||
| * @throws GaslessError(QUOTE_EXPIRED) when the quote's relayer-provided | ||
| * `validUntil` window has already passed. Checked before signing so the | ||
| * wallet is never prompted for a quote the relayer would reject anyway. | ||
| * @throws GaslessError(WALLET_MISMATCH) when the quote was issued for a | ||
| * different address than the currently selected wallet (e.g. the active | ||
| * wallet was switched after the quote was fetched). | ||
| * @throws GaslessError(SIGN_MESSAGE_NOT_SUPPORTED) when the wallet does not | ||
| * advertise the `SignMessage` feature. | ||
| * @throws GaslessError(TOO_MANY_MESSAGES) when the quote carries more | ||
| * messages than the wallet's advertised `maxMessages` cap. | ||
| * @throws GaslessError(SEND_FAILED) when the relayer accepts the BoC but | ||
| * omits the broadcasted external message in its response. | ||
| */ | ||
| export const sendGaslessTransaction = async ( | ||
| appKit: AppKit, | ||
| parameters: SendGaslessTransactionParameters, | ||
| ): Promise<SendGaslessTransactionReturnType> => { | ||
| const { quote, providerId } = parameters; | ||
| const wallet = getSelectedWallet(appKit); | ||
| if (!wallet) { | ||
| throw new Error('Wallet not connected'); | ||
| } | ||
| // Fail fast on a dead quote before prompting the wallet to sign: the relayer | ||
| // owns `validUntil`, so a passed deadline means the relayer would reject the | ||
| // send anyway. Cheaper to surface a typed error here than to round-trip a | ||
| // signature the relayer discards. A non-finite `validUntil` (missing/garbled | ||
| // relayer response) is treated as expired rather than silently bypassing the | ||
| // check (`n > undefined` is always false). | ||
| if (!Number.isFinite(quote.validUntil) || Math.floor(Date.now() / 1000) > quote.validUntil) { | ||
| throw new GaslessError( | ||
| 'Gasless quote has expired or is missing a validity window. Fetch a fresh quote before sending.', | ||
| GaslessErrorCode.QuoteExpired, | ||
| { validUntil: quote.validUntil }, | ||
| ); | ||
| } | ||
| // Guard against the active wallet being switched between quote and send: the | ||
| // quote is bound to the `from` the relayer echoed, and signing with a | ||
| // different wallet would produce a BoC the relayer rejects. Skip when a | ||
| // provider does not echo `from` (treat absence as "no claim", not mismatch). | ||
| if (quote.from && !compareAddress(quote.from, wallet.getAddress())) { | ||
| throw new GaslessError( | ||
| 'Gasless quote was issued for a different wallet than the selected one.', | ||
| GaslessErrorCode.WalletMismatch, | ||
| { quoteFrom: quote.from, wallet: wallet.getAddress() }, | ||
| ); | ||
| } | ||
| // Gasless signs via `signMessage`, so the wallet must advertise the | ||
| // `SignMessage` feature, and the quote's message bundle must fit the wallet's | ||
| // `SignMessage` `maxMessages` cap. Checked before prompting so a wallet that | ||
| // can't satisfy the request fails with a typed error instead of an opaque | ||
| // bridge rejection. | ||
| const features = wallet.getSupportedFeatures() ?? []; | ||
| if (!hasSignMessageSupport(features)) { | ||
| throw new GaslessError( | ||
| 'Connected wallet does not support the SignMessage feature required for gasless transactions.', | ||
| GaslessErrorCode.SignMessageNotSupported, | ||
| ); | ||
| } | ||
| const maxMessages = getMaxOutgoingMessages(features, 'SignMessage'); | ||
| if (quote.messages.length > maxMessages) { | ||
| throw new GaslessError( | ||
| `Quote has ${quote.messages.length} messages but the wallet only supports up to ${maxMessages}.`, | ||
| GaslessErrorCode.TooManyMessages, | ||
| { messages: quote.messages.length, maxMessages }, | ||
| ); | ||
| } | ||
| const { internalBoc } = await wallet.signMessage({ | ||
| messages: quote.messages, | ||
| validUntil: quote.validUntil, | ||
| }); | ||
| return appKit.gaslessManager.sendTransaction( | ||
| { | ||
| network: quote.network, | ||
| walletPublicKey: wallet.getPublicKey(), | ||
| internalBoc, | ||
| }, | ||
| providerId, | ||
| ); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface SetDefaultGaslessProviderParameters { | ||
| providerId: string; | ||
| } | ||
| export type SetDefaultGaslessProviderReturnType = void; | ||
| /** | ||
| * Set the default gasless provider. | ||
| * Subsequent estimate and send calls will use this provider when none is specified. | ||
| */ | ||
| export const setDefaultGaslessProvider = ( | ||
| appKit: AppKit, | ||
| parameters: SetDefaultGaslessProviderParameters, | ||
| ): SetDefaultGaslessProviderReturnType => { | ||
| appKit.gaslessManager.setDefaultProvider(parameters.providerId); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| export interface WatchGaslessProvidersParameters { | ||
| onChange: () => void; | ||
| } | ||
| export type WatchGaslessProvidersReturnType = () => void; | ||
| /** | ||
| * Watch for new gasless providers registration and default-provider changes. | ||
| */ | ||
| export const watchGaslessProviders = ( | ||
| appKit: AppKit, | ||
| parameters: WatchGaslessProvidersParameters, | ||
| ): WatchGaslessProvidersReturnType => { | ||
| const { onChange } = parameters; | ||
| const unsubscribeRegistered = appKit.emitter.on('provider:registered', (event) => { | ||
| if (event.payload.type === 'gasless') onChange(); | ||
| }); | ||
| const unsubscribeDefaultChanged = appKit.emitter.on('provider:default-changed', (event) => { | ||
| if (event.payload.type === 'gasless') onChange(); | ||
| }); | ||
| return () => { | ||
| unsubscribeRegistered(); | ||
| unsubscribeDefaultChanged(); | ||
| }; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { TransactionRequest } from '../../types/transaction'; | ||
| import type { SignMessageResponse } from '../../types/signing'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import { getMaxOutgoingMessages, hasSignMessageSupport } from '../../utils'; | ||
| import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
| export type SignMessageParameters = TransactionRequest; | ||
| export type SignMessageReturnType = SignMessageResponse; | ||
| export type SignMessageErrorType = Error; | ||
| /** | ||
| * Ask the connected wallet to sign a transaction-shaped request without broadcasting it. | ||
| * | ||
| * Returns a signed internal-message BoC that can be relayed on-chain by a third party | ||
| * (e.g. a gasless relayer). Unlike sendTransaction, the message is NOT submitted to the | ||
| * network by the wallet. | ||
| * | ||
| * Throws when the connected wallet does not advertise the `SignMessage` feature, or when | ||
| * the request carries more messages than the wallet's `SignMessage` `maxMessages` cap — | ||
| * surfacing a clear error before prompting instead of an opaque bridge rejection. | ||
| */ | ||
| export const signMessage = async ( | ||
| appKit: AppKit, | ||
| parameters: SignMessageParameters, | ||
| ): Promise<SignMessageReturnType> => { | ||
| const wallet = getSelectedWallet(appKit); | ||
| if (!wallet) { | ||
| throw new Error('Wallet not connected'); | ||
| } | ||
| const features = wallet.getSupportedFeatures() ?? []; | ||
| if (!hasSignMessageSupport(features)) { | ||
| throw new Error('Connected wallet does not support the SignMessage feature.'); | ||
| } | ||
| const maxMessages = getMaxOutgoingMessages(features, 'SignMessage'); | ||
| if (parameters.messages.length > maxMessages) { | ||
| throw new Error( | ||
| `SignMessage request has ${parameters.messages.length} messages but the wallet supports up to ${maxMessages}.`, | ||
| ); | ||
| } | ||
| return wallet.signMessage(parameters); | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import { hasSignMessageSupport } from '../../utils'; | ||
| import { getSelectedWallet } from './get-selected-wallet'; | ||
| export type GetSignMessageSupportReturnType = boolean; | ||
| /** | ||
| * Whether the currently selected wallet advertises the `SignMessage` feature | ||
| * (required for gasless transactions). | ||
| * | ||
| * Fail-closed: returns `false` when no wallet is selected or the wallet | ||
| * advertises no features. This mirrors the gasless send path, which rejects a | ||
| * `SignMessage` request from a wallet that doesn't list the feature — so the UI | ||
| * should not offer gasless when the send would refuse it. | ||
| */ | ||
| export const getSignMessageSupport = (appKit: AppKit): GetSignMessageSupportReturnType => { | ||
| const features = getSelectedWallet(appKit)?.getSupportedFeatures(); | ||
| return features ? hasSignMessageSupport(features) : false; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import { WALLETS_EVENTS } from '../../core/app-kit'; | ||
| import { getSignMessageSupport } from './get-sign-message-support'; | ||
| export interface WatchSignMessageSupportParameters { | ||
| onChange: (supported: boolean) => void; | ||
| } | ||
| export type WatchSignMessageSupportReturnType = () => void; | ||
| /** | ||
| * Watch whether the selected wallet supports `SignMessage`. Re-evaluated on | ||
| * every wallet selection change (features are static per wallet, so the | ||
| * selection change is the only thing that can flip the result). | ||
| */ | ||
| export const watchSignMessageSupport = ( | ||
| appKit: AppKit, | ||
| parameters: WatchSignMessageSupportParameters, | ||
| ): WatchSignMessageSupportReturnType => { | ||
| const { onChange } = parameters; | ||
| const unsubscribe = appKit.emitter.on(WALLETS_EVENTS.SELECTION_CHANGED, () => { | ||
| onChange(getSignMessageSupport(appKit)); | ||
| }); | ||
| return unsubscribe; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export { GaslessProvider, GaslessError, GaslessErrorCode, GaslessManager } from '@ton/walletkit'; | ||
| export type { | ||
| GaslessAPI, | ||
| GaslessProviderInterface, | ||
| GaslessConfig, | ||
| GaslessSupportedAsset, | ||
| GaslessProviderMetadata, | ||
| GaslessProviderMetadataOverride, | ||
| GaslessQuoteParams, | ||
| GaslessQuote, | ||
| GaslessSendParams, | ||
| GaslessSendResponse, | ||
| } from '@ton/walletkit'; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export * from '@ton/walletkit/gasless/tonapi'; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getGaslessConfig } from '../../actions/gasless/get-gasless-config'; | ||
| import type { | ||
| GetGaslessConfigErrorType, | ||
| GetGaslessConfigOptions, | ||
| GetGaslessConfigReturnType, | ||
| } from '../../actions/gasless/get-gasless-config'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| import { filterQueryOptions, resolveNetwork } from '../../utils'; | ||
| export type { GetGaslessConfigErrorType }; | ||
| export type GetGaslessConfigQueryConfig<selectData = GetGaslessConfigData> = Compute< | ||
| ExactPartial<GetGaslessConfigOptions> | ||
| > & | ||
| QueryParameter<GetGaslessConfigQueryFnData, GetGaslessConfigErrorType, selectData, GetGaslessConfigQueryKey>; | ||
| export const getGaslessConfigQueryOptions = <selectData = GetGaslessConfigData>( | ||
| appKit: AppKit, | ||
| options: GetGaslessConfigQueryConfig<selectData> = {}, | ||
| ): GetGaslessConfigQueryOptions<selectData> => { | ||
| const resolvedOptions = { ...options, network: resolveNetwork(appKit, options.network) }; | ||
| return { | ||
| ...options.query, | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey as [string, GetGaslessConfigOptions]; | ||
| return getGaslessConfig(appKit, parameters); | ||
| }, | ||
| queryKey: getGaslessConfigQueryKey(resolvedOptions), | ||
| }; | ||
| }; | ||
| export type GetGaslessConfigQueryFnData = Compute<Awaited<GetGaslessConfigReturnType>>; | ||
| export type GetGaslessConfigData = GetGaslessConfigQueryFnData; | ||
| export const getGaslessConfigQueryKey = ( | ||
| options: Compute<ExactPartial<GetGaslessConfigOptions>> = {}, | ||
| ): GetGaslessConfigQueryKey => { | ||
| return ['gaslessConfig', filterQueryOptions(options as unknown as Record<string, unknown>)] as const; | ||
| }; | ||
| export type GetGaslessConfigQueryKey = readonly ['gaslessConfig', Compute<ExactPartial<GetGaslessConfigOptions>>]; | ||
| export type GetGaslessConfigQueryOptions<selectData = GetGaslessConfigData> = QueryOptions< | ||
| GetGaslessConfigQueryFnData, | ||
| GetGaslessConfigErrorType, | ||
| selectData, | ||
| GetGaslessConfigQueryKey | ||
| >; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getGaslessJettonTransferQuote } from '../../actions/gasless/get-gasless-jetton-transfer-quote'; | ||
| import type { | ||
| GetGaslessJettonTransferQuoteErrorType, | ||
| GetGaslessJettonTransferQuoteOptions, | ||
| GetGaslessJettonTransferQuoteReturnType, | ||
| } from '../../actions/gasless/get-gasless-jetton-transfer-quote'; | ||
| import { getSelectedWallet } from '../../actions/wallets/get-selected-wallet'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { Network } from '../../types/network'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| import { filterQueryOptions, resolveNetwork } from '../../utils'; | ||
| import { GASLESS_QUOTE_STALE_TIME_MS } from './get-gasless-quote'; | ||
| export type { GetGaslessJettonTransferQuoteErrorType }; | ||
| export type GetGaslessJettonTransferQuoteQueryConfig<selectData = GetGaslessJettonTransferQuoteData> = Compute< | ||
| ExactPartial<GetGaslessJettonTransferQuoteOptions> | ||
| > & | ||
| QueryParameter< | ||
| GetGaslessJettonTransferQuoteQueryFnData, | ||
| GetGaslessJettonTransferQuoteErrorType, | ||
| selectData, | ||
| GetGaslessJettonTransferQuoteQueryKey | ||
| >; | ||
| export const getGaslessJettonTransferQuoteQueryOptions = <selectData = GetGaslessJettonTransferQuoteData>( | ||
| appKit: AppKit, | ||
| options: GetGaslessJettonTransferQuoteQueryConfig<selectData> = {}, | ||
| network?: Network, | ||
| ): GetGaslessJettonTransferQuoteQueryOptions<selectData> => { | ||
| // Bind the quote to the selected wallet's address and network so a | ||
| // wallet/network switch produces a distinct cache entry and refetch | ||
| // (mirrors `getGaslessQuoteQueryOptions`). The quote is always built on the | ||
| // selected wallet's network — the action resolves it internally, there is no | ||
| // caller override — so `network` here is a key dimension only, never forwarded | ||
| // to the action. | ||
| const wallet = getSelectedWallet(appKit); | ||
| const walletAddress = wallet?.getAddress(); | ||
| const networkChainId = resolveNetwork(appKit, network).chainId; | ||
| return { | ||
| staleTime: GASLESS_QUOTE_STALE_TIME_MS, | ||
| ...options.query, | ||
| // Gate on a connected wallet too: the action resolves the jetton wallet | ||
| // via the selected wallet and throws without one, so without this the | ||
| // query would fire into a `Wallet not connected` error instead of idling. | ||
| enabled: Boolean( | ||
| options.jettonAddress && | ||
| options.recipientAddress && | ||
| options.amount && | ||
| walletAddress && | ||
| (options.query?.enabled ?? true), | ||
| ), | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey as [ | ||
| string, | ||
| GetGaslessJettonTransferQuoteOptions, | ||
| string | undefined, | ||
| string | undefined, | ||
| ]; | ||
| return getGaslessJettonTransferQuote(appKit, parameters); | ||
| }, | ||
| queryKey: getGaslessJettonTransferQuoteQueryKey(options, walletAddress, networkChainId), | ||
| }; | ||
| }; | ||
| export type GetGaslessJettonTransferQuoteQueryFnData = Compute<Awaited<GetGaslessJettonTransferQuoteReturnType>>; | ||
| export type GetGaslessJettonTransferQuoteData = GetGaslessJettonTransferQuoteQueryFnData; | ||
| export const getGaslessJettonTransferQuoteQueryKey = ( | ||
| options: Compute<ExactPartial<GetGaslessJettonTransferQuoteOptions>> = {}, | ||
| walletAddress?: string, | ||
| networkChainId?: string, | ||
| ): GetGaslessJettonTransferQuoteQueryKey => { | ||
| return [ | ||
| 'gaslessJettonTransferQuote', | ||
| filterQueryOptions(options as unknown as Record<string, unknown>), | ||
| walletAddress, | ||
| networkChainId, | ||
| ] as const; | ||
| }; | ||
| export type GetGaslessJettonTransferQuoteQueryKey = readonly [ | ||
| 'gaslessJettonTransferQuote', | ||
| Compute<ExactPartial<GetGaslessJettonTransferQuoteOptions>>, | ||
| string | undefined, | ||
| string | undefined, | ||
| ]; | ||
| export type GetGaslessJettonTransferQuoteQueryOptions<selectData = GetGaslessJettonTransferQuoteData> = QueryOptions< | ||
| GetGaslessJettonTransferQuoteQueryFnData, | ||
| GetGaslessJettonTransferQuoteErrorType, | ||
| selectData, | ||
| GetGaslessJettonTransferQuoteQueryKey | ||
| >; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getGaslessProviderMetadata } from '../../actions/gasless/get-gasless-provider-metadata'; | ||
| import type { | ||
| GetGaslessProviderMetadataErrorType, | ||
| GetGaslessProviderMetadataOptions, | ||
| GetGaslessProviderMetadataReturnType, | ||
| } from '../../actions/gasless/get-gasless-provider-metadata'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| import { filterQueryOptions } from '../../utils'; | ||
| export type { GetGaslessProviderMetadataErrorType }; | ||
| export type GetGaslessProviderMetadataQueryConfig<selectData = GetGaslessProviderMetadataData> = Compute< | ||
| ExactPartial<GetGaslessProviderMetadataOptions> | ||
| > & | ||
| QueryParameter< | ||
| GetGaslessProviderMetadataQueryFnData, | ||
| GetGaslessProviderMetadataErrorType, | ||
| selectData, | ||
| GetGaslessProviderMetadataQueryKey | ||
| >; | ||
| export const getGaslessProviderMetadataQueryOptions = <selectData = GetGaslessProviderMetadataData>( | ||
| appKit: AppKit, | ||
| options: GetGaslessProviderMetadataQueryConfig<selectData> = {}, | ||
| ): GetGaslessProviderMetadataQueryOptions<selectData> => { | ||
| return { | ||
| ...options.query, | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey as [string, GetGaslessProviderMetadataOptions]; | ||
| return getGaslessProviderMetadata(appKit, parameters); | ||
| }, | ||
| queryKey: getGaslessProviderMetadataQueryKey(options), | ||
| }; | ||
| }; | ||
| export type GetGaslessProviderMetadataQueryFnData = Compute<Awaited<GetGaslessProviderMetadataReturnType>>; | ||
| export type GetGaslessProviderMetadataData = GetGaslessProviderMetadataQueryFnData; | ||
| export const getGaslessProviderMetadataQueryKey = ( | ||
| options: Compute<ExactPartial<GetGaslessProviderMetadataOptions>> = {}, | ||
| ): GetGaslessProviderMetadataQueryKey => { | ||
| return ['gaslessProviderMetadata', filterQueryOptions(options as unknown as Record<string, unknown>)] as const; | ||
| }; | ||
| export type GetGaslessProviderMetadataQueryKey = readonly [ | ||
| 'gaslessProviderMetadata', | ||
| Compute<ExactPartial<GetGaslessProviderMetadataOptions>>, | ||
| ]; | ||
| export type GetGaslessProviderMetadataQueryOptions<selectData = GetGaslessProviderMetadataData> = QueryOptions< | ||
| GetGaslessProviderMetadataQueryFnData, | ||
| GetGaslessProviderMetadataErrorType, | ||
| selectData, | ||
| GetGaslessProviderMetadataQueryKey | ||
| >; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { getGaslessQuote } from '../../actions/gasless/get-gasless-quote'; | ||
| import type { | ||
| GetGaslessQuoteErrorType, | ||
| GetGaslessQuoteOptions, | ||
| GetGaslessQuoteReturnType, | ||
| } from '../../actions/gasless/get-gasless-quote'; | ||
| import { getSelectedWallet } from '../../actions/wallets/get-selected-wallet'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { QueryOptions, QueryParameter } from '../../types/query'; | ||
| import type { Compute, ExactPartial } from '../../types/utils'; | ||
| import { filterQueryOptions } from '../../utils'; | ||
| export type { GetGaslessQuoteErrorType }; | ||
| /** | ||
| * Default time-to-live for a gasless quote. The relayer returns its own | ||
| * `validUntil`; this is the upper bound used by react-query to refresh the | ||
| * quote before it expires. | ||
| */ | ||
| export const GASLESS_QUOTE_STALE_TIME_MS = 2 * 60 * 1000; | ||
| export type GetGaslessQuoteQueryConfig<selectData = GetGaslessQuoteData> = Compute< | ||
| ExactPartial<GetGaslessQuoteOptions> | ||
| > & | ||
| QueryParameter<GetGaslessQuoteQueryFnData, GetGaslessQuoteErrorType, selectData, GetGaslessQuoteQueryKey>; | ||
| export const getGaslessQuoteQueryOptions = <selectData = GetGaslessQuoteData>( | ||
| appKit: AppKit, | ||
| options: GetGaslessQuoteQueryConfig<selectData> = {}, | ||
| ): GetGaslessQuoteQueryOptions<selectData> => { | ||
| // The quote is bound to the selected wallet's address and network, both of | ||
| // which `getGaslessQuote` resolves internally. Fold them into the key so a | ||
| // wallet/network switch produces a distinct cache entry and refetch instead | ||
| // of silently serving a quote issued for a different wallet. | ||
| const wallet = getSelectedWallet(appKit); | ||
| const walletAddress = wallet?.getAddress(); | ||
| const resolvedOptions = { ...options, network: options.network ?? wallet?.getNetwork() }; | ||
| return { | ||
| staleTime: GASLESS_QUOTE_STALE_TIME_MS, | ||
| ...options.query, | ||
| // `feeAsset` is intentionally not part of the gate: free / sponsored | ||
| // providers accept an undefined asset, and jetton-only providers throw | ||
| // a typed error themselves. We require messages and a connected wallet — | ||
| // the action resolves the wallet internally and throws without one, so | ||
| // gating here keeps the query idle instead of erroring (matches the | ||
| // jetton/ton transfer-quote options). | ||
| enabled: Boolean( | ||
| options.messages && options.messages.length > 0 && walletAddress && (options.query?.enabled ?? true), | ||
| ), | ||
| queryFn: async (context) => { | ||
| const [, parameters] = context.queryKey as [string, GetGaslessQuoteOptions, string | undefined]; | ||
| if (!parameters.messages || parameters.messages.length === 0) { | ||
| throw new Error('messages is required'); | ||
| } | ||
| return getGaslessQuote(appKit, parameters); | ||
| }, | ||
| queryKey: getGaslessQuoteQueryKey(resolvedOptions, walletAddress), | ||
| }; | ||
| }; | ||
| export type GetGaslessQuoteQueryFnData = Compute<Awaited<GetGaslessQuoteReturnType>>; | ||
| export type GetGaslessQuoteData = GetGaslessQuoteQueryFnData; | ||
| export const getGaslessQuoteQueryKey = ( | ||
| options: Compute<ExactPartial<GetGaslessQuoteOptions>> = {}, | ||
| walletAddress?: string, | ||
| ): GetGaslessQuoteQueryKey => { | ||
| return ['gaslessQuote', filterQueryOptions(options as unknown as Record<string, unknown>), walletAddress] as const; | ||
| }; | ||
| export type GetGaslessQuoteQueryKey = readonly [ | ||
| 'gaslessQuote', | ||
| Compute<ExactPartial<GetGaslessQuoteOptions>>, | ||
| string | undefined, | ||
| ]; | ||
| export type GetGaslessQuoteQueryOptions<selectData = GetGaslessQuoteData> = QueryOptions< | ||
| GetGaslessQuoteQueryFnData, | ||
| GetGaslessQuoteErrorType, | ||
| selectData, | ||
| GetGaslessQuoteQueryKey | ||
| >; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { MutateOptions, MutationOptions } from '@tanstack/query-core'; | ||
| import { sendGaslessTransaction } from '../../actions/gasless/send-gasless-transaction'; | ||
| import type { | ||
| SendGaslessTransactionErrorType, | ||
| SendGaslessTransactionParameters, | ||
| SendGaslessTransactionReturnType, | ||
| } from '../../actions/gasless/send-gasless-transaction'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { MutationParameter } from '../../types/query'; | ||
| import type { Compute } from '../../types/utils'; | ||
| export type { SendGaslessTransactionErrorType }; | ||
| export type SendGaslessTransactionMutationConfig<context = unknown> = MutationParameter< | ||
| SendGaslessTransactionData, | ||
| SendGaslessTransactionErrorType, | ||
| SendGaslessTransactionVariables, | ||
| context | ||
| >; | ||
| export const sendGaslessTransactionMutationOptions = <context = unknown>( | ||
| appKit: AppKit, | ||
| config: SendGaslessTransactionMutationConfig<context> = {}, | ||
| ): SendGaslessTransactionMutationOptions<context> => { | ||
| return { | ||
| ...config.mutation, | ||
| mutationFn(variables) { | ||
| return sendGaslessTransaction(appKit, variables); | ||
| }, | ||
| mutationKey: ['sendGaslessTransaction'], | ||
| }; | ||
| }; | ||
| export type SendGaslessTransactionVariables = Compute<SendGaslessTransactionParameters>; | ||
| export type SendGaslessTransactionData = Compute<Awaited<SendGaslessTransactionReturnType>>; | ||
| export type SendGaslessTransactionMutate<context = unknown> = ( | ||
| variables: SendGaslessTransactionVariables, | ||
| options?: | ||
| | Compute< | ||
| MutateOptions< | ||
| SendGaslessTransactionData, | ||
| SendGaslessTransactionErrorType, | ||
| SendGaslessTransactionVariables, | ||
| context | ||
| > | ||
| > | ||
| | undefined, | ||
| ) => void; | ||
| export type SendGaslessTransactionMutateAsync<context = unknown> = ( | ||
| variables: SendGaslessTransactionVariables, | ||
| options?: | ||
| | Compute< | ||
| MutateOptions< | ||
| SendGaslessTransactionData, | ||
| SendGaslessTransactionErrorType, | ||
| SendGaslessTransactionVariables, | ||
| context | ||
| > | ||
| > | ||
| | undefined, | ||
| ) => Promise<SendGaslessTransactionData>; | ||
| export type SendGaslessTransactionMutationOptions<context = unknown> = MutationOptions< | ||
| SendGaslessTransactionData, | ||
| SendGaslessTransactionErrorType, | ||
| SendGaslessTransactionVariables, | ||
| context | ||
| >; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import type { MutateOptions, MutationOptions } from '@tanstack/query-core'; | ||
| import { signMessage } from '../../actions/transaction/sign-message'; | ||
| import type { | ||
| SignMessageErrorType, | ||
| SignMessageParameters, | ||
| SignMessageReturnType, | ||
| } from '../../actions/transaction/sign-message'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
| import type { MutationParameter } from '../../types/query'; | ||
| import type { Compute } from '../../types/utils'; | ||
| export type { SignMessageErrorType, SignMessageParameters, SignMessageReturnType }; | ||
| export type SignMessageOptions<context = unknown> = MutationParameter< | ||
| SignMessageData, | ||
| SignMessageErrorType, | ||
| SignMessageVariables, | ||
| context | ||
| >; | ||
| export const signMessageMutationOptions = <context = unknown>( | ||
| appKit: AppKit, | ||
| options: SignMessageOptions<context> = {}, | ||
| ): SignMessageMutationOptions<context> => { | ||
| return { | ||
| ...options.mutation, | ||
| mutationFn(variables) { | ||
| return signMessage(appKit, variables); | ||
| }, | ||
| mutationKey: ['signMessage'], | ||
| }; | ||
| }; | ||
| export type SignMessageMutationOptions<context = unknown> = MutationOptions< | ||
| SignMessageData, | ||
| SignMessageErrorType, | ||
| SignMessageVariables, | ||
| context | ||
| >; | ||
| export type SignMessageData = Compute<SignMessageReturnType>; | ||
| export type SignMessageVariables = SignMessageParameters; | ||
| export type SignMessageMutate<context = unknown> = ( | ||
| variables: SignMessageVariables, | ||
| options?: | ||
| | Compute<MutateOptions<SignMessageData, SignMessageErrorType, Compute<SignMessageVariables>, context>> | ||
| | undefined, | ||
| ) => void; | ||
| export type SignMessageMutateAsync<context = unknown> = ( | ||
| variables: SignMessageVariables, | ||
| options?: | ||
| | Compute<MutateOptions<SignMessageData, SignMessageErrorType, Compute<SignMessageVariables>, context>> | ||
| | undefined, | ||
| ) => Promise<SignMessageData>; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { checkTonBalance } from './check-ton-balance'; | ||
| /** 0.01 TON in nanos — a reasonable buffer for unit tests. */ | ||
| const BUFFER = 10_000_000n; | ||
| const msg = (amountNanos: bigint) => ({ amount: amountNanos.toString() }); | ||
| describe('checkTonBalance', () => { | ||
| describe('balance is sufficient', () => { | ||
| it('returns undefined when balance exceeds outflow + buffer', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50_000_000n)], // 0.05 TON outflow | ||
| tonBalance: '1', // 1 TON | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| it('returns undefined when balance equals exactly (required = balance)', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50_000_000n)], // 0.05 TON | ||
| tonBalance: '0.06', // 0.06 TON = 0.05 + 0.01 buffer | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| it('returns undefined for an empty messages array when balance covers buffer', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [], | ||
| tonBalance: '0.01', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| describe('balance is insufficient', () => { | ||
| it('returns shortfall when balance is below required', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50_000_000n)], | ||
| tonBalance: '0.05', // 0.05 TON — exactly outflow, but no headroom for buffer | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 60_000_000n }); | ||
| }); | ||
| it('returns shortfall when balance is zero', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(1_000_000n)], // 0.001 TON deploy | ||
| tonBalance: '0', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 11_000_000n }); | ||
| }); | ||
| it('sums multiple message outflows', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50_000_000n), msg(30_000_000n), msg(10_000_000n)], | ||
| tonBalance: '0.05', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 50_000_000n + 30_000_000n + 10_000_000n + BUFFER }); | ||
| }); | ||
| it('respects a smaller gasBufferNanos override', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50_000_000n)], | ||
| tonBalance: '0.05', | ||
| gasBufferNanos: 1_000_000n, // 0.001 TON buffer | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 51_000_000n }); | ||
| }); | ||
| it('triggers on a 1-nano deficit (boundary)', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50_000_000n)], | ||
| tonBalance: '0.059999999', // 1 nano short of 0.06 = 50_000_000 + 10_000_000 buffer | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: 60_000_000n }); | ||
| }); | ||
| }); | ||
| describe('unloaded balance', () => { | ||
| it('returns undefined when tonBalance is undefined (not yet loaded)', () => { | ||
| const result = checkTonBalance({ | ||
| messages: [msg(50_000_000n)], | ||
| tonBalance: undefined, | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| it('treats undefined as "unknown", not as zero — no false-positive shortfall', () => { | ||
| // If `undefined` were treated as 0n, a user with insufficient balance would already | ||
| // see a shortfall flash on first render before their real balance loads. | ||
| const result = checkTonBalance({ | ||
| messages: [msg(1_000_000_000n)], | ||
| tonBalance: undefined, | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| describe('precision', () => { | ||
| it('handles bigint values larger than Number.MAX_SAFE_INTEGER', () => { | ||
| const huge = 1_000_000_000_000_000_000n; // 1 quintillion nanos = 1 billion TON | ||
| const result = checkTonBalance({ | ||
| messages: [msg(huge)], | ||
| tonBalance: '0', | ||
| gasBufferNanos: BUFFER, | ||
| }); | ||
| expect(result).toEqual({ requiredNanos: huge + BUFFER }); | ||
| }); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { parseUnits } from '@ton/walletkit'; | ||
| export interface CheckTonBalanceParams { | ||
| /** Outgoing messages of the built transaction — each `amount` is the TON value in nanos. */ | ||
| messages: Array<{ amount: string }>; | ||
| /** | ||
| * User's TON balance as a decimal string (`formatUnits(balance, 9)` format). | ||
| * `undefined` means "not loaded yet" — function returns `undefined` (no judgement). | ||
| */ | ||
| tonBalance: string | undefined; | ||
| /** Extra TON headroom on top of total outflow. Caller-supplied — no opinion on default. */ | ||
| gasBufferNanos: bigint; | ||
| } | ||
| export interface TonBalanceShortfall { | ||
| /** Total TON the user wallet must hold for the transaction to land. */ | ||
| requiredNanos: bigint; | ||
| } | ||
| /** | ||
| * Pure balance check: does the user have enough TON for the built transaction? | ||
| * | ||
| * Returns `undefined` when the balance is sufficient OR when it hasn't loaded | ||
| * yet (treating unloaded as "unknown" rather than "zero" avoids false-positive | ||
| * shortfalls flashing on first render). | ||
| * | ||
| * No mode classification — this hook reports only "shortfall exists, here's | ||
| * how much was needed." Callers decide what to suggest (topup, gasless, | ||
| * reduce, etc.). For transfer/swap flows where the user can reduce their own | ||
| * outflow, compose this with `checkTransferBalance`. | ||
| */ | ||
| export const checkTonBalance = ({ | ||
| messages, | ||
| tonBalance, | ||
| gasBufferNanos, | ||
| }: CheckTonBalanceParams): TonBalanceShortfall | undefined => { | ||
| if (tonBalance === undefined) return undefined; | ||
| const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n); | ||
| const requiredNanos = totalOutNanos + gasBufferNanos; | ||
| const tonBalanceNanos = parseUnits(tonBalance, 9); | ||
| if (tonBalanceNanos >= requiredNanos) return undefined; | ||
| return { requiredNanos }; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { checkTransferBalance } from './check-transfer-balance'; | ||
| const BUFFER = 10_000_000n; // 0.01 TON | ||
| const TON = { address: 'ton' }; | ||
| const JETTON = { address: 'EQA_jetton_master' }; | ||
| const msg = (amountNanos: bigint) => ({ amount: amountNanos.toString() }); | ||
| describe('checkTransferBalance', () => { | ||
| describe('balance is sufficient', () => { | ||
| it('returns undefined regardless of fromToken', () => { | ||
| expect( | ||
| checkTransferBalance({ | ||
| messages: [msg(50_000_000n)], | ||
| tonBalance: '1', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.04', | ||
| }), | ||
| ).toBeUndefined(); | ||
| expect( | ||
| checkTransferBalance({ | ||
| messages: [msg(50_000_000n)], | ||
| tonBalance: '1', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }), | ||
| ).toBeUndefined(); | ||
| }); | ||
| it('returns undefined when balance is unloaded', () => { | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(50_000_000n)], | ||
| tonBalance: undefined, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.04', | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| describe('jetton outflow — always topup', () => { | ||
| it('returns topup when jetton-from has insufficient TON for gas', () => { | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(50_000_000n)], // 0.05 TON jetton-transfer gas | ||
| tonBalance: '0.02', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| expect(result).toEqual({ mode: 'topup', requiredNanos: 60_000_000n }); | ||
| }); | ||
| it('returns topup even when balance is zero', () => { | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(1_000_000n)], | ||
| tonBalance: '0', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '50', | ||
| }); | ||
| expect(result).toEqual({ mode: 'topup', requiredNanos: 11_000_000n }); | ||
| }); | ||
| it('does not consider safetyMarginNanos for jetton outflow', () => { | ||
| // safetyMarginNanos only matters in the reduce calculation — jetton can't reduce. | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(50_000_000n)], | ||
| tonBalance: '0.02', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| safetyMarginNanos: 1_000_000_000n, // 1 TON — would be huge if applied | ||
| }); | ||
| expect(result).toEqual({ mode: 'topup', requiredNanos: 60_000_000n }); | ||
| }); | ||
| }); | ||
| describe('TON outflow — reduce when gas fits', () => { | ||
| it('returns reduce with a smaller suggestedFromAmount when balance covers gas', () => { | ||
| // total_out = fromAmount + gas. User has enough for gas + buffer + safety, but | ||
| // not for full fromAmount. Suggest reduced amount. | ||
| const fromAmountNanos = 500_000_000n; // 0.5 TON intended spend | ||
| const gasOnlyNanos = 50_000_000n; // 0.05 TON gas attached to other messages | ||
| const tonBalance = '0.4'; // can't afford 0.5 spend, but enough for gas + margin | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(fromAmountNanos + gasOnlyNanos)], | ||
| tonBalance, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.5', | ||
| }); | ||
| // suggested = balance - gasOnly - gasBuffer - safetyMargin | ||
| // = 400_000_000 - 50_000_000 - 10_000_000 - 20_000_000 = 320_000_000n = 0.32 TON | ||
| expect(result).toEqual({ | ||
| mode: 'reduce', | ||
| requiredNanos: fromAmountNanos + gasOnlyNanos + BUFFER, | ||
| suggestedFromAmount: '0.32', | ||
| }); | ||
| }); | ||
| it('returns topup when even gas does not fit', () => { | ||
| // Balance below gasOnly + buffer + safetyMargin → reducing won't help. | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(500_000_000n)], // 0.5 TON total outflow | ||
| tonBalance: '0.001', // way too low for any meaningful gas | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.4', | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| expect(result?.requiredNanos).toBe(510_000_000n); | ||
| }); | ||
| it('boundary: balance equals nonSpendReserved exactly → topup', () => { | ||
| // tonBalance <= nonSpendReserved should return topup (cannot leave anything to spend). | ||
| const gasOnly = 50_000_000n; | ||
| const fromAmount = 100_000_000n; | ||
| // nonSpendReserved = gasOnly + BUFFER + DEFAULT_SAFETY_MARGIN_NANOS = 80_000_000n | ||
| const balanceAtBoundary = '0.08'; | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(gasOnly + fromAmount)], | ||
| tonBalance: balanceAtBoundary, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.1', | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| }); | ||
| it('boundary: 1-nano above nonSpendReserved → reduce', () => { | ||
| const gasOnly = 50_000_000n; | ||
| const fromAmount = 100_000_000n; | ||
| // nonSpendReserved = gasOnly + BUFFER + DEFAULT_SAFETY_MARGIN_NANOS = 80_000_000n | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(gasOnly + fromAmount)], | ||
| tonBalance: '0.080000001', // 1 nano above the boundary | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.1', | ||
| }); | ||
| // suggested = 1 nano | ||
| expect(result).toEqual({ | ||
| mode: 'reduce', | ||
| requiredNanos: gasOnly + fromAmount + BUFFER, | ||
| suggestedFromAmount: '0.000000001', | ||
| }); | ||
| }); | ||
| }); | ||
| describe('safetyMarginNanos', () => { | ||
| it('shrinks the suggested reduced amount when safetyMargin is larger', () => { | ||
| const tonBalance = '0.4'; | ||
| const baseParams = { | ||
| messages: [msg(550_000_000n)], // 0.55 TON total outflow | ||
| tonBalance, | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.5', | ||
| }; | ||
| const lowMargin = checkTransferBalance({ ...baseParams, safetyMarginNanos: 5_000_000n }); | ||
| const highMargin = checkTransferBalance({ ...baseParams, safetyMarginNanos: 50_000_000n }); | ||
| // higher safety margin → less suggested | ||
| expect(lowMargin?.mode).toBe('reduce'); | ||
| expect(highMargin?.mode).toBe('reduce'); | ||
| if (lowMargin?.mode === 'reduce' && highMargin?.mode === 'reduce') { | ||
| expect(BigInt(lowMargin.suggestedFromAmount.replace('.', '').padEnd(10, '0'))).toBeGreaterThan( | ||
| BigInt(highMargin.suggestedFromAmount.replace('.', '').padEnd(10, '0')), | ||
| ); | ||
| } | ||
| }); | ||
| it('uses DEFAULT_SAFETY_MARGIN_NANOS when not provided', () => { | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(550_000_000n)], | ||
| tonBalance: '0.4', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.5', | ||
| }); | ||
| expect(result?.mode).toBe('reduce'); | ||
| // gasOnly = 50_000_000, balance = 400_000_000 | ||
| // suggested = 400 - 50 - 10 - 20 = 320 mTON | ||
| if (result?.mode === 'reduce') { | ||
| expect(result.suggestedFromAmount).toBe('0.32'); | ||
| } | ||
| }); | ||
| }); | ||
| describe('composes checkTonBalance', () => { | ||
| it('returns undefined when checkTonBalance would (sufficient or unloaded)', () => { | ||
| // Same inputs as a sufficient-balance check | ||
| const result = checkTransferBalance({ | ||
| messages: [msg(10_000_000n)], | ||
| tonBalance: '1', | ||
| gasBufferNanos: BUFFER, | ||
| fromToken: TON, | ||
| fromAmount: '0.005', | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { formatUnits, parseUnits } from '@ton/walletkit'; | ||
| import { checkTonBalance } from './check-ton-balance'; | ||
| import type { CheckTonBalanceParams } from './check-ton-balance'; | ||
| /** | ||
| * Default headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one sent after the | ||
| * amount changes. 0.02 TON. | ||
| */ | ||
| export const DEFAULT_SAFETY_MARGIN_NANOS = 20_000_000n; | ||
| export interface CheckTransferBalanceParams extends CheckTonBalanceParams { | ||
| /** The asset being transferred / swapped. TON-from enables the `'reduce'` outcome. */ | ||
| fromToken: { address: string }; | ||
| /** Amount of `fromToken` being sent, as a decimal string in `fromToken` units. */ | ||
| fromAmount: string; | ||
| /** | ||
| * Headroom baked into the suggested reduced amount when the recovery mode is `'reduce'`. | ||
| * Defaults to {@link DEFAULT_SAFETY_MARGIN_NANOS}. | ||
| */ | ||
| safetyMarginNanos?: bigint; | ||
| } | ||
| export type TransferShortfall = | ||
| | { mode: 'reduce'; requiredNanos: bigint; suggestedFromAmount: string } | ||
| | { mode: 'topup'; requiredNanos: bigint }; | ||
| /** | ||
| * Balance check for user-initiated transfers (send TON / jetton / NFT) and swaps — | ||
| * where the user controls a `fromAmount` and might be able to fix a shortfall by | ||
| * sending less. | ||
| * | ||
| * Returns: | ||
| * - `undefined` when balance is sufficient (or unloaded — see {@link checkTonBalance}). | ||
| * - `{ mode: 'reduce', suggestedFromAmount }` only when `fromToken` is TON and the | ||
| * remaining balance can still cover gas — the user can keep going by spending less. | ||
| * - `{ mode: 'topup' }` otherwise (reducing wouldn't free up TON gas). | ||
| * | ||
| * Gasless availability is intentionally **not** modelled here — that's a UI policy. | ||
| * Caller maps `'topup'` to `'gasless'` when a gasless alternative is on the table. | ||
| */ | ||
| export const checkTransferBalance = ({ | ||
| messages, | ||
| tonBalance, | ||
| gasBufferNanos, | ||
| fromToken, | ||
| fromAmount, | ||
| safetyMarginNanos = DEFAULT_SAFETY_MARGIN_NANOS, | ||
| }: CheckTransferBalanceParams): TransferShortfall | undefined => { | ||
| const shortfall = checkTonBalance({ messages, tonBalance, gasBufferNanos }); | ||
| if (!shortfall) return undefined; | ||
| // Reducing the user's own amount only helps when the outflow is in TON. | ||
| // For jetton / NFT outflow, gas is denominated in TON regardless — reducing | ||
| // the jetton-side input doesn't free up any TON. | ||
| if (fromToken.address !== 'ton') { | ||
| return { mode: 'topup', requiredNanos: shortfall.requiredNanos }; | ||
| } | ||
| // We know `tonBalance !== undefined` because checkTonBalance returned a shortfall | ||
| // (it short-circuits on undefined balance). | ||
| const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n); | ||
| const fromAmountNanos = parseUnits(fromAmount, 9); | ||
| const gasOnlyNanos = totalOutNanos - fromAmountNanos; | ||
| const nonSpendReservedNanos = gasOnlyNanos + gasBufferNanos + safetyMarginNanos; | ||
| const tonBalanceNanos = parseUnits(tonBalance as string, 9); | ||
| if (tonBalanceNanos <= nonSpendReservedNanos) { | ||
| // Even gas doesn't fit — reducing the spend amount won't help. | ||
| return { mode: 'topup', requiredNanos: shortfall.requiredNanos }; | ||
| } | ||
| const suggestedFromAmount = formatUnits(tonBalanceNanos - nonSpendReservedNanos, 9); | ||
| return { mode: 'reduce', requiredNanos: shortfall.requiredNanos, suggestedFromAmount }; | ||
| }; |
+26
-0
| # @ton/appkit | ||
| ## 1.0.0-alpha.4 | ||
| ### Patch Changes | ||
| - a588278: Updated @tonconnect dependencies | ||
| - 912e0a2: Added gasless transactions support. A relayer pays the TON gas; the user pays a fee in a relayer-accepted jetton (e.g. USDT). See [`@ton/appkit/docs/gasless.md`](https://github.com/ton-connect/kit/blob/main/packages/appkit/docs/gasless.md) for the regular-send → gasless-send migration guide. | ||
| - `@ton/walletkit`: | ||
| - `GaslessManager` and the `GaslessProvider` abstract base — parallel to `StakingManager` / `SwapManager`. Extend `GaslessProvider` to plug in your own relayer. | ||
| - `TonApiGaslessProvider` / `createTonApiGaslessProvider()` — gasless via the TonAPI relayer. Auto-discovers networks from the kit; per-chain `apiKey` / `endpoint` overrides supported. | ||
| - `GaslessError` with `GaslessErrorCode`: `UnsupportedOperation`, `QuoteFailed`, `SendFailed`, `ConfigFailed`, `SignMessageNotSupported`, `TooManyMessages`, `QuoteExpired`, `WalletMismatch`. | ||
| - `TonApiGaslessProvider` retries transient (5xx / network) failures for both quote and send — configurable via `quoteRetries` / `quoteRetryDelayMs` and `sendRetries` / `sendRetryDelayMs` on `createTonApiGaslessProvider`. | ||
| - Wallet-feature helpers: `hasSignMessageSupport(features)` (whether a wallet's advertised features include `SignMessage`, the capability gasless requires) and `getMaxOutgoingMessages(features, featureName?)` — now takes an optional feature name so it reads the `maxMessages` cap of either `SendTransaction` (default) or `SignMessage`. | ||
| - `@ton/appkit`: | ||
| - Actions: `getGaslessConfig`, `getGaslessQuote`, `getGaslessJettonTransferQuote`, `sendGaslessTransaction`, `getGaslessProviderMetadata`, plus provider management (`getGaslessManager`, `getGaslessProvider(s)`, `setDefaultGaslessProvider`, `watchGaslessProviders`). | ||
| - `getGaslessJettonTransferQuote` is a convenience wrapper: takes `jettonAddress`/`recipientAddress`/`amount`/`feeAsset` and builds the transfer messages for you, routing the jetton `excess` back to the relayer. The two-step quote → `sendGaslessTransaction` flow is preserved. | ||
| - `sendGaslessTransaction` runs fail-fast guards before prompting the wallet — throws `GaslessError(QUOTE_EXPIRED)`, `WALLET_MISMATCH`, `SIGN_MESSAGE_NOT_SUPPORTED`, or `TOO_MANY_MESSAGES` so the user is not asked to sign a quote the relayer would reject. | ||
| - Quote queries are wallet- and network-bound: switching wallet or network refetches a fresh quote instead of serving one issued for the previous wallet. | ||
| - New `signMessage` action — signs a transaction-shaped request without broadcasting, returning a signed BoC a relayer can submit on-chain (the same `signMessage` primitive the gasless flow signs with). `TonConnectWalletAdapter` now implements `signMessage` and `getSupportedFeatures`. | ||
| - `getSignMessageSupport` / `watchSignMessageSupport` actions — whether the selected wallet supports `SignMessage`, for gating the gasless UI (fail-closed when no wallet is connected). | ||
| - `@ton/appkit-react`: | ||
| - Hooks: `useGaslessConfig`, `useGaslessQuote`, `useGaslessJettonTransferQuote`, `useSendGaslessTransaction`, `useGaslessProviderMetadata`, `useGaslessProvider(s)`, `useSignMessage`. Quote hooks auto-refetch on wallet/network switch. | ||
| - `useSignMessageSupport` hook — reactive check whether the selected wallet supports `SignMessage` (gates the gasless toggle/UI; re-evaluates on wallet switch). | ||
| - Updated dependencies [912e0a2] | ||
| - @ton/walletkit@1.0.0-alpha.4 | ||
| ## 1.0.0-alpha.3 | ||
@@ -4,0 +30,0 @@ |
@@ -42,2 +42,12 @@ /** | ||
| export { registerProvider, type RegisterProviderOptions } from './providers/register-provider'; | ||
| export { getGaslessManager, type GetGaslessManagerReturnType } from './gasless/get-gasless-manager'; | ||
| export { getGaslessProvider, type GetGaslessProviderOptions, type GetGaslessProviderReturnType, } from './gasless/get-gasless-provider'; | ||
| export { getGaslessProviders, type GetGaslessProvidersReturnType } from './gasless/get-gasless-providers'; | ||
| export { setDefaultGaslessProvider, type SetDefaultGaslessProviderParameters, type SetDefaultGaslessProviderReturnType, } from './gasless/set-default-gasless-provider'; | ||
| export { watchGaslessProviders, type WatchGaslessProvidersParameters, type WatchGaslessProvidersReturnType, } from './gasless/watch-gasless-providers'; | ||
| export { getGaslessConfig, type GetGaslessConfigOptions, type GetGaslessConfigReturnType, type GetGaslessConfigErrorType, } from './gasless/get-gasless-config'; | ||
| export { getGaslessProviderMetadata, type GetGaslessProviderMetadataOptions, type GetGaslessProviderMetadataReturnType, type GetGaslessProviderMetadataErrorType, } from './gasless/get-gasless-provider-metadata'; | ||
| export { getGaslessQuote, type GetGaslessQuoteOptions, type GetGaslessQuoteReturnType, type GetGaslessQuoteErrorType, } from './gasless/get-gasless-quote'; | ||
| export { getGaslessJettonTransferQuote, type GetGaslessJettonTransferQuoteOptions, type GetGaslessJettonTransferQuoteReturnType, type GetGaslessJettonTransferQuoteErrorType, } from './gasless/get-gasless-jetton-transfer-quote'; | ||
| export { sendGaslessTransaction, type SendGaslessTransactionParameters, type SendGaslessTransactionReturnType, type SendGaslessTransactionErrorType, } from './gasless/send-gasless-transaction'; | ||
| export { signText, type SignTextParameters, type SignTextReturnType } from './signing/sign-text'; | ||
@@ -64,2 +74,3 @@ export { signBinary, type SignBinaryParameters, type SignBinaryReturnType } from './signing/sign-binary'; | ||
| export { sendTransaction, type SendTransactionParameters, type SendTransactionReturnType, } from './transaction/send-transaction'; | ||
| export { signMessage, type SignMessageParameters, type SignMessageReturnType, type SignMessageErrorType, } from './transaction/sign-message'; | ||
| export { transferTon, type TransferTonParameters, type TransferTonReturnType } from './transaction/transfer-ton'; | ||
@@ -75,3 +86,5 @@ export { getTransactionStatus, type GetTransactionStatusParameters, type GetTransactionStatusReturnType, type GetTransactionStatusErrorType, } from './transaction/get-transaction-status'; | ||
| export { watchSelectedWallet, type WatchSelectedWalletParameters, type WatchSelectedWalletReturnType, } from './wallets/watch-selected-wallet'; | ||
| export { getSignMessageSupport, type GetSignMessageSupportReturnType } from './wallets/get-sign-message-support'; | ||
| export { watchSignMessageSupport, type WatchSignMessageSupportParameters, type WatchSignMessageSupportReturnType, } from './wallets/watch-sign-message-support'; | ||
| export { watchConnectedWallets, type WatchConnectedWalletsParameters, type WatchConnectedWalletsReturnType, } from './wallets/watch-connected-wallets'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACH,mBAAmB,EACnB,KAAK,0B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EACjB,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,GACnC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,4BAA4B,EAC5B,KAAK,sCAAsC,EAC3C,KAAK,sCAAsC,GAC9C,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,4BAA4B,EAC5B,KAAK,sCAAsC,EAC3C,KAAK,sCAAsC,GAC9C,MAAM,+CAA+C,CAAC;AAGvD,OAAO,EAAE,mBAAmB,EAAE,KAAK,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,KAAK,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,EACH,mBAAmB,EACnB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,GACrC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,mBAAmB,EACnB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,GACrC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,KAAK,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AACjH,OAAO,EACH,uBAAuB,EACvB,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,GACzC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,qBAAqB,EACrB,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,GACvC,MAAM,mCAAmC,CAAC"} |
@@ -10,4 +10,4 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getStakingQuote = exports.watchStakingProviders = exports.setDefaultStakingProvider = exports.getStakingProvider = exports.getStakingProviders = exports.getStakingManager = exports.buildSwapTransaction = exports.watchSwapProviders = exports.getSwapQuote = exports.setDefaultSwapProvider = exports.getSwapProviders = exports.getSwapProvider = exports.getSwapManager = exports.signCell = exports.signBinary = exports.signText = exports.registerProvider = exports.transferNft = exports.getNft = exports.getNfts = exports.getNftsByAddress = exports.hasStreamingProvider = exports.watchDefaultNetwork = exports.setDefaultNetwork = exports.getDefaultNetwork = exports.getBlockNumber = exports.watchNetworks = exports.getApiClient = exports.getNetwork = exports.getNetworks = exports.transferJetton = exports.createTransferJettonTransaction = exports.watchJettons = exports.getJettons = exports.watchJettonsByAddress = exports.getJettonsByAddress = exports.getJettonBalance = exports.getJettonWalletAddress = exports.getJettonInfo = exports.watchConnectorById = exports.getConnectorById = exports.watchConnectors = exports.getConnectors = exports.disconnect = exports.connect = exports.addConnector = exports.watchBalance = exports.getBalance = exports.watchBalanceByAddress = exports.getBalanceByAddress = void 0; | ||
| exports.watchConnectedWallets = exports.watchSelectedWallet = exports.setSelectedWalletId = exports.getSelectedWallet = exports.getConnectedWallets = exports.createTransferTonTransaction = exports.createTransferNftTransaction = exports.watchTransactions = exports.watchTransactionsByAddress = exports.getTransactionStatus = exports.transferTon = exports.sendTransaction = exports.getStakingProviderMetadata = exports.getStakingProviderInfo = exports.getStakedBalance = exports.buildStakeTransaction = void 0; | ||
| exports.getSwapProviders = exports.getSwapProvider = exports.getSwapManager = exports.signCell = exports.signBinary = exports.signText = exports.sendGaslessTransaction = exports.getGaslessJettonTransferQuote = exports.getGaslessQuote = exports.getGaslessProviderMetadata = exports.getGaslessConfig = exports.watchGaslessProviders = exports.setDefaultGaslessProvider = exports.getGaslessProviders = exports.getGaslessProvider = exports.getGaslessManager = exports.registerProvider = exports.transferNft = exports.getNft = exports.getNfts = exports.getNftsByAddress = exports.hasStreamingProvider = exports.watchDefaultNetwork = exports.setDefaultNetwork = exports.getDefaultNetwork = exports.getBlockNumber = exports.watchNetworks = exports.getApiClient = exports.getNetwork = exports.getNetworks = exports.transferJetton = exports.createTransferJettonTransaction = exports.watchJettons = exports.getJettons = exports.watchJettonsByAddress = exports.getJettonsByAddress = exports.getJettonBalance = exports.getJettonWalletAddress = exports.getJettonInfo = exports.watchConnectorById = exports.getConnectorById = exports.watchConnectors = exports.getConnectors = exports.disconnect = exports.connect = exports.addConnector = exports.watchBalance = exports.getBalance = exports.watchBalanceByAddress = exports.getBalanceByAddress = void 0; | ||
| exports.watchConnectedWallets = exports.watchSignMessageSupport = exports.getSignMessageSupport = exports.watchSelectedWallet = exports.setSelectedWalletId = exports.getSelectedWallet = exports.getConnectedWallets = exports.createTransferTonTransaction = exports.createTransferNftTransaction = exports.watchTransactions = exports.watchTransactionsByAddress = exports.getTransactionStatus = exports.transferTon = exports.signMessage = exports.sendTransaction = exports.getStakingProviderMetadata = exports.getStakingProviderInfo = exports.getStakedBalance = exports.buildStakeTransaction = exports.getStakingQuote = exports.watchStakingProviders = exports.setDefaultStakingProvider = exports.getStakingProvider = exports.getStakingProviders = exports.getStakingManager = exports.buildSwapTransaction = exports.watchSwapProviders = exports.getSwapQuote = exports.setDefaultSwapProvider = void 0; | ||
| // Balances | ||
@@ -87,2 +87,23 @@ var get_balance_by_address_1 = require("./balances/get-balance-by-address"); | ||
| Object.defineProperty(exports, "registerProvider", { enumerable: true, get: function () { return register_provider_1.registerProvider; } }); | ||
| // Gasless | ||
| var get_gasless_manager_1 = require("./gasless/get-gasless-manager"); | ||
| Object.defineProperty(exports, "getGaslessManager", { enumerable: true, get: function () { return get_gasless_manager_1.getGaslessManager; } }); | ||
| var get_gasless_provider_1 = require("./gasless/get-gasless-provider"); | ||
| Object.defineProperty(exports, "getGaslessProvider", { enumerable: true, get: function () { return get_gasless_provider_1.getGaslessProvider; } }); | ||
| var get_gasless_providers_1 = require("./gasless/get-gasless-providers"); | ||
| Object.defineProperty(exports, "getGaslessProviders", { enumerable: true, get: function () { return get_gasless_providers_1.getGaslessProviders; } }); | ||
| var set_default_gasless_provider_1 = require("./gasless/set-default-gasless-provider"); | ||
| Object.defineProperty(exports, "setDefaultGaslessProvider", { enumerable: true, get: function () { return set_default_gasless_provider_1.setDefaultGaslessProvider; } }); | ||
| var watch_gasless_providers_1 = require("./gasless/watch-gasless-providers"); | ||
| Object.defineProperty(exports, "watchGaslessProviders", { enumerable: true, get: function () { return watch_gasless_providers_1.watchGaslessProviders; } }); | ||
| var get_gasless_config_1 = require("./gasless/get-gasless-config"); | ||
| Object.defineProperty(exports, "getGaslessConfig", { enumerable: true, get: function () { return get_gasless_config_1.getGaslessConfig; } }); | ||
| var get_gasless_provider_metadata_1 = require("./gasless/get-gasless-provider-metadata"); | ||
| Object.defineProperty(exports, "getGaslessProviderMetadata", { enumerable: true, get: function () { return get_gasless_provider_metadata_1.getGaslessProviderMetadata; } }); | ||
| var get_gasless_quote_1 = require("./gasless/get-gasless-quote"); | ||
| Object.defineProperty(exports, "getGaslessQuote", { enumerable: true, get: function () { return get_gasless_quote_1.getGaslessQuote; } }); | ||
| var get_gasless_jetton_transfer_quote_1 = require("./gasless/get-gasless-jetton-transfer-quote"); | ||
| Object.defineProperty(exports, "getGaslessJettonTransferQuote", { enumerable: true, get: function () { return get_gasless_jetton_transfer_quote_1.getGaslessJettonTransferQuote; } }); | ||
| var send_gasless_transaction_1 = require("./gasless/send-gasless-transaction"); | ||
| Object.defineProperty(exports, "sendGaslessTransaction", { enumerable: true, get: function () { return send_gasless_transaction_1.sendGaslessTransaction; } }); | ||
| // Signing | ||
@@ -134,2 +155,4 @@ var sign_text_1 = require("./signing/sign-text"); | ||
| Object.defineProperty(exports, "sendTransaction", { enumerable: true, get: function () { return send_transaction_1.sendTransaction; } }); | ||
| var sign_message_1 = require("./transaction/sign-message"); | ||
| Object.defineProperty(exports, "signMessage", { enumerable: true, get: function () { return sign_message_1.signMessage; } }); | ||
| var transfer_ton_1 = require("./transaction/transfer-ton"); | ||
@@ -156,3 +179,7 @@ Object.defineProperty(exports, "transferTon", { enumerable: true, get: function () { return transfer_ton_1.transferTon; } }); | ||
| Object.defineProperty(exports, "watchSelectedWallet", { enumerable: true, get: function () { return watch_selected_wallet_1.watchSelectedWallet; } }); | ||
| var get_sign_message_support_1 = require("./wallets/get-sign-message-support"); | ||
| Object.defineProperty(exports, "getSignMessageSupport", { enumerable: true, get: function () { return get_sign_message_support_1.getSignMessageSupport; } }); | ||
| var watch_sign_message_support_1 = require("./wallets/watch-sign-message-support"); | ||
| Object.defineProperty(exports, "watchSignMessageSupport", { enumerable: true, get: function () { return watch_sign_message_support_1.watchSignMessageSupport; } }); | ||
| var watch_connected_wallets_1 = require("./wallets/watch-connected-wallets"); | ||
| Object.defineProperty(exports, "watchConnectedWallets", { enumerable: true, get: function () { return watch_connected_wallets_1.watchConnectedWallets; } }); |
@@ -16,2 +16,3 @@ /** | ||
| comment?: string; | ||
| responseDestination?: string; | ||
| } | ||
@@ -18,0 +19,0 @@ export type CreateTransferJettonTransactionReturnType = TransactionRequest; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"create-transfer-jetton-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/jettons/create-transfer-jetton-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,WAAW,yCAAyC;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,yCAAyC,GAAG,kBAAkB,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,+BAA+B,GACxC,QAAQ,MAAM,EACd,YAAY,yCAAyC,KACtD,OAAO,CAAC,yCAAyC,CA4CnD,CAAC"} | ||
| {"version":3,"file":"create-transfer-jetton-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/jettons/create-transfer-jetton-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,WAAW,yCAAyC;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,MAAM,yCAAyC,GAAG,kBAAkB,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,+BAA+B,GACxC,QAAQ,MAAM,EACd,YAAY,yCAAyC,KACtD,OAAO,CAAC,yCAAyC,CA4CnD,CAAC"} |
@@ -19,3 +19,3 @@ "use strict"; | ||
| const createTransferJettonTransaction = async (appKit, parameters) => { | ||
| const { jettonAddress, recipientAddress, amount, jettonDecimals, comment } = parameters; | ||
| const { jettonAddress, recipientAddress, amount, jettonDecimals, comment, responseDestination } = parameters; | ||
| const wallet = (0, get_selected_wallet_1.getSelectedWallet)(appKit); | ||
@@ -43,3 +43,3 @@ if (!wallet) { | ||
| destination: recipientAddress, | ||
| responseDestination: ownerAddress, | ||
| responseDestination: responseDestination ?? ownerAddress, | ||
| comment, | ||
@@ -46,0 +46,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"create-transfer-ton-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/transaction/create-transfer-ton-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAA6B,MAAM,yBAAyB,CAAC;AAC7F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,WAAW,sCAAsC;IACnD,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,sCAAsC,GAAG,kBAAkB,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACrC,QAAQ,MAAM,EACd,YAAY,sCAAsC,KACnD,sCA2BF,CAAC"} | ||
| {"version":3,"file":"create-transfer-ton-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/transaction/create-transfer-ton-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAA6B,MAAM,yBAAyB,CAAC;AAE7F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,WAAW,sCAAsC;IACnD,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,sCAAsC,GAAG,kBAAkB,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACrC,QAAQ,MAAM,EACd,YAAY,sCAAsC,KACnD,sCA2BF,CAAC"} |
@@ -12,2 +12,3 @@ "use strict"; | ||
| const walletkit_1 = require("@ton/walletkit"); | ||
| const utils_1 = require("../../utils"); | ||
| const get_selected_wallet_1 = require("../wallets/get-selected-wallet"); | ||
@@ -26,7 +27,7 @@ /** | ||
| amount: (0, walletkit_1.parseUnits)(amount, 9).toString(), | ||
| stateInit, | ||
| stateInit: stateInit ? (0, utils_1.asBase64)(stateInit) : undefined, | ||
| }; | ||
| // Payload takes priority, otherwise use comment | ||
| if (payload) { | ||
| message.payload = payload; | ||
| message.payload = (0, utils_1.asBase64)(payload); | ||
| } | ||
@@ -33,0 +34,0 @@ else if (comment) { |
@@ -9,7 +9,7 @@ /** | ||
| import type { Wallet as TonConnectWallet } from '@tonconnect/sdk'; | ||
| import type { SendTransactionResponse, UserFriendlyAddress, Hex } from '@ton/walletkit'; | ||
| import type { Feature, SendTransactionResponse, UserFriendlyAddress, Hex } from '@ton/walletkit'; | ||
| import type { TonConnectUI } from '@tonconnect/ui'; | ||
| import type { TransactionRequest } from '../../../types/transaction'; | ||
| import type { WalletInterface } from '../../../types/wallet'; | ||
| import type { SignDataRequest, SignDataResponse } from '../../../types/signing'; | ||
| import type { SignDataRequest, SignDataResponse, SignMessageResponse } from '../../../types/signing'; | ||
| import { Network } from '../../../types/network'; | ||
@@ -37,6 +37,9 @@ /** | ||
| getWalletId(): string; | ||
| getSupportedFeatures(): Feature[] | undefined; | ||
| sendTransaction(request: TransactionRequest): Promise<SendTransactionResponse>; | ||
| signMessage(request: TransactionRequest): Promise<SignMessageResponse>; | ||
| signData(payload: SignDataRequest): Promise<SignDataResponse>; | ||
| private mapTransactionRequest; | ||
| private mapSignDataRequest; | ||
| } | ||
| //# sourceMappingURL=ton-connect-wallet-adapter.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"ton-connect-wallet-adapter.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/tonconnect/adapters/ton-connect-wallet-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAExF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAC3D,SAAgB,gBAAgB,EAAE,gBAAgB,CAAC;IACnD,SAAgB,YAAY,EAAE,YAAY,CAAC;IAC3C,SAAgB,WAAW,EAAE,MAAM,CAAC;gBAExB,MAAM,EAAE,6BAA6B;IAUjD,UAAU,IAAI,mBAAmB;IAQjC,YAAY,IAAI,GAAG;IAQnB,UAAU,IAAI,OAAO;IAKrB,WAAW,IAAI,MAAM;IAQf,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAsB9E,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgBnE,OAAO,CAAC,kBAAkB;CAmC7B"} | ||
| {"version":3,"file":"ton-connect-wallet-adapter.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/tonconnect/adapters/ton-connect-wallet-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,KAAK,EAAE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAC3D,SAAgB,gBAAgB,EAAE,gBAAgB,CAAC;IACnD,SAAgB,YAAY,EAAE,YAAY,CAAC;IAC3C,SAAgB,WAAW,EAAE,MAAM,CAAC;gBAExB,MAAM,EAAE,6BAA6B;IAUjD,UAAU,IAAI,mBAAmB;IAQjC,YAAY,IAAI,GAAG;IAQnB,UAAU,IAAI,OAAO;IAKrB,WAAW,IAAI,MAAM;IAIrB,oBAAoB,IAAI,OAAO,EAAE,GAAG,SAAS;IAQvC,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAa9E,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUtE,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgBnE,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,kBAAkB;CAmC7B"} |
@@ -49,2 +49,5 @@ "use strict"; | ||
| } | ||
| getSupportedFeatures() { | ||
| return this.tonConnectWallet.device?.features; | ||
| } | ||
| // ========================================== | ||
@@ -54,12 +57,3 @@ // Signing / Transactions | ||
| async sendTransaction(request) { | ||
| const transaction = { | ||
| validUntil: request.validUntil || (0, transaction_1.getValidUntil)(), | ||
| messages: request.messages.map((msg) => ({ | ||
| address: msg.address, | ||
| amount: String(msg.amount), | ||
| payload: msg.payload, | ||
| stateInit: msg.stateInit, | ||
| })), | ||
| network: request.network?.chainId ?? this.tonConnectWallet.account?.chain, | ||
| }; | ||
| const transaction = this.mapTransactionRequest(request); | ||
| const result = await this.tonConnectUI.sendTransaction(transaction); | ||
@@ -73,2 +67,9 @@ const { hash, boc: normalizedBoc } = (0, walletkit_1.getNormalizedExtMessageHash)(result.boc); | ||
| } | ||
| async signMessage(request) { | ||
| const message = this.mapTransactionRequest(request); | ||
| const result = await this.tonConnectUI.signMessage(message); | ||
| return { | ||
| internalBoc: (0, walletkit_1.asBase64)(result.internalBoc), | ||
| }; | ||
| } | ||
| async signData(payload) { | ||
@@ -87,2 +88,14 @@ const result = await this.tonConnectUI.signData(this.mapSignDataRequest(payload)); | ||
| // ========================================== | ||
| mapTransactionRequest(request) { | ||
| return { | ||
| validUntil: request.validUntil || (0, transaction_1.getValidUntil)(), | ||
| messages: request.messages.map((msg) => ({ | ||
| address: msg.address, | ||
| amount: String(msg.amount), | ||
| payload: msg.payload, | ||
| stateInit: msg.stateInit, | ||
| })), | ||
| network: request.network?.chainId ?? this.tonConnectWallet.account?.chain, | ||
| }; | ||
| } | ||
| mapSignDataRequest(request) { | ||
@@ -89,0 +102,0 @@ const chainId = request.network?.chainId ?? this.getNetwork().chainId; |
@@ -12,2 +12,3 @@ /** | ||
| import { StakingManager } from '../../../staking'; | ||
| import { GaslessManager } from '../../../gasless'; | ||
| import type { Connector, ConnectorFactoryContext, ConnectorInput } from '../../../types/connector'; | ||
@@ -29,2 +30,3 @@ import type { AppKitEmitter } from '../types/events'; | ||
| readonly stakingManager: StakingManager; | ||
| readonly gaslessManager: GaslessManager; | ||
| readonly networkManager: AppKitNetworkManager; | ||
@@ -31,0 +33,0 @@ readonly streamingManager: StreamingManager; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"app-kit.d.ts","sourceRoot":"","sources":["../../../../../src/core/app-kit/services/app-kit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAsE,MAAM,gBAAgB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,MAAM,EAAE,YAAY;IAiChC,oBAAoB,IAAI,uBAAuB;IAI/C;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,IAAI;IAkB/C;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAY3C;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,IAAI;IAoB5D;;OAEG;IACH,OAAO,CAAC,2BAA2B;CAWtC"} |
@@ -14,2 +14,3 @@ "use strict"; | ||
| const staking_1 = require("../../../staking"); | ||
| const gasless_1 = require("../../../gasless"); | ||
| const emitter_1 = require("../../emitter"); | ||
@@ -39,2 +40,3 @@ const wallets_manager_1 = require("../../wallets-manager"); | ||
| this.stakingManager = new staking_1.StakingManager(() => this.createFactoryContext()); | ||
| this.gaslessManager = new gasless_1.GaslessManager(() => this.createFactoryContext()); | ||
| this.streamingManager = new walletkit_1.StreamingManager(() => this.createFactoryContext()); | ||
@@ -100,2 +102,5 @@ if (config.connectors) { | ||
| break; | ||
| case 'gasless': | ||
| this.gaslessManager.registerProvider(provider); | ||
| break; | ||
| default: | ||
@@ -102,0 +107,0 @@ throw new Error('Unknown provider type'); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"wallets-manager.d.ts","sourceRoot":"","sources":["../../../../../src/core/wallets-manager/services/wallets-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,OAAO,CAAgB;gBAEnB,OAAO,EAAE,aAAa;IAMlC;;OAEG;IACH,IAAI,OAAO,IAAI,eAAe,EAAE,CAE/B;IAED;;OAEG;IACH,IAAI,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEpC;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,eAAe,GAAG,IAAI,CAM3C;IAED;;OAEG;IACH,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAI5C;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI;CAwB/C"} | ||
| {"version":3,"file":"wallets-manager.d.ts","sourceRoot":"","sources":["../../../../../src/core/wallets-manager/services/wallets-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,OAAO,CAAgB;gBAEnB,OAAO,EAAE,aAAa;IAMlC;;OAEG;IACH,IAAI,OAAO,IAAI,eAAe,EAAE,CAE/B;IAED;;OAEG;IACH,IAAI,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEpC;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,eAAe,GAAG,IAAI,CAM3C;IAED;;OAEG;IACH,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAO5C;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI;CAW/C"} |
@@ -46,3 +46,6 @@ "use strict"; | ||
| setSelectedWalletId(id) { | ||
| if (this._selectedWalletId === id) | ||
| return; | ||
| this._selectedWalletId = id; | ||
| this.emitter.emit(app_kit_1.WALLETS_EVENTS.SELECTION_CHANGED, { walletId: id }, 'wallets-manager'); | ||
| } | ||
@@ -59,13 +62,6 @@ /** | ||
| } | ||
| // If list is not empty, auto-select the first one | ||
| if (wallets.length > 0) { | ||
| this._selectedWalletId = wallets[0].getWalletId(); | ||
| this.emitter.emit(app_kit_1.WALLETS_EVENTS.SELECTION_CHANGED, { walletId: this._selectedWalletId }, 'wallets-manager'); | ||
| return; | ||
| } | ||
| // Otherwise clear selection | ||
| this._selectedWalletId = null; | ||
| this.emitter.emit(app_kit_1.WALLETS_EVENTS.SELECTION_CHANGED, { walletId: null }, 'wallets-manager'); | ||
| // Auto-select the first wallet, or clear selection when the list is empty. | ||
| this.setSelectedWalletId(wallets.length > 0 ? wallets[0].getWalletId() : null); | ||
| } | ||
| } | ||
| exports.WalletsManager = WalletsManager; |
@@ -34,2 +34,3 @@ /** | ||
| export * from './staking'; | ||
| export * from './gasless'; | ||
| export * from './actions'; | ||
@@ -36,0 +37,0 @@ export * from './types/connector'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AAExC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAG1B,cAAc,WAAW,CAAC;AAG1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,SAAS,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AAExC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAG1B,cAAc,WAAW,CAAC;AAG1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,SAAS,CAAC"} |
@@ -51,2 +51,3 @@ "use strict"; | ||
| __exportStar(require("./staking"), exports); | ||
| __exportStar(require("./gasless"), exports); | ||
| // Actions | ||
@@ -53,0 +54,0 @@ __exportStar(require("./actions"), exports); |
@@ -25,2 +25,7 @@ /** | ||
| export { buildSwapTransactionMutationOptions, type BuildSwapTransactionMutationConfig, type BuildSwapTransactionMutationOptions, type BuildSwapTransactionData, type BuildSwapTransactionErrorType, type BuildSwapTransactionMutate, type BuildSwapTransactionMutateAsync, type BuildSwapTransactionVariables, } from './swap/build-swap-transaction'; | ||
| export { getGaslessConfigQueryOptions, getGaslessConfigQueryKey, type GetGaslessConfigQueryConfig, type GetGaslessConfigData, type GetGaslessConfigErrorType, type GetGaslessConfigQueryKey, type GetGaslessConfigQueryOptions, } from './gasless/get-gasless-config'; | ||
| export { getGaslessProviderMetadataQueryOptions, getGaslessProviderMetadataQueryKey, type GetGaslessProviderMetadataQueryConfig, type GetGaslessProviderMetadataData, type GetGaslessProviderMetadataErrorType, type GetGaslessProviderMetadataQueryKey, type GetGaslessProviderMetadataQueryOptions, } from './gasless/get-gasless-provider-metadata'; | ||
| export { getGaslessQuoteQueryOptions, getGaslessQuoteQueryKey, GASLESS_QUOTE_STALE_TIME_MS, type GetGaslessQuoteQueryConfig, type GetGaslessQuoteData, type GetGaslessQuoteErrorType, type GetGaslessQuoteQueryKey, type GetGaslessQuoteQueryOptions, } from './gasless/get-gasless-quote'; | ||
| export { getGaslessJettonTransferQuoteQueryOptions, getGaslessJettonTransferQuoteQueryKey, type GetGaslessJettonTransferQuoteQueryConfig, type GetGaslessJettonTransferQuoteData, type GetGaslessJettonTransferQuoteErrorType, type GetGaslessJettonTransferQuoteQueryKey, type GetGaslessJettonTransferQuoteQueryOptions, } from './gasless/get-gasless-jetton-transfer-quote'; | ||
| export { sendGaslessTransactionMutationOptions, type SendGaslessTransactionMutationConfig, type SendGaslessTransactionData, type SendGaslessTransactionErrorType, type SendGaslessTransactionMutate, type SendGaslessTransactionMutateAsync, type SendGaslessTransactionVariables, } from './gasless/send-gasless-transaction'; | ||
| export { getStakingQuoteQueryOptions, type GetStakingQuoteQueryConfig, type GetStakingQuoteQueryOptions, type GetStakingQuoteData, type GetStakingQuoteErrorType, type GetStakingQuoteQueryFnData, type GetStakingQuoteQueryKey, } from './staking/get-staking-quote'; | ||
@@ -32,3 +37,4 @@ export { getStakedBalanceQueryOptions, type GetStakedBalanceQueryConfig, type GetStakedBalanceData, type GetStakedBalanceErrorType, } from './staking/get-staked-balance'; | ||
| export { sendTransactionMutationOptions, type SendTransactionData, type SendTransactionErrorType, type SendTransactionMutate, type SendTransactionMutateAsync, type SendTransactionMutationOptions, type SendTransactionOptions, type SendTransactionVariables, type SendTransactionParameters, type SendTransactionReturnType, } from './transaction/send-transaction'; | ||
| export { signMessageMutationOptions, type SignMessageData, type SignMessageErrorType, type SignMessageMutate, type SignMessageMutateAsync, type SignMessageMutationOptions, type SignMessageOptions, type SignMessageVariables, type SignMessageParameters, type SignMessageReturnType, } from './transaction/sign-message'; | ||
| export { getTransactionStatusQueryOptions, type GetTransactionStatusData, type GetTransactionStatusErrorType, type GetTransactionStatusParameters, type GetTransactionStatusReturnType, type GetTransactionStatusQueryConfig, type GetTransactionStatusQueryOptions, } from './transaction/get-transaction-status'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/queries/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACH,+BAA+B,EAC/B,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,GACtC,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EACH,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,yBAAyB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GAC3B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACH,yBAAyB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,kCAAkC,EAClC,KAAK,iCAAiC,EACtC,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,GACvC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,qCAAqC,EACrC,yBAAyB,EACzB,KAAK,oCAAoC,EACzC,KAAK,6BAA6B,EAClC,KAAK,yBAAyB,GACjC,MAAM,yCAAyC,CAAC;AAC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AAqC,CAAC;AAC7C,OAAO,EACH,oCAAoC,EACpC,KAAK,yBAAyB,EAC9B,KAAK,8BAA8B,EACnC,KAAK,oCAAoC,EACzC,KAAK,8BAA8B,GACtC,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EACH,0BAA0B,EAC1B,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,8BAA8B,EAC9B,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACH,0BAA0B,EAC1B,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,gCAAgC,EAChC,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,GACxC,MAAM,sCAAsC,CAAC"} |
@@ -10,3 +10,3 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getTransactionStatusQueryOptions = exports.sendTransactionMutationOptions = exports.transferTonMutationOptions = exports.buildStakeTransactionMutationOptions = exports.getStakingProviderInfoQueryOptions = exports.getStakedBalanceQueryOptions = exports.getStakingQuoteQueryOptions = exports.buildSwapTransactionMutationOptions = exports.getSwapQuoteQueryOptions = exports.signCellMutationOptions = exports.signBinaryMutationOptions = exports.signTextMutationOptions = exports.transferNftMutationOptions = exports.getNftQueryOptions = exports.getNFTsQueryOptions = exports.getBlockNumberQueryOptions = exports.transferJettonMutationOptions = exports.handleJettonsUpdate = exports.getJettonsByAddressQueryOptions = exports.handleJettonBalanceUpdate = exports.getJettonBalanceByAddressQueryOptions = exports.getJettonWalletAddressQueryOptions = exports.getJettonInfoQueryOptions = exports.disconnectMutationOptions = exports.connectMutationOptions = exports.handleBalanceUpdate = exports.getBalanceByAddressQueryOptions = void 0; | ||
| exports.getTransactionStatusQueryOptions = exports.signMessageMutationOptions = exports.sendTransactionMutationOptions = exports.transferTonMutationOptions = exports.buildStakeTransactionMutationOptions = exports.getStakingProviderInfoQueryOptions = exports.getStakedBalanceQueryOptions = exports.getStakingQuoteQueryOptions = exports.sendGaslessTransactionMutationOptions = exports.getGaslessJettonTransferQuoteQueryKey = exports.getGaslessJettonTransferQuoteQueryOptions = exports.GASLESS_QUOTE_STALE_TIME_MS = exports.getGaslessQuoteQueryKey = exports.getGaslessQuoteQueryOptions = exports.getGaslessProviderMetadataQueryKey = exports.getGaslessProviderMetadataQueryOptions = exports.getGaslessConfigQueryKey = exports.getGaslessConfigQueryOptions = exports.buildSwapTransactionMutationOptions = exports.getSwapQuoteQueryOptions = exports.signCellMutationOptions = exports.signBinaryMutationOptions = exports.signTextMutationOptions = exports.transferNftMutationOptions = exports.getNftQueryOptions = exports.getNFTsQueryOptions = exports.getBlockNumberQueryOptions = exports.transferJettonMutationOptions = exports.handleJettonsUpdate = exports.getJettonsByAddressQueryOptions = exports.handleJettonBalanceUpdate = exports.getJettonBalanceByAddressQueryOptions = exports.getJettonWalletAddressQueryOptions = exports.getJettonInfoQueryOptions = exports.disconnectMutationOptions = exports.connectMutationOptions = exports.handleBalanceUpdate = exports.getBalanceByAddressQueryOptions = void 0; | ||
| // Balances | ||
@@ -56,2 +56,18 @@ var get_balance_by_address_1 = require("./balances/get-balance-by-address"); | ||
| Object.defineProperty(exports, "buildSwapTransactionMutationOptions", { enumerable: true, get: function () { return build_swap_transaction_1.buildSwapTransactionMutationOptions; } }); | ||
| // Gasless | ||
| var get_gasless_config_1 = require("./gasless/get-gasless-config"); | ||
| Object.defineProperty(exports, "getGaslessConfigQueryOptions", { enumerable: true, get: function () { return get_gasless_config_1.getGaslessConfigQueryOptions; } }); | ||
| Object.defineProperty(exports, "getGaslessConfigQueryKey", { enumerable: true, get: function () { return get_gasless_config_1.getGaslessConfigQueryKey; } }); | ||
| var get_gasless_provider_metadata_1 = require("./gasless/get-gasless-provider-metadata"); | ||
| Object.defineProperty(exports, "getGaslessProviderMetadataQueryOptions", { enumerable: true, get: function () { return get_gasless_provider_metadata_1.getGaslessProviderMetadataQueryOptions; } }); | ||
| Object.defineProperty(exports, "getGaslessProviderMetadataQueryKey", { enumerable: true, get: function () { return get_gasless_provider_metadata_1.getGaslessProviderMetadataQueryKey; } }); | ||
| var get_gasless_quote_1 = require("./gasless/get-gasless-quote"); | ||
| Object.defineProperty(exports, "getGaslessQuoteQueryOptions", { enumerable: true, get: function () { return get_gasless_quote_1.getGaslessQuoteQueryOptions; } }); | ||
| Object.defineProperty(exports, "getGaslessQuoteQueryKey", { enumerable: true, get: function () { return get_gasless_quote_1.getGaslessQuoteQueryKey; } }); | ||
| Object.defineProperty(exports, "GASLESS_QUOTE_STALE_TIME_MS", { enumerable: true, get: function () { return get_gasless_quote_1.GASLESS_QUOTE_STALE_TIME_MS; } }); | ||
| var get_gasless_jetton_transfer_quote_1 = require("./gasless/get-gasless-jetton-transfer-quote"); | ||
| Object.defineProperty(exports, "getGaslessJettonTransferQuoteQueryOptions", { enumerable: true, get: function () { return get_gasless_jetton_transfer_quote_1.getGaslessJettonTransferQuoteQueryOptions; } }); | ||
| Object.defineProperty(exports, "getGaslessJettonTransferQuoteQueryKey", { enumerable: true, get: function () { return get_gasless_jetton_transfer_quote_1.getGaslessJettonTransferQuoteQueryKey; } }); | ||
| var send_gasless_transaction_1 = require("./gasless/send-gasless-transaction"); | ||
| Object.defineProperty(exports, "sendGaslessTransactionMutationOptions", { enumerable: true, get: function () { return send_gasless_transaction_1.sendGaslessTransactionMutationOptions; } }); | ||
| // Staking | ||
@@ -71,3 +87,5 @@ var get_staking_quote_1 = require("./staking/get-staking-quote"); | ||
| Object.defineProperty(exports, "sendTransactionMutationOptions", { enumerable: true, get: function () { return send_transaction_1.sendTransactionMutationOptions; } }); | ||
| var sign_message_1 = require("./transaction/sign-message"); | ||
| Object.defineProperty(exports, "signMessageMutationOptions", { enumerable: true, get: function () { return sign_message_1.signMessageMutationOptions; } }); | ||
| var get_transaction_status_1 = require("./transaction/get-transaction-status"); | ||
| Object.defineProperty(exports, "getTransactionStatusQueryOptions", { enumerable: true, get: function () { return get_transaction_status_1.getTransactionStatusQueryOptions; } }); |
@@ -8,7 +8,7 @@ /** | ||
| */ | ||
| import type { SwapProviderInterface, StakingProviderInterface, StreamingProvider } from '@ton/walletkit'; | ||
| import type { SwapProviderInterface, StakingProviderInterface, StreamingProvider, GaslessProviderInterface } from '@ton/walletkit'; | ||
| /** | ||
| * Available provider types in AppKit. | ||
| */ | ||
| export type AppKitProvider = SwapProviderInterface | StakingProviderInterface | StreamingProvider; | ||
| export type AppKitProvider = SwapProviderInterface | StakingProviderInterface | StreamingProvider | GaslessProviderInterface; | ||
| //# sourceMappingURL=provider.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/types/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEzG;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG,wBAAwB,GAAG,iBAAiB,CAAC"} | ||
| {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/types/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACR,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,EAC3B,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,MAAM,cAAc,GACpB,qBAAqB,GACrB,wBAAwB,GACxB,iBAAiB,GACjB,wBAAwB,CAAC"} |
@@ -76,2 +76,13 @@ /** | ||
| } | ||
| /** | ||
| * SignMessage Response - returned from wallet. | ||
| * | ||
| * Wallet signs a transaction-shaped request with the internal message opcode | ||
| * (instead of external), so the resulting BoC can be relayed on-chain by a | ||
| * third party (e.g. a gasless relayer) rather than broadcast directly. | ||
| */ | ||
| export interface SignMessageResponse { | ||
| /** Signed internal message BoC (base64) ready to be relayed */ | ||
| internalBoc: Base64String; | ||
| } | ||
| //# sourceMappingURL=signing.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../../src/types/signing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD;;GAEG;AACH,MAAM,MAAM,QAAQ,GACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,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IACH,OAAO,EAAE,YAAY,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC5B,cAAc;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mBAAmB;IACnB,IAAI,EAAE,QAAQ,CAAC;CAClB;AAED,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC7B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,OAAO,EAAE,eAAe,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAChC,+DAA+D;IAC/D,WAAW,EAAE,YAAY,CAAC;CAC7B"} |
@@ -10,2 +10,3 @@ /** | ||
| import type { Network } from './network'; | ||
| import type { Base64String } from './primitives'; | ||
| export type { TransactionStatus } from '@ton/walletkit'; | ||
@@ -49,8 +50,8 @@ export interface TransactionRequest { | ||
| */ | ||
| stateInit?: string; | ||
| stateInit?: Base64String; | ||
| /** | ||
| * Message payload data encoded in Base64 | ||
| */ | ||
| payload?: string; | ||
| payload?: Base64String; | ||
| } | ||
| //# sourceMappingURL=transaction.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/types/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,YAAY,EAAE,iBAAiB,EA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H,aAAa,CAAC,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;CAC1B"} |
@@ -8,5 +8,6 @@ /** | ||
| */ | ||
| import type { SendTransactionResponse, Hex, UserFriendlyAddress } from '@ton/walletkit'; | ||
| import type { Feature, SendTransactionResponse, Hex, UserFriendlyAddress } from '@ton/walletkit'; | ||
| export type { Feature } from '@ton/walletkit'; | ||
| import type { TransactionRequest } from './transaction'; | ||
| import type { SignDataRequest, SignDataResponse } from './signing'; | ||
| import type { SignDataRequest, SignDataResponse, SignMessageResponse } from './signing'; | ||
| import type { Network } from './network'; | ||
@@ -29,2 +30,8 @@ /** | ||
| getWalletId(): string; | ||
| /** | ||
| * Features supported by the underlying wallet (e.g. SendTransaction, SignData, SignMessage). | ||
| * Returns undefined when the connector cannot report capabilities. | ||
| * Callers should gracefully degrade when a feature is missing. | ||
| */ | ||
| getSupportedFeatures(): Feature[] | undefined; | ||
| /** Send a transaction (wallet signs and submits) */ | ||
@@ -34,3 +41,11 @@ sendTransaction(request: TransactionRequest): Promise<SendTransactionResponse>; | ||
| signData(payload: SignDataRequest): Promise<SignDataResponse>; | ||
| /** | ||
| * Sign a transaction-shaped request without broadcasting it. | ||
| * The wallet returns a signed internal-message BoC that a third party can relay | ||
| * on-chain (e.g. a gasless relayer). | ||
| * | ||
| * Requires the wallet to support the SignMessage feature (see getSupportedFeatures). | ||
| */ | ||
| signMessage(request: TransactionRequest): Promise<SignMessageResponse>; | ||
| } | ||
| //# sourceMappingURL=wallet.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/types/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,GAAG,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAExF,OAAO,KAAK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AAgC;IAChC,YAAY,IAAI,GAAG,CAAC;IAEpB,iDAAiD;IACjD,UAAU,IAAI,OAAO,CAAC;IAEtB,mCAAmC;IACnC,WAAW,IAAI,MAAM,CAAC;IAEtB;;;;OAIG;IACH,oBAAoB,IAAI,OAAO,EAAE,GAAG,SAAS,CAAC;IAM9C,oDAAoD;IACpD,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAE/E,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAE9D;;;;;;OAMG;IACH,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC1E"} |
@@ -8,3 +8,3 @@ /** | ||
| */ | ||
| export { formatUnits, parseUnits, compareAddress } from '@ton/walletkit'; | ||
| export { formatUnits, parseUnits, compareAddress, createJettonTransferPayload, asAddressFriendly, asBase64, asHex, hasSignMessageSupport, getMaxOutgoingMessages, } from '@ton/walletkit'; | ||
| export * from './address/is-valid-address'; | ||
@@ -18,3 +18,4 @@ export * from './address/to-bounceble-address'; | ||
| export * from './balance/calc-max-spendable'; | ||
| export * from './balance/get-ton-shortfall'; | ||
| export * from './balance/check-ton-balance'; | ||
| export * from './balance/check-transfer-balance'; | ||
| export * from './arrays/key-by'; | ||
@@ -21,0 +22,0 @@ export * from './arrays/random-from-array'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzE,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C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CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC"} |
@@ -24,3 +24,3 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.compareAddress = exports.parseUnits = exports.formatUnits = void 0; | ||
| exports.getMaxOutgoingMessages = exports.hasSignMessageSupport = exports.asHex = exports.asBase64 = exports.asAddressFriendly = exports.createJettonTransferPayload = exports.compareAddress = exports.parseUnits = exports.formatUnits = void 0; | ||
| var walletkit_1 = require("@ton/walletkit"); | ||
@@ -30,2 +30,8 @@ Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return walletkit_1.formatUnits; } }); | ||
| Object.defineProperty(exports, "compareAddress", { enumerable: true, get: function () { return walletkit_1.compareAddress; } }); | ||
| Object.defineProperty(exports, "createJettonTransferPayload", { enumerable: true, get: function () { return walletkit_1.createJettonTransferPayload; } }); | ||
| Object.defineProperty(exports, "asAddressFriendly", { enumerable: true, get: function () { return walletkit_1.asAddressFriendly; } }); | ||
| Object.defineProperty(exports, "asBase64", { enumerable: true, get: function () { return walletkit_1.asBase64; } }); | ||
| Object.defineProperty(exports, "asHex", { enumerable: true, get: function () { return walletkit_1.asHex; } }); | ||
| Object.defineProperty(exports, "hasSignMessageSupport", { enumerable: true, get: function () { return walletkit_1.hasSignMessageSupport; } }); | ||
| Object.defineProperty(exports, "getMaxOutgoingMessages", { enumerable: true, get: function () { return walletkit_1.getMaxOutgoingMessages; } }); | ||
| __exportStar(require("./address/is-valid-address"), exports); | ||
@@ -39,3 +45,4 @@ __exportStar(require("./address/to-bounceble-address"), exports); | ||
| __exportStar(require("./balance/calc-max-spendable"), exports); | ||
| __exportStar(require("./balance/get-ton-shortfall"), exports); | ||
| __exportStar(require("./balance/check-ton-balance"), exports); | ||
| __exportStar(require("./balance/check-transfer-balance"), exports); | ||
| __exportStar(require("./arrays/key-by"), exports); | ||
@@ -42,0 +49,0 @@ __exportStar(require("./arrays/random-from-array"), exports); |
@@ -42,2 +42,12 @@ /** | ||
| export { registerProvider, type RegisterProviderOptions } from './providers/register-provider'; | ||
| export { getGaslessManager, type GetGaslessManagerReturnType } from './gasless/get-gasless-manager'; | ||
| export { getGaslessProvider, type GetGaslessProviderOptions, type GetGaslessProviderReturnType, } from './gasless/get-gasless-provider'; | ||
| export { getGaslessProviders, type GetGaslessProvidersReturnType } from './gasless/get-gasless-providers'; | ||
| export { setDefaultGaslessProvider, type SetDefaultGaslessProviderParameters, type SetDefaultGaslessProviderReturnType, } from './gasless/set-default-gasless-provider'; | ||
| export { watchGaslessProviders, type WatchGaslessProvidersParameters, type WatchGaslessProvidersReturnType, } from './gasless/watch-gasless-providers'; | ||
| export { getGaslessConfig, type GetGaslessConfigOptions, type GetGaslessConfigReturnType, type GetGaslessConfigErrorType, } from './gasless/get-gasless-config'; | ||
| export { getGaslessProviderMetadata, type GetGaslessProviderMetadataOptions, type GetGaslessProviderMetadataReturnType, type GetGaslessProviderMetadataErrorType, } from './gasless/get-gasless-provider-metadata'; | ||
| export { getGaslessQuote, type GetGaslessQuoteOptions, type GetGaslessQuoteReturnType, type GetGaslessQuoteErrorType, } from './gasless/get-gasless-quote'; | ||
| export { getGaslessJettonTransferQuote, type GetGaslessJettonTransferQuoteOptions, type GetGaslessJettonTransferQuoteReturnType, type GetGaslessJettonTransferQuoteErrorType, } from './gasless/get-gasless-jetton-transfer-quote'; | ||
| export { sendGaslessTransaction, type SendGaslessTransactionParameters, type SendGaslessTransactionReturnType, type SendGaslessTransactionErrorType, } from './gasless/send-gasless-transaction'; | ||
| export { signText, type SignTextParameters, type SignTextReturnType } from './signing/sign-text'; | ||
@@ -64,2 +74,3 @@ export { signBinary, type SignBinaryParameters, type SignBinaryReturnType } from './signing/sign-binary'; | ||
| export { sendTransaction, type SendTransactionParameters, type SendTransactionReturnType, } from './transaction/send-transaction'; | ||
| export { signMessage, type SignMessageParameters, type SignMessageReturnType, type SignMessageErrorType, } from './transaction/sign-message'; | ||
| export { transferTon, type TransferTonParameters, type TransferTonReturnType } from './transaction/transfer-ton'; | ||
@@ -75,3 +86,5 @@ export { getTransactionStatus, type GetTransactionStatusParameters, type GetTransactionStatusReturnType, type GetTransactionStatusErrorType, } from './transaction/get-transaction-status'; | ||
| export { watchSelectedWallet, type WatchSelectedWalletParameters, type WatchSelectedWalletReturnType, } from './wallets/watch-selected-wallet'; | ||
| export { getSignMessageSupport, type GetSignMessageSupportReturnType } from './wallets/get-sign-message-support'; | ||
| export { watchSignMessageSupport, type WatchSignMessageSupportParameters, type WatchSignMessageSupportReturnType, } from './wallets/watch-sign-message-support'; | ||
| export { watchConnectedWallets, type WatchConnectedWalletsParameters, type WatchConnectedWalletsReturnType, } from './wallets/watch-connected-wallets'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACH,mBAAmB,EACnB,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,GACrC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,qBAAqB,EACrB,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,GACvC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAG/G,OAAO,EAAE,YAAY,EAAE,KAAK,sBAAsB,EAAE,KAAK,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpH,OAAO,EAAE,OAAO,EAAE,KAAK,iBAAiB,EA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BAA6B,GACrC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,mBAAmB,EACnB,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,GACrC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,KAAK,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AACjH,OAAO,EACH,uBAAuB,EACvB,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,GACzC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,qBAAqB,EACrB,KAAK,+BAA+B,EACpC,KAAK,+BAA+B,GACvC,MAAM,mCAAmC,CAAC"} |
@@ -48,2 +48,13 @@ /** | ||
| export { registerProvider } from './providers/register-provider'; | ||
| // Gasless | ||
| export { getGaslessManager } from './gasless/get-gasless-manager'; | ||
| export { getGaslessProvider, } from './gasless/get-gasless-provider'; | ||
| export { getGaslessProviders } from './gasless/get-gasless-providers'; | ||
| export { setDefaultGaslessProvider, } from './gasless/set-default-gasless-provider'; | ||
| export { watchGaslessProviders, } from './gasless/watch-gasless-providers'; | ||
| export { getGaslessConfig, } from './gasless/get-gasless-config'; | ||
| export { getGaslessProviderMetadata, } from './gasless/get-gasless-provider-metadata'; | ||
| export { getGaslessQuote, } from './gasless/get-gasless-quote'; | ||
| export { getGaslessJettonTransferQuote, } from './gasless/get-gasless-jetton-transfer-quote'; | ||
| export { sendGaslessTransaction, } from './gasless/send-gasless-transaction'; | ||
| // Signing | ||
@@ -74,2 +85,3 @@ export { signText } from './signing/sign-text'; | ||
| export { sendTransaction, } from './transaction/send-transaction'; | ||
| export { signMessage, } from './transaction/sign-message'; | ||
| export { transferTon } from './transaction/transfer-ton'; | ||
@@ -86,2 +98,4 @@ export { getTransactionStatus, } from './transaction/get-transaction-status'; | ||
| export { watchSelectedWallet, } from './wallets/watch-selected-wallet'; | ||
| export { getSignMessageSupport } from './wallets/get-sign-message-support'; | ||
| export { watchSignMessageSupport, } from './wallets/watch-sign-message-support'; | ||
| export { watchConnectedWallets, } from './wallets/watch-connected-wallets'; |
@@ -16,2 +16,3 @@ /** | ||
| comment?: string; | ||
| responseDestination?: string; | ||
| } | ||
@@ -18,0 +19,0 @@ export type CreateTransferJettonTransactionReturnType = TransactionRequest; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"create-transfer-jetton-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/jettons/create-transfer-jetton-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,WAAW,yCAAyC;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,yCAAyC,GAAG,kBAAkB,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,+BAA+B,GACxC,QAAQ,MAAM,EACd,YAAY,yCAAyC,KACtD,OAAO,CAAC,yCAAyC,CA4CnD,CAAC"} | ||
| {"version":3,"file":"create-transfer-jetton-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/jettons/create-transfer-jetton-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAKjD,MAAM,WAAW,yCAAyC;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,MAAM,yCAAyC,GAAG,kBAAkB,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,+BAA+B,GACxC,QAAQ,MAAM,EACd,YAAY,yCAAyC,KACtD,OAAO,CAAC,yCAAyC,CA4CnD,CAAC"} |
@@ -16,3 +16,3 @@ /** | ||
| export const createTransferJettonTransaction = async (appKit, parameters) => { | ||
| const { jettonAddress, recipientAddress, amount, jettonDecimals, comment } = parameters; | ||
| const { jettonAddress, recipientAddress, amount, jettonDecimals, comment, responseDestination } = parameters; | ||
| const wallet = getSelectedWallet(appKit); | ||
@@ -40,3 +40,3 @@ if (!wallet) { | ||
| destination: recipientAddress, | ||
| responseDestination: ownerAddress, | ||
| responseDestination: responseDestination ?? ownerAddress, | ||
| comment, | ||
@@ -43,0 +43,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"create-transfer-ton-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/transaction/create-transfer-ton-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAA6B,MAAM,yBAAyB,CAAC;AAC7F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,WAAW,sCAAsC;IACnD,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,sCAAsC,GAAG,kBAAkB,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACrC,QAAQ,MAAM,EACd,YAAY,sCAAsC,KACnD,sCA2BF,CAAC"} | ||
| {"version":3,"file":"create-transfer-ton-transaction.d.ts","sourceRoot":"","sources":["../../../../src/actions/transaction/create-transfer-ton-transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,kBAAkB,EAA6B,MAAM,yBAAyB,CAAC;AAE7F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD,MAAM,WAAW,sCAAsC;IACnD,wBAAwB;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,sCAAsC,GAAG,kBAAkB,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACrC,QAAQ,MAAM,EACd,YAAY,sCAAsC,KACnD,sCA2BF,CAAC"} |
@@ -9,2 +9,3 @@ /** | ||
| import { createCommentPayloadBase64, parseUnits } from '@ton/walletkit'; | ||
| import { asBase64 } from '../../utils'; | ||
| import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
@@ -23,7 +24,7 @@ /** | ||
| amount: parseUnits(amount, 9).toString(), | ||
| stateInit, | ||
| stateInit: stateInit ? asBase64(stateInit) : undefined, | ||
| }; | ||
| // Payload takes priority, otherwise use comment | ||
| if (payload) { | ||
| message.payload = payload; | ||
| message.payload = asBase64(payload); | ||
| } | ||
@@ -30,0 +31,0 @@ else if (comment) { |
@@ -9,7 +9,7 @@ /** | ||
| import type { Wallet as TonConnectWallet } from '@tonconnect/sdk'; | ||
| import type { SendTransactionResponse, UserFriendlyAddress, Hex } from '@ton/walletkit'; | ||
| import type { Feature, SendTransactionResponse, UserFriendlyAddress, Hex } from '@ton/walletkit'; | ||
| import type { TonConnectUI } from '@tonconnect/ui'; | ||
| import type { TransactionRequest } from '../../../types/transaction'; | ||
| import type { WalletInterface } from '../../../types/wallet'; | ||
| import type { SignDataRequest, SignDataResponse } from '../../../types/signing'; | ||
| import type { SignDataRequest, SignDataResponse, SignMessageResponse } from '../../../types/signing'; | ||
| import { Network } from '../../../types/network'; | ||
@@ -37,6 +37,9 @@ /** | ||
| getWalletId(): string; | ||
| getSupportedFeatures(): Feature[] | undefined; | ||
| sendTransaction(request: TransactionRequest): Promise<SendTransactionResponse>; | ||
| signMessage(request: TransactionRequest): Promise<SignMessageResponse>; | ||
| signData(payload: SignDataRequest): Promise<SignDataResponse>; | ||
| private mapTransactionRequest; | ||
| private mapSignDataRequest; | ||
| } | ||
| //# sourceMappingURL=ton-connect-wallet-adapter.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"ton-connect-wallet-adapter.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/tonconnect/adapters/ton-connect-wallet-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAExF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAC3D,SAAgB,gBAAgB,EAAE,gBAAgB,CAAC;IACnD,SAAgB,YAAY,EAAE,YAAY,CAAC;IAC3C,SAAgB,WAAW,EAAE,MAAM,CAAC;gBAExB,MAAM,EAAE,6BAA6B;IAUjD,UAAU,IAAI,mBAAmB;IAQjC,YAAY,IAAI,GAAG;IAQnB,UAAU,IAAI,OAAO;IAKrB,WAAW,IAAI,MAAM;IAQf,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAsB9E,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgBnE,OAAO,CAAC,kBAAkB;CAmC7B"} | ||
| {"version":3,"file":"ton-connect-wallet-adapter.d.ts","sourceRoot":"","sources":["../../../../../src/connectors/tonconnect/adapters/ton-connect-wallet-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,KAAK,EAAE,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAEjG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAC3D,SAAgB,gBAAgB,EAAE,gBAAgB,CAAC;IACnD,SAAgB,YAAY,EAAE,YAAY,CAAC;IAC3C,SAAgB,WAAW,EAAE,MAAM,CAAC;gBAExB,MAAM,EAAE,6BAA6B;IAUjD,UAAU,IAAI,mBAAmB;IAQjC,YAAY,IAAI,GAAG;IAQnB,UAAU,IAAI,OAAO;IAKrB,WAAW,IAAI,MAAM;IAIrB,oBAAoB,IAAI,OAAO,EAAE,GAAG,SAAS;IAQvC,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAa9E,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUtE,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgBnE,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,kBAAkB;CAmC7B"} |
@@ -9,3 +9,3 @@ /** | ||
| import { Address } from '@ton/core'; | ||
| import { asHex, createWalletId, getNormalizedExtMessageHash } from '@ton/walletkit'; | ||
| import { asBase64, asHex, createWalletId, getNormalizedExtMessageHash } from '@ton/walletkit'; | ||
| import { getValidUntil } from '../utils/transaction'; | ||
@@ -47,2 +47,5 @@ import { Network } from '../../../types/network'; | ||
| } | ||
| getSupportedFeatures() { | ||
| return this.tonConnectWallet.device?.features; | ||
| } | ||
| // ========================================== | ||
@@ -52,12 +55,3 @@ // Signing / Transactions | ||
| async sendTransaction(request) { | ||
| const transaction = { | ||
| validUntil: request.validUntil || getValidUntil(), | ||
| messages: request.messages.map((msg) => ({ | ||
| address: msg.address, | ||
| amount: String(msg.amount), | ||
| payload: msg.payload, | ||
| stateInit: msg.stateInit, | ||
| })), | ||
| network: request.network?.chainId ?? this.tonConnectWallet.account?.chain, | ||
| }; | ||
| const transaction = this.mapTransactionRequest(request); | ||
| const result = await this.tonConnectUI.sendTransaction(transaction); | ||
@@ -71,2 +65,9 @@ const { hash, boc: normalizedBoc } = getNormalizedExtMessageHash(result.boc); | ||
| } | ||
| async signMessage(request) { | ||
| const message = this.mapTransactionRequest(request); | ||
| const result = await this.tonConnectUI.signMessage(message); | ||
| return { | ||
| internalBoc: asBase64(result.internalBoc), | ||
| }; | ||
| } | ||
| async signData(payload) { | ||
@@ -85,2 +86,14 @@ const result = await this.tonConnectUI.signData(this.mapSignDataRequest(payload)); | ||
| // ========================================== | ||
| mapTransactionRequest(request) { | ||
| return { | ||
| validUntil: request.validUntil || getValidUntil(), | ||
| messages: request.messages.map((msg) => ({ | ||
| address: msg.address, | ||
| amount: String(msg.amount), | ||
| payload: msg.payload, | ||
| stateInit: msg.stateInit, | ||
| })), | ||
| network: request.network?.chainId ?? this.tonConnectWallet.account?.chain, | ||
| }; | ||
| } | ||
| mapSignDataRequest(request) { | ||
@@ -87,0 +100,0 @@ const chainId = request.network?.chainId ?? this.getNetwork().chainId; |
@@ -12,2 +12,3 @@ /** | ||
| import { StakingManager } from '../../../staking'; | ||
| import { GaslessManager } from '../../../gasless'; | ||
| import type { Connector, ConnectorFactoryContext, ConnectorInput } from '../../../types/connector'; | ||
@@ -29,2 +30,3 @@ import type { AppKitEmitter } from '../types/events'; | ||
| readonly stakingManager: StakingManager; | ||
| readonly gaslessManager: GaslessManager; | ||
| readonly networkManager: AppKitNetworkManager; | ||
@@ -31,0 +33,0 @@ readonly streamingManager: StreamingManager; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"app-kit.d.ts","sourceRoot":"","sources":["../../../../../src/core/app-kit/services/app-kit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAsE,MAAM,gBAAgB,CAAC;AAExH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM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AAG,MAAM,IAAI;IAkB/C;;OAEG;IACH,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAY3C;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,IAAI;IAoB5D;;OAEG;IACH,OAAO,CAAC,2BAA2B;CAWtC"} |
@@ -11,2 +11,3 @@ /** | ||
| import { StakingManager } from '../../../staking'; | ||
| import { GaslessManager } from '../../../gasless'; | ||
| import { EventEmitter } from '../../emitter'; | ||
@@ -36,2 +37,3 @@ import { WalletsManager } from '../../wallets-manager'; | ||
| this.stakingManager = new StakingManager(() => this.createFactoryContext()); | ||
| this.gaslessManager = new GaslessManager(() => this.createFactoryContext()); | ||
| this.streamingManager = new StreamingManager(() => this.createFactoryContext()); | ||
@@ -97,2 +99,5 @@ if (config.connectors) { | ||
| break; | ||
| case 'gasless': | ||
| this.gaslessManager.registerProvider(provider); | ||
| break; | ||
| default: | ||
@@ -99,0 +104,0 @@ throw new Error('Unknown provider type'); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"wallets-manager.d.ts","sourceRoot":"","sources":["../../../../../src/core/wallets-manager/services/wallets-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,OAAO,CAAgB;gBAEnB,OAAO,EAAE,aAAa;IAMlC;;OAEG;IACH,IAAI,OAAO,IAAI,eAAe,EAAE,CAE/B;IAED;;OAEG;IACH,IAAI,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEpC;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,eAAe,GAAG,IAAI,CAM3C;IAED;;OAEG;IACH,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAI5C;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI;CAwB/C"} | ||
| {"version":3,"file":"wallets-manager.d.ts","sourceRoot":"","sources":["../../../../../src/core/wallets-manager/services/wallets-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,OAAO,CAAgB;gBAEnB,OAAO,EAAE,aAAa;IAMlC;;OAEG;IACH,IAAI,OAAO,IAAI,eAAe,EAAE,CAE/B;IAED;;OAEG;IACH,IAAI,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAEpC;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,eAAe,GAAG,IAAI,CAM3C;IAED;;OAEG;IACH,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAO5C;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI;CAW/C"} |
@@ -43,3 +43,6 @@ /** | ||
| setSelectedWalletId(id) { | ||
| if (this._selectedWalletId === id) | ||
| return; | ||
| this._selectedWalletId = id; | ||
| this.emitter.emit(WALLETS_EVENTS.SELECTION_CHANGED, { walletId: id }, 'wallets-manager'); | ||
| } | ||
@@ -56,12 +59,5 @@ /** | ||
| } | ||
| // If list is not empty, auto-select the first one | ||
| if (wallets.length > 0) { | ||
| this._selectedWalletId = wallets[0].getWalletId(); | ||
| this.emitter.emit(WALLETS_EVENTS.SELECTION_CHANGED, { walletId: this._selectedWalletId }, 'wallets-manager'); | ||
| return; | ||
| } | ||
| // Otherwise clear selection | ||
| this._selectedWalletId = null; | ||
| this.emitter.emit(WALLETS_EVENTS.SELECTION_CHANGED, { walletId: null }, 'wallets-manager'); | ||
| // Auto-select the first wallet, or clear selection when the list is empty. | ||
| this.setSelectedWalletId(wallets.length > 0 ? wallets[0].getWalletId() : null); | ||
| } | ||
| } |
@@ -34,2 +34,3 @@ /** | ||
| export * from './staking'; | ||
| export * from './gasless'; | ||
| export * from './actions'; | ||
@@ -36,0 +37,0 @@ export * from './types/connector'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AAExC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAG1B,cAAc,WAAW,CAAC;AAG1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,SAAS,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AAExC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAG1B,cAAc,WAAW,CAAC;AAG1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,SAAS,CAAC"} |
@@ -35,2 +35,3 @@ /** | ||
| export * from './staking'; | ||
| export * from './gasless'; | ||
| // Actions | ||
@@ -37,0 +38,0 @@ export * from './actions'; |
@@ -25,2 +25,7 @@ /** | ||
| export { buildSwapTransactionMutationOptions, type BuildSwapTransactionMutationConfig, type BuildSwapTransactionMutationOptions, type BuildSwapTransactionData, type BuildSwapTransactionErrorType, type BuildSwapTransactionMutate, type BuildSwapTransactionMutateAsync, type BuildSwapTransactionVariables, } from './swap/build-swap-transaction'; | ||
| export { getGaslessConfigQueryOptions, getGaslessConfigQueryKey, type GetGaslessConfigQueryConfig, type GetGaslessConfigData, type GetGaslessConfigErrorType, type GetGaslessConfigQueryKey, type GetGaslessConfigQueryOptions, } from './gasless/get-gasless-config'; | ||
| export { getGaslessProviderMetadataQueryOptions, getGaslessProviderMetadataQueryKey, type GetGaslessProviderMetadataQueryConfig, type GetGaslessProviderMetadataData, type GetGaslessProviderMetadataErrorType, type GetGaslessProviderMetadataQueryKey, type GetGaslessProviderMetadataQueryOptions, } from './gasless/get-gasless-provider-metadata'; | ||
| export { getGaslessQuoteQueryOptions, getGaslessQuoteQueryKey, GASLESS_QUOTE_STALE_TIME_MS, type GetGaslessQuoteQueryConfig, type GetGaslessQuoteData, type GetGaslessQuoteErrorType, type GetGaslessQuoteQueryKey, type GetGaslessQuoteQueryOptions, } from './gasless/get-gasless-quote'; | ||
| export { getGaslessJettonTransferQuoteQueryOptions, getGaslessJettonTransferQuoteQueryKey, type GetGaslessJettonTransferQuoteQueryConfig, type GetGaslessJettonTransferQuoteData, type GetGaslessJettonTransferQuoteErrorType, type GetGaslessJettonTransferQuoteQueryKey, type GetGaslessJettonTransferQuoteQueryOptions, } from './gasless/get-gasless-jetton-transfer-quote'; | ||
| export { sendGaslessTransactionMutationOptions, type SendGaslessTransactionMutationConfig, type SendGaslessTransactionData, type SendGaslessTransactionErrorType, type SendGaslessTransactionMutate, type SendGaslessTransactionMutateAsync, type SendGaslessTransactionVariables, } from './gasless/send-gasless-transaction'; | ||
| export { getStakingQuoteQueryOptions, type GetStakingQuoteQueryConfig, type GetStakingQuoteQueryOptions, type GetStakingQuoteData, type GetStakingQuoteErrorType, type GetStakingQuoteQueryFnData, type GetStakingQuoteQueryKey, } from './staking/get-staking-quote'; | ||
@@ -32,3 +37,4 @@ export { getStakedBalanceQueryOptions, type GetStakedBalanceQueryConfig, type GetStakedBalanceData, type GetStakedBalanceErrorType, } from './staking/get-staked-balance'; | ||
| export { sendTransactionMutationOptions, type SendTransactionData, type SendTransactionErrorType, type SendTransactionMutate, type SendTransactionMutateAsync, type SendTransactionMutationOptions, type SendTransactionOptions, type SendTransactionVariables, type SendTransactionParameters, type SendTransactionReturnType, } from './transaction/send-transaction'; | ||
| export { signMessageMutationOptions, type SignMessageData, type SignMessageErrorType, type SignMessageMutate, type SignMessageMutateAsync, type SignMessageMutationOptions, type SignMessageOptions, type SignMessageVariables, type SignMessageParameters, type SignMessageReturnType, } from './transaction/sign-message'; | ||
| export { getTransactionStatusQueryOptions, type GetTransactionStatusData, type GetTransactionStatusErrorType, type GetTransactionStatusParameters, type GetTransactionStatusReturnType, type GetTransactionStatusQueryConfig, type GetTransactionStatusQueryOptions, } from './transaction/get-transaction-status'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/queries/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACH,+BAA+B,EAC/B,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,GACtC,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EACH,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACH,yBAAyB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GAC3B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACH,yBAAyB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACH,kCAAkC,EAClC,KAAK,iCAAiC,EACtC,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,GACvC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,qCAAqC,EACrC,yBAAyB,EACzB,KAAK,oCAAoC,EACzC,KAAK,6BAA6B,EAClC,KAAK,yBAAyB,GACjC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACH,+BAA+B,EAC/B,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,8BAA8B,GACtC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,6BAA6B,EAC7B,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,oBAAo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ACzB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,8BAA8B,EAC9B,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,GACjC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACH,0BAA0B,EAC1B,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,gCAAgC,EAChC,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,gCAAgC,GACxC,MAAM,sCAAsC,CAAC"} |
@@ -32,2 +32,8 @@ /** | ||
| export { buildSwapTransactionMutationOptions, } from './swap/build-swap-transaction'; | ||
| // Gasless | ||
| export { getGaslessConfigQueryOptions, getGaslessConfigQueryKey, } from './gasless/get-gasless-config'; | ||
| export { getGaslessProviderMetadataQueryOptions, getGaslessProviderMetadataQueryKey, } from './gasless/get-gasless-provider-metadata'; | ||
| export { getGaslessQuoteQueryOptions, getGaslessQuoteQueryKey, GASLESS_QUOTE_STALE_TIME_MS, } from './gasless/get-gasless-quote'; | ||
| export { getGaslessJettonTransferQuoteQueryOptions, getGaslessJettonTransferQuoteQueryKey, } from './gasless/get-gasless-jetton-transfer-quote'; | ||
| export { sendGaslessTransactionMutationOptions, } from './gasless/send-gasless-transaction'; | ||
| // Staking | ||
@@ -41,2 +47,3 @@ export { getStakingQuoteQueryOptions, } from './staking/get-staking-quote'; | ||
| export { sendTransactionMutationOptions, } from './transaction/send-transaction'; | ||
| export { signMessageMutationOptions, } from './transaction/sign-message'; | ||
| export { getTransactionStatusQueryOptions, } from './transaction/get-transaction-status'; |
@@ -8,7 +8,7 @@ /** | ||
| */ | ||
| import type { SwapProviderInterface, StakingProviderInterface, StreamingProvider } from '@ton/walletkit'; | ||
| import type { SwapProviderInterface, StakingProviderInterface, StreamingProvider, GaslessProviderInterface } from '@ton/walletkit'; | ||
| /** | ||
| * Available provider types in AppKit. | ||
| */ | ||
| export type AppKitProvider = SwapProviderInterface | StakingProviderInterface | StreamingProvider; | ||
| export type AppKitProvider = SwapProviderInterface | StakingProviderInterface | StreamingProvider | GaslessProviderInterface; | ||
| //# sourceMappingURL=provider.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/types/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEzG;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG,wBAAwB,GAAG,iBAAiB,CAAC"} | ||
| {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/types/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACR,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,EAC3B,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,MAAM,cAAc,GACpB,qBAAqB,GACrB,wBAAwB,GACxB,iBAAiB,GACjB,wBAAwB,CAAC"} |
@@ -76,2 +76,13 @@ /** | ||
| } | ||
| /** | ||
| * SignMessage Response - returned from wallet. | ||
| * | ||
| * Wallet signs a transaction-shaped request with the internal message opcode | ||
| * (instead of external), so the resulting BoC can be relayed on-chain by a | ||
| * third party (e.g. a gasless relayer) rather than broadcast directly. | ||
| */ | ||
| export interface SignMessageResponse { | ||
| /** Signed internal message BoC (base64) ready to be relayed */ | ||
| internalBoc: Base64String; | ||
| } | ||
| //# sourceMappingURL=signing.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../../../src/types/signing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD;;GAEG;AACH,MAAM,MAAM,QAAQ,GACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC5B,cAAc;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mBAAmB;IACnB,IAAI,EAAE,QAAQ,CAAC;CAClB;AAED,+CAA+C;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,gBAAgB;IAC7B,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,OAAO,EAAE,eAAe,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAChC,+DAA+D;IAC/D,WAAW,EAAE,YAAY,CAAC;CAC7B"} |
@@ -10,2 +10,3 @@ /** | ||
| import type { Network } from './network'; | ||
| import type { Base64String } from './primitives'; | ||
| export type { TransactionStatus } from '@ton/walletkit'; | ||
@@ -49,8 +50,8 @@ export interface TransactionRequest { | ||
| */ | ||
| stateInit?: string; | ||
| stateInit?: Base64String; | ||
| /** | ||
| * Message payload data encoded in Base64 | ||
| */ | ||
| payload?: string; | ||
| payload?: Base64String; | ||
| } | ||
| //# sourceMappingURL=transaction.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/types/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IAEtC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB"} | ||
| {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/types/transaction.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IAC/B;;OAEG;IACH,QAAQ,EAAE,yBAAyB,EAAE,CAAC;IAEtC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,eAAe,CAAC;IAEhC;;OAEG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;CAC1B"} |
@@ -8,5 +8,6 @@ /** | ||
| */ | ||
| import type { SendTransactionResponse, Hex, UserFriendlyAddress } from '@ton/walletkit'; | ||
| import type { Feature, SendTransactionResponse, Hex, UserFriendlyAddress } from '@ton/walletkit'; | ||
| export type { Feature } from '@ton/walletkit'; | ||
| import type { TransactionRequest } from './transaction'; | ||
| import type { SignDataRequest, SignDataResponse } from './signing'; | ||
| import type { SignDataRequest, SignDataResponse, SignMessageResponse } from './signing'; | ||
| import type { Network } from './network'; | ||
@@ -29,2 +30,8 @@ /** | ||
| getWalletId(): string; | ||
| /** | ||
| * Features supported by the underlying wallet (e.g. SendTransaction, SignData, SignMessage). | ||
| * Returns undefined when the connector cannot report capabilities. | ||
| * Callers should gracefully degrade when a feature is missing. | ||
| */ | ||
| getSupportedFeatures(): Feature[] | undefined; | ||
| /** Send a transaction (wallet signs and submits) */ | ||
@@ -34,3 +41,11 @@ sendTransaction(request: TransactionRequest): Promise<SendTransactionResponse>; | ||
| signData(payload: SignDataRequest): Promise<SignDataResponse>; | ||
| /** | ||
| * Sign a transaction-shaped request without broadcasting it. | ||
| * The wallet returns a signed internal-message BoC that a third party can relay | ||
| * on-chain (e.g. a gasless relayer). | ||
| * | ||
| * Requires the wallet to support the SignMessage feature (see getSupportedFeatures). | ||
| */ | ||
| signMessage(request: TransactionRequest): Promise<SignMessageResponse>; | ||
| } | ||
| //# sourceMappingURL=wallet.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../../src/types/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,GAAG,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAExF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAM7B,6BAA6B;IAC7B,UAAU,IAAI,mBAAmB,CAAC;IAElC,gCAAgC;IAChC,YAAY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Ae,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAE9D;;;;;;OAMG;IACH,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC1E"} |
@@ -8,3 +8,3 @@ /** | ||
| */ | ||
| export { formatUnits, parseUnits, compareAddress } from '@ton/walletkit'; | ||
| export { formatUnits, parseUnits, compareAddress, createJettonTransferPayload, asAddressFriendly, asBase64, asHex, hasSignMessageSupport, getMaxOutgoingMessages, } from '@ton/walletkit'; | ||
| export * from './address/is-valid-address'; | ||
@@ -18,3 +18,4 @@ export * from './address/to-bounceble-address'; | ||
| export * from './balance/calc-max-spendable'; | ||
| export * from './balance/get-ton-shortfall'; | ||
| export * from './balance/check-ton-balance'; | ||
| export * from './balance/check-transfer-balance'; | ||
| export * from './arrays/key-by'; | ||
@@ -21,0 +22,0 @@ export * from './arrays/random-from-array'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEzE,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACH,WAAW,EACX,UAAU,EACV,cAAc,EACd,2BAA2B,EAC3B,iBAAiB,EACjB,QAAQ,EACR,KAAK,EACL,qBAAqB,EACrB,sBAAsB,GACzB,MAAM,gBAAgB,CAAC;AAExB,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC"} |
@@ -8,3 +8,3 @@ /** | ||
| */ | ||
| export { formatUnits, parseUnits, compareAddress } from '@ton/walletkit'; | ||
| export { formatUnits, parseUnits, compareAddress, createJettonTransferPayload, asAddressFriendly, asBase64, asHex, hasSignMessageSupport, getMaxOutgoingMessages, } from '@ton/walletkit'; | ||
| export * from './address/is-valid-address'; | ||
@@ -18,3 +18,4 @@ export * from './address/to-bounceble-address'; | ||
| export * from './balance/calc-max-spendable'; | ||
| export * from './balance/get-ton-shortfall'; | ||
| export * from './balance/check-ton-balance'; | ||
| export * from './balance/check-transfer-balance'; | ||
| export * from './arrays/key-by'; | ||
@@ -21,0 +22,0 @@ export * from './arrays/random-from-array'; |
+166
-0
@@ -635,2 +635,125 @@ # Actions | ||
| ## Gasless | ||
| Gasless lets a dApp submit on-chain transactions without the user holding TON for gas: a relayer co-signs and broadcasts the transaction, charging the user a fee in a relayer-accepted asset (e.g. USDT). The connected wallet must support the `SignMessage` TonConnect feature. See the [gasless guide](./gasless.md) for a regular-send → gasless-send migration. | ||
| The high-level flow is: | ||
| 1. `getGaslessConfig` – discover the relay address and assets the relayer accepts as fee payment. | ||
| 2. `getGaslessQuote` – ask the relayer for fee + wrapped messages (with a `validUntil`). | ||
| 3. `sendGaslessTransaction` – sign the wrapped messages via the wallet and submit the signed BoC. | ||
| ### `getGaslessManager` | ||
| Get the `GaslessManager` instance to interact with gasless providers directly. | ||
| ```ts | ||
| const gaslessManager = getGaslessManager(appKit); | ||
| ``` | ||
| ### `getGaslessProvider` | ||
| Get a specific gasless provider by its ID. Uses the default provider when no `id` is supplied. | ||
| ```ts | ||
| const provider = getGaslessProvider(appKit, { id: 'tonapi' }); | ||
| ``` | ||
| ### `getGaslessProviders` | ||
| Get all registered gasless providers. | ||
| ```ts | ||
| const providers = getGaslessProviders(appKit); | ||
| console.log( | ||
| 'Registered gasless providers:', | ||
| providers.map((p) => p.providerId), | ||
| ); | ||
| ``` | ||
| ### `setDefaultGaslessProvider` | ||
| Set the default gasless provider. Subsequent quote and send calls will use this provider when none is specified. | ||
| ```ts | ||
| setDefaultGaslessProvider(appKit, { providerId: 'tonapi' }); | ||
| ``` | ||
| ### `watchGaslessProviders` | ||
| Watch for new gasless provider registrations and default-provider changes. | ||
| ```ts | ||
| const unsubscribe = watchGaslessProviders(appKit, { | ||
| onChange: () => console.log('Gasless providers updated'), | ||
| }); | ||
| unsubscribe(); | ||
| ``` | ||
| ### `getGaslessProviderMetadata` | ||
| Fetch static metadata (display name, logo, url) for a gasless provider. | ||
| ```ts | ||
| const metadata = await getGaslessProviderMetadata(appKit); | ||
| console.log('Gasless provider:', metadata.name, metadata.url); | ||
| ``` | ||
| ### `getGaslessConfig` | ||
| Fetch the relayer's configuration on a network — the relay address (e.g. for jetton-transfer `responseDestination`) and the assets it accepts as fee payment. | ||
| ```ts | ||
| const config = await getGaslessConfig(appKit); | ||
| const feeAsset = config.supportedAssets[0].address; | ||
| console.log('Relay address:', config.relayAddress, '— supported fee assets:', config.supportedAssets.length); | ||
| ``` | ||
| ### `getGaslessQuote` | ||
| Ask the relayer for a gasless transaction quote. Returns relayer-wrapped messages, the fee charged in the chosen `feeAsset`, and the bundle validity window (`validUntil`). Omit `feeAsset` for free / sponsored providers — jetton-fee providers (like TonAPI) throw `GaslessError(UNSUPPORTED_OPERATION)` in that case. Quotes are typically valid for ~2 minutes. | ||
| ```ts | ||
| const quote = await getGaslessQuote(appKit, { | ||
| feeAsset, | ||
| messages: [ | ||
| { | ||
| address: 'EQ...jetton_wallet_address', | ||
| amount: '60000000', // 0.06 TON gas budget | ||
| payload: 'te6cckEBAQEAAgAAAA==' as never, | ||
| }, | ||
| ], | ||
| }); | ||
| console.log('Relayer fee:', quote.fee, 'valid until:', quote.validUntil); | ||
| ``` | ||
| ### `getGaslessJettonTransferQuote` | ||
| Convenience wrapper that builds a jetton transfer's messages (resolving the jetton wallet address, decimals and payload) and quotes them in one call. Takes semantic params (`jettonAddress`, `recipientAddress`, `amount`, `feeAsset`) instead of pre-built `messages`. Returns a `GaslessQuote` to pass to `sendGaslessTransaction`. | ||
| ```ts | ||
| // Convenience wrapper: builds the jetton transfer messages for you, then quotes. | ||
| const jettonQuote = await getGaslessJettonTransferQuote(appKit, { | ||
| jettonAddress: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs', | ||
| recipientAddress: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c', | ||
| amount: '100', | ||
| feeAsset, // pay the relayer fee in this jetton (here: USDT) | ||
| }); | ||
| await sendGaslessTransaction(appKit, { quote: jettonQuote }); | ||
| ``` | ||
| ### `sendGaslessTransaction` | ||
| Sign a previously computed gasless quote and submit the resulting BoC to the relayer. Returns a `GaslessSendResponse` — a strict superset of `SendTransactionResponse` (`{ boc, normalizedBoc, normalizedHash, internalBoc }`). | ||
| Throws: | ||
| - `GaslessError(QUOTE_EXPIRED)` if the quote's `validUntil` window has passed (checked before signing). | ||
| - `GaslessError(WALLET_MISMATCH)` if the quote was issued for a different address than the selected wallet. | ||
| - `GaslessError(SIGN_MESSAGE_NOT_SUPPORTED)` if the connected wallet does not advertise the `SignMessage` feature. | ||
| - `GaslessError(TOO_MANY_MESSAGES)` if the quote carries more messages than the wallet's `maxMessages` cap. | ||
| ```ts | ||
| const result = await sendGaslessTransaction(appKit, { quote }); | ||
| console.log('Submitted gasless transaction. Hash:', result.normalizedHash, 'BoC:', result.internalBoc); | ||
| ``` | ||
| ## Transaction | ||
@@ -668,2 +791,21 @@ | ||
| ``` | ||
| ### `signMessage` | ||
| Ask the connected wallet to sign a transaction-shaped request without broadcasting it. Returns a signed internal-message BoC that can be relayed on-chain by a third party (e.g. a gasless relayer). Requires wallet support for the `SignMessage` feature. | ||
| ```ts | ||
| const result = await signMessage(appKit, { | ||
| messages: [ | ||
| { | ||
| address: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c', | ||
| amount: '100000000', // 0.1 TON in nanotons | ||
| }, | ||
| ], | ||
| }); | ||
| // result.internalBoc is a signed internal message BoC (base64) | ||
| // that can be relayed on-chain by a third party (e.g. a gasless relayer). | ||
| console.log('Signed Message:', result); | ||
| ``` | ||
@@ -751,2 +893,26 @@ ### `transferTon` | ||
| ### `getSignMessageSupport` | ||
| Whether the selected wallet advertises the `SignMessage` feature (required for gasless). Fail-closed: returns `false` when no wallet is selected or features aren't advertised. | ||
| ```ts | ||
| const supported = getSignMessageSupport(appKit); | ||
| console.log(supported ? 'Wallet supports SignMessage (gasless available)' : 'SignMessage not supported'); | ||
| ``` | ||
| ### `watchSignMessageSupport` | ||
| Watch whether the selected wallet supports `SignMessage`, re-evaluated on every selection change. | ||
| ```ts | ||
| const unsubscribe = watchSignMessageSupport(appKit, { | ||
| onChange: (supported) => { | ||
| console.log('SignMessage support changed:', supported); | ||
| }, | ||
| }); | ||
| // Later: unsubscribe(); | ||
| ``` | ||
| <!-- | ||
@@ -753,0 +919,0 @@ This file is auto-generated. Do not edit manually. |
+18
-5
| { | ||
| "name": "@ton/appkit", | ||
| "version": "1.0.0-alpha.3", | ||
| "version": "1.0.0-alpha.4", | ||
| "description": "", | ||
@@ -63,2 +63,12 @@ "repository": { | ||
| } | ||
| }, | ||
| "./gasless/tonapi": { | ||
| "import": { | ||
| "types": "./dist/esm/gasless/tonapi/index.d.ts", | ||
| "default": "./dist/esm/gasless/tonapi/index.js" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/gasless/tonapi/index.d.ts", | ||
| "default": "./dist/cjs/gasless/tonapi/index.js" | ||
| } | ||
| } | ||
@@ -79,2 +89,5 @@ }, | ||
| "./dist/esm/staking/tonstakers/index.d.ts" | ||
| ], | ||
| "gasless/tonapi": [ | ||
| "./dist/esm/gasless/tonapi/index.d.ts" | ||
| ] | ||
@@ -85,3 +98,3 @@ } | ||
| "lru-cache": "^11.5.0", | ||
| "@ton/walletkit": "1.0.0-alpha.3" | ||
| "@ton/walletkit": "1.0.0-alpha.4" | ||
| }, | ||
@@ -92,4 +105,4 @@ "peerDependencies": { | ||
| "@ton/crypto": "^3.3.0", | ||
| "@tonconnect/ui": ">=2.5.0-alpha.1", | ||
| "@tonconnect/sdk": ">=3.5.0-alpha.1" | ||
| "@tonconnect/ui": ">=3.0.0", | ||
| "@tonconnect/sdk": ">=4.0.0" | ||
| }, | ||
@@ -113,3 +126,3 @@ "peerDependenciesMeta": { | ||
| "@ton/core": "^0.63.1", | ||
| "@tonconnect/ui": "^2.5.0-alpha.0", | ||
| "@tonconnect/ui": "^3.0.0", | ||
| "typescript": "5.9.3", | ||
@@ -116,0 +129,0 @@ "vitest": "^4.1.4" |
+61
-0
@@ -111,2 +111,51 @@ /** | ||
| // Gasless | ||
| export { getGaslessManager, type GetGaslessManagerReturnType } from './gasless/get-gasless-manager'; | ||
| export { | ||
| getGaslessProvider, | ||
| type GetGaslessProviderOptions, | ||
| type GetGaslessProviderReturnType, | ||
| } from './gasless/get-gasless-provider'; | ||
| export { getGaslessProviders, type GetGaslessProvidersReturnType } from './gasless/get-gasless-providers'; | ||
| export { | ||
| setDefaultGaslessProvider, | ||
| type SetDefaultGaslessProviderParameters, | ||
| type SetDefaultGaslessProviderReturnType, | ||
| } from './gasless/set-default-gasless-provider'; | ||
| export { | ||
| watchGaslessProviders, | ||
| type WatchGaslessProvidersParameters, | ||
| type WatchGaslessProvidersReturnType, | ||
| } from './gasless/watch-gasless-providers'; | ||
| export { | ||
| getGaslessConfig, | ||
| type GetGaslessConfigOptions, | ||
| type GetGaslessConfigReturnType, | ||
| type GetGaslessConfigErrorType, | ||
| } from './gasless/get-gasless-config'; | ||
| export { | ||
| getGaslessProviderMetadata, | ||
| type GetGaslessProviderMetadataOptions, | ||
| type GetGaslessProviderMetadataReturnType, | ||
| type GetGaslessProviderMetadataErrorType, | ||
| } from './gasless/get-gasless-provider-metadata'; | ||
| export { | ||
| getGaslessQuote, | ||
| type GetGaslessQuoteOptions, | ||
| type GetGaslessQuoteReturnType, | ||
| type GetGaslessQuoteErrorType, | ||
| } from './gasless/get-gasless-quote'; | ||
| export { | ||
| getGaslessJettonTransferQuote, | ||
| type GetGaslessJettonTransferQuoteOptions, | ||
| type GetGaslessJettonTransferQuoteReturnType, | ||
| type GetGaslessJettonTransferQuoteErrorType, | ||
| } from './gasless/get-gasless-jetton-transfer-quote'; | ||
| export { | ||
| sendGaslessTransaction, | ||
| type SendGaslessTransactionParameters, | ||
| type SendGaslessTransactionReturnType, | ||
| type SendGaslessTransactionErrorType, | ||
| } from './gasless/send-gasless-transaction'; | ||
| // Signing | ||
@@ -188,2 +237,8 @@ export { signText, type SignTextParameters, type SignTextReturnType } from './signing/sign-text'; | ||
| } from './transaction/send-transaction'; | ||
| export { | ||
| signMessage, | ||
| type SignMessageParameters, | ||
| type SignMessageReturnType, | ||
| type SignMessageErrorType, | ||
| } from './transaction/sign-message'; | ||
| export { transferTon, type TransferTonParameters, type TransferTonReturnType } from './transaction/transfer-ton'; | ||
@@ -230,3 +285,9 @@ export { | ||
| } from './wallets/watch-selected-wallet'; | ||
| export { getSignMessageSupport, type GetSignMessageSupportReturnType } from './wallets/get-sign-message-support'; | ||
| export { | ||
| watchSignMessageSupport, | ||
| type WatchSignMessageSupportParameters, | ||
| type WatchSignMessageSupportReturnType, | ||
| } from './wallets/watch-sign-message-support'; | ||
| export { | ||
| watchConnectedWallets, | ||
@@ -233,0 +294,0 @@ type WatchConnectedWalletsParameters, |
@@ -29,2 +29,3 @@ /** | ||
| comment?: string; | ||
| responseDestination?: string; | ||
| } | ||
@@ -41,3 +42,3 @@ | ||
| ): Promise<CreateTransferJettonTransactionReturnType> => { | ||
| const { jettonAddress, recipientAddress, amount, jettonDecimals, comment } = parameters; | ||
| const { jettonAddress, recipientAddress, amount, jettonDecimals, comment, responseDestination } = parameters; | ||
@@ -74,3 +75,3 @@ const wallet = getSelectedWallet(appKit); | ||
| destination: recipientAddress, | ||
| responseDestination: ownerAddress, | ||
| responseDestination: responseDestination ?? ownerAddress, | ||
| comment, | ||
@@ -77,0 +78,0 @@ }); |
@@ -12,2 +12,3 @@ /** | ||
| import type { TransactionRequest, TransactionRequestMessage } from '../../types/transaction'; | ||
| import { asBase64 } from '../../utils'; | ||
| import type { AppKit } from '../../core/app-kit'; | ||
@@ -49,3 +50,3 @@ import { getSelectedWallet } from '../wallets/get-selected-wallet'; | ||
| amount: parseUnits(amount, 9).toString(), | ||
| stateInit, | ||
| stateInit: stateInit ? asBase64(stateInit) : undefined, | ||
| }; | ||
@@ -55,3 +56,3 @@ | ||
| if (payload) { | ||
| message.payload = payload; | ||
| message.payload = asBase64(payload); | ||
| } else if (comment) { | ||
@@ -58,0 +59,0 @@ message.payload = createCommentPayloadBase64(comment); |
@@ -12,4 +12,4 @@ /** | ||
| import type { SignDataPayload as TonConnectSignDataPayload } from '@tonconnect/sdk'; | ||
| import type { SendTransactionResponse, UserFriendlyAddress, Hex } from '@ton/walletkit'; | ||
| import { asHex, createWalletId, getNormalizedExtMessageHash } from '@ton/walletkit'; | ||
| import type { Feature, SendTransactionResponse, UserFriendlyAddress, Hex } from '@ton/walletkit'; | ||
| import { asBase64, asHex, createWalletId, getNormalizedExtMessageHash } from '@ton/walletkit'; | ||
| import type { TonConnectUI } from '@tonconnect/ui'; | ||
@@ -21,3 +21,3 @@ | ||
| import type { WalletInterface } from '../../../types/wallet'; | ||
| import type { SignDataRequest, SignDataResponse } from '../../../types/signing'; | ||
| import type { SignDataRequest, SignDataResponse, SignMessageResponse } from '../../../types/signing'; | ||
| import { Network } from '../../../types/network'; | ||
@@ -78,2 +78,6 @@ | ||
| getSupportedFeatures(): Feature[] | undefined { | ||
| return this.tonConnectWallet.device?.features; | ||
| } | ||
| // ========================================== | ||
@@ -84,12 +88,3 @@ // Signing / Transactions | ||
| async sendTransaction(request: TransactionRequest): Promise<SendTransactionResponse> { | ||
| const transaction = { | ||
| validUntil: request.validUntil || getValidUntil(), | ||
| messages: request.messages.map((msg) => ({ | ||
| address: msg.address, | ||
| amount: String(msg.amount), | ||
| payload: msg.payload, | ||
| stateInit: msg.stateInit, | ||
| })), | ||
| network: request.network?.chainId ?? this.tonConnectWallet.account?.chain, | ||
| }; | ||
| const transaction = this.mapTransactionRequest(request); | ||
@@ -106,2 +101,12 @@ const result = await this.tonConnectUI.sendTransaction(transaction); | ||
| async signMessage(request: TransactionRequest): Promise<SignMessageResponse> { | ||
| const message = this.mapTransactionRequest(request); | ||
| const result = await this.tonConnectUI.signMessage(message); | ||
| return { | ||
| internalBoc: asBase64(result.internalBoc), | ||
| }; | ||
| } | ||
| async signData(payload: SignDataRequest): Promise<SignDataResponse> { | ||
@@ -123,2 +128,15 @@ const result = await this.tonConnectUI.signData(this.mapSignDataRequest(payload)); | ||
| private mapTransactionRequest(request: TransactionRequest) { | ||
| return { | ||
| validUntil: request.validUntil || getValidUntil(), | ||
| messages: request.messages.map((msg) => ({ | ||
| address: msg.address, | ||
| amount: String(msg.amount), | ||
| payload: msg.payload, | ||
| stateInit: msg.stateInit, | ||
| })), | ||
| network: request.network?.chainId ?? this.tonConnectWallet.account?.chain, | ||
| }; | ||
| } | ||
| private mapSignDataRequest(request: SignDataRequest): TonConnectSignDataPayload { | ||
@@ -125,0 +143,0 @@ const chainId = request.network?.chainId ?? this.getNetwork().chainId; |
@@ -15,2 +15,4 @@ /** | ||
| import { StakingManager } from '../../../staking'; | ||
| import { GaslessManager } from '../../../gasless'; | ||
| import type { GaslessProviderInterface } from '../../../gasless'; | ||
| import type { Connector, ConnectorFactoryContext, ConnectorInput } from '../../../types/connector'; | ||
@@ -37,2 +39,3 @@ import { EventEmitter } from '../../emitter'; | ||
| readonly stakingManager: StakingManager; | ||
| readonly gaslessManager: GaslessManager; | ||
@@ -61,2 +64,3 @@ readonly networkManager: AppKitNetworkManager; | ||
| this.stakingManager = new StakingManager(() => this.createFactoryContext()); | ||
| this.gaslessManager = new GaslessManager(() => this.createFactoryContext()); | ||
| this.streamingManager = new StreamingManager(() => this.createFactoryContext()); | ||
@@ -132,2 +136,5 @@ | ||
| break; | ||
| case 'gasless': | ||
| this.gaslessManager.registerProvider(provider as GaslessProviderInterface); | ||
| break; | ||
| default: | ||
@@ -134,0 +141,0 @@ throw new Error('Unknown provider type'); |
@@ -56,3 +56,6 @@ /** | ||
| setSelectedWalletId(id: string | null): void { | ||
| if (this._selectedWalletId === id) return; | ||
| this._selectedWalletId = id; | ||
| this.emitter.emit(WALLETS_EVENTS.SELECTION_CHANGED, { walletId: id }, 'wallets-manager'); | ||
| } | ||
@@ -72,18 +75,5 @@ | ||
| // If list is not empty, auto-select the first one | ||
| if (wallets.length > 0) { | ||
| this._selectedWalletId = wallets[0].getWalletId(); | ||
| this.emitter.emit( | ||
| WALLETS_EVENTS.SELECTION_CHANGED, | ||
| { walletId: this._selectedWalletId }, | ||
| 'wallets-manager', | ||
| ); | ||
| return; | ||
| } | ||
| // Otherwise clear selection | ||
| this._selectedWalletId = null; | ||
| this.emitter.emit(WALLETS_EVENTS.SELECTION_CHANGED, { walletId: null }, 'wallets-manager'); | ||
| // Auto-select the first wallet, or clear selection when the list is empty. | ||
| this.setSelectedWalletId(wallets.length > 0 ? wallets[0].getWalletId() : null); | ||
| } | ||
| } |
+1
-0
@@ -38,2 +38,3 @@ /** | ||
| export * from './staking'; | ||
| export * from './gasless'; | ||
@@ -40,0 +41,0 @@ // Actions |
+60
-0
@@ -168,2 +168,50 @@ /** | ||
| // Gasless | ||
| export { | ||
| getGaslessConfigQueryOptions, | ||
| getGaslessConfigQueryKey, | ||
| type GetGaslessConfigQueryConfig, | ||
| type GetGaslessConfigData, | ||
| type GetGaslessConfigErrorType, | ||
| type GetGaslessConfigQueryKey, | ||
| type GetGaslessConfigQueryOptions, | ||
| } from './gasless/get-gasless-config'; | ||
| export { | ||
| getGaslessProviderMetadataQueryOptions, | ||
| getGaslessProviderMetadataQueryKey, | ||
| type GetGaslessProviderMetadataQueryConfig, | ||
| type GetGaslessProviderMetadataData, | ||
| type GetGaslessProviderMetadataErrorType, | ||
| type GetGaslessProviderMetadataQueryKey, | ||
| type GetGaslessProviderMetadataQueryOptions, | ||
| } from './gasless/get-gasless-provider-metadata'; | ||
| export { | ||
| getGaslessQuoteQueryOptions, | ||
| getGaslessQuoteQueryKey, | ||
| GASLESS_QUOTE_STALE_TIME_MS, | ||
| type GetGaslessQuoteQueryConfig, | ||
| type GetGaslessQuoteData, | ||
| type GetGaslessQuoteErrorType, | ||
| type GetGaslessQuoteQueryKey, | ||
| type GetGaslessQuoteQueryOptions, | ||
| } from './gasless/get-gasless-quote'; | ||
| export { | ||
| getGaslessJettonTransferQuoteQueryOptions, | ||
| getGaslessJettonTransferQuoteQueryKey, | ||
| type GetGaslessJettonTransferQuoteQueryConfig, | ||
| type GetGaslessJettonTransferQuoteData, | ||
| type GetGaslessJettonTransferQuoteErrorType, | ||
| type GetGaslessJettonTransferQuoteQueryKey, | ||
| type GetGaslessJettonTransferQuoteQueryOptions, | ||
| } from './gasless/get-gasless-jetton-transfer-quote'; | ||
| export { | ||
| sendGaslessTransactionMutationOptions, | ||
| type SendGaslessTransactionMutationConfig, | ||
| type SendGaslessTransactionData, | ||
| type SendGaslessTransactionErrorType, | ||
| type SendGaslessTransactionMutate, | ||
| type SendGaslessTransactionMutateAsync, | ||
| type SendGaslessTransactionVariables, | ||
| } from './gasless/send-gasless-transaction'; | ||
| // Staking | ||
@@ -225,2 +273,14 @@ export { | ||
| export { | ||
| signMessageMutationOptions, | ||
| type SignMessageData, | ||
| type SignMessageErrorType, | ||
| type SignMessageMutate, | ||
| type SignMessageMutateAsync, | ||
| type SignMessageMutationOptions, | ||
| type SignMessageOptions, | ||
| type SignMessageVariables, | ||
| type SignMessageParameters, | ||
| type SignMessageReturnType, | ||
| } from './transaction/sign-message'; | ||
| export { | ||
| getTransactionStatusQueryOptions, | ||
@@ -227,0 +287,0 @@ type GetTransactionStatusData, |
@@ -9,3 +9,8 @@ /** | ||
| import type { SwapProviderInterface, StakingProviderInterface, StreamingProvider } from '@ton/walletkit'; | ||
| import type { | ||
| SwapProviderInterface, | ||
| StakingProviderInterface, | ||
| StreamingProvider, | ||
| GaslessProviderInterface, | ||
| } from '@ton/walletkit'; | ||
@@ -15,2 +20,6 @@ /** | ||
| */ | ||
| export type AppKitProvider = SwapProviderInterface | StakingProviderInterface | StreamingProvider; | ||
| export type AppKitProvider = | ||
| | SwapProviderInterface | ||
| | StakingProviderInterface | ||
| | StreamingProvider | ||
| | GaslessProviderInterface; |
+12
-0
@@ -79,1 +79,13 @@ /** | ||
| } | ||
| /** | ||
| * SignMessage Response - returned from wallet. | ||
| * | ||
| * Wallet signs a transaction-shaped request with the internal message opcode | ||
| * (instead of external), so the resulting BoC can be relayed on-chain by a | ||
| * third party (e.g. a gasless relayer) rather than broadcast directly. | ||
| */ | ||
| export interface SignMessageResponse { | ||
| /** Signed internal message BoC (base64) ready to be relayed */ | ||
| internalBoc: Base64String; | ||
| } |
@@ -12,2 +12,3 @@ /** | ||
| import type { Network } from './network'; | ||
| import type { Base64String } from './primitives'; | ||
@@ -60,3 +61,3 @@ export type { TransactionStatus } from '@ton/walletkit'; | ||
| */ | ||
| stateInit?: string; | ||
| stateInit?: Base64String; | ||
@@ -66,3 +67,3 @@ /** | ||
| */ | ||
| payload?: string; | ||
| payload?: Base64String; | ||
| } |
+20
-2
@@ -9,6 +9,8 @@ /** | ||
| import type { SendTransactionResponse, Hex, UserFriendlyAddress } from '@ton/walletkit'; | ||
| import type { Feature, SendTransactionResponse, Hex, UserFriendlyAddress } from '@ton/walletkit'; | ||
| export type { Feature } from '@ton/walletkit'; | ||
| import type { TransactionRequest } from './transaction'; | ||
| import type { SignDataRequest, SignDataResponse } from './signing'; | ||
| import type { SignDataRequest, SignDataResponse, SignMessageResponse } from './signing'; | ||
| import type { Network } from './network'; | ||
@@ -41,2 +43,9 @@ | ||
| /** | ||
| * Features supported by the underlying wallet (e.g. SendTransaction, SignData, SignMessage). | ||
| * Returns undefined when the connector cannot report capabilities. | ||
| * Callers should gracefully degrade when a feature is missing. | ||
| */ | ||
| getSupportedFeatures(): Feature[] | undefined; | ||
| // ========================================== | ||
@@ -51,2 +60,11 @@ // Actions requiring wallet signature | ||
| signData(payload: SignDataRequest): Promise<SignDataResponse>; | ||
| /** | ||
| * Sign a transaction-shaped request without broadcasting it. | ||
| * The wallet returns a signed internal-message BoC that a third party can relay | ||
| * on-chain (e.g. a gasless relayer). | ||
| * | ||
| * Requires the wallet to support the SignMessage feature (see getSupportedFeatures). | ||
| */ | ||
| signMessage(request: TransactionRequest): Promise<SignMessageResponse>; | ||
| } |
+13
-2
@@ -9,3 +9,13 @@ /** | ||
| export { formatUnits, parseUnits, compareAddress } from '@ton/walletkit'; | ||
| export { | ||
| formatUnits, | ||
| parseUnits, | ||
| compareAddress, | ||
| createJettonTransferPayload, | ||
| asAddressFriendly, | ||
| asBase64, | ||
| asHex, | ||
| hasSignMessageSupport, | ||
| getMaxOutgoingMessages, | ||
| } from '@ton/walletkit'; | ||
@@ -20,3 +30,4 @@ export * from './address/is-valid-address'; | ||
| export * from './balance/calc-max-spendable'; | ||
| export * from './balance/get-ton-shortfall'; | ||
| export * from './balance/check-ton-balance'; | ||
| export * from './balance/check-transfer-balance'; | ||
| export * from './arrays/key-by'; | ||
@@ -23,0 +34,0 @@ export * from './arrays/random-from-array'; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| /** Default extra TON buffer added on top of built transaction outflow when checking balance before sending. */ | ||
| export declare const DEFAULT_GAS_BUFFER_NANOS = 100000000n; | ||
| /** | ||
| * Default extra headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one that will actually be sent | ||
| * after the amount changes. 0.02 TON. | ||
| */ | ||
| export declare const DEFAULT_SAFETY_MARGIN_NANOS = 20000000n; | ||
| export type TonShortfall = { | ||
| mode: 'reduce'; | ||
| requiredNanos: bigint; | ||
| suggestedFromAmount: string; | ||
| } | { | ||
| mode: 'topup'; | ||
| requiredNanos: bigint; | ||
| suggestedFromAmount: ''; | ||
| }; | ||
| export interface GetTonShortfallParams { | ||
| /** Messages of the built transaction. Each `amount` is the TON value in nanos attached to the message. */ | ||
| messages: Array<{ | ||
| amount: string; | ||
| }>; | ||
| /** User's current TON balance as a decimal string (same format `formatUnits(balance, 9)` returns). */ | ||
| tonBalance: string | undefined; | ||
| /** The outgoing token — `{ address: 'ton' }` when the user spends TON, otherwise a jetton. */ | ||
| fromToken: { | ||
| address: string; | ||
| }; | ||
| /** Amount the user intends to spend in `fromToken` units, as a decimal string. */ | ||
| fromAmount: string; | ||
| /** | ||
| * Extra TON headroom on top of built-tx outflow when checking balance before sending. | ||
| * Defaults to {@link DEFAULT_GAS_BUFFER_NANOS}. | ||
| */ | ||
| gasBufferNanos?: bigint; | ||
| /** | ||
| * Extra headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Defaults to {@link DEFAULT_SAFETY_MARGIN_NANOS}. | ||
| */ | ||
| safetyMarginNanos?: bigint; | ||
| } | ||
| /** | ||
| * Check whether the user's TON balance covers the built transaction. | ||
| * - Returns `null` if the balance is sufficient. | ||
| * - Returns `{ mode: 'reduce', ... }` with a smaller suggested `fromAmount` when `fromToken` is TON | ||
| * and the balance is enough to cover at least gas (user can fix it by reducing the amount). | ||
| * - Returns `{ mode: 'topup', ... }` when `fromToken` is a jetton (reducing jetton amount won't free up TON gas), | ||
| * or when `fromToken` is TON but the balance can't even cover gas (reducing won't help — user must top up). | ||
| */ | ||
| export declare const getTonShortfall: ({ messages, tonBalance, fromToken, fromAmount, gasBufferNanos, safetyMarginNanos, }: GetTonShortfallParams) => TonShortfall | undefined; | ||
| //# sourceMappingURL=get-ton-shortfall.d.ts.map |
| {"version":3,"file":"get-ton-shortfall.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/get-ton-shortfall.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,+GAA+G;AAC/G,eAAO,MAAM,wBAAwB,aAAe,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,YAAc,CAAC;AAEvD,MAAM,MAAM,YAAY,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,EAAE,CAAA;CAAE,CAAC;AAExE,MAAM,WAAW,qBAAqB;IAClC,0GAA0G;IAC1G,QAAQ,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpC,sGAAsG;IACtG,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,8FAA8F;IAC9F,SAAS,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,qFAO7B,qBAAqB,KAAG,YAAY,GAAG,SAqBzC,CAAC"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getTonShortfall = exports.DEFAULT_SAFETY_MARGIN_NANOS = exports.DEFAULT_GAS_BUFFER_NANOS = void 0; | ||
| const walletkit_1 = require("@ton/walletkit"); | ||
| /** Default extra TON buffer added on top of built transaction outflow when checking balance before sending. */ | ||
| exports.DEFAULT_GAS_BUFFER_NANOS = 100000000n; | ||
| /** | ||
| * Default extra headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one that will actually be sent | ||
| * after the amount changes. 0.02 TON. | ||
| */ | ||
| exports.DEFAULT_SAFETY_MARGIN_NANOS = 20000000n; | ||
| /** | ||
| * Check whether the user's TON balance covers the built transaction. | ||
| * - Returns `null` if the balance is sufficient. | ||
| * - Returns `{ mode: 'reduce', ... }` with a smaller suggested `fromAmount` when `fromToken` is TON | ||
| * and the balance is enough to cover at least gas (user can fix it by reducing the amount). | ||
| * - Returns `{ mode: 'topup', ... }` when `fromToken` is a jetton (reducing jetton amount won't free up TON gas), | ||
| * or when `fromToken` is TON but the balance can't even cover gas (reducing won't help — user must top up). | ||
| */ | ||
| const getTonShortfall = ({ messages, tonBalance, fromToken, fromAmount, gasBufferNanos = exports.DEFAULT_GAS_BUFFER_NANOS, safetyMarginNanos = exports.DEFAULT_SAFETY_MARGIN_NANOS, }) => { | ||
| const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n); | ||
| const requiredNanos = totalOutNanos + gasBufferNanos; | ||
| const tonBalanceNanos = tonBalance ? (0, walletkit_1.parseUnits)(tonBalance, 9) : 0n; | ||
| if (tonBalanceNanos >= requiredNanos) | ||
| return; | ||
| if (fromToken.address === 'ton') { | ||
| const gasOnlyNanos = totalOutNanos - (0, walletkit_1.parseUnits)(fromAmount, 9); | ||
| const nonSwapReservedNanos = gasOnlyNanos + gasBufferNanos + safetyMarginNanos; | ||
| // Balance can't cover even gas for a minimal outgoing tx — reducing the amount won't help. | ||
| if (tonBalanceNanos <= nonSwapReservedNanos) { | ||
| return { mode: 'topup', requiredNanos, suggestedFromAmount: '' }; | ||
| } | ||
| const suggestedFromAmount = (0, walletkit_1.formatUnits)(tonBalanceNanos - nonSwapReservedNanos, 9); | ||
| return { mode: 'reduce', requiredNanos, suggestedFromAmount }; | ||
| } | ||
| return { mode: 'topup', requiredNanos, suggestedFromAmount: '' }; | ||
| }; | ||
| exports.getTonShortfall = getTonShortfall; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export {}; | ||
| //# sourceMappingURL=get-ton-shortfall.test.d.ts.map |
| {"version":3,"file":"get-ton-shortfall.test.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/get-ton-shortfall.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"} |
| "use strict"; | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const vitest_1 = require("vitest"); | ||
| const get_ton_shortfall_1 = require("./get-ton-shortfall"); | ||
| const TON = { address: 'ton' }; | ||
| const JETTON = { address: 'EQA_jetton_address' }; | ||
| // Helper — convert a decimal string of TON to nanos as a string (for message amounts). | ||
| const toNanos = (ton) => BigInt(Math.round(Number(ton) * 1e9)).toString(); | ||
| (0, vitest_1.describe)('getTonShortfall', () => { | ||
| (0, vitest_1.it)('returns undefined when TON balance covers the built transaction', () => { | ||
| // Swap 1 TON, total tx outflow 1.3 TON (1 TON swap + 0.3 TON attached gas), balance 2 TON. | ||
| const result = (0, get_ton_shortfall_1.getTonShortfall)({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '2', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }); | ||
| (0, vitest_1.expect)(result).toBeUndefined(); | ||
| }); | ||
| (0, vitest_1.it)('returns topup when fromToken is a jetton and TON balance is below outflow + buffer', () => { | ||
| // Jetton swap, tx needs 0.05 TON for gas, user has 0 TON. | ||
| const result = (0, get_ton_shortfall_1.getTonShortfall)({ | ||
| messages: [{ amount: toNanos('0.05') }], | ||
| tonBalance: '0', | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ | ||
| mode: 'topup', | ||
| requiredNanos: 50000000n + get_ton_shortfall_1.DEFAULT_GAS_BUFFER_NANOS, | ||
| suggestedFromAmount: '', | ||
| }); | ||
| }); | ||
| (0, vitest_1.it)('returns reduce for TON-from when balance covers gas but not full amount', () => { | ||
| // User wants 1 TON swap, total outflow 1.3 TON, has 1 TON. Gas only = 0.3 TON. | ||
| // Balance (1) > nonSwapReserved (0.3 gas + 0.1 buffer + 0.02 safety = 0.42) → reduce mode. | ||
| const result = (0, get_ton_shortfall_1.getTonShortfall)({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }); | ||
| (0, vitest_1.expect)(result?.mode).toBe('reduce'); | ||
| if (result?.mode !== 'reduce') | ||
| return; | ||
| // Suggested = 1 - 0.42 = 0.58 | ||
| (0, vitest_1.expect)(result.suggestedFromAmount).toBe('0.58'); | ||
| (0, vitest_1.expect)(result.requiredNanos).toBe(1300000000n + get_ton_shortfall_1.DEFAULT_GAS_BUFFER_NANOS); | ||
| }); | ||
| (0, vitest_1.it)('returns topup for TON-from when balance cannot cover even gas (reducing would not help)', () => { | ||
| // User wants 1 TON swap, total outflow 1.3 TON → gas = 0.3 TON. Balance 0.2 TON. | ||
| // nonSwapReserved = 0.3 + 0.1 buffer + 0.02 safety = 0.42 TON → balance (0.2) <= 0.42 → topup. | ||
| const result = (0, get_ton_shortfall_1.getTonShortfall)({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '0.2', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }); | ||
| (0, vitest_1.expect)(result).toEqual({ | ||
| mode: 'topup', | ||
| requiredNanos: 1300000000n + get_ton_shortfall_1.DEFAULT_GAS_BUFFER_NANOS, | ||
| suggestedFromAmount: '', | ||
| }); | ||
| }); | ||
| (0, vitest_1.it)('treats an undefined tonBalance as zero', () => { | ||
| const result = (0, get_ton_shortfall_1.getTonShortfall)({ | ||
| messages: [{ amount: toNanos('0.05') }], | ||
| tonBalance: undefined, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| (0, vitest_1.expect)(result?.mode).toBe('topup'); | ||
| }); | ||
| (0, vitest_1.it)('sums amounts across multiple messages', () => { | ||
| // Two messages attaching 0.6 TON each → totalOut = 1.2 TON. Balance 1 TON → shortfall. | ||
| const result = (0, get_ton_shortfall_1.getTonShortfall)({ | ||
| messages: [{ amount: toNanos('0.6') }, { amount: toNanos('0.6') }], | ||
| tonBalance: '1', | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| (0, vitest_1.expect)(result?.mode).toBe('topup'); | ||
| (0, vitest_1.expect)(result?.requiredNanos).toBe(1200000000n + get_ton_shortfall_1.DEFAULT_GAS_BUFFER_NANOS); | ||
| }); | ||
| (0, vitest_1.it)('respects a custom gasBufferNanos', () => { | ||
| const baseParams = { | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1.3', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }; | ||
| // With the default buffer (0.1 TON), balance 1.3 is insufficient (needs 1.4). | ||
| (0, vitest_1.expect)((0, get_ton_shortfall_1.getTonShortfall)(baseParams)?.mode).toBe('reduce'); | ||
| // With a zero buffer, 1.3 TON balance covers the 1.3 TON outflow exactly. | ||
| (0, vitest_1.expect)((0, get_ton_shortfall_1.getTonShortfall)({ ...baseParams, gasBufferNanos: 0n })).toBeUndefined(); | ||
| }); | ||
| (0, vitest_1.it)('respects a custom safetyMarginNanos in the reduce branch', () => { | ||
| // Default margin: suggested = balance - gas - buffer - 0.02 = 1 - 0.3 - 0.1 - 0.02 = 0.58 | ||
| // Zero margin: suggested = balance - gas - buffer = 1 - 0.3 - 0.1 = 0.6 | ||
| const baseParams = { | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }; | ||
| const withDefault = (0, get_ton_shortfall_1.getTonShortfall)(baseParams); | ||
| (0, vitest_1.expect)(withDefault?.mode === 'reduce' ? withDefault.suggestedFromAmount : null).toBe('0.58'); | ||
| const withZero = (0, get_ton_shortfall_1.getTonShortfall)({ ...baseParams, safetyMarginNanos: 0n }); | ||
| (0, vitest_1.expect)(withZero?.mode === 'reduce' ? withZero.suggestedFromAmount : null).toBe('0.6'); | ||
| }); | ||
| (0, vitest_1.it)('flips from reduce to topup when a large custom safetyMarginNanos eats the balance', () => { | ||
| // Balance 1 TON, gas 0.3 TON, buffer 0.1 TON. With a 1 TON safety margin, nonSwapReserved becomes 1.4 TON → topup. | ||
| const result = (0, get_ton_shortfall_1.getTonShortfall)({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| safetyMarginNanos: 1000000000n, | ||
| }); | ||
| (0, vitest_1.expect)(result?.mode).toBe('topup'); | ||
| }); | ||
| (0, vitest_1.it)('exports sane default constants', () => { | ||
| (0, vitest_1.expect)(get_ton_shortfall_1.DEFAULT_GAS_BUFFER_NANOS).toBe(100000000n); | ||
| (0, vitest_1.expect)(get_ton_shortfall_1.DEFAULT_SAFETY_MARGIN_NANOS).toBe(20000000n); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| /** Default extra TON buffer added on top of built transaction outflow when checking balance before sending. */ | ||
| export declare const DEFAULT_GAS_BUFFER_NANOS = 100000000n; | ||
| /** | ||
| * Default extra headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one that will actually be sent | ||
| * after the amount changes. 0.02 TON. | ||
| */ | ||
| export declare const DEFAULT_SAFETY_MARGIN_NANOS = 20000000n; | ||
| export type TonShortfall = { | ||
| mode: 'reduce'; | ||
| requiredNanos: bigint; | ||
| suggestedFromAmount: string; | ||
| } | { | ||
| mode: 'topup'; | ||
| requiredNanos: bigint; | ||
| suggestedFromAmount: ''; | ||
| }; | ||
| export interface GetTonShortfallParams { | ||
| /** Messages of the built transaction. Each `amount` is the TON value in nanos attached to the message. */ | ||
| messages: Array<{ | ||
| amount: string; | ||
| }>; | ||
| /** User's current TON balance as a decimal string (same format `formatUnits(balance, 9)` returns). */ | ||
| tonBalance: string | undefined; | ||
| /** The outgoing token — `{ address: 'ton' }` when the user spends TON, otherwise a jetton. */ | ||
| fromToken: { | ||
| address: string; | ||
| }; | ||
| /** Amount the user intends to spend in `fromToken` units, as a decimal string. */ | ||
| fromAmount: string; | ||
| /** | ||
| * Extra TON headroom on top of built-tx outflow when checking balance before sending. | ||
| * Defaults to {@link DEFAULT_GAS_BUFFER_NANOS}. | ||
| */ | ||
| gasBufferNanos?: bigint; | ||
| /** | ||
| * Extra headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Defaults to {@link DEFAULT_SAFETY_MARGIN_NANOS}. | ||
| */ | ||
| safetyMarginNanos?: bigint; | ||
| } | ||
| /** | ||
| * Check whether the user's TON balance covers the built transaction. | ||
| * - Returns `null` if the balance is sufficient. | ||
| * - Returns `{ mode: 'reduce', ... }` with a smaller suggested `fromAmount` when `fromToken` is TON | ||
| * and the balance is enough to cover at least gas (user can fix it by reducing the amount). | ||
| * - Returns `{ mode: 'topup', ... }` when `fromToken` is a jetton (reducing jetton amount won't free up TON gas), | ||
| * or when `fromToken` is TON but the balance can't even cover gas (reducing won't help — user must top up). | ||
| */ | ||
| export declare const getTonShortfall: ({ messages, tonBalance, fromToken, fromAmount, gasBufferNanos, safetyMarginNanos, }: GetTonShortfallParams) => TonShortfall | undefined; | ||
| //# sourceMappingURL=get-ton-shortfall.d.ts.map |
| {"version":3,"file":"get-ton-shortfall.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/get-ton-shortfall.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,+GAA+G;AAC/G,eAAO,MAAM,wBAAwB,aAAe,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,YAAc,CAAC;AAEvD,MAAM,MAAM,YAAY,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,EAAE,CAAA;CAAE,CAAC;AAExE,MAAM,WAAW,qBAAqB;IAClC,0GAA0G;IAC1G,QAAQ,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpC,sGAAsG;IACtG,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,8FAA8F;IAC9F,SAAS,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,qFAO7B,qBAAqB,KAAG,YAAY,GAAG,SAqBzC,CAAC"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { formatUnits, parseUnits } from '@ton/walletkit'; | ||
| /** Default extra TON buffer added on top of built transaction outflow when checking balance before sending. */ | ||
| export const DEFAULT_GAS_BUFFER_NANOS = 100000000n; | ||
| /** | ||
| * Default extra headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one that will actually be sent | ||
| * after the amount changes. 0.02 TON. | ||
| */ | ||
| export const DEFAULT_SAFETY_MARGIN_NANOS = 20000000n; | ||
| /** | ||
| * Check whether the user's TON balance covers the built transaction. | ||
| * - Returns `null` if the balance is sufficient. | ||
| * - Returns `{ mode: 'reduce', ... }` with a smaller suggested `fromAmount` when `fromToken` is TON | ||
| * and the balance is enough to cover at least gas (user can fix it by reducing the amount). | ||
| * - Returns `{ mode: 'topup', ... }` when `fromToken` is a jetton (reducing jetton amount won't free up TON gas), | ||
| * or when `fromToken` is TON but the balance can't even cover gas (reducing won't help — user must top up). | ||
| */ | ||
| export const getTonShortfall = ({ messages, tonBalance, fromToken, fromAmount, gasBufferNanos = DEFAULT_GAS_BUFFER_NANOS, safetyMarginNanos = DEFAULT_SAFETY_MARGIN_NANOS, }) => { | ||
| const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n); | ||
| const requiredNanos = totalOutNanos + gasBufferNanos; | ||
| const tonBalanceNanos = tonBalance ? parseUnits(tonBalance, 9) : 0n; | ||
| if (tonBalanceNanos >= requiredNanos) | ||
| return; | ||
| if (fromToken.address === 'ton') { | ||
| const gasOnlyNanos = totalOutNanos - parseUnits(fromAmount, 9); | ||
| const nonSwapReservedNanos = gasOnlyNanos + gasBufferNanos + safetyMarginNanos; | ||
| // Balance can't cover even gas for a minimal outgoing tx — reducing the amount won't help. | ||
| if (tonBalanceNanos <= nonSwapReservedNanos) { | ||
| return { mode: 'topup', requiredNanos, suggestedFromAmount: '' }; | ||
| } | ||
| const suggestedFromAmount = formatUnits(tonBalanceNanos - nonSwapReservedNanos, 9); | ||
| return { mode: 'reduce', requiredNanos, suggestedFromAmount }; | ||
| } | ||
| return { mode: 'topup', requiredNanos, suggestedFromAmount: '' }; | ||
| }; |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| export {}; | ||
| //# sourceMappingURL=get-ton-shortfall.test.d.ts.map |
| {"version":3,"file":"get-ton-shortfall.test.d.ts","sourceRoot":"","sources":["../../../../src/utils/balance/get-ton-shortfall.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"} |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { DEFAULT_GAS_BUFFER_NANOS, DEFAULT_SAFETY_MARGIN_NANOS, getTonShortfall } from './get-ton-shortfall'; | ||
| const TON = { address: 'ton' }; | ||
| const JETTON = { address: 'EQA_jetton_address' }; | ||
| // Helper — convert a decimal string of TON to nanos as a string (for message amounts). | ||
| const toNanos = (ton) => BigInt(Math.round(Number(ton) * 1e9)).toString(); | ||
| describe('getTonShortfall', () => { | ||
| it('returns undefined when TON balance covers the built transaction', () => { | ||
| // Swap 1 TON, total tx outflow 1.3 TON (1 TON swap + 0.3 TON attached gas), balance 2 TON. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '2', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| it('returns topup when fromToken is a jetton and TON balance is below outflow + buffer', () => { | ||
| // Jetton swap, tx needs 0.05 TON for gas, user has 0 TON. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('0.05') }], | ||
| tonBalance: '0', | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| expect(result).toEqual({ | ||
| mode: 'topup', | ||
| requiredNanos: 50000000n + DEFAULT_GAS_BUFFER_NANOS, | ||
| suggestedFromAmount: '', | ||
| }); | ||
| }); | ||
| it('returns reduce for TON-from when balance covers gas but not full amount', () => { | ||
| // User wants 1 TON swap, total outflow 1.3 TON, has 1 TON. Gas only = 0.3 TON. | ||
| // Balance (1) > nonSwapReserved (0.3 gas + 0.1 buffer + 0.02 safety = 0.42) → reduce mode. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }); | ||
| expect(result?.mode).toBe('reduce'); | ||
| if (result?.mode !== 'reduce') | ||
| return; | ||
| // Suggested = 1 - 0.42 = 0.58 | ||
| expect(result.suggestedFromAmount).toBe('0.58'); | ||
| expect(result.requiredNanos).toBe(1300000000n + DEFAULT_GAS_BUFFER_NANOS); | ||
| }); | ||
| it('returns topup for TON-from when balance cannot cover even gas (reducing would not help)', () => { | ||
| // User wants 1 TON swap, total outflow 1.3 TON → gas = 0.3 TON. Balance 0.2 TON. | ||
| // nonSwapReserved = 0.3 + 0.1 buffer + 0.02 safety = 0.42 TON → balance (0.2) <= 0.42 → topup. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '0.2', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }); | ||
| expect(result).toEqual({ | ||
| mode: 'topup', | ||
| requiredNanos: 1300000000n + DEFAULT_GAS_BUFFER_NANOS, | ||
| suggestedFromAmount: '', | ||
| }); | ||
| }); | ||
| it('treats an undefined tonBalance as zero', () => { | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('0.05') }], | ||
| tonBalance: undefined, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| }); | ||
| it('sums amounts across multiple messages', () => { | ||
| // Two messages attaching 0.6 TON each → totalOut = 1.2 TON. Balance 1 TON → shortfall. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('0.6') }, { amount: toNanos('0.6') }], | ||
| tonBalance: '1', | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| expect(result?.requiredNanos).toBe(1200000000n + DEFAULT_GAS_BUFFER_NANOS); | ||
| }); | ||
| it('respects a custom gasBufferNanos', () => { | ||
| const baseParams = { | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1.3', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }; | ||
| // With the default buffer (0.1 TON), balance 1.3 is insufficient (needs 1.4). | ||
| expect(getTonShortfall(baseParams)?.mode).toBe('reduce'); | ||
| // With a zero buffer, 1.3 TON balance covers the 1.3 TON outflow exactly. | ||
| expect(getTonShortfall({ ...baseParams, gasBufferNanos: 0n })).toBeUndefined(); | ||
| }); | ||
| it('respects a custom safetyMarginNanos in the reduce branch', () => { | ||
| // Default margin: suggested = balance - gas - buffer - 0.02 = 1 - 0.3 - 0.1 - 0.02 = 0.58 | ||
| // Zero margin: suggested = balance - gas - buffer = 1 - 0.3 - 0.1 = 0.6 | ||
| const baseParams = { | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }; | ||
| const withDefault = getTonShortfall(baseParams); | ||
| expect(withDefault?.mode === 'reduce' ? withDefault.suggestedFromAmount : null).toBe('0.58'); | ||
| const withZero = getTonShortfall({ ...baseParams, safetyMarginNanos: 0n }); | ||
| expect(withZero?.mode === 'reduce' ? withZero.suggestedFromAmount : null).toBe('0.6'); | ||
| }); | ||
| it('flips from reduce to topup when a large custom safetyMarginNanos eats the balance', () => { | ||
| // Balance 1 TON, gas 0.3 TON, buffer 0.1 TON. With a 1 TON safety margin, nonSwapReserved becomes 1.4 TON → topup. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| safetyMarginNanos: 1000000000n, | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| }); | ||
| it('exports sane default constants', () => { | ||
| expect(DEFAULT_GAS_BUFFER_NANOS).toBe(100000000n); | ||
| expect(DEFAULT_SAFETY_MARGIN_NANOS).toBe(20000000n); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { DEFAULT_GAS_BUFFER_NANOS, DEFAULT_SAFETY_MARGIN_NANOS, getTonShortfall } from './get-ton-shortfall'; | ||
| const TON = { address: 'ton' }; | ||
| const JETTON = { address: 'EQA_jetton_address' }; | ||
| // Helper — convert a decimal string of TON to nanos as a string (for message amounts). | ||
| const toNanos = (ton: string): string => BigInt(Math.round(Number(ton) * 1e9)).toString(); | ||
| describe('getTonShortfall', () => { | ||
| it('returns undefined when TON balance covers the built transaction', () => { | ||
| // Swap 1 TON, total tx outflow 1.3 TON (1 TON swap + 0.3 TON attached gas), balance 2 TON. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '2', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }); | ||
| expect(result).toBeUndefined(); | ||
| }); | ||
| it('returns topup when fromToken is a jetton and TON balance is below outflow + buffer', () => { | ||
| // Jetton swap, tx needs 0.05 TON for gas, user has 0 TON. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('0.05') }], | ||
| tonBalance: '0', | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| expect(result).toEqual({ | ||
| mode: 'topup', | ||
| requiredNanos: 50_000_000n + DEFAULT_GAS_BUFFER_NANOS, | ||
| suggestedFromAmount: '', | ||
| }); | ||
| }); | ||
| it('returns reduce for TON-from when balance covers gas but not full amount', () => { | ||
| // User wants 1 TON swap, total outflow 1.3 TON, has 1 TON. Gas only = 0.3 TON. | ||
| // Balance (1) > nonSwapReserved (0.3 gas + 0.1 buffer + 0.02 safety = 0.42) → reduce mode. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }); | ||
| expect(result?.mode).toBe('reduce'); | ||
| if (result?.mode !== 'reduce') return; | ||
| // Suggested = 1 - 0.42 = 0.58 | ||
| expect(result.suggestedFromAmount).toBe('0.58'); | ||
| expect(result.requiredNanos).toBe(1_300_000_000n + DEFAULT_GAS_BUFFER_NANOS); | ||
| }); | ||
| it('returns topup for TON-from when balance cannot cover even gas (reducing would not help)', () => { | ||
| // User wants 1 TON swap, total outflow 1.3 TON → gas = 0.3 TON. Balance 0.2 TON. | ||
| // nonSwapReserved = 0.3 + 0.1 buffer + 0.02 safety = 0.42 TON → balance (0.2) <= 0.42 → topup. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '0.2', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }); | ||
| expect(result).toEqual({ | ||
| mode: 'topup', | ||
| requiredNanos: 1_300_000_000n + DEFAULT_GAS_BUFFER_NANOS, | ||
| suggestedFromAmount: '', | ||
| }); | ||
| }); | ||
| it('treats an undefined tonBalance as zero', () => { | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('0.05') }], | ||
| tonBalance: undefined, | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| }); | ||
| it('sums amounts across multiple messages', () => { | ||
| // Two messages attaching 0.6 TON each → totalOut = 1.2 TON. Balance 1 TON → shortfall. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('0.6') }, { amount: toNanos('0.6') }], | ||
| tonBalance: '1', | ||
| fromToken: JETTON, | ||
| fromAmount: '100', | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| expect(result?.requiredNanos).toBe(1_200_000_000n + DEFAULT_GAS_BUFFER_NANOS); | ||
| }); | ||
| it('respects a custom gasBufferNanos', () => { | ||
| const baseParams = { | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1.3', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }; | ||
| // With the default buffer (0.1 TON), balance 1.3 is insufficient (needs 1.4). | ||
| expect(getTonShortfall(baseParams)?.mode).toBe('reduce'); | ||
| // With a zero buffer, 1.3 TON balance covers the 1.3 TON outflow exactly. | ||
| expect(getTonShortfall({ ...baseParams, gasBufferNanos: 0n })).toBeUndefined(); | ||
| }); | ||
| it('respects a custom safetyMarginNanos in the reduce branch', () => { | ||
| // Default margin: suggested = balance - gas - buffer - 0.02 = 1 - 0.3 - 0.1 - 0.02 = 0.58 | ||
| // Zero margin: suggested = balance - gas - buffer = 1 - 0.3 - 0.1 = 0.6 | ||
| const baseParams = { | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| }; | ||
| const withDefault = getTonShortfall(baseParams); | ||
| expect(withDefault?.mode === 'reduce' ? withDefault.suggestedFromAmount : null).toBe('0.58'); | ||
| const withZero = getTonShortfall({ ...baseParams, safetyMarginNanos: 0n }); | ||
| expect(withZero?.mode === 'reduce' ? withZero.suggestedFromAmount : null).toBe('0.6'); | ||
| }); | ||
| it('flips from reduce to topup when a large custom safetyMarginNanos eats the balance', () => { | ||
| // Balance 1 TON, gas 0.3 TON, buffer 0.1 TON. With a 1 TON safety margin, nonSwapReserved becomes 1.4 TON → topup. | ||
| const result = getTonShortfall({ | ||
| messages: [{ amount: toNanos('1.3') }], | ||
| tonBalance: '1', | ||
| fromToken: TON, | ||
| fromAmount: '1', | ||
| safetyMarginNanos: 1_000_000_000n, | ||
| }); | ||
| expect(result?.mode).toBe('topup'); | ||
| }); | ||
| it('exports sane default constants', () => { | ||
| expect(DEFAULT_GAS_BUFFER_NANOS).toBe(100_000_000n); | ||
| expect(DEFAULT_SAFETY_MARGIN_NANOS).toBe(20_000_000n); | ||
| }); | ||
| }); |
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
| import { formatUnits, parseUnits } from '@ton/walletkit'; | ||
| /** Default extra TON buffer added on top of built transaction outflow when checking balance before sending. */ | ||
| export const DEFAULT_GAS_BUFFER_NANOS = 100_000_000n; | ||
| /** | ||
| * Default extra headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Covers quote/gas drift between the current built tx and the one that will actually be sent | ||
| * after the amount changes. 0.02 TON. | ||
| */ | ||
| export const DEFAULT_SAFETY_MARGIN_NANOS = 20_000_000n; | ||
| export type TonShortfall = | ||
| | { mode: 'reduce'; requiredNanos: bigint; suggestedFromAmount: string } | ||
| | { mode: 'topup'; requiredNanos: bigint; suggestedFromAmount: '' }; | ||
| export interface GetTonShortfallParams { | ||
| /** Messages of the built transaction. Each `amount` is the TON value in nanos attached to the message. */ | ||
| messages: Array<{ amount: string }>; | ||
| /** User's current TON balance as a decimal string (same format `formatUnits(balance, 9)` returns). */ | ||
| tonBalance: string | undefined; | ||
| /** The outgoing token — `{ address: 'ton' }` when the user spends TON, otherwise a jetton. */ | ||
| fromToken: { address: string }; | ||
| /** Amount the user intends to spend in `fromToken` units, as a decimal string. */ | ||
| fromAmount: string; | ||
| /** | ||
| * Extra TON headroom on top of built-tx outflow when checking balance before sending. | ||
| * Defaults to {@link DEFAULT_GAS_BUFFER_NANOS}. | ||
| */ | ||
| gasBufferNanos?: bigint; | ||
| /** | ||
| * Extra headroom baked into the suggested reduced amount, on top of the gas buffer. | ||
| * Defaults to {@link DEFAULT_SAFETY_MARGIN_NANOS}. | ||
| */ | ||
| safetyMarginNanos?: bigint; | ||
| } | ||
| /** | ||
| * Check whether the user's TON balance covers the built transaction. | ||
| * - Returns `null` if the balance is sufficient. | ||
| * - Returns `{ mode: 'reduce', ... }` with a smaller suggested `fromAmount` when `fromToken` is TON | ||
| * and the balance is enough to cover at least gas (user can fix it by reducing the amount). | ||
| * - Returns `{ mode: 'topup', ... }` when `fromToken` is a jetton (reducing jetton amount won't free up TON gas), | ||
| * or when `fromToken` is TON but the balance can't even cover gas (reducing won't help — user must top up). | ||
| */ | ||
| export const getTonShortfall = ({ | ||
| messages, | ||
| tonBalance, | ||
| fromToken, | ||
| fromAmount, | ||
| gasBufferNanos = DEFAULT_GAS_BUFFER_NANOS, | ||
| safetyMarginNanos = DEFAULT_SAFETY_MARGIN_NANOS, | ||
| }: GetTonShortfallParams): TonShortfall | undefined => { | ||
| const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n); | ||
| const requiredNanos = totalOutNanos + gasBufferNanos; | ||
| const tonBalanceNanos = tonBalance ? parseUnits(tonBalance, 9) : 0n; | ||
| if (tonBalanceNanos >= requiredNanos) return; | ||
| if (fromToken.address === 'ton') { | ||
| const gasOnlyNanos = totalOutNanos - parseUnits(fromAmount, 9); | ||
| const nonSwapReservedNanos = gasOnlyNanos + gasBufferNanos + safetyMarginNanos; | ||
| // Balance can't cover even gas for a minimal outgoing tx — reducing the amount won't help. | ||
| if (tonBalanceNanos <= nonSwapReservedNanos) { | ||
| return { mode: 'topup', requiredNanos, suggestedFromAmount: '' }; | ||
| } | ||
| const suggestedFromAmount = formatUnits(tonBalanceNanos - nonSwapReservedNanos, 9); | ||
| return { mode: 'reduce', requiredNanos, suggestedFromAmount }; | ||
| } | ||
| return { mode: 'topup', requiredNanos, suggestedFromAmount: '' }; | ||
| }; |
1467553
23.48%1380
13.96%27662
20.23%+ Added
- Removed
- Removed
- Removed
Updated