@ledgerhq/coin-solana 0.7.0-next.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 (521) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +16 -0
  4. package/CHANGELOG.md +27 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest.config.js +8 -0
  7. package/lib/api/cached.d.ts +3 -0
  8. package/lib/api/cached.d.ts.map +1 -0
  9. package/lib/api/cached.js +41 -0
  10. package/lib/api/cached.js.map +1 -0
  11. package/lib/api/chain/account/index.d.ts +2 -0
  12. package/lib/api/chain/account/index.d.ts.map +1 -0
  13. package/lib/api/chain/account/index.js +8 -0
  14. package/lib/api/chain/account/index.js.map +1 -0
  15. package/lib/api/chain/account/parser.d.ts +10 -0
  16. package/lib/api/chain/account/parser.d.ts.map +1 -0
  17. package/lib/api/chain/account/parser.js +56 -0
  18. package/lib/api/chain/account/parser.js.map +1 -0
  19. package/lib/api/chain/account/stake.d.ts +237 -0
  20. package/lib/api/chain/account/stake.d.ts.map +1 -0
  21. package/lib/api/chain/account/stake.js +38 -0
  22. package/lib/api/chain/account/stake.js.map +1 -0
  23. package/lib/api/chain/account/token.d.ts +116 -0
  24. package/lib/api/chain/account/token.d.ts.map +1 -0
  25. package/lib/api/chain/account/token.js +42 -0
  26. package/lib/api/chain/account/token.js.map +1 -0
  27. package/lib/api/chain/account/vote.d.ts +252 -0
  28. package/lib/api/chain/account/vote.d.ts.map +1 -0
  29. package/lib/api/chain/account/vote.js +44 -0
  30. package/lib/api/chain/account/vote.js.map +1 -0
  31. package/lib/api/chain/index.d.ts +29 -0
  32. package/lib/api/chain/index.d.ts.map +1 -0
  33. package/lib/api/chain/index.js +96 -0
  34. package/lib/api/chain/index.js.map +1 -0
  35. package/lib/api/chain/instruction/associated-token-account/index.d.ts +15 -0
  36. package/lib/api/chain/instruction/associated-token-account/index.d.ts.map +1 -0
  37. package/lib/api/chain/instruction/associated-token-account/index.js +21 -0
  38. package/lib/api/chain/instruction/associated-token-account/index.js.map +1 -0
  39. package/lib/api/chain/instruction/associated-token-account/types.d.ts +30 -0
  40. package/lib/api/chain/instruction/associated-token-account/types.d.ts.map +1 -0
  41. package/lib/api/chain/instruction/associated-token-account/types.js +19 -0
  42. package/lib/api/chain/instruction/associated-token-account/types.js.map +1 -0
  43. package/lib/api/chain/instruction/memo/index.d.ts +15 -0
  44. package/lib/api/chain/instruction/memo/index.d.ts.map +1 -0
  45. package/lib/api/chain/instruction/memo/index.js +14 -0
  46. package/lib/api/chain/instruction/memo/index.js.map +1 -0
  47. package/lib/api/chain/instruction/memo/types.d.ts +21 -0
  48. package/lib/api/chain/instruction/memo/types.d.ts.map +1 -0
  49. package/lib/api/chain/instruction/memo/types.js +16 -0
  50. package/lib/api/chain/instruction/memo/types.js.map +1 -0
  51. package/lib/api/chain/instruction/stake/index.d.ts +15 -0
  52. package/lib/api/chain/instruction/stake/index.d.ts.map +1 -0
  53. package/lib/api/chain/instruction/stake/index.js +20 -0
  54. package/lib/api/chain/instruction/stake/index.js.map +1 -0
  55. package/lib/api/chain/instruction/stake/types.d.ts +215 -0
  56. package/lib/api/chain/instruction/stake/types.d.ts.map +1 -0
  57. package/lib/api/chain/instruction/stake/types.js +80 -0
  58. package/lib/api/chain/instruction/stake/types.js.map +1 -0
  59. package/lib/api/chain/instruction/system/index.d.ts +15 -0
  60. package/lib/api/chain/instruction/system/index.d.ts.map +1 -0
  61. package/lib/api/chain/instruction/system/index.js +20 -0
  62. package/lib/api/chain/instruction/system/index.js.map +1 -0
  63. package/lib/api/chain/instruction/system/types.d.ts +298 -0
  64. package/lib/api/chain/instruction/system/types.d.ts.map +1 -0
  65. package/lib/api/chain/instruction/system/types.js +117 -0
  66. package/lib/api/chain/instruction/system/types.js.map +1 -0
  67. package/lib/api/chain/instruction/token/index.d.ts +15 -0
  68. package/lib/api/chain/instruction/token/index.d.ts.map +1 -0
  69. package/lib/api/chain/instruction/token/index.js +20 -0
  70. package/lib/api/chain/instruction/token/index.js.map +1 -0
  71. package/lib/api/chain/instruction/token/types.d.ts +497 -0
  72. package/lib/api/chain/instruction/token/types.d.ts.map +1 -0
  73. package/lib/api/chain/instruction/token/types.js +200 -0
  74. package/lib/api/chain/instruction/token/types.js.map +1 -0
  75. package/lib/api/chain/program/constants.d.ts +11 -0
  76. package/lib/api/chain/program/constants.d.ts.map +1 -0
  77. package/lib/api/chain/program/constants.js +14 -0
  78. package/lib/api/chain/program/constants.js.map +1 -0
  79. package/lib/api/chain/program/index.d.ts +2 -0
  80. package/lib/api/chain/program/index.d.ts.map +1 -0
  81. package/lib/api/chain/program/index.js +7 -0
  82. package/lib/api/chain/program/index.js.map +1 -0
  83. package/lib/api/chain/program/parser.d.ts +35 -0
  84. package/lib/api/chain/program/parser.d.ts.map +1 -0
  85. package/lib/api/chain/program/parser.js +66 -0
  86. package/lib/api/chain/program/parser.js.map +1 -0
  87. package/lib/api/chain/validators/bignum.d.ts +3 -0
  88. package/lib/api/chain/validators/bignum.d.ts.map +1 -0
  89. package/lib/api/chain/validators/bignum.js +11 -0
  90. package/lib/api/chain/validators/bignum.js.map +1 -0
  91. package/lib/api/chain/validators/index.d.ts +10 -0
  92. package/lib/api/chain/validators/index.d.ts.map +1 -0
  93. package/lib/api/chain/validators/index.js +10 -0
  94. package/lib/api/chain/validators/index.js.map +1 -0
  95. package/lib/api/chain/validators/pubkey.d.ts +3 -0
  96. package/lib/api/chain/validators/pubkey.d.ts.map +1 -0
  97. package/lib/api/chain/validators/pubkey.js +7 -0
  98. package/lib/api/chain/validators/pubkey.js.map +1 -0
  99. package/lib/api/chain/web3.d.ts +43 -0
  100. package/lib/api/chain/web3.d.ts.map +1 -0
  101. package/lib/api/chain/web3.js +272 -0
  102. package/lib/api/chain/web3.js.map +1 -0
  103. package/lib/api/index.d.ts +5 -0
  104. package/lib/api/index.d.ts.map +1 -0
  105. package/lib/api/index.js +25 -0
  106. package/lib/api/index.js.map +1 -0
  107. package/lib/api/logged.d.ts +3 -0
  108. package/lib/api/logged.d.ts.map +1 -0
  109. package/lib/api/logged.js +69 -0
  110. package/lib/api/logged.js.map +1 -0
  111. package/lib/api/queued.d.ts +3 -0
  112. package/lib/api/queued.d.ts.map +1 -0
  113. package/lib/api/queued.js +27 -0
  114. package/lib/api/queued.js.map +1 -0
  115. package/lib/api/traced.d.ts +3 -0
  116. package/lib/api/traced.d.ts.map +1 -0
  117. package/lib/api/traced.js +80 -0
  118. package/lib/api/traced.js.map +1 -0
  119. package/lib/bridge/bridge.d.ts +15 -0
  120. package/lib/bridge/bridge.d.ts.map +1 -0
  121. package/lib/bridge/bridge.js +134 -0
  122. package/lib/bridge/bridge.js.map +1 -0
  123. package/lib/bridge/js.d.ts +7 -0
  124. package/lib/bridge/js.d.ts.map +1 -0
  125. package/lib/bridge/js.js +28 -0
  126. package/lib/bridge/js.js.map +1 -0
  127. package/lib/bridge.integration.test.d.ts +4 -0
  128. package/lib/bridge.integration.test.d.ts.map +1 -0
  129. package/lib/bridge.integration.test.js +988 -0
  130. package/lib/bridge.integration.test.js.map +1 -0
  131. package/lib/broadcast.d.ts +7 -0
  132. package/lib/broadcast.d.ts.map +1 -0
  133. package/lib/broadcast.js +37 -0
  134. package/lib/broadcast.js.map +1 -0
  135. package/lib/buildTransaction.d.ts +5 -0
  136. package/lib/buildTransaction.d.ts.map +1 -0
  137. package/lib/buildTransaction.js +67 -0
  138. package/lib/buildTransaction.js.map +1 -0
  139. package/lib/cli-transaction.d.ts +19 -0
  140. package/lib/cli-transaction.d.ts.map +1 -0
  141. package/lib/cli-transaction.js +196 -0
  142. package/lib/cli-transaction.js.map +1 -0
  143. package/lib/createTransaction.d.ts +5 -0
  144. package/lib/createTransaction.d.ts.map +1 -0
  145. package/lib/createTransaction.js +19 -0
  146. package/lib/createTransaction.js.map +1 -0
  147. package/lib/datasets/solana.scanAccounts.1.d.ts +6 -0
  148. package/lib/datasets/solana.scanAccounts.1.d.ts.map +1 -0
  149. package/lib/datasets/solana.scanAccounts.1.js +12 -0
  150. package/lib/datasets/solana.scanAccounts.1.js.map +1 -0
  151. package/lib/deviceTransactionConfig.d.ts +10 -0
  152. package/lib/deviceTransactionConfig.d.ts.map +1 -0
  153. package/lib/deviceTransactionConfig.js +228 -0
  154. package/lib/deviceTransactionConfig.js.map +1 -0
  155. package/lib/errors.d.ts +61 -0
  156. package/lib/errors.d.ts.map +1 -0
  157. package/lib/errors.js +25 -0
  158. package/lib/errors.js.map +1 -0
  159. package/lib/estimateMaxSpendable.d.ts +11 -0
  160. package/lib/estimateMaxSpendable.d.ts.map +1 -0
  161. package/lib/estimateMaxSpendable.js +63 -0
  162. package/lib/estimateMaxSpendable.js.map +1 -0
  163. package/lib/getTransactionStatus.d.ts +5 -0
  164. package/lib/getTransactionStatus.d.ts.map +1 -0
  165. package/lib/getTransactionStatus.js +73 -0
  166. package/lib/getTransactionStatus.js.map +1 -0
  167. package/lib/hw-getAddress.d.ts +6 -0
  168. package/lib/hw-getAddress.d.ts.map +1 -0
  169. package/lib/hw-getAddress.js +28 -0
  170. package/lib/hw-getAddress.js.map +1 -0
  171. package/lib/logic.d.ts +29 -0
  172. package/lib/logic.d.ts.map +1 -0
  173. package/lib/logic.js +102 -0
  174. package/lib/logic.js.map +1 -0
  175. package/lib/preload-data.d.ts +7 -0
  176. package/lib/preload-data.d.ts.map +1 -0
  177. package/lib/preload-data.js +45 -0
  178. package/lib/preload-data.js.map +1 -0
  179. package/lib/preload.d.ts +7 -0
  180. package/lib/preload.d.ts.map +1 -0
  181. package/lib/preload.js +67 -0
  182. package/lib/preload.js.map +1 -0
  183. package/lib/preload.test.d.ts +2 -0
  184. package/lib/preload.test.d.ts.map +1 -0
  185. package/lib/preload.test.js +9 -0
  186. package/lib/preload.test.js.map +1 -0
  187. package/lib/prepareTransaction.d.ts +5 -0
  188. package/lib/prepareTransaction.d.ts.map +1 -0
  189. package/lib/prepareTransaction.js +500 -0
  190. package/lib/prepareTransaction.js.map +1 -0
  191. package/lib/serialization.d.ts +9 -0
  192. package/lib/serialization.d.ts.map +1 -0
  193. package/lib/serialization.js +69 -0
  194. package/lib/serialization.js.map +1 -0
  195. package/lib/signOperation.d.ts +7 -0
  196. package/lib/signOperation.d.ts.map +1 -0
  197. package/lib/signOperation.js +153 -0
  198. package/lib/signOperation.js.map +1 -0
  199. package/lib/signer.d.ts +11 -0
  200. package/lib/signer.d.ts.map +1 -0
  201. package/lib/signer.js +3 -0
  202. package/lib/signer.js.map +1 -0
  203. package/lib/specs.d.ts +7 -0
  204. package/lib/specs.d.ts.map +1 -0
  205. package/lib/specs.js +409 -0
  206. package/lib/specs.js.map +1 -0
  207. package/lib/speculos-deviceActions.d.ts +8 -0
  208. package/lib/speculos-deviceActions.d.ts.map +1 -0
  209. package/lib/speculos-deviceActions.js +217 -0
  210. package/lib/speculos-deviceActions.js.map +1 -0
  211. package/lib/synchronization.d.ts +5 -0
  212. package/lib/synchronization.d.ts.map +1 -0
  213. package/lib/synchronization.js +463 -0
  214. package/lib/synchronization.js.map +1 -0
  215. package/lib/transaction.d.ts +15 -0
  216. package/lib/transaction.d.ts.map +1 -0
  217. package/lib/transaction.js +154 -0
  218. package/lib/transaction.js.map +1 -0
  219. package/lib/tx-fees.d.ts +4 -0
  220. package/lib/tx-fees.d.ts.map +1 -0
  221. package/lib/tx-fees.js +167 -0
  222. package/lib/tx-fees.js.map +1 -0
  223. package/lib/types.d.ts +225 -0
  224. package/lib/types.d.ts.map +1 -0
  225. package/lib/types.js +3 -0
  226. package/lib/types.js.map +1 -0
  227. package/lib/utils.d.ts +24 -0
  228. package/lib/utils.d.ts.map +1 -0
  229. package/lib/utils.js +172 -0
  230. package/lib/utils.js.map +1 -0
  231. package/lib/validator-app/index.d.ts +22 -0
  232. package/lib/validator-app/index.d.ts.map +1 -0
  233. package/lib/validator-app/index.js +62 -0
  234. package/lib/validator-app/index.js.map +1 -0
  235. package/lib-es/api/cached.d.ts +3 -0
  236. package/lib-es/api/cached.d.ts.map +1 -0
  237. package/lib-es/api/cached.js +34 -0
  238. package/lib-es/api/cached.js.map +1 -0
  239. package/lib-es/api/chain/account/index.d.ts +2 -0
  240. package/lib-es/api/chain/account/index.d.ts.map +1 -0
  241. package/lib-es/api/chain/account/index.js +2 -0
  242. package/lib-es/api/chain/account/index.js.map +1 -0
  243. package/lib-es/api/chain/account/parser.d.ts +10 -0
  244. package/lib-es/api/chain/account/parser.d.ts.map +1 -0
  245. package/lib-es/api/chain/account/parser.js +48 -0
  246. package/lib-es/api/chain/account/parser.js.map +1 -0
  247. package/lib-es/api/chain/account/stake.d.ts +237 -0
  248. package/lib-es/api/chain/account/stake.d.ts.map +1 -0
  249. package/lib-es/api/chain/account/stake.js +35 -0
  250. package/lib-es/api/chain/account/stake.js.map +1 -0
  251. package/lib-es/api/chain/account/token.d.ts +116 -0
  252. package/lib-es/api/chain/account/token.d.ts.map +1 -0
  253. package/lib-es/api/chain/account/token.js +39 -0
  254. package/lib-es/api/chain/account/token.js.map +1 -0
  255. package/lib-es/api/chain/account/vote.d.ts +252 -0
  256. package/lib-es/api/chain/account/vote.d.ts.map +1 -0
  257. package/lib-es/api/chain/account/vote.js +41 -0
  258. package/lib-es/api/chain/account/vote.js.map +1 -0
  259. package/lib-es/api/chain/index.d.ts +29 -0
  260. package/lib-es/api/chain/index.d.ts.map +1 -0
  261. package/lib-es/api/chain/index.js +92 -0
  262. package/lib-es/api/chain/index.js.map +1 -0
  263. package/lib-es/api/chain/instruction/associated-token-account/index.d.ts +15 -0
  264. package/lib-es/api/chain/instruction/associated-token-account/index.d.ts.map +1 -0
  265. package/lib-es/api/chain/instruction/associated-token-account/index.js +17 -0
  266. package/lib-es/api/chain/instruction/associated-token-account/index.js.map +1 -0
  267. package/lib-es/api/chain/instruction/associated-token-account/types.d.ts +30 -0
  268. package/lib-es/api/chain/instruction/associated-token-account/types.d.ts.map +1 -0
  269. package/lib-es/api/chain/instruction/associated-token-account/types.js +16 -0
  270. package/lib-es/api/chain/instruction/associated-token-account/types.js.map +1 -0
  271. package/lib-es/api/chain/instruction/memo/index.d.ts +15 -0
  272. package/lib-es/api/chain/instruction/memo/index.d.ts.map +1 -0
  273. package/lib-es/api/chain/instruction/memo/index.js +10 -0
  274. package/lib-es/api/chain/instruction/memo/index.js.map +1 -0
  275. package/lib-es/api/chain/instruction/memo/types.d.ts +21 -0
  276. package/lib-es/api/chain/instruction/memo/types.d.ts.map +1 -0
  277. package/lib-es/api/chain/instruction/memo/types.js +13 -0
  278. package/lib-es/api/chain/instruction/memo/types.js.map +1 -0
  279. package/lib-es/api/chain/instruction/stake/index.d.ts +15 -0
  280. package/lib-es/api/chain/instruction/stake/index.d.ts.map +1 -0
  281. package/lib-es/api/chain/instruction/stake/index.js +16 -0
  282. package/lib-es/api/chain/instruction/stake/index.js.map +1 -0
  283. package/lib-es/api/chain/instruction/stake/types.d.ts +215 -0
  284. package/lib-es/api/chain/instruction/stake/types.d.ts.map +1 -0
  285. package/lib-es/api/chain/instruction/stake/types.js +77 -0
  286. package/lib-es/api/chain/instruction/stake/types.js.map +1 -0
  287. package/lib-es/api/chain/instruction/system/index.d.ts +15 -0
  288. package/lib-es/api/chain/instruction/system/index.d.ts.map +1 -0
  289. package/lib-es/api/chain/instruction/system/index.js +16 -0
  290. package/lib-es/api/chain/instruction/system/index.js.map +1 -0
  291. package/lib-es/api/chain/instruction/system/types.d.ts +298 -0
  292. package/lib-es/api/chain/instruction/system/types.d.ts.map +1 -0
  293. package/lib-es/api/chain/instruction/system/types.js +114 -0
  294. package/lib-es/api/chain/instruction/system/types.js.map +1 -0
  295. package/lib-es/api/chain/instruction/token/index.d.ts +15 -0
  296. package/lib-es/api/chain/instruction/token/index.d.ts.map +1 -0
  297. package/lib-es/api/chain/instruction/token/index.js +16 -0
  298. package/lib-es/api/chain/instruction/token/index.js.map +1 -0
  299. package/lib-es/api/chain/instruction/token/types.d.ts +497 -0
  300. package/lib-es/api/chain/instruction/token/types.d.ts.map +1 -0
  301. package/lib-es/api/chain/instruction/token/types.js +197 -0
  302. package/lib-es/api/chain/instruction/token/types.js.map +1 -0
  303. package/lib-es/api/chain/program/constants.d.ts +11 -0
  304. package/lib-es/api/chain/program/constants.d.ts.map +1 -0
  305. package/lib-es/api/chain/program/constants.js +11 -0
  306. package/lib-es/api/chain/program/constants.js.map +1 -0
  307. package/lib-es/api/chain/program/index.d.ts +2 -0
  308. package/lib-es/api/chain/program/index.d.ts.map +1 -0
  309. package/lib-es/api/chain/program/index.js +2 -0
  310. package/lib-es/api/chain/program/index.js.map +1 -0
  311. package/lib-es/api/chain/program/parser.d.ts +35 -0
  312. package/lib-es/api/chain/program/parser.d.ts.map +1 -0
  313. package/lib-es/api/chain/program/parser.js +61 -0
  314. package/lib-es/api/chain/program/parser.js.map +1 -0
  315. package/lib-es/api/chain/validators/bignum.d.ts +3 -0
  316. package/lib-es/api/chain/validators/bignum.d.ts.map +1 -0
  317. package/lib-es/api/chain/validators/bignum.js +8 -0
  318. package/lib-es/api/chain/validators/bignum.js.map +1 -0
  319. package/lib-es/api/chain/validators/index.d.ts +10 -0
  320. package/lib-es/api/chain/validators/index.d.ts.map +1 -0
  321. package/lib-es/api/chain/validators/index.js +7 -0
  322. package/lib-es/api/chain/validators/index.js.map +1 -0
  323. package/lib-es/api/chain/validators/pubkey.d.ts +3 -0
  324. package/lib-es/api/chain/validators/pubkey.d.ts.map +1 -0
  325. package/lib-es/api/chain/validators/pubkey.js +4 -0
  326. package/lib-es/api/chain/validators/pubkey.js.map +1 -0
  327. package/lib-es/api/chain/web3.d.ts +43 -0
  328. package/lib-es/api/chain/web3.d.ts.map +1 -0
  329. package/lib-es/api/chain/web3.js +249 -0
  330. package/lib-es/api/chain/web3.js.map +1 -0
  331. package/lib-es/api/index.d.ts +5 -0
  332. package/lib-es/api/index.d.ts.map +1 -0
  333. package/lib-es/api/index.js +5 -0
  334. package/lib-es/api/index.js.map +1 -0
  335. package/lib-es/api/logged.d.ts +3 -0
  336. package/lib-es/api/logged.d.ts.map +1 -0
  337. package/lib-es/api/logged.js +65 -0
  338. package/lib-es/api/logged.js.map +1 -0
  339. package/lib-es/api/queued.d.ts +3 -0
  340. package/lib-es/api/queued.d.ts.map +1 -0
  341. package/lib-es/api/queued.js +23 -0
  342. package/lib-es/api/queued.js.map +1 -0
  343. package/lib-es/api/traced.d.ts +3 -0
  344. package/lib-es/api/traced.d.ts.map +1 -0
  345. package/lib-es/api/traced.js +76 -0
  346. package/lib-es/api/traced.js.map +1 -0
  347. package/lib-es/bridge/bridge.d.ts +15 -0
  348. package/lib-es/bridge/bridge.d.ts.map +1 -0
  349. package/lib-es/bridge/bridge.js +127 -0
  350. package/lib-es/bridge/bridge.js.map +1 -0
  351. package/lib-es/bridge/js.d.ts +7 -0
  352. package/lib-es/bridge/js.d.ts.map +1 -0
  353. package/lib-es/bridge/js.js +24 -0
  354. package/lib-es/bridge/js.js.map +1 -0
  355. package/lib-es/bridge.integration.test.d.ts +4 -0
  356. package/lib-es/bridge.integration.test.d.ts.map +1 -0
  357. package/lib-es/bridge.integration.test.js +986 -0
  358. package/lib-es/bridge.integration.test.js.map +1 -0
  359. package/lib-es/broadcast.d.ts +7 -0
  360. package/lib-es/broadcast.d.ts.map +1 -0
  361. package/lib-es/broadcast.js +33 -0
  362. package/lib-es/broadcast.js.map +1 -0
  363. package/lib-es/buildTransaction.d.ts +5 -0
  364. package/lib-es/buildTransaction.d.ts.map +1 -0
  365. package/lib-es/buildTransaction.js +63 -0
  366. package/lib-es/buildTransaction.js.map +1 -0
  367. package/lib-es/cli-transaction.d.ts +19 -0
  368. package/lib-es/cli-transaction.d.ts.map +1 -0
  369. package/lib-es/cli-transaction.js +190 -0
  370. package/lib-es/cli-transaction.js.map +1 -0
  371. package/lib-es/createTransaction.d.ts +5 -0
  372. package/lib-es/createTransaction.d.ts.map +1 -0
  373. package/lib-es/createTransaction.js +15 -0
  374. package/lib-es/createTransaction.js.map +1 -0
  375. package/lib-es/datasets/solana.scanAccounts.1.d.ts +6 -0
  376. package/lib-es/datasets/solana.scanAccounts.1.d.ts.map +1 -0
  377. package/lib-es/datasets/solana.scanAccounts.1.js +10 -0
  378. package/lib-es/datasets/solana.scanAccounts.1.js.map +1 -0
  379. package/lib-es/deviceTransactionConfig.d.ts +10 -0
  380. package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
  381. package/lib-es/deviceTransactionConfig.js +223 -0
  382. package/lib-es/deviceTransactionConfig.js.map +1 -0
  383. package/lib-es/errors.d.ts +61 -0
  384. package/lib-es/errors.d.ts.map +1 -0
  385. package/lib-es/errors.js +22 -0
  386. package/lib-es/errors.js.map +1 -0
  387. package/lib-es/estimateMaxSpendable.d.ts +11 -0
  388. package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
  389. package/lib-es/estimateMaxSpendable.js +55 -0
  390. package/lib-es/estimateMaxSpendable.js.map +1 -0
  391. package/lib-es/getTransactionStatus.d.ts +5 -0
  392. package/lib-es/getTransactionStatus.d.ts.map +1 -0
  393. package/lib-es/getTransactionStatus.js +69 -0
  394. package/lib-es/getTransactionStatus.js.map +1 -0
  395. package/lib-es/hw-getAddress.d.ts +6 -0
  396. package/lib-es/hw-getAddress.d.ts.map +1 -0
  397. package/lib-es/hw-getAddress.js +23 -0
  398. package/lib-es/hw-getAddress.js.map +1 -0
  399. package/lib-es/logic.d.ts +29 -0
  400. package/lib-es/logic.d.ts.map +1 -0
  401. package/lib-es/logic.js +87 -0
  402. package/lib-es/logic.js.map +1 -0
  403. package/lib-es/preload-data.d.ts +7 -0
  404. package/lib-es/preload-data.d.ts.map +1 -0
  405. package/lib-es/preload-data.js +39 -0
  406. package/lib-es/preload-data.js.map +1 -0
  407. package/lib-es/preload.d.ts +7 -0
  408. package/lib-es/preload.d.ts.map +1 -0
  409. package/lib-es/preload.js +62 -0
  410. package/lib-es/preload.js.map +1 -0
  411. package/lib-es/preload.test.d.ts +2 -0
  412. package/lib-es/preload.test.d.ts.map +1 -0
  413. package/lib-es/preload.test.js +7 -0
  414. package/lib-es/preload.test.js.map +1 -0
  415. package/lib-es/prepareTransaction.d.ts +5 -0
  416. package/lib-es/prepareTransaction.d.ts.map +1 -0
  417. package/lib-es/prepareTransaction.js +497 -0
  418. package/lib-es/prepareTransaction.js.map +1 -0
  419. package/lib-es/serialization.d.ts +9 -0
  420. package/lib-es/serialization.d.ts.map +1 -0
  421. package/lib-es/serialization.js +60 -0
  422. package/lib-es/serialization.js.map +1 -0
  423. package/lib-es/signOperation.d.ts +7 -0
  424. package/lib-es/signOperation.d.ts.map +1 -0
  425. package/lib-es/signOperation.js +146 -0
  426. package/lib-es/signOperation.js.map +1 -0
  427. package/lib-es/signer.d.ts +11 -0
  428. package/lib-es/signer.d.ts.map +1 -0
  429. package/lib-es/signer.js +2 -0
  430. package/lib-es/signer.js.map +1 -0
  431. package/lib-es/specs.d.ts +7 -0
  432. package/lib-es/specs.d.ts.map +1 -0
  433. package/lib-es/specs.js +404 -0
  434. package/lib-es/specs.js.map +1 -0
  435. package/lib-es/speculos-deviceActions.d.ts +8 -0
  436. package/lib-es/speculos-deviceActions.d.ts.map +1 -0
  437. package/lib-es/speculos-deviceActions.js +211 -0
  438. package/lib-es/speculos-deviceActions.js.map +1 -0
  439. package/lib-es/synchronization.d.ts +5 -0
  440. package/lib-es/synchronization.d.ts.map +1 -0
  441. package/lib-es/synchronization.js +456 -0
  442. package/lib-es/synchronization.js.map +1 -0
  443. package/lib-es/transaction.d.ts +15 -0
  444. package/lib-es/transaction.d.ts.map +1 -0
  445. package/lib-es/transaction.js +148 -0
  446. package/lib-es/transaction.js.map +1 -0
  447. package/lib-es/tx-fees.d.ts +4 -0
  448. package/lib-es/tx-fees.d.ts.map +1 -0
  449. package/lib-es/tx-fees.js +160 -0
  450. package/lib-es/tx-fees.js.map +1 -0
  451. package/lib-es/types.d.ts +225 -0
  452. package/lib-es/types.d.ts.map +1 -0
  453. package/lib-es/types.js +2 -0
  454. package/lib-es/types.js.map +1 -0
  455. package/lib-es/utils.d.ts +24 -0
  456. package/lib-es/utils.d.ts.map +1 -0
  457. package/lib-es/utils.js +157 -0
  458. package/lib-es/utils.js.map +1 -0
  459. package/lib-es/validator-app/index.d.ts +22 -0
  460. package/lib-es/validator-app/index.d.ts.map +1 -0
  461. package/lib-es/validator-app/index.js +55 -0
  462. package/lib-es/validator-app/index.js.map +1 -0
  463. package/package.json +90 -0
  464. package/src/api/cached.ts +79 -0
  465. package/src/api/chain/account/index.ts +1 -0
  466. package/src/api/chain/account/parser.ts +63 -0
  467. package/src/api/chain/account/stake.ts +45 -0
  468. package/src/api/chain/account/token.ts +63 -0
  469. package/src/api/chain/account/vote.ts +55 -0
  470. package/src/api/chain/index.ts +212 -0
  471. package/src/api/chain/instruction/associated-token-account/index.ts +33 -0
  472. package/src/api/chain/instruction/associated-token-account/types.ts +23 -0
  473. package/src/api/chain/instruction/memo/index.ts +24 -0
  474. package/src/api/chain/instruction/memo/types.ts +18 -0
  475. package/src/api/chain/instruction/stake/index.ts +29 -0
  476. package/src/api/chain/instruction/stake/types.ts +95 -0
  477. package/src/api/chain/instruction/system/index.ts +30 -0
  478. package/src/api/chain/instruction/system/types.ts +141 -0
  479. package/src/api/chain/instruction/token/index.ts +30 -0
  480. package/src/api/chain/instruction/token/types.ts +222 -0
  481. package/src/api/chain/program/constants.ts +10 -0
  482. package/src/api/chain/program/index.ts +1 -0
  483. package/src/api/chain/program/parser.ts +120 -0
  484. package/src/api/chain/validators/bignum.ts +7 -0
  485. package/src/api/chain/validators/index.ts +9 -0
  486. package/src/api/chain/validators/pubkey.ts +8 -0
  487. package/src/api/chain/web3.ts +399 -0
  488. package/src/api/index.ts +4 -0
  489. package/src/api/logged.ts +70 -0
  490. package/src/api/queued.ts +25 -0
  491. package/src/api/traced.ts +89 -0
  492. package/src/bridge/bridge.ts +192 -0
  493. package/src/bridge/js.ts +42 -0
  494. package/src/bridge.integration.test.ts +1104 -0
  495. package/src/broadcast.ts +38 -0
  496. package/src/buildTransaction.ts +81 -0
  497. package/src/cli-transaction.ts +246 -0
  498. package/src/createTransaction.ts +18 -0
  499. package/src/datasets/solana.scanAccounts.1.ts +9 -0
  500. package/src/deviceTransactionConfig.ts +302 -0
  501. package/src/errors.ts +61 -0
  502. package/src/estimateMaxSpendable.ts +72 -0
  503. package/src/getTransactionStatus.ts +79 -0
  504. package/src/hw-getAddress.ts +22 -0
  505. package/src/logic.ts +123 -0
  506. package/src/preload-data.ts +46 -0
  507. package/src/preload.test.ts +14 -0
  508. package/src/preload.ts +74 -0
  509. package/src/prepareTransaction.ts +686 -0
  510. package/src/serialization.ts +81 -0
  511. package/src/signOperation.ts +315 -0
  512. package/src/signer.ts +10 -0
  513. package/src/specs.ts +514 -0
  514. package/src/speculos-deviceActions.ts +229 -0
  515. package/src/synchronization.ts +729 -0
  516. package/src/transaction.ts +199 -0
  517. package/src/tx-fees.ts +206 -0
  518. package/src/types.ts +291 -0
  519. package/src/utils.ts +176 -0
  520. package/src/validator-app/index.ts +79 -0
  521. package/tsconfig.json +13 -0
