@ledgerhq/coin-aptos 1.9.6 → 1.10.0-nightly.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 (513) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +18 -6
  3. package/CHANGELOG.md +24 -0
  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 -404
  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 +115 -14
  23. package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
  24. package/lib/__tests__/bridge/getTransactionStatus.test.js +175 -37
  25. package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
  26. package/lib/__tests__/bridge/logic.test.js +702 -478
  27. package/lib/__tests__/bridge/logic.test.js.map +1 -1
  28. package/lib/__tests__/bridge/prepareTransaction.test.js +3 -3
  29. package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -1
  30. package/lib/__tests__/bridge/signOperation.test.js +137 -14
  31. package/lib/__tests__/bridge/signOperation.test.js.map +1 -1
  32. package/lib/__tests__/bridge/synchronisation.test.js +1215 -68
  33. package/lib/__tests__/bridge/synchronisation.test.js.map +1 -1
  34. package/lib/__tests__/index.test.js +1 -1
  35. package/lib/__tests__/index.test.js.map +1 -1
  36. package/lib/__tests__/logic/buildTransaction.test.d.ts.map +1 -0
  37. package/lib/__tests__/logic/buildTransaction.test.js +112 -0
  38. package/lib/__tests__/logic/buildTransaction.test.js.map +1 -0
  39. package/lib/__tests__/logic/calculateAmount.unit.test.d.ts +2 -0
  40. package/lib/__tests__/logic/calculateAmount.unit.test.d.ts.map +1 -0
  41. package/lib/__tests__/logic/calculateAmount.unit.test.js +45 -0
  42. package/lib/__tests__/logic/calculateAmount.unit.test.js.map +1 -0
  43. package/lib/__tests__/logic/combine.unit.test.d.ts +2 -0
  44. package/lib/__tests__/logic/combine.unit.test.d.ts.map +1 -0
  45. package/lib/__tests__/logic/combine.unit.test.js +47 -0
  46. package/lib/__tests__/logic/combine.unit.test.js.map +1 -0
  47. package/lib/__tests__/logic/compareAddress.unit.test.d.ts +2 -0
  48. package/lib/__tests__/logic/compareAddress.unit.test.d.ts.map +1 -0
  49. package/lib/__tests__/logic/compareAddress.unit.test.js +26 -0
  50. package/lib/__tests__/logic/compareAddress.unit.test.js.map +1 -0
  51. package/lib/__tests__/logic/createTransaction.test.d.ts.map +1 -0
  52. package/lib/__tests__/{bridge → logic}/createTransaction.test.js +2 -2
  53. package/lib/__tests__/logic/createTransaction.test.js.map +1 -0
  54. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.d.ts +2 -0
  55. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.d.ts.map +1 -0
  56. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.js +186 -0
  57. package/lib/__tests__/logic/getCoinAndAmounts.unit.test.js.map +1 -0
  58. package/lib/__tests__/logic/getFunctionAddress.unit.test.d.ts +2 -0
  59. package/lib/__tests__/logic/getFunctionAddress.unit.test.d.ts.map +1 -0
  60. package/lib/__tests__/logic/getFunctionAddress.unit.test.js +29 -0
  61. package/lib/__tests__/logic/getFunctionAddress.unit.test.js.map +1 -0
  62. package/lib/__tests__/logic/getResourceAddress.unit.test.d.ts +2 -0
  63. package/lib/__tests__/logic/getResourceAddress.unit.test.d.ts.map +1 -0
  64. package/lib/__tests__/logic/getResourceAddress.unit.test.js +218 -0
  65. package/lib/__tests__/logic/getResourceAddress.unit.test.js.map +1 -0
  66. package/lib/__tests__/logic/isTestnet.unit.test.d.ts +2 -0
  67. package/lib/__tests__/logic/isTestnet.unit.test.d.ts.map +1 -0
  68. package/lib/__tests__/logic/isTestnet.unit.test.js +12 -0
  69. package/lib/__tests__/logic/isTestnet.unit.test.js.map +1 -0
  70. package/lib/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
  71. package/lib/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
  72. package/lib/__tests__/logic/processRecipients.unit.test.js +79 -0
  73. package/lib/__tests__/logic/processRecipients.unit.test.js.map +1 -0
  74. package/lib/__tests__/network/client.test.d.ts +2 -0
  75. package/lib/__tests__/network/client.test.d.ts.map +1 -0
  76. package/lib/__tests__/network/client.test.js +992 -0
  77. package/lib/__tests__/network/client.test.js.map +1 -0
  78. package/lib/api/index.d.ts +4 -30
  79. package/lib/api/index.d.ts.map +1 -1
  80. package/lib/api/index.js +19 -170
  81. package/lib/api/index.js.map +1 -1
  82. package/lib/bridge/bridge.fixture.d.ts +2 -0
  83. package/lib/bridge/bridge.fixture.d.ts.map +1 -1
  84. package/lib/bridge/bridge.fixture.js +85 -13
  85. package/lib/bridge/bridge.fixture.js.map +1 -1
  86. package/lib/bridge/broadcast.d.ts +3 -2
  87. package/lib/bridge/broadcast.d.ts.map +1 -1
  88. package/lib/bridge/broadcast.js +4 -3
  89. package/lib/bridge/broadcast.js.map +1 -1
  90. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
  91. package/lib/bridge/estimateMaxSpendable.js +6 -5
  92. package/lib/bridge/estimateMaxSpendable.js.map +1 -1
  93. package/lib/bridge/getFeesForTransaction.d.ts +1 -1
  94. package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
  95. package/lib/bridge/getFeesForTransaction.js +20 -14
  96. package/lib/bridge/getFeesForTransaction.js.map +1 -1
  97. package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
  98. package/lib/bridge/getTransactionStatus.js +28 -14
  99. package/lib/bridge/getTransactionStatus.js.map +1 -1
  100. package/lib/bridge/index.d.ts +1 -1
  101. package/lib/bridge/index.d.ts.map +1 -1
  102. package/lib/bridge/index.js +1 -1
  103. package/lib/bridge/index.js.map +1 -1
  104. package/lib/bridge/logic.d.ts +5 -19
  105. package/lib/bridge/logic.d.ts.map +1 -1
  106. package/lib/bridge/logic.js +50 -147
  107. package/lib/bridge/logic.js.map +1 -1
  108. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  109. package/lib/bridge/prepareTransaction.js +5 -4
  110. package/lib/bridge/prepareTransaction.js.map +1 -1
  111. package/lib/bridge/signOperation.d.ts.map +1 -1
  112. package/lib/bridge/signOperation.js +21 -7
  113. package/lib/bridge/signOperation.js.map +1 -1
  114. package/lib/bridge/synchronisation.d.ts +15 -0
  115. package/lib/bridge/synchronisation.d.ts.map +1 -1
  116. package/lib/bridge/synchronisation.js +129 -6
  117. package/lib/bridge/synchronisation.js.map +1 -1
  118. package/lib/config.d.ts +13 -0
  119. package/lib/config.d.ts.map +1 -0
  120. package/lib/config.js +9 -0
  121. package/lib/config.js.map +1 -0
  122. package/lib/constants.d.ts +10 -2
  123. package/lib/constants.d.ts.map +1 -1
  124. package/lib/constants.js +13 -2
  125. package/lib/constants.js.map +1 -1
  126. package/lib/{bridge → logic}/buildTransaction.d.ts +1 -1
  127. package/lib/logic/buildTransaction.d.ts.map +1 -0
  128. package/lib/logic/buildTransaction.js +45 -0
  129. package/lib/logic/buildTransaction.js.map +1 -0
  130. package/lib/logic/calculateAmount.d.ts +3 -0
  131. package/lib/logic/calculateAmount.d.ts.map +1 -0
  132. package/lib/logic/calculateAmount.js +13 -0
  133. package/lib/logic/calculateAmount.js.map +1 -0
  134. package/lib/logic/combine.d.ts +4 -0
  135. package/lib/logic/combine.d.ts.map +1 -0
  136. package/lib/logic/combine.js +34 -0
  137. package/lib/logic/combine.js.map +1 -0
  138. package/lib/logic/craftTransaction.d.ts +5 -0
  139. package/lib/logic/craftTransaction.d.ts.map +1 -0
  140. package/lib/logic/craftTransaction.js +23 -0
  141. package/lib/logic/craftTransaction.js.map +1 -0
  142. package/lib/logic/createTransaction.d.ts.map +1 -0
  143. package/lib/{bridge → logic}/createTransaction.js +3 -3
  144. package/lib/logic/createTransaction.js.map +1 -0
  145. package/lib/logic/getBalance.d.ts +5 -0
  146. package/lib/logic/getBalance.d.ts.map +1 -0
  147. package/lib/logic/getBalance.js +12 -0
  148. package/lib/logic/getBalance.js.map +1 -0
  149. package/lib/logic/getCoinAndAmounts.d.ts +13 -0
  150. package/lib/logic/getCoinAndAmounts.d.ts.map +1 -0
  151. package/lib/logic/getCoinAndAmounts.js +112 -0
  152. package/lib/logic/getCoinAndAmounts.js.map +1 -0
  153. package/lib/logic/getFunctionAddress.d.ts +3 -0
  154. package/lib/logic/getFunctionAddress.d.ts.map +1 -0
  155. package/lib/logic/getFunctionAddress.js +12 -0
  156. package/lib/logic/getFunctionAddress.js.map +1 -0
  157. package/lib/logic/getResourceAddress.d.ts +4 -0
  158. package/lib/logic/getResourceAddress.d.ts.map +1 -0
  159. package/lib/logic/getResourceAddress.js +17 -0
  160. package/lib/logic/getResourceAddress.js.map +1 -0
  161. package/lib/logic/isTestnet.d.ts +2 -0
  162. package/lib/logic/isTestnet.d.ts.map +1 -0
  163. package/lib/logic/isTestnet.js +9 -0
  164. package/lib/logic/isTestnet.js.map +1 -0
  165. package/lib/logic/isWriteSetChangeWriteResource.d.ts +3 -0
  166. package/lib/logic/isWriteSetChangeWriteResource.d.ts.map +1 -0
  167. package/lib/logic/isWriteSetChangeWriteResource.js +8 -0
  168. package/lib/logic/isWriteSetChangeWriteResource.js.map +1 -0
  169. package/lib/logic/normalizeTransactionOptions.d.ts +3 -0
  170. package/lib/logic/normalizeTransactionOptions.d.ts.map +1 -0
  171. package/lib/logic/normalizeTransactionOptions.js +21 -0
  172. package/lib/logic/normalizeTransactionOptions.js.map +1 -0
  173. package/lib/logic/processRecipients.d.ts +6 -0
  174. package/lib/logic/processRecipients.d.ts.map +1 -0
  175. package/lib/logic/processRecipients.js +57 -0
  176. package/lib/logic/processRecipients.js.map +1 -0
  177. package/lib/logic/transactionsToOperations.d.ts +7 -0
  178. package/lib/logic/transactionsToOperations.d.ts.map +1 -0
  179. package/lib/logic/transactionsToOperations.js +85 -0
  180. package/lib/logic/transactionsToOperations.js.map +1 -0
  181. package/lib/network/client.d.ts +38 -0
  182. package/lib/network/client.d.ts.map +1 -0
  183. package/lib/network/client.js +266 -0
  184. package/lib/network/client.js.map +1 -0
  185. package/lib/network/graphql/queries.d.ts.map +1 -0
  186. package/lib/{api → network}/graphql/queries.js +6 -6
  187. package/lib/network/graphql/queries.js.map +1 -0
  188. package/lib/{api → network}/graphql/types.d.ts +9 -9
  189. package/lib/network/graphql/types.d.ts.map +1 -0
  190. package/lib/{api → network}/graphql/types.js.map +1 -1
  191. package/lib/network/index.d.ts +2 -1
  192. package/lib/network/index.d.ts.map +1 -1
  193. package/lib/network/index.js +19 -7
  194. package/lib/network/index.js.map +1 -1
  195. package/lib/test/bot-specs.d.ts.map +1 -1
  196. package/lib/test/bot-specs.js +40 -1
  197. package/lib/test/bot-specs.js.map +1 -1
  198. package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
  199. package/lib/test/bridgeDatasetTest.js +44 -62
  200. package/lib/test/bridgeDatasetTest.js.map +1 -1
  201. package/lib/test/speculos-deviceActions.d.ts +1 -0
  202. package/lib/test/speculos-deviceActions.d.ts.map +1 -1
  203. package/lib/test/speculos-deviceActions.js +37 -5
  204. package/lib/test/speculos-deviceActions.js.map +1 -1
  205. package/lib/types/assets.d.ts +12 -0
  206. package/lib/types/assets.d.ts.map +1 -0
  207. package/lib/types/assets.js +3 -0
  208. package/lib/types/assets.js.map +1 -0
  209. package/lib/types/index.d.ts +22 -7
  210. package/lib/types/index.d.ts.map +1 -1
  211. package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts +2 -0
  212. package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts.map +1 -0
  213. package/lib-es/__tests__/api/craftTransaction.unit.test.js +48 -0
  214. package/lib-es/__tests__/api/craftTransaction.unit.test.js.map +1 -0
  215. package/lib-es/__tests__/api/getBalance.unit.test.d.ts +2 -0
  216. package/lib-es/__tests__/api/getBalance.unit.test.d.ts.map +1 -0
  217. package/lib-es/__tests__/api/getBalance.unit.test.js +36 -0
  218. package/lib-es/__tests__/api/getBalance.unit.test.js.map +1 -0
  219. package/lib-es/__tests__/api/index.integ.test.d.ts +2 -0
  220. package/lib-es/__tests__/api/index.integ.test.d.ts.map +1 -0
  221. package/lib-es/__tests__/api/index.integ.test.js +113 -0
  222. package/lib-es/__tests__/api/index.integ.test.js.map +1 -0
  223. package/lib-es/__tests__/api/index.test.js +52 -408
  224. package/lib-es/__tests__/api/index.test.js.map +1 -1
  225. package/lib-es/__tests__/bridge/broadcast.test.js +2 -2
  226. package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -1
  227. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +112 -11
  228. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
  229. package/lib-es/__tests__/bridge/getTransactionStatus.test.js +177 -39
  230. package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
  231. package/lib-es/__tests__/bridge/logic.test.js +702 -478
  232. package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
  233. package/lib-es/__tests__/bridge/prepareTransaction.test.js +2 -2
  234. package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -1
  235. package/lib-es/__tests__/bridge/signOperation.test.js +137 -14
  236. package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -1
  237. package/lib-es/__tests__/bridge/synchronisation.test.js +1213 -69
  238. package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
  239. package/lib-es/__tests__/index.test.js +1 -1
  240. package/lib-es/__tests__/index.test.js.map +1 -1
  241. package/lib-es/__tests__/logic/buildTransaction.test.d.ts.map +1 -0
  242. package/lib-es/__tests__/logic/buildTransaction.test.js +107 -0
  243. package/lib-es/__tests__/logic/buildTransaction.test.js.map +1 -0
  244. package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts +2 -0
  245. package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts.map +1 -0
  246. package/lib-es/__tests__/logic/calculateAmount.unit.test.js +40 -0
  247. package/lib-es/__tests__/logic/calculateAmount.unit.test.js.map +1 -0
  248. package/lib-es/__tests__/logic/combine.unit.test.d.ts +2 -0
  249. package/lib-es/__tests__/logic/combine.unit.test.d.ts.map +1 -0
  250. package/lib-es/__tests__/logic/combine.unit.test.js +45 -0
  251. package/lib-es/__tests__/logic/combine.unit.test.js.map +1 -0
  252. package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts +2 -0
  253. package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts.map +1 -0
  254. package/lib-es/__tests__/logic/compareAddress.unit.test.js +24 -0
  255. package/lib-es/__tests__/logic/compareAddress.unit.test.js.map +1 -0
  256. package/lib-es/__tests__/logic/createTransaction.test.d.ts.map +1 -0
  257. package/lib-es/__tests__/{bridge → logic}/createTransaction.test.js +2 -2
  258. package/lib-es/__tests__/logic/createTransaction.test.js.map +1 -0
  259. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts +2 -0
  260. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts.map +1 -0
  261. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js +181 -0
  262. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js.map +1 -0
  263. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts +2 -0
  264. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts.map +1 -0
  265. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js +27 -0
  266. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js.map +1 -0
  267. package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts +2 -0
  268. package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts.map +1 -0
  269. package/lib-es/__tests__/logic/getResourceAddress.unit.test.js +216 -0
  270. package/lib-es/__tests__/logic/getResourceAddress.unit.test.js.map +1 -0
  271. package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts +2 -0
  272. package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts.map +1 -0
  273. package/lib-es/__tests__/logic/isTestnet.unit.test.js +10 -0
  274. package/lib-es/__tests__/logic/isTestnet.unit.test.js.map +1 -0
  275. package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
  276. package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
  277. package/lib-es/__tests__/logic/processRecipients.unit.test.js +74 -0
  278. package/lib-es/__tests__/logic/processRecipients.unit.test.js.map +1 -0
  279. package/lib-es/__tests__/network/client.test.d.ts +2 -0
  280. package/lib-es/__tests__/network/client.test.d.ts.map +1 -0
  281. package/lib-es/__tests__/network/client.test.js +987 -0
  282. package/lib-es/__tests__/network/client.test.js.map +1 -0
  283. package/lib-es/api/index.d.ts +4 -30
  284. package/lib-es/api/index.d.ts.map +1 -1
  285. package/lib-es/api/index.js +17 -168
  286. package/lib-es/api/index.js.map +1 -1
  287. package/lib-es/bridge/bridge.fixture.d.ts +2 -0
  288. package/lib-es/bridge/bridge.fixture.d.ts.map +1 -1
  289. package/lib-es/bridge/bridge.fixture.js +82 -12
  290. package/lib-es/bridge/bridge.fixture.js.map +1 -1
  291. package/lib-es/bridge/broadcast.d.ts +3 -2
  292. package/lib-es/bridge/broadcast.d.ts.map +1 -1
  293. package/lib-es/bridge/broadcast.js +4 -3
  294. package/lib-es/bridge/broadcast.js.map +1 -1
  295. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
  296. package/lib-es/bridge/estimateMaxSpendable.js +4 -3
  297. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
  298. package/lib-es/bridge/getFeesForTransaction.d.ts +1 -1
  299. package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
  300. package/lib-es/bridge/getFeesForTransaction.js +15 -9
  301. package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
  302. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
  303. package/lib-es/bridge/getTransactionStatus.js +28 -14
  304. package/lib-es/bridge/getTransactionStatus.js.map +1 -1
  305. package/lib-es/bridge/index.d.ts +1 -1
  306. package/lib-es/bridge/index.d.ts.map +1 -1
  307. package/lib-es/bridge/index.js +1 -1
  308. package/lib-es/bridge/index.js.map +1 -1
  309. package/lib-es/bridge/logic.d.ts +5 -19
  310. package/lib-es/bridge/logic.d.ts.map +1 -1
  311. package/lib-es/bridge/logic.js +44 -134
  312. package/lib-es/bridge/logic.js.map +1 -1
  313. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  314. package/lib-es/bridge/prepareTransaction.js +5 -4
  315. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  316. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  317. package/lib-es/bridge/signOperation.js +19 -5
  318. package/lib-es/bridge/signOperation.js.map +1 -1
  319. package/lib-es/bridge/synchronisation.d.ts +15 -0
  320. package/lib-es/bridge/synchronisation.d.ts.map +1 -1
  321. package/lib-es/bridge/synchronisation.js +124 -4
  322. package/lib-es/bridge/synchronisation.js.map +1 -1
  323. package/lib-es/config.d.ts +13 -0
  324. package/lib-es/config.d.ts.map +1 -0
  325. package/lib-es/config.js +4 -0
  326. package/lib-es/config.js.map +1 -0
  327. package/lib-es/constants.d.ts +10 -2
  328. package/lib-es/constants.d.ts.map +1 -1
  329. package/lib-es/constants.js +9 -1
  330. package/lib-es/constants.js.map +1 -1
  331. package/lib-es/{bridge → logic}/buildTransaction.d.ts +1 -1
  332. package/lib-es/logic/buildTransaction.d.ts.map +1 -0
  333. package/lib-es/logic/buildTransaction.js +43 -0
  334. package/lib-es/logic/buildTransaction.js.map +1 -0
  335. package/lib-es/logic/calculateAmount.d.ts +3 -0
  336. package/lib-es/logic/calculateAmount.d.ts.map +1 -0
  337. package/lib-es/logic/calculateAmount.js +9 -0
  338. package/lib-es/logic/calculateAmount.js.map +1 -0
  339. package/lib-es/logic/combine.d.ts +4 -0
  340. package/lib-es/logic/combine.d.ts.map +1 -0
  341. package/lib-es/logic/combine.js +29 -0
  342. package/lib-es/logic/combine.js.map +1 -0
  343. package/lib-es/logic/craftTransaction.d.ts +5 -0
  344. package/lib-es/logic/craftTransaction.d.ts.map +1 -0
  345. package/lib-es/logic/craftTransaction.js +16 -0
  346. package/lib-es/logic/craftTransaction.js.map +1 -0
  347. package/lib-es/logic/createTransaction.d.ts.map +1 -0
  348. package/lib-es/{bridge → logic}/createTransaction.js +1 -1
  349. package/lib-es/logic/createTransaction.js.map +1 -0
  350. package/lib-es/logic/getBalance.d.ts +5 -0
  351. package/lib-es/logic/getBalance.d.ts.map +1 -0
  352. package/lib-es/logic/getBalance.js +8 -0
  353. package/lib-es/logic/getBalance.js.map +1 -0
  354. package/lib-es/logic/getCoinAndAmounts.d.ts +13 -0
  355. package/lib-es/logic/getCoinAndAmounts.d.ts.map +1 -0
  356. package/lib-es/logic/getCoinAndAmounts.js +101 -0
  357. package/lib-es/logic/getCoinAndAmounts.js.map +1 -0
  358. package/lib-es/logic/getFunctionAddress.d.ts +3 -0
  359. package/lib-es/logic/getFunctionAddress.d.ts.map +1 -0
  360. package/lib-es/logic/getFunctionAddress.js +8 -0
  361. package/lib-es/logic/getFunctionAddress.js.map +1 -0
  362. package/lib-es/logic/getResourceAddress.d.ts +4 -0
  363. package/lib-es/logic/getResourceAddress.d.ts.map +1 -0
  364. package/lib-es/logic/getResourceAddress.js +13 -0
  365. package/lib-es/logic/getResourceAddress.js.map +1 -0
  366. package/lib-es/logic/isTestnet.d.ts +2 -0
  367. package/lib-es/logic/isTestnet.d.ts.map +1 -0
  368. package/lib-es/logic/isTestnet.js +5 -0
  369. package/lib-es/logic/isTestnet.js.map +1 -0
  370. package/lib-es/logic/isWriteSetChangeWriteResource.d.ts +3 -0
  371. package/lib-es/logic/isWriteSetChangeWriteResource.d.ts.map +1 -0
  372. package/lib-es/logic/isWriteSetChangeWriteResource.js +4 -0
  373. package/lib-es/logic/isWriteSetChangeWriteResource.js.map +1 -0
  374. package/lib-es/logic/normalizeTransactionOptions.d.ts +3 -0
  375. package/lib-es/logic/normalizeTransactionOptions.d.ts.map +1 -0
  376. package/lib-es/logic/normalizeTransactionOptions.js +17 -0
  377. package/lib-es/logic/normalizeTransactionOptions.js.map +1 -0
  378. package/lib-es/logic/processRecipients.d.ts +6 -0
  379. package/lib-es/logic/processRecipients.d.ts.map +1 -0
  380. package/lib-es/logic/processRecipients.js +53 -0
  381. package/lib-es/logic/processRecipients.js.map +1 -0
  382. package/lib-es/logic/transactionsToOperations.d.ts +7 -0
  383. package/lib-es/logic/transactionsToOperations.d.ts.map +1 -0
  384. package/lib-es/logic/transactionsToOperations.js +77 -0
  385. package/lib-es/logic/transactionsToOperations.js.map +1 -0
  386. package/lib-es/network/client.d.ts +38 -0
  387. package/lib-es/network/client.d.ts.map +1 -0
  388. package/lib-es/network/client.js +259 -0
  389. package/lib-es/network/client.js.map +1 -0
  390. package/lib-es/network/graphql/queries.d.ts.map +1 -0
  391. package/lib-es/{api → network}/graphql/queries.js +6 -6
  392. package/lib-es/network/graphql/queries.js.map +1 -0
  393. package/lib-es/{api → network}/graphql/types.d.ts +9 -9
  394. package/lib-es/network/graphql/types.d.ts.map +1 -0
  395. package/lib-es/{api → network}/graphql/types.js.map +1 -1
  396. package/lib-es/network/index.d.ts +2 -1
  397. package/lib-es/network/index.d.ts.map +1 -1
  398. package/lib-es/network/index.js +6 -8
  399. package/lib-es/network/index.js.map +1 -1
  400. package/lib-es/test/bot-specs.d.ts.map +1 -1
  401. package/lib-es/test/bot-specs.js +41 -2
  402. package/lib-es/test/bot-specs.js.map +1 -1
  403. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
  404. package/lib-es/test/bridgeDatasetTest.js +44 -59
  405. package/lib-es/test/bridgeDatasetTest.js.map +1 -1
  406. package/lib-es/test/speculos-deviceActions.d.ts +1 -0
  407. package/lib-es/test/speculos-deviceActions.d.ts.map +1 -1
  408. package/lib-es/test/speculos-deviceActions.js +36 -4
  409. package/lib-es/test/speculos-deviceActions.js.map +1 -1
  410. package/lib-es/types/assets.d.ts +12 -0
  411. package/lib-es/types/assets.d.ts.map +1 -0
  412. package/lib-es/types/assets.js +2 -0
  413. package/lib-es/types/assets.js.map +1 -0
  414. package/lib-es/types/index.d.ts +22 -7
  415. package/lib-es/types/index.d.ts.map +1 -1
  416. package/package.json +9 -7
  417. package/src/__tests__/api/craftTransaction.unit.test.ts +70 -0
  418. package/src/__tests__/api/getBalance.unit.test.ts +44 -0
  419. package/src/__tests__/api/index.integ.test.ts +139 -0
  420. package/src/__tests__/api/index.test.ts +60 -477
  421. package/src/__tests__/bridge/broadcast.test.ts +2 -2
  422. package/src/__tests__/bridge/getFeesForTransaction.test.ts +146 -11
  423. package/src/__tests__/bridge/getTransactionStatus.test.ts +217 -38
  424. package/src/__tests__/bridge/logic.test.ts +727 -568
  425. package/src/__tests__/bridge/prepareTransaction.test.ts +2 -2
  426. package/src/__tests__/bridge/signOperation.test.ts +153 -15
  427. package/src/__tests__/bridge/synchronisation.test.ts +1265 -71
  428. package/src/__tests__/index.test.ts +1 -1
  429. package/src/__tests__/logic/buildTransaction.test.ts +148 -0
  430. package/src/__tests__/logic/calculateAmount.unit.test.ts +51 -0
  431. package/src/__tests__/logic/combine.unit.test.ts +65 -0
  432. package/src/__tests__/logic/compareAddress.unit.test.ts +27 -0
  433. package/src/__tests__/{bridge → logic}/createTransaction.test.ts +2 -2
  434. package/src/__tests__/logic/getCoinAndAmounts.unit.test.ts +195 -0
  435. package/src/__tests__/logic/getFunctionAddress.unit.test.ts +33 -0
  436. package/src/__tests__/logic/getResourceAddress.unit.test.ts +241 -0
  437. package/src/__tests__/logic/isTestnet.unit.test.ts +11 -0
  438. package/src/__tests__/logic/processRecipients.unit.test.ts +87 -0
  439. package/src/__tests__/network/client.test.ts +1107 -0
  440. package/src/api/index.ts +29 -224
  441. package/src/bridge/bridge.fixture.ts +91 -12
  442. package/src/bridge/broadcast.ts +7 -7
  443. package/src/bridge/estimateMaxSpendable.ts +4 -3
  444. package/src/bridge/getFeesForTransaction.ts +17 -11
  445. package/src/bridge/getTransactionStatus.ts +35 -13
  446. package/src/bridge/index.ts +2 -2
  447. package/src/bridge/logic.ts +58 -194
  448. package/src/bridge/prepareTransaction.ts +7 -4
  449. package/src/bridge/signOperation.ts +21 -5
  450. package/src/bridge/synchronisation.ts +171 -4
  451. package/src/config.ts +19 -0
  452. package/src/constants.ts +18 -2
  453. package/src/logic/buildTransaction.ts +62 -0
  454. package/src/logic/calculateAmount.ts +15 -0
  455. package/src/logic/combine.ts +51 -0
  456. package/src/logic/craftTransaction.ts +26 -0
  457. package/src/{bridge → logic}/createTransaction.ts +1 -1
  458. package/src/logic/getBalance.ts +15 -0
  459. package/src/logic/getCoinAndAmounts.ts +141 -0
  460. package/src/logic/getFunctionAddress.ts +9 -0
  461. package/src/logic/getResourceAddress.ts +24 -0
  462. package/src/logic/isTestnet.ts +5 -0
  463. package/src/logic/isWriteSetChangeWriteResource.ts +7 -0
  464. package/src/logic/normalizeTransactionOptions.ts +18 -0
  465. package/src/logic/processRecipients.ts +87 -0
  466. package/src/logic/transactionsToOperations.ts +105 -0
  467. package/src/network/client.ts +351 -0
  468. package/src/{api → network}/graphql/queries.ts +6 -6
  469. package/src/{api → network}/graphql/types.ts +9 -9
  470. package/src/network/index.ts +6 -14
  471. package/src/test/bot-specs.ts +63 -3
  472. package/src/test/bridgeDatasetTest.ts +46 -59
  473. package/src/test/speculos-deviceActions.ts +40 -4
  474. package/src/types/assets.ts +15 -0
  475. package/src/types/index.ts +20 -1
  476. package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
  477. package/lib/__tests__/bridge/buildTransaction.test.js +0 -53
  478. package/lib/__tests__/bridge/buildTransaction.test.js.map +0 -1
  479. package/lib/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
  480. package/lib/__tests__/bridge/createTransaction.test.js.map +0 -1
  481. package/lib/api/graphql/queries.d.ts.map +0 -1
  482. package/lib/api/graphql/queries.js.map +0 -1
  483. package/lib/api/graphql/types.d.ts.map +0 -1
  484. package/lib/bridge/buildTransaction.d.ts.map +0 -1
  485. package/lib/bridge/buildTransaction.js +0 -19
  486. package/lib/bridge/buildTransaction.js.map +0 -1
  487. package/lib/bridge/createTransaction.d.ts.map +0 -1
  488. package/lib/bridge/createTransaction.js.map +0 -1
  489. package/lib-es/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
  490. package/lib-es/__tests__/bridge/buildTransaction.test.js +0 -48
  491. package/lib-es/__tests__/bridge/buildTransaction.test.js.map +0 -1
  492. package/lib-es/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
  493. package/lib-es/__tests__/bridge/createTransaction.test.js.map +0 -1
  494. package/lib-es/api/graphql/queries.d.ts.map +0 -1
  495. package/lib-es/api/graphql/queries.js.map +0 -1
  496. package/lib-es/api/graphql/types.d.ts.map +0 -1
  497. package/lib-es/bridge/buildTransaction.d.ts.map +0 -1
  498. package/lib-es/bridge/buildTransaction.js +0 -17
  499. package/lib-es/bridge/buildTransaction.js.map +0 -1
  500. package/lib-es/bridge/createTransaction.d.ts.map +0 -1
  501. package/lib-es/bridge/createTransaction.js.map +0 -1
  502. package/src/__tests__/bridge/buildTransaction.test.ts +0 -61
  503. package/src/bridge/buildTransaction.ts +0 -29
  504. /package/lib/__tests__/{bridge → logic}/buildTransaction.test.d.ts +0 -0
  505. /package/lib/__tests__/{bridge → logic}/createTransaction.test.d.ts +0 -0
  506. /package/lib/{bridge → logic}/createTransaction.d.ts +0 -0
  507. /package/lib/{api → network}/graphql/queries.d.ts +0 -0
  508. /package/lib/{api → network}/graphql/types.js +0 -0
  509. /package/lib-es/__tests__/{bridge → logic}/buildTransaction.test.d.ts +0 -0
  510. /package/lib-es/__tests__/{bridge → logic}/createTransaction.test.d.ts +0 -0
  511. /package/lib-es/{bridge → logic}/createTransaction.d.ts +0 -0
  512. /package/lib-es/{api → network}/graphql/queries.d.ts +0 -0
  513. /package/lib-es/{api → network}/graphql/types.js +0 -0
