crypto-aio 0.0.3 → 0.1.0

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 (691) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +144 -14
  3. package/dist/adapters/avalanche/address.d.ts +15 -0
  4. package/dist/adapters/avalanche/address.js +74 -0
  5. package/dist/adapters/avalanche/address.js.map +1 -0
  6. package/dist/adapters/avalanche/api.d.ts +100 -0
  7. package/dist/adapters/avalanche/api.js +381 -0
  8. package/dist/adapters/avalanche/api.js.map +1 -0
  9. package/dist/adapters/avalanche/builder.d.ts +13 -0
  10. package/dist/adapters/avalanche/builder.js +336 -0
  11. package/dist/adapters/avalanche/builder.js.map +1 -0
  12. package/dist/adapters/avalanche/cb58.d.ts +7 -0
  13. package/dist/adapters/avalanche/cb58.js +49 -0
  14. package/dist/adapters/avalanche/cb58.js.map +1 -0
  15. package/dist/adapters/avalanche/chains.d.ts +21 -0
  16. package/dist/adapters/avalanche/chains.js +79 -0
  17. package/dist/adapters/avalanche/chains.js.map +1 -0
  18. package/dist/adapters/avalanche/codec.d.ts +94 -0
  19. package/dist/adapters/avalanche/codec.js +371 -0
  20. package/dist/adapters/avalanche/codec.js.map +1 -0
  21. package/dist/adapters/avalanche/context.d.ts +59 -0
  22. package/dist/adapters/avalanche/context.js +114 -0
  23. package/dist/adapters/avalanche/context.js.map +1 -0
  24. package/dist/adapters/avalanche/decode.d.ts +16 -0
  25. package/dist/adapters/avalanche/decode.js +101 -0
  26. package/dist/adapters/avalanche/decode.js.map +1 -0
  27. package/dist/adapters/avalanche/driver.d.ts +22 -0
  28. package/dist/adapters/avalanche/driver.js +81 -0
  29. package/dist/adapters/avalanche/driver.js.map +1 -0
  30. package/dist/adapters/avalanche/errors.d.ts +18 -0
  31. package/dist/adapters/avalanche/errors.js +61 -0
  32. package/dist/adapters/avalanche/errors.js.map +1 -0
  33. package/dist/adapters/avalanche/fees.d.ts +23 -0
  34. package/dist/adapters/avalanche/fees.js +105 -0
  35. package/dist/adapters/avalanche/fees.js.map +1 -0
  36. package/dist/adapters/avalanche/index.d.ts +19 -0
  37. package/dist/adapters/avalanche/index.js +8 -0
  38. package/dist/adapters/avalanche/index.js.map +1 -0
  39. package/dist/adapters/avalanche/network.d.ts +37 -0
  40. package/dist/adapters/avalanche/network.js +135 -0
  41. package/dist/adapters/avalanche/network.js.map +1 -0
  42. package/dist/adapters/avalanche/plugin.d.ts +21 -0
  43. package/dist/adapters/avalanche/plugin.js +46 -0
  44. package/dist/adapters/avalanche/plugin.js.map +1 -0
  45. package/dist/adapters/avalanche/presets.d.ts +6 -0
  46. package/dist/adapters/avalanche/presets.js +86 -0
  47. package/dist/adapters/avalanche/presets.js.map +1 -0
  48. package/dist/adapters/avalanche/proofs.d.ts +41 -0
  49. package/dist/adapters/avalanche/proofs.js +270 -0
  50. package/dist/adapters/avalanche/proofs.js.map +1 -0
  51. package/dist/adapters/avalanche/reader.d.ts +40 -0
  52. package/dist/adapters/avalanche/reader.js +231 -0
  53. package/dist/adapters/avalanche/reader.js.map +1 -0
  54. package/dist/adapters/avalanche/sdk.d.ts +182 -0
  55. package/dist/adapters/avalanche/sdk.js +21 -0
  56. package/dist/adapters/avalanche/sdk.js.map +1 -0
  57. package/dist/adapters/avalanche/types.d.ts +86 -0
  58. package/dist/{type/common.js → adapters/avalanche/types.js} +1 -1
  59. package/dist/adapters/avalanche/types.js.map +1 -0
  60. package/dist/adapters/evm/builder.d.ts +11 -0
  61. package/dist/adapters/evm/builder.js +326 -0
  62. package/dist/adapters/evm/builder.js.map +1 -0
  63. package/dist/adapters/evm/chains.d.ts +6 -0
  64. package/dist/adapters/evm/chains.js +203 -0
  65. package/dist/adapters/evm/chains.js.map +1 -0
  66. package/dist/adapters/evm/client.d.ts +84 -0
  67. package/dist/adapters/evm/client.js +335 -0
  68. package/dist/adapters/evm/client.js.map +1 -0
  69. package/dist/adapters/evm/decode.d.ts +35 -0
  70. package/dist/adapters/evm/decode.js +170 -0
  71. package/dist/adapters/evm/decode.js.map +1 -0
  72. package/dist/adapters/evm/driver.d.ts +8 -0
  73. package/dist/adapters/evm/driver.js +61 -0
  74. package/dist/adapters/evm/driver.js.map +1 -0
  75. package/dist/adapters/evm/errors.d.ts +20 -0
  76. package/dist/adapters/evm/errors.js +110 -0
  77. package/dist/adapters/evm/errors.js.map +1 -0
  78. package/dist/adapters/evm/ethers-client.d.ts +43 -0
  79. package/dist/adapters/evm/ethers-client.js +135 -0
  80. package/dist/adapters/evm/ethers-client.js.map +1 -0
  81. package/dist/adapters/evm/fees.d.ts +79 -0
  82. package/dist/adapters/evm/fees.js +234 -0
  83. package/dist/adapters/evm/fees.js.map +1 -0
  84. package/dist/adapters/evm/index.d.ts +20 -0
  85. package/dist/adapters/evm/index.js +11 -0
  86. package/dist/adapters/evm/index.js.map +1 -0
  87. package/dist/adapters/evm/network.d.ts +60 -0
  88. package/dist/adapters/evm/network.js +131 -0
  89. package/dist/adapters/evm/network.js.map +1 -0
  90. package/dist/adapters/evm/plugin.d.ts +36 -0
  91. package/dist/adapters/evm/plugin.js +102 -0
  92. package/dist/adapters/evm/plugin.js.map +1 -0
  93. package/dist/adapters/evm/presets.d.ts +2 -0
  94. package/dist/adapters/evm/presets.js +105 -0
  95. package/dist/adapters/evm/presets.js.map +1 -0
  96. package/dist/adapters/evm/proofs.d.ts +19 -0
  97. package/dist/adapters/evm/proofs.js +358 -0
  98. package/dist/adapters/evm/proofs.js.map +1 -0
  99. package/dist/adapters/evm/rawtx.d.ts +25 -0
  100. package/dist/adapters/evm/rawtx.js +176 -0
  101. package/dist/adapters/evm/rawtx.js.map +1 -0
  102. package/dist/adapters/evm/reader.d.ts +65 -0
  103. package/dist/adapters/evm/reader.js +292 -0
  104. package/dist/adapters/evm/reader.js.map +1 -0
  105. package/dist/adapters/evm/rpc.d.ts +39 -0
  106. package/dist/adapters/evm/rpc.js +152 -0
  107. package/dist/adapters/evm/rpc.js.map +1 -0
  108. package/dist/adapters/evm/tokens.d.ts +7 -0
  109. package/dist/adapters/evm/tokens.js +23 -0
  110. package/dist/adapters/evm/tokens.js.map +1 -0
  111. package/dist/adapters/evm/types.d.ts +255 -0
  112. package/dist/{type/account.js → adapters/evm/types.js} +1 -1
  113. package/dist/adapters/evm/types.js.map +1 -0
  114. package/dist/adapters/evm/web3-client.d.ts +23 -0
  115. package/dist/adapters/evm/web3-client.js +159 -0
  116. package/dist/adapters/evm/web3-client.js.map +1 -0
  117. package/dist/adapters/solana/builder.d.ts +18 -0
  118. package/dist/adapters/solana/builder.js +545 -0
  119. package/dist/adapters/solana/builder.js.map +1 -0
  120. package/dist/adapters/solana/chains.d.ts +13 -0
  121. package/dist/adapters/solana/chains.js +37 -0
  122. package/dist/adapters/solana/chains.js.map +1 -0
  123. package/dist/adapters/solana/decode.d.ts +111 -0
  124. package/dist/adapters/solana/decode.js +595 -0
  125. package/dist/adapters/solana/decode.js.map +1 -0
  126. package/dist/adapters/solana/driver.d.ts +15 -0
  127. package/dist/adapters/solana/driver.js +72 -0
  128. package/dist/adapters/solana/driver.js.map +1 -0
  129. package/dist/adapters/solana/errors.d.ts +36 -0
  130. package/dist/adapters/solana/errors.js +154 -0
  131. package/dist/adapters/solana/errors.js.map +1 -0
  132. package/dist/adapters/solana/fees.d.ts +68 -0
  133. package/dist/adapters/solana/fees.js +205 -0
  134. package/dist/adapters/solana/fees.js.map +1 -0
  135. package/dist/adapters/solana/heights.d.ts +47 -0
  136. package/dist/adapters/solana/heights.js +185 -0
  137. package/dist/adapters/solana/heights.js.map +1 -0
  138. package/dist/adapters/solana/history.d.ts +10 -0
  139. package/dist/adapters/solana/history.js +71 -0
  140. package/dist/adapters/solana/history.js.map +1 -0
  141. package/dist/adapters/solana/index.d.ts +16 -0
  142. package/dist/adapters/solana/index.js +9 -0
  143. package/dist/adapters/solana/index.js.map +1 -0
  144. package/dist/adapters/solana/keys.d.ts +13 -0
  145. package/dist/adapters/solana/keys.js +69 -0
  146. package/dist/adapters/solana/keys.js.map +1 -0
  147. package/dist/adapters/solana/network.d.ts +24 -0
  148. package/dist/adapters/solana/network.js +95 -0
  149. package/dist/adapters/solana/network.js.map +1 -0
  150. package/dist/adapters/solana/plugin.d.ts +18 -0
  151. package/dist/adapters/solana/plugin.js +41 -0
  152. package/dist/adapters/solana/plugin.js.map +1 -0
  153. package/dist/adapters/solana/presets.d.ts +2 -0
  154. package/dist/adapters/solana/presets.js +77 -0
  155. package/dist/adapters/solana/presets.js.map +1 -0
  156. package/dist/adapters/solana/programs.d.ts +44 -0
  157. package/dist/adapters/solana/programs.js +159 -0
  158. package/dist/adapters/solana/programs.js.map +1 -0
  159. package/dist/adapters/solana/proofs.d.ts +56 -0
  160. package/dist/adapters/solana/proofs.js +540 -0
  161. package/dist/adapters/solana/proofs.js.map +1 -0
  162. package/dist/adapters/solana/reader.d.ts +82 -0
  163. package/dist/adapters/solana/reader.js +326 -0
  164. package/dist/adapters/solana/reader.js.map +1 -0
  165. package/dist/adapters/solana/rpc.d.ts +102 -0
  166. package/dist/adapters/solana/rpc.js +301 -0
  167. package/dist/adapters/solana/rpc.js.map +1 -0
  168. package/dist/adapters/solana/tokens.d.ts +7 -0
  169. package/dist/adapters/solana/tokens.js +19 -0
  170. package/dist/adapters/solana/tokens.js.map +1 -0
  171. package/dist/adapters/solana/types.d.ts +121 -0
  172. package/dist/{type/contract.js → adapters/solana/types.js} +1 -1
  173. package/dist/adapters/solana/types.js.map +1 -0
  174. package/dist/adapters/solana/web3.d.ts +5 -0
  175. package/dist/adapters/solana/web3.js +83 -0
  176. package/dist/adapters/solana/web3.js.map +1 -0
  177. package/dist/adapters/solana/wire.d.ts +62 -0
  178. package/dist/adapters/solana/wire.js +168 -0
  179. package/dist/adapters/solana/wire.js.map +1 -0
  180. package/dist/adapters/ton/address.d.ts +43 -0
  181. package/dist/adapters/ton/address.js +168 -0
  182. package/dist/adapters/ton/address.js.map +1 -0
  183. package/dist/adapters/ton/api.d.ts +344 -0
  184. package/dist/adapters/ton/api.js +942 -0
  185. package/dist/adapters/ton/api.js.map +1 -0
  186. package/dist/adapters/ton/builder.d.ts +18 -0
  187. package/dist/adapters/ton/builder.js +701 -0
  188. package/dist/adapters/ton/builder.js.map +1 -0
  189. package/dist/adapters/ton/chains.d.ts +16 -0
  190. package/dist/adapters/ton/chains.js +39 -0
  191. package/dist/adapters/ton/chains.js.map +1 -0
  192. package/dist/adapters/ton/decode.d.ts +43 -0
  193. package/dist/adapters/ton/decode.js +219 -0
  194. package/dist/adapters/ton/decode.js.map +1 -0
  195. package/dist/adapters/ton/driver.d.ts +10 -0
  196. package/dist/adapters/ton/driver.js +117 -0
  197. package/dist/adapters/ton/driver.js.map +1 -0
  198. package/dist/adapters/ton/errors.d.ts +36 -0
  199. package/dist/adapters/ton/errors.js +89 -0
  200. package/dist/adapters/ton/errors.js.map +1 -0
  201. package/dist/adapters/ton/fees.d.ts +28 -0
  202. package/dist/adapters/ton/fees.js +121 -0
  203. package/dist/adapters/ton/fees.js.map +1 -0
  204. package/dist/adapters/ton/index.d.ts +16 -0
  205. package/dist/adapters/ton/index.js +9 -0
  206. package/dist/adapters/ton/index.js.map +1 -0
  207. package/dist/adapters/ton/messages.d.ts +157 -0
  208. package/dist/adapters/ton/messages.js +397 -0
  209. package/dist/adapters/ton/messages.js.map +1 -0
  210. package/dist/adapters/ton/native-client.d.ts +10 -0
  211. package/dist/adapters/ton/native-client.js +47 -0
  212. package/dist/adapters/ton/native-client.js.map +1 -0
  213. package/dist/adapters/ton/network.d.ts +58 -0
  214. package/dist/adapters/ton/network.js +207 -0
  215. package/dist/adapters/ton/network.js.map +1 -0
  216. package/dist/adapters/ton/plugin.d.ts +24 -0
  217. package/dist/adapters/ton/plugin.js +57 -0
  218. package/dist/adapters/ton/plugin.js.map +1 -0
  219. package/dist/adapters/ton/presets.d.ts +6 -0
  220. package/dist/adapters/ton/presets.js +94 -0
  221. package/dist/adapters/ton/presets.js.map +1 -0
  222. package/dist/adapters/ton/proofs.d.ts +66 -0
  223. package/dist/adapters/ton/proofs.js +813 -0
  224. package/dist/adapters/ton/proofs.js.map +1 -0
  225. package/dist/adapters/ton/reader.d.ts +194 -0
  226. package/dist/adapters/ton/reader.js +781 -0
  227. package/dist/adapters/ton/reader.js.map +1 -0
  228. package/dist/adapters/ton/tokens.d.ts +10 -0
  229. package/dist/adapters/ton/tokens.js +27 -0
  230. package/dist/adapters/ton/tokens.js.map +1 -0
  231. package/dist/adapters/ton/trace.d.ts +48 -0
  232. package/dist/adapters/ton/trace.js +277 -0
  233. package/dist/adapters/ton/trace.js.map +1 -0
  234. package/dist/adapters/ton/types.d.ts +105 -0
  235. package/dist/{type/transact.js → adapters/ton/types.js} +1 -1
  236. package/dist/adapters/ton/types.js.map +1 -0
  237. package/dist/adapters/ton/wallets.d.ts +86 -0
  238. package/dist/adapters/ton/wallets.js +373 -0
  239. package/dist/adapters/ton/wallets.js.map +1 -0
  240. package/dist/adapters/tron/abi.d.ts +39 -0
  241. package/dist/adapters/tron/abi.js +110 -0
  242. package/dist/adapters/tron/abi.js.map +1 -0
  243. package/dist/adapters/tron/address.d.ts +20 -0
  244. package/dist/adapters/tron/address.js +110 -0
  245. package/dist/adapters/tron/address.js.map +1 -0
  246. package/dist/adapters/tron/builder.d.ts +12 -0
  247. package/dist/adapters/tron/builder.js +553 -0
  248. package/dist/adapters/tron/builder.js.map +1 -0
  249. package/dist/adapters/tron/chains.d.ts +12 -0
  250. package/dist/adapters/tron/chains.js +35 -0
  251. package/dist/adapters/tron/chains.js.map +1 -0
  252. package/dist/adapters/tron/codec.d.ts +10 -0
  253. package/dist/adapters/tron/codec.js +322 -0
  254. package/dist/adapters/tron/codec.js.map +1 -0
  255. package/dist/adapters/tron/decode.d.ts +50 -0
  256. package/dist/adapters/tron/decode.js +280 -0
  257. package/dist/adapters/tron/decode.js.map +1 -0
  258. package/dist/adapters/tron/driver.d.ts +12 -0
  259. package/dist/adapters/tron/driver.js +106 -0
  260. package/dist/adapters/tron/driver.js.map +1 -0
  261. package/dist/adapters/tron/errors.d.ts +74 -0
  262. package/dist/adapters/tron/errors.js +261 -0
  263. package/dist/adapters/tron/errors.js.map +1 -0
  264. package/dist/adapters/tron/fees.d.ts +49 -0
  265. package/dist/adapters/tron/fees.js +166 -0
  266. package/dist/adapters/tron/fees.js.map +1 -0
  267. package/dist/adapters/tron/http.d.ts +173 -0
  268. package/dist/adapters/tron/http.js +729 -0
  269. package/dist/adapters/tron/http.js.map +1 -0
  270. package/dist/adapters/tron/index.d.ts +16 -0
  271. package/dist/adapters/tron/index.js +15 -0
  272. package/dist/adapters/tron/index.js.map +1 -0
  273. package/dist/adapters/tron/network.d.ts +44 -0
  274. package/dist/adapters/tron/network.js +163 -0
  275. package/dist/adapters/tron/network.js.map +1 -0
  276. package/dist/adapters/tron/plugin.d.ts +17 -0
  277. package/dist/adapters/tron/plugin.js +39 -0
  278. package/dist/adapters/tron/plugin.js.map +1 -0
  279. package/dist/adapters/tron/presets.d.ts +5 -0
  280. package/dist/adapters/tron/presets.js +68 -0
  281. package/dist/adapters/tron/presets.js.map +1 -0
  282. package/dist/adapters/tron/proofs.d.ts +80 -0
  283. package/dist/adapters/tron/proofs.js +370 -0
  284. package/dist/adapters/tron/proofs.js.map +1 -0
  285. package/dist/adapters/tron/protobuf.d.ts +36 -0
  286. package/dist/adapters/tron/protobuf.js +90 -0
  287. package/dist/adapters/tron/protobuf.js.map +1 -0
  288. package/dist/adapters/tron/reader.d.ts +47 -0
  289. package/dist/adapters/tron/reader.js +203 -0
  290. package/dist/adapters/tron/reader.js.map +1 -0
  291. package/dist/adapters/tron/tokens.d.ts +7 -0
  292. package/dist/adapters/tron/tokens.js +14 -0
  293. package/dist/adapters/tron/tokens.js.map +1 -0
  294. package/dist/adapters/tron/types.d.ts +166 -0
  295. package/dist/adapters/tron/types.js +3 -0
  296. package/dist/adapters/tron/types.js.map +1 -0
  297. package/dist/adapters/utxo/address.d.ts +51 -0
  298. package/dist/adapters/utxo/address.js +341 -0
  299. package/dist/adapters/utxo/address.js.map +1 -0
  300. package/dist/adapters/utxo/builder.d.ts +35 -0
  301. package/dist/adapters/utxo/builder.js +380 -0
  302. package/dist/adapters/utxo/builder.js.map +1 -0
  303. package/dist/adapters/utxo/chains.d.ts +17 -0
  304. package/dist/adapters/utxo/chains.js +99 -0
  305. package/dist/adapters/utxo/chains.js.map +1 -0
  306. package/dist/adapters/utxo/codec.d.ts +120 -0
  307. package/dist/adapters/utxo/codec.js +408 -0
  308. package/dist/adapters/utxo/codec.js.map +1 -0
  309. package/dist/adapters/utxo/coinselect.d.ts +48 -0
  310. package/dist/adapters/utxo/coinselect.js +131 -0
  311. package/dist/adapters/utxo/coinselect.js.map +1 -0
  312. package/dist/adapters/utxo/context.d.ts +57 -0
  313. package/dist/adapters/utxo/context.js +118 -0
  314. package/dist/adapters/utxo/context.js.map +1 -0
  315. package/dist/adapters/utxo/decode.d.ts +14 -0
  316. package/dist/adapters/utxo/decode.js +85 -0
  317. package/dist/adapters/utxo/decode.js.map +1 -0
  318. package/dist/adapters/utxo/driver.d.ts +16 -0
  319. package/dist/adapters/utxo/driver.js +74 -0
  320. package/dist/adapters/utxo/driver.js.map +1 -0
  321. package/dist/adapters/utxo/ecc.d.ts +9 -0
  322. package/dist/adapters/utxo/ecc.js +26 -0
  323. package/dist/adapters/utxo/ecc.js.map +1 -0
  324. package/dist/adapters/utxo/errors.d.ts +52 -0
  325. package/dist/adapters/utxo/errors.js +191 -0
  326. package/dist/adapters/utxo/errors.js.map +1 -0
  327. package/dist/adapters/utxo/esplora.d.ts +79 -0
  328. package/dist/adapters/utxo/esplora.js +451 -0
  329. package/dist/adapters/utxo/esplora.js.map +1 -0
  330. package/dist/adapters/utxo/fees.d.ts +41 -0
  331. package/dist/adapters/utxo/fees.js +125 -0
  332. package/dist/adapters/utxo/fees.js.map +1 -0
  333. package/dist/adapters/utxo/index.d.ts +17 -0
  334. package/dist/adapters/utxo/index.js +8 -0
  335. package/dist/adapters/utxo/index.js.map +1 -0
  336. package/dist/adapters/utxo/network.d.ts +50 -0
  337. package/dist/adapters/utxo/network.js +165 -0
  338. package/dist/adapters/utxo/network.js.map +1 -0
  339. package/dist/adapters/utxo/plugin.d.ts +17 -0
  340. package/dist/adapters/utxo/plugin.js +41 -0
  341. package/dist/adapters/utxo/plugin.js.map +1 -0
  342. package/dist/adapters/utxo/presets.d.ts +12 -0
  343. package/dist/adapters/utxo/presets.js +47 -0
  344. package/dist/adapters/utxo/presets.js.map +1 -0
  345. package/dist/adapters/utxo/preview.d.ts +3 -0
  346. package/dist/adapters/utxo/preview.js +65 -0
  347. package/dist/adapters/utxo/preview.js.map +1 -0
  348. package/dist/adapters/utxo/proofs.d.ts +57 -0
  349. package/dist/adapters/utxo/proofs.js +331 -0
  350. package/dist/adapters/utxo/proofs.js.map +1 -0
  351. package/dist/adapters/utxo/rawtx.d.ts +59 -0
  352. package/dist/adapters/utxo/rawtx.js +234 -0
  353. package/dist/adapters/utxo/rawtx.js.map +1 -0
  354. package/dist/adapters/utxo/reader.d.ts +36 -0
  355. package/dist/adapters/utxo/reader.js +265 -0
  356. package/dist/adapters/utxo/reader.js.map +1 -0
  357. package/dist/adapters/utxo/sdk.d.ts +18 -0
  358. package/dist/adapters/utxo/sdk.js +17 -0
  359. package/dist/adapters/utxo/sdk.js.map +1 -0
  360. package/dist/adapters/utxo/signed-psbt.d.ts +36 -0
  361. package/dist/adapters/utxo/signed-psbt.js +428 -0
  362. package/dist/adapters/utxo/signed-psbt.js.map +1 -0
  363. package/dist/adapters/utxo/spend.d.ts +59 -0
  364. package/dist/adapters/utxo/spend.js +230 -0
  365. package/dist/adapters/utxo/spend.js.map +1 -0
  366. package/dist/adapters/utxo/types.d.ts +167 -0
  367. package/dist/adapters/utxo/types.js +3 -0
  368. package/dist/adapters/utxo/types.js.map +1 -0
  369. package/dist/core/assets/service.d.ts +18 -0
  370. package/dist/core/assets/service.js +69 -0
  371. package/dist/core/assets/service.js.map +1 -0
  372. package/dist/core/blockchain/default-ref.d.ts +4 -0
  373. package/dist/core/blockchain/default-ref.js +16 -0
  374. package/dist/core/blockchain/default-ref.js.map +1 -0
  375. package/dist/core/blockchain/handle.d.ts +200 -0
  376. package/dist/core/blockchain/handle.js +579 -0
  377. package/dist/core/blockchain/handle.js.map +1 -0
  378. package/dist/core/blockchain/internal.d.ts +19 -0
  379. package/dist/core/blockchain/internal.js +16 -0
  380. package/dist/core/blockchain/internal.js.map +1 -0
  381. package/dist/core/blockchain/mapping.d.ts +22 -0
  382. package/dist/core/blockchain/mapping.js +136 -0
  383. package/dist/core/blockchain/mapping.js.map +1 -0
  384. package/dist/core/config/env.d.ts +8 -0
  385. package/dist/core/config/env.js +60 -0
  386. package/dist/core/config/env.js.map +1 -0
  387. package/dist/core/config/merge.d.ts +26 -0
  388. package/dist/core/config/merge.js +144 -0
  389. package/dist/core/config/merge.js.map +1 -0
  390. package/dist/core/config/resolve.d.ts +12 -0
  391. package/dist/core/config/resolve.js +251 -0
  392. package/dist/core/config/resolve.js.map +1 -0
  393. package/dist/core/config/types.d.ts +165 -0
  394. package/dist/core/config/types.js +3 -0
  395. package/dist/core/config/types.js.map +1 -0
  396. package/dist/core/container/builtins.d.ts +4 -0
  397. package/dist/core/container/builtins.js +13 -0
  398. package/dist/core/container/builtins.js.map +1 -0
  399. package/dist/core/container/container.d.ts +69 -0
  400. package/dist/core/container/container.js +466 -0
  401. package/dist/core/container/container.js.map +1 -0
  402. package/dist/core/container/default.d.ts +15 -0
  403. package/dist/core/container/default.js +70 -0
  404. package/dist/core/container/default.js.map +1 -0
  405. package/dist/core/container/internals.d.ts +54 -0
  406. package/dist/core/container/internals.js +21 -0
  407. package/dist/core/container/internals.js.map +1 -0
  408. package/dist/core/container/pool.d.ts +27 -0
  409. package/dist/core/container/pool.js +77 -0
  410. package/dist/core/container/pool.js.map +1 -0
  411. package/dist/core/driver/types.d.ts +346 -0
  412. package/dist/core/driver/types.js +3 -0
  413. package/dist/core/driver/types.js.map +1 -0
  414. package/dist/core/errors/codes.d.ts +153 -0
  415. package/dist/core/errors/codes.js +49 -0
  416. package/dist/core/errors/codes.js.map +1 -0
  417. package/dist/core/errors/error.d.ts +66 -0
  418. package/dist/core/errors/error.js +129 -0
  419. package/dist/core/errors/error.js.map +1 -0
  420. package/dist/core/events/bus.d.ts +12 -0
  421. package/dist/core/events/bus.js +46 -0
  422. package/dist/core/events/bus.js.map +1 -0
  423. package/dist/core/events/logger.d.ts +13 -0
  424. package/dist/core/events/logger.js +42 -0
  425. package/dist/core/events/logger.js.map +1 -0
  426. package/dist/core/events/types.d.ts +131 -0
  427. package/dist/core/events/types.js +3 -0
  428. package/dist/core/events/types.js.map +1 -0
  429. package/dist/core/lifecycle/engine-rules.d.ts +107 -0
  430. package/dist/core/lifecycle/engine-rules.js +257 -0
  431. package/dist/core/lifecycle/engine-rules.js.map +1 -0
  432. package/dist/core/lifecycle/engine.d.ts +500 -0
  433. package/dist/core/lifecycle/engine.js +1732 -0
  434. package/dist/core/lifecycle/engine.js.map +1 -0
  435. package/dist/core/lifecycle/evaluate.d.ts +19 -0
  436. package/dist/core/lifecycle/evaluate.js +72 -0
  437. package/dist/core/lifecycle/evaluate.js.map +1 -0
  438. package/dist/core/lifecycle/intent.d.ts +11 -0
  439. package/dist/core/lifecycle/intent.js +88 -0
  440. package/dist/core/lifecycle/intent.js.map +1 -0
  441. package/dist/core/lifecycle/monitor.d.ts +138 -0
  442. package/dist/core/lifecycle/monitor.js +606 -0
  443. package/dist/core/lifecycle/monitor.js.map +1 -0
  444. package/dist/core/lifecycle/observations.d.ts +17 -0
  445. package/dist/core/lifecycle/observations.js +59 -0
  446. package/dist/core/lifecycle/observations.js.map +1 -0
  447. package/dist/core/lifecycle/reconcile.d.ts +58 -0
  448. package/dist/core/lifecycle/reconcile.js +112 -0
  449. package/dist/core/lifecycle/reconcile.js.map +1 -0
  450. package/dist/core/lifecycle/views.d.ts +49 -0
  451. package/dist/core/lifecycle/views.js +57 -0
  452. package/dist/core/lifecycle/views.js.map +1 -0
  453. package/dist/core/lifecycle/workers.d.ts +82 -0
  454. package/dist/core/lifecycle/workers.js +329 -0
  455. package/dist/core/lifecycle/workers.js.map +1 -0
  456. package/dist/core/model/address.d.ts +32 -0
  457. package/dist/core/model/address.js +43 -0
  458. package/dist/core/model/address.js.map +1 -0
  459. package/dist/core/model/amount.d.ts +25 -0
  460. package/dist/core/model/amount.js +102 -0
  461. package/dist/core/model/amount.js.map +1 -0
  462. package/dist/core/model/asset.d.ts +28 -0
  463. package/dist/core/model/asset.js +47 -0
  464. package/dist/core/model/asset.js.map +1 -0
  465. package/dist/core/model/capability.d.ts +3 -0
  466. package/dist/core/model/capability.js +18 -0
  467. package/dist/core/model/capability.js.map +1 -0
  468. package/dist/core/model/chain.d.ts +63 -0
  469. package/dist/core/model/chain.js +8 -0
  470. package/dist/core/model/chain.js.map +1 -0
  471. package/dist/core/model/fee.d.ts +36 -0
  472. package/dist/core/model/fee.js +17 -0
  473. package/dist/core/model/fee.js.map +1 -0
  474. package/dist/core/model/ids.d.ts +37 -0
  475. package/dist/core/model/ids.js +13 -0
  476. package/dist/core/model/ids.js.map +1 -0
  477. package/dist/core/model/intent.d.ts +63 -0
  478. package/dist/core/model/intent.js +81 -0
  479. package/dist/core/model/intent.js.map +1 -0
  480. package/dist/core/model/ordering.d.ts +20 -0
  481. package/dist/core/model/ordering.js +29 -0
  482. package/dist/core/model/ordering.js.map +1 -0
  483. package/dist/core/model/transaction.d.ts +116 -0
  484. package/dist/{type/lib-types.js → core/model/transaction.js} +1 -1
  485. package/dist/core/model/transaction.js.map +1 -0
  486. package/dist/core/observe/scanner.d.ts +135 -0
  487. package/dist/core/observe/scanner.js +355 -0
  488. package/dist/core/observe/scanner.js.map +1 -0
  489. package/dist/core/ordering/reservations.d.ts +16 -0
  490. package/dist/core/ordering/reservations.js +53 -0
  491. package/dist/core/ordering/reservations.js.map +1 -0
  492. package/dist/core/ordering/sequence.d.ts +61 -0
  493. package/dist/core/ordering/sequence.js +155 -0
  494. package/dist/core/ordering/sequence.js.map +1 -0
  495. package/dist/core/registry/adapters.d.ts +10 -0
  496. package/dist/core/registry/adapters.js +56 -0
  497. package/dist/core/registry/adapters.js.map +1 -0
  498. package/dist/core/registry/assets.d.ts +18 -0
  499. package/dist/core/registry/assets.js +90 -0
  500. package/dist/core/registry/assets.js.map +1 -0
  501. package/dist/core/registry/chains.d.ts +10 -0
  502. package/dist/core/registry/chains.js +80 -0
  503. package/dist/core/registry/chains.js.map +1 -0
  504. package/dist/core/registry/plugin.d.ts +41 -0
  505. package/dist/core/registry/plugin.js +109 -0
  506. package/dist/core/registry/plugin.js.map +1 -0
  507. package/dist/core/registry/providers.d.ts +31 -0
  508. package/dist/core/registry/providers.js +43 -0
  509. package/dist/core/registry/providers.js.map +1 -0
  510. package/dist/core/registry/schemes.d.ts +30 -0
  511. package/dist/core/registry/schemes.js +84 -0
  512. package/dist/core/registry/schemes.js.map +1 -0
  513. package/dist/core/secret/fragments.d.ts +33 -0
  514. package/dist/core/secret/fragments.js +110 -0
  515. package/dist/core/secret/fragments.js.map +1 -0
  516. package/dist/core/secret/redact.d.ts +10 -0
  517. package/dist/core/secret/redact.js +110 -0
  518. package/dist/core/secret/redact.js.map +1 -0
  519. package/dist/core/secret/secret.d.ts +14 -0
  520. package/dist/core/secret/secret.js +42 -0
  521. package/dist/core/secret/secret.js.map +1 -0
  522. package/dist/core/signing/callback.d.ts +10 -0
  523. package/dist/core/signing/callback.js +22 -0
  524. package/dist/core/signing/callback.js.map +1 -0
  525. package/dist/core/signing/guard.d.ts +18 -0
  526. package/dist/core/signing/guard.js +72 -0
  527. package/dist/core/signing/guard.js.map +1 -0
  528. package/dist/core/signing/hd.d.ts +36 -0
  529. package/dist/core/signing/hd.js +167 -0
  530. package/dist/core/signing/hd.js.map +1 -0
  531. package/dist/core/signing/local.d.ts +48 -0
  532. package/dist/core/signing/local.js +190 -0
  533. package/dist/core/signing/local.js.map +1 -0
  534. package/dist/core/signing/orchestrator.d.ts +40 -0
  535. package/dist/core/signing/orchestrator.js +300 -0
  536. package/dist/core/signing/orchestrator.js.map +1 -0
  537. package/dist/core/signing/types.d.ts +64 -0
  538. package/dist/core/signing/types.js +3 -0
  539. package/dist/core/signing/types.js.map +1 -0
  540. package/dist/core/signing/wallet.d.ts +48 -0
  541. package/dist/core/signing/wallet.js +153 -0
  542. package/dist/core/signing/wallet.js.map +1 -0
  543. package/dist/core/store/clone.d.ts +25 -0
  544. package/dist/core/store/clone.js +71 -0
  545. package/dist/core/store/clone.js.map +1 -0
  546. package/dist/core/store/memory.d.ts +38 -0
  547. package/dist/core/store/memory.js +325 -0
  548. package/dist/core/store/memory.js.map +1 -0
  549. package/dist/core/store/types.d.ts +246 -0
  550. package/dist/core/store/types.js +117 -0
  551. package/dist/core/store/types.js.map +1 -0
  552. package/dist/core/transport/backoff.d.ts +8 -0
  553. package/dist/core/transport/backoff.js +27 -0
  554. package/dist/core/transport/backoff.js.map +1 -0
  555. package/dist/core/transport/circuit.d.ts +25 -0
  556. package/dist/core/transport/circuit.js +61 -0
  557. package/dist/core/transport/circuit.js.map +1 -0
  558. package/dist/core/transport/http-transport.d.ts +30 -0
  559. package/dist/core/transport/http-transport.js +1695 -0
  560. package/dist/core/transport/http-transport.js.map +1 -0
  561. package/dist/core/transport/rate-limit.d.ts +27 -0
  562. package/dist/core/transport/rate-limit.js +78 -0
  563. package/dist/core/transport/rate-limit.js.map +1 -0
  564. package/dist/core/transport/stale-view.d.ts +11 -0
  565. package/dist/core/transport/stale-view.js +17 -0
  566. package/dist/core/transport/stale-view.js.map +1 -0
  567. package/dist/core/transport/types.d.ts +144 -0
  568. package/dist/core/transport/types.js +6 -0
  569. package/dist/core/transport/types.js.map +1 -0
  570. package/dist/core/util/bytes.d.ts +9 -0
  571. package/dist/core/util/bytes.js +40 -0
  572. package/dist/core/util/bytes.js.map +1 -0
  573. package/dist/core/util/clock.d.ts +6 -0
  574. package/dist/core/util/clock.js +26 -0
  575. package/dist/core/util/clock.js.map +1 -0
  576. package/dist/core/util/freeze.d.ts +8 -0
  577. package/dist/core/util/freeze.js +31 -0
  578. package/dist/core/util/freeze.js.map +1 -0
  579. package/dist/core/util/json.d.ts +29 -0
  580. package/dist/core/util/json.js +165 -0
  581. package/dist/core/util/json.js.map +1 -0
  582. package/dist/core/util/names.d.ts +21 -0
  583. package/dist/core/util/names.js +46 -0
  584. package/dist/core/util/names.js.map +1 -0
  585. package/dist/index.d.ts +64 -14
  586. package/dist/index.js +105 -49
  587. package/dist/index.js.map +1 -1
  588. package/dist/native.d.ts +21 -0
  589. package/dist/native.js +44 -0
  590. package/dist/native.js.map +1 -0
  591. package/dist/testing/contracts/api.d.ts +12 -0
  592. package/dist/testing/contracts/api.js +58 -0
  593. package/dist/testing/contracts/api.js.map +1 -0
  594. package/dist/testing/contracts/cursors.d.ts +6 -0
  595. package/dist/testing/contracts/cursors.js +43 -0
  596. package/dist/testing/contracts/cursors.js.map +1 -0
  597. package/dist/testing/contracts/locks.d.ts +10 -0
  598. package/dist/testing/contracts/locks.js +63 -0
  599. package/dist/testing/contracts/locks.js.map +1 -0
  600. package/dist/testing/contracts/operations.d.ts +21 -0
  601. package/dist/testing/contracts/operations.js +718 -0
  602. package/dist/testing/contracts/operations.js.map +1 -0
  603. package/dist/testing/contracts/sequences.d.ts +6 -0
  604. package/dist/testing/contracts/sequences.js +68 -0
  605. package/dist/testing/contracts/sequences.js.map +1 -0
  606. package/dist/testing/env.d.ts +63 -0
  607. package/dist/testing/env.js +105 -0
  608. package/dist/testing/env.js.map +1 -0
  609. package/dist/testing/fake-chain.d.ts +118 -0
  610. package/dist/testing/fake-chain.js +536 -0
  611. package/dist/testing/fake-chain.js.map +1 -0
  612. package/dist/testing/fake-clock.d.ts +15 -0
  613. package/dist/testing/fake-clock.js +86 -0
  614. package/dist/testing/fake-clock.js.map +1 -0
  615. package/dist/testing/fake-driver.d.ts +15 -0
  616. package/dist/testing/fake-driver.js +458 -0
  617. package/dist/testing/fake-driver.js.map +1 -0
  618. package/dist/testing/fake-fetch.d.ts +32 -0
  619. package/dist/testing/fake-fetch.js +81 -0
  620. package/dist/testing/fake-fetch.js.map +1 -0
  621. package/dist/testing/fake-plugin.d.ts +30 -0
  622. package/dist/testing/fake-plugin.js +66 -0
  623. package/dist/testing/fake-plugin.js.map +1 -0
  624. package/dist/testing/faulty-store.d.ts +36 -0
  625. package/dist/testing/faulty-store.js +66 -0
  626. package/dist/testing/faulty-store.js.map +1 -0
  627. package/dist/testing/generation.d.ts +60 -0
  628. package/dist/testing/generation.js +252 -0
  629. package/dist/testing/generation.js.map +1 -0
  630. package/dist/testing/index.d.ts +28 -0
  631. package/dist/testing/index.js +51 -0
  632. package/dist/testing/index.js.map +1 -0
  633. package/package.json +188 -45
  634. package/dist/libs/eth/account.d.ts +0 -9
  635. package/dist/libs/eth/account.js +0 -58
  636. package/dist/libs/eth/account.js.map +0 -1
  637. package/dist/libs/eth/contract.d.ts +0 -7
  638. package/dist/libs/eth/contract.js +0 -42
  639. package/dist/libs/eth/contract.js.map +0 -1
  640. package/dist/libs/eth/index.d.ts +0 -24
  641. package/dist/libs/eth/index.js +0 -72
  642. package/dist/libs/eth/index.js.map +0 -1
  643. package/dist/libs/eth/transact.d.ts +0 -7
  644. package/dist/libs/eth/transact.js +0 -26
  645. package/dist/libs/eth/transact.js.map +0 -1
  646. package/dist/libs/index.d.ts +0 -2
  647. package/dist/libs/index.js +0 -19
  648. package/dist/libs/index.js.map +0 -1
  649. package/dist/libs/trx/account.d.ts +0 -9
  650. package/dist/libs/trx/account.js +0 -55
  651. package/dist/libs/trx/account.js.map +0 -1
  652. package/dist/libs/trx/contract.d.ts +0 -7
  653. package/dist/libs/trx/contract.js +0 -27
  654. package/dist/libs/trx/contract.js.map +0 -1
  655. package/dist/libs/trx/index.d.ts +0 -22
  656. package/dist/libs/trx/index.js +0 -64
  657. package/dist/libs/trx/index.js.map +0 -1
  658. package/dist/libs/trx/transact.d.ts +0 -7
  659. package/dist/libs/trx/transact.js +0 -26
  660. package/dist/libs/trx/transact.js.map +0 -1
  661. package/dist/tool/common.d.ts +0 -28
  662. package/dist/tool/common.js +0 -33
  663. package/dist/tool/common.js.map +0 -1
  664. package/dist/tool/eth-tools.d.ts +0 -3
  665. package/dist/tool/eth-tools.js +0 -33
  666. package/dist/tool/eth-tools.js.map +0 -1
  667. package/dist/tool/index.d.ts +0 -5
  668. package/dist/tool/index.js +0 -22
  669. package/dist/tool/index.js.map +0 -1
  670. package/dist/tool/logging.d.ts +0 -3
  671. package/dist/tool/logging.js +0 -11
  672. package/dist/tool/logging.js.map +0 -1
  673. package/dist/tool/options.d.ts +0 -6
  674. package/dist/tool/options.js +0 -41
  675. package/dist/tool/options.js.map +0 -1
  676. package/dist/tool/trx-tools.d.ts +0 -3
  677. package/dist/tool/trx-tools.js +0 -20
  678. package/dist/tool/trx-tools.js.map +0 -1
  679. package/dist/type/account.d.ts +0 -9
  680. package/dist/type/account.js.map +0 -1
  681. package/dist/type/common.d.ts +0 -18
  682. package/dist/type/common.js.map +0 -1
  683. package/dist/type/contract.d.ts +0 -10
  684. package/dist/type/contract.js.map +0 -1
  685. package/dist/type/index.d.ts +0 -5
  686. package/dist/type/index.js +0 -22
  687. package/dist/type/index.js.map +0 -1
  688. package/dist/type/lib-types.d.ts +0 -9
  689. package/dist/type/lib-types.js.map +0 -1
  690. package/dist/type/transact.d.ts +0 -7
  691. package/dist/type/transact.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../src/adapters/ton/reader.ts"],"names":[],"mappings":";;;AA+HA,oBAGC;AAED,4CAqBC;AAgFD,kDA2BC;AAMD,sCAiBC;AAuBD,8CA4BC;AASD,gDAgBC;AAuOD,oCASC;AAED,sCAOC;AA6BD,wCAYC;AAiBD,kCAkCC;AAGD,gCAEC;AAqCD,8CAyBC;AAKD,0CA6EC;AA8CD,kCAMC;AA+CD,kCAwBC;AAaD,sCAkBC;AAyDD,8CAWC;AAED,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,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,aAAO,CAAC;KACpE,CAAC;AACJ,CAAC;AAED,SAAgB,YAAY,CAAC,GAAe;IAC1C,OAAO;QACL,GAAG,EAAE;YACH,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAC1B,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,UAAI,CAAC;YAChE,iFAAiF;YACjF,kBAAkB;YAClB,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CACpC,mBAAmB,CACjB,GAAG,EACH,YAAY,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,EAC3D,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,EACpC,WAAK,CACN;SACJ;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * TON addresses, reads, seqnos, jetton lookups and the `ext.ton` API. Every call carries the\n * tags of the `ChainDriver` contract table (`src/core/driver/types.ts`): `read` for point\n * queries, `monitor` for heights, observations and seqnos. Jetton metadata, which the\n * core caches for the container's life, is a `read` under the proof quorum.\n */\nimport { Cell, Dictionary, type Transaction } from '@ton/core';\nimport { createHash } from 'node:crypto';\nimport type {\n AddressCodec,\n ChainReader,\n DriverBlock,\n DriverTxObservation,\n SequenceSource,\n WalletOptions,\n} from '../../core/driver/types';\nimport {\n ChainError,\n ProviderError,\n ValidationError,\n isCryptoAioError,\n withContext,\n} from '../../core/errors/error';\nimport type { Logger } from '../../core/events/logger';\nimport type { AssetMetadata, AssetRef, TokenRef } from '../../core/model/asset';\nimport type { ChainInfo, NetworkInfo } from '../../core/model/chain';\nimport type { AttemptRef } from '../../core/model/transaction';\nimport type { Clock } from '../../core/util/clock';\nimport { createTonAddressCodec } from './address';\nimport {\n MASTERCHAIN_SHARD,\n MONITOR,\n PROOF,\n READ,\n jettonDataOf,\n runResultOf,\n sameBlock,\n type AccountState,\n type BlockHeader,\n type BlockId,\n type BoundRunResult,\n type RunResult,\n type TonApi,\n type V3Trace,\n type V3Transaction,\n} from './api';\nimport {\n decodeTransaction,\n executed,\n jettonWalletToVerify,\n ran,\n type VerifiedJettonWallet,\n} from './decode';\nimport {\n addressArgument,\n addressFromBoc,\n decodeWalletRequest,\n messageBody,\n type WalletRequest,\n} from './messages';\nimport type { TonNetworkConfig } from './network';\nimport {\n REASONS,\n attemptVerdict,\n consumesSeqno,\n isOwnAttempt,\n type Verdict,\n} from './trace';\nimport type { TonCallTags, TonExt } from './types';\nimport { requestIsOwn, resolveIdentity, walletAddress } from './wallets';\n\n/**\n * What every TON port is built from. Drivers are shared: the caches hold only immutable\n * chain data, values the proof quorum attested or transactions bound to their own hash\n * (`chainTxs`); a single `read` or `monitor` answer is used once and never cached. The one\n * record of anything else is `assembled`, for the replay guard: what this driver itself\n * built and sent.\n */\nexport interface TonContext {\n readonly api: TonApi;\n readonly chain: ChainInfo;\n readonly network: NetworkInfo;\n readonly config: TonNetworkConfig;\n readonly log: Logger;\n readonly clock: Clock;\n readonly codec: AddressCodec;\n /** `master|owner` → the jetton wallet the master names, as the quorum attested it. */\n readonly jettonWallets: Map<string, string>;\n /** jetton wallet → its owner and master, verified under the quorum. */\n readonly verified: Map<string, VerifiedJettonWallet>;\n /**\n * Wallet transactions the chain walk authenticated, by `lt:hash`. A\n * transaction is immutable and its cell hashes to its id, so a kept one is as good as one\n * fetched again; each walk fetches only what it has not seen (bounded, `CHAIN_MEMO`).\n */\n readonly chainTxs: Map<string, Transaction>;\n /**\n * The external messages this driver assembled, by TEP-467 hash: the build's recorded\n * chain time and whether they were ever handed to a send (bounded, `ASSEMBLED_MEMO`).\n * Known gap: the `Broadcaster` port carries only the bytes, never the Attempt's\n * ordering, so the replay guard keeps this memo; bytes this driver did not assemble, or\n * has evicted, are guarded with the widest window (one day).\n */\n readonly assembled: Map<string, AssembledMessage>;\n}\n\n/** What `assemble` recorded about a message it made. */\nexport interface AssembledMessage {\n /** `TonSeqnoOrdering.validFrom`, as the ordering bound to the signed bytes holds it. */\n readonly validFrom: number;\n /**\n * The driver's clock when `assemble` ran, in ms: a first send skips the replay guard only\n * within `FIRST_SEND_MS` of it.\n */\n readonly assembledAt: number;\n /** Set before the first send; never cleared. */\n sent: boolean;\n}\n\n/** The most authenticated transactions a driver keeps (each at most `MEMO_TX_LENGTH`). */\nexport const CHAIN_MEMO = 4_096;\n/** The longest transaction BOC text kept: a wallet transaction takes about 1-2 KB. */\nexport const MEMO_TX_LENGTH = 16_384;\n/** The most assembled messages a driver remembers; an evicted one is guarded as foreign. */\nexport const ASSEMBLED_MEMO = 4_096;\n\n/** Keeps `value` in a bounded memo, dropping the oldest entry beyond `size`. */\nexport function keep<K, V>(memo: Map<K, V>, key: K, value: V, size: number): void {\n memo.set(key, value);\n if (memo.size > size) memo.delete(memo.keys().next().value as K);\n}\n\nexport function createTonContext(args: {\n readonly api: TonApi;\n readonly chain: ChainInfo;\n readonly network: NetworkInfo;\n readonly config: TonNetworkConfig;\n readonly log: Logger;\n readonly clock: Clock;\n}): TonContext {\n const codec = createTonAddressCodec({\n testnet: args.config.testnet,\n fromPublicKey: (publicKey: Uint8Array, wallet?: WalletOptions) =>\n walletAddress(resolveIdentity(wallet, args.config.globalId), publicKey),\n });\n return {\n ...args,\n codec,\n jettonWallets: new Map(),\n verified: new Map(),\n chainTxs: new Map(),\n assembled: new Map(),\n };\n}\n\nconst assetError = (reason: string) => new ValidationError('ASSET_RESOLUTION', reason);\n\nconst notYet = (reason: string) =>\n new ProviderError('PROVIDER_UNAVAILABLE', reason, { retryable: true });\n\n/**\n * Metadata the indexer does not have, for a token read anywhere (`jettonMetadata`):\n * non-retryable, so the core reports a transfer of it unresolved instead of failing the\n * read, and not `ASSET_RESOLUTION`, so the core never caches it.\n */\nconst unresolvable = (reason: string) =>\n new ProviderError('PROVIDER_UNAVAILABLE', reason, { retryable: false });\n\n/**\n * The core caches a token's metadata,\n * and its \"no such token\", for the container's life, so one lagging or buggy endpoint must\n * never decide it. Balances stay plain reads.\n */\nconst METADATA: TonCallTags = { ...READ, quorum: 'proof' };\n\n/**\n * A token's own failure (a missing account, a TVM exit code, content that does\n * not parse) is `ASSET_RESOLUTION`; `PROVIDER_MISCONFIGURED` and already retryable errors\n * propagate unchanged; any other definitive node answer is made retryable.\n */\nfunction asRetryable(error: unknown): unknown {\n if (\n isCryptoAioError(error) &&\n error.category === 'provider' &&\n !error.retryable &&\n error.code !== 'PROVIDER_MISCONFIGURED'\n ) {\n return withContext(error, {}, { retryable: true });\n }\n return error;\n}\n\nasync function tokenCall<T>(work: () => Promise<T>): Promise<T> {\n try {\n return await work();\n } catch (error) {\n throw asRetryable(error);\n }\n}\n\nconst cellStack = (entry: RunResult['stack'][number] | undefined): string | undefined =>\n entry?.type === 'cell' ? entry.boc : undefined;\n\n/** A lookup id (a 32-byte hash in hex, either case) in lower case; undefined otherwise. */\nconst hashId = (id: string): string | undefined =>\n typeof id === 'string' && /^[0-9a-fA-F]{64}$/.test(id) ? id.toLowerCase() : undefined;\n\n/** The wallet address a `get_wallet_address` answer names; null when it names none. */\nfunction namedWallet(result: RunResult): string | null {\n const boc = result.exitCode === 0 ? cellStack(result.stack[0]) : undefined;\n return boc ? addressFromBoc(boc) : null;\n}\n\n/**\n * What endpoints must agree on for `get_wallet_address`: the exit code and the\n * address it names, never the slice's serialization. It never throws: an answer that does\n * not parse is itself a fact, which the parse then refuses (retryable).\n */\nfunction walletAddressKey(body: unknown): unknown {\n try {\n const result = runResultOf(body);\n return { exitCode: result.exitCode, wallet: namedWallet(result) };\n } catch {\n return 'malformed';\n }\n}\n\n/**\n * The jetton wallet `master` assigns to `owner` (`get_wallet_address`), at masterchain\n * block `block` when given. Cached only when the proof quorum attested it: the builder\n * sends jettons to it and the verdict checks it, so one endpoint's answer must never stick.\n * Under a quorum the endpoints agree on the address itself (`walletAddressKey`).\n */\nexport async function jettonWalletAddress(\n ctx: TonContext,\n master: string,\n owner: string,\n tags: TonCallTags,\n block?: number,\n): Promise<string> {\n const key = `${master}|${owner}`;\n const cached = ctx.jettonWallets.get(key);\n if (cached) return cached;\n const keyed =\n tags.quorum !== undefined && tags.quorumKey === undefined\n ? { ...tags, quorumKey: walletAddressKey }\n : tags;\n const result = await tokenCall(() =>\n ctx.api.runGetMethod(\n master,\n 'get_wallet_address',\n [['tvm.Slice', addressArgument(owner)]],\n keyed,\n block,\n ),\n );\n const address = namedWallet(result);\n if (!address) throw assetError('the jetton master gives no wallet address');\n if (tags.quorum !== undefined) ctx.jettonWallets.set(key, address);\n return address;\n}\n\n/**\n * `owner`'s jetton balance; 0 while its jetton wallet is not deployed. The state and the\n * balance are read at one block, so a load-balanced endpoint never mixes two views.\n */\nexport async function jettonBalance(\n ctx: TonContext,\n master: string,\n owner: string,\n tags: TonCallTags,\n): Promise<bigint> {\n const wallet = await jettonWalletAddress(ctx, master, owner, tags);\n const state = await tokenCall(() => ctx.api.account(wallet, tags));\n if (state.status === 'uninitialized') return 0n;\n const data = await tokenCall(() =>\n ctx.api.runGetMethod(wallet, 'get_wallet_data', [], tags, state.blockSeqno),\n );\n const first = data.stack[0];\n if (data.exitCode === 0 && first?.type === 'num' && first.value >= 0n) {\n return first.value;\n }\n throw assetError('the jetton wallet gives no balance');\n}\n\n/**\n * What the get-methods at masterchain block `block` say about a jetton wallet:\n * - `verified`: it names an owner and a master, and that master names it for that owner;\n * - `foreign`: it names an owner and a master that parse, and that master names another\n * wallet for that owner: positive evidence that it is not the master's;\n * - `unknown`: no evidence either way. `get_wallet_data` exited with `exitCode` (toncenter\n * answers -13 for an account it holds no state for at that block), or named no owner\n * or master that parses, or the master named no wallet.\n * Both get-methods run at `block`, one at which the wallet had already run a transaction\n * (a fact at its own height): an endpoint that lags behind it refuses\n * (retryable), where a read at its own head would take a wallet it has not seen yet for a\n * fake. Cached once verified under the quorum.\n */\nexport type JettonWalletFacts =\n | { readonly kind: 'verified'; readonly wallet: VerifiedJettonWallet }\n | { readonly kind: 'foreign' }\n | { readonly kind: 'unknown'; readonly exitCode?: number };\n\n/** toncenter's exit code for an account it holds no state for at the block asked. */\nexport const NO_STATE_EXIT = -13;\n\nexport async function jettonWalletFacts(\n ctx: TonContext,\n address: string,\n tags: TonCallTags,\n block: number,\n): Promise<JettonWalletFacts> {\n const known = ctx.verified.get(address);\n if (known) return { kind: 'verified', wallet: known };\n const data = await tokenCall(() =>\n ctx.api.runGetMethod(address, 'get_wallet_data', [], tags, block),\n );\n if (data.exitCode !== 0) return { kind: 'unknown', exitCode: data.exitCode };\n const ownerBoc = cellStack(data.stack[1]);\n const masterBoc = cellStack(data.stack[2]);\n const owner = ownerBoc ? addressFromBoc(ownerBoc) : null;\n const master = masterBoc ? addressFromBoc(masterBoc) : null;\n if (!owner || !master) return { kind: 'unknown' };\n let named: string;\n try {\n named = await jettonWalletAddress(ctx, master, owner, tags, block);\n } catch (error) {\n if (isCryptoAioError(error, 'ASSET_RESOLUTION')) return { kind: 'unknown' };\n throw error;\n }\n if (named !== address) return { kind: 'foreign' };\n const verified = { address, owner, master };\n if (tags.quorum !== undefined) ctx.verified.set(address, verified);\n return { kind: 'verified', wallet: verified };\n}\n\n/**\n * The lenient reading for history: a wallet the master names, else `undefined` (any\n * other contract; the transaction is then `partial`), so a fake contract never stalls a\n * page. One exception: \"no state at this block\" (exit -13) for the jetton\n * wallet whose own transaction this is (`ranHere`) contradicts the chain, which shows it\n * running there, so it is unavailable data (retryable), never a silent drop of a deposit.\n */\nexport async function verifyJettonWallet(\n ctx: TonContext,\n address: string,\n tags: TonCallTags,\n block: number,\n ranHere = false,\n memo?: PageMemo,\n): Promise<VerifiedJettonWallet | undefined> {\n const facts = await remembered(memo?.jettonWallets, address, () =>\n jettonWalletFacts(ctx, address, tags, block),\n );\n if (facts.kind === 'verified') return facts.wallet;\n if (ranHere && facts.kind === 'unknown' && facts.exitCode === NO_STATE_EXIT) {\n throw notYet('the jetton wallet state is not available at its block');\n }\n return undefined;\n}\n\n// ---- jetton metadata (TEP-64) -------------------------------------------------------------\n\n/**\n * The most cells one on-chain content value is read to (at most 127 bytes each,\n * about 8 KB), snake or chunked alike; past them it is unreadable. A symbol or name takes a\n * few cells: the bound keeps an author's long texts readable while bounding the work on\n * content anyone can deploy.\n */\nconst MAX_VALUE_CELLS = 64;\n/** The longest symbol and name kept: the indexer's limits (`api.ts`). */\nconst MAX_SYMBOL_LENGTH = 256;\nconst MAX_NAME_LENGTH = 256;\n\ntype Slice = ReturnType<Cell['beginParse']>;\n\n/**\n * TEP-64 snake data, read in one pass (`@ton/core`'s `loadStringTail` recurses\n * per cell and concatenates at each level, quadratic in the chain); undefined for a cell that\n * is not whole bytes with at most one ref, or a chain past `MAX_VALUE_CELLS`.\n */\nfunction snakeBytes(first: Slice): Buffer | undefined {\n let slice = first;\n const chunks: Buffer[] = [];\n for (let cells = 1; ; cells += 1) {\n const bits = slice.remainingBits;\n if (cells > MAX_VALUE_CELLS || bits % 8 !== 0 || slice.remainingRefs > 1) {\n return undefined;\n }\n if (bits > 0) chunks.push(slice.loadBuffer(bits / 8));\n if (slice.remainingRefs === 0) return Buffer.concat(chunks);\n slice = slice.loadRef().beginParse();\n }\n}\n\n/**\n * TEP-64 chunked data (`chunks#01 data:ChunkedData`, `chunked_data#_ data:(HashmapE 32\n * ^(SnakeData ~0))`): its chunks in index order, from 0 without a gap, each one cell of\n * whole bytes and no refs; at most `MAX_VALUE_CELLS` of them. Undefined otherwise.\n */\nfunction chunkedBytes(slice: Slice): Buffer | undefined {\n const dict = slice.loadDict(Dictionary.Keys.Uint(32), Dictionary.Values.Cell());\n if (dict.size > MAX_VALUE_CELLS) return undefined;\n const chunks: Buffer[] = [];\n for (let index = 0; index < dict.size; index += 1) {\n const chunk = dict.get(index)?.beginParse();\n if (!chunk || chunk.remainingRefs !== 0 || chunk.remainingBits % 8 !== 0) {\n return undefined;\n }\n chunks.push(chunk.loadBuffer(chunk.remainingBits / 8));\n }\n return Buffer.concat(chunks);\n}\n\n/**\n * A TEP-64 `ContentData` value as text: snake data (prefix 0x00, which some masters omit) or\n * chunked data (prefix 0x01), both bounded by `MAX_VALUE_CELLS`. Undefined when it does not\n * read.\n */\nfunction contentText(value: Cell): string | undefined {\n try {\n const slice = value.beginParse();\n const prefix = slice.remainingBits >= 8 ? slice.preloadUint(8) : undefined;\n if (prefix === 0 || prefix === 1) slice.skip(8);\n const bytes = prefix === 1 ? chunkedBytes(slice) : snakeBytes(slice);\n return bytes?.toString('utf8');\n } catch {\n return undefined;\n }\n}\n\n/** The on-chain content fields read (null: present but unreadable). */\ninterface OnchainFields {\n readonly decimals?: string | null;\n readonly symbol?: string | null;\n readonly name?: string | null;\n}\n\ninterface JettonContent {\n readonly fields: OnchainFields;\n /**\n * Whether an off-chain JSON holds the fields the chain does not (TEP-64: off-chain\n * content, or on-chain content with a `uri`); only the indexer has read it.\n */\n readonly linked: boolean;\n}\n\nconst contentKey = (name: string): Buffer => createHash('sha256').update(name).digest();\n\n/**\n * TEP-64: a parsed content cell's layout and fields. A layout or dictionary that does not\n * read is the token's own content (`ASSET_RESOLUTION`).\n */\nfunction contentOf(cell: Cell): JettonContent {\n try {\n const slice = cell.beginParse();\n const prefix = slice.loadUint(8);\n if (prefix === 1) return { fields: {}, linked: true };\n if (prefix !== 0) throw new Error('layout');\n const dict = slice.loadDict(Dictionary.Keys.Buffer(32), Dictionary.Values.Cell());\n const fields: {\n decimals?: string | null;\n symbol?: string | null;\n name?: string | null;\n } = {};\n for (const key of ['decimals', 'symbol', 'name'] as const) {\n const value = dict.get(contentKey(key));\n if (value) fields[key] = contentText(value) ?? null;\n }\n return { fields, linked: dict.has(contentKey('uri')) };\n } catch {\n throw assetError('the jetton content is unreadable');\n }\n}\n\n/** A content BOC as a cell; undefined when it does not parse as one root. */\nfunction contentCell(boc: string): Cell | undefined {\n try {\n const cells = Cell.fromBoc(Buffer.from(boc, 'base64'));\n return cells.length === 1 ? cells[0] : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Content cells parsed once per metadata read: a state-sized content takes about 2 s to\n * decode (`MAX_STATE_BOC_LENGTH`), and the quorum's endpoints usually serve the same text.\n */\nfunction contentCells(): (boc: string) => Cell | undefined {\n const parsed = new Map<string, Cell | undefined>();\n return (boc) => {\n if (!parsed.has(boc)) parsed.set(boc, contentCell(boc));\n return parsed.get(boc);\n };\n}\n\n/**\n * The facts endpoints must agree on for jetton metadata: the exit code and the content\n * cell's hash, never the rest of the answer (a total supply that moves between two reads)\n * nor the cell's serialization. It never throws: an answer that does not parse\n * is itself a fact, which the parse then refuses (retryable).\n */\nfunction jettonDataKey(cellOf: (boc: string) => Cell | undefined) {\n return (body: unknown): unknown => {\n try {\n const { exitCode, content } = jettonDataOf(body);\n if (!content) return { exitCode };\n if (content.kind === 'oversized') return { exitCode, content: 'oversized' };\n const cell = cellOf(content.boc);\n return { exitCode, content: cell ? cell.hash().toString('hex') : 'unparseable' };\n } catch {\n return 'malformed';\n }\n };\n}\n\n/**\n * A jetton's metadata, under the proof quorum. The master's content decides what it can:\n * - no master, or content beyond an account state's limits (every quorum endpoint agreed\n * on it), or a layout or value that does not read: `ASSET_RESOLUTION`;\n * - a content BOC that does not parse: the endpoint's fault, retryable;\n * - content wholly on chain: its own symbol, and its decimals or TEP-64's default of 9;\n * - otherwise the off-chain JSON fills in what the chain does not state, as the indexer\n * fetched it, and only those fields are judged: one the indexer holds but is not one\n * (agreed by the quorum) is the token's own `ASSET_RESOLUTION`. Metadata the indexer\n * does not have (no usable entry: never indexed, not valid, an unfetchable JSON; or a\n * JSON that states no decimals) is never a default: an index that lags or drops its\n * filter would otherwise cache 9 decimals for the container's life, and a 6-decimal\n * token would be mis-scaled 1,000× (fund safety over liveness).\n *\n * That absence is `unresolvable`, a non-retryable `PROVIDER_UNAVAILABLE`. Anyone can send\n * a junk jetton to a deposit address, and a retryable answer would fail every history\n * page and `getTransaction` that holds it, forever. Non-retryable, the core reports the\n * transfer with its raw base-unit amount and the asset unresolved and reads the rest of\n * the page. Its code is not `ASSET_RESOLUTION`, the one failure the core caches for the\n * container's life, so it is never cached: once the indexer has the metadata, the next\n * read resolves the token. A transfer of such a token fails the same way, before anything\n * is signed.\n * Known gap: that refusal is not retryable, even for a jetton the indexer has simply not\n * indexed yet; it records nothing, so the same call succeeds later. A retryable refusal\n * needs the core to report a transfer unresolved on a retryable failure too, or the\n * history stall comes back. A jetton whose metadata states no decimals stays unresolved:\n * the only way to use it is to register its decimals in a plugin's `assets`.\n */\nasync function jettonMetadata(ctx: TonContext, master: string): Promise<AssetMetadata> {\n const cellOf = contentCells();\n const data = await tokenCall(() =>\n ctx.api.jettonData(master, { ...METADATA, quorumKey: jettonDataKey(cellOf) }),\n );\n if (data.exitCode !== 0 || !data.content) {\n throw assetError('no jetton master at this address');\n }\n if (data.content.kind === 'oversized')\n throw assetError('the jetton content is unreadable');\n const cell = cellOf(data.content.boc);\n if (!cell) throw notYet('malformed jetton content answer');\n const { fields, linked } = contentOf(cell);\n if (fields.decimals === null) throw assetError('the jetton decimals are unreadable');\n if (fields.symbol === null) throw assetError('the jetton symbol is unreadable');\n let decimals: string | null | undefined = fields.decimals;\n let symbol: string | null | undefined = fields.symbol;\n let name = fields.name ?? undefined;\n if (!linked) {\n decimals ??= '9';\n } else if (decimals === undefined || symbol === undefined) {\n const info = await tokenCall(() => ctx.api.tokenInfo(master, METADATA));\n if (!info) throw unresolvable('the jetton metadata is not indexed');\n if (decimals === undefined) decimals = info.decimals;\n if (symbol === undefined) symbol = info.symbol;\n name ??= info.name;\n if (decimals === null) throw assetError('the jetton decimals are unreadable');\n if (symbol === null) throw assetError('the jetton symbol is unreadable');\n if (decimals === undefined)\n throw unresolvable('the jetton metadata states no decimals');\n }\n if (!/^\\d{1,3}$/.test(decimals) || Number(decimals) > 255) {\n throw assetError('the jetton decimals are unreadable');\n }\n if (!symbol) throw assetError('the jetton has no symbol');\n if (symbol.length > MAX_SYMBOL_LENGTH)\n throw assetError('the jetton symbol is unreadable');\n return {\n symbol,\n decimals: Number(decimals),\n ...(name && name.length <= MAX_NAME_LENGTH ? { name } : {}),\n };\n}\n\n/** The canonical master address of a jetton asset ref; `ASSET_RESOLUTION` otherwise. */\nexport function jettonMaster(ctx: TonContext, asset: AssetRef): string {\n if (asset === 'native' || asset.standard !== 'jetton') {\n throw assetError(`TON tokens use the 'jetton' standard`);\n }\n try {\n return ctx.codec.normalize(asset.contract).canonical;\n } catch {\n throw assetError('not a TON jetton master address');\n }\n}\n\nexport function toDriverBlock(header: BlockHeader): DriverBlock {\n return {\n height: BigInt(header.id.seqno),\n hash: header.id.rootHash,\n parentHash: header.prev[0]?.rootHash ?? '',\n timestamp: header.genUtime,\n };\n}\n\n// ---- transactions and Attempts -------------------------------------------------------------\n\n/**\n * The transaction a lookup id names (anyone's): by message hash, then by its own hash. An\n * external message can run more than once while it does not consume its seqno; the run\n * that consumed it is the one that took effect, so it is preferred.\n */\nasync function findTransaction(\n ctx: TonContext,\n id: string,\n tags: TonCallTags,\n): Promise<V3Transaction | null> {\n const hash = hashId(id);\n if (!hash) return null;\n const byMessage = await ctx.api.transactionsByMessage(hash, tags);\n const runs = byMessage.filter((tx) => tx.inMsg?.source === null);\n const found = runs.find(consumesSeqno) ?? runs[0] ?? byMessage[0];\n return found ?? ctx.api.transaction(hash, tags);\n}\n\n/**\n * Our own Attempt's wallet transaction, bound by account and a locally computed hash\n * (`isOwnAttempt`, never a first-result fallback). A run that did not consume its\n * seqno (a failed action phase, or a compute phase that failed before `commit()`) leaves the\n * same message valid, so it may run again; the run that consumed the seqno is preferred,\n * since only it decides.\n */\nexport async function findOwnAttempt(\n ctx: TonContext,\n ref: AttemptRef,\n from: string,\n tags: TonCallTags,\n): Promise<V3Transaction | undefined> {\n const hash = hashId(ref.id);\n if (!hash) return undefined;\n const own = (await ctx.api.transactionsByMessage(hash, tags)).filter((tx) =>\n isOwnAttempt(tx, from, hash),\n );\n return own.find(consumesSeqno) ?? own[0];\n}\n\n/**\n * Each jetton leg's wallets must be the master's own for the sender and the intended\n * recipient (the same master), as masterchain block `block` (the trace's last) records\n * them: a fake jetton wallet can \"accept\" a transfer that moves nothing. The verdict\n * unchanged when they are.\n *\n * Only positive evidence decides `failed`, never a missing\n * answer. The sender's jetton wallet is the one the proof quorum attested at build and the\n * trace shows both wallets running, so a leg that cannot be verified (no answer, exit -13\n * \"no state at this block\", nothing that parses), or a sender wallet that is not ours,\n * contradicts the chain: a retryable `PROVIDER_INCONSISTENT` (logged `JETTON_UNVERIFIED`),\n * never a terminal failure that a new key would pay again. `failed` only when the recipient\n * wallet answered, and it is not the master's for the intended recipient (another wallet\n * named, another owner, another master): the jettons went elsewhere.\n */\nexport async function confirmLegs(\n ctx: TonContext,\n verdict: Verdict,\n from: string,\n tags: TonCallTags,\n block: number,\n): Promise<Verdict> {\n if (verdict.kind !== 'success') return verdict;\n for (const leg of verdict.legs) {\n const sender = await jettonWalletFacts(ctx, leg.senderWallet, tags, block);\n const recipient = await jettonWalletFacts(ctx, leg.recipientWallet, tags, block);\n if (\n sender.kind !== 'verified' ||\n sender.wallet.owner !== from ||\n recipient.kind === 'unknown'\n ) {\n ctx.log.warn('a jetton wallet of the transfer could not be verified', {\n code: 'JETTON_UNVERIFIED',\n });\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the jetton wallets of the transfer could not be verified at its block',\n { retryable: true },\n );\n }\n if (\n recipient.kind === 'foreign' ||\n recipient.wallet.owner !== leg.recipient ||\n recipient.wallet.master !== sender.wallet.master\n ) {\n return Object.freeze({ kind: 'failed', reason: REASONS.jettonUnverified });\n }\n }\n return verdict;\n}\n\n/** The newest masterchain block of a trace: every leg's wallet has run by then. */\nexport function traceBlock(root: V3Transaction, trace: V3Trace | null): number {\n return Math.max(root.mcSeqno, ...(trace?.transactions ?? []).map((tx) => tx.mcSeqno));\n}\n\n/**\n * What one history page reads once and uses for every transaction on it:\n * each masterchain block's header, and each jetton wallet's facts, read at the block of the\n * first (newest) transaction that needs them. The same answer reused, so it trusts nothing\n * more; a page reads from then on only what it has not read.\n */\nexport interface PageMemo {\n readonly headers: Map<number, Promise<BlockHeader>>;\n readonly jettonWallets: Map<string, Promise<JettonWalletFacts>>;\n}\n\nexport const pageMemo = (): PageMemo => ({\n headers: new Map(),\n jettonWallets: new Map(),\n});\n\n/** `read()` once per key in `memo` (none: read every time). */\nfunction remembered<K, V>(\n memo: Map<K, Promise<V>> | undefined,\n key: K,\n read: () => Promise<V>,\n): Promise<V> {\n if (!memo) return read();\n let pending = memo.get(key);\n if (!pending) {\n pending = read();\n memo.set(key, pending);\n }\n return pending;\n}\n\n/**\n * A transaction decoded with its jetton wallet verified at the transaction's own block\n * and its block's hash; `memo` shares both reads across one history page.\n */\nexport async function decodeWithJettons(\n ctx: TonContext,\n tx: V3Transaction,\n tags: TonCallTags,\n memo?: PageMemo,\n) {\n const candidate = jettonWalletToVerify(tx);\n // The arrival's own jetton wallet ran here; a notification's sender ran earlier.\n const jetton = candidate\n ? await verifyJettonWallet(\n ctx,\n candidate,\n tags,\n tx.mcSeqno,\n candidate === tx.account,\n memo,\n )\n : undefined;\n const header = await remembered(memo?.headers, tx.mcSeqno, () =>\n ctx.api.masterchainHeader(tx.mcSeqno, tags),\n );\n return decodeTransaction(tx, {\n blockHash: header.id.rootHash,\n ...(jetton ? { jetton } : {}),\n });\n}\n\n/** The highest masterchain seqno (a uint32). */\nconst MAX_BLOCK_SEQNO = 0xffff_ffffn;\n\nexport function createTonReader(ctx: TonContext): ChainReader {\n const { api } = ctx;\n return {\n getBalance: async (address, asset) => {\n const owner = ctx.codec.normalize(address).canonical;\n if (asset === 'native') return (await api.account(owner, READ)).balance;\n return jettonBalance(ctx, jettonMaster(ctx, asset), owner, READ);\n },\n getBlockHeight: async () => BigInt(await api.masterchainHead(MONITOR)),\n // Every masterchain block is final once it exists.\n getFinalizedHeight: async () => BigInt(await api.masterchainHead(MONITOR)),\n getBlock: async (ref) => {\n let seqno: number | null;\n let hash: string | undefined;\n if (typeof ref === 'bigint') {\n if (ref < 0n || ref > MAX_BLOCK_SEQNO) return null;\n seqno = Number(ref);\n } else {\n hash = hashId(ref);\n if (!hash) return null;\n seqno = await api.masterchainSeqnoOf(hash, READ);\n }\n if (seqno === null || seqno > (await api.masterchainHead(READ))) return null;\n const header = await api.masterchainHeader(seqno, READ);\n if (hash !== undefined && header.id.rootHash !== hash) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the indexer and the liteserver name different blocks',\n { retryable: true },\n );\n }\n return toDriverBlock(header);\n },\n getTransaction: async (id) => {\n const tx = await findTransaction(ctx, id, READ);\n return tx ? decodeWithJettons(ctx, tx, READ) : null;\n },\n observe: async (ref, ordering, from): Promise<DriverTxObservation> => {\n const managed = ordering !== undefined && from !== undefined;\n const wallet = managed ? ctx.codec.normalize(from).canonical : undefined;\n // A managed Attempt is only ever our own wallet transaction (`isOwnAttempt`, before\n // any verdict), never a fallback.\n const tx =\n wallet !== undefined\n ? await findOwnAttempt(ctx, ref, wallet, MONITOR)\n : await findTransaction(ctx, ref.id, MONITOR);\n if (!tx) return { seen: 'none' };\n const header = await api.masterchainHeader(tx.mcSeqno, MONITOR);\n const seen = {\n seen: 'block' as const,\n txHash: tx.hash,\n blockHeight: BigInt(tx.mcSeqno),\n blockHash: header.id.rootHash,\n };\n // Anyone's transaction: its execution status as the chain reports it.\n if (wallet === undefined) return { ...seen, success: executed(tx) };\n // Our own Attempt: the verdict path.\n const trace = await api.trace(tx.hash, MONITOR);\n const verdict = await confirmLegs(\n ctx,\n attemptVerdict(tx, trace),\n wallet,\n MONITOR,\n traceBlock(tx, trace),\n );\n if (verdict.kind === 'pending') return seen;\n return verdict.kind === 'success'\n ? { ...seen, success: true }\n : { ...seen, success: false, reason: verdict.reason };\n },\n getTokenMetadata: async (ref: TokenRef) =>\n jettonMetadata(ctx, jettonMaster(ctx, ref)),\n normalizeTokenRef: (ref) => ({\n standard: 'jetton',\n contract: jettonMaster(ctx, ref),\n }),\n };\n}\n\n// ---- seqnos --------------------------------------------------------------------------------\n\n/** A live seqno read and the account state it was read at. */\ninterface LiveSeqno {\n readonly seqno: bigint;\n readonly state: AccountState;\n /** Whether the wallet is deployed at that block (it then has a public key there). */\n readonly deployed: boolean;\n}\n\n/**\n * A get-method's answer is the one run where it was asked: at `block` (the full id\n * when the caller has it, else the masterchain seqno), and on `state` when given, the\n * account's last transaction there. An endpoint that drops the block answers at its own\n * latest state, which decides nothing (a retryable `PROVIDER_INCONSISTENT`).\n */\nfunction assertRunAt(\n result: BoundRunResult,\n block: BlockId | number,\n state?: Pick<AccountState, 'lastLt' | 'lastHash'>,\n): void {\n const atBlock =\n typeof block === 'number'\n ? result.block.workchain === -1 &&\n result.block.shard === MASTERCHAIN_SHARD &&\n result.block.seqno === block\n : sameBlock(result.block, block);\n if (\n !atBlock ||\n (state !== undefined &&\n (result.lastTransaction.lt !== state.lastLt ||\n result.lastTransaction.hash !== state.lastHash))\n ) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'a get-method was answered at another state than the one asked',\n { retryable: true },\n );\n }\n}\n\nconst MAX_WALLET_SEQNO = 0xffff_ffffn;\n\n/** The wallet's seqno at the latest state: 0 while undeployed (its first message deploys it). */\nexport async function walletSeqno(\n ctx: TonContext,\n address: string,\n tags: TonCallTags,\n): Promise<bigint> {\n return (await liveSeqno(ctx, address, tags)).seqno;\n}\n\n/**\n * The seqno at the block the account state was read at, so both come from one view. A\n * frozen account is refused from its state alone, before any get-method: its deploy\n * `StateInit` would not revive it, and a message signed for it can never run.\n */\nasync function liveSeqno(\n ctx: TonContext,\n address: string,\n tags: TonCallTags,\n): Promise<LiveSeqno> {\n const state = await ctx.api.account(address, tags);\n if (state.status === 'uninitialized') {\n return { seqno: 0n, state, deployed: false };\n }\n if (state.status === 'frozen') {\n throw new ChainError('TX_REFUSED', 'the wallet account is frozen');\n }\n const result = await ctx.api.runGetMethodAt(\n address,\n 'seqno',\n [],\n tags,\n state.blockSeqno,\n );\n assertRunAt(result, state.block, state);\n const first = result.stack[0];\n if (\n result.exitCode !== 0 ||\n first?.type !== 'num' ||\n first.value < 0n ||\n first.value > MAX_WALLET_SEQNO\n ) {\n throw new ValidationError(\n 'INVALID_INTENT',\n 'the account is not a v4r2 or v5r1 wallet',\n );\n }\n return { seqno: first.value, state, deployed: true };\n}\n\n/**\n * The wallet's public key at masterchain block `block` (`get_public_key`), read once and\n * only when needed; undefined when the account has none there. The answer is bound to the\n * block asked and, when given, to the account state read there.\n */\nexport function publicKeyAt(\n ctx: TonContext,\n address: string,\n tags: TonCallTags,\n block: BlockId | number,\n state?: Pick<AccountState, 'lastLt' | 'lastHash'>,\n): () => Promise<Uint8Array | undefined> {\n let key: Promise<Uint8Array | undefined> | undefined;\n const seqno = typeof block === 'number' ? block : block.seqno;\n const read = async (): Promise<Uint8Array | undefined> => {\n const result = await ctx.api.runGetMethodAt(\n address,\n 'get_public_key',\n [],\n tags,\n seqno,\n );\n assertRunAt(result, block, state);\n const first = result.stack[0];\n if (result.exitCode !== 0 || first?.type !== 'num') return undefined;\n if (first.value < 0n || first.value >= 1n << 256n) return undefined;\n return Buffer.from(first.value.toString(16).padStart(64, '0'), 'hex');\n };\n return () => (key ??= read());\n}\n\n/**\n * The wallet request `tx` proves `from` consumed its seqno,\n * else null. Every request must be the wallet's own, signed by its key (`requestIsOwn`): a\n * lone lying indexer can make up an external one, and anyone can post a relayed W5 body for\n * a small fee (a v5r1 wallet ignores a forged one). And it must have consumed the seqno: an\n * external request only when `consumesSeqno` holds (its action phase succeeded, or W5\n * committed and then threw 137), a relayed one only when the wallet ran it to the end\n * (`ran`: with no `commit()` there, a failed action phase rolls the seqno back). A foreign\n * request signed with the same key whose action phase failed consumed nothing. `publicKey`\n * gives the wallet's key for `tx`; it is read only for a request that passed the rest.\n */\nexport async function provenRequest(\n ctx: TonContext,\n tx: V3Transaction,\n from: string,\n publicKey: (tx: V3Transaction) => Promise<Uint8Array | undefined>,\n): Promise<WalletRequest | null> {\n const inMsg = tx.inMsg;\n if (!inMsg || tx.account !== from) return null;\n const body = messageBody(inMsg);\n const request = body ? decodeWalletRequest(body) : null;\n if (!body || !request) return null;\n if (inMsg.source === null) {\n if (request.auth !== 'external' || !consumesSeqno(tx)) return null;\n } else if (request.auth !== 'internal' || !ran(tx)) {\n return null;\n }\n const key = await publicKey(tx);\n return key && requestIsOwn(from, body, key, ctx.config.globalId) ? request : null;\n}\n\n/** The history page the seqno floor reads, and how many pages before it gives up. */\nconst FLOOR_PAGE = 64;\nconst FLOOR_PAGES = 4;\n\n/**\n * The seqno after the newest wallet request the indexer has. Once the previous transfer\n * is `included`, the core hands out the next seqno; a lagging liteserver read could still\n * show the consumed one, and a message signed for it could only end `replaced`. Only a\n * proven request counts, and only one newer than the live read: the live read\n * already covers the rest. The history is paged on the indexer's own pages (a page\n * whose newest transactions are not final yet still leads to the older ones) until it\n * reaches the live read's block; more than `FLOOR_PAGES` pages since then decides nothing\n * (retryable) rather than guess, and so does a request dated after its own lifetime.\n */\nasync function indexedSeqnoFloor(\n ctx: TonContext,\n address: string,\n live: LiveSeqno,\n tags: TonCallTags,\n): Promise<bigint> {\n const liveKey = live.deployed\n ? publicKeyAt(ctx, address, tags, live.state.block, live.state)\n : async () => undefined;\n // An undeployed wallet at the live read has no key there: read it at the evidence's own\n // block, which a lagging endpoint refuses (retryable), so nothing is guessed meanwhile.\n const key = async (tx: V3Transaction) =>\n (await liveKey()) ?? publicKeyAt(ctx, address, tags, tx.mcSeqno)();\n let endLt: bigint | undefined;\n for (let page = 0; page < FLOOR_PAGES; page += 1) {\n const { transactions, next } = await ctx.api.accountTransactionsPage(\n address,\n { limit: FLOOR_PAGE, ...(endLt !== undefined ? { endLt } : {}) },\n tags,\n );\n for (const tx of transactions) {\n if (tx.mcSeqno <= live.state.blockSeqno) return 0n; // newest first: the rest is older still\n const request = await provenRequest(ctx, tx, address, key);\n if (!request) continue;\n // A request that ran after its own lifetime is a record the chain\n // cannot produce (the wallet refuses it), so it decides nothing, as in the proofs.\n if (request.validUntil <= tx.now) {\n throw new ProviderError(\n 'PROVIDER_INCONSISTENT',\n 'the seqno consumer ran after its request expired',\n { retryable: true },\n );\n }\n return BigInt(request.seqno) + 1n;\n }\n if (next === undefined) return 0n;\n endLt = next;\n }\n throw notYet('the wallet history since the live seqno read is too long to check');\n}\n\nexport function createTonSequence(ctx: TonContext): SequenceSource {\n return {\n pending: async (address) => {\n const wallet = ctx.codec.normalize(address).canonical;\n const live = await liveSeqno(ctx, wallet, MONITOR);\n const floor = await indexedSeqnoFloor(ctx, wallet, live, MONITOR);\n return live.seqno > floor ? live.seqno : floor;\n },\n latest: async (address) =>\n walletSeqno(ctx, ctx.codec.normalize(address).canonical, MONITOR),\n };\n}\n\nexport function createTonExt(ctx: TonContext): TonExt {\n return {\n ton: {\n getSeqno: async (address) =>\n walletSeqno(ctx, ctx.codec.normalize(address).canonical, READ),\n // A caller sends jettons to it, so the proof quorum attests it, and the attested\n // answer is kept.\n jettonWallet: async (owner, master) =>\n jettonWalletAddress(\n ctx,\n jettonMaster(ctx, { standard: 'jetton', contract: master }),\n ctx.codec.normalize(owner).canonical,\n PROOF,\n ),\n },\n };\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Well-known TON assets. USDT is Tether's jetton on TON mainnet (master and
