@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,52 +1,17 @@
1
- import {
2
- EntryFunctionPayloadResponse,
3
- Event,
4
- InputEntryFunctionData,
5
- WriteSetChange,
6
- } from "@aptos-labs/ts-sdk";
7
- import type { Operation, OperationType } from "@ledgerhq/types-live";
1
+ import { EntryFunctionPayloadResponse } from "@aptos-labs/ts-sdk";
8
2
  import BigNumber from "bignumber.js";
9
- import {
10
- APTOS_ASSET_ID,
11
- APTOS_COIN_CHANGE,
12
- APTOS_FUNGIBLE_STORE,
13
- APTOS_OBJECT_CORE,
14
- DIRECTION,
15
- } from "../../constants";
16
- import {
17
- calculateAmount,
18
- compareAddress,
19
- getCoinAndAmounts,
20
- getFunctionAddress,
21
- getResourceAddress,
22
- isTestnet,
23
- processRecipients,
24
- getMaxSendBalance,
25
- normalizeTransactionOptions,
26
- getBlankOperation,
27
- txsToOps,
28
- getEventCoinAddress,
29
- getEventFAAddress,
30
- } from "../../bridge/logic";
3
+ import { APTOS_COIN_CHANGE, DIRECTION } from "../../constants";
4
+ import { getMaxSendBalance, getBlankOperation, txsToOps } from "../../bridge/logic";
31
5
  import type { AptosTransaction, TransactionOptions } from "../../types";
32
6
  import { createFixtureAccount, createFixtureTransaction } from "../../bridge/bridge.fixture";
33
7
  import { findTokenByAddressInCurrency } from "@ledgerhq/cryptoassets";
34
8
  import { decodeTokenAccountId, encodeTokenAccountId } from "@ledgerhq/coin-framework/account/index";
9
+ import { normalizeTransactionOptions } from "../../logic/normalizeTransactionOptions";
35
10
 
36
11
  jest.mock("@ledgerhq/cryptoassets");
37
12
  jest.mock("@ledgerhq/coin-framework/account/index");
38
13
 