@@ -0,0 +1,988 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.dataset = void 0;
16
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
+ const solana_scanAccounts_1_1 = __importDefault(require("./datasets/solana.scanAccounts.1"));
18
+ const errors_1 = require("@ledgerhq/errors");
19
+ const errors_2 = require("./errors");
20
+ const logic_1 = require("./logic");
21
+ const createTransaction_1 = __importDefault(require("./createTransaction"));
22
+ const fp_1 = require("lodash/fp");
23
+ const utils_1 = require("./utils");
24
+ const live_env_1 = require("@ledgerhq/live-env");
25
+ const errors_3 = require("./errors");
26
+ const getTransactionStatus_1 = __importDefault(require("./getTransactionStatus"));
27
+ const prepareTransaction_1 = require("./prepareTransaction");
28
+ const accountId_1 = require("@ledgerhq/coin-framework/account/accountId");
29
+ const chain_1 = require("./api/chain");
30
+ // do not change real properties or the test will break
31
+ const testOnChainData = {
32
+ // --- real props ---
33
+ unfundedAddress: "7b6Q3ap8qRzfyvDw1Qce3fUV8C7WgFNzJQwYNTJm3KQo",
34
+ // 0/0
35
+ fundedSenderAddress: "AQbkEagmPgmsdAfS4X8V8UyJnXXjVPMvjeD15etqQ3Jh",
36
+ fundedSenderBalance: new bignumber_js_1.default(83389840),
37
+ // 1000/0
38
+ fundedAddress: "ARRKL4FT4LMwpkhUw4xNbfiHqR7UdePtzGLvkszgydqZ",
39
+ wSolSenderAssocTokenAccAddress: "8RtwWeqdFz4EFuZU3MAadfYMWSdRMamjFrfq6BXkHuNN",
40
+ wSolSenderAssocTokenAccBalance: new bignumber_js_1.default(7960720),
41
+ // 1000/0, mint - wrapped sol
42
+ wSolFundedAccountAssocTokenAccAddress: "Ax69sAxqBSdT3gMAUqXb8pUvgxSLCiXfTitMALEnFZTS",
43
+ // 0/0
44
+ notWSolTokenAccAddress: "Hsm3S2rhX4HwxYBaCyqgJ1cCtFyFSBu6HLy1bdvh7fKs",
45
+ validatorAddress: "9QU2QSxhb24FUX3Tu2FpczXjpK3VYrvRudywSZaM29mF",
46
+ fees: {
47
+ stakeAccountRentExempt: 2282880,
48
+ systemAccountRentExempt: 890880,
49
+ lamportsPerSignature: 5000,
50
+ },
51
+ // --- maybe outdated or not real, fine for tests ---
52
+ offEd25519Address: "6D8GtWkKJgToM5UoiByHqjQCCC9Dq1Hh7iNmU4jKSs14",
53
+ offEd25519Address2: "12rqwuEgBYiGhBrDJStCiqEtzQpTTiZbh7teNVLuYcFA",
54
+ };
55
+ const mainAccId = (0, accountId_1.encodeAccountId)({
56
+ type: "js",
57
+ version: "2",
58
+ currencyId: "solana",
59
+ xpubOrAddress: testOnChainData.fundedSenderAddress,
60
+ derivationMode: "solanaMain",
61
+ });
62
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
63
+ const wSolSubAccId = (0, logic_1.encodeAccountIdWithTokenAccountAddress)(mainAccId, testOnChainData.wSolSenderAssocTokenAccAddress);
64
+ const fees = (signatureCount) => new bignumber_js_1.default(signatureCount * testOnChainData.fees.lamportsPerSignature);
65
+ const zero = new bignumber_js_1.default(0);
66
+ const solana = {
67
+ scanAccounts: [solana_scanAccounts_1_1.default],
68
+ // FIXME Ordering of validators must be always the same, for this test to be stable:
69
+ // https://github.com/LedgerHQ/ledger-live-common/blob/develop/src/__tests__/test-helpers/bridge.ts#L171-L188
70
+ FIXME_ignorePreloadFields: ["validators"],
71
+ accounts: [
72
+ {
73
+ raw: makeAccount(testOnChainData.fundedSenderAddress),
74
+ /*
75
+ Solana integration is written in such a way that requires
76
+ prepareTransaction to be called before any meaningfull status
77
+ can be calculated. The general bridge tests do not run prepareTransaction
78
+ on all tests, so skip them in the general runner, but make alternatives for them.
79
+ */
80
+ FIXME_tests: [
81
+ "balance is sum of ops",
82
+ "Default empty recipient have a recipientError",
83
+ "invalid recipient have a recipientError",
84
+ "can be called on an empty transaction",
85
+ ],
86
+ transactions: [
87
+ ...recipientRequired(),
88
+ ...recipientNotValid(),
89
+ ...recipientIsSameAsSender(),
90
+ ...memoIsTooLong(),
91
+ {
92
+ name: "status is error: called on an empty transaction",
93
+ transaction: (0, createTransaction_1.default)({}),
94
+ expectedStatus: {
95
+ errors: {
96
+ recipient: new errors_1.RecipientRequired(),
97
+ },
98
+ warnings: {},
99
+ estimatedFees: fees(1),
100
+ amount: zero,
101
+ totalSpent: fees(1),
102
+ },
103
+ },
104
+ ...transferTests(),
105
+ ...stakingTests(),
106
+ //...tokenTests()
107
+ ],
108
+ },
109
+ ],
110
+ };
111
+ exports.dataset = {
112
+ implementations: [(0, live_env_1.getEnv)("MOCK") ? "mock" : "js"], // FIXME we should actually put both mock and js like other dataset do
113
+ currencies: {
114
+ solana,
115
+ },
116
+ };
117
+ function makeAccount(freshAddress) {
118
+ return {
119
+ id: mainAccId,
120
+ seedIdentifier: "",
121
+ derivationMode: "solanaMain",
122
+ index: 0,
123
+ freshAddress,
124
+ freshAddressPath: "",
125
+ blockHeight: 0,
126
+ operations: [],
127
+ pendingOperations: [],
128
+ currencyId: "solana",
129
+ lastSyncDate: "",
130
+ balance: "0",
131
+ };
132
+ }
133
+ function recipientRequired() {
134
+ const models = [
135
+ // uncomment when tokens are supported
136
+ /*
137
+ {
138
+ kind: "token.transfer",
139
+ uiState: {
140
+ subAccountId: "",
141
+ },
142
+ },
143
+ */
144
+ {
145
+ kind: "transfer",
146
+ uiState: {},
147
+ },
148
+ ];
149
+ return models.map(model => {
150
+ return {
151
+ name: `${model.kind} :: status is error: recipient required`,
152
+ transaction: {
153
+ model,
154
+ amount: zero,
155
+ recipient: "",
156
+ family: "solana",
157
+ },
158
+ expectedStatus: {
159
+ errors: {
160
+ recipient: new errors_1.RecipientRequired(),
161
+ },
162
+ warnings: {},
163
+ estimatedFees: fees(1),
164
+ amount: zero,
165
+ totalSpent: model.kind === "transfer" ? fees(1) : zero,
166
+ },
167
+ };
168
+ });
169
+ }
170
+ function recipientNotValid() {
171
+ return recipientRequired().map(spec => {
172
+ return Object.assign(Object.assign({}, spec), { transaction: Object.assign(Object.assign({}, spec.transaction), { recipient: "invalid address" }), expectedStatus: Object.assign(Object.assign({}, spec.expectedStatus), { errors: {
173
+ recipient: new errors_1.InvalidAddress(),
174
+ } }) });
175
+ });
176
+ }
177
+ function recipientIsSameAsSender() {
178
+ return recipientRequired().map(spec => {
179
+ return Object.assign(Object.assign({}, spec), { transaction: Object.assign(Object.assign({}, spec.transaction), { recipient: testOnChainData.fundedSenderAddress }), expectedStatus: Object.assign(Object.assign({}, spec.expectedStatus), { errors: {
180
+ recipient: new errors_1.InvalidAddressBecauseDestinationIsAlsoSource(),
181
+ } }) });
182
+ });
183
+ }
184
+ function memoIsTooLong() {
185
+ return (0, fp_1.compact)(recipientRequired().map(spec => {
186
+ const tx = spec.transaction;
187
+ switch (tx.model.kind) {
188
+ case "transfer":
189
+ case "token.transfer":
190
+ tx.model.uiState.memo = "c".repeat(logic_1.MAX_MEMO_LENGTH + 1);
191
+ return Object.assign(Object.assign({}, spec), { transaction: Object.assign(Object.assign({}, spec.transaction), { recipient: testOnChainData.fundedAddress }), expectedStatus: Object.assign(Object.assign({}, spec.expectedStatus), { errors: {
192
+ memo: new errors_2.SolanaMemoIsTooLong(),
193
+ } }) });
194
+ case "token.createATA":
195
+ case "stake.createAccount":
196
+ case "stake.delegate":
197
+ case "stake.undelegate":
198
+ case "stake.withdraw":
199
+ case "stake.split":
200
+ return undefined;
201
+ default:
202
+ return (0, utils_1.assertUnreachable)(tx.model);
203
+ }
204
+ }));
205
+ }
206
+ function transferTests() {
207
+ return [
208
+ {
209
+ name: "transfer :: status is success: not all amount",
210
+ transaction: {
211
+ model: {
212
+ kind: "transfer",
213
+ uiState: {},
214
+ },
215
+ amount: testOnChainData.fundedSenderBalance.dividedBy(2),
216
+ recipient: testOnChainData.fundedAddress,
217
+ family: "solana",
218
+ },
219
+ expectedStatus: {
220
+ errors: {},
221
+ warnings: {},
222
+ estimatedFees: fees(1),
223
+ amount: testOnChainData.fundedSenderBalance.dividedBy(2),
224
+ totalSpent: testOnChainData.fundedSenderBalance.dividedBy(2).plus(fees(1)),
225
+ },
226
+ },
227
+ {
228
+ name: "transfer :: status is success: all amount",
229
+ transaction: {
230
+ model: {
231
+ kind: "transfer",
232
+ uiState: {},
233
+ },
234
+ useAllAmount: true,
235
+ amount: zero,
236
+ recipient: testOnChainData.fundedAddress,
237
+ family: "solana",
238
+ },
239
+ expectedStatus: {
240
+ errors: {},
241
+ warnings: {},
242
+ estimatedFees: fees(1),
243
+ amount: testOnChainData.fundedSenderBalance
244
+ .minus(fees(1))
245
+ .minus(testOnChainData.fees.systemAccountRentExempt),
246
+ totalSpent: testOnChainData.fundedSenderBalance.minus(testOnChainData.fees.systemAccountRentExempt),
247
+ },
248
+ },
249
+ {
250
+ name: "transfer :: status is error: not enough balance, not all amount",
251
+ transaction: {
252
+ model: {
253
+ kind: "transfer",
254
+ uiState: {},
255
+ },
256
+ amount: testOnChainData.fundedSenderBalance,
257
+ recipient: testOnChainData.fundedAddress,
258
+ family: "solana",
259
+ },
260
+ expectedStatus: {
261
+ errors: {
262
+ amount: new errors_1.NotEnoughBalance(),
263
+ },
264
+ warnings: {},
265
+ estimatedFees: fees(1),
266
+ amount: testOnChainData.fundedSenderBalance,
267
+ totalSpent: testOnChainData.fundedSenderBalance.plus(fees(1)),
268
+ },
269
+ },
270
+ {
271
+ name: "transfer :: status is error: amount is 0",
272
+ transaction: {
273
+ model: {
274
+ kind: "transfer",
275
+ uiState: {},
276
+ },
277
+ amount: zero,
278
+ recipient: testOnChainData.fundedAddress,
279
+ family: "solana",
280
+ },
281
+ expectedStatus: {
282
+ errors: {
283
+ amount: new errors_1.AmountRequired(),
284
+ },
285
+ warnings: {},
286
+ estimatedFees: fees(1),
287
+ amount: zero,
288
+ totalSpent: fees(1),
289
+ },
290
+ },
291
+ {
292
+ name: "transfer :: status is error: amount is negative",
293
+ transaction: {
294
+ model: {
295
+ kind: "transfer",
296
+ uiState: {},
297
+ },
298
+ amount: new bignumber_js_1.default(-1),
299
+ recipient: testOnChainData.fundedAddress,
300
+ family: "solana",
301
+ },
302
+ expectedStatus: {
303
+ errors: {
304
+ amount: new errors_1.AmountRequired(),
305
+ },
306
+ warnings: {},
307
+ estimatedFees: fees(1),
308
+ amount: new bignumber_js_1.default(-1),
309
+ totalSpent: zero,
310
+ },
311
+ },
312
+ {
313
+ name: "transfer :: status is warning: recipient wallet not funded",
314
+ transaction: {
315
+ model: {
316
+ kind: "transfer",
317
+ uiState: {},
318
+ },
319
+ amount: new bignumber_js_1.default(1),
320
+ recipient: testOnChainData.unfundedAddress,
321
+ family: "solana",
322
+ },
323
+ expectedStatus: {
324
+ errors: {},
325
+ warnings: {
326
+ recipient: new errors_2.SolanaAccountNotFunded(),
327
+ },
328
+ estimatedFees: fees(1),
329
+ amount: new bignumber_js_1.default(1),
330
+ totalSpent: fees(1).plus(1),
331
+ },
332
+ },
333
+ {
334
+ name: "transfer :: status is warning: recipient address is off ed25519",
335
+ transaction: {
336
+ model: {
337
+ kind: "transfer",
338
+ uiState: {},
339
+ },
340
+ amount: new bignumber_js_1.default(1),
341
+ recipient: testOnChainData.offEd25519Address,
342
+ family: "solana",
343
+ },
344
+ expectedStatus: {
345
+ errors: {},
346
+ warnings: {
347
+ recipient: new errors_2.SolanaAccountNotFunded(),
348
+ recipientOffCurve: new errors_2.SolanaAddressOffEd25519(),
349
+ },
350
+ estimatedFees: fees(1),
351
+ amount: new bignumber_js_1.default(1),
352
+ totalSpent: fees(1).plus(1),
353
+ },
354
+ },
355
+ ];
356
+ }
357
+ // uncomment when tokens are supported
358
+ /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
359
+ function tokenTests() {
360
+ return [
361
+ {
362
+ name: "token.transfer :: status is success: recipient is funded wallet, assoc token acc exists",
363
+ transaction: {
364
+ model: {
365
+ kind: "token.transfer",
366
+ uiState: {
367
+ subAccountId: wSolSubAccId,
368
+ },
369
+ },
370
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
371
+ recipient: testOnChainData.fundedAddress,
372
+ family: "solana",
373
+ },
374
+ expectedStatus: {
375
+ errors: {},
376
+ warnings: {},
377
+ estimatedFees: fees(1),
378
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
379
+ totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
380
+ },
381
+ },
382
+ {
383
+ name: "token.transfer :: status is success: recipient is correct mint token acc",
384
+ transaction: {
385
+ model: {
386
+ kind: "token.transfer",
387
+ uiState: {
388
+ subAccountId: wSolSubAccId,
389
+ },
390
+ },
391
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
392
+ recipient: testOnChainData.wSolFundedAccountAssocTokenAccAddress,
393
+ family: "solana",
394
+ },
395
+ expectedStatus: {
396
+ errors: {},
397
+ warnings: {},
398
+ estimatedFees: fees(1),
399
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
400
+ totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
401
+ },
402
+ },
403
+ {
404
+ name: "token.transfer :: status is error: recipient is another mint token acc",
405
+ transaction: {
406
+ model: {
407
+ kind: "token.transfer",
408
+ uiState: {
409
+ subAccountId: wSolSubAccId,
410
+ },
411
+ },
412
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
413
+ recipient: testOnChainData.notWSolTokenAccAddress,
414
+ family: "solana",
415
+ },
416
+ expectedStatus: {
417
+ errors: {
418
+ recipient: new errors_2.SolanaTokenAccountHoldsAnotherToken(),
419
+ },
420
+ warnings: {},
421
+ estimatedFees: fees(1),
422
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
423
+ totalSpent: zero,
424
+ },
425
+ },
426
+ {
427
+ name: "token.transfer :: status is warning: recipient is off curve",
428
+ transaction: {
429
+ model: {
430
+ kind: "token.transfer",
431
+ uiState: {
432
+ subAccountId: wSolSubAccId,
433
+ },
434
+ },
435
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
436
+ recipient: testOnChainData.offEd25519Address,
437
+ family: "solana",
438
+ },
439
+ expectedStatus: {
440
+ errors: {
441
+ recipient: new errors_2.SolanaAddressOffEd25519(),
442
+ },
443
+ warnings: {},
444
+ estimatedFees: fees(1),
445
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
446
+ totalSpent: zero,
447
+ },
448
+ },
449
+ {
450
+ name: "token.transfer :: status is success: recipient is wallet and no assoc token acc exists (will be created)",
451
+ transaction: {
452
+ model: {
453
+ kind: "token.transfer",
454
+ uiState: {
455
+ subAccountId: wSolSubAccId,
456
+ },
457
+ },
458
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
459
+ recipient: testOnChainData.unfundedAddress,
460
+ family: "solana",
461
+ },
462
+ expectedStatus: {
463
+ errors: {},
464
+ warnings: {
465
+ recipient: new errors_2.SolanaAccountNotFunded(),
466
+ recipientAssociatedTokenAccount: new errors_2.SolanaRecipientAssociatedTokenAccountWillBeFunded(),
467
+ },
468
+ // this fee is dynamic, skip
469
+ //estimatedFees: new BigNumber(2044280),
470
+ amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
471
+ totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
472
+ },
473
+ },
474
+ ];
475
+ }
476
+ function stakingTests() {
477
+ return [
478
+ {
479
+ name: "stake.createAccount :: status is error: amount is negative",
480
+ transaction: {
481
+ family: "solana",
482
+ model: {
483
+ kind: "stake.createAccount",
484
+ uiState: {
485
+ delegate: { voteAccAddress: testOnChainData.validatorAddress },
486
+ },
487
+ },
488
+ recipient: "",
489
+ amount: new bignumber_js_1.default(-1),
490
+ },
491
+ expectedStatus: {
492
+ amount: new bignumber_js_1.default(-1),
493
+ estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
494
+ totalSpent: zero,
495
+ errors: {
496
+ amount: new errors_1.AmountRequired(),
497
+ },
498
+ },
499
+ },
500
+ {
501
+ name: "stake.createAccount :: status is error: amount is zero",
502
+ transaction: {
503
+ family: "solana",
504
+ model: {
505
+ kind: "stake.createAccount",
506
+ uiState: {
507
+ delegate: { voteAccAddress: testOnChainData.validatorAddress },
508
+ },
509
+ },
510
+ recipient: "",
511
+ amount: zero,
512
+ },
513
+ expectedStatus: {
514
+ amount: zero,
515
+ estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
516
+ totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
517
+ errors: {
518
+ amount: new errors_1.AmountRequired(),
519
+ },
520
+ },
521
+ },
522
+ {
523
+ name: "stake.createAccount :: status is error: not enough balance, not all amount",
524
+ transaction: {
525
+ family: "solana",
526
+ model: {
527
+ kind: "stake.createAccount",
528
+ uiState: {
529
+ delegate: { voteAccAddress: testOnChainData.validatorAddress },
530
+ },
531
+ },
532
+ recipient: "",
533
+ amount: testOnChainData.fundedSenderBalance,
534
+ },
535
+ expectedStatus: {
536
+ amount: testOnChainData.fundedSenderBalance,
537
+ estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
538
+ totalSpent: fees(1)
539
+ .plus(testOnChainData.fees.stakeAccountRentExempt)
540
+ .plus(testOnChainData.fundedSenderBalance),
541
+ errors: {
542
+ amount: new errors_1.NotEnoughBalance(),
543
+ },
544
+ },
545
+ },
546
+ {
547
+ name: "stake.createAccount :: status is error: validator required",
548
+ transaction: {
549
+ family: "solana",
550
+ model: {
551
+ kind: "stake.createAccount",
552
+ uiState: {
553
+ delegate: { voteAccAddress: "" },
554
+ },
555
+ },
556
+ recipient: "",
557
+ amount: new bignumber_js_1.default(1),
558
+ },
559
+ expectedStatus: {
560
+ amount: new bignumber_js_1.default(1),
561
+ estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
562
+ totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
563
+ errors: {
564
+ voteAccAddr: new errors_2.SolanaValidatorRequired(),
565
+ },
566
+ },
567
+ },
568
+ {
569
+ name: "stake.createAccount :: status is error: validator has invalid address",
570
+ transaction: {
571
+ family: "solana",
572
+ model: {
573
+ kind: "stake.createAccount",
574
+ uiState: {
575
+ delegate: { voteAccAddress: "invalid address" },
576
+ },
577
+ },
578
+ recipient: "",
579
+ amount: new bignumber_js_1.default(1),
580
+ },
581
+ expectedStatus: {
582
+ amount: new bignumber_js_1.default(1),
583
+ estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
584
+ totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
585
+ errors: {
586
+ voteAccAddr: new errors_1.InvalidAddress(),
587
+ },
588
+ },
589
+ },
590
+ {
591
+ name: "stake.createAccount :: status is error: validator invalid",
592
+ transaction: {
593
+ family: "solana",
594
+ model: {
595
+ kind: "stake.createAccount",
596
+ uiState: {
597
+ delegate: { voteAccAddress: testOnChainData.fundedSenderAddress },
598
+ },
599
+ },
600
+ recipient: "",
601
+ amount: new bignumber_js_1.default(1),
602
+ },
603
+ expectedStatus: {
604
+ amount: new bignumber_js_1.default(1),
605
+ estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
606
+ totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
607
+ errors: {
608
+ voteAccAddr: new errors_2.SolanaInvalidValidator(),
609
+ },
610
+ },
611
+ },
612
+ {
613
+ name: "stake.createAccount :: status is success, not all amount",
614
+ transaction: {
615
+ family: "solana",
616
+ model: {
617
+ kind: "stake.createAccount",
618
+ uiState: {
619
+ delegate: { voteAccAddress: testOnChainData.validatorAddress },
620
+ },
621
+ },
622
+ recipient: "",
623
+ amount: new bignumber_js_1.default(1),
624
+ },
625
+ expectedStatus: {
626
+ amount: new bignumber_js_1.default(1),
627
+ estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
628
+ totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
629
+ errors: {},
630
+ },
631
+ },
632
+ {
633
+ name: "stake.createAccount :: status is success, all amount",
634
+ transaction: {
635
+ family: "solana",
636
+ model: {
637
+ kind: "stake.createAccount",
638
+ uiState: {
639
+ delegate: { voteAccAddress: testOnChainData.validatorAddress },
640
+ },
641
+ },
642
+ recipient: "",
643
+ useAllAmount: true,
644
+ amount: zero,
645
+ },
646
+ expectedStatus: {
647
+ amount: testOnChainData.fundedSenderBalance
648
+ .minus(fees(1)) // transaction fee
649
+ .minus(fees(1).multipliedBy(2)) // undelegate + withdraw fees reserve
650
+ .minus(testOnChainData.fees.stakeAccountRentExempt)
651
+ .minus(testOnChainData.fees.systemAccountRentExempt),
652
+ estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
653
+ totalSpent: testOnChainData.fundedSenderBalance
654
+ .minus(testOnChainData.fees.systemAccountRentExempt)
655
+ .minus(fees(1).multipliedBy(2)), // undelegate + withdraw fees reserve,
656
+ errors: {},
657
+ },
658
+ },
659
+ {
660
+ name: "stake.delegate :: status is error: stake account address and validator address required",
661
+ transaction: {
662
+ family: "solana",
663
+ model: {
664
+ kind: "stake.delegate",
665
+ uiState: {
666
+ stakeAccAddr: "",
667
+ voteAccAddr: "",
668
+ },
669
+ },
670
+ recipient: "",
671
+ amount: zero,
672
+ },
673
+ expectedStatus: {
674
+ amount: zero,
675
+ estimatedFees: fees(1),
676
+ totalSpent: fees(1),
677
+ errors: {
678
+ stakeAccAddr: new errors_2.SolanaStakeAccountRequired(),
679
+ voteAccAddr: new errors_2.SolanaValidatorRequired(),
680
+ },
681
+ },
682
+ },
683
+ {
684
+ name: "stake.delegate :: status is error: stake account address and validator address are invalid",
685
+ transaction: {
686
+ family: "solana",
687
+ model: {
688
+ kind: "stake.delegate",
689
+ uiState: {
690
+ stakeAccAddr: "invalid address",
691
+ voteAccAddr: "invalid address",
692
+ },
693
+ },
694
+ recipient: "",
695
+ amount: zero,
696
+ },
697
+ expectedStatus: {
698
+ amount: zero,
699
+ estimatedFees: fees(1),
700
+ totalSpent: fees(1),
701
+ errors: {
702
+ stakeAccAddr: new errors_1.InvalidAddress(),
703
+ voteAccAddr: new errors_1.InvalidAddress(),
704
+ },
705
+ },
706
+ },
707
+ {
708
+ name: "stake.delegate :: status is error: stake account not found",
709
+ transaction: {
710
+ family: "solana",
711
+ model: {
712
+ kind: "stake.delegate",
713
+ uiState: {
714
+ stakeAccAddr: testOnChainData.unfundedAddress,
715
+ voteAccAddr: testOnChainData.validatorAddress,
716
+ },
717
+ },
718
+ recipient: "",
719
+ amount: zero,
720
+ },
721
+ expectedStatus: {
722
+ amount: zero,
723
+ estimatedFees: fees(1),
724
+ totalSpent: fees(1),
725
+ errors: {
726
+ stakeAccAddr: new errors_2.SolanaStakeAccountNotFound(),
727
+ },
728
+ },
729
+ },
730
+ {
731
+ name: "stake.undelegate :: status is error: stake account required",
732
+ transaction: {
733
+ family: "solana",
734
+ model: {
735
+ kind: "stake.undelegate",
736
+ uiState: {
737
+ stakeAccAddr: "",
738
+ },
739
+ },
740
+ recipient: "",
741
+ amount: zero,
742
+ },
743
+ expectedStatus: {
744
+ amount: zero,
745
+ estimatedFees: fees(1),
746
+ totalSpent: fees(1),
747
+ errors: {
748
+ stakeAccAddr: new errors_2.SolanaStakeAccountRequired(),
749
+ },
750
+ },
751
+ },
752
+ {
753
+ name: "stake.undelegate :: status is error: stake account invalid",
754
+ transaction: {
755
+ family: "solana",
756
+ model: {
757
+ kind: "stake.undelegate",
758
+ uiState: {
759
+ stakeAccAddr: "invalid address",
760
+ },
761
+ },
762
+ recipient: "",
763
+ amount: zero,
764
+ },
765
+ expectedStatus: {
766
+ amount: zero,
767
+ estimatedFees: fees(1),
768
+ totalSpent: fees(1),
769
+ errors: {
770
+ stakeAccAddr: new errors_1.InvalidAddress(),
771
+ },
772
+ },
773
+ },
774
+ {
775
+ name: "stake.undelegate :: status is error: stake account not found",
776
+ transaction: {
777
+ family: "solana",
778
+ model: {
779
+ kind: "stake.undelegate",
780
+ uiState: {
781
+ stakeAccAddr: testOnChainData.unfundedAddress,
782
+ },
783
+ },
784
+ recipient: "",
785
+ amount: zero,
786
+ },
787
+ expectedStatus: {
788
+ amount: zero,
789
+ estimatedFees: fees(1),
790
+ totalSpent: fees(1),
791
+ errors: {
792
+ stakeAccAddr: new errors_2.SolanaStakeAccountNotFound(),
793
+ },
794
+ },
795
+ },
796
+ {
797
+ name: "stake.withdraw :: status is error: stake account required",
798
+ transaction: {
799
+ family: "solana",
800
+ model: {
801
+ kind: "stake.withdraw",
802
+ uiState: {
803
+ stakeAccAddr: "",
804
+ },
805
+ },
806
+ recipient: "",
807
+ amount: zero,
808
+ },
809
+ expectedStatus: {
810
+ amount: zero,
811
+ estimatedFees: fees(1),
812
+ totalSpent: fees(1),
813
+ errors: {
814
+ stakeAccAddr: new errors_2.SolanaStakeAccountRequired(),
815
+ },
816
+ },
817
+ },
818
+ {
819
+ name: "stake.withdraw :: status is error: stake account address invalid",
820
+ transaction: {
821
+ family: "solana",
822
+ model: {
823
+ kind: "stake.withdraw",
824
+ uiState: {
825
+ stakeAccAddr: "invalid address",
826
+ },
827
+ },
828
+ recipient: "",
829
+ amount: zero,
830
+ },
831
+ expectedStatus: {
832
+ amount: zero,
833
+ estimatedFees: fees(1),
834
+ totalSpent: fees(1),
835
+ errors: {
836
+ stakeAccAddr: new errors_1.InvalidAddress(),
837
+ },
838
+ },
839
+ },
840
+ {
841
+ name: "stake.withdraw :: status is error: stake account not found",
842
+ transaction: {
843
+ family: "solana",
844
+ model: {
845
+ kind: "stake.withdraw",
846
+ uiState: {
847
+ stakeAccAddr: testOnChainData.unfundedAddress,
848
+ },
849
+ },
850
+ recipient: "",
851
+ amount: zero,
852
+ },
853
+ expectedStatus: {
854
+ amount: zero,
855
+ estimatedFees: fees(1),
856
+ totalSpent: fees(1),
857
+ errors: {
858
+ stakeAccAddr: new errors_2.SolanaStakeAccountNotFound(),
859
+ },
860
+ },
861
+ },
862
+ ];
863
+ }
864
+ const baseAccount = {
865
+ balance: new bignumber_js_1.default(0),
866
+ spendableBalance: new bignumber_js_1.default(0),
867
+ };
868
+ const baseTx = {
869
+ family: "solana",
870
+ recipient: "",
871
+ amount: new bignumber_js_1.default(0),
872
+ };
873
+ const baseAPI = {
874
+ getLatestBlockhash: () => Promise.resolve(chain_1.LATEST_BLOCKHASH_MOCK),
875
+ getFeeForMessage: (_msg) => Promise.resolve(testOnChainData.fees.lamportsPerSignature),
876
+ };
877
+ /**
878
+ * Some business logic can not be described in terms of transactions and expected status
879
+ * in the test datasets, like stake activation/deactivation, because stake activation is
880
+ * not determenistic and changes with time. Hence the tests here to mock data
881
+ * to be determenistic.
882
+ */
883
+ describe("solana staking", () => {
884
+ test("stake.delegate :: status is error: stake account is not delegatable", () => __awaiter(void 0, void 0, void 0, function* () {
885
+ const stakeDelegateModel = {
886
+ kind: "stake.delegate",
887
+ uiState: {
888
+ stakeAccAddr: testOnChainData.unfundedAddress,
889
+ voteAccAddr: testOnChainData.validatorAddress,
890
+ },
891
+ };
892
+ const stakeTests = [
893
+ {
894
+ activationState: "activating",
895
+ txModel: stakeDelegateModel,
896
+ expectedErrors: {
897
+ fee: new errors_1.NotEnoughBalance(),
898
+ stakeAccAddr: new errors_3.SolanaStakeAccountIsNotDelegatable(),
899
+ },
900
+ },
901
+ {
902
+ activationState: "active",
903
+ txModel: stakeDelegateModel,
904
+ expectedErrors: {
905
+ fee: new errors_1.NotEnoughBalance(),
906
+ stakeAccAddr: new errors_3.SolanaStakeAccountIsNotDelegatable(),
907
+ },
908
+ },
909
+ {
910
+ activationState: "deactivating",
911
+ txModel: Object.assign(Object.assign({}, stakeDelegateModel), { uiState: Object.assign(Object.assign({}, stakeDelegateModel.uiState), { voteAccAddr: testOnChainData.unfundedAddress }) }),
912
+ expectedErrors: {
913
+ fee: new errors_1.NotEnoughBalance(),
914
+ stakeAccAddr: new errors_3.SolanaStakeAccountValidatorIsUnchangeable(),
915
+ },
916
+ },
917
+ ];
918
+ for (const stakeTest of stakeTests) {
919
+ yield runStakeTest(stakeTest);
920
+ }
921
+ }));
922
+ });
923
+ function runStakeTest(stakeTestSpec) {
924
+ return __awaiter(this, void 0, void 0, function* () {
925
+ const api = Object.assign(Object.assign({}, baseAPI), { getMinimumBalanceForRentExemption: () => Promise.resolve(testOnChainData.fees.stakeAccountRentExempt), getAccountInfo: () => {
926
+ return Promise.resolve({ data: mockedVoteAccount });
927
+ } });
928
+ const account = Object.assign(Object.assign({}, baseAccount), { freshAddress: testOnChainData.fundedSenderAddress, solanaResources: {
929
+ stakes: [
930
+ {
931
+ stakeAccAddr: testOnChainData.unfundedAddress,
932
+ delegation: {
933
+ stake: 1,
934
+ voteAccAddr: testOnChainData.validatorAddress,
935
+ },
936
+ activation: {
937
+ state: stakeTestSpec.activationState,
938
+ },
939
+ },
940
+ ],
941
+ unstakeReserve: (0, bignumber_js_1.default)(0),
942
+ } });
943
+ const tx = Object.assign(Object.assign({}, baseTx), { model: stakeTestSpec.txModel });
944
+ const preparedTx = yield (0, prepareTransaction_1.prepareTransaction)(account, tx, api);
945
+ const status = yield (0, getTransactionStatus_1.default)(account, preparedTx);
946
+ const expectedStatus = {
947
+ amount: new bignumber_js_1.default(0),
948
+ estimatedFees: new bignumber_js_1.default(testOnChainData.fees.lamportsPerSignature),
949
+ totalSpent: new bignumber_js_1.default(testOnChainData.fees.lamportsPerSignature),
950
+ errors: stakeTestSpec.expectedErrors,
951
+ warnings: {},
952
+ };
953
+ expect(status).toEqual(expectedStatus);
954
+ });
955
+ }
956
+ const mockedVoteAccount = {
957
+ parsed: {
958
+ info: {
959
+ authorizedVoters: [
960
+ {
961
+ authorizedVoter: "EvnRmnMrd69kFdbLMxWkTn1icZ7DCceRhvmb2SJXqDo4",
962
+ epoch: 283,
963
+ },
964
+ ],
965
+ authorizedWithdrawer: "EvnRmnMrd69kFdbLMxWkTn1icZ7DCceRhvmb2SJXqDo4",
966
+ commission: 7,
967
+ epochCredits: [
968
+ {
969
+ credits: "98854605",
970
+ epoch: 283,
971
+ previousCredits: "98728105",
972
+ },
973
+ ],
974
+ lastTimestamp: { slot: 122422797, timestamp: 1645796249 },
975
+ nodePubkey: "EvnRmnMrd69kFdbLMxWkTn1icZ7DCceRhvmb2SJXqDo4",
976
+ priorVoters: [],
977
+ rootSlot: 122422766,
978
+ votes: [{ confirmationCount: 1, slot: 122422797 }],
979
+ },
980
+ type: "vote",
981
+ },
982
+ program: "vote",
983
+ space: 3731,
984
+ };
985
+ describe("Solana bridge", () => {
986
+ test.todo("This is an empty test to make jest command pass. Remove it once there is a real test.");
987
+ });
988
+ //# sourceMappingURL=bridge.integration.test.js.map