@getomnichain/omnichain 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (576) hide show
  1. package/dist/cjs/abstract_gas_pricing.js +27 -0
  2. package/dist/cjs/abstract_gas_pricing.js.map +1 -0
  3. package/dist/cjs/address.factory.js +81 -0
  4. package/dist/cjs/address.factory.js.map +1 -0
  5. package/dist/cjs/address.js +17 -0
  6. package/dist/cjs/address.js.map +1 -0
  7. package/dist/cjs/address_field.decorator.js +37 -0
  8. package/dist/cjs/address_field.decorator.js.map +1 -0
  9. package/dist/cjs/chain.base.js +118 -0
  10. package/dist/cjs/chain.base.js.map +1 -0
  11. package/dist/cjs/chain_ids.js +205 -0
  12. package/dist/cjs/chain_ids.js.map +1 -0
  13. package/dist/cjs/errors.js +69 -0
  14. package/dist/cjs/errors.js.map +1 -0
  15. package/dist/cjs/evm/evm_address.js +63 -0
  16. package/dist/cjs/evm/evm_address.js.map +1 -0
  17. package/dist/cjs/evm/evm_chain.js +690 -0
  18. package/dist/cjs/evm/evm_chain.js.map +1 -0
  19. package/dist/cjs/evm/evm_chains.js +530 -0
  20. package/dist/cjs/evm/evm_chains.js.map +1 -0
  21. package/dist/cjs/evm/evm_gas_estimate.js +76 -0
  22. package/dist/cjs/evm/evm_gas_estimate.js.map +1 -0
  23. package/dist/cjs/evm/evm_gas_pricing.js +62 -0
  24. package/dist/cjs/evm/evm_gas_pricing.js.map +1 -0
  25. package/dist/cjs/evm/evm_token.js +26 -0
  26. package/dist/cjs/evm/evm_token.js.map +1 -0
  27. package/dist/cjs/evm/evm_tokens.js +109 -0
  28. package/dist/cjs/evm/evm_tokens.js.map +1 -0
  29. package/dist/cjs/evm/evm_transaction_status.js +183 -0
  30. package/dist/cjs/evm/evm_transaction_status.js.map +1 -0
  31. package/dist/cjs/evm/index.js +26 -0
  32. package/dist/cjs/evm/index.js.map +1 -0
  33. package/dist/cjs/evm/unsigned_evm_transaction.js +22 -0
  34. package/dist/cjs/evm/unsigned_evm_transaction.js.map +1 -0
  35. package/dist/cjs/index.js +34 -0
  36. package/dist/cjs/index.js.map +1 -0
  37. package/dist/cjs/is_address.decorator.js +54 -0
  38. package/dist/cjs/is_address.decorator.js.map +1 -0
  39. package/dist/cjs/network_type.js +152 -0
  40. package/dist/cjs/network_type.js.map +1 -0
  41. package/dist/cjs/package.json +3 -0
  42. package/dist/cjs/priority.js +26 -0
  43. package/dist/cjs/priority.js.map +1 -0
  44. package/dist/cjs/solana/index.js +25 -0
  45. package/dist/cjs/solana/index.js.map +1 -0
  46. package/dist/cjs/solana/solana_address.js +49 -0
  47. package/dist/cjs/solana/solana_address.js.map +1 -0
  48. package/dist/cjs/solana/solana_chain.js +708 -0
  49. package/dist/cjs/solana/solana_chain.js.map +1 -0
  50. package/dist/cjs/solana/solana_chains.js +88 -0
  51. package/dist/cjs/solana/solana_chains.js.map +1 -0
  52. package/dist/cjs/solana/solana_gas_pricing.js +30 -0
  53. package/dist/cjs/solana/solana_gas_pricing.js.map +1 -0
  54. package/dist/cjs/solana/solana_token.js +38 -0
  55. package/dist/cjs/solana/solana_token.js.map +1 -0
  56. package/dist/cjs/solana/solana_tokens.js +29 -0
  57. package/dist/cjs/solana/solana_tokens.js.map +1 -0
  58. package/dist/cjs/solana/solana_transaction_status.js +149 -0
  59. package/dist/cjs/solana/solana_transaction_status.js.map +1 -0
  60. package/dist/cjs/solana/unsigned_solana_transaction.js +30 -0
  61. package/dist/cjs/solana/unsigned_solana_transaction.js.map +1 -0
  62. package/dist/cjs/token.js +66 -0
  63. package/dist/cjs/token.js.map +1 -0
  64. package/dist/cjs/ton/index.js +18 -0
  65. package/dist/cjs/ton/index.js.map +1 -0
  66. package/dist/cjs/ton/ton_address.js +57 -0
  67. package/dist/cjs/ton/ton_address.js.map +1 -0
  68. package/dist/cjs/transaction_status.js +283 -0
  69. package/dist/cjs/transaction_status.js.map +1 -0
  70. package/dist/cjs/unsigned_transaction.js +13 -0
  71. package/dist/cjs/unsigned_transaction.js.map +1 -0
  72. package/dist/cjs/utxo/btc/btc_address.js +43 -0
  73. package/dist/cjs/utxo/btc/btc_address.js.map +1 -0
  74. package/dist/cjs/utxo/btc/btc_chain.js +66 -0
  75. package/dist/cjs/utxo/btc/btc_chain.js.map +1 -0
  76. package/dist/cjs/utxo/btc/btc_chains.js +49 -0
  77. package/dist/cjs/utxo/btc/btc_chains.js.map +1 -0
  78. package/dist/cjs/utxo/btc/btc_token.js +15 -0
  79. package/dist/cjs/utxo/btc/btc_token.js.map +1 -0
  80. package/dist/cjs/utxo/btc/index.js +30 -0
  81. package/dist/cjs/utxo/btc/index.js.map +1 -0
  82. package/dist/cjs/utxo/btc/network_params.js +196 -0
  83. package/dist/cjs/utxo/btc/network_params.js.map +1 -0
  84. package/dist/cjs/utxo/btc/tools/asset_outpoint.js +16 -0
  85. package/dist/cjs/utxo/btc/tools/asset_outpoint.js.map +1 -0
  86. package/dist/cjs/utxo/btc/tools/bitcoin_core.tool.js +179 -0
  87. package/dist/cjs/utxo/btc/tools/bitcoin_core.tool.js.map +1 -0
  88. package/dist/cjs/utxo/btc/tools/esplora.tool.js +120 -0
  89. package/dist/cjs/utxo/btc/tools/esplora.tool.js.map +1 -0
  90. package/dist/cjs/utxo/btc/tools/inscription_index.js +3 -0
  91. package/dist/cjs/utxo/btc/tools/inscription_index.js.map +1 -0
  92. package/dist/cjs/utxo/btc/tools/ordiscan.tool.js +60 -0
  93. package/dist/cjs/utxo/btc/tools/ordiscan.tool.js.map +1 -0
  94. package/dist/cjs/utxo/btc/tools/rare_sat_index.js +3 -0
  95. package/dist/cjs/utxo/btc/tools/rare_sat_index.js.map +1 -0
  96. package/dist/cjs/utxo/btc/tools/rune_index.js +3 -0
  97. package/dist/cjs/utxo/btc/tools/rune_index.js.map +1 -0
  98. package/dist/cjs/utxo/btc/tools/unisat.tool.js +56 -0
  99. package/dist/cjs/utxo/btc/tools/unisat.tool.js.map +1 -0
  100. package/dist/cjs/utxo/coin_selection.js +160 -0
  101. package/dist/cjs/utxo/coin_selection.js.map +1 -0
  102. package/dist/cjs/utxo/doge/doge_chains.js +32 -0
  103. package/dist/cjs/utxo/doge/doge_chains.js.map +1 -0
  104. package/dist/cjs/utxo/doge/index.js +19 -0
  105. package/dist/cjs/utxo/doge/index.js.map +1 -0
  106. package/dist/cjs/utxo/doge/network_params.js +30 -0
  107. package/dist/cjs/utxo/doge/network_params.js.map +1 -0
  108. package/dist/cjs/utxo/ecc.js +47 -0
  109. package/dist/cjs/utxo/ecc.js.map +1 -0
  110. package/dist/cjs/utxo/fee.js +61 -0
  111. package/dist/cjs/utxo/fee.js.map +1 -0
  112. package/dist/cjs/utxo/index.js +36 -0
  113. package/dist/cjs/utxo/index.js.map +1 -0
  114. package/dist/cjs/utxo/ltc/index.js +19 -0
  115. package/dist/cjs/utxo/ltc/index.js.map +1 -0
  116. package/dist/cjs/utxo/ltc/ltc_chains.js +32 -0
  117. package/dist/cjs/utxo/ltc/ltc_chains.js.map +1 -0
  118. package/dist/cjs/utxo/ltc/network_params.js +33 -0
  119. package/dist/cjs/utxo/ltc/network_params.js.map +1 -0
  120. package/dist/cjs/utxo/script.js +59 -0
  121. package/dist/cjs/utxo/script.js.map +1 -0
  122. package/dist/cjs/utxo/tools/broadcaster.js +3 -0
  123. package/dist/cjs/utxo/tools/broadcaster.js.map +1 -0
  124. package/dist/cjs/utxo/tools/chain_tip_provider.js +3 -0
  125. package/dist/cjs/utxo/tools/chain_tip_provider.js.map +1 -0
  126. package/dist/cjs/utxo/tools/fee_estimator.js +3 -0
  127. package/dist/cjs/utxo/tools/fee_estimator.js.map +1 -0
  128. package/dist/cjs/utxo/tools/raw_transaction_provider.js +3 -0
  129. package/dist/cjs/utxo/tools/raw_transaction_provider.js.map +1 -0
  130. package/dist/cjs/utxo/tools/utxo_provider.js +3 -0
  131. package/dist/cjs/utxo/tools/utxo_provider.js.map +1 -0
  132. package/dist/cjs/utxo/unsigned_utxo_transaction.js +36 -0
  133. package/dist/cjs/utxo/unsigned_utxo_transaction.js.map +1 -0
  134. package/dist/cjs/utxo/utxo.js +3 -0
  135. package/dist/{utxo → cjs/utxo}/utxo.js.map +1 -1
  136. package/dist/cjs/utxo/utxo_chain.js +528 -0
  137. package/dist/cjs/utxo/utxo_chain.js.map +1 -0
  138. package/dist/cjs/utxo/utxo_chains.js +68 -0
  139. package/dist/cjs/utxo/utxo_chains.js.map +1 -0
  140. package/dist/cjs/utxo/utxo_gas_pricing.js +24 -0
  141. package/dist/cjs/utxo/utxo_gas_pricing.js.map +1 -0
  142. package/dist/cjs/utxo/utxo_network_params.js +18 -0
  143. package/dist/cjs/utxo/utxo_network_params.js.map +1 -0
  144. package/dist/cjs/utxo/utxo_transaction_status.js +95 -0
  145. package/dist/cjs/utxo/utxo_transaction_status.js.map +1 -0
  146. package/dist/esm/abstract_gas_pricing.d.ts.map +1 -0
  147. package/dist/esm/abstract_gas_pricing.js.map +1 -0
  148. package/dist/esm/address.d.ts.map +1 -0
  149. package/dist/esm/address.factory.d.ts.map +1 -0
  150. package/dist/esm/address.factory.js.map +1 -0
  151. package/dist/esm/address.js.map +1 -0
  152. package/dist/esm/address_field.decorator.d.ts.map +1 -0
  153. package/dist/esm/address_field.decorator.js.map +1 -0
  154. package/dist/esm/chain.base.d.ts.map +1 -0
  155. package/dist/esm/chain.base.js.map +1 -0
  156. package/dist/esm/chain_ids.d.ts.map +1 -0
  157. package/dist/esm/chain_ids.js.map +1 -0
  158. package/dist/esm/errors.d.ts.map +1 -0
  159. package/dist/esm/errors.js.map +1 -0
  160. package/dist/esm/evm/evm_address.d.ts.map +1 -0
  161. package/dist/esm/evm/evm_address.js.map +1 -0
  162. package/dist/esm/evm/evm_chain.d.ts.map +1 -0
  163. package/dist/esm/evm/evm_chain.js.map +1 -0
  164. package/dist/esm/evm/evm_chains.d.ts.map +1 -0
  165. package/dist/esm/evm/evm_chains.js.map +1 -0
  166. package/dist/esm/evm/evm_gas_estimate.d.ts.map +1 -0
  167. package/dist/esm/evm/evm_gas_estimate.js.map +1 -0
  168. package/dist/esm/evm/evm_gas_pricing.d.ts.map +1 -0
  169. package/dist/esm/evm/evm_gas_pricing.js.map +1 -0
  170. package/dist/esm/evm/evm_token.d.ts.map +1 -0
  171. package/dist/esm/evm/evm_token.js.map +1 -0
  172. package/dist/esm/evm/evm_tokens.d.ts.map +1 -0
  173. package/dist/esm/evm/evm_tokens.js.map +1 -0
  174. package/dist/esm/evm/evm_transaction_status.d.ts.map +1 -0
  175. package/dist/esm/evm/evm_transaction_status.js.map +1 -0
  176. package/dist/esm/evm/index.d.ts.map +1 -0
  177. package/dist/esm/evm/index.js.map +1 -0
  178. package/dist/esm/evm/unsigned_evm_transaction.d.ts.map +1 -0
  179. package/dist/esm/evm/unsigned_evm_transaction.js.map +1 -0
  180. package/dist/esm/index.d.ts.map +1 -0
  181. package/dist/esm/index.js.map +1 -0
  182. package/dist/esm/is_address.decorator.d.ts.map +1 -0
  183. package/dist/esm/is_address.decorator.js.map +1 -0
  184. package/dist/esm/network_type.d.ts.map +1 -0
  185. package/dist/esm/network_type.js.map +1 -0
  186. package/dist/esm/package.json +3 -0
  187. package/dist/esm/priority.d.ts.map +1 -0
  188. package/dist/esm/priority.js.map +1 -0
  189. package/dist/esm/solana/index.d.ts.map +1 -0
  190. package/dist/esm/solana/index.js.map +1 -0
  191. package/dist/esm/solana/solana_address.d.ts.map +1 -0
  192. package/dist/esm/solana/solana_address.js.map +1 -0
  193. package/dist/esm/solana/solana_chain.d.ts.map +1 -0
  194. package/dist/esm/solana/solana_chain.js.map +1 -0
  195. package/dist/esm/solana/solana_chains.d.ts.map +1 -0
  196. package/dist/esm/solana/solana_chains.js.map +1 -0
  197. package/dist/esm/solana/solana_gas_pricing.d.ts.map +1 -0
  198. package/dist/esm/solana/solana_gas_pricing.js.map +1 -0
  199. package/dist/esm/solana/solana_token.d.ts.map +1 -0
  200. package/dist/esm/solana/solana_token.js.map +1 -0
  201. package/dist/esm/solana/solana_tokens.d.ts.map +1 -0
  202. package/dist/esm/solana/solana_tokens.js.map +1 -0
  203. package/dist/esm/solana/solana_transaction_status.d.ts.map +1 -0
  204. package/dist/esm/solana/solana_transaction_status.js.map +1 -0
  205. package/dist/esm/solana/unsigned_solana_transaction.d.ts.map +1 -0
  206. package/dist/esm/solana/unsigned_solana_transaction.js.map +1 -0
  207. package/dist/esm/token.d.ts.map +1 -0
  208. package/dist/esm/token.js.map +1 -0
  209. package/dist/esm/ton/index.d.ts.map +1 -0
  210. package/dist/esm/ton/index.js.map +1 -0
  211. package/dist/esm/ton/ton_address.d.ts.map +1 -0
  212. package/dist/esm/ton/ton_address.js.map +1 -0
  213. package/dist/esm/transaction_status.d.ts.map +1 -0
  214. package/dist/esm/transaction_status.js.map +1 -0
  215. package/dist/esm/unsigned_transaction.d.ts.map +1 -0
  216. package/dist/esm/unsigned_transaction.js.map +1 -0
  217. package/dist/esm/utxo/btc/btc_address.d.ts.map +1 -0
  218. package/dist/esm/utxo/btc/btc_address.js.map +1 -0
  219. package/dist/esm/utxo/btc/btc_chain.d.ts.map +1 -0
  220. package/dist/esm/utxo/btc/btc_chain.js.map +1 -0
  221. package/dist/esm/utxo/btc/btc_chains.d.ts.map +1 -0
  222. package/dist/esm/utxo/btc/btc_chains.js.map +1 -0
  223. package/dist/esm/utxo/btc/btc_token.d.ts.map +1 -0
  224. package/dist/esm/utxo/btc/btc_token.js.map +1 -0
  225. package/dist/esm/utxo/btc/index.d.ts.map +1 -0
  226. package/dist/esm/utxo/btc/index.js.map +1 -0
  227. package/dist/esm/utxo/btc/network_params.d.ts.map +1 -0
  228. package/dist/esm/utxo/btc/network_params.js.map +1 -0
  229. package/dist/esm/utxo/btc/tools/asset_outpoint.d.ts.map +1 -0
  230. package/dist/esm/utxo/btc/tools/asset_outpoint.js.map +1 -0
  231. package/dist/esm/utxo/btc/tools/bitcoin_core.tool.d.ts.map +1 -0
  232. package/dist/esm/utxo/btc/tools/bitcoin_core.tool.js.map +1 -0
  233. package/dist/esm/utxo/btc/tools/esplora.tool.d.ts.map +1 -0
  234. package/dist/esm/utxo/btc/tools/esplora.tool.js.map +1 -0
  235. package/dist/esm/utxo/btc/tools/inscription_index.d.ts.map +1 -0
  236. package/dist/esm/utxo/btc/tools/inscription_index.js.map +1 -0
  237. package/dist/esm/utxo/btc/tools/ordiscan.tool.d.ts.map +1 -0
  238. package/dist/esm/utxo/btc/tools/ordiscan.tool.js.map +1 -0
  239. package/dist/esm/utxo/btc/tools/rare_sat_index.d.ts.map +1 -0
  240. package/dist/esm/utxo/btc/tools/rare_sat_index.js.map +1 -0
  241. package/dist/esm/utxo/btc/tools/rune_index.d.ts.map +1 -0
  242. package/dist/esm/utxo/btc/tools/rune_index.js.map +1 -0
  243. package/dist/esm/utxo/btc/tools/unisat.tool.d.ts.map +1 -0
  244. package/dist/esm/utxo/btc/tools/unisat.tool.js.map +1 -0
  245. package/dist/esm/utxo/coin_selection.d.ts.map +1 -0
  246. package/dist/esm/utxo/coin_selection.js.map +1 -0
  247. package/dist/esm/utxo/doge/doge_chains.d.ts.map +1 -0
  248. package/dist/esm/utxo/doge/doge_chains.js.map +1 -0
  249. package/dist/esm/utxo/doge/index.d.ts.map +1 -0
  250. package/dist/esm/utxo/doge/index.js.map +1 -0
  251. package/dist/esm/utxo/doge/network_params.d.ts.map +1 -0
  252. package/dist/esm/utxo/doge/network_params.js.map +1 -0
  253. package/dist/esm/utxo/ecc.d.ts.map +1 -0
  254. package/dist/esm/utxo/ecc.js.map +1 -0
  255. package/dist/esm/utxo/fee.d.ts.map +1 -0
  256. package/dist/esm/utxo/fee.js.map +1 -0
  257. package/dist/esm/utxo/index.d.ts.map +1 -0
  258. package/dist/esm/utxo/index.js.map +1 -0
  259. package/dist/esm/utxo/ltc/index.d.ts.map +1 -0
  260. package/dist/esm/utxo/ltc/index.js.map +1 -0
  261. package/dist/{utxo/doge/doge_chains.d.ts.map → esm/utxo/ltc/ltc_chains.d.ts.map} +1 -1
  262. package/dist/{utxo/doge/doge_chains.js.map → esm/utxo/ltc/ltc_chains.js.map} +1 -1
  263. package/dist/esm/utxo/ltc/network_params.d.ts.map +1 -0
  264. package/dist/esm/utxo/ltc/network_params.js.map +1 -0
  265. package/dist/esm/utxo/script.d.ts.map +1 -0
  266. package/dist/esm/utxo/script.js.map +1 -0
  267. package/dist/esm/utxo/tools/broadcaster.d.ts.map +1 -0
  268. package/dist/esm/utxo/tools/broadcaster.js.map +1 -0
  269. package/dist/esm/utxo/tools/chain_tip_provider.d.ts.map +1 -0
  270. package/dist/esm/utxo/tools/chain_tip_provider.js.map +1 -0
  271. package/dist/esm/utxo/tools/fee_estimator.d.ts.map +1 -0
  272. package/dist/esm/utxo/tools/fee_estimator.js.map +1 -0
  273. package/dist/esm/utxo/tools/raw_transaction_provider.d.ts.map +1 -0
  274. package/dist/esm/utxo/tools/raw_transaction_provider.js.map +1 -0
  275. package/dist/esm/utxo/tools/utxo_provider.d.ts.map +1 -0
  276. package/dist/esm/utxo/tools/utxo_provider.js.map +1 -0
  277. package/dist/esm/utxo/unsigned_utxo_transaction.d.ts.map +1 -0
  278. package/dist/esm/utxo/unsigned_utxo_transaction.js.map +1 -0
  279. package/dist/esm/utxo/utxo.d.ts.map +1 -0
  280. package/dist/esm/utxo/utxo.js.map +1 -0
  281. package/dist/esm/utxo/utxo_chain.d.ts.map +1 -0
  282. package/dist/esm/utxo/utxo_chain.js.map +1 -0
  283. package/dist/esm/utxo/utxo_chains.d.ts.map +1 -0
  284. package/dist/esm/utxo/utxo_chains.js.map +1 -0
  285. package/dist/esm/utxo/utxo_gas_pricing.d.ts.map +1 -0
  286. package/dist/esm/utxo/utxo_gas_pricing.js.map +1 -0
  287. package/dist/esm/utxo/utxo_network_params.d.ts.map +1 -0
  288. package/dist/esm/utxo/utxo_network_params.js.map +1 -0
  289. package/dist/esm/utxo/utxo_transaction_status.d.ts.map +1 -0
  290. package/dist/esm/utxo/utxo_transaction_status.js.map +1 -0
  291. package/package.json +32 -16
  292. package/dist/abstract_gas_pricing.d.ts.map +0 -1
  293. package/dist/abstract_gas_pricing.js.map +0 -1
  294. package/dist/address.d.ts.map +0 -1
  295. package/dist/address.factory.d.ts.map +0 -1
  296. package/dist/address.factory.js.map +0 -1
  297. package/dist/address.js.map +0 -1
  298. package/dist/address_field.decorator.d.ts.map +0 -1
  299. package/dist/address_field.decorator.js.map +0 -1
  300. package/dist/chain.base.d.ts.map +0 -1
  301. package/dist/chain.base.js.map +0 -1
  302. package/dist/chain_ids.d.ts.map +0 -1
  303. package/dist/chain_ids.js.map +0 -1
  304. package/dist/errors.d.ts.map +0 -1
  305. package/dist/errors.js.map +0 -1
  306. package/dist/evm/evm_address.d.ts.map +0 -1
  307. package/dist/evm/evm_address.js.map +0 -1
  308. package/dist/evm/evm_chain.d.ts.map +0 -1
  309. package/dist/evm/evm_chain.js.map +0 -1
  310. package/dist/evm/evm_chains.d.ts.map +0 -1
  311. package/dist/evm/evm_chains.js.map +0 -1
  312. package/dist/evm/evm_gas_estimate.d.ts.map +0 -1
  313. package/dist/evm/evm_gas_estimate.js.map +0 -1
  314. package/dist/evm/evm_gas_pricing.d.ts.map +0 -1
  315. package/dist/evm/evm_gas_pricing.js.map +0 -1
  316. package/dist/evm/evm_token.d.ts.map +0 -1
  317. package/dist/evm/evm_token.js.map +0 -1
  318. package/dist/evm/evm_tokens.d.ts.map +0 -1
  319. package/dist/evm/evm_tokens.js.map +0 -1
  320. package/dist/evm/evm_transaction_status.d.ts.map +0 -1
  321. package/dist/evm/evm_transaction_status.js.map +0 -1
  322. package/dist/evm/index.d.ts.map +0 -1
  323. package/dist/evm/index.js.map +0 -1
  324. package/dist/evm/unsigned_evm_transaction.d.ts.map +0 -1
  325. package/dist/evm/unsigned_evm_transaction.js.map +0 -1
  326. package/dist/index.d.ts.map +0 -1
  327. package/dist/index.js.map +0 -1
  328. package/dist/is_address.decorator.d.ts.map +0 -1
  329. package/dist/is_address.decorator.js.map +0 -1
  330. package/dist/network_type.d.ts.map +0 -1
  331. package/dist/network_type.js.map +0 -1
  332. package/dist/priority.d.ts.map +0 -1
  333. package/dist/priority.js.map +0 -1
  334. package/dist/solana/index.d.ts.map +0 -1
  335. package/dist/solana/index.js.map +0 -1
  336. package/dist/solana/solana_address.d.ts.map +0 -1
  337. package/dist/solana/solana_address.js.map +0 -1
  338. package/dist/solana/solana_chain.d.ts.map +0 -1
  339. package/dist/solana/solana_chain.js.map +0 -1
  340. package/dist/solana/solana_chains.d.ts.map +0 -1
  341. package/dist/solana/solana_chains.js.map +0 -1
  342. package/dist/solana/solana_gas_pricing.d.ts.map +0 -1
  343. package/dist/solana/solana_gas_pricing.js.map +0 -1
  344. package/dist/solana/solana_token.d.ts.map +0 -1
  345. package/dist/solana/solana_token.js.map +0 -1
  346. package/dist/solana/solana_tokens.d.ts.map +0 -1
  347. package/dist/solana/solana_tokens.js.map +0 -1
  348. package/dist/solana/solana_transaction_status.d.ts.map +0 -1
  349. package/dist/solana/solana_transaction_status.js.map +0 -1
  350. package/dist/solana/unsigned_solana_transaction.d.ts.map +0 -1
  351. package/dist/solana/unsigned_solana_transaction.js.map +0 -1
  352. package/dist/token.d.ts.map +0 -1
  353. package/dist/token.js.map +0 -1
  354. package/dist/ton/index.d.ts.map +0 -1
  355. package/dist/ton/index.js.map +0 -1
  356. package/dist/ton/ton_address.d.ts.map +0 -1
  357. package/dist/ton/ton_address.js.map +0 -1
  358. package/dist/transaction_status.d.ts.map +0 -1
  359. package/dist/transaction_status.js.map +0 -1
  360. package/dist/unsigned_transaction.d.ts.map +0 -1
  361. package/dist/unsigned_transaction.js.map +0 -1
  362. package/dist/utxo/btc/btc_address.d.ts.map +0 -1
  363. package/dist/utxo/btc/btc_address.js.map +0 -1
  364. package/dist/utxo/btc/btc_chain.d.ts.map +0 -1
  365. package/dist/utxo/btc/btc_chain.js.map +0 -1
  366. package/dist/utxo/btc/btc_chains.d.ts.map +0 -1
  367. package/dist/utxo/btc/btc_chains.js.map +0 -1
  368. package/dist/utxo/btc/btc_token.d.ts.map +0 -1
  369. package/dist/utxo/btc/btc_token.js.map +0 -1
  370. package/dist/utxo/btc/index.d.ts.map +0 -1
  371. package/dist/utxo/btc/index.js.map +0 -1
  372. package/dist/utxo/btc/network_params.d.ts.map +0 -1
  373. package/dist/utxo/btc/network_params.js.map +0 -1
  374. package/dist/utxo/btc/tools/asset_outpoint.d.ts.map +0 -1
  375. package/dist/utxo/btc/tools/asset_outpoint.js.map +0 -1
  376. package/dist/utxo/btc/tools/bitcoin_core.tool.d.ts.map +0 -1
  377. package/dist/utxo/btc/tools/bitcoin_core.tool.js.map +0 -1
  378. package/dist/utxo/btc/tools/esplora.tool.d.ts.map +0 -1
  379. package/dist/utxo/btc/tools/esplora.tool.js.map +0 -1
  380. package/dist/utxo/btc/tools/inscription_index.d.ts.map +0 -1
  381. package/dist/utxo/btc/tools/inscription_index.js.map +0 -1
  382. package/dist/utxo/btc/tools/ordiscan.tool.d.ts.map +0 -1
  383. package/dist/utxo/btc/tools/ordiscan.tool.js.map +0 -1
  384. package/dist/utxo/btc/tools/rare_sat_index.d.ts.map +0 -1
  385. package/dist/utxo/btc/tools/rare_sat_index.js.map +0 -1
  386. package/dist/utxo/btc/tools/rune_index.d.ts.map +0 -1
  387. package/dist/utxo/btc/tools/rune_index.js.map +0 -1
  388. package/dist/utxo/btc/tools/unisat.tool.d.ts.map +0 -1
  389. package/dist/utxo/btc/tools/unisat.tool.js.map +0 -1
  390. package/dist/utxo/coin_selection.d.ts.map +0 -1
  391. package/dist/utxo/coin_selection.js.map +0 -1
  392. package/dist/utxo/doge/index.d.ts.map +0 -1
  393. package/dist/utxo/doge/index.js.map +0 -1
  394. package/dist/utxo/doge/network_params.d.ts.map +0 -1
  395. package/dist/utxo/doge/network_params.js.map +0 -1
  396. package/dist/utxo/ecc.d.ts.map +0 -1
  397. package/dist/utxo/ecc.js.map +0 -1
  398. package/dist/utxo/fee.d.ts.map +0 -1
  399. package/dist/utxo/fee.js.map +0 -1
  400. package/dist/utxo/index.d.ts.map +0 -1
  401. package/dist/utxo/index.js.map +0 -1
  402. package/dist/utxo/ltc/index.d.ts.map +0 -1
  403. package/dist/utxo/ltc/index.js.map +0 -1
  404. package/dist/utxo/ltc/ltc_chains.d.ts.map +0 -1
  405. package/dist/utxo/ltc/ltc_chains.js.map +0 -1
  406. package/dist/utxo/ltc/network_params.d.ts.map +0 -1
  407. package/dist/utxo/ltc/network_params.js.map +0 -1
  408. package/dist/utxo/script.d.ts.map +0 -1
  409. package/dist/utxo/script.js.map +0 -1
  410. package/dist/utxo/tools/broadcaster.d.ts.map +0 -1
  411. package/dist/utxo/tools/broadcaster.js.map +0 -1
  412. package/dist/utxo/tools/chain_tip_provider.d.ts.map +0 -1
  413. package/dist/utxo/tools/chain_tip_provider.js.map +0 -1
  414. package/dist/utxo/tools/fee_estimator.d.ts.map +0 -1
  415. package/dist/utxo/tools/fee_estimator.js.map +0 -1
  416. package/dist/utxo/tools/raw_transaction_provider.d.ts.map +0 -1
  417. package/dist/utxo/tools/raw_transaction_provider.js.map +0 -1
  418. package/dist/utxo/tools/utxo_provider.d.ts.map +0 -1
  419. package/dist/utxo/tools/utxo_provider.js.map +0 -1
  420. package/dist/utxo/unsigned_utxo_transaction.d.ts.map +0 -1
  421. package/dist/utxo/unsigned_utxo_transaction.js.map +0 -1
  422. package/dist/utxo/utxo.d.ts.map +0 -1
  423. package/dist/utxo/utxo_chain.d.ts.map +0 -1
  424. package/dist/utxo/utxo_chain.js.map +0 -1
  425. package/dist/utxo/utxo_chains.d.ts.map +0 -1
  426. package/dist/utxo/utxo_chains.js.map +0 -1
  427. package/dist/utxo/utxo_gas_pricing.d.ts.map +0 -1
  428. package/dist/utxo/utxo_gas_pricing.js.map +0 -1
  429. package/dist/utxo/utxo_network_params.d.ts.map +0 -1
  430. package/dist/utxo/utxo_network_params.js.map +0 -1
  431. package/dist/utxo/utxo_transaction_status.d.ts.map +0 -1
  432. package/dist/utxo/utxo_transaction_status.js.map +0 -1
  433. /package/dist/{abstract_gas_pricing.d.ts → esm/abstract_gas_pricing.d.ts} +0 -0
  434. /package/dist/{abstract_gas_pricing.js → esm/abstract_gas_pricing.js} +0 -0
  435. /package/dist/{address.d.ts → esm/address.d.ts} +0 -0
  436. /package/dist/{address.factory.d.ts → esm/address.factory.d.ts} +0 -0
  437. /package/dist/{address.factory.js → esm/address.factory.js} +0 -0
  438. /package/dist/{address.js → esm/address.js} +0 -0
  439. /package/dist/{address_field.decorator.d.ts → esm/address_field.decorator.d.ts} +0 -0
  440. /package/dist/{address_field.decorator.js → esm/address_field.decorator.js} +0 -0
  441. /package/dist/{chain.base.d.ts → esm/chain.base.d.ts} +0 -0
  442. /package/dist/{chain.base.js → esm/chain.base.js} +0 -0
  443. /package/dist/{chain_ids.d.ts → esm/chain_ids.d.ts} +0 -0
  444. /package/dist/{chain_ids.js → esm/chain_ids.js} +0 -0
  445. /package/dist/{errors.d.ts → esm/errors.d.ts} +0 -0
  446. /package/dist/{errors.js → esm/errors.js} +0 -0
  447. /package/dist/{evm → esm/evm}/evm_address.d.ts +0 -0
  448. /package/dist/{evm → esm/evm}/evm_address.js +0 -0
  449. /package/dist/{evm → esm/evm}/evm_chain.d.ts +0 -0
  450. /package/dist/{evm → esm/evm}/evm_chain.js +0 -0
  451. /package/dist/{evm → esm/evm}/evm_chains.d.ts +0 -0
  452. /package/dist/{evm → esm/evm}/evm_chains.js +0 -0
  453. /package/dist/{evm → esm/evm}/evm_gas_estimate.d.ts +0 -0
  454. /package/dist/{evm → esm/evm}/evm_gas_estimate.js +0 -0
  455. /package/dist/{evm → esm/evm}/evm_gas_pricing.d.ts +0 -0
  456. /package/dist/{evm → esm/evm}/evm_gas_pricing.js +0 -0
  457. /package/dist/{evm → esm/evm}/evm_token.d.ts +0 -0
  458. /package/dist/{evm → esm/evm}/evm_token.js +0 -0
  459. /package/dist/{evm → esm/evm}/evm_tokens.d.ts +0 -0
  460. /package/dist/{evm → esm/evm}/evm_tokens.js +0 -0
  461. /package/dist/{evm → esm/evm}/evm_transaction_status.d.ts +0 -0
  462. /package/dist/{evm → esm/evm}/evm_transaction_status.js +0 -0
  463. /package/dist/{evm → esm/evm}/index.d.ts +0 -0
  464. /package/dist/{evm → esm/evm}/index.js +0 -0
  465. /package/dist/{evm → esm/evm}/unsigned_evm_transaction.d.ts +0 -0
  466. /package/dist/{evm → esm/evm}/unsigned_evm_transaction.js +0 -0
  467. /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
  468. /package/dist/{index.js → esm/index.js} +0 -0
  469. /package/dist/{is_address.decorator.d.ts → esm/is_address.decorator.d.ts} +0 -0
  470. /package/dist/{is_address.decorator.js → esm/is_address.decorator.js} +0 -0
  471. /package/dist/{network_type.d.ts → esm/network_type.d.ts} +0 -0
  472. /package/dist/{network_type.js → esm/network_type.js} +0 -0
  473. /package/dist/{priority.d.ts → esm/priority.d.ts} +0 -0
  474. /package/dist/{priority.js → esm/priority.js} +0 -0
  475. /package/dist/{solana → esm/solana}/index.d.ts +0 -0
  476. /package/dist/{solana → esm/solana}/index.js +0 -0
  477. /package/dist/{solana → esm/solana}/solana_address.d.ts +0 -0
  478. /package/dist/{solana → esm/solana}/solana_address.js +0 -0
  479. /package/dist/{solana → esm/solana}/solana_chain.d.ts +0 -0
  480. /package/dist/{solana → esm/solana}/solana_chain.js +0 -0
  481. /package/dist/{solana → esm/solana}/solana_chains.d.ts +0 -0
  482. /package/dist/{solana → esm/solana}/solana_chains.js +0 -0
  483. /package/dist/{solana → esm/solana}/solana_gas_pricing.d.ts +0 -0
  484. /package/dist/{solana → esm/solana}/solana_gas_pricing.js +0 -0
  485. /package/dist/{solana → esm/solana}/solana_token.d.ts +0 -0
  486. /package/dist/{solana → esm/solana}/solana_token.js +0 -0
  487. /package/dist/{solana → esm/solana}/solana_tokens.d.ts +0 -0
  488. /package/dist/{solana → esm/solana}/solana_tokens.js +0 -0
  489. /package/dist/{solana → esm/solana}/solana_transaction_status.d.ts +0 -0
  490. /package/dist/{solana → esm/solana}/solana_transaction_status.js +0 -0
  491. /package/dist/{solana → esm/solana}/unsigned_solana_transaction.d.ts +0 -0
  492. /package/dist/{solana → esm/solana}/unsigned_solana_transaction.js +0 -0
  493. /package/dist/{token.d.ts → esm/token.d.ts} +0 -0
  494. /package/dist/{token.js → esm/token.js} +0 -0
  495. /package/dist/{ton → esm/ton}/index.d.ts +0 -0
  496. /package/dist/{ton → esm/ton}/index.js +0 -0
  497. /package/dist/{ton → esm/ton}/ton_address.d.ts +0 -0
  498. /package/dist/{ton → esm/ton}/ton_address.js +0 -0
  499. /package/dist/{transaction_status.d.ts → esm/transaction_status.d.ts} +0 -0
  500. /package/dist/{transaction_status.js → esm/transaction_status.js} +0 -0
  501. /package/dist/{unsigned_transaction.d.ts → esm/unsigned_transaction.d.ts} +0 -0
  502. /package/dist/{unsigned_transaction.js → esm/unsigned_transaction.js} +0 -0
  503. /package/dist/{utxo → esm/utxo}/btc/btc_address.d.ts +0 -0
  504. /package/dist/{utxo → esm/utxo}/btc/btc_address.js +0 -0
  505. /package/dist/{utxo → esm/utxo}/btc/btc_chain.d.ts +0 -0
  506. /package/dist/{utxo → esm/utxo}/btc/btc_chain.js +0 -0
  507. /package/dist/{utxo → esm/utxo}/btc/btc_chains.d.ts +0 -0
  508. /package/dist/{utxo → esm/utxo}/btc/btc_chains.js +0 -0
  509. /package/dist/{utxo → esm/utxo}/btc/btc_token.d.ts +0 -0
  510. /package/dist/{utxo → esm/utxo}/btc/btc_token.js +0 -0
  511. /package/dist/{utxo → esm/utxo}/btc/index.d.ts +0 -0
  512. /package/dist/{utxo → esm/utxo}/btc/index.js +0 -0
  513. /package/dist/{utxo → esm/utxo}/btc/network_params.d.ts +0 -0
  514. /package/dist/{utxo → esm/utxo}/btc/network_params.js +0 -0
  515. /package/dist/{utxo → esm/utxo}/btc/tools/asset_outpoint.d.ts +0 -0
  516. /package/dist/{utxo → esm/utxo}/btc/tools/asset_outpoint.js +0 -0
  517. /package/dist/{utxo → esm/utxo}/btc/tools/bitcoin_core.tool.d.ts +0 -0
  518. /package/dist/{utxo → esm/utxo}/btc/tools/bitcoin_core.tool.js +0 -0
  519. /package/dist/{utxo → esm/utxo}/btc/tools/esplora.tool.d.ts +0 -0
  520. /package/dist/{utxo → esm/utxo}/btc/tools/esplora.tool.js +0 -0
  521. /package/dist/{utxo → esm/utxo}/btc/tools/inscription_index.d.ts +0 -0
  522. /package/dist/{utxo → esm/utxo}/btc/tools/inscription_index.js +0 -0
  523. /package/dist/{utxo → esm/utxo}/btc/tools/ordiscan.tool.d.ts +0 -0
  524. /package/dist/{utxo → esm/utxo}/btc/tools/ordiscan.tool.js +0 -0
  525. /package/dist/{utxo → esm/utxo}/btc/tools/rare_sat_index.d.ts +0 -0
  526. /package/dist/{utxo → esm/utxo}/btc/tools/rare_sat_index.js +0 -0
  527. /package/dist/{utxo → esm/utxo}/btc/tools/rune_index.d.ts +0 -0
  528. /package/dist/{utxo → esm/utxo}/btc/tools/rune_index.js +0 -0
  529. /package/dist/{utxo → esm/utxo}/btc/tools/unisat.tool.d.ts +0 -0
  530. /package/dist/{utxo → esm/utxo}/btc/tools/unisat.tool.js +0 -0
  531. /package/dist/{utxo → esm/utxo}/coin_selection.d.ts +0 -0
  532. /package/dist/{utxo → esm/utxo}/coin_selection.js +0 -0
  533. /package/dist/{utxo → esm/utxo}/doge/doge_chains.d.ts +0 -0
  534. /package/dist/{utxo → esm/utxo}/doge/doge_chains.js +0 -0
  535. /package/dist/{utxo → esm/utxo}/doge/index.d.ts +0 -0
  536. /package/dist/{utxo → esm/utxo}/doge/index.js +0 -0
  537. /package/dist/{utxo → esm/utxo}/doge/network_params.d.ts +0 -0
  538. /package/dist/{utxo → esm/utxo}/doge/network_params.js +0 -0
  539. /package/dist/{utxo → esm/utxo}/ecc.d.ts +0 -0
  540. /package/dist/{utxo → esm/utxo}/ecc.js +0 -0
  541. /package/dist/{utxo → esm/utxo}/fee.d.ts +0 -0
  542. /package/dist/{utxo → esm/utxo}/fee.js +0 -0
  543. /package/dist/{utxo → esm/utxo}/index.d.ts +0 -0
  544. /package/dist/{utxo → esm/utxo}/index.js +0 -0
  545. /package/dist/{utxo → esm/utxo}/ltc/index.d.ts +0 -0
  546. /package/dist/{utxo → esm/utxo}/ltc/index.js +0 -0
  547. /package/dist/{utxo → esm/utxo}/ltc/ltc_chains.d.ts +0 -0
  548. /package/dist/{utxo → esm/utxo}/ltc/ltc_chains.js +0 -0
  549. /package/dist/{utxo → esm/utxo}/ltc/network_params.d.ts +0 -0
  550. /package/dist/{utxo → esm/utxo}/ltc/network_params.js +0 -0
  551. /package/dist/{utxo → esm/utxo}/script.d.ts +0 -0
  552. /package/dist/{utxo → esm/utxo}/script.js +0 -0
  553. /package/dist/{utxo → esm/utxo}/tools/broadcaster.d.ts +0 -0
  554. /package/dist/{utxo → esm/utxo}/tools/broadcaster.js +0 -0
  555. /package/dist/{utxo → esm/utxo}/tools/chain_tip_provider.d.ts +0 -0
  556. /package/dist/{utxo → esm/utxo}/tools/chain_tip_provider.js +0 -0
  557. /package/dist/{utxo → esm/utxo}/tools/fee_estimator.d.ts +0 -0
  558. /package/dist/{utxo → esm/utxo}/tools/fee_estimator.js +0 -0
  559. /package/dist/{utxo → esm/utxo}/tools/raw_transaction_provider.d.ts +0 -0
  560. /package/dist/{utxo → esm/utxo}/tools/raw_transaction_provider.js +0 -0
  561. /package/dist/{utxo → esm/utxo}/tools/utxo_provider.d.ts +0 -0
  562. /package/dist/{utxo → esm/utxo}/tools/utxo_provider.js +0 -0
  563. /package/dist/{utxo → esm/utxo}/unsigned_utxo_transaction.d.ts +0 -0
  564. /package/dist/{utxo → esm/utxo}/unsigned_utxo_transaction.js +0 -0
  565. /package/dist/{utxo → esm/utxo}/utxo.d.ts +0 -0
  566. /package/dist/{utxo → esm/utxo}/utxo.js +0 -0
  567. /package/dist/{utxo → esm/utxo}/utxo_chain.d.ts +0 -0
  568. /package/dist/{utxo → esm/utxo}/utxo_chain.js +0 -0
  569. /package/dist/{utxo → esm/utxo}/utxo_chains.d.ts +0 -0
  570. /package/dist/{utxo → esm/utxo}/utxo_chains.js +0 -0
  571. /package/dist/{utxo → esm/utxo}/utxo_gas_pricing.d.ts +0 -0
  572. /package/dist/{utxo → esm/utxo}/utxo_gas_pricing.js +0 -0
  573. /package/dist/{utxo → esm/utxo}/utxo_network_params.d.ts +0 -0
  574. /package/dist/{utxo → esm/utxo}/utxo_network_params.js +0 -0
  575. /package/dist/{utxo → esm/utxo}/utxo_transaction_status.d.ts +0 -0
  576. /package/dist/{utxo → esm/utxo}/utxo_transaction_status.js +0 -0
