@ledgerhq/coin-tron 0.0.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 (351) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +25 -0
  4. package/LICENSE.txt +21 -0
  5. package/jest.config.js +8 -0
  6. package/jest.integ.config.js +7 -0
  7. package/lib/bridge/broadcast.d.ts +7 -0
  8. package/lib/bridge/broadcast.d.ts.map +1 -0
  9. package/lib/bridge/broadcast.js +26 -0
  10. package/lib/bridge/broadcast.js.map +1 -0
  11. package/lib/bridge/buildOptimisticOperation.d.ts +5 -0
  12. package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -0
  13. package/lib/bridge/buildOptimisticOperation.js +101 -0
  14. package/lib/bridge/buildOptimisticOperation.js.map +1 -0
  15. package/lib/bridge/createTransaction.d.ts +4 -0
  16. package/lib/bridge/createTransaction.d.ts.map +1 -0
  17. package/lib/bridge/createTransaction.js +19 -0
  18. package/lib/bridge/createTransaction.js.map +1 -0
  19. package/lib/bridge/deviceTransactionConfig.d.ts +20 -0
  20. package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
  21. package/lib/bridge/deviceTransactionConfig.js +65 -0
  22. package/lib/bridge/deviceTransactionConfig.js.map +1 -0
  23. package/lib/bridge/estimateMaxSpendable.d.ts +5 -0
  24. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
  25. package/lib/bridge/estimateMaxSpendable.js +30 -0
  26. package/lib/bridge/estimateMaxSpendable.js.map +1 -0
  27. package/lib/bridge/getEstimateFees.d.ts +6 -0
  28. package/lib/bridge/getEstimateFees.d.ts.map +1 -0
  29. package/lib/bridge/getEstimateFees.js +52 -0
  30. package/lib/bridge/getEstimateFees.js.map +1 -0
  31. package/lib/bridge/getTransactionStatus.d.ts +4 -0
  32. package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
  33. package/lib/bridge/getTransactionStatus.js +218 -0
  34. package/lib/bridge/getTransactionStatus.js.map +1 -0
  35. package/lib/bridge/index.d.ts +10 -0
  36. package/lib/bridge/index.d.ts.map +1 -0
  37. package/lib/bridge/index.js +60 -0
  38. package/lib/bridge/index.js.map +1 -0
  39. package/lib/bridge/preload.d.ts +8 -0
  40. package/lib/bridge/preload.d.ts.map +1 -0
  41. package/lib/bridge/preload.js +32 -0
  42. package/lib/bridge/preload.js.map +1 -0
  43. package/lib/bridge/prepareTransaction.d.ts +4 -0
  44. package/lib/bridge/prepareTransaction.d.ts.map +1 -0
  45. package/lib/bridge/prepareTransaction.js +19 -0
  46. package/lib/bridge/prepareTransaction.js.map +1 -0
  47. package/lib/bridge/serialization.d.ts +9 -0
  48. package/lib/bridge/serialization.d.ts.map +1 -0
  49. package/lib/bridge/serialization.js +238 -0
  50. package/lib/bridge/serialization.js.map +1 -0
  51. package/lib/bridge/signOperation.d.ts +5 -0
  52. package/lib/bridge/signOperation.d.ts.map +1 -0
  53. package/lib/bridge/signOperation.js +92 -0
  54. package/lib/bridge/signOperation.js.map +1 -0
  55. package/lib/bridge/synchronization.d.ts +5 -0
  56. package/lib/bridge/synchronization.d.ts.map +1 -0
  57. package/lib/bridge/synchronization.integ.test.d.ts +3 -0
  58. package/lib/bridge/synchronization.integ.test.d.ts.map +1 -0
  59. package/lib/bridge/synchronization.integ.test.js +96 -0
  60. package/lib/bridge/synchronization.integ.test.js.map +1 -0
  61. package/lib/bridge/synchronization.js +216 -0
  62. package/lib/bridge/synchronization.js.map +1 -0
  63. package/lib/bridge/transaction.d.ts +15 -0
  64. package/lib/bridge/transaction.d.ts.map +1 -0
  65. package/lib/bridge/transaction.js +61 -0
  66. package/lib/bridge/transaction.js.map +1 -0
  67. package/lib/config.d.ts +10 -0
  68. package/lib/config.d.ts.map +1 -0
  69. package/lib/config.js +17 -0
  70. package/lib/config.js.map +1 -0
  71. package/lib/index.d.ts +3 -0
  72. package/lib/index.d.ts.map +1 -0
  73. package/lib/index.js +21 -0
  74. package/lib/index.js.map +1 -0
  75. package/lib/logic/constants.d.ts +4 -0
  76. package/lib/logic/constants.d.ts.map +1 -0
  77. package/lib/logic/constants.js +7 -0
  78. package/lib/logic/constants.js.map +1 -0
  79. package/lib/logic/pagination.d.ts +3 -0
  80. package/lib/logic/pagination.d.ts.map +1 -0
  81. package/lib/logic/pagination.js +19 -0
  82. package/lib/logic/pagination.js.map +1 -0
  83. package/lib/logic/utils.d.ts +12 -0
  84. package/lib/logic/utils.d.ts.map +1 -0
  85. package/lib/logic/utils.js +177 -0
  86. package/lib/logic/utils.js.map +1 -0
  87. package/lib/network/format.d.ts +9 -0
  88. package/lib/network/format.d.ts.map +1 -0
  89. package/lib/network/format.js +127 -0
  90. package/lib/network/format.js.map +1 -0
  91. package/lib/network/index.d.ts +30 -0
  92. package/lib/network/index.d.ts.map +1 -0
  93. package/lib/network/index.integ.test.d.ts +2 -0
  94. package/lib/network/index.integ.test.d.ts.map +1 -0
  95. package/lib/network/index.integ.test.js +38 -0
  96. package/lib/network/index.integ.test.js.map +1 -0
  97. package/lib/network/index.js +555 -0
  98. package/lib/network/index.js.map +1 -0
  99. package/lib/network/index.test.d.ts +2 -0
  100. package/lib/network/index.test.d.ts.map +1 -0
  101. package/lib/network/index.test.js +66 -0
  102. package/lib/network/index.test.js.map +1 -0
  103. package/lib/network/superRepresentativesData.mock.d.ts +69 -0
  104. package/lib/network/superRepresentativesData.mock.d.ts.map +1 -0
  105. package/lib/network/superRepresentativesData.mock.js +2208 -0
  106. package/lib/network/superRepresentativesData.mock.js.map +1 -0
  107. package/lib/network/types.d.ts +122 -0
  108. package/lib/network/types.d.ts.map +1 -0
  109. package/lib/network/types.fixture.d.ts +498 -0
  110. package/lib/network/types.fixture.d.ts.map +1 -0
  111. package/lib/network/types.fixture.js +4375 -0
  112. package/lib/network/types.fixture.js.map +1 -0
  113. package/lib/network/types.js +13 -0
  114. package/lib/network/types.js.map +1 -0
  115. package/lib/signer/getAddress.d.ts +6 -0
  116. package/lib/signer/getAddress.d.ts.map +1 -0
  117. package/lib/signer/getAddress.js +19 -0
  118. package/lib/signer/getAddress.js.map +1 -0
  119. package/lib/signer/index.d.ts +6 -0
  120. package/lib/signer/index.d.ts.map +1 -0
  121. package/lib/signer/index.js +11 -0
  122. package/lib/signer/index.js.map +1 -0
  123. package/lib/test/bot-deviceActions.d.ts +4 -0
  124. package/lib/test/bot-deviceActions.d.ts.map +1 -0
  125. package/lib/test/bot-deviceActions.js +103 -0
  126. package/lib/test/bot-deviceActions.js.map +1 -0
  127. package/lib/test/bot-specs.d.ts +7 -0
  128. package/lib/test/bot-specs.d.ts.map +1 -0
  129. package/lib/test/bot-specs.js +433 -0
  130. package/lib/test/bot-specs.js.map +1 -0
  131. package/lib/test/bridgeDatasetTest.d.ts +4 -0
  132. package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
  133. package/lib/test/bridgeDatasetTest.js +1284 -0
  134. package/lib/test/bridgeDatasetTest.js.map +1 -0
  135. package/lib/test/cli.d.ts +52 -0
  136. package/lib/test/cli.d.ts.map +1 -0
  137. package/lib/test/cli.js +155 -0
  138. package/lib/test/cli.js.map +1 -0
  139. package/lib/test/index.d.ts +6 -0
  140. package/lib/test/index.d.ts.map +1 -0
  141. package/lib/test/index.js +26 -0
  142. package/lib/test/index.js.map +1 -0
  143. package/lib/types/bridge.d.ts +245 -0
  144. package/lib/types/bridge.d.ts.map +1 -0
  145. package/lib/types/bridge.js +16 -0
  146. package/lib/types/bridge.js.map +1 -0
  147. package/lib/types/errors.d.ts +49 -0
  148. package/lib/types/errors.d.ts.map +1 -0
  149. package/lib/types/errors.js +21 -0
  150. package/lib/types/errors.js.map +1 -0
  151. package/lib/types/index.d.ts +4 -0
  152. package/lib/types/index.d.ts.map +1 -0
  153. package/lib/types/index.js +21 -0
  154. package/lib/types/index.js.map +1 -0
  155. package/lib/types/signer.d.ts +10 -0
  156. package/lib/types/signer.d.ts.map +1 -0
  157. package/lib/types/signer.js +3 -0
  158. package/lib/types/signer.js.map +1 -0
  159. package/lib-es/bridge/broadcast.d.ts +7 -0
  160. package/lib-es/bridge/broadcast.d.ts.map +1 -0
  161. package/lib-es/bridge/broadcast.js +24 -0
  162. package/lib-es/bridge/broadcast.js.map +1 -0
  163. package/lib-es/bridge/buildOptimisticOperation.d.ts +5 -0
  164. package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -0
  165. package/lib-es/bridge/buildOptimisticOperation.js +94 -0
  166. package/lib-es/bridge/buildOptimisticOperation.js.map +1 -0
  167. package/lib-es/bridge/createTransaction.d.ts +4 -0
  168. package/lib-es/bridge/createTransaction.d.ts.map +1 -0
  169. package/lib-es/bridge/createTransaction.js +14 -0
  170. package/lib-es/bridge/createTransaction.js.map +1 -0
  171. package/lib-es/bridge/deviceTransactionConfig.d.ts +20 -0
  172. package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
  173. package/lib-es/bridge/deviceTransactionConfig.js +63 -0
  174. package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
  175. package/lib-es/bridge/estimateMaxSpendable.d.ts +5 -0
  176. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
  177. package/lib-es/bridge/estimateMaxSpendable.js +25 -0
  178. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
  179. package/lib-es/bridge/getEstimateFees.d.ts +6 -0
  180. package/lib-es/bridge/getEstimateFees.d.ts.map +1 -0
  181. package/lib-es/bridge/getEstimateFees.js +47 -0
  182. package/lib-es/bridge/getEstimateFees.js.map +1 -0
  183. package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
  184. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
  185. package/lib-es/bridge/getTransactionStatus.js +213 -0
  186. package/lib-es/bridge/getTransactionStatus.js.map +1 -0
  187. package/lib-es/bridge/index.d.ts +10 -0
  188. package/lib-es/bridge/index.d.ts.map +1 -0
  189. package/lib-es/bridge/index.js +53 -0
  190. package/lib-es/bridge/index.js.map +1 -0
  191. package/lib-es/bridge/preload.d.ts +8 -0
  192. package/lib-es/bridge/preload.d.ts.map +1 -0
  193. package/lib-es/bridge/preload.js +27 -0
  194. package/lib-es/bridge/preload.js.map +1 -0
  195. package/lib-es/bridge/prepareTransaction.d.ts +4 -0
  196. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
  197. package/lib-es/bridge/prepareTransaction.js +15 -0
  198. package/lib-es/bridge/prepareTransaction.js.map +1 -0
  199. package/lib-es/bridge/serialization.d.ts +9 -0
  200. package/lib-es/bridge/serialization.d.ts.map +1 -0
  201. package/lib-es/bridge/serialization.js +229 -0
  202. package/lib-es/bridge/serialization.js.map +1 -0
  203. package/lib-es/bridge/signOperation.d.ts +5 -0
  204. package/lib-es/bridge/signOperation.d.ts.map +1 -0
  205. package/lib-es/bridge/signOperation.js +85 -0
  206. package/lib-es/bridge/signOperation.js.map +1 -0
  207. package/lib-es/bridge/synchronization.d.ts +5 -0
  208. package/lib-es/bridge/synchronization.d.ts.map +1 -0
  209. package/lib-es/bridge/synchronization.integ.test.d.ts +3 -0
  210. package/lib-es/bridge/synchronization.integ.test.d.ts.map +1 -0
  211. package/lib-es/bridge/synchronization.integ.test.js +89 -0
  212. package/lib-es/bridge/synchronization.integ.test.js.map +1 -0
  213. package/lib-es/bridge/synchronization.js +209 -0
  214. package/lib-es/bridge/synchronization.js.map +1 -0
  215. package/lib-es/bridge/transaction.d.ts +15 -0
  216. package/lib-es/bridge/transaction.d.ts.map +1 -0
  217. package/lib-es/bridge/transaction.js +55 -0
  218. package/lib-es/bridge/transaction.js.map +1 -0
  219. package/lib-es/config.d.ts +10 -0
  220. package/lib-es/config.d.ts.map +1 -0
  221. package/lib-es/config.js +12 -0
  222. package/lib-es/config.js.map +1 -0
  223. package/lib-es/index.d.ts +3 -0
  224. package/lib-es/index.d.ts.map +1 -0
  225. package/lib-es/index.js +3 -0
  226. package/lib-es/index.js.map +1 -0
  227. package/lib-es/logic/constants.d.ts +4 -0
  228. package/lib-es/logic/constants.d.ts.map +1 -0
  229. package/lib-es/logic/constants.js +4 -0
  230. package/lib-es/logic/constants.js.map +1 -0
  231. package/lib-es/logic/pagination.d.ts +3 -0
  232. package/lib-es/logic/pagination.d.ts.map +1 -0
  233. package/lib-es/logic/pagination.js +15 -0
  234. package/lib-es/logic/pagination.js.map +1 -0
  235. package/lib-es/logic/utils.d.ts +12 -0
  236. package/lib-es/logic/utils.d.ts.map +1 -0
  237. package/lib-es/logic/utils.js +167 -0
  238. package/lib-es/logic/utils.js.map +1 -0
  239. package/lib-es/network/format.d.ts +9 -0
  240. package/lib-es/network/format.d.ts.map +1 -0
  241. package/lib-es/network/format.js +117 -0
  242. package/lib-es/network/format.js.map +1 -0
  243. package/lib-es/network/index.d.ts +30 -0
  244. package/lib-es/network/index.d.ts.map +1 -0
  245. package/lib-es/network/index.integ.test.d.ts +2 -0
  246. package/lib-es/network/index.integ.test.d.ts.map +1 -0
  247. package/lib-es/network/index.integ.test.js +36 -0
  248. package/lib-es/network/index.integ.test.js.map +1 -0
  249. package/lib-es/network/index.js +524 -0
  250. package/lib-es/network/index.js.map +1 -0
  251. package/lib-es/network/index.test.d.ts +2 -0
  252. package/lib-es/network/index.test.d.ts.map +1 -0
  253. package/lib-es/network/index.test.js +63 -0
  254. package/lib-es/network/index.test.js.map +1 -0
  255. package/lib-es/network/superRepresentativesData.mock.d.ts +69 -0
  256. package/lib-es/network/superRepresentativesData.mock.d.ts.map +1 -0
  257. package/lib-es/network/superRepresentativesData.mock.js +2206 -0
  258. package/lib-es/network/superRepresentativesData.mock.js.map +1 -0
  259. package/lib-es/network/types.d.ts +122 -0
  260. package/lib-es/network/types.d.ts.map +1 -0
  261. package/lib-es/network/types.fixture.d.ts +498 -0
  262. package/lib-es/network/types.fixture.d.ts.map +1 -0
  263. package/lib-es/network/types.fixture.js +4371 -0
  264. package/lib-es/network/types.fixture.js.map +1 -0
  265. package/lib-es/network/types.js +8 -0
  266. package/lib-es/network/types.js.map +1 -0
  267. package/lib-es/signer/getAddress.d.ts +6 -0
  268. package/lib-es/signer/getAddress.d.ts.map +1 -0
  269. package/lib-es/signer/getAddress.js +17 -0
  270. package/lib-es/signer/getAddress.js.map +1 -0
  271. package/lib-es/signer/index.d.ts +6 -0
  272. package/lib-es/signer/index.d.ts.map +1 -0
  273. package/lib-es/signer/index.js +6 -0
  274. package/lib-es/signer/index.js.map +1 -0
  275. package/lib-es/test/bot-deviceActions.d.ts +4 -0
  276. package/lib-es/test/bot-deviceActions.d.ts.map +1 -0
  277. package/lib-es/test/bot-deviceActions.js +100 -0
  278. package/lib-es/test/bot-deviceActions.js.map +1 -0
  279. package/lib-es/test/bot-specs.d.ts +7 -0
  280. package/lib-es/test/bot-specs.d.ts.map +1 -0
  281. package/lib-es/test/bot-specs.js +428 -0
  282. package/lib-es/test/bot-specs.js.map +1 -0
  283. package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
  284. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
  285. package/lib-es/test/bridgeDatasetTest.js +1278 -0
  286. package/lib-es/test/bridgeDatasetTest.js.map +1 -0
  287. package/lib-es/test/cli.d.ts +52 -0
  288. package/lib-es/test/cli.d.ts.map +1 -0
  289. package/lib-es/test/cli.js +149 -0
  290. package/lib-es/test/cli.js.map +1 -0
  291. package/lib-es/test/index.d.ts +6 -0
  292. package/lib-es/test/index.d.ts.map +1 -0
  293. package/lib-es/test/index.js +6 -0
  294. package/lib-es/test/index.js.map +1 -0
  295. package/lib-es/types/bridge.d.ts +245 -0
  296. package/lib-es/types/bridge.d.ts.map +1 -0
  297. package/lib-es/types/bridge.js +11 -0
  298. package/lib-es/types/bridge.js.map +1 -0
  299. package/lib-es/types/errors.d.ts +49 -0
  300. package/lib-es/types/errors.d.ts.map +1 -0
  301. package/lib-es/types/errors.js +18 -0
  302. package/lib-es/types/errors.js.map +1 -0
  303. package/lib-es/types/index.d.ts +4 -0
  304. package/lib-es/types/index.d.ts.map +1 -0
  305. package/lib-es/types/index.js +5 -0
  306. package/lib-es/types/index.js.map +1 -0
  307. package/lib-es/types/signer.d.ts +10 -0
  308. package/lib-es/types/signer.d.ts.map +1 -0
  309. package/lib-es/types/signer.js +2 -0
  310. package/lib-es/types/signer.js.map +1 -0
  311. package/package.json +133 -0
  312. package/src/bridge/broadcast.ts +24 -0
  313. package/src/bridge/buildOptimisticOperation.ts +133 -0
  314. package/src/bridge/createTransaction.ts +16 -0
  315. package/src/bridge/deviceTransactionConfig.ts +99 -0
  316. package/src/bridge/estimateMaxSpendable.ts +32 -0
  317. package/src/bridge/getEstimateFees.ts +52 -0
  318. package/src/bridge/getTransactionStatus.ts +263 -0
  319. package/src/bridge/index.ts +78 -0
  320. package/src/bridge/preload.ts +24 -0
  321. package/src/bridge/prepareTransaction.ts +12 -0
  322. package/src/bridge/serialization.ts +288 -0
  323. package/src/bridge/signOperation.ts +123 -0
  324. package/src/bridge/synchronization.integ.test.ts +105 -0
  325. package/src/bridge/synchronization.ts +284 -0
  326. package/src/bridge/transaction.ts +84 -0
  327. package/src/config.ts +24 -0
  328. package/src/index.ts +3 -0
  329. package/src/logic/constants.ts +4 -0
  330. package/src/logic/pagination.ts +21 -0
  331. package/src/logic/utils.ts +231 -0
  332. package/src/network/format.ts +148 -0
  333. package/src/network/index.integ.test.ts +33 -0
  334. package/src/network/index.test.ts +61 -0
  335. package/src/network/index.ts +747 -0
  336. package/src/network/superRepresentativesData.mock.ts +2205 -0
  337. package/src/network/types.fixture.ts +4476 -0
  338. package/src/network/types.ts +147 -0
  339. package/src/signer/getAddress.ts +13 -0
  340. package/src/signer/index.ts +7 -0
  341. package/src/test/bot-deviceActions.ts +121 -0
  342. package/src/test/bot-specs.ts +457 -0
  343. package/src/test/bridgeDatasetTest.ts +1343 -0
  344. package/src/test/cli.ts +219 -0
  345. package/src/test/index.ts +6 -0
  346. package/src/types/bridge.ts +304 -0
  347. package/src/types/errors.ts +22 -0
  348. package/src/types/index.ts +4 -0
  349. package/src/types/signer.ts +9 -0
  350. package/tsconfig.json +14 -0
  351. package/types/tronweb/index.d.ts +5 -0