39
14
  describe("Aptos logic ", () => {
40
- describe("isTestnet", () => {
41
- it("should return true for testnet currencies", () => {
42
- expect(isTestnet("aptos_testnet")).toBe(true);
43
- });
44
-
45
- it("should return false for mainnet currencies", () => {
46
- expect(isTestnet("aptos")).toBe(false);
47
- });
48
- });
49
-
50
15
  describe("getMaxSendBalance", () => {
51
16
  it("should return the correct max send balance when amount is greater than total gas", () => {
52
17
  const amount = new BigNumber(1000000);
@@ -183,616 +148,6 @@ describe("Aptos logic ", () => {
183
148
  });
184
149
 
185
150
  describe("Aptos sync logic ", () => {
186
- describe("compareAddress", () => {
187
- it("should return true for identical addresses", () => {
188
- const addressA = "0x1234567890abcdef";
189
- const addressB = "0x1234567890abcdef";
190
- expect(compareAddress(addressA, addressB)).toBe(true);
191
- });
192
-
193
- it("should return true for addresses with different cases", () => {
194
- const addressA = "0x1234567890abcdef";
195
- const addressB = "0x1234567890ABCDEF";
196
- expect(compareAddress(addressA, addressB)).toBe(true);
197
- });
198
-
199
- it("should return true for addresses with different hex formats", () => {
200
- const addressA = "0x1234567890abcdef";
201
- const addressB = "1234567890abcdef";
202
- expect(compareAddress(addressA, addressB)).toBe(true);
203
- });
204
-
205
- it("should return false for different addresses", () => {
206
- const addressA = "0x1234567890abcdef";
207
- const addressB = "0xfedcba0987654321";
208
- expect(compareAddress(addressA, addressB)).toBe(false);
209
- });
210
- });
211
-
212
- describe("getFunctionAddress", () => {
213
- it("should return the function address when payload contains a function", () => {
214
- const payload: InputEntryFunctionData = {
215
- function: "0x1::coin::transfer",
216
- typeArguments: [],
217
- functionArguments: [],
218
- };
219
-
220
- const result = getFunctionAddress(payload);
221
- expect(result).toBe("0x1");
222
- });
223
-
224
- it("should return undefined when payload does not contain a function", () => {
225
- const payload = {
226
- function: "::::",
227
- typeArguments: [],
228
- functionArguments: [],
229
- } as InputEntryFunctionData;
230
-
231
- const result = getFunctionAddress(payload);
232
- expect(result).toBeUndefined();
233
- });
234
-
235
- it("should return undefined when payload is empty", () => {
236
- const payload = {} as InputEntryFunctionData;
237
-
238
- const result = getFunctionAddress(payload);
239
- expect(result).toBeUndefined();
240
- });
241
- });
242
-
243
- describe("processRecipients", () => {
244
- let op: Operation;
245
-
246
- beforeEach(() => {
247
- op = {
248
- id: "",
249
- hash: "",
250
- type: "" as OperationType,
251
- value: new BigNumber(0),
252
- fee: new BigNumber(0),
253
- blockHash: "",
254
- blockHeight: 0,
255
- senders: [],
256
- recipients: [],
257
- accountId: "",
258
- date: new Date(),
259
- extra: {},
260
- transactionSequenceNumber: 0,
261
- hasFailed: false,
262
- };
263
- });
264
-
265
- it("should add recipient for transfer-like functions from LL account", () => {
266
- const payload: InputEntryFunctionData = {
267
- function: "0x1::coin::transfer",
268
- typeArguments: [],
269
- functionArguments: ["0x13", 1], // from: &signer, to: address, amount: u64
270
- };
271
-
272
- processRecipients(payload, "0x13", op, "0x1");
273
- expect(op.recipients).toContain("0x13");
274
- });
275
-
276
- it("should add recipient for transfer-like functions from external account", () => {
277
- const payload: InputEntryFunctionData = {
278
- function: "0x1::coin::transfer",
279
- typeArguments: [],
280
- functionArguments: ["0x12", 1], // from: &signer, to: address, amount: u64
281
- };
282
-
283
- processRecipients(payload, "0x13", op, "0x1");
284
- expect(op.recipients).toContain("0x12");
285
- });
286
-
287
- it("should add recipients for batch transfer functions", () => {
288
- const payload: InputEntryFunctionData = {
289
- function: "0x1::aptos_account::batch_transfer_coins",
290
- typeArguments: [APTOS_ASSET_ID],
291
- functionArguments: [
292
- ["0x12", "0x13"],
293
- [1, 2],
294
- ],
295
- };
296
-
297
- op.senders.push("0x11");
298
- processRecipients(payload, "0x12", op, "0x1");
299
- expect(op.recipients).toContain("0x12");
300
- });
301
-
302
- it("should add function address as recipient for other smart contracts", () => {
303
- const payload: InputEntryFunctionData = {
304
- function: "0x2::other::contract",
305
- typeArguments: [],
306
- functionArguments: [["0x12"], [1]],
307
- };
308
-
309
- processRecipients(payload, "0x11", op, "0x2");
310
- expect(op.recipients).toContain("0x2");
311
- });
312
-
313
- it("should add recipient for fungible assets transfer-like functions", () => {
314
- const payload: InputEntryFunctionData = {
315
- function: "0x1::primary_fungible_store::transfer",
316
- typeArguments: [],
317
- functionArguments: [["0xfff"], "0x13"],
318
- };
319
-
320
- processRecipients(payload, "0x13", op, "0x1");
321
- expect(op.recipients).toContain("0x13");
322
- });
323
- });
324
-
325
- describe("getResourceAddress", () => {
326
- it("should return coin name from the change", () => {
327
- const change = {
328
- type: "write_resource",
329
- data: {
330
- type: APTOS_COIN_CHANGE,
331
- data: {
332
- withdraw_events: {
333
- guid: {
334
- id: {
335
- addr: "0x11",
336
- creation_num: "2",
337
- },
338
- },
339
- },
340
- },
341
- },
342
- } as unknown as WriteSetChange;
343
-
344
- const tx: AptosTransaction = {
345
- hash: "0x123",
346
- block: { hash: "0xabc", height: 1 },
347
- timestamp: "1000000",
348
- sequence_number: "1",
349
- version: "1",
350
- changes: [change],
351
- } as unknown as AptosTransaction;
352
-
353
- const event = {
354
- guid: {
355
- account_address: "0x11",
356
- creation_number: "2",
357
- },
358
- type: "0x1::coin::WithdrawEvent",
359
- } as Event;
360
-
361
- const result = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
362
- expect(result).toEqual(APTOS_ASSET_ID);
363
- });
364
-
365
- it("should return null for not finding the valid coin in change", () => {
366
- const change = {
367
- type: "write_resource",
368
- data: {
369
- type: APTOS_COIN_CHANGE,
370
- data: {
371
- withdraw_events: {
372
- guid: {
373
- id: {
374
- addr: "0x12",
375
- creation_num: "2",
376
- },
377
- },
378
- },
379
- },
380
- },
381
- } as unknown as WriteSetChange;
382
-
383
- const tx: AptosTransaction = {
384
- hash: "0x123",
385
- block: { hash: "0xabc", height: 1 },
386
- timestamp: "1000000",
387
- sequence_number: "1",
388
- version: "1",
389
- changes: [change],
390
- } as unknown as AptosTransaction;
391
-
392
- const event = {
393
- guid: {
394
- account_address: "0x11",
395
- creation_number: "1",
396
- },
397
- type: "0x1::coin::WithdrawEvent",
398
- } as Event;
399
-
400
- const result = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
401
- expect(result).toBe(null);
402
- });
403
-
404
- it("should return null for not finding the event name in change", () => {
405
- const change = {
406
- type: "write_resource",
407
- data: {
408
- type: APTOS_COIN_CHANGE,
409
- data: {
410
- other_events: {
411
- guid: {
412
- id: {
413
- addr: "0x12",
414
- creation_num: "2",
415
- },
416
- },
417
- },
418
- },
419
- },
420
- } as unknown as WriteSetChange;
421
-
422
- const tx: AptosTransaction = {
423
- hash: "0x123",
424
- block: { hash: "0xabc", height: 1 },
425
- timestamp: "1000000",
426
- sequence_number: "1",
427
- version: "1",
428
- changes: [change],
429
- } as unknown as AptosTransaction;
430
-
431
- const event = {
432
- guid: {
433
- account_address: "0x11",
434
- creation_number: "1",
435
- },
436
- type: "0x1::coin::WithdrawEvent",
437
- } as Event;
438
-
439
- const result = getResourceAddress(tx, event, "withdraw_events", getEventCoinAddress);
440
- expect(result).toBe(null);
441
- });
442
-
443
- it("should return fungible asset address", () => {
444
- const change = {
445
- type: "write_resource",
446
- address: "0xsomeaddress",
447
- data: {
448
- type: APTOS_FUNGIBLE_STORE,
449
- data: {
450
- metadata: {
451
- inner: "0xassetaddress",
452
- },
453
- },
454
- },
455
- } as unknown as WriteSetChange;
456
-
457
- const tx: AptosTransaction = {
458
- hash: "0x123",
459
- block: { hash: "0xabc", height: 1 },
460
- timestamp: "1000000",
461
- sequence_number: "1",
462
- version: "1",
463
- changes: [change],
464
- } as unknown as AptosTransaction;
465
-
466
- const event = {
467
- guid: {
468
- account_address: "0x0",
469
- creation_number: "0",
470
- },
471
- type: "0x1::fungible_asset::Deposit",
472
- data: {
473
- amount: "100",
474
- store: "0xsomeaddress",
475
- },
476
- } as Event;
477
-
478
- const result = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
479
- expect(result).toEqual("0xassetaddress");
480
- });
481
-
482
- it("should return null address instead of fungible asset when wrong type", () => {
483
- const change = {
484
- type: "write_resource",
485
- address: "0xsomeaddress",
486
- data: {
487
- type: APTOS_COIN_CHANGE,
488
- data: {
489
- metadata: {
490
- inner: "0xassetaddress",
491
- },
492
- },
493
- },
494
- } as unknown as WriteSetChange;
495
-
496
- const tx: AptosTransaction = {
497
- hash: "0x123",
498
- block: { hash: "0xabc", height: 1 },
499
- timestamp: "1000000",
500
- sequence_number: "1",
501
- version: "1",
502
- changes: [change],
503
- } as unknown as AptosTransaction;
504
-
505
- const event = {
506
- guid: {
507
- account_address: "0x0",
508
- creation_number: "0",
509
- },
510
- type: "0x1::fungible_asset::Deposit",
511
- data: {
512
- amount: "100",
513
- store: "0xsomeaddress",
514
- },
515
- } as Event;
516
-
517
- const result = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
518
- expect(result).toEqual(null);
519
- });
520
-
521
- it("should return null address instead of fungible asset when wrong event address", () => {
522
- const change = {
523
- type: "write_resource",
524
- address: "0xsomeaddress",
525
- data: {
526
- type: APTOS_FUNGIBLE_STORE,
527
- data: {
528
- metadata: {
529
- inner: "0xassetaddress",
530
- },
531
- },
532
- },
533
- } as unknown as WriteSetChange;
534
-
535
- const tx: AptosTransaction = {
536
- hash: "0x123",
537
- block: { hash: "0xabc", height: 1 },
538
- timestamp: "1000000",
539
- sequence_number: "1",
540
- version: "1",
541
- changes: [change],
542
- } as unknown as AptosTransaction;
543
-
544
- const event = {
545
- guid: {
546
- account_address: "0x0",
547
- creation_number: "0",
548
- },
549
- type: "0x1::fungible_asset::Deposit",
550
- data: {
551
- amount: "100",
552
- store: "0xwrongaddress",
553
- },
554
- } as Event;
555
-
556
- const result = getResourceAddress(tx, event, "withdraw_events", getEventFAAddress);
557
- expect(result).toEqual(null);
558
- });
559
- });
560
-
561
- describe("getCoinAndAmounts", () => {
562
- it("should calculate the correct legacy coins amounts for withdraw and deposit events", () => {
563
- const tx = {
564
- events: [
565
- {
566
- type: "0x1::coin::WithdrawEvent",
567
- guid: {
568
- account_address: "0x11",
569
- creation_number: "1",
570
- },
571
- data: {
572
- amount: "100",
573
- },
574
- },
575
- {
576
- type: "0x1::coin::DepositEvent",
577
- guid: {
578
- account_address: "0x11",
579
- creation_number: "2",
580
- },
581
- data: {
582
- amount: "50",
583
- },
584
- },
585
- ],
586
- changes: [
587
- {
588
- type: "write_resource",
589
- data: {
590
- type: APTOS_COIN_CHANGE,
591
- data: {
592
- withdraw_events: {
593
- guid: {
594
- id: {
595
- addr: "0x11",
596
- creation_num: "1",
597
- },
598
- },
599
- },
600
- deposit_events: {
601
- guid: {
602
- id: {
603
- addr: "0x11",
604
- creation_num: "2",
605
- },
606
- },
607
- },
608
- },
609
- },
610
- },
611
- ],
612
- } as unknown as AptosTransaction;
613
-
614
- const address = "0x11";
615
- const result = getCoinAndAmounts(tx, address);
616
-
617
- expect(result.amount_in).toEqual(new BigNumber(50));
618
- expect(result.amount_out).toEqual(new BigNumber(100));
619
- expect(result.coin_id).toEqual(APTOS_ASSET_ID);
620
- });
621
-
622
- it("should calculate the correct fungible asset amounts for withdraw and deposit events", () => {
623
- const tx = {
624
- events: [
625
- {
626
- type: "0x1::fungible_asset::Withdraw",
627
- guid: {
628
- account_address: "0x11",
629
- creation_number: "1",
630
- },
631
- data: {
632
- amount: "100",
633
- store: "0x22",
634
- },
635
- },
636
- {
637
- type: "0x1::fungible_asset::Deposit",
638
- guid: {
639
- account_address: "0x11",
640
- creation_number: "2",
641
- },
642
- data: {
643
- amount: "50",
644
- store: "0x33",
645
- },
646
- },
647
- ],
648
- changes: [
649
- {
650
- type: "write_resource",
651
- address: "0x22",
652
- data: {
653
- type: APTOS_FUNGIBLE_STORE,
654
- data: {
655
- metadata: {
656
- inner: "0x44",
657
- },
658
- transfer_events: {
659
- guid: {
660
- id: {
661
- addr: "0x11",
662
- creation_num: "2",
663
- },
664
- },
665
- },
666
- },
667
- },
668
- },
669
- {
670
- type: "write_resource",
671
- address: "0x22",
672
- data: {
673
- type: APTOS_OBJECT_CORE,
674
- data: {
675
- owner: "0x11",
676
- transfer_events: {
677
- guid: {
678
- id: {
679
- addr: "0x22",
680
- creation_num: "2",
681
- },
682
- },
683
- },
684
- },
685
- },
686
- },
687
- {
688
- type: "write_resource",
689
- data: {
690
- type: APTOS_COIN_CHANGE,
691
- data: {
692
- withdraw_events: {
693
- guid: {
694
- id: {
695
- addr: "0x11",
696
- creation_num: "1",
697
- },
698
- },
699
- },
700
- deposit_events: {
701
- guid: {
702
- id: {
703
- addr: "0x11",
704
- creation_num: "2",
705
- },
706
- },
707
- },
708
- },
709
- },
710
- },
711
- ],
712
- } as unknown as AptosTransaction;
713
-
714
- const address = "0x11";
715
- const result = getCoinAndAmounts(tx, address);
716
-
717
- expect(result.amount_in).toEqual(new BigNumber(0));
718
- expect(result.amount_out).toEqual(new BigNumber(100));
719
- expect(result.coin_id).toEqual("0x44");
720
- });
721
-
722
- it("should handle transactions with other events", () => {
723
- const tx = {
724
- events: [
725
- {
726
- type: "0x1::coin::OtherEvent",
727
- guid: {
728
- account_address: "0x11",
729
- creation_number: "1",
730
- },
731
- data: {
732
- amount: "100",
733
- },
734
- },
735
- ],
736
- } as unknown as AptosTransaction;
737
-
738
- const address = "0x1";
739
- const result = getCoinAndAmounts(tx, address);
740
-
741
- expect(result.amount_in).toEqual(new BigNumber(0));
742
- expect(result.amount_out).toEqual(new BigNumber(0));
743
- expect(result.coin_id).toEqual(null);
744
- });
745
- });
746
-
747
- describe("calculateAmount", () => {
748
- it("should calculate the correct amount when the address is the sender", () => {
749
- const address = "0x11";
750
- const sender = "0x11";
751
- const amount_in = new BigNumber(50);
752
- const amount_out = new BigNumber(100);
753
-
754
- const result = calculateAmount(sender, address, amount_in, amount_out);
755
-
756
- // LL negates the amount for SEND transactions during output
757
- expect(result).toEqual(new BigNumber(50)); // -(50 - 100 - 10)
758
- });
759
-
760
- it("should calculate the correct amount when the address is not the sender", () => {
761
- const address = "0x11";
762
- const sender = "0x12";
763
- const amount_in = new BigNumber(100);
764
- const amount_out = new BigNumber(50);
765
-
766
- const result = calculateAmount(sender, address, amount_in, amount_out);
767
-
768
- expect(result).toEqual(new BigNumber(50)); // 100 - 50
769
- });
770
-
771
- it("should handle transactions with zero amounts", () => {
772
- const address = "0x11";
773
- const sender = "0x11";
774
- const amount_in = new BigNumber(0);
775
- const amount_out = new BigNumber(0);
776
-
777
- const result = calculateAmount(sender, address, amount_in, amount_out);
778
-
779
- // LL negates the amount for SEND transactions during output
780
- expect(result).toEqual(new BigNumber(0)); // -(0 - 0 - 10)
781
- });
782
-
783
- it("should get negative numbers (for send tx with deposit to account)", () => {
784
- const address = "0x11";
785
- const sender = "0x11";
786
- const amount_in = new BigNumber(100);
787
- const amount_out = new BigNumber(0);
788
-
789
- const result = calculateAmount(sender, address, amount_in, amount_out);
790
-
791
- // LL negates the amount for SEND transactions during output
792
- expect(result).toEqual(new BigNumber(100).negated()); // 100 - 10
793
- });
794
- });
795
-
796
151
  describe("txsToOps", () => {
797
152
  it("should convert Aptos transactions to operations correctly", () => {
798
153
  const address = "0x11";
@@ -1,12 +1,12 @@
1
1
  import prepareTransaction from "../../bridge/prepareTransaction";
2
- import { AptosAPI } from "../../api";
2
+ import { AptosAPI } from "../../network";
3
3
  import { getEstimatedGas } from "../../bridge/getFeesForTransaction";
4
4
  import { getMaxSendBalance } from "../../bridge/logic";
5
5
  import BigNumber from "bignumber.js";
6
6
  import type { Account } from "@ledgerhq/types-live";
7
7
  import type { Transaction } from "../../types";
8
8
 
9
- jest.mock("../../api");
9
+ jest.mock("../../network");
10
10
  jest.mock("../../bridge/getFeesForTransaction");
11
11
  jest.mock("../../bridge/logic");
12
12