@@ -6,52 +6,54 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
7
7
  const constants_1 = require("../../constants");
8
8
  const logic_1 = require("../../bridge/logic");
9
- jest.mock("@ledgerhq/cryptoassets", () => ({
10
- getCryptoCurrencyById: jest.fn(),
11
- }));
9
+ const bridge_fixture_1 = require("../../bridge/bridge.fixture");
10
+ const cryptoassets_1 = require("@ledgerhq/cryptoassets");
11
+ const index_1 = require("@ledgerhq/coin-framework/account/index");
12
+ const normalizeTransactionOptions_1 = require("../../logic/normalizeTransactionOptions");
13
+ jest.mock("@ledgerhq/cryptoassets");
14
+ jest.mock("@ledgerhq/coin-framework/account/index");
12
15
  describe("Aptos logic ", () => {
13
- describe("isTestnet", () => {
14
- it("should return true for testnet currencies", () => {
15
- expect((0, logic_1.isTestnet)("aptos_testnet")).toBe(true);
16
- });
17
- it("should return false for mainnet currencies", () => {
18
- expect((0, logic_1.isTestnet)("aptos")).toBe(false);
19
- });
20
- });
21
16
  describe("getMaxSendBalance", () => {
22
17
  it("should return the correct max send balance when amount is greater than total gas", () => {
23
18
  const amount = new bignumber_js_1.default(1000000);
19
+ const account = (0, bridge_fixture_1.createFixtureAccount)({ balance: amount, spendableBalance: amount });
20
+ const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
24
21
  const gas = new bignumber_js_1.default(200);
25
22
  const gasPrice = new bignumber_js_1.default(100);
26
- const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
23
+ const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
27
24
  expect(result.isEqualTo(amount.minus(gas.multipliedBy(gasPrice)))).toBe(true);
28
25
  });
29
26
  it("should return zero when amount is less than total gas", () => {
30
- const amount = new bignumber_js_1.default(1000);
27
+ const account = (0, bridge_fixture_1.createFixtureAccount)();
28
+ const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
31
29
  const gas = new bignumber_js_1.default(200);
32
30
  const gasPrice = new bignumber_js_1.default(100);
33
- const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
31
+ const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
34
32
  expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
35
33
  });
36
34
  it("should return zero when amount is equal to total gas", () => {
37
- const amount = new bignumber_js_1.default(20000);
35
+ const account = (0, bridge_fixture_1.createFixtureAccount)();
36
+ const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
38
37
  const gas = new bignumber_js_1.default(200);
39
38
  const gasPrice = new bignumber_js_1.default(100);
40
- const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
39
+ const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
41
40
  expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
42
41
  });
43
42
  it("should handle zero amount", () => {
44
- const amount = new bignumber_js_1.default(0);
43
+ const account = (0, bridge_fixture_1.createFixtureAccount)();
44
+ const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
45
45
  const gas = new bignumber_js_1.default(200);
46
46
  const gasPrice = new bignumber_js_1.default(100);
47
- const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
47
+ const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
48
48
  expect(result.isEqualTo(new bignumber_js_1.default(0))).toBe(true);
49
49
  });
50
50
  it("should handle zero gas and gas price", () => {
51
51
  const amount = new bignumber_js_1.default(1000000);
52
+ const account = (0, bridge_fixture_1.createFixtureAccount)({ balance: amount, spendableBalance: amount });
53
+ const transaction = (0, bridge_fixture_1.createFixtureTransaction)();
52
54
  const gas = new bignumber_js_1.default(0);
53
55
  const gasPrice = new bignumber_js_1.default(0);
54
- const result = (0, logic_1.getMaxSendBalance)(amount, gas, gasPrice);
56
+ const result = (0, logic_1.getMaxSendBalance)(gas, gasPrice, account, transaction);
55
57
  expect(result.isEqualTo(amount)).toBe(true);
56
58
  });
57
59
  });
@@ -61,7 +63,7 @@ describe("Aptos logic ", () => {
61
63
  maxGasAmount: "1000",
62
64
  gasUnitPrice: "10",
63
65
  };
64
- const result = (0, logic_1.normalizeTransactionOptions)(options);
66
+ const result = (0, normalizeTransactionOptions_1.normalizeTransactionOptions)(options);
65
67
  expect(result).toEqual(options);
66
68
  });
67
69
  it("should return undefined for empty values", () => {
@@ -69,7 +71,7 @@ describe("Aptos logic ", () => {
69
71
  maxGasAmount: "",
70
72
  gasUnitPrice: "",
71
73
  };
72
- const result = (0, logic_1.normalizeTransactionOptions)(options);
74
+ const result = (0, normalizeTransactionOptions_1.normalizeTransactionOptions)(options);
73
75
  expect(result).toEqual({
74
76
  maxGasAmount: undefined,
75
77
  gasUnitPrice: undefined,
@@ -85,7 +87,7 @@ describe("Aptos logic ", () => {
85
87
  sequence_number: "1",
86
88
  version: "1",
87
89
  };
88
- const id = "test-id";
90
+ const id = "test_id";
89
91
  const result = (0, logic_1.getBlankOperation)(tx, id);
90
92
  expect(result).toEqual({
91
93
  id: "",
@@ -110,7 +112,7 @@ describe("Aptos logic ", () => {
110
112
  timestamp: "1000000",
111
113
  sequence_number: "1",
112
114
  };
113
- const id = "test-id";
115
+ const id = "test_id";
114
116
  const result = (0, logic_1.getBlankOperation)(tx, id);
115
117
  expect(result).toEqual({
116
118
  id: "",
@@ -132,431 +134,10 @@ describe("Aptos logic ", () => {
132
134
  });
133
135
  });
134
136
  describe("Aptos sync logic ", () => {
135
- describe("compareAddress", () => {
136
- it("should return true for identical addresses", () => {
137
- const addressA = "0x1234567890abcdef";
138
- const addressB = "0x1234567890abcdef";
139
- expect((0, logic_1.compareAddress)(addressA, addressB)).toBe(true);
140
- });
141
- it("should return true for addresses with different cases", () => {
142
- const addressA = "0x1234567890abcdef";
143
- const addressB = "0x1234567890ABCDEF";
144
- expect((0, logic_1.compareAddress)(addressA, addressB)).toBe(true);
145
- });
146
- it("should return true for addresses with different hex formats", () => {
147
- const addressA = "0x1234567890abcdef";
148
- const addressB = "1234567890abcdef";
149
- expect((0, logic_1.compareAddress)(addressA, addressB)).toBe(true);
150
- });
151
- it("should return false for different addresses", () => {
152
- const addressA = "0x1234567890abcdef";
153
- const addressB = "0xfedcba0987654321";
154
- expect((0, logic_1.compareAddress)(addressA, addressB)).toBe(false);
155
- });
156
- });
157
- describe("getFunctionAddress", () => {
158
- it("should return the function address when payload contains a function", () => {
159
- const payload = {
160
- function: "0x1::coin::transfer",
161
- typeArguments: [],
162
- functionArguments: [],
163
- };
164
- const result = (0, logic_1.getFunctionAddress)(payload);
165
- expect(result).toBe("0x1");
166
- });
167
- it("should return undefined when payload does not contain a function", () => {
168
- const payload = {
169
- function: "::::",
170
- typeArguments: [],
171
- functionArguments: [],
172
- };
173
- const result = (0, logic_1.getFunctionAddress)(payload);
174
- expect(result).toBeUndefined();
175
- });
176
- it("should return undefined when payload is empty", () => {
177
- const payload = {};
178
- const result = (0, logic_1.getFunctionAddress)(payload);
179
- expect(result).toBeUndefined();
180
- });
181
- });
182
- describe("processRecipients", () => {
183
- let op;
184
- beforeEach(() => {
185
- op = {
186
- id: "",
187
- hash: "",
188
- type: "",
189
- value: new bignumber_js_1.default(0),
190
- fee: new bignumber_js_1.default(0),
191
- blockHash: "",
192
- blockHeight: 0,
193
- senders: [],
194
- recipients: [],
195
- accountId: "",
196
- date: new Date(),
197
- extra: {},
198
- transactionSequenceNumber: 0,
199
- hasFailed: false,
200
- };
201
- });
202
- it("should add recipient for transfer-like functions from LL account", () => {
203
- const payload = {
204
- function: "0x1::coin::transfer",
205
- typeArguments: [],
206
- functionArguments: ["0x13", 1], // from: &signer, to: address, amount: u64
207
- };
208
- (0, logic_1.processRecipients)(payload, "0x13", op, "0x1");
209
- expect(op.recipients).toContain("0x13");
210
- });
211
- it("should add recipient for transfer-like functions from external account", () => {
212
- const payload = {
213
- function: "0x1::coin::transfer",
214
- typeArguments: [],
215
- functionArguments: ["0x12", 1], // from: &signer, to: address, amount: u64
216
- };
217
- (0, logic_1.processRecipients)(payload, "0x13", op, "0x1");
218
- expect(op.recipients).toContain("0x12");
219
- });
220
- it("should add recipients for batch transfer functions", () => {
221
- const payload = {
222
- function: "0x1::aptos_account::batch_transfer_coins",
223
- typeArguments: [constants_1.APTOS_ASSET_ID],
224
- functionArguments: [
225
- ["0x12", "0x13"],
226
- [1, 2],
227
- ],
228
- };
229
- op.senders.push("0x11");
230
- (0, logic_1.processRecipients)(payload, "0x12", op, "0x1");
231
- expect(op.recipients).toContain("0x12");
232
- });
233
- it("should add function address as recipient for other smart contracts", () => {
234
- const payload = {
235
- function: "0x2::other::contract",
236
- typeArguments: [],
237
- functionArguments: [["0x12"], [1]],
238
- };
239
- (0, logic_1.processRecipients)(payload, "0x11", op, "0x2");
240
- expect(op.recipients).toContain("0x2");
241
- });
242
- });
243
- describe("isChangeOfAptos", () => {
244
- it("should return true for a valid change of Aptos", () => {
245
- const change = {
246
- type: "write_resource",
247
- data: {
248
- type: constants_1.APTOS_COIN_CHANGE,
249
- data: {
250
- withdraw_events: {
251
- guid: {
252
- id: {
253
- addr: "0x11",
254
- creation_num: "2",
255
- },
256
- },
257
- },
258
- },
259
- },
260
- };
261
- const event = {
262
- guid: {
263
- account_address: "0x11",
264
- creation_number: "2",
265
- },
266
- type: "0x1::coin::WithdrawEvent",
267
- };
268
- const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
269
- expect(result).toBe(true);
270
- });
271
- it("should return false for an invalid change of Aptos", () => {
272
- const change = {
273
- type: "write_resource",
274
- data: {
275
- type: constants_1.APTOS_COIN_CHANGE,
276
- data: {
277
- withdraw_events: {
278
- guid: {
279
- id: {
280
- addr: "0x12",
281
- creation_num: "2",
282
- },
283
- },
284
- },
285
- },
286
- },
287
- };
288
- const event = {
289
- guid: {
290
- account_address: "0x11",
291
- creation_number: "1",
292
- },
293
- type: "0x1::coin::WithdrawEvent",
294
- };
295
- const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
296
- expect(result).toBe(false);
297
- });
298
- it("should return false for a change with a different WriteSet type", () => {
299
- const change = {
300
- type: "write_module",
301
- data: {},
302
- };
303
- const event = {
304
- guid: {
305
- account_address: "0x1",
306
- creation_number: "1",
307
- },
308
- type: "0x1::coin::WithdrawEvent",
309
- };
310
- const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
311
- expect(result).toBe(false);
312
- });
313
- it("should return false if no data in WriteSet Change", () => {
314
- const change = {
315
- type: "write_resource",
316
- };
317
- const event = {
318
- guid: {
319
- account_address: "0x11",
320
- creation_number: "2",
321
- },
322
- type: "0x1::coin::WithdrawEvent",
323
- };
324
- const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
325
- expect(result).toBe(false);
326
- });
327
- it("should return false if no type in change data", () => {
328
- const change = {
329
- type: "write_resource",
330
- data: {
331
- data: {
332
- withdraw_events: {
333
- guid: {
334
- id: {
335
- addr: "0x11",
336
- creation_num: "2",
337
- },
338
- },
339
- },
340
- },
341
- },
342
- };
343
- const event = {
344
- guid: {
345
- account_address: "0x11",
346
- creation_number: "2",
347
- },
348
- type: "0x1::coin::WithdrawEvent",
349
- };
350
- const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
351
- expect(result).toBe(false);
352
- });
353
- it("should return false for a change with a different WriteSet Change type", () => {
354
- const change = {
355
- type: "write_resource",
356
- data: {
357
- type: "0x1::coin::CoinStore<0x1::aptos_coin::ANY_OTHER_COIN>",
358
- data: {
359
- withdraw_events: {
360
- guid: {
361
- id: {
362
- addr: "0x11",
363
- creation_num: "2",
364
- },
365
- },
366
- },
367
- },
368
- },
369
- };
370
- const event = {
371
- guid: {
372
- account_address: "0x11",
373
- creation_number: "2",
374
- },
375
- type: "0x1::coin::WithdrawEvent",
376
- };
377
- const result = (0, logic_1.isChangeOfAptos)(change, event, "withdraw_events");
378
- expect(result).toBe(false);
379
- });
380
- });
381
- describe("getAptosAmounts", () => {
382
- it("should calculate the correct amounts for withdraw and deposit events", () => {
383
- const tx = {
384
- events: [
385
- {
386
- type: "0x1::coin::WithdrawEvent",
387
- guid: {
388
- account_address: "0x11",
389
- creation_number: "1",
390
- },
391
- data: {
392
- amount: "100",
393
- },
394
- },
395
- {
396
- type: "0x1::coin::DepositEvent",
397
- guid: {
398
- account_address: "0x11",
399
- creation_number: "2",
400
- },
401
- data: {
402
- amount: "50",
403
- },
404
- },
405
- ],
406
- changes: [
407
- {
408
- type: "write_resource",
409
- data: {
410
- type: constants_1.APTOS_COIN_CHANGE,
411
- data: {
412
- withdraw_events: {
413
- guid: {
414
- id: {
415
- addr: "0x11",
416
- creation_num: "1",
417
- },
418
- },
419
- },
420
- deposit_events: {
421
- guid: {
422
- id: {
423
- addr: "0x11",
424
- creation_num: "2",
425
- },
426
- },
427
- },
428
- },
429
- },
430
- },
431
- ],
432
- };
433
- const address = "0x11";
434
- const result = (0, logic_1.getAptosAmounts)(tx, address);
435
- expect(result.amount_in).toEqual(new bignumber_js_1.default(50));
436
- expect(result.amount_out).toEqual(new bignumber_js_1.default(100));
437
- });
438
- it("should return zero amounts if no matching events are found", () => {
439
- const tx = {
440
- events: [
441
- {
442
- type: "0x1::coin::WithdrawEvent",
443
- guid: {
444
- account_address: "0x11",
445
- creation_number: "1",
446
- },
447
- data: {
448
- amount: "100",
449
- },
450
- },
451
- {
452
- type: "0x1::coin::DepositEvent",
453
- guid: {
454
- account_address: "0x11",
455
- creation_number: "2",
456
- },
457
- data: {
458
- amount: "50",
459
- },
460
- },
461
- ],
462
- changes: [
463
- {
464
- type: "write_resource",
465
- data: {
466
- type: constants_1.APTOS_COIN_CHANGE,
467
- data: {
468
- withdraw_events: {
469
- guid: {
470
- id: {
471
- addr: "0x12", // should fail by address check
472
- creation_num: "1",
473
- },
474
- },
475
- },
476
- deposit_events: {
477
- guid: {
478
- id: {
479
- addr: "0x11",
480
- creation_num: "3", // should fail by number check
481
- },
482
- },
483
- },
484
- },
485
- },
486
- },
487
- ],
488
- };
489
- const address = "0x11";
490
- const result = (0, logic_1.getAptosAmounts)(tx, address);
491
- expect(result.amount_in).toEqual(new bignumber_js_1.default(0));
492
- expect(result.amount_out).toEqual(new bignumber_js_1.default(0));
493
- });
494
- it("should handle transactions with other events", () => {
495
- const tx = {
496
- events: [
497
- {
498
- type: "0x1::coin::OtherEvent",
499
- guid: {
500
- account_address: "0x11",
501
- creation_number: "1",
502
- },
503
- data: {
504
- amount: "100",
505
- },
506
- },
507
- ],
508
- };
509
- const address = "0x1";
510
- const result = (0, logic_1.getAptosAmounts)(tx, address);
511
- expect(result.amount_in).toEqual(new bignumber_js_1.default(0));
512
- expect(result.amount_out).toEqual(new bignumber_js_1.default(0));
513
- });
514
- });
515
- describe("calculateAmount", () => {
516
- it("should calculate the correct amount when the address is the sender", () => {
517
- const address = "0x11";
518
- const sender = "0x11";
519
- const fee = new bignumber_js_1.default(10); // account pays fees
520
- const amount_in = new bignumber_js_1.default(50);
521
- const amount_out = new bignumber_js_1.default(100);
522
- const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
523
- // LL negates the amount for SEND transactions during output
524
- expect(result).toEqual(new bignumber_js_1.default(60)); // -(50 - 100 - 10)
525
- });
526
- it("should calculate the correct amount when the address is not the sender", () => {
527
- const address = "0x11";
528
- const sender = "0x12";
529
- const fee = new bignumber_js_1.default(10); // sender pays fees
530
- const amount_in = new bignumber_js_1.default(100);
531
- const amount_out = new bignumber_js_1.default(50);
532
- const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
533
- expect(result).toEqual(new bignumber_js_1.default(50)); // 100 - 50
534
- });
535
- it("should handle transactions with zero amounts", () => {
536
- const address = "0x11";
537
- const sender = "0x11";
538
- const fee = new bignumber_js_1.default(10);
539
- const amount_in = new bignumber_js_1.default(0);
540
- const amount_out = new bignumber_js_1.default(0);
541
- const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
542
- // LL negates the amount for SEND transactions during output
543
- expect(result).toEqual(new bignumber_js_1.default(10)); // -(0 - 0 - 10)
544
- });
545
- it("should get negative numbers (for send tx with deposit to account)", () => {
546
- const address = "0x11";
547
- const sender = "0x11";
548
- const fee = new bignumber_js_1.default(10);
549
- const amount_in = new bignumber_js_1.default(100);
550
- const amount_out = new bignumber_js_1.default(0);
551
- const result = (0, logic_1.calculateAmount)(sender, address, fee, amount_in, amount_out);
552
- // LL negates the amount for SEND transactions during output
553
- expect(result).toEqual(new bignumber_js_1.default(90).negated()); // 100 - 10
554
- });
555
- });
556
137
  describe("txsToOps", () => {
557
- it("should convert transactions to operations correctly", () => {
138
+ it("should convert Aptos transactions to operations correctly", () => {
558
139
  const address = "0x11";
559
- const id = "test-id";
140
+ const id = "test_id";
560
141
  const txs = [
561
142
  {
562
143
  hash: "0x123",
@@ -623,13 +204,13 @@ describe("Aptos sync logic ", () => {
623
204
  sequence_number: "1",
624
205
  },
625
206
  ];
626
- const result = (0, logic_1.txsToOps)({ address }, id, txs);
207
+ const [result] = (0, logic_1.txsToOps)({ address }, id, txs);
627
208
  expect(result).toHaveLength(1);
628
209
  expect(result[0]).toEqual({
629
210
  id: expect.any(String),
630
211
  hash: "0x123",
631
212
  type: constants_1.DIRECTION.OUT,
632
- value: new bignumber_js_1.default(20100),
213
+ value: new bignumber_js_1.default(100),
633
214
  fee: new bignumber_js_1.default(20000),
634
215
  blockHash: "0xabc",
635
216
  blockHeight: 1,
@@ -644,7 +225,7 @@ describe("Aptos sync logic ", () => {
644
225
  });
645
226
  it("should skip transactions without functions in payload", () => {
646
227
  const address = "0x11";
647
- const id = "test-id";
228
+ const id = "test_id";
648
229
  const txs = [
649
230
  {
650
231
  hash: "0x123",
@@ -653,12 +234,6 @@ describe("Aptos sync logic ", () => {
653
234
  gas_unit_price: "100",
654
235
  success: true,
655
236
  payload: {},
656
- // payload: {
657
- // type: "entry_function_payload",
658
- // function: "0x1::coin::transfer",
659
- // type_arguments: [],
660
- // arguments: ["0x12", 100],
661
- // } as EntryFunctionPayloadResponse,
662
237
  events: [],
663
238
  changes: [],
664
239
  block: { hash: "0xabc", height: 1 },
@@ -666,12 +241,12 @@ describe("Aptos sync logic ", () => {
666
241
  sequence_number: "1",
667
242
  },
668
243
  ];
669
- const result = (0, logic_1.txsToOps)({ address }, id, txs);
244
+ const [result] = (0, logic_1.txsToOps)({ address }, id, txs);
670
245
  expect(result).toHaveLength(0);
671
246
  });
672
247
  it("should skip transactions that result in no Aptos change", () => {
673
248
  const address = "0x11";
674
- const id = "test-id";
249
+ const id = "test_id";
675
250
  const txs = [
676
251
  {
677
252
  hash: "0x123",
@@ -692,71 +267,704 @@ describe("Aptos sync logic ", () => {
692
267
  sequence_number: "1",
693
268
  },
694
269
  ];
695
- const result = (0, logic_1.txsToOps)({ address }, id, txs);
270
+ const [result] = (0, logic_1.txsToOps)({ address }, id, txs);
696
271
  expect(result).toHaveLength(0);
697
272
  });
698
273
  it("should handle failed transactions", () => {
699
- const address = "0x11";
700
- const id = "test-id";
274
+ const address = "0xa0d8";
275
+ const id = "test_id";
701
276
  const txs = [
702
277
  {
703
- hash: "0x123",
704
- sender: "0x11",
278
+ hash: "0x0189",
279
+ sender: "0xa0d8",
705
280
  gas_used: "200",
706
281
  gas_unit_price: "100",
707
282
  success: false,
708
283
  payload: {
709
- type: "entry_function_payload",
710
284
  function: "0x1::coin::transfer",
711
- type_arguments: [],
712
- arguments: ["0x12", 100],
285
+ type_arguments: ["0xd111::staked_coin::StakedAptos"],
286
+ arguments: ["0x4e5e", "50000000"],
287
+ type: "entry_function_payload",
713
288
  },
714
289
  events: [
715
290
  {
716
- type: "0x1::coin::WithdrawEvent",
717
291
  guid: {
718
- account_address: "0x11",
719
- creation_number: "1",
292
+ creation_number: "0",
293
+ account_address: "0x0",
720
294
  },
295
+ sequence_number: "0",
296
+ type: "0x1::transaction_fee::FeeStatement",
721
297
  data: {
722
- amount: "100",
298
+ execution_gas_units: "5",
299
+ io_gas_units: "4",
300
+ storage_fee_octas: "0",
301
+ storage_fee_refund_octas: "0",
302
+ total_charge_gas_units: "8",
303
+ },
304
+ },
305
+ ],
306
+ changes: [
307
+ {
308
+ address: "0xa0d8",
309
+ state_key_hash: "0x1709",
310
+ data: {
311
+ type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
312
+ data: {
313
+ coin: {
314
+ value: "573163341",
315
+ },
316
+ deposit_events: {
317
+ counter: "45",
318
+ guid: {
319
+ id: {
320
+ addr: "0xa0d8",
321
+ creation_num: "2",
322
+ },
323
+ },
324
+ },
325
+ frozen: false,
326
+ withdraw_events: {
327
+ counter: "82",
328
+ guid: {
329
+ id: {
330
+ addr: "0xa0d8",
331
+ creation_num: "3",
332
+ },
333
+ },
334
+ },
335
+ },
336
+ },
337
+ type: "write_resource",
338
+ },
339
+ {
340
+ address: "0xa0d8",
341
+ state_key_hash: "0x6f1e",
342
+ data: {
343
+ type: "0x1::account::Account",
344
+ data: {
345
+ authentication_key: "0xa0d8",
346
+ coin_register_events: {
347
+ counter: "5",
348
+ guid: {
349
+ id: {
350
+ addr: "0xa0d8",
351
+ creation_num: "0",
352
+ },
353
+ },
354
+ },
355
+ guid_creation_num: "12",
356
+ key_rotation_events: {
357
+ counter: "0",
358
+ guid: {
359
+ id: {
360
+ addr: "0xa0d8",
361
+ creation_num: "1",
362
+ },
363
+ },
364
+ },
365
+ rotation_capability_offer: {
366
+ for: {
367
+ vec: [],
368
+ },
369
+ },
370
+ sequence_number: "83",
371
+ signer_capability_offer: {
372
+ for: {
373
+ vec: [],
374
+ },
375
+ },
376
+ },
723
377
  },
378
+ type: "write_resource",
379
+ },
380
+ {
381
+ state_key_hash: "0x6e4b",
382
+ handle: "0x1b85",
383
+ key: "0x0619",
384
+ value: "0x72c5e483c25c96010000000000000000",
385
+ data: null,
386
+ type: "write_table_item",
387
+ },
388
+ ],
389
+ block: {
390
+ hash: "0xc496",
391
+ height: 1,
392
+ },
393
+ timestamp: "1000000",
394
+ sequence_number: "1",
395
+ },
396
+ ];
397
+ const [result] = (0, logic_1.txsToOps)({ address }, id, txs);
398
+ expect(result).toHaveLength(1);
399
+ expect(result[0]).toEqual({
400
+ id: expect.any(String),
401
+ hash: "0x0189",
402
+ type: constants_1.DIRECTION.OUT,
403
+ value: new bignumber_js_1.default(20000),
404
+ fee: new bignumber_js_1.default(20000),
405
+ blockHash: "0xc496",
406
+ blockHeight: 1,
407
+ senders: ["0xa0d8"],
408
+ recipients: ["0x4e5e"],
409
+ accountId: id,
410
+ date: new Date(1000),
411
+ extra: { version: undefined },
412
+ transactionSequenceNumber: 1,
413
+ hasFailed: true,
414
+ });
415
+ });
416
+ it("should convert Aptos token transactions to operations correctly", () => {
417
+ cryptoassets_1.findTokenByAddressInCurrency.mockReturnValue({
418
+ type: "TokenCurrency",
419
+ id: "aptos/coin/dstapt::staked_coin::stakedaptos",
420
+ contractAddress: "0xd111::staked_coin::StakedAptos",
421
+ parentCurrency: {
422
+ type: "CryptoCurrency",
423
+ id: "aptos",
424
+ coinType: 637,
425
+ name: "Aptos",
426
+ managerAppName: "Aptos",
427
+ ticker: "APT",
428
+ scheme: "aptos",
429
+ color: "#231F20",
430
+ family: "aptos",
431
+ units: [
432
+ {
433
+ name: "APT",
434
+ code: "APT",
435
+ magnitude: 8,
436
+ },
437
+ ],
438
+ explorerViews: [
439
+ {
440
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
441
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
724
442
  },
443
+ ],
444
+ },
445
+ name: "dstAPT",
446
+ tokenType: "coin",
447
+ ticker: "dstAPT",
448
+ disableCountervalue: false,
449
+ delisted: false,
450
+ units: [
451
+ {
452
+ name: "dstAPT",
453
+ code: "dstAPT",
454
+ magnitude: 8,
455
+ },
456
+ ],
457
+ });
458
+ jest.mock("../../bridge/logic", () => ({
459
+ ...jest.requireActual("../../bridge/logic"),
460
+ getResourceAddress: jest.fn().mockReturnValue("0xd111::staked_coin::StakedAptos"),
461
+ }));
462
+ index_1.decodeTokenAccountId.mockReturnValue({
463
+ accountId: "token_account_id",
464
+ });
465
+ const address = "0xa0d";
466
+ const id = "test_id";
467
+ const txs = [
468
+ {
469
+ hash: "0x123",
470
+ sender: address,
471
+ gas_used: "200",
472
+ gas_unit_price: "100",
473
+ success: true,
474
+ payload: {
475
+ function: "0x1::aptos_account::transfer_coins",
476
+ type_arguments: ["0xd111::staked_coin::StakedAptos"],
477
+ arguments: ["0x4e5", "1500000"],
478
+ type: "entry_function_payload",
479
+ },
480
+ events: [
725
481
  {
482
+ guid: {
483
+ creation_number: "11",
484
+ account_address: "0xa0d",
485
+ },
486
+ sequence_number: "12",
487
+ type: "0x1::coin::WithdrawEvent",
488
+ data: {
489
+ amount: "1500000",
490
+ },
491
+ },
492
+ {
493
+ guid: {
494
+ creation_number: "4",
495
+ account_address: "0x4e5",
496
+ },
497
+ sequence_number: "8",
726
498
  type: "0x1::coin::DepositEvent",
499
+ data: {
500
+ amount: "1500000",
501
+ },
502
+ },
503
+ {
727
504
  guid: {
728
- account_address: "0x12",
729
- creation_number: "2",
505
+ creation_number: "0",
506
+ account_address: "0x0",
730
507
  },
508
+ sequence_number: "0",
509
+ type: "0x1::transaction_fee::FeeStatement",
731
510
  data: {
732
- amount: "100",
511
+ execution_gas_units: "6",
512
+ io_gas_units: "6",
513
+ storage_fee_octas: "0",
514
+ storage_fee_refund_octas: "0",
515
+ total_charge_gas_units: "12",
733
516
  },
734
517
  },
735
518
  ],
736
519
  changes: [
737
520
  {
521
+ address: "0x4e5",
522
+ state_key_hash: "0x3c0",
523
+ data: {
524
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
525
+ data: {
526
+ coin: {
527
+ value: "4000000",
528
+ },
529
+ deposit_events: {
530
+ counter: "9",
531
+ guid: {
532
+ id: {
533
+ addr: "0x4e5",
534
+ creation_num: "4",
535
+ },
536
+ },
537
+ },
538
+ frozen: false,
539
+ withdraw_events: {
540
+ counter: "6",
541
+ guid: {
542
+ id: {
543
+ addr: "0x4e5",
544
+ creation_num: "5",
545
+ },
546
+ },
547
+ },
548
+ },
549
+ },
738
550
  type: "write_resource",
551
+ },
552
+ {
553
+ address: "0xa0d",
554
+ state_key_hash: "0x1709",
739
555
  data: {
740
- type: constants_1.APTOS_COIN_CHANGE,
556
+ type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
741
557
  data: {
558
+ coin: {
559
+ value: "68254118",
560
+ },
561
+ deposit_events: {
562
+ counter: "46",
563
+ guid: {
564
+ id: {
565
+ addr: "0xa0d",
566
+ creation_num: "2",
567
+ },
568
+ },
569
+ },
570
+ frozen: false,
742
571
  withdraw_events: {
572
+ counter: "89",
743
573
  guid: {
744
574
  id: {
745
- addr: "0x11",
575
+ addr: "0xa0d",
576
+ creation_num: "3",
577
+ },
578
+ },
579
+ },
580
+ },
581
+ },
582
+ type: "write_resource",
583
+ },
584
+ {
585
+ address: "0xa0d",
586
+ state_key_hash: "0x5520",
587
+ data: {
588
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
589
+ data: {
590
+ coin: {
591
+ value: "1000000",
592
+ },
593
+ deposit_events: {
594
+ counter: "7",
595
+ guid: {
596
+ id: {
597
+ addr: "0xa0d",
598
+ creation_num: "10",
599
+ },
600
+ },
601
+ },
602
+ frozen: false,
603
+ withdraw_events: {
604
+ counter: "13",
605
+ guid: {
606
+ id: {
607
+ addr: "0xa0d",
608
+ creation_num: "11",
609
+ },
610
+ },
611
+ },
612
+ },
613
+ },
614
+ type: "write_resource",
615
+ },
616
+ {
617
+ address: "0xa0d",
618
+ state_key_hash: "0x6f1e",
619
+ data: {
620
+ type: "0x1::account::Account",
621
+ data: {
622
+ authentication_key: "0xa0d",
623
+ coin_register_events: {
624
+ counter: "5",
625
+ guid: {
626
+ id: {
627
+ addr: "0xa0d",
628
+ creation_num: "0",
629
+ },
630
+ },
631
+ },
632
+ guid_creation_num: "12",
633
+ key_rotation_events: {
634
+ counter: "0",
635
+ guid: {
636
+ id: {
637
+ addr: "0xa0d",
746
638
  creation_num: "1",
747
639
  },
748
640
  },
749
641
  },
642
+ rotation_capability_offer: {
643
+ for: {
644
+ vec: [],
645
+ },
646
+ },
647
+ sequence_number: "122",
648
+ signer_capability_offer: {
649
+ for: {
650
+ vec: [],
651
+ },
652
+ },
653
+ },
654
+ },
655
+ type: "write_resource",
656
+ },
657
+ {
658
+ state_key_hash: "0x6e4b",
659
+ handle: "0x1b85",
660
+ key: "0x0619",
661
+ value: "0x1ddaf8da3b1497010000000000000000",
662
+ data: null,
663
+ type: "write_table_item",
664
+ },
665
+ ],
666
+ block: { hash: "0xabc", height: 1 },
667
+ timestamp: "1000000",
668
+ sequence_number: "1",
669
+ },
670
+ ];
671
+ const [ops, tokenOps] = (0, logic_1.txsToOps)({ address }, id, txs);
672
+ expect(ops).toHaveLength(1);
673
+ expect(ops[0]).toEqual({
674
+ id: expect.any(String),
675
+ hash: "0x123",
676
+ type: "FEES",
677
+ value: new bignumber_js_1.default(20000),
678
+ fee: new bignumber_js_1.default(20000),
679
+ blockHash: "0xabc",
680
+ blockHeight: 1,
681
+ senders: ["0xa0d"],
682
+ recipients: ["0x4e5"],
683
+ accountId: "token_account_id",
684
+ date: new Date(1000),
685
+ extra: { version: undefined },
686
+ transactionSequenceNumber: 1,
687
+ hasFailed: false,
688
+ });
689
+ expect(tokenOps).toHaveLength(1);
690
+ expect(tokenOps[0]).toEqual({
691
+ id: expect.any(String),
692
+ hash: "0x123",
693
+ type: constants_1.DIRECTION.OUT,
694
+ value: new bignumber_js_1.default(1500000),
695
+ fee: new bignumber_js_1.default(20000),
696
+ blockHash: "0xabc",
697
+ blockHeight: 1,
698
+ senders: ["0xa0d"],
699
+ recipients: ["0x4e5"],
700
+ date: new Date(1000),
701
+ extra: { version: undefined },
702
+ transactionSequenceNumber: 1,
703
+ hasFailed: false,
704
+ });
705
+ });
706
+ it("should convert Aptos token transactions to operations correctly", () => {
707
+ cryptoassets_1.findTokenByAddressInCurrency.mockReturnValue({
708
+ type: "TokenCurrency",
709
+ id: "aptos/fungible_asset/cellana_0x2ebb2ccac5e027a87fa0e2e5f656a3a4238d6a48d93ec9b610d570fc0aa0df12",
710
+ contractAddress: "0x2ebb",
711
+ parentCurrency: {
712
+ type: "CryptoCurrency",
713
+ id: "aptos",
714
+ coinType: 637,
715
+ name: "Aptos",
716
+ managerAppName: "Aptos",
717
+ ticker: "APT",
718
+ scheme: "aptos",
719
+ color: "#231F20",
720
+ family: "aptos",
721
+ units: [
722
+ {
723
+ name: "APT",
724
+ code: "APT",
725
+ magnitude: 8,
726
+ },
727
+ ],
728
+ explorerViews: [
729
+ {
730
+ address: "https://explorer.aptoslabs.com/account/$address?network=mainnet",
731
+ tx: "https://explorer.aptoslabs.com/txn/$hash?network=mainnet",
732
+ },
733
+ ],
734
+ },
735
+ name: "CELLANA",
736
+ tokenType: "fungible_asset",
737
+ ticker: "CELL",
738
+ disableCountervalue: false,
739
+ delisted: false,
740
+ units: [
741
+ {
742
+ name: "CELLANA",
743
+ code: "CELL",
744
+ magnitude: 8,
745
+ },
746
+ ],
747
+ });
748
+ jest.mock("../../bridge/logic", () => ({
749
+ ...jest.requireActual("../../bridge/logic"),
750
+ getResourceAddress: jest.fn().mockReturnValue("0x2ebb"),
751
+ }));
752
+ index_1.encodeTokenAccountId.mockReturnValue("token_account_id");
753
+ const txs = [
754
+ {
755
+ hash: "0x10c9",
756
+ sender: "0xa0d8",
757
+ gas_used: "200",
758
+ gas_unit_price: "100",
759
+ success: true,
760
+ payload: {
761
+ function: "0x1::primary_fungible_store::transfer",
762
+ type_arguments: ["0x1::fungible_asset::Metadata"],
763
+ arguments: [
764
+ {
765
+ inner: "0x2ebb",
766
+ },
767
+ "0x6b8c",
768
+ "193",
769
+ ],
770
+ type: "entry_function_payload",
771
+ },
772
+ events: [
773
+ {
774
+ guid: {
775
+ creation_number: "0",
776
+ account_address: "0x0",
777
+ },
778
+ sequence_number: "0",
779
+ type: "0x1::fungible_asset::Withdraw",
780
+ data: {
781
+ amount: "193",
782
+ store: "0xd475",
783
+ },
784
+ },
785
+ {
786
+ guid: {
787
+ creation_number: "0",
788
+ account_address: "0x0",
789
+ },
790
+ sequence_number: "0",
791
+ type: "0x1::fungible_asset::Deposit",
792
+ data: {
793
+ amount: "193",
794
+ store: "0xaaa9",
795
+ },
796
+ },
797
+ {
798
+ guid: {
799
+ creation_number: "0",
800
+ account_address: "0x0",
801
+ },
802
+ sequence_number: "0",
803
+ type: "0x1::transaction_fee::FeeStatement",
804
+ data: {
805
+ execution_gas_units: "4",
806
+ io_gas_units: "6",
807
+ storage_fee_octas: "0",
808
+ storage_fee_refund_octas: "0",
809
+ total_charge_gas_units: "10",
810
+ },
811
+ },
812
+ ],
813
+ changes: [
814
+ {
815
+ address: "0xaaa9",
816
+ state_key_hash: "0x9a17",
817
+ data: {
818
+ type: "0x1::fungible_asset::FungibleStore",
819
+ data: {
820
+ balance: "10044959",
821
+ frozen: false,
822
+ metadata: {
823
+ inner: "0x2ebb",
824
+ },
825
+ },
826
+ },
827
+ type: "write_resource",
828
+ },
829
+ {
830
+ address: "0xaaa9",
831
+ state_key_hash: "0x9a17",
832
+ data: {
833
+ type: "0x1::object::ObjectCore",
834
+ data: {
835
+ allow_ungated_transfer: false,
836
+ guid_creation_num: "1125899906842625",
837
+ owner: "0x6b8c",
838
+ transfer_events: {
839
+ counter: "0",
840
+ guid: {
841
+ id: {
842
+ addr: "0xaaa9",
843
+ creation_num: "1125899906842624",
844
+ },
845
+ },
846
+ },
847
+ },
848
+ },
849
+ type: "write_resource",
850
+ },
851
+ {
852
+ address: "0xa0d8",
853
+ state_key_hash: "0x1709",
854
+ data: {
855
+ type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
856
+ data: {
857
+ coin: {
858
+ value: "98423118",
859
+ },
750
860
  deposit_events: {
861
+ counter: "46",
751
862
  guid: {
752
863
  id: {
753
- addr: "0x12",
864
+ addr: "0xa0d8",
754
865
  creation_num: "2",
755
866
  },
756
867
  },
757
868
  },
869
+ frozen: false,
870
+ withdraw_events: {
871
+ counter: "88",
872
+ guid: {
873
+ id: {
874
+ addr: "0xa0d8",
875
+ creation_num: "3",
876
+ },
877
+ },
878
+ },
758
879
  },
759
880
  },
881
+ type: "write_resource",
882
+ },
883
+ {
884
+ address: "0xa0d8",
885
+ state_key_hash: "0x6f1e",
886
+ data: {
887
+ type: "0x1::account::Account",
888
+ data: {
889
+ authentication_key: "0xa0d8",
890
+ coin_register_events: {
891
+ counter: "5",
892
+ guid: {
893
+ id: {
894
+ addr: "0xa0d8",
895
+ creation_num: "0",
896
+ },
897
+ },
898
+ },
899
+ guid_creation_num: "12",
900
+ key_rotation_events: {
901
+ counter: "0",
902
+ guid: {
903
+ id: {
904
+ addr: "0xa0d8",
905
+ creation_num: "1",
906
+ },
907
+ },
908
+ },
909
+ rotation_capability_offer: {
910
+ for: {
911
+ vec: [],
912
+ },
913
+ },
914
+ sequence_number: "108",
915
+ signer_capability_offer: {
916
+ for: {
917
+ vec: [],
918
+ },
919
+ },
920
+ },
921
+ },
922
+ type: "write_resource",
923
+ },
924
+ {
925
+ address: "0xd475",
926
+ state_key_hash: "0x7567",
927
+ data: {
928
+ type: "0x1::fungible_asset::FungibleStore",
929
+ data: {
930
+ balance: "14000",
931
+ frozen: false,
932
+ metadata: {
933
+ inner: "0x2ebb",
934
+ },
935
+ },
936
+ },
937
+ type: "write_resource",
938
+ },
939
+ {
940
+ address: "0xd475",
941
+ state_key_hash: "0x7567",
942
+ data: {
943
+ type: "0x1::object::ObjectCore",
944
+ data: {
945
+ allow_ungated_transfer: false,
946
+ guid_creation_num: "1125899906842625",
947
+ owner: "0xa0d8",
948
+ transfer_events: {
949
+ counter: "0",
950
+ guid: {
951
+ id: {
952
+ addr: "0xd475",
953
+ creation_num: "1125899906842624",
954
+ },
955
+ },
956
+ },
957
+ },
958
+ },
959
+ type: "write_resource",
960
+ },
961
+ {
962
+ state_key_hash: "0x6e4b",
963
+ handle: "0x1b85",
964
+ key: "0x0619",
965
+ value: "0xad4388dc7daf96010000000000000000",
966
+ data: null,
967
+ type: "write_table_item",
760
968
  },
761
969
  ],
762
970
  block: { hash: "0xabc", height: 1 },
@@ -764,9 +972,25 @@ describe("Aptos sync logic ", () => {
764
972
  sequence_number: "1",
765
973
  },
766
974
  ];
767
- const result = (0, logic_1.txsToOps)({ address }, id, txs);
768
- expect(result).toHaveLength(1);
769
- expect(result[0].hasFailed).toBe(true);
975
+ const [ops, tokenOps] = (0, logic_1.txsToOps)({ address: "0x6b8c" }, "test_id", txs);
976
+ expect(ops).toHaveLength(0);
977
+ expect(tokenOps).toHaveLength(1);
978
+ expect(tokenOps[0]).toEqual({
979
+ id: expect.any(String),
980
+ accountId: "token_account_id",
981
+ hash: "0x10c9",
982
+ type: constants_1.DIRECTION.IN,
983
+ value: new bignumber_js_1.default(193),
984
+ fee: new bignumber_js_1.default(20000),
985
+ blockHash: "0xabc",
986
+ blockHeight: 1,
987
+ senders: ["0xa0d8"],
988
+ recipients: ["0x6b8c"],
989
+ date: new Date(1000),
990
+ extra: { version: undefined },
991
+ transactionSequenceNumber: 1,
992
+ hasFailed: false,
993
+ });
770
994
  });
771
995
  });
772
996
  });