@ledgerhq/coin-aptos 1.10.0-nightly.0 → 1.10.0-nightly.2

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 (459) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +18 -6
  3. package/CHANGELOG.md +40 -9
  4. package/jest.config.js +1 -1
  5. package/jest.integ.config.js +8 -0
  6. package/lib/__tests__/api/craftTransaction.unit.test.d.ts +2 -0
  7. package/lib/__tests__/api/craftTransaction.unit.test.d.ts.map +1 -0
  8. package/lib/__tests__/api/craftTransaction.unit.test.js +50 -0
  9. package/lib/__tests__/api/craftTransaction.unit.test.js.map +1 -0
  10. package/lib/__tests__/api/getBalance.unit.test.d.ts +2 -0
  11. package/lib/__tests__/api/getBalance.unit.test.d.ts.map +1 -0
  12. package/lib/__tests__/api/getBalance.unit.test.js +41 -0
  13. package/lib/__tests__/api/getBalance.unit.test.js.map +1 -0
  14. package/lib/__tests__/api/index.integ.test.d.ts +2 -0
  15. package/lib/__tests__/api/index.integ.test.d.ts.map +1 -0
  16. package/lib/__tests__/api/index.integ.test.js +115 -0
  17. package/lib/__tests__/api/index.integ.test.js.map +1 -0
  18. package/lib/__tests__/api/index.test.js +48 -460
  19. package/lib/__tests__/api/index.test.js.map +1 -1
  20. package/lib/__tests__/bridge/broadcast.test.js +5 -5
  21. package/lib/__tests__/bridge/broadcast.test.js.map +1 -1
  22. package/lib/__tests__/bridge/getFeesForTransaction.test.js +9 -9
  23. package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
  24. package/lib/__tests__/bridge/logic.test.js +3 -553
  25. package/lib/__tests__/bridge/logic.test.js.map +1 -1
  26. package/lib/__tests__/bridge/prepareTransaction.test.js +3 -3
  27. package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -1
  28. package/lib/__tests__/bridge/signOperation.test.js +9 -12
  29. package/lib/__tests__/bridge/signOperation.test.js.map +1 -1
  30. package/lib/__tests__/bridge/synchronisation.test.js +6 -6
  31. package/lib/__tests__/bridge/synchronisation.test.js.map +1 -1
  32. package/lib/__tests__/index.test.js +1 -1
  33. package/lib/__tests__/index.test.js.map +1 -1
  34. package/lib/__tests__/logic/buildTransaction.test.d.ts.map +1 -0
  35. package/lib/__tests__/{bridge → logic}/buildTransaction.test.js +16 -12
  36. package/lib/__tests__/logic/buildTransaction.test.js.map +1 -0
  37. package/lib/__tests__/logic/calculateAmount.unit.test.d.ts +2 -0
  38. package/lib/__tests__/logic/calculateAmount.unit.test.d.ts.map +1 -0
  39. package/lib/__tests__/logic/calculateAmount.unit.test.js +45 -0
  40. package/lib/__tests__/logic/calculateAmount.unit.test.js.map +1 -0
  41. package/lib/__tests__/logic/combine.unit.test.d.ts +2 -0
  42. package/lib/__tests__/logic/combine.unit.test.d.ts.map +1 -0
  43. package/lib/__tests__/logic/combine.unit.test.js +47 -0
  44. package/lib/__tests__/logic/combine.unit.test.js.map +1 -0
  45. package/lib/__tests__/logic/compareAddress.unit.test.d.ts +2 -0
  46. package/lib/__tests__/logic/compareAddress.unit.test.d.ts.map +1 -0
  47. package/lib/__tests__/logic/compareAddress.unit.test.js +26 -0
  48. package/lib/__tests__/logic/compareAddress.unit.test.js.map +1 -0
  49. package/lib/__tests__/logic/createTransaction.test.d.ts.map +1 -0
  50. package/lib/__tests__/{bridge → logic}/createTransaction.test.js +2 -2
  51. package/lib/__tests__/logic/createTransaction.test.js.map +1 -0
  52. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.d.ts +2 -0
  53. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.d.ts.map +1 -0
  54. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.js +186 -0
  55. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.js.map +1 -0
  56. package/lib/__tests__/logic/getFunctionAddress.unit.test.d.ts +2 -0
  57. package/lib/__tests__/logic/getFunctionAddress.unit.test.d.ts.map +1 -0
  58. package/lib/__tests__/logic/getFunctionAddress.unit.test.js +29 -0
  59. package/lib/__tests__/logic/getFunctionAddress.unit.test.js.map +1 -0
  60. package/lib/__tests__/logic/getResourceAddress.unit.test.d.ts +2 -0
  61. package/lib/__tests__/logic/getResourceAddress.unit.test.d.ts.map +1 -0
  62. package/lib/__tests__/logic/getResourceAddress.unit.test.js +218 -0
  63. package/lib/__tests__/logic/getResourceAddress.unit.test.js.map +1 -0
  64. package/lib/__tests__/logic/isTestnet.unit.test.d.ts +2 -0
  65. package/lib/__tests__/logic/isTestnet.unit.test.d.ts.map +1 -0
  66. package/lib/__tests__/logic/isTestnet.unit.test.js +12 -0
  67. package/lib/__tests__/logic/isTestnet.unit.test.js.map +1 -0
  68. package/lib/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
  69. package/lib/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
  70. package/lib/__tests__/logic/processRecipients.unit.test.js +79 -0
  71. package/lib/__tests__/logic/processRecipients.unit.test.js.map +1 -0
  72. package/lib/__tests__/network/client.test.d.ts +2 -0
  73. package/lib/__tests__/network/client.test.d.ts.map +1 -0
  74. package/lib/__tests__/network/client.test.js +992 -0
  75. package/lib/__tests__/network/client.test.js.map +1 -0
  76. package/lib/api/index.d.ts +4 -33
  77. package/lib/api/index.d.ts.map +1 -1
  78. package/lib/api/index.js +19 -196
  79. package/lib/api/index.js.map +1 -1
  80. package/lib/bridge/broadcast.d.ts +3 -2
  81. package/lib/bridge/broadcast.d.ts.map +1 -1
  82. package/lib/bridge/broadcast.js +4 -3
  83. package/lib/bridge/broadcast.js.map +1 -1
  84. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
  85. package/lib/bridge/estimateMaxSpendable.js +5 -4
  86. package/lib/bridge/estimateMaxSpendable.js.map +1 -1
  87. package/lib/bridge/getFeesForTransaction.d.ts +1 -1
  88. package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
  89. package/lib/bridge/getFeesForTransaction.js +8 -7
  90. package/lib/bridge/getFeesForTransaction.js.map +1 -1
  91. package/lib/bridge/index.d.ts +1 -1
  92. package/lib/bridge/index.d.ts.map +1 -1
  93. package/lib/bridge/index.js +1 -1
  94. package/lib/bridge/index.js.map +1 -1
  95. package/lib/bridge/logic.d.ts +1 -20
  96. package/lib/bridge/logic.d.ts.map +1 -1
  97. package/lib/bridge/logic.js +12 -207
  98. package/lib/bridge/logic.js.map +1 -1
  99. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  100. package/lib/bridge/prepareTransaction.js +4 -3
  101. package/lib/bridge/prepareTransaction.js.map +1 -1
  102. package/lib/bridge/signOperation.d.ts.map +1 -1
  103. package/lib/bridge/signOperation.js +4 -4
  104. package/lib/bridge/signOperation.js.map +1 -1
  105. package/lib/bridge/synchronisation.js +3 -3
  106. package/lib/bridge/synchronisation.js.map +1 -1
  107. package/lib/config.d.ts +13 -0
  108. package/lib/config.d.ts.map +1 -0
  109. package/lib/config.js +9 -0
  110. package/lib/config.js.map +1 -0
  111. package/lib/constants.d.ts +5 -1
  112. package/lib/constants.d.ts.map +1 -1
  113. package/lib/constants.js +8 -1
  114. package/lib/constants.js.map +1 -1
  115. package/lib/{bridge → logic}/buildTransaction.d.ts +1 -1
  116. package/lib/logic/buildTransaction.d.ts.map +1 -0
  117. package/lib/{bridge → logic}/buildTransaction.js +2 -2
  118. package/lib/logic/buildTransaction.js.map +1 -0
  119. package/lib/logic/calculateAmount.d.ts +3 -0
  120. package/lib/logic/calculateAmount.d.ts.map +1 -0
  121. package/lib/logic/calculateAmount.js +13 -0
  122. package/lib/logic/calculateAmount.js.map +1 -0
  123. package/lib/logic/combine.d.ts +4 -0
  124. package/lib/logic/combine.d.ts.map +1 -0
  125. package/lib/logic/combine.js +34 -0
  126. package/lib/logic/combine.js.map +1 -0
  127. package/lib/logic/craftTransaction.d.ts +5 -0
  128. package/lib/logic/craftTransaction.d.ts.map +1 -0
  129. package/lib/logic/craftTransaction.js +23 -0
  130. package/lib/logic/craftTransaction.js.map +1 -0
  131. package/lib/logic/createTransaction.d.ts.map +1 -0
  132. package/lib/{bridge → logic}/createTransaction.js +3 -3
  133. package/lib/logic/createTransaction.js.map +1 -0
  134. package/lib/logic/getBalance.d.ts +5 -0
  135. package/lib/logic/getBalance.d.ts.map +1 -0
  136. package/lib/logic/getBalance.js +12 -0
  137. package/lib/logic/getBalance.js.map +1 -0
  138. package/lib/logic/getCoinAndAmounts.d.ts +13 -0
  139. package/lib/logic/getCoinAndAmounts.d.ts.map +1 -0
  140. package/lib/logic/getCoinAndAmounts.js +112 -0
  141. package/lib/logic/getCoinAndAmounts.js.map +1 -0
  142. package/lib/logic/getFunctionAddress.d.ts +3 -0
  143. package/lib/logic/getFunctionAddress.d.ts.map +1 -0
  144. package/lib/logic/getFunctionAddress.js +12 -0
  145. package/lib/logic/getFunctionAddress.js.map +1 -0
  146. package/lib/logic/getResourceAddress.d.ts +4 -0
  147. package/lib/logic/getResourceAddress.d.ts.map +1 -0
  148. package/lib/logic/getResourceAddress.js +17 -0
  149. package/lib/logic/getResourceAddress.js.map +1 -0
  150. package/lib/logic/isTestnet.d.ts +2 -0
  151. package/lib/logic/isTestnet.d.ts.map +1 -0
  152. package/lib/logic/isTestnet.js +9 -0
  153. package/lib/logic/isTestnet.js.map +1 -0
  154. package/lib/logic/isWriteSetChangeWriteResource.d.ts +3 -0
  155. package/lib/logic/isWriteSetChangeWriteResource.d.ts.map +1 -0
  156. package/lib/logic/isWriteSetChangeWriteResource.js +8 -0
  157. package/lib/logic/isWriteSetChangeWriteResource.js.map +1 -0
  158. package/lib/logic/normalizeTransactionOptions.d.ts +3 -0
  159. package/lib/logic/normalizeTransactionOptions.d.ts.map +1 -0
  160. package/lib/logic/normalizeTransactionOptions.js +21 -0
  161. package/lib/logic/normalizeTransactionOptions.js.map +1 -0
  162. package/lib/logic/processRecipients.d.ts +6 -0
  163. package/lib/logic/processRecipients.d.ts.map +1 -0
  164. package/lib/logic/processRecipients.js +57 -0
  165. package/lib/logic/processRecipients.js.map +1 -0
  166. package/lib/logic/transactionsToOperations.d.ts +7 -0
  167. package/lib/logic/transactionsToOperations.d.ts.map +1 -0
  168. package/lib/logic/transactionsToOperations.js +85 -0
  169. package/lib/logic/transactionsToOperations.js.map +1 -0
  170. package/lib/network/client.d.ts +38 -0
  171. package/lib/network/client.d.ts.map +1 -0
  172. package/lib/network/client.js +266 -0
  173. package/lib/network/client.js.map +1 -0
  174. package/lib/network/graphql/queries.d.ts.map +1 -0
  175. package/lib/network/graphql/queries.js.map +1 -0
  176. package/lib/network/graphql/types.d.ts.map +1 -0
  177. package/lib/{api → network}/graphql/types.js.map +1 -1
  178. package/lib/network/index.d.ts +2 -1
  179. package/lib/network/index.d.ts.map +1 -1
  180. package/lib/network/index.js +19 -7
  181. package/lib/network/index.js.map +1 -1
  182. package/lib/types/assets.d.ts +12 -0
  183. package/lib/types/assets.d.ts.map +1 -0
  184. package/lib/types/assets.js +3 -0
  185. package/lib/types/assets.js.map +1 -0
  186. package/lib/types/index.d.ts +4 -0
  187. package/lib/types/index.d.ts.map +1 -1
  188. package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts +2 -0
  189. package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts.map +1 -0
  190. package/lib-es/__tests__/api/craftTransaction.unit.test.js +48 -0
  191. package/lib-es/__tests__/api/craftTransaction.unit.test.js.map +1 -0
  192. package/lib-es/__tests__/api/getBalance.unit.test.d.ts +2 -0
  193. package/lib-es/__tests__/api/getBalance.unit.test.d.ts.map +1 -0
  194. package/lib-es/__tests__/api/getBalance.unit.test.js +36 -0
  195. package/lib-es/__tests__/api/getBalance.unit.test.js.map +1 -0
  196. package/lib-es/__tests__/api/index.integ.test.d.ts +2 -0
  197. package/lib-es/__tests__/api/index.integ.test.d.ts.map +1 -0
  198. package/lib-es/__tests__/api/index.integ.test.js +113 -0
  199. package/lib-es/__tests__/api/index.integ.test.js.map +1 -0
  200. package/lib-es/__tests__/api/index.test.js +52 -464
  201. package/lib-es/__tests__/api/index.test.js.map +1 -1
  202. package/lib-es/__tests__/bridge/broadcast.test.js +2 -2
  203. package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -1
  204. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +2 -2
  205. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
  206. package/lib-es/__tests__/bridge/logic.test.js +3 -553
  207. package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
  208. package/lib-es/__tests__/bridge/prepareTransaction.test.js +2 -2
  209. package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -1
  210. package/lib-es/__tests__/bridge/signOperation.test.js +9 -12
  211. package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -1
  212. package/lib-es/__tests__/bridge/synchronisation.test.js +3 -3
  213. package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
  214. package/lib-es/__tests__/index.test.js +1 -1
  215. package/lib-es/__tests__/index.test.js.map +1 -1
  216. package/lib-es/__tests__/logic/buildTransaction.test.d.ts.map +1 -0
  217. package/lib-es/__tests__/{bridge → logic}/buildTransaction.test.js +9 -5
  218. package/lib-es/__tests__/logic/buildTransaction.test.js.map +1 -0
  219. package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts +2 -0
  220. package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts.map +1 -0
  221. package/lib-es/__tests__/logic/calculateAmount.unit.test.js +40 -0
  222. package/lib-es/__tests__/logic/calculateAmount.unit.test.js.map +1 -0
  223. package/lib-es/__tests__/logic/combine.unit.test.d.ts +2 -0
  224. package/lib-es/__tests__/logic/combine.unit.test.d.ts.map +1 -0
  225. package/lib-es/__tests__/logic/combine.unit.test.js +45 -0
  226. package/lib-es/__tests__/logic/combine.unit.test.js.map +1 -0
  227. package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts +2 -0
  228. package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts.map +1 -0
  229. package/lib-es/__tests__/logic/compareAddress.unit.test.js +24 -0
  230. package/lib-es/__tests__/logic/compareAddress.unit.test.js.map +1 -0
  231. package/lib-es/__tests__/logic/createTransaction.test.d.ts.map +1 -0
  232. package/lib-es/__tests__/{bridge → logic}/createTransaction.test.js +2 -2
  233. package/lib-es/__tests__/logic/createTransaction.test.js.map +1 -0
  234. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts +2 -0
  235. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts.map +1 -0
  236. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js +181 -0
  237. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js.map +1 -0
  238. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts +2 -0
  239. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts.map +1 -0
  240. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js +27 -0
  241. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js.map +1 -0
  242. package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts +2 -0
  243. package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts.map +1 -0
  244. package/lib-es/__tests__/logic/getResourceAddress.unit.test.js +216 -0
  245. package/lib-es/__tests__/logic/getResourceAddress.unit.test.js.map +1 -0
  246. package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts +2 -0
  247. package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts.map +1 -0
  248. package/lib-es/__tests__/logic/isTestnet.unit.test.js +10 -0
  249. package/lib-es/__tests__/logic/isTestnet.unit.test.js.map +1 -0
  250. package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
  251. package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
  252. package/lib-es/__tests__/logic/processRecipients.unit.test.js +74 -0
  253. package/lib-es/__tests__/logic/processRecipients.unit.test.js.map +1 -0
  254. package/lib-es/__tests__/network/client.test.d.ts +2 -0
  255. package/lib-es/__tests__/network/client.test.d.ts.map +1 -0
  256. package/lib-es/__tests__/network/client.test.js +987 -0
  257. package/lib-es/__tests__/network/client.test.js.map +1 -0
  258. package/lib-es/api/index.d.ts +4 -33
  259. package/lib-es/api/index.d.ts.map +1 -1
  260. package/lib-es/api/index.js +17 -194
  261. package/lib-es/api/index.js.map +1 -1
  262. package/lib-es/bridge/broadcast.d.ts +3 -2
  263. package/lib-es/bridge/broadcast.d.ts.map +1 -1
  264. package/lib-es/bridge/broadcast.js +4 -3
  265. package/lib-es/bridge/broadcast.js.map +1 -1
  266. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
  267. package/lib-es/bridge/estimateMaxSpendable.js +3 -2
  268. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
  269. package/lib-es/bridge/getFeesForTransaction.d.ts +1 -1
  270. package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
  271. package/lib-es/bridge/getFeesForTransaction.js +3 -2
  272. package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
  273. package/lib-es/bridge/index.d.ts +1 -1
  274. package/lib-es/bridge/index.d.ts.map +1 -1
  275. package/lib-es/bridge/index.js +1 -1
  276. package/lib-es/bridge/index.js.map +1 -1
  277. package/lib-es/bridge/logic.d.ts +1 -20
  278. package/lib-es/bridge/logic.d.ts.map +1 -1
  279. package/lib-es/bridge/logic.js +6 -190
  280. package/lib-es/bridge/logic.js.map +1 -1
  281. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  282. package/lib-es/bridge/prepareTransaction.js +3 -2
  283. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  284. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  285. package/lib-es/bridge/signOperation.js +2 -2
  286. package/lib-es/bridge/signOperation.js.map +1 -1
  287. package/lib-es/bridge/synchronisation.js +1 -1
  288. package/lib-es/bridge/synchronisation.js.map +1 -1
  289. package/lib-es/config.d.ts +13 -0
  290. package/lib-es/config.d.ts.map +1 -0
  291. package/lib-es/config.js +4 -0
  292. package/lib-es/config.js.map +1 -0
  293. package/lib-es/constants.d.ts +5 -1
  294. package/lib-es/constants.d.ts.map +1 -1
  295. package/lib-es/constants.js +4 -0
  296. package/lib-es/constants.js.map +1 -1
  297. package/lib-es/{bridge → logic}/buildTransaction.d.ts +1 -1
  298. package/lib-es/logic/buildTransaction.d.ts.map +1 -0
  299. package/lib-es/{bridge → logic}/buildTransaction.js +1 -1
  300. package/lib-es/logic/buildTransaction.js.map +1 -0
  301. package/lib-es/logic/calculateAmount.d.ts +3 -0
  302. package/lib-es/logic/calculateAmount.d.ts.map +1 -0
  303. package/lib-es/logic/calculateAmount.js +9 -0
  304. package/lib-es/logic/calculateAmount.js.map +1 -0
  305. package/lib-es/logic/combine.d.ts +4 -0
  306. package/lib-es/logic/combine.d.ts.map +1 -0
  307. package/lib-es/logic/combine.js +29 -0
  308. package/lib-es/logic/combine.js.map +1 -0
  309. package/lib-es/logic/craftTransaction.d.ts +5 -0
  310. package/lib-es/logic/craftTransaction.d.ts.map +1 -0
  311. package/lib-es/logic/craftTransaction.js +16 -0
  312. package/lib-es/logic/craftTransaction.js.map +1 -0
  313. package/lib-es/logic/createTransaction.d.ts.map +1 -0
  314. package/lib-es/{bridge → logic}/createTransaction.js +1 -1
  315. package/lib-es/logic/createTransaction.js.map +1 -0
  316. package/lib-es/logic/getBalance.d.ts +5 -0
  317. package/lib-es/logic/getBalance.d.ts.map +1 -0
  318. package/lib-es/logic/getBalance.js +8 -0
  319. package/lib-es/logic/getBalance.js.map +1 -0
  320. package/lib-es/logic/getCoinAndAmounts.d.ts +13 -0
  321. package/lib-es/logic/getCoinAndAmounts.d.ts.map +1 -0
  322. package/lib-es/logic/getCoinAndAmounts.js +101 -0
  323. package/lib-es/logic/getCoinAndAmounts.js.map +1 -0
  324. package/lib-es/logic/getFunctionAddress.d.ts +3 -0
  325. package/lib-es/logic/getFunctionAddress.d.ts.map +1 -0
  326. package/lib-es/logic/getFunctionAddress.js +8 -0
  327. package/lib-es/logic/getFunctionAddress.js.map +1 -0
  328. package/lib-es/logic/getResourceAddress.d.ts +4 -0
  329. package/lib-es/logic/getResourceAddress.d.ts.map +1 -0
  330. package/lib-es/logic/getResourceAddress.js +13 -0
  331. package/lib-es/logic/getResourceAddress.js.map +1 -0
  332. package/lib-es/logic/isTestnet.d.ts +2 -0
  333. package/lib-es/logic/isTestnet.d.ts.map +1 -0
  334. package/lib-es/logic/isTestnet.js +5 -0
  335. package/lib-es/logic/isTestnet.js.map +1 -0
  336. package/lib-es/logic/isWriteSetChangeWriteResource.d.ts +3 -0
  337. package/lib-es/logic/isWriteSetChangeWriteResource.d.ts.map +1 -0
  338. package/lib-es/logic/isWriteSetChangeWriteResource.js +4 -0
  339. package/lib-es/logic/isWriteSetChangeWriteResource.js.map +1 -0
  340. package/lib-es/logic/normalizeTransactionOptions.d.ts +3 -0
  341. package/lib-es/logic/normalizeTransactionOptions.d.ts.map +1 -0
  342. package/lib-es/logic/normalizeTransactionOptions.js +17 -0
  343. package/lib-es/logic/normalizeTransactionOptions.js.map +1 -0
  344. package/lib-es/logic/processRecipients.d.ts +6 -0
  345. package/lib-es/logic/processRecipients.d.ts.map +1 -0
  346. package/lib-es/logic/processRecipients.js +53 -0
  347. package/lib-es/logic/processRecipients.js.map +1 -0
  348. package/lib-es/logic/transactionsToOperations.d.ts +7 -0
  349. package/lib-es/logic/transactionsToOperations.d.ts.map +1 -0
  350. package/lib-es/logic/transactionsToOperations.js +77 -0
  351. package/lib-es/logic/transactionsToOperations.js.map +1 -0
  352. package/lib-es/network/client.d.ts +38 -0
  353. package/lib-es/network/client.d.ts.map +1 -0
  354. package/lib-es/network/client.js +259 -0
  355. package/lib-es/network/client.js.map +1 -0
  356. package/lib-es/network/graphql/queries.d.ts.map +1 -0
  357. package/lib-es/network/graphql/queries.js.map +1 -0
  358. package/lib-es/network/graphql/types.d.ts.map +1 -0
  359. package/lib-es/{api → network}/graphql/types.js.map +1 -1
  360. package/lib-es/network/index.d.ts +2 -1
  361. package/lib-es/network/index.d.ts.map +1 -1
  362. package/lib-es/network/index.js +6 -8
  363. package/lib-es/network/index.js.map +1 -1
  364. package/lib-es/types/assets.d.ts +12 -0
  365. package/lib-es/types/assets.d.ts.map +1 -0
  366. package/lib-es/types/assets.js +2 -0
  367. package/lib-es/types/assets.js.map +1 -0
  368. package/lib-es/types/index.d.ts +4 -0
  369. package/lib-es/types/index.d.ts.map +1 -1
  370. package/package.json +9 -8
  371. package/src/__tests__/api/craftTransaction.unit.test.ts +70 -0
  372. package/src/__tests__/api/getBalance.unit.test.ts +44 -0
  373. package/src/__tests__/api/index.integ.test.ts +139 -0
  374. package/src/__tests__/api/index.test.ts +60 -547
  375. package/src/__tests__/bridge/broadcast.test.ts +2 -2
  376. package/src/__tests__/bridge/getFeesForTransaction.test.ts +2 -2
  377. package/src/__tests__/bridge/logic.test.ts +4 -649
  378. package/src/__tests__/bridge/prepareTransaction.test.ts +2 -2
  379. package/src/__tests__/bridge/signOperation.test.ts +12 -13
  380. package/src/__tests__/bridge/synchronisation.test.ts +4 -4
  381. package/src/__tests__/index.test.ts +1 -1
  382. package/src/__tests__/{bridge → logic}/buildTransaction.test.ts +12 -7
  383. package/src/__tests__/logic/calculateAmount.unit.test.ts +51 -0
  384. package/src/__tests__/logic/combine.unit.test.ts +65 -0
  385. package/src/__tests__/logic/compareAddress.unit.test.ts +27 -0
  386. package/src/__tests__/{bridge → logic}/createTransaction.test.ts +2 -2
  387. package/src/__tests__/logic/getCoinAndAmounts.unit.test.ts +195 -0
  388. package/src/__tests__/logic/getFunctionAddress.unit.test.ts +33 -0
  389. package/src/__tests__/logic/getResourceAddress.unit.test.ts +241 -0
  390. package/src/__tests__/logic/isTestnet.unit.test.ts +11 -0
  391. package/src/__tests__/logic/processRecipients.unit.test.ts +87 -0
  392. package/src/__tests__/network/client.test.ts +1107 -0
  393. package/src/api/index.ts +29 -251
  394. package/src/bridge/broadcast.ts +7 -7
  395. package/src/bridge/estimateMaxSpendable.ts +3 -2
  396. package/src/bridge/getFeesForTransaction.ts +4 -3
  397. package/src/bridge/index.ts +2 -2
  398. package/src/bridge/logic.ts +8 -283
  399. package/src/bridge/prepareTransaction.ts +4 -2
  400. package/src/bridge/signOperation.ts +2 -2
  401. package/src/bridge/synchronisation.ts +1 -1
  402. package/src/config.ts +19 -0
  403. package/src/constants.ts +6 -1
  404. package/src/{bridge → logic}/buildTransaction.ts +2 -2
  405. package/src/logic/calculateAmount.ts +15 -0
  406. package/src/logic/combine.ts +51 -0
  407. package/src/logic/craftTransaction.ts +26 -0
  408. package/src/{bridge → logic}/createTransaction.ts +1 -1
  409. package/src/logic/getBalance.ts +15 -0
  410. package/src/logic/getCoinAndAmounts.ts +141 -0
  411. package/src/logic/getFunctionAddress.ts +9 -0
  412. package/src/logic/getResourceAddress.ts +24 -0
  413. package/src/logic/isTestnet.ts +5 -0
  414. package/src/logic/isWriteSetChangeWriteResource.ts +7 -0
  415. package/src/logic/normalizeTransactionOptions.ts +18 -0
  416. package/src/logic/processRecipients.ts +87 -0
  417. package/src/logic/transactionsToOperations.ts +105 -0
  418. package/src/network/client.ts +351 -0
  419. package/src/network/index.ts +6 -14
  420. package/src/types/assets.ts +15 -0
  421. package/src/types/index.ts +5 -0
  422. package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
  423. package/lib/__tests__/bridge/buildTransaction.test.js.map +0 -1
  424. package/lib/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
  425. package/lib/__tests__/bridge/createTransaction.test.js.map +0 -1
  426. package/lib/api/graphql/queries.d.ts.map +0 -1
  427. package/lib/api/graphql/queries.js.map +0 -1
  428. package/lib/api/graphql/types.d.ts.map +0 -1
  429. package/lib/bridge/buildTransaction.d.ts.map +0 -1
  430. package/lib/bridge/buildTransaction.js.map +0 -1
  431. package/lib/bridge/createTransaction.d.ts.map +0 -1
  432. package/lib/bridge/createTransaction.js.map +0 -1
  433. package/lib-es/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
  434. package/lib-es/__tests__/bridge/buildTransaction.test.js.map +0 -1
  435. package/lib-es/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
  436. package/lib-es/__tests__/bridge/createTransaction.test.js.map +0 -1
  437. package/lib-es/api/graphql/queries.d.ts.map +0 -1
  438. package/lib-es/api/graphql/queries.js.map +0 -1
  439. package/lib-es/api/graphql/types.d.ts.map +0 -1
  440. package/lib-es/bridge/buildTransaction.d.ts.map +0 -1
  441. package/lib-es/bridge/buildTransaction.js.map +0 -1
  442. package/lib-es/bridge/createTransaction.d.ts.map +0 -1
  443. package/lib-es/bridge/createTransaction.js.map +0 -1
  444. /package/lib/__tests__/{bridge → logic}/buildTransaction.test.d.ts +0 -0
  445. /package/lib/__tests__/{bridge → logic}/createTransaction.test.d.ts +0 -0
  446. /package/lib/{bridge → logic}/createTransaction.d.ts +0 -0
  447. /package/lib/{api → network}/graphql/queries.d.ts +0 -0
  448. /package/lib/{api → network}/graphql/queries.js +0 -0
  449. /package/lib/{api → network}/graphql/types.d.ts +0 -0
  450. /package/lib/{api → network}/graphql/types.js +0 -0
  451. /package/lib-es/__tests__/{bridge → logic}/buildTransaction.test.d.ts +0 -0
  452. /package/lib-es/__tests__/{bridge → logic}/createTransaction.test.d.ts +0 -0
  453. /package/lib-es/{bridge → logic}/createTransaction.d.ts +0 -0
  454. /package/lib-es/{api → network}/graphql/queries.d.ts +0 -0
  455. /package/lib-es/{api → network}/graphql/queries.js +0 -0
  456. /package/lib-es/{api → network}/graphql/types.d.ts +0 -0
  457. /package/lib-es/{api → network}/graphql/types.js +0 -0
  458. /package/src/{api → network}/graphql/queries.ts +0 -0
  459. /package/src/{api → network}/graphql/types.ts +0 -0
