@ton/appkit 0.0.5-alpha.3 → 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (455) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +144 -0
  3. package/README.md +8 -7
  4. package/dist/cjs/actions/connectors/watch-connector-by-id.d.ts.map +1 -1
  5. package/dist/cjs/actions/connectors/watch-connector-by-id.js +8 -3
  6. package/dist/cjs/actions/connectors/watch-connectors.d.ts.map +1 -1
  7. package/dist/cjs/actions/connectors/watch-connectors.js +8 -3
  8. package/dist/cjs/actions/index.d.ts +8 -0
  9. package/dist/cjs/actions/index.d.ts.map +1 -1
  10. package/dist/cjs/actions/index.js +18 -2
  11. package/dist/cjs/actions/jettons/create-transfer-jetton-transaction.d.ts +1 -1
  12. package/dist/cjs/actions/jettons/create-transfer-jetton-transaction.d.ts.map +1 -1
  13. package/dist/cjs/actions/jettons/create-transfer-jetton-transaction.js +17 -5
  14. package/dist/cjs/actions/jettons/get-jetton-balance.d.ts +1 -1
  15. package/dist/cjs/actions/jettons/get-jetton-balance.d.ts.map +1 -1
  16. package/dist/cjs/actions/jettons/get-jetton-balance.js +8 -3
  17. package/dist/cjs/actions/jettons/get-jetton-info.d.ts.map +1 -1
  18. package/dist/cjs/actions/jettons/get-jetton-info.js +15 -6
  19. package/dist/cjs/actions/jettons/get-jetton-wallet-address.d.ts +1 -1
  20. package/dist/cjs/actions/jettons/get-jetton-wallet-address.d.ts.map +1 -1
  21. package/dist/cjs/actions/jettons/get-jetton-wallet-address.js +15 -4
  22. package/dist/cjs/actions/nft/get-nft.d.ts +1 -1
  23. package/dist/cjs/actions/nft/get-nft.d.ts.map +1 -1
  24. package/dist/cjs/actions/providers/register-provider.d.ts +2 -1
  25. package/dist/cjs/actions/providers/register-provider.d.ts.map +1 -1
  26. package/dist/cjs/actions/staking/get-staking-provider-metadata.d.ts +19 -0
  27. package/dist/cjs/actions/staking/get-staking-provider-metadata.d.ts.map +1 -0
  28. package/dist/cjs/actions/staking/get-staking-provider-metadata.js +18 -0
  29. package/dist/cjs/actions/staking/get-staking-provider.d.ts +21 -0
  30. package/dist/cjs/actions/staking/get-staking-provider.d.ts.map +1 -0
  31. package/dist/cjs/actions/staking/get-staking-provider.js +17 -0
  32. package/dist/cjs/actions/staking/get-staking-providers.d.ts +3 -2
  33. package/dist/cjs/actions/staking/get-staking-providers.d.ts.map +1 -1
  34. package/dist/cjs/actions/staking/get-staking-providers.js +2 -2
  35. package/dist/cjs/actions/staking/set-default-staking-provider.d.ts +18 -0
  36. package/dist/cjs/actions/staking/set-default-staking-provider.d.ts.map +1 -0
  37. package/dist/cjs/actions/staking/set-default-staking-provider.js +18 -0
  38. package/dist/cjs/actions/staking/watch-staking-providers.d.ts +17 -0
  39. package/dist/cjs/actions/staking/watch-staking-providers.d.ts.map +1 -0
  40. package/dist/cjs/actions/staking/watch-staking-providers.js +28 -0
  41. package/dist/cjs/actions/swap/get-swap-provider.d.ts +15 -0
  42. package/dist/cjs/actions/swap/get-swap-provider.d.ts.map +1 -0
  43. package/dist/cjs/actions/swap/get-swap-provider.js +14 -0
  44. package/dist/cjs/actions/swap/get-swap-providers.d.ts +15 -0
  45. package/dist/cjs/actions/swap/get-swap-providers.d.ts.map +1 -0
  46. package/dist/cjs/actions/swap/get-swap-providers.js +17 -0
  47. package/dist/cjs/actions/swap/get-swap-quote.d.ts.map +1 -1
  48. package/dist/cjs/actions/swap/get-swap-quote.js +6 -1
  49. package/dist/cjs/actions/swap/set-default-swap-provider.d.ts +18 -0
  50. package/dist/cjs/actions/swap/set-default-swap-provider.d.ts.map +1 -0
  51. package/dist/cjs/actions/swap/set-default-swap-provider.js +18 -0
  52. package/dist/cjs/actions/swap/watch-swap-providers.d.ts +17 -0
  53. package/dist/cjs/actions/swap/watch-swap-providers.d.ts.map +1 -0
  54. package/dist/cjs/actions/swap/watch-swap-providers.js +29 -0
  55. package/dist/cjs/connectors/tonconnect/connectors/ton-connect-connector.d.ts +1 -2
  56. package/dist/cjs/connectors/tonconnect/connectors/ton-connect-connector.d.ts.map +1 -1
  57. package/dist/cjs/connectors/tonconnect/connectors/ton-connect-connector.js +16 -18
  58. package/dist/cjs/core/app-kit/constants/events.d.ts +3 -8
  59. package/dist/cjs/core/app-kit/constants/events.d.ts.map +1 -1
  60. package/dist/cjs/core/app-kit/constants/events.js +4 -9
  61. package/dist/cjs/core/app-kit/index.d.ts +2 -2
  62. package/dist/cjs/core/app-kit/index.d.ts.map +1 -1
  63. package/dist/cjs/core/app-kit/index.js +1 -2
  64. package/dist/cjs/core/app-kit/services/app-kit.d.ts +5 -2
  65. package/dist/cjs/core/app-kit/services/app-kit.d.ts.map +1 -1
  66. package/dist/cjs/core/app-kit/services/app-kit.js +12 -4
  67. package/dist/cjs/core/app-kit/types/config.d.ts +6 -3
  68. package/dist/cjs/core/app-kit/types/config.d.ts.map +1 -1
  69. package/dist/cjs/core/app-kit/types/events.d.ts +13 -13
  70. package/dist/cjs/core/app-kit/types/events.d.ts.map +1 -1
  71. package/dist/cjs/core/cache/adapters/lru-app-kit-cache.d.ts +20 -0
  72. package/dist/cjs/core/cache/adapters/lru-app-kit-cache.d.ts.map +1 -0
  73. package/dist/cjs/core/cache/adapters/lru-app-kit-cache.js +32 -0
  74. package/dist/cjs/core/cache/adapters/lru-app-kit-cache.test.d.ts +9 -0
  75. package/dist/cjs/core/cache/adapters/lru-app-kit-cache.test.d.ts.map +1 -0
  76. package/dist/cjs/core/cache/adapters/lru-app-kit-cache.test.js +68 -0
  77. package/dist/cjs/core/cache/index.d.ts +11 -0
  78. package/dist/cjs/core/cache/index.d.ts.map +1 -0
  79. package/dist/cjs/core/cache/index.js +14 -0
  80. package/dist/cjs/core/cache/types/app-kit-cache.d.ts +14 -0
  81. package/dist/cjs/core/cache/types/app-kit-cache.d.ts.map +1 -0
  82. package/dist/cjs/core/cache/types/app-kit-cache.js +9 -0
  83. package/dist/cjs/core/cache/utils/get-cache-key.d.ts +9 -0
  84. package/dist/cjs/core/cache/utils/get-cache-key.d.ts.map +1 -0
  85. package/dist/cjs/core/cache/utils/get-cache-key.js +12 -0
  86. package/dist/cjs/core/cache/utils/get-cache-key.test.d.ts +9 -0
  87. package/dist/cjs/core/cache/utils/get-cache-key.test.d.ts.map +1 -0
  88. package/dist/cjs/core/cache/utils/get-cache-key.test.js +30 -0
  89. package/dist/cjs/index.d.ts +1 -0
  90. package/dist/cjs/index.d.ts.map +1 -1
  91. package/dist/cjs/index.js +1 -0
  92. package/dist/cjs/queries/balances/get-balance-by-address.d.ts.map +1 -1
  93. package/dist/cjs/queries/balances/get-balance-by-address.js +9 -3
  94. package/dist/cjs/queries/index.d.ts +0 -1
  95. package/dist/cjs/queries/index.d.ts.map +1 -1
  96. package/dist/cjs/queries/index.js +1 -3
  97. package/dist/cjs/queries/jettons/get-jetton-balance-by-address.d.ts.map +1 -1
  98. package/dist/cjs/queries/jettons/get-jetton-balance-by-address.js +11 -11
  99. package/dist/cjs/queries/jettons/get-jetton-info.d.ts.map +1 -1
  100. package/dist/cjs/queries/jettons/get-jetton-info.js +5 -1
  101. package/dist/cjs/queries/jettons/get-jetton-wallet-address.d.ts.map +1 -1
  102. package/dist/cjs/queries/jettons/get-jetton-wallet-address.js +6 -1
  103. package/dist/cjs/queries/jettons/get-jettons-by-address.d.ts.map +1 -1
  104. package/dist/cjs/queries/jettons/get-jettons-by-address.js +9 -3
  105. package/dist/cjs/queries/nft/get-nft.d.ts +1 -1
  106. package/dist/cjs/queries/nft/get-nft.d.ts.map +1 -1
  107. package/dist/cjs/queries/nft/get-nft.js +5 -1
  108. package/dist/cjs/queries/nft/get-nfts-by-address.d.ts.map +1 -1
  109. package/dist/cjs/queries/nft/get-nfts-by-address.js +5 -1
  110. package/dist/cjs/queries/staking/get-staked-balance.d.ts +1 -1
  111. package/dist/cjs/queries/staking/get-staked-balance.d.ts.map +1 -1
  112. package/dist/cjs/queries/staking/get-staked-balance.js +7 -1
  113. package/dist/cjs/queries/staking/get-staking-provider-info.d.ts +1 -1
  114. package/dist/cjs/queries/staking/get-staking-provider-info.d.ts.map +1 -1
  115. package/dist/cjs/queries/staking/get-staking-provider-info.js +3 -1
  116. package/dist/cjs/queries/staking/get-staking-quote.d.ts +1 -1
  117. package/dist/cjs/queries/staking/get-staking-quote.d.ts.map +1 -1
  118. package/dist/cjs/queries/staking/get-staking-quote.js +8 -2
  119. package/dist/cjs/queries/swap/get-swap-quote.d.ts.map +1 -1
  120. package/dist/cjs/queries/swap/get-swap-quote.js +1 -1
  121. package/dist/cjs/staking/index.d.ts +2 -2
  122. package/dist/cjs/staking/index.d.ts.map +1 -1
  123. package/dist/cjs/staking/index.js +3 -1
  124. package/dist/cjs/swap/index.d.ts +2 -1
  125. package/dist/cjs/swap/index.d.ts.map +1 -1
  126. package/dist/cjs/swap/index.js +8 -0
  127. package/dist/cjs/types/connector.d.ts +0 -6
  128. package/dist/cjs/types/connector.d.ts.map +1 -1
  129. package/dist/cjs/types/primitives.d.ts +1 -1
  130. package/dist/cjs/types/primitives.d.ts.map +1 -1
  131. package/dist/cjs/types/provider.d.ts +3 -3
  132. package/dist/cjs/types/provider.d.ts.map +1 -1
  133. package/dist/cjs/utils/address/is-valid-address.d.ts +11 -0
  134. package/dist/cjs/utils/address/is-valid-address.d.ts.map +1 -0
  135. package/dist/cjs/utils/address/is-valid-address.js +38 -0
  136. package/dist/cjs/utils/address/to-bounceble-address.d.ts +11 -0
  137. package/dist/cjs/utils/address/to-bounceble-address.d.ts.map +1 -0
  138. package/dist/cjs/utils/address/to-bounceble-address.js +36 -0
  139. package/dist/cjs/utils/address/to-non-bounceble-address.d.ts +11 -0
  140. package/dist/cjs/utils/address/to-non-bounceble-address.d.ts.map +1 -0
  141. package/dist/cjs/utils/address/to-non-bounceble-address.js +36 -0
  142. package/dist/cjs/utils/amount/calc-fiat-value.d.ts +13 -0
  143. package/dist/cjs/utils/amount/calc-fiat-value.d.ts.map +1 -0
  144. package/dist/cjs/utils/amount/calc-fiat-value.js +22 -0
  145. package/dist/cjs/utils/amount/calc-fiat-value.test.d.ts +9 -0
  146. package/dist/cjs/utils/amount/calc-fiat-value.test.d.ts.map +1 -0
  147. package/dist/cjs/utils/amount/calc-fiat-value.test.js +39 -0
  148. package/dist/cjs/utils/amount/format-large-value.d.ts +9 -0
  149. package/dist/cjs/utils/amount/format-large-value.d.ts.map +1 -0
  150. package/dist/cjs/utils/amount/format-large-value.js +40 -0
  151. package/dist/cjs/utils/amount/format-large-value.test.d.ts +9 -0
  152. package/dist/cjs/utils/amount/format-large-value.test.d.ts.map +1 -0
  153. package/dist/cjs/utils/amount/format-large-value.test.js +43 -0
  154. package/dist/cjs/utils/amount/truncate-decimals.d.ts +9 -0
  155. package/dist/cjs/utils/amount/truncate-decimals.d.ts.map +1 -0
  156. package/dist/cjs/utils/amount/truncate-decimals.js +59 -0
  157. package/dist/cjs/utils/amount/truncate-decimals.test.d.ts +9 -0
  158. package/dist/cjs/utils/amount/truncate-decimals.test.d.ts.map +1 -0
  159. package/dist/cjs/utils/amount/truncate-decimals.test.js +83 -0
  160. package/dist/cjs/utils/balance/calc-max-spendable.d.ts +33 -0
  161. package/dist/cjs/utils/balance/calc-max-spendable.d.ts.map +1 -0
  162. package/dist/cjs/utils/balance/calc-max-spendable.js +29 -0
  163. package/dist/cjs/utils/balance/calc-max-spendable.test.d.ts +9 -0
  164. package/dist/cjs/utils/balance/calc-max-spendable.test.d.ts.map +1 -0
  165. package/dist/cjs/utils/balance/calc-max-spendable.test.js +38 -0
  166. package/dist/cjs/utils/balance/get-ton-shortfall.d.ts +58 -0
  167. package/dist/cjs/utils/balance/get-ton-shortfall.d.ts.map +1 -0
  168. package/dist/cjs/utils/balance/get-ton-shortfall.js +46 -0
  169. package/dist/cjs/utils/balance/get-ton-shortfall.test.d.ts +9 -0
  170. package/dist/cjs/utils/balance/get-ton-shortfall.test.d.ts.map +1 -0
  171. package/dist/cjs/utils/balance/get-ton-shortfall.test.js +133 -0
  172. package/dist/cjs/utils/functions/debounce.d.ts +80 -0
  173. package/dist/cjs/utils/functions/debounce.d.ts.map +1 -0
  174. package/dist/cjs/utils/functions/debounce.js +107 -0
  175. package/dist/cjs/utils/index.d.ts +10 -0
  176. package/dist/cjs/utils/index.d.ts.map +1 -1
  177. package/dist/cjs/utils/index.js +10 -0
  178. package/dist/cjs/utils/jetton/jetton-info.d.ts +2 -1
  179. package/dist/cjs/utils/jetton/jetton-info.d.ts.map +1 -1
  180. package/dist/cjs/utils/jetton/jetton-info.js +11 -1
  181. package/dist/cjs/utils/jetton/jetton-info.test.d.ts +9 -0
  182. package/dist/cjs/utils/jetton/jetton-info.test.d.ts.map +1 -0
  183. package/dist/cjs/utils/jetton/jetton-info.test.js +54 -0
  184. package/dist/cjs/utils/predicate/is-number.d.ts +9 -0
  185. package/dist/cjs/utils/predicate/is-number.d.ts.map +1 -0
  186. package/dist/cjs/utils/predicate/is-number.js +20 -0
  187. package/dist/cjs/utils/predicate/is-string.d.ts +1 -1
  188. package/dist/cjs/utils/predicate/is-string.d.ts.map +1 -1
  189. package/dist/cjs/utils/predicate/is-string.js +4 -3
  190. package/dist/esm/actions/connectors/watch-connector-by-id.d.ts.map +1 -1
  191. package/dist/esm/actions/connectors/watch-connector-by-id.js +8 -3
  192. package/dist/esm/actions/connectors/watch-connectors.d.ts.map +1 -1
  193. package/dist/esm/actions/connectors/watch-connectors.js +8 -3
  194. package/dist/esm/actions/index.d.ts +8 -0
  195. package/dist/esm/actions/index.d.ts.map +1 -1
  196. package/dist/esm/actions/index.js +8 -0
  197. package/dist/esm/actions/jettons/create-transfer-jetton-transaction.d.ts +1 -1
  198. package/dist/esm/actions/jettons/create-transfer-jetton-transaction.d.ts.map +1 -1
  199. package/dist/esm/actions/jettons/create-transfer-jetton-transaction.js +17 -5
  200. package/dist/esm/actions/jettons/get-jetton-balance.d.ts +1 -1
  201. package/dist/esm/actions/jettons/get-jetton-balance.d.ts.map +1 -1
  202. package/dist/esm/actions/jettons/get-jetton-balance.js +7 -2
  203. package/dist/esm/actions/jettons/get-jetton-info.d.ts.map +1 -1
  204. package/dist/esm/actions/jettons/get-jetton-info.js +15 -6
  205. package/dist/esm/actions/jettons/get-jetton-wallet-address.d.ts +1 -1
  206. package/dist/esm/actions/jettons/get-jetton-wallet-address.d.ts.map +1 -1
  207. package/dist/esm/actions/jettons/get-jetton-wallet-address.js +15 -4
  208. package/dist/esm/actions/nft/get-nft.d.ts +1 -1
  209. package/dist/esm/actions/nft/get-nft.d.ts.map +1 -1
  210. package/dist/esm/actions/providers/register-provider.d.ts +2 -1
  211. package/dist/esm/actions/providers/register-provider.d.ts.map +1 -1
  212. package/dist/esm/actions/staking/get-staking-provider-metadata.d.ts +19 -0
  213. package/dist/esm/actions/staking/get-staking-provider-metadata.d.ts.map +1 -0
  214. package/dist/esm/actions/staking/get-staking-provider-metadata.js +14 -0
  215. package/dist/esm/actions/staking/get-staking-provider.d.ts +21 -0
  216. package/dist/esm/actions/staking/get-staking-provider.d.ts.map +1 -0
  217. package/dist/esm/actions/staking/get-staking-provider.js +13 -0
  218. package/dist/esm/actions/staking/get-staking-providers.d.ts +3 -2
  219. package/dist/esm/actions/staking/get-staking-providers.d.ts.map +1 -1
  220. package/dist/esm/actions/staking/get-staking-providers.js +2 -2
  221. package/dist/esm/actions/staking/set-default-staking-provider.d.ts +18 -0
  222. package/dist/esm/actions/staking/set-default-staking-provider.d.ts.map +1 -0
  223. package/dist/esm/actions/staking/set-default-staking-provider.js +14 -0
  224. package/dist/esm/actions/staking/watch-staking-providers.d.ts +17 -0
  225. package/dist/esm/actions/staking/watch-staking-providers.d.ts.map +1 -0
  226. package/dist/esm/actions/staking/watch-staking-providers.js +24 -0
  227. package/dist/esm/actions/swap/get-swap-provider.d.ts +15 -0
  228. package/dist/esm/actions/swap/get-swap-provider.d.ts.map +1 -0
  229. package/dist/esm/actions/swap/get-swap-provider.js +10 -0
  230. package/dist/esm/actions/swap/get-swap-providers.d.ts +15 -0
  231. package/dist/esm/actions/swap/get-swap-providers.d.ts.map +1 -0
  232. package/dist/esm/actions/swap/get-swap-providers.js +13 -0
  233. package/dist/esm/actions/swap/get-swap-quote.d.ts.map +1 -1
  234. package/dist/esm/actions/swap/get-swap-quote.js +6 -1
  235. package/dist/esm/actions/swap/set-default-swap-provider.d.ts +18 -0
  236. package/dist/esm/actions/swap/set-default-swap-provider.d.ts.map +1 -0
  237. package/dist/esm/actions/swap/set-default-swap-provider.js +14 -0
  238. package/dist/esm/actions/swap/watch-swap-providers.d.ts +17 -0
  239. package/dist/esm/actions/swap/watch-swap-providers.d.ts.map +1 -0
  240. package/dist/esm/actions/swap/watch-swap-providers.js +25 -0
  241. package/dist/esm/connectors/tonconnect/connectors/ton-connect-connector.d.ts +1 -2
  242. package/dist/esm/connectors/tonconnect/connectors/ton-connect-connector.d.ts.map +1 -1
  243. package/dist/esm/connectors/tonconnect/connectors/ton-connect-connector.js +16 -18
  244. package/dist/esm/core/app-kit/constants/events.d.ts +3 -8
  245. package/dist/esm/core/app-kit/constants/events.d.ts.map +1 -1
  246. package/dist/esm/core/app-kit/constants/events.js +3 -8
  247. package/dist/esm/core/app-kit/index.d.ts +2 -2
  248. package/dist/esm/core/app-kit/index.d.ts.map +1 -1
  249. package/dist/esm/core/app-kit/index.js +1 -1
  250. package/dist/esm/core/app-kit/services/app-kit.d.ts +5 -2
  251. package/dist/esm/core/app-kit/services/app-kit.d.ts.map +1 -1
  252. package/dist/esm/core/app-kit/services/app-kit.js +12 -4
  253. package/dist/esm/core/app-kit/types/config.d.ts +6 -3
  254. package/dist/esm/core/app-kit/types/config.d.ts.map +1 -1
  255. package/dist/esm/core/app-kit/types/events.d.ts +13 -13
  256. package/dist/esm/core/app-kit/types/events.d.ts.map +1 -1
  257. package/dist/esm/core/cache/adapters/lru-app-kit-cache.d.ts +20 -0
  258. package/dist/esm/core/cache/adapters/lru-app-kit-cache.d.ts.map +1 -0
  259. package/dist/esm/core/cache/adapters/lru-app-kit-cache.js +28 -0
  260. package/dist/esm/core/cache/adapters/lru-app-kit-cache.test.d.ts +9 -0
  261. package/dist/esm/core/cache/adapters/lru-app-kit-cache.test.d.ts.map +1 -0
  262. package/dist/esm/core/cache/adapters/lru-app-kit-cache.test.js +66 -0
  263. package/dist/esm/core/cache/index.d.ts +11 -0
  264. package/dist/esm/core/cache/index.d.ts.map +1 -0
  265. package/dist/esm/core/cache/index.js +9 -0
  266. package/dist/esm/core/cache/types/app-kit-cache.d.ts +14 -0
  267. package/dist/esm/core/cache/types/app-kit-cache.d.ts.map +1 -0
  268. package/dist/esm/core/cache/types/app-kit-cache.js +8 -0
  269. package/dist/esm/core/cache/utils/get-cache-key.d.ts +9 -0
  270. package/dist/esm/core/cache/utils/get-cache-key.d.ts.map +1 -0
  271. package/dist/esm/core/cache/utils/get-cache-key.js +8 -0
  272. package/dist/esm/core/cache/utils/get-cache-key.test.d.ts +9 -0
  273. package/dist/esm/core/cache/utils/get-cache-key.test.d.ts.map +1 -0
  274. package/dist/esm/core/cache/utils/get-cache-key.test.js +28 -0
  275. package/dist/esm/index.d.ts +1 -0
  276. package/dist/esm/index.d.ts.map +1 -1
  277. package/dist/esm/index.js +1 -0
  278. package/dist/esm/queries/balances/get-balance-by-address.d.ts.map +1 -1
  279. package/dist/esm/queries/balances/get-balance-by-address.js +10 -4
  280. package/dist/esm/queries/index.d.ts +0 -1
  281. package/dist/esm/queries/index.d.ts.map +1 -1
  282. package/dist/esm/queries/index.js +0 -1
  283. package/dist/esm/queries/jettons/get-jetton-balance-by-address.d.ts.map +1 -1
  284. package/dist/esm/queries/jettons/get-jetton-balance-by-address.js +12 -12
  285. package/dist/esm/queries/jettons/get-jetton-info.d.ts.map +1 -1
  286. package/dist/esm/queries/jettons/get-jetton-info.js +6 -2
  287. package/dist/esm/queries/jettons/get-jetton-wallet-address.d.ts.map +1 -1
  288. package/dist/esm/queries/jettons/get-jetton-wallet-address.js +7 -2
  289. package/dist/esm/queries/jettons/get-jettons-by-address.d.ts.map +1 -1
  290. package/dist/esm/queries/jettons/get-jettons-by-address.js +10 -4
  291. package/dist/esm/queries/nft/get-nft.d.ts +1 -1
  292. package/dist/esm/queries/nft/get-nft.d.ts.map +1 -1
  293. package/dist/esm/queries/nft/get-nft.js +6 -2
  294. package/dist/esm/queries/nft/get-nfts-by-address.d.ts.map +1 -1
  295. package/dist/esm/queries/nft/get-nfts-by-address.js +6 -2
  296. package/dist/esm/queries/staking/get-staked-balance.d.ts +1 -1
  297. package/dist/esm/queries/staking/get-staked-balance.d.ts.map +1 -1
  298. package/dist/esm/queries/staking/get-staked-balance.js +8 -2
  299. package/dist/esm/queries/staking/get-staking-provider-info.d.ts +1 -1
  300. package/dist/esm/queries/staking/get-staking-provider-info.d.ts.map +1 -1
  301. package/dist/esm/queries/staking/get-staking-provider-info.js +4 -2
  302. package/dist/esm/queries/staking/get-staking-quote.d.ts +1 -1
  303. package/dist/esm/queries/staking/get-staking-quote.d.ts.map +1 -1
  304. package/dist/esm/queries/staking/get-staking-quote.js +9 -3
  305. package/dist/esm/queries/swap/get-swap-quote.d.ts.map +1 -1
  306. package/dist/esm/queries/swap/get-swap-quote.js +1 -1
  307. package/dist/esm/staking/index.d.ts +2 -2
  308. package/dist/esm/staking/index.d.ts.map +1 -1
  309. package/dist/esm/staking/index.js +1 -1
  310. package/dist/esm/swap/index.d.ts +2 -1
  311. package/dist/esm/swap/index.d.ts.map +1 -1
  312. package/dist/esm/swap/index.js +1 -1
  313. package/dist/esm/types/connector.d.ts +0 -6
  314. package/dist/esm/types/connector.d.ts.map +1 -1
  315. package/dist/esm/types/primitives.d.ts +1 -1
  316. package/dist/esm/types/primitives.d.ts.map +1 -1
  317. package/dist/esm/types/provider.d.ts +3 -3
  318. package/dist/esm/types/provider.d.ts.map +1 -1
  319. package/dist/esm/utils/address/is-valid-address.d.ts +11 -0
  320. package/dist/esm/utils/address/is-valid-address.d.ts.map +1 -0
  321. package/dist/esm/utils/address/is-valid-address.js +33 -0
  322. package/dist/esm/utils/address/to-bounceble-address.d.ts +11 -0
  323. package/dist/esm/utils/address/to-bounceble-address.d.ts.map +1 -0
  324. package/dist/esm/utils/address/to-bounceble-address.js +31 -0
  325. package/dist/esm/utils/address/to-non-bounceble-address.d.ts +11 -0
  326. package/dist/esm/utils/address/to-non-bounceble-address.d.ts.map +1 -0
  327. package/dist/esm/utils/address/to-non-bounceble-address.js +31 -0
  328. package/dist/esm/utils/amount/calc-fiat-value.d.ts +13 -0
  329. package/dist/esm/utils/amount/calc-fiat-value.d.ts.map +1 -0
  330. package/dist/esm/utils/amount/calc-fiat-value.js +19 -0
  331. package/dist/esm/utils/amount/calc-fiat-value.test.d.ts +9 -0
  332. package/dist/esm/utils/amount/calc-fiat-value.test.d.ts.map +1 -0
  333. package/dist/esm/utils/amount/calc-fiat-value.test.js +37 -0
  334. package/dist/esm/utils/amount/format-large-value.d.ts +9 -0
  335. package/dist/esm/utils/amount/format-large-value.d.ts.map +1 -0
  336. package/dist/esm/utils/amount/format-large-value.js +36 -0
  337. package/dist/esm/utils/amount/format-large-value.test.d.ts +9 -0
  338. package/dist/esm/utils/amount/format-large-value.test.d.ts.map +1 -0
  339. package/dist/esm/utils/amount/format-large-value.test.js +41 -0
  340. package/dist/esm/utils/amount/truncate-decimals.d.ts +9 -0
  341. package/dist/esm/utils/amount/truncate-decimals.d.ts.map +1 -0
  342. package/dist/esm/utils/amount/truncate-decimals.js +55 -0
  343. package/dist/esm/utils/amount/truncate-decimals.test.d.ts +9 -0
  344. package/dist/esm/utils/amount/truncate-decimals.test.d.ts.map +1 -0
  345. package/dist/esm/utils/amount/truncate-decimals.test.js +81 -0
  346. package/dist/esm/utils/balance/calc-max-spendable.d.ts +33 -0
  347. package/dist/esm/utils/balance/calc-max-spendable.d.ts.map +1 -0
  348. package/dist/esm/utils/balance/calc-max-spendable.js +25 -0
  349. package/dist/esm/utils/balance/calc-max-spendable.test.d.ts +9 -0
  350. package/dist/esm/utils/balance/calc-max-spendable.test.d.ts.map +1 -0
  351. package/dist/esm/utils/balance/calc-max-spendable.test.js +36 -0
  352. package/dist/esm/utils/balance/get-ton-shortfall.d.ts +58 -0
  353. package/dist/esm/utils/balance/get-ton-shortfall.d.ts.map +1 -0
  354. package/dist/esm/utils/balance/get-ton-shortfall.js +42 -0
  355. package/dist/esm/utils/balance/get-ton-shortfall.test.d.ts +9 -0
  356. package/dist/esm/utils/balance/get-ton-shortfall.test.d.ts.map +1 -0
  357. package/dist/esm/utils/balance/get-ton-shortfall.test.js +131 -0
  358. package/dist/esm/utils/functions/debounce.d.ts +80 -0
  359. package/dist/esm/utils/functions/debounce.d.ts.map +1 -0
  360. package/dist/esm/utils/functions/debounce.js +103 -0
  361. package/dist/esm/utils/index.d.ts +10 -0
  362. package/dist/esm/utils/index.d.ts.map +1 -1
  363. package/dist/esm/utils/index.js +10 -0
  364. package/dist/esm/utils/jetton/jetton-info.d.ts +2 -1
  365. package/dist/esm/utils/jetton/jetton-info.d.ts.map +1 -1
  366. package/dist/esm/utils/jetton/jetton-info.js +9 -0
  367. package/dist/esm/utils/jetton/jetton-info.test.d.ts +9 -0
  368. package/dist/esm/utils/jetton/jetton-info.test.d.ts.map +1 -0
  369. package/dist/esm/utils/jetton/jetton-info.test.js +52 -0
  370. package/dist/esm/utils/predicate/is-number.d.ts +9 -0
  371. package/dist/esm/utils/predicate/is-number.d.ts.map +1 -0
  372. package/dist/esm/utils/predicate/is-number.js +16 -0
  373. package/dist/esm/utils/predicate/is-string.d.ts +1 -1
  374. package/dist/esm/utils/predicate/is-string.d.ts.map +1 -1
  375. package/dist/esm/utils/predicate/is-string.js +2 -2
  376. package/docs/actions.md +64 -15
  377. package/docs/connectors.md +5 -25
  378. package/docs/staking.md +7 -6
  379. package/docs/swap.md +11 -10
  380. package/package.json +4 -3
  381. package/src/actions/connectors/watch-connector-by-id.ts +9 -3
  382. package/src/actions/connectors/watch-connectors.ts +9 -3
  383. package/src/actions/index.ts +32 -0
  384. package/src/actions/jettons/create-transfer-jetton-transaction.ts +22 -6
  385. package/src/actions/jettons/get-jetton-balance.ts +10 -3
  386. package/src/actions/jettons/get-jetton-info.ts +18 -6
  387. package/src/actions/jettons/get-jetton-wallet-address.ts +19 -5
  388. package/src/actions/nft/get-nft.ts +1 -1
  389. package/src/actions/providers/register-provider.ts +2 -1
  390. package/src/actions/staking/get-staking-provider-metadata.ts +32 -0
  391. package/src/actions/staking/get-staking-provider.ts +30 -0
  392. package/src/actions/staking/get-staking-providers.ts +5 -3
  393. package/src/actions/staking/set-default-staking-provider.ts +26 -0
  394. package/src/actions/staking/watch-staking-providers.ts +39 -0
  395. package/src/actions/swap/get-swap-provider.ts +21 -0
  396. package/src/actions/swap/get-swap-providers.ts +20 -0
  397. package/src/actions/swap/get-swap-quote.ts +7 -1
  398. package/src/actions/swap/set-default-swap-provider.ts +26 -0
  399. package/src/actions/swap/watch-swap-providers.ts +38 -0
  400. package/src/connectors/tonconnect/connectors/ton-connect-connector.ts +22 -20
  401. package/src/core/app-kit/constants/events.ts +3 -9
  402. package/src/core/app-kit/index.ts +4 -4
  403. package/src/core/app-kit/services/app-kit.ts +18 -7
  404. package/src/core/app-kit/types/config.ts +6 -3
  405. package/src/core/app-kit/types/events.ts +13 -15
  406. package/src/core/cache/adapters/lru-app-kit-cache.test.ts +77 -0
  407. package/src/core/cache/adapters/lru-app-kit-cache.ts +38 -0
  408. package/src/core/cache/index.ts +12 -0
  409. package/src/core/cache/types/app-kit-cache.ts +14 -0
  410. package/src/core/cache/utils/get-cache-key.test.ts +34 -0
  411. package/src/core/cache/utils/get-cache-key.ts +12 -0
  412. package/src/index.ts +1 -0
  413. package/src/queries/balances/get-balance-by-address.ts +11 -4
  414. package/src/queries/index.ts +0 -6
  415. package/src/queries/jettons/get-jetton-balance-by-address.ts +13 -12
  416. package/src/queries/jettons/get-jetton-info.ts +6 -2
  417. package/src/queries/jettons/get-jetton-wallet-address.ts +7 -2
  418. package/src/queries/jettons/get-jettons-by-address.ts +18 -4
  419. package/src/queries/nft/get-nft.ts +7 -3
  420. package/src/queries/nft/get-nfts-by-address.ts +6 -2
  421. package/src/queries/staking/get-staked-balance.ts +10 -3
  422. package/src/queries/staking/get-staking-provider-info.ts +5 -2
  423. package/src/queries/staking/get-staking-quote.ts +13 -4
  424. package/src/queries/swap/get-swap-quote.ts +3 -1
  425. package/src/staking/index.ts +10 -1
  426. package/src/swap/index.ts +2 -4
  427. package/src/types/connector.ts +0 -8
  428. package/src/types/primitives.ts +1 -1
  429. package/src/types/provider.ts +3 -3
  430. package/src/utils/address/is-valid-address.ts +40 -0
  431. package/src/utils/address/to-bounceble-address.ts +35 -0
  432. package/src/utils/address/to-non-bounceble-address.ts +35 -0
  433. package/src/utils/amount/calc-fiat-value.test.ts +46 -0
  434. package/src/utils/amount/calc-fiat-value.ts +18 -0
  435. package/src/utils/amount/format-large-value.test.ts +50 -0
  436. package/src/utils/amount/format-large-value.ts +43 -0
  437. package/src/utils/amount/truncate-decimals.test.ts +97 -0
  438. package/src/utils/amount/truncate-decimals.ts +56 -0
  439. package/src/utils/balance/calc-max-spendable.test.ts +46 -0
  440. package/src/utils/balance/calc-max-spendable.ts +44 -0
  441. package/src/utils/balance/get-ton-shortfall.test.ts +148 -0
  442. package/src/utils/balance/get-ton-shortfall.ts +82 -0
  443. package/src/utils/functions/debounce.ts +169 -0
  444. package/src/utils/index.ts +10 -0
  445. package/src/utils/jetton/jetton-info.test.ts +65 -0
  446. package/src/utils/jetton/jetton-info.ts +12 -1
  447. package/src/utils/predicate/is-number.ts +19 -0
  448. package/src/utils/predicate/is-string.ts +2 -2
  449. package/dist/cjs/queries/staking/get-staking-providers.d.ts +0 -20
  450. package/dist/cjs/queries/staking/get-staking-providers.d.ts.map +0 -1
  451. package/dist/cjs/queries/staking/get-staking-providers.js +0 -25
  452. package/dist/esm/queries/staking/get-staking-providers.d.ts +0 -20
  453. package/dist/esm/queries/staking/get-staking-providers.d.ts.map +0 -1
  454. package/dist/esm/queries/staking/get-staking-providers.js +0 -20
  455. package/src/queries/staking/get-staking-providers.ts +0 -52
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { formatUnits, parseUnits } from '@ton/walletkit';
10
+
11
+ /** Default extra TON buffer added on top of built transaction outflow when checking balance before sending. */
12
+ export const DEFAULT_GAS_BUFFER_NANOS = 100_000_000n;
13
+
14
+ /**
15
+ * Default extra headroom baked into the suggested reduced amount, on top of the gas buffer.
16
+ * Covers quote/gas drift between the current built tx and the one that will actually be sent
17
+ * after the amount changes. 0.02 TON.
18
+ */
19
+ export const DEFAULT_SAFETY_MARGIN_NANOS = 20_000_000n;
20
+
21
+ export type TonShortfall =
22
+ | { mode: 'reduce'; requiredNanos: bigint; suggestedFromAmount: string }
23
+ | { mode: 'topup'; requiredNanos: bigint; suggestedFromAmount: '' };
24
+
25
+ export interface GetTonShortfallParams {
26
+ /** Messages of the built transaction. Each `amount` is the TON value in nanos attached to the message. */
27
+ messages: Array<{ amount: string }>;
28
+ /** User's current TON balance as a decimal string (same format `formatUnits(balance, 9)` returns). */
29
+ tonBalance: string | undefined;
30
+ /** The outgoing token — `{ address: 'ton' }` when the user spends TON, otherwise a jetton. */
31
+ fromToken: { address: string };
32
+ /** Amount the user intends to spend in `fromToken` units, as a decimal string. */
33
+ fromAmount: string;
34
+ /**
35
+ * Extra TON headroom on top of built-tx outflow when checking balance before sending.
36
+ * Defaults to {@link DEFAULT_GAS_BUFFER_NANOS}.
37
+ */
38
+ gasBufferNanos?: bigint;
39
+ /**
40
+ * Extra headroom baked into the suggested reduced amount, on top of the gas buffer.
41
+ * Defaults to {@link DEFAULT_SAFETY_MARGIN_NANOS}.
42
+ */
43
+ safetyMarginNanos?: bigint;
44
+ }
45
+
46
+ /**
47
+ * Check whether the user's TON balance covers the built transaction.
48
+ * - Returns `null` if the balance is sufficient.
49
+ * - Returns `{ mode: 'reduce', ... }` with a smaller suggested `fromAmount` when `fromToken` is TON
50
+ * and the balance is enough to cover at least gas (user can fix it by reducing the amount).
51
+ * - Returns `{ mode: 'topup', ... }` when `fromToken` is a jetton (reducing jetton amount won't free up TON gas),
52
+ * or when `fromToken` is TON but the balance can't even cover gas (reducing won't help — user must top up).
53
+ */
54
+ export const getTonShortfall = ({
55
+ messages,
56
+ tonBalance,
57
+ fromToken,
58
+ fromAmount,
59
+ gasBufferNanos = DEFAULT_GAS_BUFFER_NANOS,
60
+ safetyMarginNanos = DEFAULT_SAFETY_MARGIN_NANOS,
61
+ }: GetTonShortfallParams): TonShortfall | undefined => {
62
+ const totalOutNanos = messages.reduce((acc, m) => acc + BigInt(m.amount), 0n);
63
+ const requiredNanos = totalOutNanos + gasBufferNanos;
64
+ const tonBalanceNanos = tonBalance ? parseUnits(tonBalance, 9) : 0n;
65
+
66
+ if (tonBalanceNanos >= requiredNanos) return;
67
+
68
+ if (fromToken.address === 'ton') {
69
+ const gasOnlyNanos = totalOutNanos - parseUnits(fromAmount, 9);
70
+ const nonSwapReservedNanos = gasOnlyNanos + gasBufferNanos + safetyMarginNanos;
71
+
72
+ // Balance can't cover even gas for a minimal outgoing tx — reducing the amount won't help.
73
+ if (tonBalanceNanos <= nonSwapReservedNanos) {
74
+ return { mode: 'topup', requiredNanos, suggestedFromAmount: '' };
75
+ }
76
+
77
+ const suggestedFromAmount = formatUnits(tonBalanceNanos - nonSwapReservedNanos, 9);
78
+ return { mode: 'reduce', requiredNanos, suggestedFromAmount };
79
+ }
80
+
81
+ return { mode: 'topup', requiredNanos, suggestedFromAmount: '' };
82
+ };
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ export interface DebounceOptions {
10
+ /**
11
+ * An optional AbortSignal to cancel the debounced function.
12
+ */
13
+ signal?: AbortSignal;
14
+
15
+ /**
16
+ * An optional array specifying whether the function should be invoked on the leading edge, trailing edge, or both.
17
+ * If `edges` include "leading", the function will be invoked at the start of the delay period.
18
+ * If `edges` include "trailing", the function will be invoked at the end of the delay period.
19
+ * If both "leading" and "trailing" are included, the function will be invoked at both the start and end of the delay period.
20
+ * @default ["trailing"]
21
+ */
22
+ edges?: Array<'leading' | 'trailing'>;
23
+ }
24
+
25
+ export interface DebouncedFunction<F extends (...args: unknown[]) => void> {
26
+ (...args: Parameters<F>): void;
27
+
28
+ /**
29
+ * Schedules the execution of the debounced function after the specified debounced delay.
30
+ * This method resets any existing timer, ensuring that the function is only invoked
31
+ * after the delay has elapsed since the last call to the debounced function.
32
+ * It is typically called internally whenever the debounced function is invoked.
33
+ *
34
+ * @returns {void}
35
+ */
36
+ schedule: () => void;
37
+
38
+ /**
39
+ * Cancels any pending execution of the debounced function.
40
+ * This method clears the active timer and resets any stored context or arguments.
41
+ */
42
+ cancel: () => void;
43
+
44
+ /**
45
+ * Immediately invokes the debounced function if there is a pending execution.
46
+ * This method executes the function right away if there is a pending execution.
47
+ */
48
+ flush: () => void;
49
+ }
50
+
51
+ /**
52
+ * Creates a debounced function that delays invoking the provided function until after `debounceMs` milliseconds
53
+ * have elapsed since the last time the debounced function was invoked. The debounced function also has a `cancel`
54
+ * method to cancel any pending execution.
55
+ *
56
+ * @template F - The type of function.
57
+ * @param {F} func - The function to debounce.
58
+ * @param {number} debounceMs - The number of milliseconds to delay.
59
+ * @param {DebounceOptions} options - The options object
60
+ * @param {AbortSignal} options.signal - An optional AbortSignal to cancel the debounced function.
61
+ * @returns A new debounced function with a `cancel` method.
62
+ *
63
+ * @example
64
+ * const debouncedFunction = debounce(() => {
65
+ * console.log('Function executed');
66
+ * }, 1000);
67
+ *
68
+ * // Will log 'Function executed' after 1 second if not called again in that time
69
+ * debouncedFunction();
70
+ *
71
+ * // Will not log anything as the previous call is canceled
72
+ * debouncedFunction.cancel();
73
+ *
74
+ * // With AbortSignal
75
+ * const controller = new AbortController();
76
+ * const signal = controller.signal;
77
+ * const debouncedWithSignal = debounce(() => {
78
+ * console.log('Function executed');
79
+ * }, 1000, { signal });
80
+ *
81
+ * debouncedWithSignal();
82
+ *
83
+ * // Will cancel the debounced function call
84
+ * controller.abort();
85
+ */
86
+ export const debounce = <F extends (...args: unknown[]) => void>(
87
+ func: F,
88
+ debounceMs: number,
89
+ { signal, edges }: DebounceOptions = {},
90
+ ): DebouncedFunction<F> => {
91
+ let pendingThis: unknown = undefined;
92
+ let pendingArgs: Parameters<F> | null = null;
93
+
94
+ const leading = edges != null && edges.includes('leading');
95
+ const trailing = edges == null || edges.includes('trailing');
96
+
97
+ const invoke = () => {
98
+ if (pendingArgs !== null) {
99
+ func.apply(pendingThis, pendingArgs);
100
+ pendingThis = undefined;
101
+ pendingArgs = null;
102
+ }
103
+ };
104
+
105
+ const onTimerEnd = () => {
106
+ if (trailing) {
107
+ invoke();
108
+ }
109
+
110
+ cancel();
111
+ };
112
+
113
+ let timeoutId: ReturnType<typeof setTimeout> | null = null;
114
+
115
+ const schedule = () => {
116
+ if (timeoutId != null) {
117
+ clearTimeout(timeoutId);
118
+ }
119
+
120
+ timeoutId = setTimeout(() => {
121
+ timeoutId = null;
122
+
123
+ onTimerEnd();
124
+ }, debounceMs);
125
+ };
126
+
127
+ const cancelTimer = () => {
128
+ if (timeoutId !== null) {
129
+ clearTimeout(timeoutId);
130
+ timeoutId = null;
131
+ }
132
+ };
133
+
134
+ const cancel = () => {
135
+ cancelTimer();
136
+ pendingThis = undefined;
137
+ pendingArgs = null;
138
+ };
139
+
140
+ const flush = () => {
141
+ invoke();
142
+ };
143
+
144
+ const debounced = function (this: unknown, ...args: Parameters<F>) {
145
+ if (signal?.aborted) {
146
+ return;
147
+ }
148
+
149
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
150
+ pendingThis = this;
151
+ pendingArgs = args;
152
+
153
+ const isFirstCall = timeoutId == null;
154
+
155
+ schedule();
156
+
157
+ if (leading && isFirstCall) {
158
+ invoke();
159
+ }
160
+ };
161
+
162
+ debounced.schedule = schedule;
163
+ debounced.cancel = cancel;
164
+ debounced.flush = flush;
165
+
166
+ signal?.addEventListener('abort', cancel, { once: true });
167
+
168
+ return debounced;
169
+ };
@@ -8,14 +8,24 @@
8
8
 
