@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
@@ -12,7 +12,7 @@ jest.mock("../types", () => jest.fn());
12
12
  jest.mock("../bridge/getTransactionStatus", () => jest.fn());
13
13
  jest.mock("../bridge/estimateMaxSpendable", () => jest.fn());
14
14
  jest.mock("../bridge/prepareTransaction", () => jest.fn());
15
- jest.mock("../bridge/createTransaction", () => jest.fn());
15
+ jest.mock("../logic/createTransaction", () => jest.fn());
16
16
  jest.mock("../bridge/synchronisation", () => jest.fn());
17
17
  jest.mock("../bridge/signOperation", () => jest.fn());
18
18
  jest.mock("../bridge/broadcast", () => jest.fn());
@@ -0,0 +1,148 @@
1
+ import {
2
+ createFixtureAccount,
3
+ createFixtureAccountWithSubAccount,
4
+ createFixtureTransaction,
5
+ createFixtureTransactionWithSubAccount,
6
+ } from "../../bridge/bridge.fixture";
7
+ import buildTransaction from "../../logic/buildTransaction";
8
+ import { AptosAPI } from "../../network";
9
+ import { normalizeTransactionOptions } from "../../logic/normalizeTransactionOptions";
10
+ import type { InputEntryFunctionData } from "@aptos-labs/ts-sdk";
11
+ import type { TransactionOptions } from "../../types";
12
+
13
+ const generateTransaction = jest.fn(() => "tx");
14
+
15
+ jest.mock("../../logic/normalizeTransactionOptions", () => ({
16
+ normalizeTransactionOptions: jest.fn(() => ({
17
+ maxGasAmount: "100",
18
+ gasUnitPrice: "200",
19
+ })),
20
+ }));
21
+
22
+ jest.mock("../../constants", () => ({
23
+ DEFAULT_GAS: 100,
24
+ DEFAULT_GAS_PRICE: 200,
25
+ APTOS_ASSET_ID: "0x1::aptos_coin::AptosCoin",
26
+ SUPPORTED_TOKEN_TYPES: ["coin", "fungible_asset"],
27
+ }));
28
+
29
+ jest.mock("../../network", () => {
30
+ return {
31
+ AptosAPI: function () {
32
+ return {
33
+ generateTransaction,
34
+ };
35
+ },
36
+ };
37
+ });
38
+
39
+ afterEach(() => {
40
+ jest.clearAllMocks();
41
+ });
42
+
43
+ describe("buildTransaction Test", () => {
44
+ it("should return transaction for main account", async () => {
45
+ const account = createFixtureAccount();
46
+ const transaction = createFixtureTransaction();
47
+ const aptosClient = new AptosAPI(account.currency.id);
48
+ const result = await buildTransaction(account, transaction, aptosClient);
49
+
50
+ const expected = "tx";
51
+
52
+ expect(result).toBe(expected);
53
+
54
+ const mockedNormalizeTransactionOptions = jest.mocked(normalizeTransactionOptions);
55
+
56
+ expect(mockedNormalizeTransactionOptions).toHaveBeenCalledTimes(1);
57
+ expect(generateTransaction).toHaveBeenCalledTimes(1);
58
+
59
+ const generateTransactionArgs: [string, InputEntryFunctionData, TransactionOptions][] =
60
+ generateTransaction.mock.calls[0];
61
+
62
+ expect(mockedNormalizeTransactionOptions.mock.calls[0][0]).toEqual({
63
+ maxGasAmount: "0",
64
+ gasUnitPrice: "0",
65
+ });
66
+
67
+ expect(generateTransactionArgs[0]).toBe("address");
68
+ expect(generateTransactionArgs[1]).toEqual({
69
+ function: "0x1::aptos_account::transfer_coins",
70
+ typeArguments: ["0x1::aptos_coin::AptosCoin"],
71
+ functionArguments: ["recipient", "0"],
72
+ });
73
+ expect(generateTransactionArgs[2]).toEqual({ maxGasAmount: "100", gasUnitPrice: "200" });
74
+ });
75
+
76
+ it("should return transaction for token account of type fungible asset", async () => {
77
+ const account = createFixtureAccountWithSubAccount("fungible_asset");
78
+ const transaction = createFixtureTransactionWithSubAccount();
79
+ const aptosClient = new AptosAPI(account.currency.id);
80
+ const result = await buildTransaction(account, transaction, aptosClient);
81
+
82
+ const expected = "tx";
83
+
84
+ expect(result).toBe(expected);
85
+
86
+ const mockedNormalizeTransactionOptions = jest.mocked(normalizeTransactionOptions);
87
+
88
+ expect(mockedNormalizeTransactionOptions).toHaveBeenCalledTimes(1);
89
+ expect(generateTransaction).toHaveBeenCalledTimes(1);
90
+
91
+ const generateTransactionArgs: [string, InputEntryFunctionData, TransactionOptions][] =
92
+ generateTransaction.mock.calls[0];
93
+
94
+ expect(mockedNormalizeTransactionOptions.mock.calls[0][0]).toEqual({
95
+ maxGasAmount: "0",
96
+ gasUnitPrice: "0",
97
+ });
98
+
99
+ expect(generateTransactionArgs[0]).toBe("address");
100
+ expect(generateTransactionArgs[1]).toEqual({
101
+ function: "0x1::primary_fungible_store::transfer",
102
+ typeArguments: ["0x1::fungible_asset::Metadata"],
103
+ functionArguments: ["contract_address", "recipient", "0"],
104
+ });
105
+ expect(generateTransactionArgs[2]).toEqual({ maxGasAmount: "100", gasUnitPrice: "200" });
106
+ });
107
+
108
+ it("should return transaction for token account of type coin", async () => {
109
+ const account = createFixtureAccountWithSubAccount("coin");
110
+ const transaction = createFixtureTransactionWithSubAccount();
111
+ const aptosClient = new AptosAPI(account.currency.id);
112
+ const result = await buildTransaction(account, transaction, aptosClient);
113
+
114
+ const expected = "tx";
115
+
116
+ expect(result).toBe(expected);
117
+
118
+ const mockedNormalizeTransactionOptions = jest.mocked(normalizeTransactionOptions);
119
+
120
+ expect(mockedNormalizeTransactionOptions).toHaveBeenCalledTimes(1);
121
+ expect(generateTransaction).toHaveBeenCalledTimes(1);
122
+
123
+ const generateTransactionArgs: [string, InputEntryFunctionData, TransactionOptions][] =
124
+ generateTransaction.mock.calls[0];
125
+
126
+ expect(mockedNormalizeTransactionOptions.mock.calls[0][0]).toEqual({
127
+ maxGasAmount: "0",
128
+ gasUnitPrice: "0",
129
+ });
130
+
131
+ expect(generateTransactionArgs[0]).toBe("address");
132
+ expect(generateTransactionArgs[1]).toEqual({
133
+ function: "0x1::aptos_account::transfer_coins",
134
+ typeArguments: ["contract_address"],
135
+ functionArguments: ["recipient", "0"],
136
+ });
137
+ expect(generateTransactionArgs[2]).toEqual({ maxGasAmount: "100", gasUnitPrice: "200" });
138
+ });
139
+
140
+ it("should throw error if token is not supported", async () => {
141
+ const account = createFixtureAccountWithSubAccount("not_supported_token_type");
142
+ const transaction = createFixtureTransactionWithSubAccount();
143
+ const aptosClient = new AptosAPI(account.currency.id);
144
+ expect(async () => await buildTransaction(account, transaction, aptosClient)).rejects.toThrow(
145
+ "Token type not_supported_token_type not supported",
146
+ );
147
+ });
148
+ });
@@ -0,0 +1,51 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { calculateAmount } from "../../logic/calculateAmount";
3
+
4
+ describe("calculateAmount", () => {
5
+ it("should calculate the correct amount when the address is the sender", () => {
6
+ const address = "0x11";
7
+ const sender = "0x11";
8
+ const amount_in = new BigNumber(50);
9
+ const amount_out = new BigNumber(100);
10
+
11
+ const result = calculateAmount(sender, address, amount_in, amount_out);
12
+
13
+ // LL negates the amount for SEND transactions during output
14
+ expect(result).toEqual(new BigNumber(50)); // -(50 - 100 - 10)
15
+ });
16
+
17
+ it("should calculate the correct amount when the address is not the sender", () => {
18
+ const address = "0x11";
19
+ const sender = "0x12";
20
+ const amount_in = new BigNumber(100);
21
+ const amount_out = new BigNumber(50);
22
+
23
+ const result = calculateAmount(sender, address, amount_in, amount_out);
24
+
25
+ expect(result).toEqual(new BigNumber(50)); // 100 - 50
26
+ });
27
+
28
+ it("should handle transactions with zero amounts", () => {
29
+ const address = "0x11";
30
+ const sender = "0x11";
31
+ const amount_in = new BigNumber(0);
32
+ const amount_out = new BigNumber(0);
33
+
34
+ const result = calculateAmount(sender, address, amount_in, amount_out);
35
+
36
+ // LL negates the amount for SEND transactions during output
37
+ expect(result).toEqual(new BigNumber(0)); // -(0 - 0 - 10)
38
+ });
39
+
40
+ it("should get negative numbers (for send tx with deposit to account)", () => {
41
+ const address = "0x11";
42
+ const sender = "0x11";
43
+ const amount_in = new BigNumber(100);
44
+ const amount_out = new BigNumber(0);
45
+
46
+ const result = calculateAmount(sender, address, amount_in, amount_out);
47
+
48
+ // LL negates the amount for SEND transactions during output
49
+ expect(result).toEqual(new BigNumber(100).negated()); // 100 - 10
50
+ });
51
+ });
@@ -0,0 +1,65 @@
1
+ import { createFixtureAccount } from "../../bridge/bridge.fixture";
2
+ import { Hex, generateSignedTransaction } from "@aptos-labs/ts-sdk";
3
+ import { combine } from "../../logic/combine";
4
+
5
+ const hexRawTx =
6
+ "0xfdde1012c0fac1f9a121eb3c8481c90d473df1c4180c070bd4f2549a6d06180400000000000000000200000000000000000000000000000000000000000000000000000000000000010d6170746f735f6163636f756e74087472616e736665720002203f5f0fcc8a909f23806e5efbdc1757e653fcd744de516a7de12b99b8417925c1080a00000000000000400d03000000000064000000000000002c721b6800000000b7";
7
+
8
+ jest.mock("@aptos-labs/ts-sdk", () => {
9
+ const originalModule = jest.requireActual("@aptos-labs/ts-sdk");
10
+ return {
11
+ ...originalModule,
12
+ generateSignedTransaction: jest
13
+ .fn()
14
+ .mockImplementation(() => Hex.fromHexString(hexRawTx).toUint8Array()),
15
+ };
16
+ });
17
+
18
+ describe("combine", () => {
19
+ beforeEach(() => {
20
+ jest.clearAllMocks();
21
+ });
22
+
23
+ it("should throws an error when no public key is provided", async () => {
24
+ const account = createFixtureAccount();
25
+ const signature = "0x7aa193705193f4";
26
+
27
+ expect(() => combine(hexRawTx, signature, account.xpub)).toThrow(
28
+ "account must have a public key",
29
+ );
30
+
31
+ expect(generateSignedTransaction).not.toHaveBeenCalled();
32
+ });
33
+
34
+ it("should throws an error when no valid hex value is provided for signature", async () => {
35
+ const account = createFixtureAccount();
36
+ const signature = "signature";
37
+
38
+ expect(() => combine(hexRawTx, signature, account.xpub)).toThrow(
39
+ "signature must be a valid hex value",
40
+ );
41
+
42
+ expect(generateSignedTransaction).not.toHaveBeenCalled();
43
+ });
44
+
45
+ it("should throws an error when no valid hex value is provided for tx", async () => {
46
+ const account = createFixtureAccount();
47
+ const signature = "0x7aa193705193f4";
48
+
49
+ expect(() => combine("tx", signature, account.xpub)).toThrow("tx must be a valid hex value");
50
+
51
+ expect(generateSignedTransaction).not.toHaveBeenCalled();
52
+ });
53
+
54
+ it("should sign a transaction", async () => {
55
+ const signature =
56
+ "0xbcdf10dc816488eca24b108056e2109220542f599caa4d81ac54556d63a777636ded8cafe972f68657bbee176f398cf332030df0f1dc2235f8f3d39456a5b90c";
57
+ const account = createFixtureAccount();
58
+ account.xpub = "0xb69a68cc64f7aa193705193f4dd598320a0a74baf7e4b50c9980c5bd60a82390";
59
+
60
+ const result = combine(hexRawTx, signature, account.xpub);
61
+
62
+ expect(generateSignedTransaction).toHaveBeenCalledTimes(1);
63
+ expect(result).not.toBe("");
64
+ });
65
+ });
@@ -0,0 +1,27 @@
1
+ import { compareAddress } from "../../logic/getCoinAndAmounts";
2
+
3
+ describe("compareAddress", () => {
4
+ it("should return true for identical addresses", () => {
5
+ const addressA = "0x1234567890abcdef";
6
+ const addressB = "0x1234567890abcdef";
7
+ expect(compareAddress(addressA, addressB)).toBe(true);
8
+ });
9
+
10
+ it("should return true for addresses with different cases", () => {
11
+ const addressA = "0x1234567890abcdef";
12
+ const addressB = "0x1234567890ABCDEF";
13
+ expect(compareAddress(addressA, addressB)).toBe(true);
14
+ });
15
+
16
+ it("should return true for addresses with different hex formats", () => {
17
+ const addressA = "0x1234567890abcdef";
18
+ const addressB = "1234567890abcdef";
19
+ expect(compareAddress(addressA, addressB)).toBe(true);
20
+ });
21
+
22
+ it("should return false for different addresses", () => {
23
+ const addressA = "0x1234567890abcdef";
24
+ const addressB = "0xfedcba0987654321";
25
+ expect(compareAddress(addressA, addressB)).toBe(false);
26
+ });
27
+ });
@@ -1,7 +1,7 @@
1
1
  import BigNumber from "bignumber.js";
