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