9
9
  export { formatUnits, parseUnits, compareAddress } from '@ton/walletkit';
10
10
 
11
+ export * from './address/is-valid-address';
12
+ export * from './address/to-bounceble-address';
13
+ export * from './address/to-non-bounceble-address';
14
+ export * from './amount/calc-fiat-value';
15
+ export * from './amount/format-large-value';
16
+ export * from './amount/truncate-decimals';
11
17
  export * from './amount/validate-numeric-string';
18
+ export * from './balance/calc-max-spendable';
19
+ export * from './balance/get-ton-shortfall';
12
20
  export * from './arrays/key-by';
13
21
  export * from './arrays/random-from-array';
14
22
  export * from './errors/get-error-message';
23
+ export * from './functions/debounce';
15
24
  export * from './functions/noop';
16
25
  export * from './jetton/jetton-info';
17
26
  export * from './nft/nft-info';
18
27
  export * from './object/map-values';
28
+ export * from './predicate/is-number';
19
29
  export * from './predicate/is-string';
20
30
  export * from './promise/cancel-promise';
21
31
  export * from './promise/sleep';
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { describe, expect, it } from 'vitest';
10
+
11
+ import { isJettonInfo } from './jetton-info';
12
+
13
+ describe('isJettonInfo', () => {
14
+ it('should return true for a valid JettonInfo object', () => {
15
+ expect(
16
+ isJettonInfo({
17
+ address: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',
18
+ name: 'Tether USD',
19
+ symbol: 'USDT',
20
+ description: 'Tether USD stablecoin',
21
+ }),
22
+ ).toBe(true);
23
+ });
24
+
25
+ it('should return true when optional fields are present', () => {
26
+ expect(
27
+ isJettonInfo({
28
+ address: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',
29
+ name: 'Tether USD',
30
+ symbol: 'USDT',
31
+ description: 'Tether USD stablecoin',
32
+ decimals: 6,
33
+ image: 'https://example.com/image.png',
34
+ uri: 'https://example.com/meta.json',
35
+ }),
36
+ ).toBe(true);
37
+ });
38
+
39
+ it('should return false for null', () => {
40
+ expect(isJettonInfo(null)).toBe(false);
41
+ });
42
+
43
+ it('should return false for primitives', () => {
44
+ expect(isJettonInfo('string')).toBe(false);
45
+ expect(isJettonInfo(42)).toBe(false);
46
+ expect(isJettonInfo(true)).toBe(false);
47
+ expect(isJettonInfo(undefined)).toBe(false);
48
+ });
49
+
50
+ it('should return false when required string fields are missing', () => {
51
+ expect(isJettonInfo({ name: 'Test', symbol: 'TST', description: 'desc' })).toBe(false);
52
+ expect(isJettonInfo({ address: 'EQ...', symbol: 'TST', description: 'desc' })).toBe(false);
53
+ expect(isJettonInfo({ address: 'EQ...', name: 'Test', description: 'desc' })).toBe(false);
54
+ expect(isJettonInfo({ address: 'EQ...', name: 'Test', symbol: 'TST' })).toBe(false);
55
+ });
56
+
57
+ it('should return false when required fields are not strings', () => {
58
+ expect(isJettonInfo({ address: 1, name: 'Test', symbol: 'TST', description: 'desc' })).toBe(false);
59
+ expect(isJettonInfo({ address: 'EQ...', name: null, symbol: 'TST', description: 'desc' })).toBe(false);
60
+ });
61
+
62
+ it('should return false for an empty object', () => {
63
+ expect(isJettonInfo({})).toBe(false);
64
+ });
65
+ });
@@ -6,7 +6,18 @@
6
6
  *