3
+ * 6 decimals verified against docs.ton.org and the master's on-chain content). The native
4
+ * coin keeps the alias `TON` beside its ticker `GRAM` (formerly Toncoin).
5
+ * USDT's `name` ('Tether USD') is the master's on-chain jetton metadata name, not verified
6
+ * live.
7
+ * Jetton asset ids use the master's raw address: `ton:mainnet/jetton:0:<hex>`.
8
+ */
9
+ import type { AssetRegistration } from '../../core/registry/assets';
10
+ export declare const TON_TOKENS: readonly AssetRegistration[];
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TON_TOKENS = void 0;
4
+ const freeze_1 = require("../../core/util/freeze");
5
+ const chains_1 = require("./chains");
6
+ /** The alias `TON` on each network's native coin, with the chain's own metadata. */
7
+ const NATIVE_ALIASES = chains_1.TON_CHAINS.flatMap((chain) => Object.keys(chain.networks).map((network) => ({
8
+ chain: chain.id,
9
+ network,
10
+ ref: 'native',
11
+ metadata: chain.nativeAsset,
12
+ aliases: ['TON'],
13
+ })));
14
+ exports.TON_TOKENS = (0, freeze_1.deepFreeze)([
15
+ ...NATIVE_ALIASES,
16
+ {
17
+ chain: 'ton',
18
+ network: 'mainnet',
19
+ ref: {
20
+ standard: 'jetton',
21
+ contract: '0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe',
22
+ },
23
+ metadata: { symbol: 'USDT', decimals: 6, name: 'Tether USD' },
24
+ aliases: ['USDT'],
25
+ },
26
+ ]);
27
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/adapters/ton/tokens.ts"],"names":[],"mappings":";;;AASA,mDAAoD;AACpD,qCAAsC;AAEtC,oFAAoF;AACpF,MAAM,cAAc,GAAiC,mBAAU,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAChF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC5C,KAAK,EAAE,KAAK,CAAC,EAAE;IACf,OAAO;IACP,GAAG,EAAE,QAAQ;IACb,QAAQ,EAAE,KAAK,CAAC,WAAW;IAC3B,OAAO,EAAE,CAAC,KAAK,CAAC;CACjB,CAAC,CAAC,CACJ,CAAC;AAEW,QAAA,UAAU,GAAiC,IAAA,mBAAU,EAAC;IACjE,GAAG,cAAc;IACjB;QACE,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,SAAS;QAClB,GAAG,EAAE;YACH,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,oEAAoE;SAC/E;QACD,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE;QAC7D,OAAO,EAAE,CAAC,MAAM,CAAC;KAClB;CACF,CAAC,CAAC","sourcesContent":["/**\n * Well-known TON assets. USDT is Tether's jetton on TON mainnet (master and\n * 6 decimals verified against docs.ton.org and the master's on-chain content). The native\n * coin keeps the alias `TON` beside its ticker `GRAM` (formerly Toncoin).\n * USDT's `name` ('Tether USD') is the master's on-chain jetton metadata name, not verified\n * live.\n * Jetton asset ids use the master's raw address: `ton:mainnet/jetton:0:<hex>`.\n */\nimport type { AssetRegistration } from '../../core/registry/assets';\nimport { deepFreeze } from '../../core/util/freeze';\nimport { TON_CHAINS } from './chains';\n\n/** The alias `TON` on each network's native coin, with the chain's own metadata. */\nconst NATIVE_ALIASES: readonly AssetRegistration[] = TON_CHAINS.flatMap((chain) =>\n Object.keys(chain.networks).map((network) => ({\n chain: chain.id,\n network,\n ref: 'native',\n metadata: chain.nativeAsset,\n aliases: ['TON'],\n })),\n);\n\nexport const TON_TOKENS: readonly AssetRegistration[] = deepFreeze([\n ...NATIVE_ALIASES,\n {\n chain: 'ton',\n network: 'mainnet',\n ref: {\n standard: 'jetton',\n contract: '0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe',\n },\n metadata: { symbol: 'USDT', decimals: 6, name: 'Tether USD' },\n aliases: ['USDT'],\n },\n]);\n"]}
@@ -0,0 +1,48 @@
1
+ import type { V3Trace, V3Transaction } from './api';
2
+ /** One jetton transfer: the jetton wallets whose owners must be `from` and `recipient`. */
3
+ export interface JettonLeg {
4
+ readonly senderWallet: string;
5
+ readonly recipientWallet: string;
6
+ readonly recipient: string;
7
+ }
8
+ export type Verdict = {
9
+ readonly kind: 'success';
10
+ readonly legs: readonly JettonLeg[];
11
+ } | {
12
+ readonly kind: 'failed';
13
+ readonly reason: string;
14
+ }
15
+ /**
16
+ * Not decidable yet: the trace is still being executed or indexed, or the request ran
17
+ * without consuming its seqno and may still run again until it expires.
18
+ */
19
+ | {
20
+ readonly kind: 'pending';
21
+ };
22
+ /** Fixed reasons: a stored reason never holds an address, an amount or node text. */
23
+ export declare const REASONS: Readonly<{
24
+ walletFailed: "the wallet transaction failed";
25
+ skipped: "the wallet skipped a message";
26
+ bounced: "transfer bounced";
27
+ jettonBounced: "jetton transfer bounced";
28
+ jettonUnverified: "the jetton wallets are not the master’s";
29
+ }>;
30
+ /**
31
+ * Whether the wallet transaction of an external request `tx` consumed the request's seqno,
32
+ * so that the same message can never run again: it ran (the new seqno stands with the
33
+ * actions, W5's 137 included), or, as a defensive reading of W5 alone, its compute phase is
34
+ * recorded failed with 137. Any other run left the old seqno (transaction.cpp: a
35
+ * failed action phase drops the compute phase's state, and a compute phase that failed
36
+ * before `commit()` never had one): a foreign request signed with the same key, or our
37
+ * own, whose action phase failed does not consume the seqno. Throws the retryable
38
+ * contradiction of `ran`.
39
+ */
40
+ export declare function consumesSeqno(tx: V3Transaction): boolean;
41
+ /**
42
+ * Whether `tx` is our Attempt: the external message to `from` whose TEP-467 hash,
43
+ * computed here from the bound body, is the Attempt id. The indexer's `hash_norm` only
44
+ * finds candidates; it never decides.
45
+ */
46
+ export declare function isOwnAttempt(tx: V3Transaction, from: string, refId: string): boolean;
47
+ /** The verdict on the Attempt whose wallet transaction is `root`, within `trace`. */
48
+ export declare function attemptVerdict(root: V3Transaction, trace: V3Trace | null): Verdict;
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REASONS = void 0;
4
+ exports.consumesSeqno = consumesSeqno;
5
+ exports.isOwnAttempt = isOwnAttempt;
6
+ exports.attemptVerdict = attemptVerdict;
7
+ /**
8
+ * The verdict on one of our own Attempts: did the value move? A TON wallet transaction
9
+ * "succeeds" even when it moved nothing (send mode +2 skips a message it cannot pay), and
10
+ * a transfer can still bounce, or a jetton move fail, one or two hops later. So an
11
+ * Attempt succeeded only when:
12
+ * - the wallet transaction consumed the request's seqno and ran it to the end;
13
+ * - every message of the signed request is among its outgoing messages (a missing one is a
14
+ * skip only when the wallet's action phase itself counts that many skipped actions);
15
+ * - no native message came back bounced (a `nofunds` or `negfunds` bounce, a failed action
16
+ * phase without send mode +16 and a non-bounceable message all leave the value with the
17
+ * recipient), each delivery's bounce phase agreeing with the flag we signed;
18
+ * - every jetton request reached a jetton wallet as an `internal_transfer` of a positive
19
+ * amount from our wallet, sent by our jetton wallet and run to the end by the receiving
20
+ * one (the exact amount is not required: fee-on-transfer tokens exist), and both jetton
21
+ * wallets are the master's own for the sender and the intended recipient. That last
22
+ * check needs chain reads, so the verdict returns the `legs` for the caller to confirm
23
+ * (`confirmLegs` in `reader.ts`); the receiving wallet's own 707 check then holds.
24
+ * Only a request that consumed its seqno is final: any other run (a failed action phase,
25
+ * or a compute phase that failed before `commit()`) left the same message valid until it
26
+ * expires, so anyone may replay it and move the value; such a run decides nothing
27
+ * (`pending`), and only the seqno or the proven expiry can.
28
+ * Used on the verdict paths only (`observe`, `includedFinal`). Every body read here is
29
+ * bound to the hash the quorum keyed (`messageBody`). A batch is one Attempt: one bounced
30
+ * output fails it, although the other outputs moved. Only the chain's own record of a
31
+ * failure decides `failed`; an answer that contradicts the chain or the signed request (a
32
+ * message missing that the wallet did not skip, a jetton wallet that ran the transfer yet
33
+ * sent nothing from the sender, phases that contradict each other or the chain's own
34
+ * counters) throws a retryable `PROVIDER_INCONSISTENT`, which decides nothing. Every
35
+ * output is checked before any of them decides.
36
+ */
37
+ const error_1 = require("../../core/errors/error");
38
+ const decode_1 = require("./decode");
39
+ const messages_1 = require("./messages");
40
+ const wallets_1 = require("./wallets");
41
+ /** Fixed reasons: a stored reason never holds an address, an amount or node text. */
42
+ exports.REASONS = Object.freeze({
43
+ walletFailed: 'the wallet transaction failed',
44
+ skipped: 'the wallet skipped a message',
45
+ bounced: 'transfer bounced',
46
+ jettonBounced: 'jetton transfer bounced',
47
+ jettonUnverified: 'the jetton wallets are not the master’s',
48
+ });
49
+ const PENDING = Object.freeze({ kind: 'pending' });
50
+ const failed = (reason) => Object.freeze({ kind: 'failed', reason });
51
+ const inconsistent = (reason) => new error_1.ProviderError('PROVIDER_INCONSISTENT', reason, { retryable: true });
52
+ /**
53
+ * wallet_v5.fc: an external request whose send mode lacks +2, refused after `commit()`
54
+ * stored the next seqno with an empty action list. The chain counts that compute phase a
55
+ * success (transaction.cpp: `success = accepted && committed`) and runs the empty list, so
56
+ * the transaction ran; the scripted node records it that way too. An indexer that wrote it
57
+ * as a failed compute phase is still read as W5's refusal.
58
+ */
59
+ const W5_REFUSED_AFTER_COMMIT = 137;
60
+ /** Whether `tx` ran a W5 signed external request (only W5 throws 137 after committing). */
61
+ function w5External(tx) {
62
+ if (!tx.inMsg || tx.inMsg.source !== null)
63
+ return false;
64
+ const body = (0, messages_1.messageBody)(tx.inMsg);
65
+ return (body !== null &&
66
+ body.bits.length >= 32 &&
67
+ body.beginParse().preloadUint(32) === messages_1.OP.w5SignedExternal);
68
+ }
69
+ /**
70
+ * Whether the wallet transaction of an external request `tx` consumed the request's seqno,
71
+ * so that the same message can never run again: it ran (the new seqno stands with the
72
+ * actions, W5's 137 included), or, as a defensive reading of W5 alone, its compute phase is
73
+ * recorded failed with 137. Any other run left the old seqno (transaction.cpp: a
74
+ * failed action phase drops the compute phase's state, and a compute phase that failed
75
+ * before `commit()` never had one): a foreign request signed with the same key, or our
76
+ * own, whose action phase failed does not consume the seqno. Throws the retryable
77
+ * contradiction of `ran`.
78
+ */
79
+ function consumesSeqno(tx) {
80
+ if ((0, decode_1.ran)(tx))
81
+ return true;
82
+ return (!tx.compute.success &&
83
+ !tx.compute.skipped &&
84
+ tx.compute.exitCode === W5_REFUSED_AFTER_COMMIT &&
85
+ w5External(tx));
86
+ }
87
+ /**
88
+ * Whether `tx` is our Attempt: the external message to `from` whose TEP-467 hash,
89
+ * computed here from the bound body, is the Attempt id. The indexer's `hash_norm` only
90
+ * finds candidates; it never decides.
91
+ */
92
+ function isOwnAttempt(tx, from, refId) {
93
+ if (!tx.inMsg || tx.inMsg.source !== null || tx.account !== from)
94
+ return false;
95
+ const body = (0, messages_1.messageBody)(tx.inMsg);
96
+ return body !== null && (0, wallets_1.externalHashOf)(tx.account, body) === refId;
97
+ }
98
+ /**
99
+ * The transaction in `trace` that received `message`, which `sender` sent. An internal
100
+ * message is delivered once, to its destination, with its value and its bounce flag:
101
+ * anything else contradicts the chain.
102
+ */
103
+ function receiver(trace, message, sender) {
104
+ const found = trace.transactions.filter((t) => t.inMsg?.hash === message.hash);
105
+ const [tx] = found;
106
+ if (!tx)
107
+ throw inconsistent('a complete trace lacks a delivered message');
108
+ if (found.length > 1 ||
109
+ message.source !== sender ||
110
+ tx.account !== message.destination ||
111
+ tx.inMsg?.source !== sender ||
112
+ tx.inMsg.value !== message.value ||
113
+ (message.bounce !== null &&
114
+ tx.inMsg.bounce !== null &&
115
+ tx.inMsg.bounce !== message.bounce)) {
116
+ throw inconsistent('the trace delivered a message other than the one sent');
117
+ }
118
+ return tx;
119
+ }
120
+ /** A native transfer as our builder signs it: a positive value, no body or a comment. */
121
+ function plainTransfer(facts) {
122
+ const { value, body } = facts;
123
+ const empty = body.bits.length === 0 && body.refs.length === 0;
124
+ return value > 0n && (empty || (0, messages_1.decodeComment)(body) !== undefined);
125
+ }
126
+ /**
127
+ * The requested messages, matched one to one with the wallet transaction's outgoing
128
+ * messages; or why they did not all go out: the wallet skipped them (send mode +2), or its
129
+ * code threw after committing the seqno. `ran` holds, so the outgoing messages are
130
+ * distinct and as many as the action phase created; the skips must be exactly the missing
131
+ * messages.
132
+ */
133
+ function sentMessages(root) {
134
+ const body = (0, messages_1.messageBody)(root.inMsg);
135
+ if (!body)
136
+ throw inconsistent('the indexer has no body for the external message');
137
+ const request = (0, messages_1.decodeWalletRequest)(body);
138
+ if (!request || request.auth !== 'external') {
139
+ throw inconsistent('the indexed external message is not a wallet transfer');
140
+ }
141
+ const action = root.action;
142
+ // Committed, then threw (W5 137): the list committed with the seqno was empty.
143
+ if ((0, decode_1.threwAfterCommit)(root)) {
144
+ if (action.msgsCreated !== 0 || action.skippedActions !== 0) {
145
+ throw inconsistent('the wallet threw after committing, yet ran an action');
146
+ }
147
+ return 'threw';
148
+ }
149
+ const unused = [...root.outMsgs];
150
+ const matched = [];
151
+ let missing = 0;
152
+ for (const requested of request.messages) {
153
+ const facts = (0, messages_1.messageFacts)(requested);
154
+ if (!facts)
155
+ throw inconsistent('the signed request holds a message that is not internal');
156
+ // Our builder signs only plain transfers of a positive value and TEP-74 transfers; any
157
+ // other message moves what the verdict cannot see, so it is never judged a success.
158
+ const jetton = (0, messages_1.decodeJettonTransfer)(facts.body);
159
+ if (!jetton && !plainTransfer(facts)) {
160
+ throw inconsistent('the signed request holds a message the verdict cannot judge');
161
+ }
162
+ const index = unused.findIndex((out) => out.destination === facts.to &&
163
+ out.value === facts.value &&
164
+ out.bodyHash === facts.bodyHash);
165
+ if (index < 0) {
166
+ missing += 1;
167
+ continue;
168
+ }
169
+ const out = unused.splice(index, 1)[0];
170
+ // A message leaves the wallet with the flag we signed.
171
+ const bounceable = requested.info.type === 'internal' && requested.info.bounce;
172
+ if (out.bounce !== null && out.bounce !== bounceable) {
173
+ throw inconsistent('a message went out with another bounce flag than signed');
174
+ }
175
+ matched.push({
176
+ out,
177
+ bounceable,
178
+ ...(jetton ? { jettonRecipient: jetton.destination } : {}),
179
+ });
180
+ }
181
+ if (unused.length > 0) {
182
+ throw inconsistent('the wallet transaction sent a message the request did not ask for');
183
+ }
184
+ // Send mode +2: the wallet records exactly the messages it skipped. The action phase
185
+ // counts skipped sends since global version 8 (config param 8), which both networks
186
+ // run; on an older chain this refuses (retryable), and never decides.
187
+ if (missing !== action.skippedActions) {
188
+ throw inconsistent('the wallet counts other skips than the messages it did not send');
189
+ }
190
+ return missing > 0 ? 'skipped' : matched;
191
+ }
192
+ /**
193
+ * The `internal_transfer` our jetton wallet `hop` sent onwards for our wallet `from`: the
194
+ * message of a positive amount, `null` when it moved nothing.
195
+ */
196
+ function onward(hop, from) {
197
+ let nothingMoved = false;
198
+ for (const m of hop.outMsgs) {
199
+ const body = (0, messages_1.messageBody)(m);
200
+ const internal = body ? (0, messages_1.decodeJettonInternalTransfer)(body) : null;
201
+ if (!internal || internal.from !== from)
202
+ continue;
203
+ // From the sender, a positive amount, never the exact one (fee-on-transfer tokens).
204
+ if (internal.amount > 0n)
205
+ return m;
206
+ nothingMoved = true; // a zero amount: nothing moved, so `failed` is accurate
207
+ }
208
+ if (nothingMoved)
209
+ return null;
210
+ throw inconsistent('the jetton wallet ran the transfer but sent none from the sender');
211
+ }
212
+ /** The outcome of the output `sent` of our wallet `from`, checked against the chain. */
213
+ function outcomeOf(trace, from, sent) {
214
+ const { out, bounceable, jettonRecipient } = sent;
215
+ const hop = receiver(trace, out, from);
216
+ const hopRan = (0, decode_1.ran)(hop);
217
+ // A bounce phase exists only for a bounceable message, and always when its compute
218
+ // phase failed (collator.cpp, transaction.cpp `bounce_enabled`). A bounce on a message
219
+ // we signed non-bounceable would fail a delivery that credited the value; a failed
220
+ // bounceable delivery without one lacks data. The flag we signed decides, even when the
221
+ // indexer leaves the delivery's own flag out.
222
+ if ((hop.inMsg?.bounce !== null && hop.inMsg?.bounce !== bounceable) ||
223
+ (hop.bounce !== undefined && !bounceable) ||
224
+ (bounceable && !hop.compute.success && hop.bounce === undefined)) {
225
+ throw inconsistent('the delivery contradicts the bounce flag we signed');
226
+ }
227
+ if (jettonRecipient === undefined) {
228
+ // The value stays unless the bounce phase sent it back.
229
+ return hop.bounce === 'ok' ? { failed: exports.REASONS.bounced } : { delivered: true };
230
+ }
231
+ // The owner's jetton wallet ran `transfer` and sent `internal_transfer` onwards. A
232
+ // failed phase dropped its state: the jettons never left.
233
+ if (!hopRan)
234
+ return { failed: exports.REASONS.jettonBounced };
235
+ const arrivalMessage = onward(hop, from);
236
+ if (!arrivalMessage)
237
+ return { failed: exports.REASONS.jettonBounced };
238
+ // TEP-74 707: the receiving wallet takes it only from the sender's jetton wallet.
239
+ const arrival = receiver(trace, arrivalMessage, hop.account);
240
+ // A failed phase drops the credit: the jettons came back, or never arrived.
241
+ if (!(0, decode_1.ran)(arrival))
242
+ return { failed: exports.REASONS.jettonBounced };
243
+ return {
244
+ leg: {
245
+ senderWallet: hop.account,
246
+ recipientWallet: arrival.account,
247
+ recipient: jettonRecipient,
248
+ },
249
+ };
250
+ }
251
+ /** The verdict on the Attempt whose wallet transaction is `root`, within `trace`. */
252
+ function attemptVerdict(root, trace) {
253
+ if (!root.inMsg || root.inMsg.source !== null) {
254
+ throw inconsistent('the attempt is not an external message');
255
+ }
256
+ if (!consumesSeqno(root))
257
+ return PENDING;
258
+ if (!root.compute.success)
259
+ return failed(exports.REASONS.walletFailed);
260
+ const sent = sentMessages(root);
261
+ if (sent === 'threw')
262
+ return failed(exports.REASONS.walletFailed);
263
+ if (sent === 'skipped')
264
+ return failed(exports.REASONS.skipped);
265
+ if (!trace || !trace.complete)
266
+ return PENDING;
267
+ // Every output is checked before any decides, so an early failure never hides a later
268
+ // contradiction.
269
+ const outcomes = sent.map((each) => outcomeOf(trace, root.account, each));
270
+ for (const outcome of outcomes) {
271
+ if ('failed' in outcome)
272
+ return failed(outcome.failed);
273
+ }
274
+ const legs = outcomes.flatMap((outcome) => ('leg' in outcome ? [outcome.leg] : []));
275
+ return Object.freeze({ kind: 'success', legs });
276
+ }
277
+ //# sourceMappingURL=trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/adapters/ton/trace.ts"],"names":[],"mappings":";;;AAyGA,sCAQC;AAOD,oCAIC;AAgLD,wCAkBC;AA9TD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,mDAAwD;AAExD,qCAAiD;AACjD,yCAQoB;AACpB,uCAA2C;AAkB3C,qFAAqF;AACxE,QAAA,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,YAAY,EAAE,+BAA+B;IAC7C,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AAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpF,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAClD,CAAC","sourcesContent":["/**\n * The verdict on one of our own Attempts: did the value move? A TON wallet transaction\n * \"succeeds\" even when it moved nothing (send mode +2 skips a message it cannot pay), and\n * a transfer can still bounce, or a jetton move fail, one or two hops later. So an\n * Attempt succeeded only when:\n * - the wallet transaction consumed the request's seqno and ran it to the end;\n * - every message of the signed request is among its outgoing messages (a missing one is a\n * skip only when the wallet's action phase itself counts that many skipped actions);\n * - no native message came back bounced (a `nofunds` or `negfunds` bounce, a failed action\n * phase without send mode +16 and a non-bounceable message all leave the value with the\n * recipient), each delivery's bounce phase agreeing with the flag we signed;\n * - every jetton request reached a jetton wallet as an `internal_transfer` of a positive\n * amount from our wallet, sent by our jetton wallet and run to the end by the receiving\n * one (the exact amount is not required: fee-on-transfer tokens exist), and both jetton\n * wallets are the master's own for the sender and the intended recipient. That last\n * check needs chain reads, so the verdict returns the `legs` for the caller to confirm\n * (`confirmLegs` in `reader.ts`); the receiving wallet's own 707 check then holds.\n * Only a request that consumed its seqno is final: any other run (a failed action phase,\n * or a compute phase that failed before `commit()`) left the same message valid until it\n * expires, so anyone may replay it and move the value; such a run decides nothing\n * (`pending`), and only the seqno or the proven expiry can.\n * Used on the verdict paths only (`observe`, `includedFinal`). Every body read here is\n * bound to the hash the quorum keyed (`messageBody`). A batch is one Attempt: one bounced\n * output fails it, although the other outputs moved. Only the chain's own record of a\n * failure decides `failed`; an answer that contradicts the chain or the signed request (a\n * message missing that the wallet did not skip, a jetton wallet that ran the transfer yet\n * sent nothing from the sender, phases that contradict each other or the chain's own\n * counters) throws a retryable `PROVIDER_INCONSISTENT`, which decides nothing. Every\n * output is checked before any of them decides.\n */\nimport { ProviderError } from '../../core/errors/error';\nimport type { V3Message, V3Trace, V3Transaction } from './api';\nimport { ran, threwAfterCommit } from './decode';\nimport {\n OP,\n decodeComment,\n decodeJettonInternalTransfer,\n decodeJettonTransfer,\n decodeWalletRequest,\n messageBody,\n messageFacts,\n} from './messages';\nimport { externalHashOf } from './wallets';\n\n/** One jetton transfer: the jetton wallets whose owners must be `from` and `recipient`. */\nexport interface JettonLeg {\n readonly senderWallet: string;\n readonly recipientWallet: string;\n readonly recipient: string;\n}\n\nexport type Verdict =\n | { readonly kind: 'success'; readonly legs: readonly JettonLeg[] }\n | { readonly kind: 'failed'; readonly reason: string }\n /**\n * Not decidable yet: the trace is still being executed or indexed, or the request ran\n * without consuming its seqno and may still run again until it expires.\n */\n | { readonly kind: 'pending' };\n\n/** Fixed reasons: a stored reason never holds an address, an amount or node text. */\nexport const REASONS = Object.freeze({\n walletFailed: 'the wallet transaction failed',\n skipped: 'the wallet skipped a message',\n bounced: 'transfer bounced',\n jettonBounced: 'jetton transfer bounced',\n jettonUnverified: 'the jetton wallets are not the master’s',\n});\n\nconst PENDING: Verdict = Object.freeze({ kind: 'pending' });\nconst failed = (reason: string): Verdict => Object.freeze({ kind: 'failed', reason });\n\nconst inconsistent = (reason: string) =>\n new ProviderError('PROVIDER_INCONSISTENT', reason, { retryable: true });\n\n/**\n * wallet_v5.fc: an external request whose send mode lacks +2, refused after `commit()`\n * stored the next seqno with an empty action list. The chain counts that compute phase a\n * success (transaction.cpp: `success = accepted && committed`) and runs the empty list, so\n * the transaction ran; the scripted node records it that way too. An indexer that wrote it\n * as a failed compute phase is still read as W5's refusal.\n */\nconst W5_REFUSED_AFTER_COMMIT = 137;\n\n/** Whether `tx` ran a W5 signed external request (only W5 throws 137 after committing). */\nfunction w5External(tx: V3Transaction): boolean {\n if (!tx.inMsg || tx.inMsg.source !== null) return false;\n const body = messageBody(tx.inMsg);\n return (\n body !== null &&\n body.bits.length >= 32 &&\n body.beginParse().preloadUint(32) === OP.w5SignedExternal\n );\n}\n\n/**\n * Whether the wallet transaction of an external request `tx` consumed the request's seqno,\n * so that the same message can never run again: it ran (the new seqno stands with the\n * actions, W5's 137 included), or, as a defensive reading of W5 alone, its compute phase is\n * recorded failed with 137. Any other run left the old seqno (transaction.cpp: a\n * failed action phase drops the compute phase's state, and a compute phase that failed\n * before `commit()` never had one): a foreign request signed with the same key, or our\n * own, whose action phase failed does not consume the seqno. Throws the retryable\n * contradiction of `ran`.\n */\nexport function consumesSeqno(tx: V3Transaction): boolean {\n if (ran(tx)) return true;\n return (\n !tx.compute.success &&\n !tx.compute.skipped &&\n tx.compute.exitCode === W5_REFUSED_AFTER_COMMIT &&\n w5External(tx)\n );\n}\n\n/**\n * Whether `tx` is our Attempt: the external message to `from` whose TEP-467 hash,\n * computed here from the bound body, is the Attempt id. The indexer's `hash_norm` only\n * finds candidates; it never decides.\n */\nexport function isOwnAttempt(tx: V3Transaction, from: string, refId: string): boolean {\n if (!tx.inMsg || tx.inMsg.source !== null || tx.account !== from) return false;\n const body = messageBody(tx.inMsg);\n return body !== null && externalHashOf(tx.account, body) === refId;\n}\n\n/**\n * The transaction in `trace` that received `message`, which `sender` sent. An internal\n * message is delivered once, to its destination, with its value and its bounce flag:\n * anything else contradicts the chain.\n */\nfunction receiver(trace: V3Trace, message: V3Message, sender: string): V3Transaction {\n const found = trace.transactions.filter((t) => t.inMsg?.hash === message.hash);\n const [tx] = found;\n if (!tx) throw inconsistent('a complete trace lacks a delivered message');\n if (\n found.length > 1 ||\n message.source !== sender ||\n tx.account !== message.destination ||\n tx.inMsg?.source !== sender ||\n tx.inMsg.value !== message.value ||\n (message.bounce !== null &&\n tx.inMsg.bounce !== null &&\n tx.inMsg.bounce !== message.bounce)\n ) {\n throw inconsistent('the trace delivered a message other than the one sent');\n }\n return tx;\n}\n\ninterface Sent {\n readonly out: V3Message;\n /** The bounce flag we signed for it: it decides whether a bounce phase may exist. */\n readonly bounceable: boolean;\n /** For a jetton request: its intended recipient (the owner). */\n readonly jettonRecipient?: string;\n}\n\n/** A native transfer as our builder signs it: a positive value, no body or a comment. */\nfunction plainTransfer(facts: NonNullable<ReturnType<typeof messageFacts>>): boolean {\n const { value, body } = facts;\n const empty = body.bits.length === 0 && body.refs.length === 0;\n return value > 0n && (empty || decodeComment(body) !== undefined);\n}\n\n/**\n * The requested messages, matched one to one with the wallet transaction's outgoing\n * messages; or why they did not all go out: the wallet skipped them (send mode +2), or its\n * code threw after committing the seqno. `ran` holds, so the outgoing messages are\n * distinct and as many as the action phase created; the skips must be exactly the missing\n * messages.\n */\nfunction sentMessages(root: V3Transaction): readonly Sent[] | 'skipped' | 'threw' {\n const body = messageBody(root.inMsg as V3Message);\n if (!body) throw inconsistent('the indexer has no body for the external message');\n const request = decodeWalletRequest(body);\n if (!request || request.auth !== 'external') {\n throw inconsistent('the indexed external message is not a wallet transfer');\n }\n const action = root.action as NonNullable<V3Transaction['action']>;\n // Committed, then threw (W5 137): the list committed with the seqno was empty.\n if (threwAfterCommit(root)) {\n if (action.msgsCreated !== 0 || action.skippedActions !== 0) {\n throw inconsistent('the wallet threw after committing, yet ran an action');\n }\n return 'threw';\n }\n const unused = [...root.outMsgs];\n const matched: Sent[] = [];\n let missing = 0;\n for (const requested of request.messages) {\n const facts = messageFacts(requested);\n if (!facts)\n throw inconsistent('the signed request holds a message that is not internal');\n // Our builder signs only plain transfers of a positive value and TEP-74 transfers; any\n // other message moves what the verdict cannot see, so it is never judged a success.\n const jetton = decodeJettonTransfer(facts.body);\n if (!jetton && !plainTransfer(facts)) {\n throw inconsistent('the signed request holds a message the verdict cannot judge');\n }\n const index = unused.findIndex(\n (out) =>\n out.destination === facts.to &&\n out.value === facts.value &&\n out.bodyHash === facts.bodyHash,\n );\n if (index < 0) {\n missing += 1;\n continue;\n }\n const out = unused.splice(index, 1)[0] as V3Message;\n // A message leaves the wallet with the flag we signed.\n const bounceable = requested.info.type === 'internal' && requested.info.bounce;\n if (out.bounce !== null && out.bounce !== bounceable) {\n throw inconsistent('a message went out with another bounce flag than signed');\n }\n matched.push({\n out,\n bounceable,\n ...(jetton ? { jettonRecipient: jetton.destination } : {}),\n });\n }\n if (unused.length > 0) {\n throw inconsistent(\n 'the wallet transaction sent a message the request did not ask for',\n );\n }\n // Send mode +2: the wallet records exactly the messages it skipped. The action phase\n // counts skipped sends since global version 8 (config param 8), which both networks\n // run; on an older chain this refuses (retryable), and never decides.\n if (missing !== action.skippedActions) {\n throw inconsistent('the wallet counts other skips than the messages it did not send');\n }\n return missing > 0 ? 'skipped' : matched;\n}\n\n/**\n * The `internal_transfer` our jetton wallet `hop` sent onwards for our wallet `from`: the\n * message of a positive amount, `null` when it moved nothing.\n */\nfunction onward(hop: V3Transaction, from: string): V3Message | null {\n let nothingMoved = false;\n for (const m of hop.outMsgs) {\n const body = messageBody(m);\n const internal = body ? decodeJettonInternalTransfer(body) : null;\n if (!internal || internal.from !== from) continue;\n // From the sender, a positive amount, never the exact one (fee-on-transfer tokens).\n if (internal.amount > 0n) return m;\n nothingMoved = true; // a zero amount: nothing moved, so `failed` is accurate\n }\n if (nothingMoved) return null;\n throw inconsistent('the jetton wallet ran the transfer but sent none from the sender');\n}\n\n/** What one output did: failed (with why), a jetton leg to confirm, or delivered. */\ntype Outcome =\n | { readonly failed: string }\n | { readonly leg: JettonLeg }\n | { readonly delivered: true };\n\n/** The outcome of the output `sent` of our wallet `from`, checked against the chain. */\nfunction outcomeOf(trace: V3Trace, from: string, sent: Sent): Outcome {\n const { out, bounceable, jettonRecipient } = sent;\n const hop = receiver(trace, out, from);\n const hopRan = ran(hop);\n // A bounce phase exists only for a bounceable message, and always when its compute\n // phase failed (collator.cpp, transaction.cpp `bounce_enabled`). A bounce on a message\n // we signed non-bounceable would fail a delivery that credited the value; a failed\n // bounceable delivery without one lacks data. The flag we signed decides, even when the\n // indexer leaves the delivery's own flag out.\n if (\n (hop.inMsg?.bounce !== null && hop.inMsg?.bounce !== bounceable) ||\n (hop.bounce !== undefined && !bounceable) ||\n (bounceable && !hop.compute.success && hop.bounce === undefined)\n ) {\n throw inconsistent('the delivery contradicts the bounce flag we signed');\n }\n if (jettonRecipient === undefined) {\n // The value stays unless the bounce phase sent it back.\n return hop.bounce === 'ok' ? { failed: REASONS.bounced } : { delivered: true };\n }\n // The owner's jetton wallet ran `transfer` and sent `internal_transfer` onwards. A\n // failed phase dropped its state: the jettons never left.\n if (!hopRan) return { failed: REASONS.jettonBounced };\n const arrivalMessage = onward(hop, from);\n if (!arrivalMessage) return { failed: REASONS.jettonBounced };\n // TEP-74 707: the receiving wallet takes it only from the sender's jetton wallet.\n const arrival = receiver(trace, arrivalMessage, hop.account);\n // A failed phase drops the credit: the jettons came back, or never arrived.\n if (!ran(arrival)) return { failed: REASONS.jettonBounced };\n return {\n leg: {\n senderWallet: hop.account,\n recipientWallet: arrival.account,\n recipient: jettonRecipient,\n },\n };\n}\n\n/** The verdict on the Attempt whose wallet transaction is `root`, within `trace`. */\nexport function attemptVerdict(root: V3Transaction, trace: V3Trace | null): Verdict {\n if (!root.inMsg || root.inMsg.source !== null) {\n throw inconsistent('the attempt is not an external message');\n }\n if (!consumesSeqno(root)) return PENDING;\n if (!root.compute.success) return failed(REASONS.walletFailed);\n const sent = sentMessages(root);\n if (sent === 'threw') return failed(REASONS.walletFailed);\n if (sent === 'skipped') return failed(REASONS.skipped);\n if (!trace || !trace.complete) return PENDING;\n // Every output is checked before any decides, so an early failure never hides a later\n // contradiction.\n const outcomes = sent.map((each) => outcomeOf(trace, root.account, each));\n for (const outcome of outcomes) {\n if ('failed' in outcome) return failed(outcome.failed);\n }\n const legs = outcomes.flatMap((outcome) => ('leg' in outcome ? [outcome.leg] : []));\n return Object.freeze({ kind: 'success', legs });\n}\n"]}