@@ -0,0 +1,708 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SolanaChain = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const spl_token_1 = require("@solana/spl-token");
6
+ const chain_base_ts_1 = require("../chain.base.js");
7
+ const errors_ts_1 = require("../errors.js");
8
+ const network_type_ts_1 = require("../network_type.js");
9
+ const priority_ts_1 = require("../priority.js");
10
+ const transaction_status_ts_1 = require("../transaction_status.js");
11
+ const solana_transaction_status_ts_1 = require("./solana_transaction_status.js");
12
+ const solana_address_ts_1 = require("./solana_address.js");
13
+ const solana_token_ts_1 = require("./solana_token.js");
14
+ const unsigned_solana_transaction_ts_1 = require("./unsigned_solana_transaction.js");
15
+ const DEFAULT_COMPUTE_UNIT_LIMIT = 200_000;
16
+ /** Percentile (0..1) of recent prioritization fees picked per Priority. */
17
+ const SOL_PRIORITY_PERCENTILE = {
18
+ [priority_ts_1.Priority.SLOW]: 0.25,
19
+ [priority_ts_1.Priority.NORMAL]: 0.5,
20
+ [priority_ts_1.Priority.FAST]: 0.9,
21
+ };
22
+ /**
23
+ * Solana is account-based but very different from EVM (see docs/solana.md). Key choices made
24
+ * for depositron:
25
+ * - Transfers always build a `VersionedTransaction` (MessageV0) — legacy transactions are
26
+ * deprecated and can't address account-lookup tables for fee reduction.
27
+ * - The fee payer is always the sender (no relayer pattern here).
28
+ * - SPL transfers use `transferChecked` (which asserts the recipient mint matches the
29
+ * declared mint, defeating the entire class of "wrong-token-decimals" attacks).
30
+ * - When the recipient doesn't have an ATA for the mint, we *prepend* a create-ATA
31
+ * instruction paid by the sender. This costs ~2039 lamports of rent-exempt deposit.
32
+ * - We do NOT consult a curated registry to determine SPL vs Token-2022 —
33
+ * instead we read the mint account owner at build time. That's one RPC per transfer but
34
+ * it's authoritative.
35
+ */
36
+ class SolanaChain extends chain_base_ts_1.Chain {
37
+ defaultRpcUrl;
38
+ rpcUrl;
39
+ legacyRpcEnvNames;
40
+ explorerClusterSuffix;
41
+ chainAgnosticGenesisHash;
42
+ _nativeToken;
43
+ _connection = null;
44
+ constructor(init) {
45
+ super(init.chainId, init.name, network_type_ts_1.NetworkType.SOLANA, init.blockTimeSeconds, init.nativeSymbol, init.explorerBaseUrl);
46
+ this.defaultRpcUrl = init.defaultRpcUrl;
47
+ this.rpcUrl = init.rpcUrl;
48
+ this.legacyRpcEnvNames = init.legacyRpcEnvNames ?? [];
49
+ this.explorerClusterSuffix = init.explorerClusterSuffix ?? '';
50
+ this.chainAgnosticGenesisHash = init.chainAgnosticGenesisHash;
51
+ this._nativeToken = solana_token_ts_1.SolanaToken.native(init.chainId, init.nativeSymbol, init.nativeDecimals ?? 9);
52
+ (0, network_type_ts_1.registerNonEvmChain)(init.chainId, network_type_ts_1.NetworkType.SOLANA);
53
+ }
54
+ get nativeToken() {
55
+ return this._nativeToken;
56
+ }
57
+ getConnection() {
58
+ if (this._connection)
59
+ return this._connection;
60
+ const rpcUrl = this.readRpcUrl();
61
+ this._connection = new web3_js_1.Connection(rpcUrl, { commitment: 'confirmed' });
62
+ return this._connection;
63
+ }
64
+ /**
65
+ * Network-aware priority fee suggestion in microlamports per compute unit.
66
+ * Samples `getRecentPrioritizationFees({ lockedWritableAccounts: [] })` (cluster-wide, ~150 most recent slots) and
67
+ * picks a percentile per priority:
68
+ * - SLOW = p25
69
+ * - NORMAL = p50
70
+ * - FAST = p90
71
+ * Returns 0 if the cluster has been so quiet that the chosen percentile is 0 (legitimate
72
+ * outcome on devnet / off-peak mainnet). Caller plugs this into
73
+ * `ComputeBudgetProgram.setComputeUnitPrice({ microLamports })`.
74
+ */
75
+ async suggestPriorityFeeMicroLamports(priority) {
76
+ const samples = await this.getConnection().getRecentPrioritizationFees({
77
+ lockedWritableAccounts: [],
78
+ });
79
+ const fees = samples
80
+ .map((s) => s.prioritizationFee)
81
+ .filter((f) => Number.isFinite(f) && f >= 0)
82
+ .sort((a, b) => a - b);
83
+ if (fees.length === 0)
84
+ return 0;
85
+ const percentile = SOL_PRIORITY_PERCENTILE[priority];
86
+ const idx = Math.min(fees.length - 1, Math.floor((fees.length - 1) * percentile));
87
+ return fees[idx];
88
+ }
89
+ /**
90
+ * Env var name for a Solana chain by chain id — mirrors Python's
91
+ * `SolanaChain.rpc_url_env_for_chain_id` (impl/solana/base.py:421-423)
92
+ * exactly, including the signed chainId. Shell operators must set via
93
+ * dotenv / docker / k8s since `SOLANA_-2000_RPC_URL` is not a settable
94
+ * name in sh/bash/zsh.
95
+ */
96
+ static rpcUrlEnvForChainId(chainId) {
97
+ return `SOLANA_${chainId}_RPC_URL`;
98
+ }
99
+ /**
100
+ * Resolution precedence, mirrors omnichain-py/impl/solana/base.py:424-434
101
+ * plus a TS-side legacy fallback for consumers with pre-v0 env-var names:
102
+ * 1. constructor `rpcUrl`
103
+ * 2. env `<NAME_UPPERCASE_UNDERSCORED>_RPC_URL`
104
+ * 3. env `SOLANA_<chainId>_RPC_URL` (Python parity — signed)
105
+ * 4. env from `legacyRpcEnvNames` (if configured — e.g. mainnet checks
106
+ * the pre-rename `SOLANA_RPC_URL` here)
107
+ * 5. `defaultRpcUrl` (never throws — public cluster)
108
+ */
109
+ readRpcUrl() {
110
+ if (this.rpcUrl && this.rpcUrl.trim().length > 0)
111
+ return this.rpcUrl.trim();
112
+ const env = globalThis.process?.env;
113
+ const candidates = [
114
+ this.name.replace(/ /g, '_').toUpperCase() + '_RPC_URL',
115
+ SolanaChain.rpcUrlEnvForChainId(this.chainId),
116
+ ...this.legacyRpcEnvNames,
117
+ ];
118
+ for (const key of candidates) {
119
+ const v = env?.[key];
120
+ if (v && v.trim().length > 0)
121
+ return v.trim();
122
+ }
123
+ return this.defaultRpcUrl;
124
+ }
125
+ getWalletExplorerUrl(address) {
126
+ return `${this.explorerBaseUrl}/account/${address}${this.explorerClusterSuffix}`;
127
+ }
128
+ getTokenExplorerUrl(tokenIdentifier) {
129
+ if (!tokenIdentifier) {
130
+ return this.explorerBaseUrl + this.explorerClusterSuffix;
131
+ }
132
+ return `${this.explorerBaseUrl}/token/${tokenIdentifier}${this.explorerClusterSuffix}`;
133
+ }
134
+ getTransactionExplorerUrl(txHash) {
135
+ return `${this.explorerBaseUrl}/tx/${txHash}${this.explorerClusterSuffix}`;
136
+ }
137
+ validateAddress(raw) {
138
+ try {
139
+ new solana_address_ts_1.SolanaAddress(raw);
140
+ return true;
141
+ }
142
+ catch {
143
+ return false;
144
+ }
145
+ }
146
+ validateTokenIdentifier(raw) {
147
+ if (raw === undefined)
148
+ return true; // native SOL
149
+ return this.validateAddress(raw);
150
+ }
151
+ async getBalance(owner, tokenIdentifier) {
152
+ if (!this.validateAddress(owner)) {
153
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `Invalid Solana address: ${owner}`, {
154
+ chainId: this.chainId,
155
+ address: owner,
156
+ });
157
+ }
158
+ const connection = this.getConnection();
159
+ const ownerPk = new web3_js_1.PublicKey(owner);
160
+ try {
161
+ if (tokenIdentifier === undefined) {
162
+ return BigInt(await connection.getBalance(ownerPk));
163
+ }
164
+ if (!this.validateAddress(tokenIdentifier)) {
165
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidTokenIdentifier, `Invalid Solana mint: ${tokenIdentifier}`, { chainId: this.chainId, identifier: tokenIdentifier });
166
+ }
167
+ const mintPk = new web3_js_1.PublicKey(tokenIdentifier);
168
+ const programId = await this.resolveTokenProgramId(mintPk);
169
+ const ata = (0, spl_token_1.getAssociatedTokenAddressSync)(mintPk, ownerPk, false, programId);
170
+ try {
171
+ const acct = await (0, spl_token_1.getAccount)(connection, ata, undefined, programId);
172
+ return acct.amount;
173
+ }
174
+ catch {
175
+ // No ATA → balance 0.
176
+ return 0n;
177
+ }
178
+ }
179
+ catch (err) {
180
+ if (err instanceof errors_ts_1.ChainError)
181
+ throw err;
182
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.RpcError, `Failed to read Solana balance for ${owner}/${tokenIdentifier ?? 'NATIVE'}: ${err.message}`, { chainId: this.chainId, address: owner, identifier: tokenIdentifier }, err);
183
+ }
184
+ }
185
+ async createTransferUnsignedTransaction(req) {
186
+ if (!req.from) {
187
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, 'Solana transfers require an explicit `from` (no implicit signer)', { chainId: this.chainId });
188
+ }
189
+ if (!this.validateAddress(req.from)) {
190
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `Invalid sender: ${req.from}`, {
191
+ chainId: this.chainId,
192
+ address: req.from,
193
+ });
194
+ }
195
+ if (!this.validateAddress(req.to)) {
196
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `Invalid recipient: ${req.to}`, {
197
+ chainId: this.chainId,
198
+ address: req.to,
199
+ });
200
+ }
201
+ if (!this.validateTokenIdentifier(req.tokenIdentifier)) {
202
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidTokenIdentifier, `Invalid token identifier: ${req.tokenIdentifier}`, { chainId: this.chainId, identifier: req.tokenIdentifier });
203
+ }
204
+ // gasPricing not yet consumed by Solana builder (Phase 2 follow-up);
205
+ // reject rather than silently ignore.
206
+ if (req.gasPricing !== undefined) {
207
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, 'CreateTransferRequest.gasPricing is not yet consumed by SolanaChain (Phase 2 follow-up). Use `priorityFeeMicroLamportsPerCu` / `computeUnitLimit` on SolanaTransferOptions for now.', { chainId: this.chainId });
208
+ }
209
+ // isFullBalance requires a base-fee + rent-exempt reserve before
210
+ // it can be safely wired — sending all lamports leaves 0 for the
211
+ // 5000-lamport base fee (and ATA rent when feePayer === from on
212
+ // the SPL path). Deferred to a follow-up card.
213
+ if (req.isFullBalance === true) {
214
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, 'CreateTransferRequest.isFullBalance is not yet supported on SolanaChain — pass `amount` or `amountHr` explicitly.', { chainId: this.chainId });
215
+ }
216
+ // Only fetch decimals when amountHr is the input form — avoids the
217
+ // extra getMint RPC on every bigint-amount transfer. Native path
218
+ // uses SDK-declared decimals; SPL path uses resolveMintDecimals
219
+ // (which already throws on RPC failure — no defensive fallback).
220
+ const tokenDecimals = req.amountHr !== undefined
221
+ ? req.tokenIdentifier === undefined
222
+ ? this._nativeToken.decimals
223
+ : await this.resolveMintDecimals(new web3_js_1.PublicKey(req.tokenIdentifier))
224
+ : 0;
225
+ const resolvedAmount = (0, chain_base_ts_1.resolveTransferAmount)(req, tokenDecimals);
226
+ const amountMr = resolvedAmount.kind === 'exact' ? resolvedAmount.amountMr : 0n;
227
+ if (amountMr <= 0n) {
228
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `Transfer amount must be positive (got ${amountMr})`, { chainId: this.chainId });
229
+ }
230
+ if (req.feePayer !== undefined && !this.validateAddress(req.feePayer)) {
231
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `Invalid feePayer: ${req.feePayer}`, {
232
+ chainId: this.chainId,
233
+ address: req.feePayer,
234
+ });
235
+ }
236
+ const connection = this.getConnection();
237
+ const fromPk = new web3_js_1.PublicKey(req.from);
238
+ const toPk = new web3_js_1.PublicKey(req.to);
239
+ const feePayerAddress = req.feePayer ?? req.from;
240
+ const feePayerPk = new web3_js_1.PublicKey(feePayerAddress);
241
+ const instructions = [];
242
+ if (req.computeUnitLimit !== undefined || req.priorityFeeMicroLamportsPerCu !== undefined) {
243
+ instructions.push(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
244
+ units: req.computeUnitLimit ?? DEFAULT_COMPUTE_UNIT_LIMIT,
245
+ }));
246
+ if (req.priorityFeeMicroLamportsPerCu !== undefined) {
247
+ instructions.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
248
+ microLamports: req.priorityFeeMicroLamportsPerCu,
249
+ }));
250
+ }
251
+ }
252
+ if (req.tokenIdentifier === undefined) {
253
+ instructions.push(web3_js_1.SystemProgram.transfer({
254
+ fromPubkey: fromPk,
255
+ toPubkey: toPk,
256
+ lamports: amountMr,
257
+ }));
258
+ }
259
+ else {
260
+ const mintPk = new web3_js_1.PublicKey(req.tokenIdentifier);
261
+ const programId = await this.resolveTokenProgramId(mintPk);
262
+ // If amountHr wasn't the input form, tokenDecimals is still 0 and
263
+ // we haven't fetched the mint yet — do it now for the transfer-
264
+ // checked instruction (which requires the real decimals).
265
+ const decimals = tokenDecimals > 0 ? tokenDecimals : await this.resolveMintDecimals(mintPk);
266
+ const sourceAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mintPk, fromPk, false, programId);
267
+ const destAta = (0, spl_token_1.getAssociatedTokenAddressSync)(mintPk, toPk, false, programId);
268
+ // Create the destination ATA when missing — the fee payer pays rent.
269
+ const destInfo = await connection.getAccountInfo(destAta);
270
+ if (!destInfo) {
271
+ instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(feePayerPk, destAta, toPk, mintPk, programId));
272
+ }
273
+ instructions.push((0, spl_token_1.createTransferCheckedInstruction)(sourceAta, mintPk, destAta, fromPk, amountMr, decimals, [], programId));
274
+ }
275
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('finalized');
276
+ const message = web3_js_1.MessageV0.compile({
277
+ payerKey: feePayerPk,
278
+ instructions,
279
+ recentBlockhash: blockhash,
280
+ });
281
+ return new unsigned_solana_transaction_ts_1.UnsignedSolanaTransaction({
282
+ chainId: this.chainId,
283
+ transaction: new web3_js_1.VersionedTransaction(message),
284
+ feePayer: feePayerAddress,
285
+ recentBlockhash: blockhash,
286
+ lastValidBlockHeight,
287
+ instructions,
288
+ });
289
+ }
290
+ /**
291
+ * Wraps a caller-supplied list of program instructions into a fully-formed
292
+ * UnsignedSolanaTransaction. Used by depositron's SOL_INSTRUCTIONS action type to support
293
+ * arbitrary program calls (staking, swaps, custom programs) without the SDK having to
294
+ * understand the instruction semantics. The SDK still owns the envelope: CU limit + price,
295
+ * MessageV0 compilation, fresh blockhash, VersionedTransaction wrapping.
296
+ *
297
+ * Caller is responsible for: instruction correctness, signer-account constraints (only the
298
+ * single key the caller will sign with — typically the vault key — can be flagged as signer),
299
+ * ATA creation (if any instruction touches an ATA that doesn't exist yet), and decimals
300
+ * validation (no automatic `transferChecked` fallback here).
301
+ */
302
+ async createInstructionsUnsignedTransaction(req) {
303
+ if (!req.from || !this.validateAddress(req.from)) {
304
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `Invalid sender: ${req.from}`, {
305
+ chainId: this.chainId,
306
+ address: req.from,
307
+ });
308
+ }
309
+ if (req.feePayer !== undefined && !this.validateAddress(req.feePayer)) {
310
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `Invalid feePayer: ${req.feePayer}`, {
311
+ chainId: this.chainId,
312
+ address: req.feePayer,
313
+ });
314
+ }
315
+ if (!Array.isArray(req.instructions) || req.instructions.length === 0) {
316
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, 'SolanaChain.createInstructionsUnsignedTransaction requires at least one instruction', { chainId: this.chainId });
317
+ }
318
+ const feePayerAddress = req.feePayer ?? req.from;
319
+ const feePayerPk = new web3_js_1.PublicKey(feePayerAddress);
320
+ const allIxs = [];
321
+ if (req.computeUnitLimit !== undefined || req.priorityFeeMicroLamportsPerCu !== undefined) {
322
+ allIxs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
323
+ units: req.computeUnitLimit ?? DEFAULT_COMPUTE_UNIT_LIMIT,
324
+ }));
325
+ if (req.priorityFeeMicroLamportsPerCu !== undefined) {
326
+ allIxs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
327
+ microLamports: req.priorityFeeMicroLamportsPerCu,
328
+ }));
329
+ }
330
+ }
331
+ for (const ix of req.instructions)
332
+ allIxs.push(ix);
333
+ const connection = this.getConnection();
334
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('finalized');
335
+ const message = web3_js_1.MessageV0.compile({
336
+ payerKey: feePayerPk,
337
+ instructions: allIxs,
338
+ recentBlockhash: blockhash,
339
+ });
340
+ return new unsigned_solana_transaction_ts_1.UnsignedSolanaTransaction({
341
+ chainId: this.chainId,
342
+ transaction: new web3_js_1.VersionedTransaction(message),
343
+ feePayer: feePayerAddress,
344
+ recentBlockhash: blockhash,
345
+ lastValidBlockHeight,
346
+ instructions: allIxs,
347
+ });
348
+ }
349
+ /**
350
+ * Returns a fresh UnsignedSolanaTransaction with the same instructions but a newly-fetched
351
+ * blockhash. Use when a previously-built tx couldn't broadcast inside its blockhash window
352
+ * (~60s on mainnet) — Solana drops txs whose blockhash has expired. Caller must re-sign:
353
+ * the new signed message has a different recent_blockhash byte sequence, so any existing
354
+ * signature is invalid.
355
+ */
356
+ async refreshBlockhash(unsigned) {
357
+ const connection = this.getConnection();
358
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('finalized');
359
+ if (blockhash === unsigned.recentBlockhash)
360
+ return unsigned;
361
+ const message = web3_js_1.MessageV0.compile({
362
+ payerKey: unsigned.feePayerPubkey,
363
+ instructions: unsigned.instructions,
364
+ recentBlockhash: blockhash,
365
+ });
366
+ return new unsigned_solana_transaction_ts_1.UnsignedSolanaTransaction({
367
+ chainId: unsigned.chainId,
368
+ transaction: new web3_js_1.VersionedTransaction(message),
369
+ feePayer: unsigned.feePayer,
370
+ recentBlockhash: blockhash,
371
+ lastValidBlockHeight,
372
+ instructions: unsigned.instructions,
373
+ });
374
+ }
375
+ /**
376
+ * Simulates the tx and right-sizes its setComputeUnitLimit instruction (10% headroom).
377
+ * Lowers priority-fee cost because the fee = CU price × CU limit; oversized limits pay for
378
+ * unused compute. Returns the unsigned untouched if it has no CU-limit ix or simulation didn't
379
+ * report unitsConsumed. Throws ChainError(SimulationFailed) when the sim returns `err`.
380
+ */
381
+ async estimateAndApplyCu(unsigned) {
382
+ const connection = this.getConnection();
383
+ const sim = await connection.simulateTransaction(unsigned.transaction, {
384
+ sigVerify: false,
385
+ replaceRecentBlockhash: true,
386
+ commitment: 'confirmed',
387
+ });
388
+ if (sim.value.err) {
389
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `Solana simulation rejected the tx: ${JSON.stringify(sim.value.err)}`, { chainId: this.chainId });
390
+ }
391
+ const consumed = sim.value.unitsConsumed;
392
+ if (!consumed)
393
+ return unsigned;
394
+ const newLimit = Math.ceil(consumed * 1.1);
395
+ const setLimitIxIndex = unsigned.instructions.findIndex((ix) => ix.programId.equals(web3_js_1.ComputeBudgetProgram.programId) &&
396
+ // setComputeUnitLimit ix discriminator is 0x02 in the first data byte.
397
+ ix.data.length >= 1 &&
398
+ ix.data[0] === 0x02);
399
+ if (setLimitIxIndex === -1)
400
+ return unsigned;
401
+ const newInstructions = [...unsigned.instructions];
402
+ newInstructions[setLimitIxIndex] = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
403
+ units: newLimit,
404
+ });
405
+ const message = web3_js_1.MessageV0.compile({
406
+ payerKey: unsigned.feePayerPubkey,
407
+ instructions: newInstructions,
408
+ recentBlockhash: unsigned.recentBlockhash,
409
+ });
410
+ return new unsigned_solana_transaction_ts_1.UnsignedSolanaTransaction({
411
+ chainId: unsigned.chainId,
412
+ transaction: new web3_js_1.VersionedTransaction(message),
413
+ feePayer: unsigned.feePayer,
414
+ recentBlockhash: unsigned.recentBlockhash,
415
+ lastValidBlockHeight: unsigned.lastValidBlockHeight,
416
+ instructions: newInstructions,
417
+ });
418
+ }
419
+ /** Whether the given error came from a preflight simulation rejection (vs network/transport). */
420
+ static isSimulationError(err) {
421
+ if (err instanceof errors_ts_1.ChainError && err.kind === errors_ts_1.ChainErrorKinds.InvalidArgument)
422
+ return true;
423
+ const msg = err?.message ?? '';
424
+ return /simulation failed|transaction simulation failed/i.test(msg);
425
+ }
426
+ /** Whether the given error indicates the tx's blockhash has expired and a refresh is needed. */
427
+ static isBlockhashExpiredError(err) {
428
+ const msg = err?.message ?? '';
429
+ return /blockhash not found|expired blockhash|blockhash.*expired/i.test(msg);
430
+ }
431
+ async getTransactionStatus(txHash) {
432
+ const connection = this.getConnection();
433
+ // Best-effort read of the current rpc URL for message/cause scrubbing.
434
+ // readRpcUrl throws when nothing is configured; there'd be no
435
+ // network call in that case, but defensive null keeps the sanitizer
436
+ // total.
437
+ let scrubUrl = null;
438
+ try {
439
+ scrubUrl = this.readRpcUrl();
440
+ }
441
+ catch {
442
+ scrubUrl = null;
443
+ }
444
+ let tx;
445
+ try {
446
+ tx = await connection.getTransaction(txHash, {
447
+ commitment: 'confirmed',
448
+ maxSupportedTransactionVersion: 0,
449
+ });
450
+ }
451
+ catch (err) {
452
+ const rawMsg = err instanceof Error ? err.message : String(err);
453
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.RpcError, (0, errors_ts_1.sanitizeMessage)(`Failed to read Solana tx ${txHash}: ${rawMsg}`, scrubUrl), { chainId: this.chainId, txHash }, (0, errors_ts_1.sanitizeCause)(err, scrubUrl));
454
+ }
455
+ if (!tx) {
456
+ // Full tx not fetchable; fall back to signature status. Consume BOTH
457
+ // fields (`confirmationStatus` + `err`) — the previous fix that
458
+ // always returned Pending on settled-but-unfetchable let a settled-
459
+ // FAILED tx poll indefinitely.
460
+ let sig;
461
+ try {
462
+ sig = await connection.getSignatureStatus(txHash, { searchTransactionHistory: true });
463
+ }
464
+ catch (err) {
465
+ const rawMsg = err instanceof Error ? err.message : String(err);
466
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.RpcError, (0, errors_ts_1.sanitizeMessage)(`Failed to read Solana signature status ${txHash}: ${rawMsg}`, scrubUrl), { chainId: this.chainId, txHash }, (0, errors_ts_1.sanitizeCause)(err, scrubUrl));
467
+ }
468
+ if (!sig || !sig.value)
469
+ return solana_transaction_status_ts_1.SolanaTransactionStatus.notFound(this.chainId);
470
+ const settled = sig.value.confirmationStatus === 'finalized' ||
471
+ sig.value.confirmationStatus === 'confirmed';
472
+ if (settled && sig.value.err) {
473
+ // Fees are not reconstructable from a sig-status only — factory
474
+ // now accepts fees: null for exactly this case.
475
+ return solana_transaction_status_ts_1.SolanaTransactionStatus.failed({
476
+ chainId: this.chainId,
477
+ inclusionAt: null,
478
+ error: { code: 'REVERTED', reason: JSON.stringify(sig.value.err) },
479
+ fees: null,
480
+ });
481
+ }
482
+ // settled-Success without a fetchable body OR still propagating —
483
+ // keep polling. NotFound here would misreport a settled deposit.
484
+ return solana_transaction_status_ts_1.SolanaTransactionStatus.pending(this.chainId);
485
+ }
486
+ if (!tx.meta) {
487
+ // A returned tx without meta is a valid RPC response shape (some
488
+ // very old txs or unusual nodes). Report Pending so consumers keep
489
+ // polling rather than throwing from a status read; matches the
490
+ // _decodeBalanceChanges guard at the same file.
491
+ return solana_transaction_status_ts_1.SolanaTransactionStatus.pending(this.chainId);
492
+ }
493
+ const accounts = tx.transaction.message.staticAccountKeys.map((k) => k.toBase58());
494
+ const feePayer = accounts[0] ?? '';
495
+ if (feePayer.length === 0) {
496
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.TransactionDecodeFailed, `Solana tx ${txHash} has no fee_payer account`, { chainId: this.chainId, txHash });
497
+ }
498
+ const feeLamports = BigInt(tx.meta.fee);
499
+ const rawCu = tx.meta.computeUnitsConsumed;
500
+ const computeUnitsConsumed = rawCu === undefined || rawCu === null ? null : BigInt(rawCu);
501
+ const preLamports = BigInt(tx.meta.preBalances?.[0] ?? 0);
502
+ const postLamports = BigInt(tx.meta.postBalances?.[0] ?? 0);
503
+ const fees = new solana_transaction_status_ts_1.SolanaTransactionFees({
504
+ feePayer,
505
+ feeLamports,
506
+ computeUnitsConsumed,
507
+ netLamportsChangeByFeePayer: postLamports - preLamports,
508
+ });
509
+ const inclusionAt = tx.blockTime ? new Date(tx.blockTime * 1000) : null;
510
+ if (tx.meta.err) {
511
+ return solana_transaction_status_ts_1.SolanaTransactionStatus.failed({
512
+ chainId: this.chainId,
513
+ inclusionAt,
514
+ error: { code: 'REVERTED', reason: JSON.stringify(tx.meta.err) },
515
+ fees,
516
+ });
517
+ }
518
+ // Wrap the decoder so a malformed uiTokenAmount.amount / pre/postBalance
519
+ // (BigInt(...) throws SyntaxError on non-numeric strings) surfaces as
520
+ // ChainError(TransactionDecodeFailed) rather than a raw SyntaxError.
521
+ // Mirrors evm_chain.ts:decodeBalanceChanges catch.
522
+ let balanceChanges;
523
+ try {
524
+ balanceChanges = this._decodeBalanceChanges(tx);
525
+ }
526
+ catch (err) {
527
+ if (err instanceof errors_ts_1.ChainError)
528
+ throw err;
529
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.TransactionDecodeFailed, `Failed to decode Solana tx ${txHash}: ${err instanceof Error ? err.message : String(err)}`, { chainId: this.chainId, txHash }, err instanceof Error ? err : undefined);
530
+ }
531
+ return solana_transaction_status_ts_1.SolanaTransactionStatus.successful({
532
+ chainId: this.chainId,
533
+ inclusionAt,
534
+ balanceChanges,
535
+ fees,
536
+ });
537
+ }
538
+ async getChainTipHeight() {
539
+ return this.getConnection().getSlot('confirmed');
540
+ }
541
+ /**
542
+ * Resolves the token program owner for a given mint. Token-2022 mints are owned by
543
+ * TOKEN_2022_PROGRAM_ID; classic SPL by TOKEN_PROGRAM_ID. Required for `transferChecked`
544
+ * and ATA derivation.
545
+ */
546
+ async resolveTokenProgramId(mint) {
547
+ const connection = this.getConnection();
548
+ const info = await connection.getAccountInfo(mint);
549
+ if (!info) {
550
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidTokenIdentifier, `Mint ${mint.toBase58()} not found on chain`, { chainId: this.chainId, identifier: mint.toBase58() });
551
+ }
552
+ const owner = info.owner.toBase58();
553
+ if (owner === spl_token_1.TOKEN_PROGRAM_ID.toBase58())
554
+ return spl_token_1.TOKEN_PROGRAM_ID;
555
+ if (owner === spl_token_1.TOKEN_2022_PROGRAM_ID.toBase58())
556
+ return spl_token_1.TOKEN_2022_PROGRAM_ID;
557
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidTokenIdentifier, `Mint ${mint.toBase58()} is owned by ${owner}, not an SPL Token program`, { chainId: this.chainId, identifier: mint.toBase58() });
558
+ }
559
+ async resolveMintDecimals(mint) {
560
+ const programId = await this.resolveTokenProgramId(mint);
561
+ const mintInfo = await (0, spl_token_1.getMint)(this.getConnection(), mint, undefined, programId);
562
+ return mintInfo.decimals;
563
+ }
564
+ /**
565
+ * Raw-instruction helper for callers that will compile the transaction downstream
566
+ * (e.g. depositron's SOL_INSTRUCTIONS action type) instead of using
567
+ * createTransferUnsignedTransaction's compiled-tx surface.
568
+ *
569
+ * Synchronous — no RPC.
570
+ */
571
+ buildNativeTransferInstruction(from, to, lamports) {
572
+ if (lamports <= 0n) {
573
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `Native transfer lamports must be positive (got ${lamports})`, { chainId: this.chainId });
574
+ }
575
+ return web3_js_1.SystemProgram.transfer({
576
+ fromPubkey: from,
577
+ toPubkey: to,
578
+ lamports,
579
+ });
580
+ }
581
+ /**
582
+ * Raw-instruction helper for SPL / Token-2022 transfers where the caller will compile
583
+ * the transaction downstream. Returns [createATA-idempotent?, transferChecked].
584
+ *
585
+ * Idempotent ATA (vs the probe-then-create pattern in createTransferUnsignedTransaction)
586
+ * is deliberate: when a downstream compiler runs the emitted instructions blindly,
587
+ * a probe done here can race with execution — the idempotent form is a no-op when the
588
+ * ATA exists and a create when it doesn't, without needing a probe RPC.
589
+ *
590
+ * `allowOwnerOffCurve: true` applies to BOTH source and destination ATA derivation —
591
+ * needed for PDA-owned vaults / program-owned recipients. Defaults to false to match
592
+ * createTransferUnsignedTransaction.
593
+ */
594
+ async buildSplTransferInstructions(req) {
595
+ if (req.amount <= 0n) {
596
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidArgument, `SPL transfer amount must be positive (got ${req.amount})`, { chainId: this.chainId, identifier: req.mint.toBase58() });
597
+ }
598
+ const includeCreateAta = req.includeCreateAta ?? true;
599
+ const allowOwnerOffCurve = req.allowOwnerOffCurve ?? false;
600
+ const programId = await this.resolveTokenProgramId(req.mint);
601
+ const decimals = await this.resolveMintDecimals(req.mint);
602
+ const deriveAta = (owner, role) => {
603
+ try {
604
+ return (0, spl_token_1.getAssociatedTokenAddressSync)(req.mint, owner, allowOwnerOffCurve, programId);
605
+ }
606
+ catch (err) {
607
+ // spl-token's TokenOwnerOffCurveError ships with an empty message. Rethrow as
608
+ // ChainError so consumers see the SDK's declared error surface, and so the
609
+ // reason is discoverable (pass `allowOwnerOffCurve: true` for PDA-owned wallets).
610
+ throw new errors_ts_1.ChainError(errors_ts_1.ChainErrorKinds.InvalidAddress, `${role} owner is off-curve; pass allowOwnerOffCurve:true for PDA-owned wallets`, { chainId: this.chainId, address: owner.toBase58() });
611
+ }
612
+ };
613
+ const sourceAta = deriveAta(req.from, 'source');
614
+ const destAta = deriveAta(req.to, 'destination');
615
+ const instructions = [];
616
+ if (includeCreateAta) {
617
+ instructions.push((0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(req.from, destAta, req.to, req.mint, programId));
618
+ }
619
+ instructions.push((0, spl_token_1.createTransferCheckedInstruction)(sourceAta, req.mint, destAta, req.from, req.amount, decimals, [], programId));
620
+ return instructions;
621
+ }
622
+ /**
623
+ * Decodes per-account lamport deltas + SPL pre/post token-balance diffs into
624
+ * a `NestedBalanceChanges` map. Marked internal via naming rather than TS
625
+ * `private` so chain-agnostic unit tests can exercise it directly without
626
+ * spinning up a Connection.
627
+ */
628
+ _decodeBalanceChanges(tx) {
629
+ const result = new Map();
630
+ if (!tx.meta)
631
+ return result;
632
+ // For v0 messages, meta.preBalances/postBalances are indexed over
633
+ // staticAccountKeys ++ loadedAddresses.writable ++ loadedAddresses.readonly.
634
+ // Iterating only staticAccountKeys silently drops lamport deltas for
635
+ // any LUT-resolved account — a SOL deposit to a wallet that only
636
+ // appears via a lookup table produces no balanceChanges row at all.
637
+ // getTransaction() is called with maxSupportedTransactionVersion: 0
638
+ // so we always see the resolved addresses.
639
+ const staticKeys = tx.transaction.message.staticAccountKeys.map((k) => k.toBase58());
640
+ const loaded = tx.meta.loadedAddresses;
641
+ const loadedWritable = (loaded?.writable ?? []).map((k) => k.toBase58());
642
+ const loadedReadonly = (loaded?.readonly ?? []).map((k) => k.toBase58());
643
+ const accounts = [...staticKeys, ...loadedWritable, ...loadedReadonly];
644
+ const pre = tx.meta.preBalances ?? [];
645
+ const post = tx.meta.postBalances ?? [];
646
+ for (let i = 0; i < accounts.length; i++) {
647
+ const delta = BigInt(post[i] ?? 0) - BigInt(pre[i] ?? 0);
648
+ if (delta === 0n)
649
+ continue;
650
+ transaction_status_ts_1.AssetBalanceChange.upsert(result, accounts[i], this._nativeToken, transaction_status_ts_1.AssetBalanceChange.fromMr(delta, this._nativeToken.decimals));
651
+ }
652
+ const preTok = tx.meta.preTokenBalances ?? [];
653
+ const postTok = tx.meta.postTokenBalances ?? [];
654
+ const tokenKey = (b) => `${b.accountIndex}|${b.mint}`;
655
+ // Track the token account's owner (a wallet) and the mint's decimals,
656
+ // both surfaced verbatim by getTransaction's parsed token-balance meta.
657
+ const byKey = new Map();
658
+ for (const b of preTok) {
659
+ byKey.set(tokenKey(b), {
660
+ pre: BigInt(b.uiTokenAmount.amount),
661
+ post: 0n,
662
+ mint: b.mint,
663
+ owner: b.owner ?? null,
664
+ decimals: b.uiTokenAmount.decimals,
665
+ });
666
+ }
667
+ for (const b of postTok) {
668
+ const k = tokenKey(b);
669
+ const cur = byKey.get(k);
670
+ if (cur) {
671
+ cur.post = BigInt(b.uiTokenAmount.amount);
672
+ // Prefer the post-owner if the pre entry lacked one (account
673
+ // freshly initialized inside the tx).
674
+ if (cur.owner === null && b.owner)
675
+ cur.owner = b.owner;
676
+ }
677
+ else {
678
+ byKey.set(k, {
679
+ pre: 0n,
680
+ post: BigInt(b.uiTokenAmount.amount),
681
+ mint: b.mint,
682
+ owner: b.owner ?? null,
683
+ decimals: b.uiTokenAmount.decimals,
684
+ });
685
+ }
686
+ }
687
+ for (const { pre: p, post: q, mint, owner, decimals } of byKey.values()) {
688
+ const delta = q - p;
689
+ if (delta === 0n)
690
+ continue;
691
+ // Skip entries where the token-account owner is unknown — filling in
692
+ // the mint as if it were a wallet address would be actively wrong.
693
+ // Matches Python's behavior in impl/solana/base.py:704-706.
694
+ if (owner === null)
695
+ continue;
696
+ // Symbol is not surfaced by getTransaction; use an UNKNOWN placeholder
697
+ // built from the first four mint characters. Mirrors the EVM decoder's
698
+ // UNKNOWN_<hex-slice> shape (evm_chain.ts:480) so consumers can spot
699
+ // unresolved tokens uniformly.
700
+ const symbol = `UNKNOWN_${mint.slice(0, 4)}`;
701
+ const splToken = new solana_token_ts_1.SolanaToken(this.chainId, symbol, mint, decimals);
702
+ transaction_status_ts_1.AssetBalanceChange.upsert(result, owner, splToken, transaction_status_ts_1.AssetBalanceChange.fromMr(delta, decimals));
703
+ }
704
+ return result;
705
+ }
706
+ }
707
+ exports.SolanaChain = SolanaChain;
708
+ //# sourceMappingURL=solana_chain.js.map