2
- import createTransaction from "../../bridge/createTransaction";
2
+ import createTransaction from "../../logic/createTransaction";
3
3
 
4
- jest.mock("../../bridge/logic", () => ({
4
+ jest.mock("../../constants", () => ({
5
5
  DEFAULT_GAS: 100,
6
6
  DEFAULT_GAS_PRICE: 200,
7
7
  }));
@@ -0,0 +1,195 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { AptosTransaction } from "../../types";
3
+ import { getCoinAndAmounts } from "../../logic/getCoinAndAmounts";
4
+ import {
5
+ APTOS_ASSET_ID,
6
+ APTOS_COIN_CHANGE,
7
+ APTOS_FUNGIBLE_STORE,
8
+ APTOS_OBJECT_CORE,
9
+ } from "../../constants";
10
+
11
+ describe("getCoinAndAmounts", () => {
12
+ it("should calculate the correct legacy coins amounts for withdraw and deposit events", () => {
13
+ const tx = {
14
+ events: [
15
+ {
16
+ type: "0x1::coin::WithdrawEvent",
17
+ guid: {
18
+ account_address: "0x11",
19
+ creation_number: "1",
20
+ },
21
+ data: {
22
+ amount: "100",
23
+ },
24
+ },
25
+ {
26
+ type: "0x1::coin::DepositEvent",
27
+ guid: {
28
+ account_address: "0x11",
29
+ creation_number: "2",
30
+ },
31
+ data: {
32
+ amount: "50",
33
+ },
34
+ },
35
+ ],
36
+ changes: [
37
+ {
38
+ type: "write_resource",
39
+ data: {
40
+ type: APTOS_COIN_CHANGE,
41
+ data: {
42
+ withdraw_events: {
43
+ guid: {
44
+ id: {
45
+ addr: "0x11",
46
+ creation_num: "1",
47
+ },
48
+ },
49
+ },
50
+ deposit_events: {
51
+ guid: {
52
+ id: {
53
+ addr: "0x11",
54
+ creation_num: "2",
55
+ },
56
+ },
57
+ },
58
+ },
59
+ },
60
+ },
61
+ ],
62
+ } as unknown as AptosTransaction;
63
+
64
+ const address = "0x11";
65
+ const result = getCoinAndAmounts(tx, address);
66
+
67
+ expect(result.amount_in).toEqual(new BigNumber(50));
68
+ expect(result.amount_out).toEqual(new BigNumber(100));
69
+ expect(result.coin_id).toEqual(APTOS_ASSET_ID);
70
+ });
71
+
72
+ it("should calculate the correct fungible asset amounts for withdraw and deposit events", () => {
73
+ const tx = {
74
+ events: [
75
+ {
76
+ type: "0x1::fungible_asset::Withdraw",
77
+ guid: {
78
+ account_address: "0x11",
79
+ creation_number: "1",
80
+ },
81
+ data: {
82
+ amount: "100",
83
+ store: "0x22",
84
+ },
85
+ },
86
+ {
87
+ type: "0x1::fungible_asset::Deposit",
88
+ guid: {
89
+ account_address: "0x11",
90
+ creation_number: "2",
91
+ },
92
+ data: {
93
+ amount: "50",
94
+ store: "0x33",
95
+ },
96
+ },
97
+ ],
98
+ changes: [
99
+ {
100
+ type: "write_resource",
101
+ address: "0x22",
102
+ data: {
103
+ type: APTOS_FUNGIBLE_STORE,
104
+ data: {
105
+ metadata: {
106
+ inner: "0x44",
107
+ },
108
+ transfer_events: {
109
+ guid: {
110
+ id: {
111
+ addr: "0x11",
112
+ creation_num: "2",
113
+ },
114
+ },
115
+ },
116
+ },
117
+ },
118
+ },
119
+ {
120
+ type: "write_resource",
121
+ address: "0x22",
122
+ data: {
123
+ type: APTOS_OBJECT_CORE,
124
+ data: {
125
+ owner: "0x11",
126
+ transfer_events: {
127
+ guid: {
128
+ id: {
129
+ addr: "0x22",
130
+ creation_num: "2",
131
+ },
132
+ },
133
+ },
134
+ },
135
+ },
136
+ },
137
+ {
138
+ type: "write_resource",
139
+ data: {
140
+ type: APTOS_COIN_CHANGE,
141
+ data: {
142
+ withdraw_events: {
143
+ guid: {
144
+ id: {
145
+ addr: "0x11",
146
+ creation_num: "1",
147
+ },
148
+ },
149
+ },
150
+ deposit_events: {
151
+ guid: {
152
+ id: {
153
+ addr: "0x11",
154
+ creation_num: "2",
155
+ },
156
+ },
157
+ },
158
+ },
159
+ },
160
+ },
161
+ ],
162
+ } as unknown as AptosTransaction;
163
+
164
+ const address = "0x11";
165
+ const result = getCoinAndAmounts(tx, address);
166
+
167
+ expect(result.amount_in).toEqual(new BigNumber(0));
168
+ expect(result.amount_out).toEqual(new BigNumber(100));
169
+ expect(result.coin_id).toEqual("0x44");
170
+ });
171
+
172
+ it("should handle transactions with other events", () => {
173
+ const tx = {
174
+ events: [
175
+ {
176
+ type: "0x1::coin::OtherEvent",
177
+ guid: {
178
+ account_address: "0x11",
179
+ creation_number: "1",
180
+ },
181
+ data: {
182
+ amount: "100",
183
+ },
184
+ },
185
+ ],
186
+ } as unknown as AptosTransaction;
187
+
188
+ const address = "0x1";
189
+ const result = getCoinAndAmounts(tx, address);
190
+
191
+ expect(result.amount_in).toEqual(new BigNumber(0));
192
+ expect(result.amount_out).toEqual(new BigNumber(0));
193
+ expect(result.coin_id).toEqual(null);
194
+ });
195
+ });
@@ -0,0 +1,33 @@
1
+ import { InputEntryFunctionData } from "@aptos-labs/ts-sdk";
2
+ import { getFunctionAddress } from "../../logic/getFunctionAddress";
3
+
4
+ describe("getFunctionAddress", () => {
5
+ it("should return the function address when payload contains a function", () => {
6
+ const payload: InputEntryFunctionData = {
7
+ function: "0x1::coin::transfer",
8
+ typeArguments: [],
9
+ functionArguments: [],
10
+ };
11
+
12
+ const result = getFunctionAddress(payload);
13
+ expect(result).toBe("0x1");
14
+ });
15
+
16
+ it("should return undefined when payload does not contain a function", () => {
17
+ const payload = {
18
+ function: "::::",
19
+ typeArguments: [],
20
+ functionArguments: [],
21
+ } as InputEntryFunctionData;
22
+
23
+ const result = getFunctionAddress(payload);
24
+ expect(result).toBeUndefined();
25
+ });
26
+
27
+ it("should return undefined when payload is empty", () => {
28
+ const payload = {} as InputEntryFunctionData;
29
+
30
+ const result = getFunctionAddress(payload);
31
+ expect(result).toBeUndefined();
32
+ });
33
+ });