@@ -1,20 +1,13 @@
1
1
  import BigNumber from "bignumber.js";
2
- import { APTOS_ASSET_ID, APTOS_COIN_CHANGE, APTOS_FUNGIBLE_STORE, APTOS_OBJECT_CORE, DIRECTION, } from "../../constants";
3
- import { calculateAmount, compareAddress, getCoinAndAmounts, getFunctionAddress, getResourceAddress, isTestnet, processRecipients, getMaxSendBalance, normalizeTransactionOptions, getBlankOperation, txsToOps, getEventCoinAddress, getEventFAAddress, } from "../../bridge/logic";
2
+ import { APTOS_COIN_CHANGE, DIRECTION } from "../../constants";
3
+ import { getMaxSendBalance, getBlankOperation, txsToOps } from "../../bridge/logic";
4
4
  import { createFixtureAccount, createFixtureTransaction } from "../../bridge/bridge.fixture";
5
5
  import { findTokenByAddressInCurrency } from "@ledgerhq/cryptoassets";
6
6
  import { decodeTokenAccountId, encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
7
+ import { normalizeTransactionOptions } from "../../logic/normalizeTransactionOptions";
7
8
  jest.mock("@ledgerhq/cryptoassets");
8
9
  jest.mock("@ledgerhq/coin-framework/account/index");
9
10
  describe("Aptos logic ", () => {
10
- describe("isTestnet", () => {
11
- it("should return true for testnet currencies", () => {
12
- expect(isTestnet("aptos_testnet")).toBe(true);
13
- });
14
- it("should return false for mainnet currencies", () => {
15
- expect(isTestnet("aptos")).toBe(false);
16
- });
17
- });
18
11
  describe("getMaxSendBalance", () => {
19
12
  it("should return the correct max send balance when amount is greater than total gas", () => {
20
13
  const amount = new BigNumber(1000000);
@@ -136,549 +129,6 @@ describe("Aptos logic ", () => {
136
129
  });
137
130
  });
138
131
  describe("Aptos sync logic ", () => {
139
- describe("compareAddress", () => {
140
- it("should return true for identical addresses", () => {
141
- const addressA = "0x1234567890abcdef";
142
- const addressB = "0x1234567890abcdef";
143
- expect(compareAddress(addressA, addressB)).toBe(true);
144
- });
145
- it("should return true for addresses with different cases", () => {
146
- const addressA = "0x1234567890abcdef";
147
- const addressB = "0x1234567890ABCDEF";
148
- expect(compareAddress(addressA, addressB)).toBe(true);
149
- });
150
- it("should return true for addresses with different hex formats", () => {
151
- const addressA = "0x1234567890abcdef";
152
- const addressB = "1234567890abcdef";
153
- expect(compareAddress(addressA, addressB)).toBe(true);
154
- });
155
- it("should return false for different addresses", () => {
156
- const addressA = "0x1234567890abcdef";
157
- const addressB = "0xfedcba0987654321";
158
- expect(compareAddress(addressA, addressB)).toBe(false);
159
- });
160
- });
161
- describe("getFunctionAddress", () => {
162
- it("should return the function address when payload contains a function", () => {
163
- const payload = {
164
- function: "0x1::coin::transfer",
165
- typeArguments: [],
166
- functionArguments: [],
167
- };
168
- const result = getFunctionAddress(payload);
169
- expect(result).toBe("0x1");
170
- });
171
- it("should return undefined when payload does not contain a function", () => {
172
- const payload = {
173
- function: "::::",
174
- typeArguments: [],
175
- functionArguments: [],
176
- };
177
- const result = getFunctionAddress(payload);
178
- expect(result).toBeUndefined();
179
- });
180
- it("should return undefined when payload is empty", () => {
181
- const payload = {};
182
- const result = getFunctionAddress(payload);
183
- expect(result).toBeUndefined();
184
- });
185
- });
186
- describe("processRecipients", () => {
187
- let op;
188
- beforeEach(() => {
189
- op = {
190
- id: "",
191
- hash: "",
192
- type: "",
193
- value: new BigNumber(0),
194
- fee: new BigNumber(0),
195
- blockHash: "",
196
- blockHeight: 0,
197
- senders: [],
198
- recipients: [],
199
- accountId: "",
200
- date: new Date(),
201
- extra: {},
202
- transactionSequenceNumber: 0,
203
- hasFailed: false,
204
- };
205
- });
206
- it("should add recipient for transfer-like functions from LL account", () => {
207
- const payload = {
208
- function: "0x1::coin::transfer",
209
- typeArguments: [],
210
- functionArguments: ["0x13", 1], // from: &signer, to: address, amount: u64
211
- };
212
- processRecipients(payload, "0x13", op, "0x1");
213
- expect(op.recipients).toContain("0x13");
214
- });
215
- it("should add recipient for transfer-like functions from external account", () => {
216
- const payload = {
217
- function: "0x1::coin::transfer",
218
- typeArguments: [],
219
- functionArguments: ["0x12", 1], // from: &signer, to: address, amount: u64
220
- };
221
- processRecipients(payload, "0x13", op, "0x1");
222
- expect(op.recipients).toContain("0x12");
223
- });
224
- it("should add recipients for batch transfer functions", () => {
225
- const payload = {
226
- function: "0x1::aptos_account::batch_transfer_coins",
227
- typeArguments: [APTOS_ASSET_ID],
228
- functionArguments: [
229
- ["0x12", "0x13"],
230
- [1, 2],
231
- ],
232
- };
233
- op.senders.push("0x11");
234
- processRecipients(payload, "0x12", op, "0x1");
235
- expect(op.recipients).toContain("0x12");
236
- });
237
- it("should add function address as recipient for other smart contracts", () => {
238
- const payload = {
239
- function: "0x2::other::contract",
240
- typeArguments: [],
241
- functionArguments: [["0x12"], [1]],
242
- };
243
- processRecipients(payload, "0x11", op, "0x2");
244
- expect(op.recipients).toContain("0x2");
245
- });
246
- it("should add recipient for fungible assets transfer-like functions", () => {
247
- const payload = {
248
- function: "0x1::primary_fungible_store::transfer",
249
- typeArguments: [],
250
- functionArguments: [["0xfff"], "0x13"],
251
- };
252
- processRecipients(payload, "0x13", op, "0x1");
253
- expect(op.recipients).toContain("0x13");
254
- });
255
- });
256
- describe("getResourceAddress", () => {
257
- it("should return coin name from the change", () => {
258
- const change = {
259
- type: "write_resource",
260
- data: {
261
- type: APTOS_COIN_CHANGE,
262
- data: {
263
- withdraw_events: {
264
- guid: {
265
- id: {
266
- addr: "0x11",
267
- creation_num: "2",
268
- },
269
- },
270
- },
271
- },
272
- },
273
- };
274
- const tx = {
275
- hash: "0x123",
276
- block: { hash: "0xabc", height: 1 },
277
- timestamp: "1000000",
278
- sequence_number: "1",
279
- version: "1",
280
- changes: [change],
281
- };
282
- const event = {
283
- guid: {
284
- account_address: "0x11",
285
- creation_number: "2",
286
- },
287
- type: "0x1::coin::WithdrawEvent",
288
- };
289
- const result = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
290
- expect(result).toEqual(APTOS_ASSET_ID);
291
- });
292
- it("should return null for not finding the valid coin in change", () => {
293
- const change = {
294
- type: "write_resource",
295
- data: {
296
- type: APTOS_COIN_CHANGE,
297
- data: {
298
- withdraw_events: {
299
- guid: {
300
- id: {
301
- addr: "0x12",
302
- creation_num: "2",
303
- },
304
- },
305
- },
306
- },
307
- },
308
- };
309
- const tx = {
310
- hash: "0x123",
311
- block: { hash: "0xabc", height: 1 },
312
- timestamp: "1000000",
313
- sequence_number: "1",
314
- version: "1",
315
- changes: [change],
316
- };
317
- const event = {
318
- guid: {
319
- account_address: "0x11",
320
- creation_number: "1",
321
- },
322
- type: "0x1::coin::WithdrawEvent",
323
- };
324
- const result = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
325
- expect(result).toBe(null);
326
- });
327
- it("should return null for not finding the event name in change", () => {
328
- const change = {
329
- type: "write_resource",
330
- data: {
331
- type: APTOS_COIN_CHANGE,
332
- data: {
333
- other_events: {
334
- guid: {
335
- id: {
336
- addr: "0x12",
337
- creation_num: "2",
338
- },
339
- },
340
- },
341
- },
342
- },
343
- };
344
- const tx = {
345
- hash: "0x123",
346
- block: { hash: "0xabc", height: 1 },
347
- timestamp: "1000000",
348
- sequence_number: "1",
349
- version: "1",
350
- changes: [change],
351
- };
352
- const event = {
353
- guid: {
354
- account_address: "0x11",
355
- creation_number: "1",
356
- },
357
- type: "0x1::coin::WithdrawEvent",
358
- };
359
- const result = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
360
- expect(result).toBe(null);
361
- });
362
- it("should return fungible asset address", () => {
363
- const change = {
364
- type: "write_resource",
365
- address: "0xsomeaddress",
366
- data: {
367
- type: APTOS_FUNGIBLE_STORE,
368
- data: {
369
- metadata: {
370
- inner: "0xassetaddress",
371
- },
372
- },
373
- },
374
- };
375
- const tx = {
376
- hash: "0x123",
377
- block: { hash: "0xabc", height: 1 },
378
- timestamp: "1000000",
379
- sequence_number: "1",
380
- version: "1",
381
- changes: [change],
382
- };
383
- const event = {
384
- guid: {
385
- account_address: "0x0",
386
- creation_number: "0",
387
- },
388
- type: "0x1::fungible_asset::Deposit",
389
- data: {
390
- amount: "100",
391
- store: "0xsomeaddress",
392
- },
393
- };
394
- const result = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
395
- expect(result).toEqual("0xassetaddress");
396
- });
397
- it("should return null address instead of fungible asset when wrong type", () => {
398
- const change = {
399
- type: "write_resource",
400
- address: "0xsomeaddress",
401
- data: {
402
- type: APTOS_COIN_CHANGE,
403
- data: {
404
- metadata: {
405
- inner: "0xassetaddress",
406
- },
407
- },
408
- },
409
- };
410
- const tx = {
411
- hash: "0x123",
412
- block: { hash: "0xabc", height: 1 },
413
- timestamp: "1000000",
414
- sequence_number: "1",
415
- version: "1",
416
- changes: [change],
417
- };
418
- const event = {
419
- guid: {
420
- account_address: "0x0",
421
- creation_number: "0",
422
- },
423
- type: "0x1::fungible_asset::Deposit",
424
- data: {
425
- amount: "100",
426
- store: "0xsomeaddress",
427
- },
428
- };
429
- const result = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
430
- expect(result).toEqual(null);
431
- });
432
- it("should return null address instead of fungible asset when wrong event address", () => {
433
- const change = {
434
- type: "write_resource",
435
- address: "0xsomeaddress",
436
- data: {
437
- type: APTOS_FUNGIBLE_STORE,
438
- data: {
439
- metadata: {
440
- inner: "0xassetaddress",
441
- },
442
- },
443
- },
444
- };
445
- const tx = {
446
- hash: "0x123",
447
- block: { hash: "0xabc", height: 1 },
448
- timestamp: "1000000",
449
- sequence_number: "1",
450
- version: "1",
451
- changes: [change],
452
- };
453
- const event = {
454
- guid: {
455
- account_address: "0x0",
456
- creation_number: "0",
457
- },
458
- type: "0x1::fungible_asset::Deposit",
459
- data: {
460
- amount: "100",
461
- store: "0xwrongaddress",
462
- },
463
- };
464
- const result = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
465
- expect(result).toEqual(null);
466
- });
467
- });
468
- describe("getCoinAndAmounts", () => {
469
- it("should calculate the correct legacy coins amounts for withdraw and deposit events", () => {
470
- const tx = {
471
- events: [
472
- {
473
- type: "0x1::coin::WithdrawEvent",
474
- guid: {
475
- account_address: "0x11",
476
- creation_number: "1",
477
- },
478
- data: {
479
- amount: "100",
480
- },
481
- },
482
- {
483
- type: "0x1::coin::DepositEvent",
484
- guid: {
485
- account_address: "0x11",
486
- creation_number: "2",
487
- },
488
- data: {
489
- amount: "50",
490
- },
491
- },
492
- ],
493
- changes: [
494
- {
495
- type: "write_resource",
496
- data: {
497
- type: APTOS_COIN_CHANGE,
498
- data: {
499
- withdraw_events: {
500
- guid: {
501
- id: {
502
- addr: "0x11",
503
- creation_num: "1",
504
- },
505
- },
506
- },
507
- deposit_events: {
508
- guid: {
509
- id: {
510
- addr: "0x11",
511
- creation_num: "2",
512
- },
513
- },
514
- },
515
- },
516
- },
517
- },
518
- ],
519
- };
520
- const address = "0x11";
521
- const result = getCoinAndAmounts(tx, address);
522
- expect(result.amount_in).toEqual(new BigNumber(50));
523
- expect(result.amount_out).toEqual(new BigNumber(100));
524
- expect(result.coin_id).toEqual(APTOS_ASSET_ID);
525
- });
526
- it("should calculate the correct fungible asset amounts for withdraw and deposit events", () => {
527
- const tx = {
528
- events: [
529
- {
530
- type: "0x1::fungible_asset::Withdraw",
531
- guid: {
532
- account_address: "0x11",
533
- creation_number: "1",
534
- },
535
- data: {
536
- amount: "100",
537
- store: "0x22",
538
- },
539
- },
540
- {
541
- type: "0x1::fungible_asset::Deposit",
542
- guid: {
543
- account_address: "0x11",
544
- creation_number: "2",
545
- },
546
- data: {
547
- amount: "50",
548
- store: "0x33",
549
- },
550
- },
551
- ],
552
- changes: [
553
- {
554
- type: "write_resource",
555
- address: "0x22",
556
- data: {
557
- type: APTOS_FUNGIBLE_STORE,
558
- data: {
559
- metadata: {
560
- inner: "0x44",
561
- },
562
- transfer_events: {
563
- guid: {
564
- id: {
565
- addr: "0x11",
566
- creation_num: "2",
567
- },
568
- },
569
- },
570
- },
571
- },
572
- },
573
- {
574
- type: "write_resource",
575
- address: "0x22",
576
- data: {
577
- type: APTOS_OBJECT_CORE,
578
- data: {
579
- owner: "0x11",
580
- transfer_events: {
581
- guid: {
582
- id: {
583
- addr: "0x22",
584
- creation_num: "2",
585
- },
586
- },
587
- },
588
- },
589
- },
590
- },
591
- {
592
- type: "write_resource",
593
- data: {
594
- type: APTOS_COIN_CHANGE,
595
- data: {
596
- withdraw_events: {
597
- guid: {
598
- id: {
599
- addr: "0x11",
600
- creation_num: "1",
601
- },
602
- },
603
- },
604
- deposit_events: {
605
- guid: {
606
- id: {
607
- addr: "0x11",
608
- creation_num: "2",
609
- },
610
- },
611
- },
612
- },
613
- },
614
- },
615
- ],
616
- };
617
- const address = "0x11";
618
- const result = getCoinAndAmounts(tx, address);
619
- expect(result.amount_in).toEqual(new BigNumber(0));
620
- expect(result.amount_out).toEqual(new BigNumber(100));
621
- expect(result.coin_id).toEqual("0x44");
622
- });
623
- it("should handle transactions with other events", () => {
624
- const tx = {
625
- events: [
626
- {
627
- type: "0x1::coin::OtherEvent",
628
- guid: {
629
- account_address: "0x11",
630
- creation_number: "1",
631
- },
632
- data: {
633
- amount: "100",
634
- },
635
- },
636
- ],
637
- };
638
- const address = "0x1";
639
- const result = getCoinAndAmounts(tx, address);
640
- expect(result.amount_in).toEqual(new BigNumber(0));
641
- expect(result.amount_out).toEqual(new BigNumber(0));
642
- expect(result.coin_id).toEqual(null);
643
- });
644
- });
645
- describe("calculateAmount", () => {
646
- it("should calculate the correct amount when the address is the sender", () => {
647
- const address = "0x11";
648
- const sender = "0x11";
649
- const amount_in = new BigNumber(50);
650
- const amount_out = new BigNumber(100);
651
- const result = calculateAmount(sender, address, amount_in, amount_out);
652
- // LL negates the amount for SEND transactions during output
653
- expect(result).toEqual(new BigNumber(50)); // -(50 - 100 - 10)
654
- });
655
- it("should calculate the correct amount when the address is not the sender", () => {
656
- const address = "0x11";
657
- const sender = "0x12";
658
- const amount_in = new BigNumber(100);
659
- const amount_out = new BigNumber(50);
660
- const result = calculateAmount(sender, address, amount_in, amount_out);
661
- expect(result).toEqual(new BigNumber(50)); // 100 - 50
662
- });
663
- it("should handle transactions with zero amounts", () => {
664
- const address = "0x11";
665
- const sender = "0x11";
666
- const amount_in = new BigNumber(0);
667
- const amount_out = new BigNumber(0);
668
- const result = calculateAmount(sender, address, amount_in, amount_out);
669
- // LL negates the amount for SEND transactions during output
670
- expect(result).toEqual(new BigNumber(0)); // -(0 - 0 - 10)
671
- });
672
- it("should get negative numbers (for send tx with deposit to account)", () => {
673
- const address = "0x11";
674
- const sender = "0x11";
675
- const amount_in = new BigNumber(100);
676
- const amount_out = new BigNumber(0);
677
- const result = calculateAmount(sender, address, amount_in, amount_out);
678
- // LL negates the amount for SEND transactions during output
679
- expect(result).toEqual(new BigNumber(100).negated()); // 100 - 10
680
- });
681
- });
682
132
  describe("txsToOps", () => {
683
133
  it("should convert Aptos transactions to operations correctly", () => {
684
134
  const address = "0x11";