7
7
  */
8
8
 
9
- import type { Jetton } from '@ton/walletkit';
9
+ import type { Jetton, JettonInfo } from '../../types/jetton';
10
+
11
+ export const isJettonInfo = (value: unknown): value is JettonInfo => {
12
+ if (typeof value !== 'object' || value === null) return false;
13
+ const v = value as Record<string, unknown>;
14
+ return (
15
+ typeof v.address === 'string' &&
16
+ typeof v.name === 'string' &&
17
+ typeof v.symbol === 'string' &&
18
+ typeof v.description === 'string'
19
+ );
20
+ };
10
21
 
11
22
  export const getJettonsSymbol = (jetton: Jetton): string | undefined => {
12
23
  if (!jetton?.info?.symbol) {
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) TonTech.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ export const isNumber = (value: unknown): value is number => {
10
+ if (typeof value !== 'number') {
11
+ return false;
12
+ }
13
+
14
+ if (Number.isNaN(value)) {
15
+ return false;
16
+ }
17
+
18
+ return Number.isFinite(value);
19
+ };
@@ -6,6 +6,6 @@
6
6
  *
7
7
  */
8
8
 
9
- export function isString(value: unknown): value is string {
9
+ export const isString = (value: unknown): value is string => {
10
10
  return typeof value === 'string';
11
- }
11
+ };
@@ -1,20 +0,0 @@
1
- /**
2
- * Copyright (c) TonTech.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import type { GetStakingProvidersReturnType } from '../../actions/staking/get-staking-providers';
9
- import type { AppKit } from '../../core/app-kit';
10
- import type { QueryOptions, QueryParameter } from '../../types/query';
11
- import type { Compute } from '../../types/utils';
12
- export type GetStakingProvidersErrorType = Error;
13
- export type GetStakingProvidersQueryConfig<selectData = GetStakingProvidersData> = QueryParameter<GetStakingProvidersQueryFnData, GetStakingProvidersErrorType, selectData, GetStakingProvidersQueryKey>;
14
- export declare const getStakingProvidersQueryOptions: <selectData = GetStakingProvidersData>(appKit: AppKit, options?: GetStakingProvidersQueryConfig<selectData>) => GetStakingProvidersQueryOptions<selectData>;
15
- export type GetStakingProvidersQueryFnData = Compute<Awaited<GetStakingProvidersReturnType>>;
16
- export type GetStakingProvidersData = GetStakingProvidersQueryFnData;
17
- export declare const getStakingProvidersQueryKey: () => GetStakingProvidersQueryKey;
18
- export type GetStakingProvidersQueryKey = readonly ['stakingProviders'];
19
- export type GetStakingProvidersQueryOptions<selectData = GetStakingProvidersData> = QueryOptions<GetStakingProvidersQueryFnData, GetStakingProvidersErrorType, selectData, GetStakingProvidersQueryKey>;
20
- //# sourceMappingURL=get-staking-providers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-staking-providers.d.ts","sourceRoot":"","sources":["../../../../src/queries/staking/get-staking-providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AACjG,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,MAAM,mBAAmB,CAAC;AAEjD,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAEjD,MAAM,MAAM,8BAA8B,CAAC,UAAU,GAAG,uBAAuB,IAAI,cAAc,CAC7F,8BAA8B,EAC9B,4BAA4B,EAC5B,UAAU,EACV,2BAA2B,CAC9B,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,UAAU,GAAG,uBAAuB,EAChF,QAAQ,MAAM,EACd,UAAS,8BAA8B,CAAC,UAAU,CAAM,KACzD,+BAA+B,CAAC,UAAU,CAQ5C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,OAAO,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC;AAE7F,MAAM,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAErE,eAAO,MAAM,2BAA2B,QAAO,2BAE9C,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;AAExE,MAAM,MAAM,+BAA+B,CAAC,UAAU,GAAG,uBAAuB,IAAI,YAAY,CAC5F,8BAA8B,EAC9B,4BAA4B,EAC5B,UAAU,EACV,2BAA2B,CAC9B,CAAC"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) TonTech.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- *
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.getStakingProvidersQueryKey = exports.getStakingProvidersQueryOptions = void 0;
11
- const get_staking_providers_1 = require("../../actions/staking/get-staking-providers");
12
- const getStakingProvidersQueryOptions = (appKit, options = {}) => {
13
- return {
14
- ...options.query,
15
- queryFn: async () => {
16
- return (0, get_staking_providers_1.getStakingProviders)(appKit);
17
- },
18
- queryKey: (0, exports.getStakingProvidersQueryKey)(),
19
- };
20
- };
21
- exports.getStakingProvidersQueryOptions = getStakingProvidersQueryOptions;
22
- const getStakingProvidersQueryKey = () => {
23
- return ['stakingProviders'];
24
- };
25
- exports.getStakingProvidersQueryKey = getStakingProvidersQueryKey;
@@ -1,20 +0,0 @@
1
- /**
2
- * Copyright (c) TonTech.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import type { GetStakingProvidersReturnType } from '../../actions/staking/get-staking-providers';
9
- import type { AppKit } from '../../core/app-kit';
10
- import type { QueryOptions, QueryParameter } from '../../types/query';
11
- import type { Compute } from '../../types/utils';
12
- export type GetStakingProvidersErrorType = Error;
13
- export type GetStakingProvidersQueryConfig<selectData = GetStakingProvidersData> = QueryParameter<GetStakingProvidersQueryFnData, GetStakingProvidersErrorType, selectData, GetStakingProvidersQueryKey>;
14
- export declare const getStakingProvidersQueryOptions: <selectData = GetStakingProvidersData>(appKit: AppKit, options?: GetStakingProvidersQueryConfig<selectData>) => GetStakingProvidersQueryOptions<selectData>;
15
- export type GetStakingProvidersQueryFnData = Compute<Awaited<GetStakingProvidersReturnType>>;
16
- export type GetStakingProvidersData = GetStakingProvidersQueryFnData;
17
- export declare const getStakingProvidersQueryKey: () => GetStakingProvidersQueryKey;
18
- export type GetStakingProvidersQueryKey = readonly ['stakingProviders'];
19
- export type GetStakingProvidersQueryOptions<selectData = GetStakingProvidersData> = QueryOptions<GetStakingProvidersQueryFnData, GetStakingProvidersErrorType, selectData, GetStakingProvidersQueryKey>;
20
- //# sourceMappingURL=get-staking-providers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-staking-providers.d.ts","sourceRoot":"","sources":["../../../../src/queries/staking/get-staking-providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AACjG,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,MAAM,mBAAmB,CAAC;AAEjD,MAAM,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAEjD,MAAM,MAAM,8BAA8B,CAAC,UAAU,GAAG,uBAAuB,IAAI,cAAc,CAC7F,8BAA8B,EAC9B,4BAA4B,EAC5B,UAAU,EACV,2BAA2B,CAC9B,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAAI,UAAU,GAAG,uBAAuB,EAChF,QAAQ,MAAM,EACd,UAAS,8BAA8B,CAAC,UAAU,CAAM,KACzD,+BAA+B,CAAC,UAAU,CAQ5C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,OAAO,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,CAAC;AAE7F,MAAM,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAErE,eAAO,MAAM,2BAA2B,QAAO,2BAE9C,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;AAExE,MAAM,MAAM,+BAA+B,CAAC,UAAU,GAAG,uBAAuB,IAAI,YAAY,CAC5F,8BAA8B,EAC9B,4BAA4B,EAC5B,UAAU,EACV,2BAA2B,CAC9B,CAAC"}
@@ -1,20 +0,0 @@
1
- /**
2
- * Copyright (c) TonTech.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
- import { getStakingProviders } from '../../actions/staking/get-staking-providers';
9
- export const getStakingProvidersQueryOptions = (appKit, options = {}) => {
10
- return {
11
- ...options.query,
12
- queryFn: async () => {
13
- return getStakingProviders(appKit);
14
- },
15
- queryKey: getStakingProvidersQueryKey(),
16
- };
17
- };
18
- export const getStakingProvidersQueryKey = () => {
19
- return ['stakingProviders'];
20
- };
@@ -1,52 +0,0 @@
1
- /**
2
- * Copyright (c) TonTech.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import { getStakingProviders } from '../../actions/staking/get-staking-providers';
10
- import type { GetStakingProvidersReturnType } from '../../actions/staking/get-staking-providers';
11
- import type { AppKit } from '../../core/app-kit';
12
- import type { QueryOptions, QueryParameter } from '../../types/query';
13
- import type { Compute } from '../../types/utils';
14
-
15
- export type GetStakingProvidersErrorType = Error;
16
-
17
- export type GetStakingProvidersQueryConfig<selectData = GetStakingProvidersData> = QueryParameter<
18
- GetStakingProvidersQueryFnData,
19
- GetStakingProvidersErrorType,
20
- selectData,
21
- GetStakingProvidersQueryKey
22
- >;
23
-
24
- export const getStakingProvidersQueryOptions = <selectData = GetStakingProvidersData>(
25
- appKit: AppKit,
26
- options: GetStakingProvidersQueryConfig<selectData> = {},
27
- ): GetStakingProvidersQueryOptions<selectData> => {
28
- return {
29
- ...options.query,
30
- queryFn: async () => {
31
- return getStakingProviders(appKit);
32
- },
33
- queryKey: getStakingProvidersQueryKey(),
34
- };
35
- };
36
-
37
- export type GetStakingProvidersQueryFnData = Compute<Awaited<GetStakingProvidersReturnType>>;
38
-
39
- export type GetStakingProvidersData = GetStakingProvidersQueryFnData;
40
-
41
- export const getStakingProvidersQueryKey = (): GetStakingProvidersQueryKey => {
42
- return ['stakingProviders'] as const;
43
- };
44
-
45
- export type GetStakingProvidersQueryKey = readonly ['stakingProviders'];
46
-
47
- export type GetStakingProvidersQueryOptions<selectData = GetStakingProvidersData> = QueryOptions<
48
- GetStakingProvidersQueryFnData,
49
- GetStakingProvidersErrorType,
50
- selectData,
51
- GetStakingProvidersQueryKey
52
- >;