@@ -0,0 +1,1343 @@
1
+ import {
2
+ AmountRequired,
3
+ InvalidAddress,
4
+ InvalidAddressBecauseDestinationIsAlsoSource,
5
+ NotEnoughBalance,
6
+ RecipientRequired,
7
+ } from "@ledgerhq/errors";
8
+ import type { Account, CurrenciesData, DatasetTest, TokenAccount } from "@ledgerhq/types-live";
9
+ import { BigNumber } from "bignumber.js";
10
+ import invariant from "invariant";
11
+ import {
12
+ TronInvalidFreezeAmount,
13
+ TronInvalidUnDelegateResourceAmount,
14
+ TronInvalidVoteCount,
15
+ TronNoFrozenForBandwidth,
16
+ TronNoFrozenForEnergy,
17
+ TronNoReward,
18
+ TronNoUnfrozenResource,
19
+ TronNotEnoughTronPower,
20
+ TronSendTrc20ToNewAccountForbidden,
21
+ TronUnexpectedFees,
22
+ TronVoteRequired,
23
+ } from "../types/errors";
24
+ import { ACTIVATION_FEES } from "../logic/constants";
25
+ import { fromTransactionRaw } from "../bridge/transaction";
26
+ import type { Transaction, TronAccountRaw } from "../types";
27
+
28
+ const unactivatedAddress = "TXFeV31qgUQYMLog3axKJeEBbXpQFtHsXD";
29
+ const activatedAddress1 = "TRqkRnAj6ceJFYAn2p1eE7aWrgBBwtdhS9";
30
+
31
+ const expectedTokenAccount = (a: TokenAccount | undefined) => {
32
+ invariant(a && a.type === "TokenAccount", "expected token account");
33
+ return a;
34
+ };
35
+
36
+ const getTokenAccountId = (account: Account, id: string) =>
37
+ expectedTokenAccount(
38
+ (account.subAccounts || []).find(a => expectedTokenAccount(a).token.id === id),
39
+ ).id;
40
+
41
+ const tron: CurrenciesData<Transaction> = {
42
+ FIXME_ignoreAccountFields: [
43
+ "tronResources.cacheTransactionInfoById", // this is a cache, don't save it
44
+ "tronResources.unwithdrawnReward", // it changes every vote cycles
45
+ "tronResources.bandwidth", // it changes if a tx is made
46
+ "tronResources.energy", // it keep changing?
47
+ ],
48
+ scanAccounts: [
49
+ {
50
+ name: "tron seed 1",
51
+ apdus: `
52
+ => e00200000d038000002c800000c380000000
53
+ <= 41049fc19cbc6d0f525b1c6947b4a36aec74b48e15f2531c5e7e58d272c9e926786da290eb3505d8fab9c83818c1174d9bc96fd18e0527365cba6b9534d43ad5052b2254546962427833526b4a4d6355394171357348337a376a5733455057676b324252419000
54
+ => e002000015058000002c800000c3800000000000000000000000
55
+ <= 41040897dbec3465fcfa24324d6be690bccab3bdb5bba7f7cbe756d58362336a91a4a8b9bdd0cb25cb97afdde08c85c2081f3a3a4ba96a012c91c835e992783ceca1225452716b526e416a3663654a4659416e3270316545376157726742427774646853399000
56
+ => e002000015058000002c800000c3800000010000000000000000
57
+ <= 4104af6028b35cd69b028df9bd1a8eccc9f7cc46ca916babe1b87500e17a65b8833e0d4a90e6ba7cfd76492378f43868cc48c89451362033cf5982f2fba92306fc95225448416534424e56787032393371677951457158456b484d705063717447373362699000
58
+ => e002000015058000002c800000c3800000020000000000000000
59
+ <= 410461936750537e962cb02353c8906cebfd61f35ee0b704be0a02640e5f2e0bb152c0614008db5753fc728cb4fd1eac47f843229ccb928890f3ac805d8cdb6b8e332254576570556e79427a487832616f45674e476f745a484379625a4a5a6531414864579000
60
+ => e002000015058000002c800000c3800000030000000000000000
61
+ <= 4104fd0fa05cefc7c50894935125c1777bba938043e19ad96fd62d4ee708e5bc5b610f401becc0b4ecb48370e1bbaf4afda6e11b425b424c8ff007205034164399392254544250424b316e386e5831566b5950683766734d35364b4c36473948524d3756639000
62
+ => e002000015058000002c800000c3800000040000000000000000
63
+ <= 41041da2283f752d855d858ea3b86ef44ed78def4878000e2508ed1a4ca5fce6a120a1f3edfbc14173577057b62e156f4a110410d886bb022e398cf607d8eb26f0c12254527a4164386b37386f623577545748657065447051727555754b596666683438789000
64
+ => e002000015058000002c800000c3800000050000000000000000
65
+ <= 4104dfeedfe3ec947d26b9b2be199c4d2a1b59b53ce8938fa37a3ebfccba5cd3432457987972d62f5ff7cebffba1655efe26324e25ae1c33d4c6b39d1ccf1a6c433f2254434b4655664672384555394356664b7a7138764c50786b5a5647347641657754649000
66
+ => e002000015058000002c800000c3800000060000000000000000
67
+ <= 4104f0bc4270d8d593486409062058abeabb87a0f2907b57d0f92a9173164e39b1a12a61ffce4c002f395cab8a790ccd00d41e056a32d285a01b218334d294abbf1f2254526552347a64464537384e614b67555555654869564758534763434434634e796a9000
68
+ => e002000015058000002c800000c3800000070000000000000000
69
+ <= 4104ac3f861b2006b1d950677b0ac77cc660a497d9e3afcb6caeb2bf4a67943535d56c0915fbd7476e93d50317fd13084ff3eb820a60cc448627e2e1be51c6145dc8225458466556333171675551594d4c6f673361784b4a654542625870514674487358449000
70
+ `,
71
+ },
72
+ ],
73
+ accounts: [
74
+ {
75
+ transactions: [
76
+ {
77
+ name: "sendSuccess",
78
+ transaction: fromTransactionRaw({
79
+ family: "tron",
80
+ recipient: activatedAddress1,
81
+ amount: "1000000",
82
+ networkInfo: null,
83
+ mode: "send",
84
+ duration: undefined,
85
+ resource: undefined,
86
+ votes: [],
87
+ }),
88
+ expectedStatus: {
89
+ amount: new BigNumber("1000000"),
90
+ errors: {},
91
+ warnings: {},
92
+ totalSpent: new BigNumber("1000000"),
93
+ estimatedFees: new BigNumber("0"),
94
+ },
95
+ },
96
+ {
97
+ name: "Send max",
98
+ transaction: fromTransactionRaw({
99
+ family: "tron",
100
+ recipient: activatedAddress1,
101
+ amount: "0",
102
+ useAllAmount: true,
103
+ networkInfo: null,
104
+ mode: "send",
105
+ duration: undefined,
106
+ resource: undefined,
107
+ votes: [],
108
+ }),
109
+ expectedStatus: account => ({
110
+ amount: account.spendableBalance,
111
+ errors: {},
112
+ warnings: {},
113
+ totalSpent: account.spendableBalance,
114
+ estimatedFees: new BigNumber("0"),
115
+ }),
116
+ },
117
+ {
118
+ name: "useAllAmountToUnactivatedAddressSuccess",
119
+ transaction: fromTransactionRaw({
120
+ family: "tron",
121
+ recipient: unactivatedAddress,
122
+ amount: "0",
123
+ useAllAmount: true,
124
+ networkInfo: null,
125
+ mode: "send",
126
+ duration: undefined,
127
+ resource: undefined,
128
+ votes: [],
129
+ }),
130
+ expectedStatus: (account, transaction, status) => {
131
+ return {
132
+ amount: account.spendableBalance.minus(status.estimatedFees),
133
+ errors: {},
134
+ warnings: {},
135
+ totalSpent: account.spendableBalance,
136
+ };
137
+ },
138
+ },
139
+ {
140
+ name: "voteSuccess",
141
+ transaction: fromTransactionRaw({
142
+ family: "tron",
143
+ recipient: activatedAddress1,
144
+ amount: "0",
145
+ networkInfo: null,
146
+ mode: "vote",
147
+ duration: undefined,
148
+ resource: undefined,
149
+ votes: [
150
+ {
151
+ address: "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH",
152
+ voteCount: 1,
153
+ },
154
+ {
155
+ address: "TGj1Ej1qRzL9feLTLhjwgxXF4Ct6GTWg2U",
156
+ voteCount: 1,
157
+ },
158
+ ],
159
+ }),
160
+ expectedStatus: {
161
+ amount: new BigNumber("0"),
162
+ errors: {},
163
+ warnings: {},
164
+ totalSpent: new BigNumber("0"),
165
+ estimatedFees: new BigNumber("0"),
166
+ },
167
+ },
168
+ {
169
+ name: "freezeBandwidthSuccess",
170
+ transaction: fromTransactionRaw({
171
+ family: "tron",
172
+ recipient: "",
173
+ amount: "1000000",
174
+ networkInfo: null,
175
+ mode: "freeze",
176
+ duration: undefined,
177
+ resource: "BANDWIDTH",
178
+ votes: [],
179
+ }),
180
+ expectedStatus: {
181
+ amount: new BigNumber("1000000"),
182
+ errors: {},
183
+ warnings: {},
184
+ totalSpent: new BigNumber("1000000"),
185
+ estimatedFees: new BigNumber("0"),
186
+ },
187
+ },
188
+ {
189
+ name: "freezeEnergySuccess",
190
+ transaction: fromTransactionRaw({
191
+ family: "tron",
192
+ recipient: "",
193
+ amount: "1000000",
194
+ networkInfo: null,
195
+ mode: "freeze",
196
+ duration: undefined,
197
+ resource: "ENERGY",
198
+ votes: [],
199
+ }),
200
+ expectedStatus: {
201
+ amount: new BigNumber("1000000"),
202
+ errors: {},
203
+ warnings: {},
204
+ totalSpent: new BigNumber("1000000"),
205
+ estimatedFees: new BigNumber("0"),
206
+ },
207
+ },
208
+ {
209
+ name: "NotEnoughFrozenEnergy",
210
+ transaction: fromTransactionRaw({
211
+ family: "tron",
212
+ recipient: "TBsyKdNsCKNXLgvneeUJ3rbXgWSgk6paTM",
213
+ amount: "1000000",
214
+ networkInfo: null,
215
+ mode: "unfreeze",
216
+ duration: undefined,
217
+ resource: "ENERGY",
218
+ votes: [],
219
+ }),
220
+ expectedStatus: {
221
+ amount: new BigNumber("0"),
222
+ errors: {
223
+ resource: new TronNoFrozenForEnergy(),
224
+ },
225
+ warnings: {},
226
+ totalSpent: new BigNumber("0"),
227
+ estimatedFees: new BigNumber("0"),
228
+ },
229
+ },
230
+ {
231
+ name: "NotEnoughFrozenBandwidth",
232
+ transaction: fromTransactionRaw({
233
+ family: "tron",
234
+ recipient: "TBsyKdNsCKNXLgvneeUJ3rbXgWSgk6paTM",
235
+ amount: "1000000",
236
+ networkInfo: null,
237
+ mode: "unfreeze",
238
+ duration: undefined,
239
+ resource: "BANDWIDTH",
240
+ votes: [],
241
+ }),
242
+ expectedStatus: {
243
+ amount: new BigNumber("0"),
244
+ errors: {
245
+ resource: new TronNoFrozenForBandwidth(),
246
+ },
247
+ warnings: {},
248
+ totalSpent: new BigNumber("0"),
249
+ estimatedFees: new BigNumber("0"),
250
+ },
251
+ },
252
+ {
253
+ name: "NoUnfrozenBalances",
254
+ transaction: fromTransactionRaw({
255
+ family: "tron",
256
+ recipient: "",
257
+ amount: "0",
258
+ networkInfo: null,
259
+ mode: "withdrawExpireUnfreeze",
260
+ duration: undefined,
261
+ votes: [],
262
+ resource: undefined,
263
+ }),
264
+ expectedStatus: {
265
+ amount: new BigNumber("0"),
266
+ errors: {
267
+ resource: new TronNoUnfrozenResource(),
268
+ },
269
+ warnings: {},
270
+ totalSpent: new BigNumber("0"),
271
+ estimatedFees: new BigNumber("0"),
272
+ },
273
+ },
274
+ {
275
+ name: "InvalidUnDelegateResourceAmount",
276
+ transaction: fromTransactionRaw({
277
+ family: "tron",
278
+ recipient: "TBsyKdNsCKNXLgvneeUJ3rbXgWSgk6paTM",
279
+ amount: "100",
280
+ networkInfo: null,
281
+ mode: "unDelegateResource",
282
+ duration: undefined,
283
+ resource: "BANDWIDTH",
284
+ votes: [],
285
+ }),
286
+ expectedStatus: {
287
+ amount: new BigNumber("0"),
288
+ errors: {
289
+ resource: new TronInvalidUnDelegateResourceAmount(),
290
+ },
291
+ warnings: {},
292
+ totalSpent: new BigNumber("0"),
293
+ estimatedFees: new BigNumber("0"),
294
+ },
295
+ },
296
+ {
297
+ name: "recipientRequired",
298
+ transaction: fromTransactionRaw({
299
+ family: "tron",
300
+ recipient: "",
301
+ amount: "1000000",
302
+ networkInfo: null,
303
+ mode: "send",
304
+ duration: undefined,
305
+ resource: undefined,
306
+ votes: [],
307
+ }),
308
+ expectedStatus: {
309
+ amount: new BigNumber("1000000"),
310
+ errors: {
311
+ recipient: new RecipientRequired(),
312
+ },
313
+ warnings: {},
314
+ totalSpent: new BigNumber("1000000"),
315
+ estimatedFees: new BigNumber("0"),
316
+ },
317
+ },
318
+ {
319
+ name: "invalidRecipientIsTheSame",
320
+ transaction: fromTransactionRaw({
321
+ family: "tron",
322
+ recipient: "THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi",
323
+ amount: "1000000",
324
+ networkInfo: null,
325
+ mode: "send",
326
+ duration: undefined,
327
+ resource: undefined,
328
+ votes: [],
329
+ }),
330
+ expectedStatus: {
331
+ amount: new BigNumber("1000000"),
332
+ errors: {
333
+ recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
334
+ },
335
+ warnings: {},
336
+ totalSpent: new BigNumber("1000000"),
337
+ estimatedFees: new BigNumber("0"),
338
+ },
339
+ },
340
+ {
341
+ name: "invalidRecipientUnknown",
342
+ transaction: fromTransactionRaw({
343
+ family: "tron",
344
+ recipient: "unknown",
345
+ amount: "1000000",
346
+ networkInfo: null,
347
+ mode: "send",
348
+ duration: undefined,
349
+ resource: undefined,
350
+ votes: [],
351
+ }),
352
+ expectedStatus: {
353
+ amount: new BigNumber("1000000"),
354
+ errors: {
355
+ recipient: new InvalidAddress(),
356
+ },
357
+ warnings: {},
358
+ totalSpent: new BigNumber("1000000"),
359
+ estimatedFees: new BigNumber("0"),
360
+ },
361
+ },
362
+ {
363
+ name: "amountRequired",
364
+ transaction: fromTransactionRaw({
365
+ family: "tron",
366
+ recipient: activatedAddress1,
367
+ amount: "0",
368
+ networkInfo: null,
369
+ mode: "send",
370
+ duration: undefined,
371
+ resource: undefined,
372
+ votes: [],
373
+ }),
374
+ expectedStatus: {
375
+ amount: new BigNumber("0"),
376
+ errors: {
377
+ amount: new AmountRequired(),
378
+ },
379
+ warnings: {},
380
+ totalSpent: new BigNumber("0"),
381
+ estimatedFees: new BigNumber("0"),
382
+ },
383
+ },
384
+ {
385
+ name: "notEnoughBalance",
386
+ transaction: fromTransactionRaw({
387
+ family: "tron",
388
+ recipient: activatedAddress1,
389
+ amount: "1000000000",
390
+ networkInfo: null,
391
+ mode: "send",
392
+ duration: undefined,
393
+ resource: undefined,
394
+ votes: [],
395
+ }),
396
+ expectedStatus: {
397
+ amount: new BigNumber("1000000000"),
398
+ errors: {
399
+ amount: new NotEnoughBalance(),
400
+ },
401
+ warnings: {},
402
+ totalSpent: new BigNumber("1000000000"),
403
+ estimatedFees: new BigNumber("0"),
404
+ },
405
+ },
406
+ {
407
+ name: "notEnoughBalance to unactivated",
408
+ transaction: t => ({
409
+ ...t,
410
+ amount: new BigNumber(100),
411
+ recipient: unactivatedAddress,
412
+ }),
413
+ expectedStatus: () => ({
414
+ estimatedFees: ACTIVATION_FEES,
415
+ }),
416
+ },
417
+ {
418
+ name: "enoughBalance near the max",
419
+ transaction: (t, account) => ({
420
+ ...t,
421
+ recipient: unactivatedAddress,
422
+ amount: account.spendableBalance.minus(ACTIVATION_FEES).minus(1),
423
+ }),
424
+ expectedStatus: () => ({
425
+ errors: {},
426
+ }),
427
+ },
428
+ {
429
+ name: "enoughBalance at exactly the max",
430
+ transaction: (t, account) => ({
431
+ ...t,
432
+ recipient: unactivatedAddress,
433
+ amount: account.spendableBalance.minus(ACTIVATION_FEES),
434
+ }),
435
+ expectedStatus: () => ({
436
+ errors: {},
437
+ }),
438
+ },
439
+ {
440
+ name: "estimatedFeesWarning",
441
+ // send 1TRX to new account = +0.1TRX of fees
442
+ transaction: fromTransactionRaw({
443
+ family: "tron",
444
+ recipient: unactivatedAddress,
445
+ amount: "1000000",
446
+ networkInfo: null,
447
+ mode: "send",
448
+ duration: undefined,
449
+ resource: undefined,
450
+ votes: [],
451
+ }),
452
+ expectedStatus: {
453
+ amount: new BigNumber("1000000"),
454
+ errors: {},
455
+ warnings: {
456
+ fee: new TronUnexpectedFees("Estimated fees"),
457
+ },
458
+ totalSpent: new BigNumber("2100000"),
459
+ estimatedFees: new BigNumber("1100000"),
460
+ },
461
+ },
462
+ {
463
+ name: "tronSendTrc20ToContractAddressSuccess",
464
+ transaction: (t, account) => ({
465
+ ...t,
466
+ recipient: "TYmGYpY3LuHHge9jmTtq2aQmSpUpqKcZtJ",
467
+ // corresponds to a valid deposit contract address
468
+ subAccountId: getTokenAccountId(
469
+ account,
470
+ "tron/trc20/tla2f6vpqdgre67v1736s7bj8ray5wyju7",
471
+ ),
472
+ amount: new BigNumber("1000000"),
473
+ }),
474
+ expectedStatus: {
475
+ amount: new BigNumber("1000000"),
476
+ errors: {},
477
+ warnings: {},
478
+ totalSpent: new BigNumber("1000000"),
479
+ estimatedFees: new BigNumber("0"),
480
+ },
481
+ },
482
+ {
483
+ name: "tronSendTrc20ToNewAccountForbidden",
484
+ transaction: (t, account) => ({
485
+ ...t,
486
+ recipient: unactivatedAddress,
487
+ subAccountId: getTokenAccountId(
488
+ account,
489
+ "tron/trc20/tla2f6vpqdgre67v1736s7bj8ray5wyju7",
490
+ ),
491
+ amount: new BigNumber("1000000"),
492
+ }),
493
+ expectedStatus: {
494
+ amount: new BigNumber("1000000"),
495
+ errors: {
496
+ recipient: new TronSendTrc20ToNewAccountForbidden(),
497
+ },
498
+ warnings: {},
499
+ totalSpent: new BigNumber("1000000"),
500
+ estimatedFees: new BigNumber("0"),
501
+ },
502
+ }, // FIXME account have moved...
503
+
504
+ /*
505
+ {
506
+ name: "tronSendTrc20NotEnoughEnergyWarning",
507
+ transaction: fromTransactionRaw({
508
+ family: "tron",
509
+ recipient: activatedAddress1,
510
+ subAccountId:
511
+ "tronjs:2:tron:THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi:+TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
512
+ amount: "1000000",
513
+ networkInfo: null,
514
+ mode: "send",
515
+ duration: undefined,
516
+ resource: undefined,
517
+ votes: []
518
+ }),
519
+ expectedStatus: {
520
+ amount: new BigNumber("1000000"),
521
+ errors: {},
522
+ warnings: { amount: new TronNotEnoughEnergy() },
523
+ totalSpent: new BigNumber("1000000"),
524
+ estimatedFees: new BigNumber("0")
525
+ }
526
+ },
527
+ */
528
+ {
529
+ name: "tronSendTrc20Success",
530
+ transaction: (t, account) => ({
531
+ ...t,
532
+ recipient: activatedAddress1,
533
+ subAccountId: getTokenAccountId(
534
+ account,
535
+ "tron/trc20/tla2f6vpqdgre67v1736s7bj8ray5wyju7",
536
+ ),
537
+ amount: new BigNumber("1000000"),
538
+ }),
539
+ expectedStatus: {
540
+ amount: new BigNumber("1000000"),
541
+ errors: {},
542
+ warnings: {},
543
+ totalSpent: new BigNumber("1000000"),
544
+ estimatedFees: new BigNumber("0"),
545
+ },
546
+ },
547
+ {
548
+ name: "tronInvalidFreezeAmount",
549
+ transaction: fromTransactionRaw({
550
+ family: "tron",
551
+ recipient: "",
552
+ amount: "100000",
553
+ networkInfo: null,
554
+ mode: "freeze",
555
+ duration: undefined,
556
+ resource: "BANDWIDTH",
557
+ votes: [],
558
+ }),
559
+ expectedStatus: {
560
+ amount: new BigNumber("100000"),
561
+ errors: {
562
+ amount: new TronInvalidFreezeAmount(),
563
+ },
564
+ warnings: {},
565
+ totalSpent: new BigNumber("100000"),
566
+ estimatedFees: new BigNumber("0"),
567
+ },
568
+ },
569
+ {
570
+ name: "tronLegacyUnFreezeBandwidth",
571
+ transaction: fromTransactionRaw({
572
+ family: "tron",
573
+ recipient: "",
574
+ amount: "1000000",
575
+ networkInfo: null,
576
+ mode: "legacyUnfreeze",
577
+ duration: undefined,
578
+ resource: "BANDWIDTH",
579
+ votes: [],
580
+ }),
581
+ expectedStatus: {
582
+ amount: new BigNumber("0"),
583
+ errors: {},
584
+ warnings: {},
585
+ totalSpent: new BigNumber("0"),
586
+ estimatedFees: new BigNumber("0"),
587
+ },
588
+ },
589
+ // Not so sure how ot make this test work again, frozen energy seems to be expired.
590
+ // {
591
+ // name: "tronNoFrozenForEnergy",
592
+ // transaction: fromTransactionRaw({
593
+ // family: "tron",
594
+ // recipient: "",
595
+ // amount: "0",
596
+ // networkInfo: null,
597
+ // mode: "unfreeze",
598
+ // duration: undefined,
599
+ // resource: "ENERGY",
600
+ // votes: [],
601
+ // }),
602
+ // expectedStatus: {
603
+ // amount: new BigNumber("0"),
604
+ // errors: {
605
+ // resource: new TronNoFrozenForEnergy(),
606
+ // },
607
+ // warnings: {},
608
+ // totalSpent: new BigNumber("0"),
609
+ // estimatedFees: new BigNumber("0"),
610
+ // },
611
+ // },
612
+ {
613
+ name: "tronVoteRequired",
614
+ transaction: fromTransactionRaw({
615
+ family: "tron",
616
+ recipient: "",
617
+ amount: "0",
618
+ networkInfo: null,
619
+ mode: "vote",
620
+ duration: undefined,
621
+ resource: undefined,
622
+ votes: [],
623
+ }),
624
+ expectedStatus: {
625
+ amount: new BigNumber("0"),
626
+ errors: {
627
+ vote: new TronVoteRequired(),
628
+ },
629
+ warnings: {},
630
+ totalSpent: new BigNumber("0"),
631
+ estimatedFees: new BigNumber("0"),
632
+ },
633
+ },
634
+ {
635
+ name: "invalidVoteAddress",
636
+ transaction: fromTransactionRaw({
637
+ family: "tron",
638
+ recipient: activatedAddress1,
639
+ amount: "0",
640
+ networkInfo: null,
641
+ mode: "vote",
642
+ duration: undefined,
643
+ resource: undefined,
644
+ votes: [
645
+ {
646
+ address: "abcde",
647
+ voteCount: 1,
648
+ },
649
+ ],
650
+ }),
651
+ expectedStatus: {
652
+ amount: new BigNumber("0"),
653
+ errors: {
654
+ vote: new InvalidAddress(),
655
+ },
656
+ warnings: {},
657
+ totalSpent: new BigNumber("0"),
658
+ estimatedFees: new BigNumber("0"),
659
+ },
660
+ },
661
+ {
662
+ name: "tronInvalidVoteCount",
663
+ transaction: fromTransactionRaw({
664
+ family: "tron",
665
+ recipient: activatedAddress1,
666
+ amount: "0",
667
+ networkInfo: null,
668
+ mode: "vote",
669
+ duration: undefined,
670
+ resource: undefined,
671
+ votes: [
672
+ {
673
+ address: "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH",
674
+ voteCount: 0,
675
+ },
676
+ ],
677
+ }),
678
+ expectedStatus: {
679
+ amount: new BigNumber("0"),
680
+ errors: {
681
+ vote: new TronInvalidVoteCount(),
682
+ },
683
+ warnings: {},
684
+ totalSpent: new BigNumber("0"),
685
+ estimatedFees: new BigNumber("0"),
686
+ },
687
+ },
688
+ {
689
+ name: "tronNotEnoughTronPower",
690
+ transaction: fromTransactionRaw({
691
+ family: "tron",
692
+ recipient: "",
693
+ amount: "0",
694
+ networkInfo: null,
695
+ mode: "vote",
696
+ duration: undefined,
697
+ resource: undefined,
698
+ votes: [
699
+ {
700
+ address: "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH",
701
+ voteCount: 5,
702
+ },
703
+ {
704
+ address: "TGj1Ej1qRzL9feLTLhjwgxXF4Ct6GTWg2U",
705
+ voteCount: 5,
706
+ },
707
+ ],
708
+ }),
709
+ expectedStatus: {
710
+ amount: new BigNumber("0"),
711
+ errors: {
712
+ vote: new TronNotEnoughTronPower(),
713
+ },
714
+ warnings: {},
715
+ totalSpent: new BigNumber("0"),
716
+ estimatedFees: new BigNumber("0"),
717
+ },
718
+ },
719
+ {
720
+ name: "tronNoReward",
721
+ transaction: fromTransactionRaw({
722
+ family: "tron",
723
+ recipient: "",
724
+ amount: "0",
725
+ networkInfo: null,
726
+ mode: "claimReward",
727
+ duration: undefined,
728
+ resource: undefined,
729
+ votes: [],
730
+ }),
731
+ expectedStatus: {
732
+ amount: new BigNumber("0"),
733
+ errors: {
734
+ reward: new TronNoReward(),
735
+ },
736
+ warnings: {},
737
+ totalSpent: new BigNumber("0"),
738
+ estimatedFees: new BigNumber("0"),
739
+ },
740
+ },
741
+ ],
742
+ raw: {
743
+ id: "js:2:tron:THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi:",
744
+ seedIdentifier: "THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi",
745
+ name: "Tron 2",
746
+ derivationMode: "",
747
+ index: 1,
748
+ freshAddress: "THAe4BNVxp293qgyQEqXEkHMpPcqtG73bi",
749
+ freshAddressPath: "44'/195'/0'/0/0",
750
+ pendingOperations: [],
751
+ currencyId: "tron",
752
+ balance: "10006000",
753
+ spendableBalance: "1606000",
754
+ subAccounts: [],
755
+ operations: [],
756
+ lastSyncDate: "",
757
+ blockHeight: 0,
758
+ tronResources: {
759
+ frozen: { bandwidth: undefined, energy: undefined },
760
+ delegatedFrozen: { bandwidth: undefined, energy: undefined },
761
+ unFrozen: { bandwidth: [], energy: [] },
762
+ legacyFrozen: {
763
+ bandwidth: { amount: "2000000", expiredAt: "2022-05-23T08:20:39.000Z" },
764
+ energy: { amount: "1000000", expiredAt: "2022-05-22T12:51:12.000Z" },
765
+ },
766
+ votes: [],
767
+ tronPower: 3,
768
+ energy: "12",
769
+ bandwidth: {
770
+ freeUsed: "0",
771
+ freeLimit: "600",
772
+ gainedUsed: "0",
773
+ gainedLimit: "2",
774
+ },
775
+ unwithdrawnReward: "0",
776
+ lastWithdrawnRewardDate: undefined,
777
+ lastVotedDate: undefined,
778
+ cacheTransactionInfoById: {},
779
+ },
780
+ } as TronAccountRaw,
781
+ },
782
+ {
783
+ transactions: [
784
+ {
785
+ name: "claimRewardSuccess",
786
+ transaction: fromTransactionRaw({
787
+ family: "tron",
788
+ recipient: "",
789
+ amount: "0",
790
+ networkInfo: null,
791
+ mode: "claimReward",
792
+ duration: undefined,
793
+ resource: undefined,
794
+ votes: [],
795
+ }),
796
+ expectedStatus: {
797
+ amount: new BigNumber("0"),
798
+ errors: {},
799
+ warnings: {},
800
+ totalSpent: new BigNumber("0"),
801
+ estimatedFees: new BigNumber("0"),
802
+ },
803
+ },
804
+ {
805
+ name: "tronNoFrozenForBandwidth",
806
+ transaction: fromTransactionRaw({
807
+ family: "tron",
808
+ recipient: "TBsyKdNsCKNXLgvneeUJ3rbXgWSgk6paTM",
809
+ amount: "1000000",
810
+ networkInfo: null,
811
+ mode: "unfreeze",
812
+ duration: undefined,
813
+ resource: "BANDWIDTH",
814
+ votes: [],
815
+ }),
816
+ expectedStatus: {
817
+ amount: new BigNumber("0"),
818
+ errors: {
819
+ resource: new TronNoFrozenForBandwidth(),
820
+ },
821
+ warnings: {},
822
+ totalSpent: new BigNumber("0"),
823
+ estimatedFees: new BigNumber("0"),
824
+ },
825
+ },
826
+ ],
827
+ FIXME_tests: [
828
+ /**
829
+ Error:
830
+ - Expected
831
+ + Received
832
+ - "26003017"
833
+ + "26000197"
834
+ The live-common ignore all unsupported tokens (by the nano app) transactions.
835
+
836
+ Difference of 2820 (0.00282 TRX) is due to an unsupported tr10 transaction which have fee:
837
+ https://tronscan.org/#/transaction/6fe0b288e0cce30396afe40b365ee57642be44146acc847672fe3d328309d2b0
838
+ To re-enable when the support will be done.
839
+ */
840
+ "balance is sum of ops",
841
+ ],
842
+ raw: {
843
+ id: "js:2:tron:TRqkRnAj6ceJFYAn2p1eE7aWrgBBwtdhS9:",
844
+ seedIdentifier: activatedAddress1,
845
+ name: "Tron 1",
846
+ derivationMode: "",
847
+ index: 0,
848
+ freshAddress: activatedAddress1,
849
+ freshAddressPath: "44'/195'/0'/0/0",
850
+ pendingOperations: [],
851
+ currencyId: "tron",
852
+ balance: "26000197",
853
+ spendableBalance: "197",
854
+ subAccounts: [],
855
+ operations: [],
856
+ lastSyncDate: "",
857
+ blockHeight: 0,
858
+ tronResources: {
859
+ frozen: { bandwidth: undefined, energy: undefined },
860
+ delegatedFrozen: { bandwidth: undefined, energy: undefined },
861
+ unFrozen: { bandwidth: [], energy: [] },
862
+ legacyFrozen: {
863
+ bandwidth: undefined,
864
+ energy: { amount: "26000000", expiredAt: "2020-02-01T16:04:51.000Z" },
865
+ },
866
+ votes: [
867
+ { address: "TLyqzVGLV1srkB7dToTAEqgDSfPtXRJZYH", voteCount: 15 },
868
+ { address: "TGj1Ej1qRzL9feLTLhjwgxXF4Ct6GTWg2U", voteCount: 1 },
869
+ { address: "TCZvvbn4SCVyNhCAt1L8Kp1qk5rtMiKdBB", voteCount: 2 },
870
+ ],
871
+ tronPower: 26,
872
+ energy: "326",
873
+ bandwidth: {
874
+ freeUsed: "0",
875
+ freeLimit: "600",
876
+ gainedUsed: "0",
877
+ gainedLimit: "0",
878
+ },
879
+ unwithdrawnReward: "1336847",
880
+ lastWithdrawnRewardDate: "2022-05-19T12:45:36.000Z",
881
+ lastVotedDate: "2022-05-19T12:43:42.000Z",
882
+ cacheTransactionInfoById: {},
883
+ },
884
+ } as TronAccountRaw,
885
+ },
886
+ {
887
+ transactions: [
888
+ {
889
+ name: "FreezeEnergySuccess",
890
+ transaction: fromTransactionRaw({
891
+ amount: "1000000",
892
+ recipient: "",
893
+ useAllAmount: false,
894
+ subAccountId: null,
895
+ networkInfo: {
896
+ family: "tron",
897
+ freeNetUsed: "0",
898
+ freeNetLimit: "600",
899
+ netUsed: "271",
900
+ netLimit: "584",
901
+ energyUsed: "0",
902
+ energyLimit: "214",
903
+ },
904
+ family: "tron",
905
+ mode: "freeze",
906
+ resource: "ENERGY",
907
+ duration: 3,
908
+ votes: [],
909
+ }),
910
+ expectedStatus: {
911
+ errors: {},
912
+ warnings: {},
913
+ amount: BigNumber("1000000"),
914
+ estimatedFees: BigNumber("0"),
915
+ totalSpent: BigNumber("1000000"),
916
+ },
917
+ },
918
+ {
919
+ name: "NotEnoughBalanceToFreeze",
920
+ transaction: fromTransactionRaw({
921
+ amount: "100000000000000000",
922
+ recipient: "",
923
+ useAllAmount: false,
924
+ subAccountId: null,
925
+ networkInfo: {
926
+ family: "tron",
927
+ freeNetUsed: "0",
928
+ freeNetLimit: "600",
929
+ netUsed: "271",
930
+ netLimit: "584",
931
+ energyUsed: "0",
932
+ energyLimit: "214",
933
+ },
934
+ family: "tron",
935
+ mode: "freeze",
936
+ resource: "ENERGY",
937
+ duration: 3,
938
+ votes: [],
939
+ }),
940
+ expectedStatus: {
941
+ errors: {
942
+ amount: new NotEnoughBalance(),
943
+ },
944
+ warnings: {},
945
+ amount: BigNumber("100000000000000000"),
946
+ estimatedFees: BigNumber("0"),
947
+ totalSpent: BigNumber("100000000000000000"),
948
+ },
949
+ },
950
+ {
951
+ name: "FreezeBandwidthSuccess",
952
+ transaction: fromTransactionRaw({
953
+ amount: "1000000",
954
+ recipient: "",
955
+ useAllAmount: false,
956
+ subAccountId: null,
957
+ networkInfo: {
958
+ family: "tron",
959
+ freeNetUsed: "0",
960
+ freeNetLimit: "600",
961
+ netUsed: "271",
962
+ netLimit: "584",
963
+ energyUsed: "0",
964
+ energyLimit: "214",
965
+ },
966
+ family: "tron",
967
+ mode: "freeze",
968
+ resource: "BANDWIDTH",
969
+ duration: 3,
970
+ votes: [],
971
+ }),
972
+ expectedStatus: {
973
+ errors: {},
974
+ warnings: {},
975
+ amount: BigNumber("1000000"),
976
+ estimatedFees: BigNumber("0"),
977
+ totalSpent: BigNumber("1000000"),
978
+ },
979
+ },
980
+ {
981
+ name: "UnfreezeEnergySuccess",
982
+ transaction: fromTransactionRaw({
983
+ amount: "1000000",
984
+ recipient: "",
985
+ useAllAmount: false,
986
+ subAccountId: null,
987
+ networkInfo: {
988
+ family: "tron",
989
+ freeNetUsed: "0",
990
+ freeNetLimit: "600",
991
+ netUsed: "271",
992
+ netLimit: "584",
993
+ energyUsed: "0",
994
+ energyLimit: "214",
995
+ },
996
+ family: "tron",
997
+ mode: "unfreeze",
998
+ resource: "ENERGY",
999
+ duration: 3,
1000
+ votes: [],
1001
+ }),
1002
+ expectedStatus: {
1003
+ errors: {},
1004
+ warnings: {},
1005
+ amount: BigNumber("0"),
1006
+ estimatedFees: BigNumber("0"),
1007
+ totalSpent: BigNumber("0"),
1008
+ },
1009
+ },
1010
+ {
1011
+ name: "NotEnoughEnergyUnfreeze",
1012
+ transaction: fromTransactionRaw({
1013
+ amount: "10000000000",
1014
+ recipient: "",
1015
+ useAllAmount: false,
1016
+ subAccountId: null,
1017
+ networkInfo: {
1018
+ family: "tron",
1019
+ freeNetUsed: "0",
1020
+ freeNetLimit: "600",
1021
+ netUsed: "271",
1022
+ netLimit: "584",
1023
+ energyUsed: "0",
1024
+ energyLimit: "214",
1025
+ },
1026
+ family: "tron",
1027
+ mode: "unfreeze",
1028
+ resource: "ENERGY",
1029
+ duration: 3,
1030
+ votes: [],
1031
+ }),
1032
+ expectedStatus: {
1033
+ errors: {
1034
+ resource: new TronNoFrozenForEnergy(),
1035
+ },
1036
+ warnings: {},
1037
+ amount: BigNumber("0"),
1038
+ estimatedFees: BigNumber("0"),
1039
+ totalSpent: BigNumber("0"),
1040
+ },
1041
+ },
1042
+ {
1043
+ name: "UnfreezeBandwidthSuccess",
1044
+ transaction: fromTransactionRaw({
1045
+ amount: "1000000",
1046
+ recipient: "",
1047
+ useAllAmount: false,
1048
+ subAccountId: null,
1049
+ networkInfo: {
1050
+ family: "tron",
1051
+ freeNetUsed: "0",
1052
+ freeNetLimit: "600",
1053
+ netUsed: "272",
1054
+ netLimit: "584",
1055
+ energyUsed: "0",
1056
+ energyLimit: "214",
1057
+ },
1058
+ family: "tron",
1059
+ mode: "unfreeze",
1060
+ resource: "BANDWIDTH",
1061
+ duration: 3,
1062
+ votes: [],
1063
+ }),
1064
+ expectedStatus: {
1065
+ errors: {},
1066
+ warnings: {},
1067
+ amount: BigNumber("0"),
1068
+ estimatedFees: BigNumber("0"),
1069
+ totalSpent: BigNumber("0"),
1070
+ },
1071
+ },
1072
+ {
1073
+ name: "withdrawExpireUnfreezeSuccess",
1074
+ transaction: fromTransactionRaw({
1075
+ amount: "0",
1076
+ recipient: "",
1077
+ useAllAmount: false,
1078
+ subAccountId: null,
1079
+ networkInfo: {
1080
+ family: "tron",
1081
+ freeNetUsed: "0",
1082
+ freeNetLimit: "600",
1083
+ netUsed: "274",
1084
+ netLimit: "584",
1085
+ energyUsed: "0",
1086
+ energyLimit: "214",
1087
+ },
1088
+ family: "tron",
1089
+ mode: "withdrawExpireUnfreeze",
1090
+ resource: null,
1091
+ duration: 3,
1092
+ votes: [],
1093
+ }),
1094
+ expectedStatus: {
1095
+ errors: {},
1096
+ warnings: {},
1097
+ amount: BigNumber("0"),
1098
+ estimatedFees: BigNumber("0"),
1099
+ totalSpent: BigNumber("0"),
1100
+ },
1101
+ },
1102
+ {
1103
+ name: "UndelegateResourceSuccess",
1104
+ transaction: fromTransactionRaw({
1105
+ amount: "1000000",
1106
+ recipient: "TKc4RbfcDf6MrHXENfRAG23ue8YYgaTh8U",
1107
+ useAllAmount: false,
1108
+ subAccountId: null,
1109
+ networkInfo: {
1110
+ family: "tron",
1111
+ freeNetUsed: "0",
1112
+ freeNetLimit: "600",
1113
+ netUsed: "268",
1114
+ netLimit: "584",
1115
+ energyUsed: "0",
1116
+ energyLimit: "214",
1117
+ },
1118
+ family: "tron",
1119
+ mode: "unDelegateResource",
1120
+ resource: "ENERGY",
1121
+ duration: 3,
1122
+ votes: [],
1123
+ }),
1124
+ expectedStatus: {
1125
+ errors: {},
1126
+ warnings: {},
1127
+ amount: BigNumber("0"),
1128
+ estimatedFees: BigNumber("0"),
1129
+ totalSpent: BigNumber("0"),
1130
+ },
1131
+ },
1132
+ {
1133
+ name: "AddressIsAlsoSourceUndelegateResourceError",
1134
+ transaction: fromTransactionRaw({
1135
+ amount: "1000",
1136
+ recipient: "TUxd6v64YTWkfpFpNDdtgc5Ps4SfGxwizT",
1137
+ useAllAmount: false,
1138
+ subAccountId: null,
1139
+ networkInfo: {
1140
+ family: "tron",
1141
+ freeNetUsed: "0",
1142
+ freeNetLimit: "600",
1143
+ netUsed: "268",
1144
+ netLimit: "584",
1145
+ energyUsed: "0",
1146
+ energyLimit: "214",
1147
+ },
1148
+ family: "tron",
1149
+ mode: "unDelegateResource",
1150
+ resource: "ENERGY",
1151
+ duration: 3,
1152
+ votes: [],
1153
+ }),
1154
+ expectedStatus: {
1155
+ errors: {
1156
+ recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
1157
+ },
1158
+ warnings: {},
1159
+ amount: BigNumber("0"),
1160
+ estimatedFees: BigNumber("0"),
1161
+ totalSpent: BigNumber("0"),
1162
+ },
1163
+ },
1164
+ {
1165
+ name: "UndelegateResourceError",
1166
+ transaction: fromTransactionRaw({
1167
+ amount: "1000000000",
1168
+ recipient: "TKc4RbfcDf6MrHXENfRAG23ue8YYgaTh8U",
1169
+ useAllAmount: false,
1170
+ subAccountId: null,
1171
+ networkInfo: {
1172
+ family: "tron",
1173
+ freeNetUsed: "0",
1174
+ freeNetLimit: "600",
1175
+ netUsed: "268",
1176
+ netLimit: "584",
1177
+ energyUsed: "0",
1178
+ energyLimit: "214",
1179
+ },
1180
+ family: "tron",
1181
+ mode: "unDelegateResource",
1182
+ resource: "ENERGY",
1183
+ duration: 3,
1184
+ votes: [],
1185
+ }),
1186
+ expectedStatus: {
1187
+ errors: {
1188
+ resource: new TronInvalidUnDelegateResourceAmount(),
1189
+ },
1190
+ warnings: {},
1191
+ amount: BigNumber("0"),
1192
+ estimatedFees: BigNumber("0"),
1193
+ totalSpent: BigNumber("0"),
1194
+ },
1195
+ },
1196
+ {
1197
+ name: "unfreezeLegacyNoFrozenForBandwidth",
1198
+ transaction: fromTransactionRaw({
1199
+ family: "tron",
1200
+ recipient: "",
1201
+ amount: "1000000",
1202
+ networkInfo: null,
1203
+ mode: "legacyUnfreeze",
1204
+ duration: undefined,
1205
+ resource: "BANDWIDTH",
1206
+ votes: [],
1207
+ }),
1208
+ expectedStatus: {
1209
+ amount: new BigNumber("0"),
1210
+ errors: {
1211
+ resource: new TronNoFrozenForBandwidth(),
1212
+ },
1213
+ warnings: {},
1214
+ totalSpent: new BigNumber("0"),
1215
+ estimatedFees: new BigNumber("0"),
1216
+ },
1217
+ },
1218
+ ],
1219
+ FIXME_tests: ["balance is sum of ops"],
1220
+ raw: {
1221
+ id: "js:2:tron:TUxd6v64YTWkfpFpNDdtgc5Ps4SfGxwizT:",
1222
+ seedIdentifier:
1223
+ "0416c02ea5e939eed995f75c44667a66b9c8dfddede8c6d54211f64b1dace9e1c40bcbbd5341480f43a5f37c7ab3a0c53f9cccff57d59bb0368d1e744135d7f68a",
1224
+ name: "Tron 1",
1225
+ used: true,
1226
+ derivationMode: "",
1227
+ index: 0,
1228
+ freshAddress: "TUxd6v64YTWkfpFpNDdtgc5Ps4SfGxwizT",
1229
+ freshAddressPath: "44'/195'/0'/0/0",
1230
+ blockHeight: 57509444,
1231
+ creationDate: "2023-10-31T14:27:27.000Z",
1232
+ operationsCount: 96,
1233
+ operations: [],
1234
+ pendingOperations: [],
1235
+ currencyId: "tron",
1236
+ lastSyncDate: "2023-12-21T12:28:03.177Z",
1237
+ balance: "859005207",
1238
+ spendableBalance: "252128207",
1239
+ subAccounts: [],
1240
+ // @ts-expect-error expected
1241
+ tronResources: {
1242
+ frozen: { bandwidth: { amount: "539000000" }, energy: { amount: "14877000" } },
1243
+ delegatedFrozen: { energy: { amount: "38000000" } },
1244
+ unFrozen: {
1245
+ bandwidth: [{ amount: "1000000", expireTime: "2023-12-20T17:22:36.000Z" }],
1246
+ energy: [
1247
+ { amount: "10000000", expireTime: "2023-12-25T19:24:54.000Z" },
1248
+ { amount: "4000000", expireTime: "2023-12-25T19:25:09.000Z" },
1249
+ ],
1250
+ },
1251
+ legacyFrozen: {},
1252
+ votes: [{ address: "TAQpCTFeJvwdWf6MQZtXXkzWrTS9aymshb", voteCount: 100 }],
1253
+ tronPower: 591,
1254
+ energy: "214",
1255
+ bandwidth: { freeUsed: "0", freeLimit: "600", gainedUsed: "274", gainedLimit: "584" },
1256
+ unwithdrawnReward: "321945",
1257
+ lastWithdrawnRewardDate: "2023-11-24T16:58:09.000Z",
1258
+ lastVotedDate: "2023-12-06T17:24:48.000Z",
1259
+ cacheTransactionInfoById: {},
1260
+ },
1261
+ swapHistory: [],
1262
+ },
1263
+ },
1264
+ {
1265
+ name: "Tron account with only frozen bandwidth",
1266
+ FIXME_tests: ["balance is sum of ops", "pendingOperations are cleaned up"],
1267
+ raw: {
1268
+ id: "js:2:tron:TY2ksFgpvb82TgGPwUSa7iseqPW5weYQyh:",
1269
+ seedIdentifier:
1270
+ "0416c02ea5e939eed995f75c44667a66b9c8dfddede8c6d54211f64b1dace9e1c40bcbbd5341480f43a5f37c7ab3a0c53f9cccff57d59bb0368d1e744135d7f68a",
1271
+ name: "Tron 3",
1272
+ used: true,
1273
+ derivationMode: "",
1274
+ index: 2,
1275
+ freshAddress: "TY2ksFgpvb82TgGPwUSa7iseqPW5weYQyh",
1276
+ freshAddressPath: "44'/195'/2'/0/0",
1277
+ blockHeight: 59127355,
1278
+ creationDate: "2024-02-15T16:36:06.000Z",
1279
+ operationsCount: 3,
1280
+ operations: [],
1281
+ pendingOperations: [],
1282
+ currencyId: "tron",
1283
+ lastSyncDate: "2024-02-15T17:11:40.339Z",
1284
+ balance: "15000004",
1285
+ spendableBalance: "10000004",
1286
+ subAccounts: [],
1287
+ // @ts-expect-error expected
1288
+ tronResources: {
1289
+ frozen: { bandwidth: { amount: "5000000" } },
1290
+ delegatedFrozen: {},
1291
+ unFrozen: { bandwidth: [], energy: [] },
1292
+ legacyFrozen: {},
1293
+ votes: [],
1294
+ tronPower: 5,
1295
+ energy: "0",
1296
+ bandwidth: { freeUsed: "250", freeLimit: "600", gainedUsed: "0", gainedLimit: "5" },
1297
+ unwithdrawnReward: "0",
1298
+ cacheTransactionInfoById: {},
1299
+ },
1300
+ swapHistory: [],
1301
+ },
1302
+ transactions: [
1303
+ {
1304
+ name: "Successful bandwidth unfreeze with no frozen energy",
1305
+ transaction: fromTransactionRaw({
1306
+ amount: "1000000",
1307
+ recipient: "",
1308
+ useAllAmount: false,
1309
+ subAccountId: null,
1310
+ networkInfo: {
1311
+ family: "tron",
1312
+ freeNetUsed: "250",
1313
+ freeNetLimit: "600",
1314
+ netUsed: "0",
1315
+ netLimit: "5",
1316
+ energyUsed: "0",
1317
+ energyLimit: "0",
1318
+ },
1319
+ family: "tron",
1320
+ mode: "unfreeze",
1321
+ resource: "BANDWIDTH",
1322
+ duration: 3,
1323
+ votes: [],
1324
+ }),
1325
+ expectedStatus: {
1326
+ errors: {},
1327
+ warnings: {},
1328
+ amount: BigNumber("0"),
1329
+ estimatedFees: BigNumber("0"),
1330
+ totalSpent: BigNumber("0"),
1331
+ },
1332
+ },
1333
+ ],
1334
+ },
1335
+ ],
1336
+ };
1337
+
1338
+ export const dataset: DatasetTest<Transaction> = {
1339
+ implementations: ["tronjs"],
1340
+ currencies: {
1341
+ tron,
1342
+ },
1343
+ };