@ledgerhq/coin-aptos 2.0.0-nightly.5 → 2.1.0-next.0

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 (533) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +18 -6
  3. package/CHANGELOG.md +178 -34
  4. package/jest.config.js +2 -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 +187 -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 +319 -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 +703 -479
  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 +114 -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/normalizeAddress.unit.test.d.ts +2 -0
  71. package/lib/__tests__/logic/normalizeAddress.unit.test.d.ts.map +1 -0
  72. package/lib/__tests__/logic/normalizeAddress.unit.test.js +12 -0
  73. package/lib/__tests__/logic/normalizeAddress.unit.test.js.map +1 -0
  74. package/lib/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
  75. package/lib/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
  76. package/lib/__tests__/logic/processRecipients.unit.test.js +79 -0
  77. package/lib/__tests__/logic/processRecipients.unit.test.js.map +1 -0
  78. package/lib/__tests__/network/client.test.d.ts +2 -0
  79. package/lib/__tests__/network/client.test.d.ts.map +1 -0
  80. package/lib/__tests__/network/client.test.js +1124 -0
  81. package/lib/__tests__/network/client.test.js.map +1 -0
  82. package/lib/api/index.d.ts +4 -30
  83. package/lib/api/index.d.ts.map +1 -1
  84. package/lib/api/index.js +19 -170
  85. package/lib/api/index.js.map +1 -1
  86. package/lib/bridge/bridge.fixture.d.ts +2 -0
  87. package/lib/bridge/bridge.fixture.d.ts.map +1 -1
  88. package/lib/bridge/bridge.fixture.js +85 -13
  89. package/lib/bridge/bridge.fixture.js.map +1 -1
  90. package/lib/bridge/broadcast.d.ts +3 -2
  91. package/lib/bridge/broadcast.d.ts.map +1 -1
  92. package/lib/bridge/broadcast.js +4 -3
  93. package/lib/bridge/broadcast.js.map +1 -1
  94. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
  95. package/lib/bridge/estimateMaxSpendable.js +6 -5
  96. package/lib/bridge/estimateMaxSpendable.js.map +1 -1
  97. package/lib/bridge/getFeesForTransaction.d.ts +1 -1
  98. package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
  99. package/lib/bridge/getFeesForTransaction.js +20 -14
  100. package/lib/bridge/getFeesForTransaction.js.map +1 -1
  101. package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
  102. package/lib/bridge/getTransactionStatus.js +28 -14
  103. package/lib/bridge/getTransactionStatus.js.map +1 -1
  104. package/lib/bridge/index.d.ts +1 -1
  105. package/lib/bridge/index.d.ts.map +1 -1
  106. package/lib/bridge/index.js +1 -1
  107. package/lib/bridge/index.js.map +1 -1
  108. package/lib/bridge/logic.d.ts +5 -19
  109. package/lib/bridge/logic.d.ts.map +1 -1
  110. package/lib/bridge/logic.js +50 -147
  111. package/lib/bridge/logic.js.map +1 -1
  112. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  113. package/lib/bridge/prepareTransaction.js +5 -4
  114. package/lib/bridge/prepareTransaction.js.map +1 -1
  115. package/lib/bridge/signOperation.d.ts.map +1 -1
  116. package/lib/bridge/signOperation.js +21 -7
  117. package/lib/bridge/signOperation.js.map +1 -1
  118. package/lib/bridge/synchronisation.d.ts +15 -0
  119. package/lib/bridge/synchronisation.d.ts.map +1 -1
  120. package/lib/bridge/synchronisation.js +129 -6
  121. package/lib/bridge/synchronisation.js.map +1 -1
  122. package/lib/config.d.ts +13 -0
  123. package/lib/config.d.ts.map +1 -0
  124. package/lib/config.js +9 -0
  125. package/lib/config.js.map +1 -0
  126. package/lib/constants.d.ts +13 -2
  127. package/lib/constants.d.ts.map +1 -1
  128. package/lib/constants.js +17 -2
  129. package/lib/constants.js.map +1 -1
  130. package/lib/logic/buildTransaction.d.ts +9 -0
  131. package/lib/logic/buildTransaction.d.ts.map +1 -0
  132. package/lib/logic/buildTransaction.js +47 -0
  133. package/lib/logic/buildTransaction.js.map +1 -0
  134. package/lib/logic/calculateAmount.d.ts +3 -0
  135. package/lib/logic/calculateAmount.d.ts.map +1 -0
  136. package/lib/logic/calculateAmount.js +13 -0
  137. package/lib/logic/calculateAmount.js.map +1 -0
  138. package/lib/logic/combine.d.ts +4 -0
  139. package/lib/logic/combine.d.ts.map +1 -0
  140. package/lib/logic/combine.js +34 -0
  141. package/lib/logic/combine.js.map +1 -0
  142. package/lib/logic/craftTransaction.d.ts +5 -0
  143. package/lib/logic/craftTransaction.d.ts.map +1 -0
  144. package/lib/logic/craftTransaction.js +68 -0
  145. package/lib/logic/craftTransaction.js.map +1 -0
  146. package/lib/logic/createTransaction.d.ts.map +1 -0
  147. package/lib/{bridge → logic}/createTransaction.js +3 -3
  148. package/lib/logic/createTransaction.js.map +1 -0
  149. package/lib/logic/getBalance.d.ts +5 -0
  150. package/lib/logic/getBalance.d.ts.map +1 -0
  151. package/lib/logic/getBalance.js +12 -0
  152. package/lib/logic/getBalance.js.map +1 -0
  153. package/lib/logic/getCoinAndAmounts.d.ts +13 -0
  154. package/lib/logic/getCoinAndAmounts.d.ts.map +1 -0
  155. package/lib/logic/getCoinAndAmounts.js +112 -0
  156. package/lib/logic/getCoinAndAmounts.js.map +1 -0
  157. package/lib/logic/getFunctionAddress.d.ts +3 -0
  158. package/lib/logic/getFunctionAddress.d.ts.map +1 -0
  159. package/lib/logic/getFunctionAddress.js +12 -0
  160. package/lib/logic/getFunctionAddress.js.map +1 -0
  161. package/lib/logic/getResourceAddress.d.ts +4 -0
  162. package/lib/logic/getResourceAddress.d.ts.map +1 -0
  163. package/lib/logic/getResourceAddress.js +17 -0
  164. package/lib/logic/getResourceAddress.js.map +1 -0
  165. package/lib/logic/isTestnet.d.ts +2 -0
  166. package/lib/logic/isTestnet.d.ts.map +1 -0
  167. package/lib/logic/isTestnet.js +9 -0
  168. package/lib/logic/isTestnet.js.map +1 -0
  169. package/lib/logic/isWriteSetChangeWriteResource.d.ts +3 -0
  170. package/lib/logic/isWriteSetChangeWriteResource.d.ts.map +1 -0
  171. package/lib/logic/isWriteSetChangeWriteResource.js +8 -0
  172. package/lib/logic/isWriteSetChangeWriteResource.js.map +1 -0
  173. package/lib/logic/normalizeAddress.d.ts +2 -0
  174. package/lib/logic/normalizeAddress.d.ts.map +1 -0
  175. package/lib/logic/normalizeAddress.js +12 -0
  176. package/lib/logic/normalizeAddress.js.map +1 -0
  177. package/lib/logic/normalizeTransactionOptions.d.ts +3 -0
  178. package/lib/logic/normalizeTransactionOptions.d.ts.map +1 -0
  179. package/lib/logic/normalizeTransactionOptions.js +21 -0
  180. package/lib/logic/normalizeTransactionOptions.js.map +1 -0
  181. package/lib/logic/processRecipients.d.ts +6 -0
  182. package/lib/logic/processRecipients.d.ts.map +1 -0
  183. package/lib/logic/processRecipients.js +58 -0
  184. package/lib/logic/processRecipients.js.map +1 -0
  185. package/lib/logic/transactionsToOperations.d.ts +7 -0
  186. package/lib/logic/transactionsToOperations.d.ts.map +1 -0
  187. package/lib/logic/transactionsToOperations.js +89 -0
  188. package/lib/logic/transactionsToOperations.js.map +1 -0
  189. package/lib/network/client.d.ts +38 -0
  190. package/lib/network/client.d.ts.map +1 -0
  191. package/lib/network/client.js +283 -0
  192. package/lib/network/client.js.map +1 -0
  193. package/lib/network/graphql/queries.d.ts.map +1 -0
  194. package/lib/{api → network}/graphql/queries.js +6 -6
  195. package/lib/network/graphql/queries.js.map +1 -0
  196. package/lib/{api → network}/graphql/types.d.ts +9 -9
  197. package/lib/network/graphql/types.d.ts.map +1 -0
  198. package/lib/{api → network}/graphql/types.js.map +1 -1
  199. package/lib/network/index.d.ts +2 -1
  200. package/lib/network/index.d.ts.map +1 -1
  201. package/lib/network/index.js +19 -7
  202. package/lib/network/index.js.map +1 -1
  203. package/lib/test/bot-specs.d.ts.map +1 -1
  204. package/lib/test/bot-specs.js +40 -1
  205. package/lib/test/bot-specs.js.map +1 -1
  206. package/lib/test/bridgeDatasetTest.d.ts.map +1 -1
  207. package/lib/test/bridgeDatasetTest.js +44 -62
  208. package/lib/test/bridgeDatasetTest.js.map +1 -1
  209. package/lib/test/speculos-deviceActions.d.ts +1 -0
  210. package/lib/test/speculos-deviceActions.d.ts.map +1 -1
  211. package/lib/test/speculos-deviceActions.js +37 -5
  212. package/lib/test/speculos-deviceActions.js.map +1 -1
  213. package/lib/types/assets.d.ts +16 -0
  214. package/lib/types/assets.d.ts.map +1 -0
  215. package/lib/types/assets.js +3 -0
  216. package/lib/types/assets.js.map +1 -0
  217. package/lib/types/index.d.ts +22 -7
  218. package/lib/types/index.d.ts.map +1 -1
  219. package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts +2 -0
  220. package/lib-es/__tests__/api/craftTransaction.unit.test.d.ts.map +1 -0
  221. package/lib-es/__tests__/api/craftTransaction.unit.test.js +185 -0
  222. package/lib-es/__tests__/api/craftTransaction.unit.test.js.map +1 -0
  223. package/lib-es/__tests__/api/getBalance.unit.test.d.ts +2 -0
  224. package/lib-es/__tests__/api/getBalance.unit.test.d.ts.map +1 -0
  225. package/lib-es/__tests__/api/getBalance.unit.test.js +36 -0
  226. package/lib-es/__tests__/api/getBalance.unit.test.js.map +1 -0
  227. package/lib-es/__tests__/api/index.integ.test.d.ts +2 -0
  228. package/lib-es/__tests__/api/index.integ.test.d.ts.map +1 -0
  229. package/lib-es/__tests__/api/index.integ.test.js +317 -0
  230. package/lib-es/__tests__/api/index.integ.test.js.map +1 -0
  231. package/lib-es/__tests__/api/index.test.js +52 -408
  232. package/lib-es/__tests__/api/index.test.js.map +1 -1
  233. package/lib-es/__tests__/bridge/broadcast.test.js +2 -2
  234. package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -1
  235. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +112 -11
  236. package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
  237. package/lib-es/__tests__/bridge/getTransactionStatus.test.js +177 -39
  238. package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
  239. package/lib-es/__tests__/bridge/logic.test.js +703 -479
  240. package/lib-es/__tests__/bridge/logic.test.js.map +1 -1
  241. package/lib-es/__tests__/bridge/prepareTransaction.test.js +2 -2
  242. package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -1
  243. package/lib-es/__tests__/bridge/signOperation.test.js +137 -14
  244. package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -1
  245. package/lib-es/__tests__/bridge/synchronisation.test.js +1213 -69
  246. package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
  247. package/lib-es/__tests__/index.test.js +1 -1
  248. package/lib-es/__tests__/index.test.js.map +1 -1
  249. package/lib-es/__tests__/logic/buildTransaction.test.d.ts.map +1 -0
  250. package/lib-es/__tests__/logic/buildTransaction.test.js +109 -0
  251. package/lib-es/__tests__/logic/buildTransaction.test.js.map +1 -0
  252. package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts +2 -0
  253. package/lib-es/__tests__/logic/calculateAmount.unit.test.d.ts.map +1 -0
  254. package/lib-es/__tests__/logic/calculateAmount.unit.test.js +40 -0
  255. package/lib-es/__tests__/logic/calculateAmount.unit.test.js.map +1 -0
  256. package/lib-es/__tests__/logic/combine.unit.test.d.ts +2 -0
  257. package/lib-es/__tests__/logic/combine.unit.test.d.ts.map +1 -0
  258. package/lib-es/__tests__/logic/combine.unit.test.js +45 -0
  259. package/lib-es/__tests__/logic/combine.unit.test.js.map +1 -0
  260. package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts +2 -0
  261. package/lib-es/__tests__/logic/compareAddress.unit.test.d.ts.map +1 -0
  262. package/lib-es/__tests__/logic/compareAddress.unit.test.js +24 -0
  263. package/lib-es/__tests__/logic/compareAddress.unit.test.js.map +1 -0
  264. package/lib-es/__tests__/logic/createTransaction.test.d.ts.map +1 -0
  265. package/lib-es/__tests__/{bridge → logic}/createTransaction.test.js +2 -2
  266. package/lib-es/__tests__/logic/createTransaction.test.js.map +1 -0
  267. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts +2 -0
  268. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.d.ts.map +1 -0
  269. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js +181 -0
  270. package/lib-es/__tests__/logic/getCoinAndAmounts.unit.test.js.map +1 -0
  271. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts +2 -0
  272. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.d.ts.map +1 -0
  273. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js +27 -0
  274. package/lib-es/__tests__/logic/getFunctionAddress.unit.test.js.map +1 -0
  275. package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts +2 -0
  276. package/lib-es/__tests__/logic/getResourceAddress.unit.test.d.ts.map +1 -0
  277. package/lib-es/__tests__/logic/getResourceAddress.unit.test.js +216 -0
  278. package/lib-es/__tests__/logic/getResourceAddress.unit.test.js.map +1 -0
  279. package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts +2 -0
  280. package/lib-es/__tests__/logic/isTestnet.unit.test.d.ts.map +1 -0
  281. package/lib-es/__tests__/logic/isTestnet.unit.test.js +10 -0
  282. package/lib-es/__tests__/logic/isTestnet.unit.test.js.map +1 -0
  283. package/lib-es/__tests__/logic/normalizeAddress.unit.test.d.ts +2 -0
  284. package/lib-es/__tests__/logic/normalizeAddress.unit.test.d.ts.map +1 -0
  285. package/lib-es/__tests__/logic/normalizeAddress.unit.test.js +10 -0
  286. package/lib-es/__tests__/logic/normalizeAddress.unit.test.js.map +1 -0
  287. package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts +2 -0
  288. package/lib-es/__tests__/logic/processRecipients.unit.test.d.ts.map +1 -0
  289. package/lib-es/__tests__/logic/processRecipients.unit.test.js +74 -0
  290. package/lib-es/__tests__/logic/processRecipients.unit.test.js.map +1 -0
  291. package/lib-es/__tests__/network/client.test.d.ts +2 -0
  292. package/lib-es/__tests__/network/client.test.d.ts.map +1 -0
  293. package/lib-es/__tests__/network/client.test.js +1119 -0
  294. package/lib-es/__tests__/network/client.test.js.map +1 -0
  295. package/lib-es/api/index.d.ts +4 -30
  296. package/lib-es/api/index.d.ts.map +1 -1
  297. package/lib-es/api/index.js +17 -168
  298. package/lib-es/api/index.js.map +1 -1
  299. package/lib-es/bridge/bridge.fixture.d.ts +2 -0
  300. package/lib-es/bridge/bridge.fixture.d.ts.map +1 -1
  301. package/lib-es/bridge/bridge.fixture.js +82 -12
  302. package/lib-es/bridge/bridge.fixture.js.map +1 -1
  303. package/lib-es/bridge/broadcast.d.ts +3 -2
  304. package/lib-es/bridge/broadcast.d.ts.map +1 -1
  305. package/lib-es/bridge/broadcast.js +4 -3
  306. package/lib-es/bridge/broadcast.js.map +1 -1
  307. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
  308. package/lib-es/bridge/estimateMaxSpendable.js +4 -3
  309. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
  310. package/lib-es/bridge/getFeesForTransaction.d.ts +1 -1
  311. package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
  312. package/lib-es/bridge/getFeesForTransaction.js +15 -9
  313. package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
  314. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
  315. package/lib-es/bridge/getTransactionStatus.js +28 -14
  316. package/lib-es/bridge/getTransactionStatus.js.map +1 -1
  317. package/lib-es/bridge/index.d.ts +1 -1
  318. package/lib-es/bridge/index.d.ts.map +1 -1
  319. package/lib-es/bridge/index.js +1 -1
  320. package/lib-es/bridge/index.js.map +1 -1
  321. package/lib-es/bridge/logic.d.ts +5 -19
  322. package/lib-es/bridge/logic.d.ts.map +1 -1
  323. package/lib-es/bridge/logic.js +44 -134
  324. package/lib-es/bridge/logic.js.map +1 -1
  325. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  326. package/lib-es/bridge/prepareTransaction.js +5 -4
  327. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  328. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  329. package/lib-es/bridge/signOperation.js +19 -5
  330. package/lib-es/bridge/signOperation.js.map +1 -1
  331. package/lib-es/bridge/synchronisation.d.ts +15 -0
  332. package/lib-es/bridge/synchronisation.d.ts.map +1 -1
  333. package/lib-es/bridge/synchronisation.js +124 -4
  334. package/lib-es/bridge/synchronisation.js.map +1 -1
  335. package/lib-es/config.d.ts +13 -0
  336. package/lib-es/config.d.ts.map +1 -0
  337. package/lib-es/config.js +4 -0
  338. package/lib-es/config.js.map +1 -0
  339. package/lib-es/constants.d.ts +13 -2
  340. package/lib-es/constants.d.ts.map +1 -1
  341. package/lib-es/constants.js +13 -1
  342. package/lib-es/constants.js.map +1 -1
  343. package/lib-es/logic/buildTransaction.d.ts +9 -0
  344. package/lib-es/logic/buildTransaction.d.ts.map +1 -0
  345. package/lib-es/logic/buildTransaction.js +43 -0
  346. package/lib-es/logic/buildTransaction.js.map +1 -0
  347. package/lib-es/logic/calculateAmount.d.ts +3 -0
  348. package/lib-es/logic/calculateAmount.d.ts.map +1 -0
  349. package/lib-es/logic/calculateAmount.js +9 -0
  350. package/lib-es/logic/calculateAmount.js.map +1 -0
  351. package/lib-es/logic/combine.d.ts +4 -0
  352. package/lib-es/logic/combine.d.ts.map +1 -0
  353. package/lib-es/logic/combine.js +29 -0
  354. package/lib-es/logic/combine.js.map +1 -0
  355. package/lib-es/logic/craftTransaction.d.ts +5 -0
  356. package/lib-es/logic/craftTransaction.d.ts.map +1 -0
  357. package/lib-es/logic/craftTransaction.js +38 -0
  358. package/lib-es/logic/craftTransaction.js.map +1 -0
  359. package/lib-es/logic/createTransaction.d.ts.map +1 -0
  360. package/lib-es/{bridge → logic}/createTransaction.js +1 -1
  361. package/lib-es/logic/createTransaction.js.map +1 -0
  362. package/lib-es/logic/getBalance.d.ts +5 -0
  363. package/lib-es/logic/getBalance.d.ts.map +1 -0
  364. package/lib-es/logic/getBalance.js +8 -0
  365. package/lib-es/logic/getBalance.js.map +1 -0
  366. package/lib-es/logic/getCoinAndAmounts.d.ts +13 -0
  367. package/lib-es/logic/getCoinAndAmounts.d.ts.map +1 -0
  368. package/lib-es/logic/getCoinAndAmounts.js +101 -0
  369. package/lib-es/logic/getCoinAndAmounts.js.map +1 -0
  370. package/lib-es/logic/getFunctionAddress.d.ts +3 -0
  371. package/lib-es/logic/getFunctionAddress.d.ts.map +1 -0
  372. package/lib-es/logic/getFunctionAddress.js +8 -0
  373. package/lib-es/logic/getFunctionAddress.js.map +1 -0
  374. package/lib-es/logic/getResourceAddress.d.ts +4 -0
  375. package/lib-es/logic/getResourceAddress.d.ts.map +1 -0
  376. package/lib-es/logic/getResourceAddress.js +13 -0
  377. package/lib-es/logic/getResourceAddress.js.map +1 -0
  378. package/lib-es/logic/isTestnet.d.ts +2 -0
  379. package/lib-es/logic/isTestnet.d.ts.map +1 -0
  380. package/lib-es/logic/isTestnet.js +5 -0
  381. package/lib-es/logic/isTestnet.js.map +1 -0
  382. package/lib-es/logic/isWriteSetChangeWriteResource.d.ts +3 -0
  383. package/lib-es/logic/isWriteSetChangeWriteResource.d.ts.map +1 -0
  384. package/lib-es/logic/isWriteSetChangeWriteResource.js +4 -0
  385. package/lib-es/logic/isWriteSetChangeWriteResource.js.map +1 -0
  386. package/lib-es/logic/normalizeAddress.d.ts +2 -0
  387. package/lib-es/logic/normalizeAddress.d.ts.map +1 -0
  388. package/lib-es/logic/normalizeAddress.js +8 -0
  389. package/lib-es/logic/normalizeAddress.js.map +1 -0
  390. package/lib-es/logic/normalizeTransactionOptions.d.ts +3 -0
  391. package/lib-es/logic/normalizeTransactionOptions.d.ts.map +1 -0
  392. package/lib-es/logic/normalizeTransactionOptions.js +17 -0
  393. package/lib-es/logic/normalizeTransactionOptions.js.map +1 -0
  394. package/lib-es/logic/processRecipients.d.ts +6 -0
  395. package/lib-es/logic/processRecipients.d.ts.map +1 -0
  396. package/lib-es/logic/processRecipients.js +54 -0
  397. package/lib-es/logic/processRecipients.js.map +1 -0
  398. package/lib-es/logic/transactionsToOperations.d.ts +7 -0
  399. package/lib-es/logic/transactionsToOperations.d.ts.map +1 -0
  400. package/lib-es/logic/transactionsToOperations.js +81 -0
  401. package/lib-es/logic/transactionsToOperations.js.map +1 -0
  402. package/lib-es/network/client.d.ts +38 -0
  403. package/lib-es/network/client.d.ts.map +1 -0
  404. package/lib-es/network/client.js +276 -0
  405. package/lib-es/network/client.js.map +1 -0
  406. package/lib-es/network/graphql/queries.d.ts.map +1 -0
  407. package/lib-es/{api → network}/graphql/queries.js +6 -6
  408. package/lib-es/network/graphql/queries.js.map +1 -0
  409. package/lib-es/{api → network}/graphql/types.d.ts +9 -9
  410. package/lib-es/network/graphql/types.d.ts.map +1 -0
  411. package/lib-es/{api → network}/graphql/types.js.map +1 -1
  412. package/lib-es/network/index.d.ts +2 -1
  413. package/lib-es/network/index.d.ts.map +1 -1
  414. package/lib-es/network/index.js +6 -8
  415. package/lib-es/network/index.js.map +1 -1
  416. package/lib-es/test/bot-specs.d.ts.map +1 -1
  417. package/lib-es/test/bot-specs.js +41 -2
  418. package/lib-es/test/bot-specs.js.map +1 -1
  419. package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -1
  420. package/lib-es/test/bridgeDatasetTest.js +44 -59
  421. package/lib-es/test/bridgeDatasetTest.js.map +1 -1
  422. package/lib-es/test/speculos-deviceActions.d.ts +1 -0
  423. package/lib-es/test/speculos-deviceActions.d.ts.map +1 -1
  424. package/lib-es/test/speculos-deviceActions.js +36 -4
  425. package/lib-es/test/speculos-deviceActions.js.map +1 -1
  426. package/lib-es/types/assets.d.ts +16 -0
  427. package/lib-es/types/assets.d.ts.map +1 -0
  428. package/lib-es/types/assets.js +2 -0
  429. package/lib-es/types/assets.js.map +1 -0
  430. package/lib-es/types/index.d.ts +22 -7
  431. package/lib-es/types/index.d.ts.map +1 -1
  432. package/package.json +16 -13
  433. package/src/__tests__/api/craftTransaction.unit.test.ts +243 -0
  434. package/src/__tests__/api/getBalance.unit.test.ts +44 -0
  435. package/src/__tests__/api/index.integ.test.ts +401 -0
  436. package/src/__tests__/api/index.test.ts +60 -477
  437. package/src/__tests__/bridge/broadcast.test.ts +2 -2
  438. package/src/__tests__/bridge/getFeesForTransaction.test.ts +146 -11
  439. package/src/__tests__/bridge/getTransactionStatus.test.ts +217 -38
  440. package/src/__tests__/bridge/logic.test.ts +728 -569
  441. package/src/__tests__/bridge/prepareTransaction.test.ts +2 -2
  442. package/src/__tests__/bridge/signOperation.test.ts +153 -15
  443. package/src/__tests__/bridge/synchronisation.test.ts +1265 -71
  444. package/src/__tests__/index.test.ts +1 -1
  445. package/src/__tests__/logic/buildTransaction.test.ts +150 -0
  446. package/src/__tests__/logic/calculateAmount.unit.test.ts +51 -0
  447. package/src/__tests__/logic/combine.unit.test.ts +65 -0
  448. package/src/__tests__/logic/compareAddress.unit.test.ts +27 -0
  449. package/src/__tests__/{bridge → logic}/createTransaction.test.ts +2 -2
  450. package/src/__tests__/logic/getCoinAndAmounts.unit.test.ts +195 -0
  451. package/src/__tests__/logic/getFunctionAddress.unit.test.ts +33 -0
  452. package/src/__tests__/logic/getResourceAddress.unit.test.ts +241 -0
  453. package/src/__tests__/logic/isTestnet.unit.test.ts +11 -0
  454. package/src/__tests__/logic/normalizeAddress.unit.test.ts +15 -0
  455. package/src/__tests__/logic/processRecipients.unit.test.ts +95 -0
  456. package/src/__tests__/network/client.test.ts +1257 -0
  457. package/src/api/index.ts +29 -224
  458. package/src/bridge/bridge.fixture.ts +91 -12
  459. package/src/bridge/broadcast.ts +7 -7
  460. package/src/bridge/estimateMaxSpendable.ts +4 -3
  461. package/src/bridge/getFeesForTransaction.ts +17 -11
  462. package/src/bridge/getTransactionStatus.ts +35 -13
  463. package/src/bridge/index.ts +2 -2
  464. package/src/bridge/logic.ts +58 -194
  465. package/src/bridge/prepareTransaction.ts +7 -4
  466. package/src/bridge/signOperation.ts +21 -5
  467. package/src/bridge/synchronisation.ts +171 -4
  468. package/src/config.ts +19 -0
  469. package/src/constants.ts +22 -2
  470. package/src/logic/buildTransaction.ts +70 -0
  471. package/src/logic/calculateAmount.ts +15 -0
  472. package/src/logic/combine.ts +51 -0
  473. package/src/logic/craftTransaction.ts +65 -0
  474. package/src/{bridge → logic}/createTransaction.ts +1 -1
  475. package/src/logic/getBalance.ts +15 -0
  476. package/src/logic/getCoinAndAmounts.ts +141 -0
  477. package/src/logic/getFunctionAddress.ts +9 -0
  478. package/src/logic/getResourceAddress.ts +24 -0
  479. package/src/logic/isTestnet.ts +5 -0
  480. package/src/logic/isWriteSetChangeWriteResource.ts +7 -0
  481. package/src/logic/normalizeAddress.ts +8 -0
  482. package/src/logic/normalizeTransactionOptions.ts +18 -0
  483. package/src/logic/processRecipients.ts +88 -0
  484. package/src/logic/transactionsToOperations.ts +106 -0
  485. package/src/network/client.ts +374 -0
  486. package/src/{api → network}/graphql/queries.ts +6 -6
  487. package/src/{api → network}/graphql/types.ts +9 -9
  488. package/src/network/index.ts +6 -14
  489. package/src/test/bot-specs.ts +63 -3
  490. package/src/test/bridgeDatasetTest.ts +46 -59
  491. package/src/test/speculos-deviceActions.ts +40 -4
  492. package/src/types/assets.ts +20 -0
  493. package/src/types/index.ts +20 -1
  494. package/lib/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
  495. package/lib/__tests__/bridge/buildTransaction.test.js +0 -53
  496. package/lib/__tests__/bridge/buildTransaction.test.js.map +0 -1
  497. package/lib/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
  498. package/lib/__tests__/bridge/createTransaction.test.js.map +0 -1
  499. package/lib/api/graphql/queries.d.ts.map +0 -1
  500. package/lib/api/graphql/queries.js.map +0 -1
  501. package/lib/api/graphql/types.d.ts.map +0 -1
  502. package/lib/bridge/buildTransaction.d.ts +0 -7
  503. package/lib/bridge/buildTransaction.d.ts.map +0 -1
  504. package/lib/bridge/buildTransaction.js +0 -19
  505. package/lib/bridge/buildTransaction.js.map +0 -1
  506. package/lib/bridge/createTransaction.d.ts.map +0 -1
  507. package/lib/bridge/createTransaction.js.map +0 -1
  508. package/lib-es/__tests__/bridge/buildTransaction.test.d.ts.map +0 -1
  509. package/lib-es/__tests__/bridge/buildTransaction.test.js +0 -48
  510. package/lib-es/__tests__/bridge/buildTransaction.test.js.map +0 -1
  511. package/lib-es/__tests__/bridge/createTransaction.test.d.ts.map +0 -1
  512. package/lib-es/__tests__/bridge/createTransaction.test.js.map +0 -1
  513. package/lib-es/api/graphql/queries.d.ts.map +0 -1
  514. package/lib-es/api/graphql/queries.js.map +0 -1
  515. package/lib-es/api/graphql/types.d.ts.map +0 -1
  516. package/lib-es/bridge/buildTransaction.d.ts +0 -7
  517. package/lib-es/bridge/buildTransaction.d.ts.map +0 -1
  518. package/lib-es/bridge/buildTransaction.js +0 -17
  519. package/lib-es/bridge/buildTransaction.js.map +0 -1
  520. package/lib-es/bridge/createTransaction.d.ts.map +0 -1
  521. package/lib-es/bridge/createTransaction.js.map +0 -1
  522. package/src/__tests__/bridge/buildTransaction.test.ts +0 -61
  523. package/src/bridge/buildTransaction.ts +0 -29
  524. /package/lib/__tests__/{bridge → logic}/buildTransaction.test.d.ts +0 -0
  525. /package/lib/__tests__/{bridge → logic}/createTransaction.test.d.ts +0 -0
  526. /package/lib/{bridge → logic}/createTransaction.d.ts +0 -0
  527. /package/lib/{api → network}/graphql/queries.d.ts +0 -0
  528. /package/lib/{api → network}/graphql/types.js +0 -0
  529. /package/lib-es/__tests__/{bridge → logic}/buildTransaction.test.d.ts +0 -0
  530. /package/lib-es/__tests__/{bridge → logic}/createTransaction.test.d.ts +0 -0
  531. /package/lib-es/{bridge → logic}/createTransaction.d.ts +0 -0
  532. /package/lib-es/{api → network}/graphql/queries.d.ts +0 -0
  533. /package/lib-es/{api → network}/graphql/types.js +0 -0
@@ -0,0 +1,1257 @@
1
+ import { ApolloClient } from "@apollo/client";
2
+ import {
3
+ AccountAddress,
4
+ Aptos,
5
+ ChainId,
6
+ Ed25519PublicKey,
7
+ Hex,
8
+ InputEntryFunctionData,
9
+ RawTransaction,
10
+ Serializable,
11
+ postAptosFullNode,
12
+ TransactionResponseType,
13
+ } from "@aptos-labs/ts-sdk";
14
+ import network from "@ledgerhq/live-network";
15
+ import BigNumber from "bignumber.js";
16
+ import { AptosAPI } from "../../network";
17
+ import { AptosAsset, AptosExtra, AptosSender } from "../../types/assets";
18
+ import { Pagination, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
19
+ import { TokenCurrency } from "@ledgerhq/types-cryptoassets";
20
+ import { APTOS_ASSET_ID } from "../../constants";
21
+ import { AptosTransaction } from "../../types";
22
+
23
+ jest.mock("@aptos-labs/ts-sdk");
24
+ jest.mock("@apollo/client");
25
+ let mockedAptos: jest.Mocked<any>;
26
+ let mockedApolloClient: jest.Mocked<any>;
27
+ let mockedPost = jest.fn();
28
+ let mockedHex: jest.Mocked<any>;
29
+
30
+ jest.mock("@ledgerhq/live-network/network");
31
+ const mockedNetwork = jest.mocked(network);
32
+
33
+ jest.mock("@ledgerhq/cryptoassets/tokens", () => ({
34
+ findTokenByAddressInCurrency: jest.fn().mockReturnValue("token-name"),
35
+ }));
36
+
37
+ describe("Aptos API", () => {
38
+ beforeEach(() => {
39
+ mockedAptos = jest.mocked(Aptos);
40
+ mockedHex = jest.mocked(Hex);
41
+ mockedApolloClient = jest.mocked(ApolloClient);
42
+ mockedPost = jest.mocked(postAptosFullNode);
43
+ });
44
+
45
+ afterEach(() => jest.clearAllMocks());
46
+
47
+ it("builds the client properly for mainnet", () => {
48
+ const api = new AptosAPI("aptos");
49
+
50
+ expect(api.broadcast).toBeDefined();
51
+ expect(typeof api.broadcast).toBe("function");
52
+ expect(api.estimateGasPrice).toBeDefined();
53
+ expect(typeof api.estimateGasPrice).toBe("function");
54
+ expect(api.generateTransaction).toBeDefined();
55
+ expect(typeof api.generateTransaction).toBe("function");
56
+ expect(api.getAccount).toBeDefined();
57
+ expect(typeof api.getAccount).toBe("function");
58
+ expect(api.getAccountInfo).toBeDefined();
59
+ expect(typeof api.getAccountInfo).toBe("function");
60
+ expect(api.simulateTransaction).toBeDefined();
61
+ expect(typeof api.simulateTransaction).toBe("function");
62
+ });
63
+
64
+ it("builds the client properly for testnet", () => {
65
+ const api = new AptosAPI("aptos_testnet");
66
+
67
+ expect(api.broadcast).toBeDefined();
68
+ expect(typeof api.broadcast).toBe("function");
69
+ expect(api.estimateGasPrice).toBeDefined();
70
+ expect(typeof api.estimateGasPrice).toBe("function");
71
+ expect(api.generateTransaction).toBeDefined();
72
+ expect(typeof api.generateTransaction).toBe("function");
73
+ expect(api.getAccount).toBeDefined();
74
+ expect(typeof api.getAccount).toBe("function");
75
+ expect(api.getAccountInfo).toBeDefined();
76
+ expect(typeof api.getAccountInfo).toBe("function");
77
+ expect(api.simulateTransaction).toBeDefined();
78
+ expect(typeof api.simulateTransaction).toBe("function");
79
+ });
80
+
81
+ describe("getAccount", () => {
82
+ it("calls getAccountInfo", async () => {
83
+ const mockGetAccountInfo = jest.fn();
84
+ mockedAptos.mockImplementation(() => ({
85
+ getAccountInfo: mockGetAccountInfo,
86
+ }));
87
+
88
+ const mockGetAccountSpy = jest.spyOn({ getAccount: mockGetAccountInfo }, "getAccount");
89
+
90
+ const api = new AptosAPI("aptos");
91
+ await api.getAccount("address");
92
+
93
+ expect(mockGetAccountSpy).toHaveBeenCalledWith({
94
+ accountAddress: "address",
95
+ });
96
+ });
97
+ });
98
+
99
+ describe("getBalance", () => {
100
+ let token: TokenCurrency;
101
+
102
+ beforeEach(() => {
103
+ token = {
104
+ type: "TokenCurrency",
105
+ id: "aptos_token",
106
+ name: "Aptos Token",
107
+ ticker: "APT",
108
+ units: [{ name: "APT", code: "APT", magnitude: 6 }],
109
+ contractAddress: "APTOS_1_ADDRESS",
110
+ tokenType: "fungible_asset",
111
+ parentCurrency: {
112
+ type: "CryptoCurrency",
113
+ id: "aptos",
114
+ name: "Aptos",
115
+ ticker: "APT",
116
+ units: [{ name: "APT", code: "APT", magnitude: 6 }],
117
+ color: "#000000",
118
+ family: "aptos",
119
+ scheme: "aptos",
120
+ explorerViews: [],
121
+ managerAppName: "Aptos",
122
+ coinType: 637,
123
+ },
124
+ };
125
+ });
126
+
127
+ it("get coin balance", async () => {
128
+ mockedAptos.mockImplementation(() => ({
129
+ view: jest.fn().mockReturnValue(["1234"]),
130
+ }));
131
+
132
+ token.tokenType = "coin";
133
+ const api = new AptosAPI("aptos");
134
+ const balance = await api.getBalance("address", token);
135
+
136
+ expect(balance).toEqual(new BigNumber(1234));
137
+ });
138
+
139
+ it("get fungible assets balance", async () => {
140
+ mockedAptos.mockImplementation(() => ({
141
+ view: jest.fn().mockReturnValue(["12345"]),
142
+ }));
143
+
144
+ token.tokenType = "fungible_asset";
145
+
146
+ const api = new AptosAPI("aptos");
147
+ const balance = await api.getBalance("address", token);
148
+
149
+ expect(balance).toEqual(new BigNumber(12345));
150
+ });
151
+
152
+ it("return 0 balace if could not retrieve proper balance of fungible assets", async () => {
153
+ mockedAptos.mockImplementation(() => ({
154
+ view: jest.fn().mockImplementation(() => {
155
+ throw new Error("error");
156
+ }),
157
+ }));
158
+
159
+ token.tokenType = "fungible_asset";
160
+
161
+ const api = new AptosAPI("aptos");
162
+ const balance = await api.getBalance("address", token);
163
+
164
+ expect(balance).toEqual(new BigNumber(0));
165
+ });
166
+ });
167
+
168
+ describe("getAccountInfo", () => {
169
+ it("calls getCoinBalance, fetchTransactions and getHeight", async () => {
170
+ mockedAptos.mockImplementation(() => ({
171
+ view: jest.fn().mockReturnValue(["123"]),
172
+ getTransactionByVersion: jest.fn().mockReturnValue({
173
+ type: "user_transaction",
174
+ version: "v1",
175
+ }),
176
+ getBlockByVersion: jest.fn().mockReturnValue({
177
+ block_height: "1",
178
+ block_hash: "83ca6d",
179
+ }),
180
+ }));
181
+
182
+ mockedNetwork.mockResolvedValue(
183
+ Promise.resolve({
184
+ data: {
185
+ account: {
186
+ account_number: 1,
187
+ sequence: 0,
188
+ pub_key: { key: "k", "@type": "type" },
189
+ base_account: {
190
+ account_number: 2,
191
+ sequence: 42,
192
+ pub_key: { key: "k2", "@type": "type2" },
193
+ },
194
+ },
195
+ block_height: "999",
196
+ },
197
+ status: 200,
198
+ headers: {} as any,
199
+ statusText: "",
200
+ config: {
201
+ headers: {} as any,
202
+ },
203
+ }),
204
+ );
205
+
206
+ mockedApolloClient.mockImplementation(() => ({
207
+ query: async () => ({
208
+ data: {
209
+ account_transactions: [{ transaction_version: 1 }],
210
+ },
211
+ loading: false,
212
+ networkStatus: 7,
213
+ }),
214
+ }));
215
+
216
+ const api = new AptosAPI("aptos");
217
+ const accountInfo = await api.getAccountInfo("APTOS_1_ADDRESS", "1");
218
+
219
+ expect(accountInfo.balance).toEqual(new BigNumber(123));
220
+ expect(accountInfo.transactions).toEqual([
221
+ {
222
+ type: "user_transaction",
223
+ version: "v1",
224
+ block: {
225
+ height: 1,
226
+ hash: "83ca6d",
227
+ },
228
+ },
229
+ ]);
230
+ expect(accountInfo.blockHeight).toEqual(999);
231
+ });
232
+
233
+ it("return balance = 0 if it fails to fetch balance", async () => {
234
+ mockedAptos.mockImplementation(() => ({
235
+ view: jest.fn().mockImplementation(() => {
236
+ throw new Error("error");
237
+ }),
238
+ getTransactionByVersion: jest.fn().mockReturnValue({
239
+ type: "user_transaction",
240
+ version: "v1",
241
+ }),
242
+ getBlockByVersion: jest.fn().mockReturnValue({
243
+ block_height: "1",
244
+ block_hash: "83ca6d",
245
+ }),
246
+ }));
247
+
248
+ mockedNetwork.mockResolvedValue(
249
+ Promise.resolve({
250
+ data: {
251
+ account: {
252
+ account_number: 1,
253
+ sequence: 0,
254
+ pub_key: { key: "k", "@type": "type" },
255
+ base_account: {
256
+ account_number: 2,
257
+ sequence: 42,
258
+ pub_key: { key: "k2", "@type": "type2" },
259
+ },
260
+ },
261
+ block_height: "999",
262
+ },
263
+ status: 200,
264
+ headers: {} as any,
265
+ statusText: "",
266
+ config: {
267
+ headers: {} as any,
268
+ },
269
+ }),
270
+ );
271
+
272
+ mockedApolloClient.mockImplementation(() => ({
273
+ query: async () => ({
274
+ data: {
275
+ account_transactions: [{ transaction_version: 1 }],
276
+ },
277
+ loading: false,
278
+ networkStatus: 7,
279
+ }),
280
+ }));
281
+
282
+ const api = new AptosAPI("aptos");
283
+ const accountInfo = await api.getAccountInfo("APTOS_1_ADDRESS", "1");
284
+
285
+ expect(accountInfo.balance).toEqual(new BigNumber(0));
286
+ expect(accountInfo.transactions).toEqual([
287
+ {
288
+ type: "user_transaction",
289
+ version: "v1",
290
+ block: {
291
+ height: 1,
292
+ hash: "83ca6d",
293
+ },
294
+ },
295
+ ]);
296
+ expect(accountInfo.blockHeight).toEqual(999);
297
+ });
298
+
299
+ it("returns no transactions if it the address is empty", async () => {
300
+ mockedAptos.mockImplementation(() => ({
301
+ view: jest.fn().mockReturnValue(["123"]),
302
+ getTransactionByVersion: jest.fn().mockReturnValue({
303
+ type: "user_transaction",
304
+ version: "v1",
305
+ }),
306
+ getBlockByVersion: jest.fn().mockReturnValue({
307
+ block_height: "1",
308
+ block_hash: "83ca6d",
309
+ }),
310
+ }));
311
+
312
+ mockedNetwork.mockResolvedValue(
313
+ Promise.resolve({
314
+ data: {
315
+ account: {
316
+ account_number: 1,
317
+ sequence: 0,
318
+ pub_key: { key: "k", "@type": "type" },
319
+ base_account: {
320
+ account_number: 2,
321
+ sequence: 42,
322
+ pub_key: { key: "k2", "@type": "type2" },
323
+ },
324
+ },
325
+ block_height: "999",
326
+ },
327
+ status: 200,
328
+ headers: {} as any,
329
+ statusText: "",
330
+ config: {
331
+ headers: {} as any,
332
+ },
333
+ }),
334
+ );
335
+
336
+ mockedApolloClient.mockImplementation(() => ({
337
+ query: async () => ({
338
+ data: {
339
+ account_transactions: [{ transaction_version: 1 }],
340
+ },
341
+ loading: false,
342
+ networkStatus: 7,
343
+ }),
344
+ }));
345
+
346
+ const api = new AptosAPI("aptos");
347
+ const accountInfo = await api.getAccountInfo("", "1");
348
+
349
+ expect(accountInfo.balance).toEqual(new BigNumber(123));
350
+ expect(accountInfo.transactions).toEqual([]);
351
+ expect(accountInfo.blockHeight).toEqual(999);
352
+ });
353
+
354
+ it("returns a null transaction if it fails to getTransactionByVersion", async () => {
355
+ mockedAptos.mockImplementation(() => ({
356
+ view: jest.fn().mockReturnValue(["123"]),
357
+ getTransactionByVersion: jest.fn().mockImplementation(() => {
358
+ throw new Error("error");
359
+ }),
360
+ getBlockByVersion: jest.fn().mockReturnValue({
361
+ block_height: "1",
362
+ block_hash: "83ca6d",
363
+ }),
364
+ }));
365
+
366
+ mockedNetwork.mockResolvedValue(
367
+ Promise.resolve({
368
+ data: {
369
+ account: {
370
+ account_number: 1,
371
+ sequence: 0,
372
+ pub_key: { key: "k", "@type": "type" },
373
+ base_account: {
374
+ account_number: 2,
375
+ sequence: 42,
376
+ pub_key: { key: "k2", "@type": "type2" },
377
+ },
378
+ },
379
+ block_height: "999",
380
+ },
381
+ status: 200,
382
+ headers: {} as any,
383
+ statusText: "",
384
+ config: {
385
+ headers: {} as any,
386
+ },
387
+ }),
388
+ );
389
+
390
+ mockedApolloClient.mockImplementation(() => ({
391
+ query: async () => ({
392
+ data: {
393
+ account_transactions: [{ transaction_version: 1 }],
394
+ },
395
+ loading: false,
396
+ networkStatus: 7,
397
+ }),
398
+ }));
399
+
400
+ const api = new AptosAPI("aptos");
401
+ const accountInfo = await api.getAccountInfo("APTOS_1_ADDRESS", "1");
402
+
403
+ expect(accountInfo.balance).toEqual(new BigNumber(123));
404
+ expect(accountInfo.transactions).toEqual([null]);
405
+ expect(accountInfo.blockHeight).toEqual(999);
406
+ });
407
+ });
408
+
409
+ describe("estimateGasPrice", () => {
410
+ it("estimates the gas price", async () => {
411
+ const gasEstimation = { gas_estimate: 100 };
412
+ mockedAptos.mockImplementation(() => ({
413
+ getGasPriceEstimation: jest.fn().mockReturnValue(gasEstimation),
414
+ }));
415
+
416
+ const api = new AptosAPI("aptos");
417
+ const gasPrice = await api.estimateGasPrice();
418
+
419
+ expect(gasPrice.gas_estimate).toEqual(100);
420
+ });
421
+ });
422
+
423
+ describe("generateTransaction", () => {
424
+ const payload: InputEntryFunctionData = {
425
+ function: "0x1::coin::transfer",
426
+ functionArguments: ["0x13", 1],
427
+ };
428
+
429
+ it("generates a transaction without expireTimestamp", async () => {
430
+ const options = {
431
+ maxGasAmount: "100",
432
+ gasUnitPrice: "50",
433
+ };
434
+
435
+ const mockSimple = jest.fn().mockImplementation(async () => ({
436
+ rawTransaction: null,
437
+ }));
438
+ mockedAptos.mockImplementation(() => ({
439
+ transaction: {
440
+ build: {
441
+ simple: mockSimple,
442
+ },
443
+ },
444
+ }));
445
+
446
+ const mockSimpleSpy = jest.spyOn({ simple: mockSimple }, "simple");
447
+
448
+ const api = new AptosAPI("aptos");
449
+ await api.generateTransaction("APTOS_1_ADDRESS", payload, options);
450
+
451
+ expect(mockSimpleSpy).toHaveBeenCalledWith({
452
+ data: payload,
453
+ options: {
454
+ maxGasAmount: Number(options.maxGasAmount),
455
+ gasUnitPrice: Number(options.gasUnitPrice),
456
+ },
457
+ sender: "APTOS_1_ADDRESS",
458
+ });
459
+ });
460
+
461
+ it("generates a transaction with default expireTimestamp", async () => {
462
+ const options = {
463
+ maxGasAmount: "100",
464
+ gasUnitPrice: "50",
465
+ };
466
+
467
+ const mockSimple = jest.fn().mockImplementation(async () => ({
468
+ rawTransaction: null,
469
+ }));
470
+ const mockGetLedgerInfo = jest.fn().mockImplementation(async () => ({
471
+ ledger_timestamp: "0",
472
+ }));
473
+ mockedAptos.mockImplementation(() => ({
474
+ transaction: {
475
+ build: {
476
+ simple: mockSimple,
477
+ },
478
+ },
479
+ getLedgerInfo: mockGetLedgerInfo,
480
+ }));
481
+
482
+ const mockSimpleSpy = jest.spyOn({ simple: mockSimple }, "simple");
483
+
484
+ const api = new AptosAPI("aptos");
485
+ await api.generateTransaction("APTOS_1_ADDRESS", payload, options);
486
+
487
+ expect(mockSimpleSpy).toHaveBeenCalledWith({
488
+ data: payload,
489
+ options: {
490
+ maxGasAmount: Number(options.maxGasAmount),
491
+ gasUnitPrice: Number(options.gasUnitPrice),
492
+ expireTimestamp: 120,
493
+ },
494
+ sender: "APTOS_1_ADDRESS",
495
+ });
496
+ });
497
+
498
+ it("throws an error when failing to build a transaction", async () => {
499
+ const options = {
500
+ maxGasAmount: "100",
501
+ gasUnitPrice: "50",
502
+ };
503
+
504
+ const mockSimple = jest.fn().mockImplementation(async () => null);
505
+ mockedAptos.mockImplementation(() => ({
506
+ transaction: {
507
+ build: {
508
+ simple: mockSimple,
509
+ },
510
+ },
511
+ }));
512
+
513
+ const api = new AptosAPI("aptos");
514
+ expect(
515
+ async () => await api.generateTransaction("APTOS_1_ADDRESS", payload, options),
516
+ ).rejects.toThrow();
517
+ });
518
+ });
519
+
520
+ describe("simulateTransaction", () => {
521
+ it("simulates a transaction with the correct options", async () => {
522
+ const mockSimple = jest.fn().mockImplementation(async () => ({
523
+ rawTransaction: null,
524
+ }));
525
+ mockedAptos.mockImplementation(() => ({
526
+ transaction: {
527
+ simulate: {
528
+ simple: mockSimple,
529
+ },
530
+ },
531
+ }));
532
+
533
+ const mockSimpleSpy = jest.spyOn({ simple: mockSimple }, "simple");
534
+
535
+ const api = new AptosAPI("aptos");
536
+ const address = new Ed25519PublicKey("APTOS_1_ADDRESS");
537
+ const tx = new RawTransaction(
538
+ new AccountAddress(Uint8Array.from(Buffer.from("APTOS_2_ADDRESS"))),
539
+ BigInt(1),
540
+ "" as unknown as Serializable,
541
+ BigInt(100),
542
+ BigInt(50),
543
+ BigInt(1),
544
+ { chainId: 1 } as ChainId,
545
+ );
546
+ await api.simulateTransaction(address, tx);
547
+
548
+ expect(mockSimpleSpy).toHaveBeenCalledWith({
549
+ signerPublicKey: address,
550
+ transaction: { rawTransaction: tx },
551
+ options: {
552
+ estimateGasUnitPrice: true,
553
+ estimateMaxGasAmount: true,
554
+ estimatePrioritizedGasUnitPrice: false,
555
+ },
556
+ });
557
+ });
558
+ });
559
+
560
+ describe("broadcast", () => {
561
+ it("broadcasts the transaction", async () => {
562
+ mockedPost.mockImplementation(async () => ({ data: { hash: "ok" } }));
563
+ const mockedPostSpy = jest.spyOn({ postAptosFullNode: mockedPost }, "postAptosFullNode");
564
+
565
+ // const txBytes = Hex.fromHexString(tx).toUint8Array();
566
+ mockedAptos.mockImplementation(() => ({
567
+ config: "config",
568
+ }));
569
+
570
+ mockedHex.fromHexString = jest.fn().mockReturnValue({ toUint8Array: () => "123" });
571
+
572
+ const api = new AptosAPI("aptos");
573
+
574
+ await api.broadcast("signed transaction");
575
+
576
+ expect(mockedPostSpy).toHaveBeenCalledWith({
577
+ aptosConfig: "config",
578
+ body: "123",
579
+ path: "transactions",
580
+ originMethod: "",
581
+ contentType: "application/x.aptos.signed_transaction+bcs",
582
+ });
583
+ });
584
+ });
585
+
586
+ describe("estimateFees", () => {
587
+ it("estimates the fees for native asset", async () => {
588
+ const gasEstimation = { gas_estimate: 100 };
589
+ const buildSimple = jest.fn().mockResolvedValue({ rawTransaction: {} });
590
+
591
+ const time = new Date("2025-05-29");
592
+ jest.useFakeTimers().setSystemTime(time);
593
+
594
+ mockedAptos.mockImplementation(() => ({
595
+ getLedgerInfo: jest.fn().mockResolvedValue({
596
+ ledger_timestamp: time,
597
+ }),
598
+ transaction: {
599
+ build: {
600
+ simple: buildSimple,
601
+ },
602
+ simulate: {
603
+ simple: jest.fn().mockResolvedValue([
604
+ {
605
+ gas_used: 10,
606
+ gas_unit_price: 4,
607
+ },
608
+ ]),
609
+ },
610
+ },
611
+ getGasPriceEstimation: jest.fn().mockReturnValue(gasEstimation),
612
+ }));
613
+
614
+ const amount = BigInt(100);
615
+ const sender: AptosSender = {
616
+ xpub: "xpub",
617
+ freshAddress: "address1",
618
+ };
619
+ const recipient = "address2";
620
+
621
+ const api = new AptosAPI("aptos");
622
+ const transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
623
+ asset: {
624
+ type: "native",
625
+ },
626
+ type: "send",
627
+ sender,
628
+ amount,
629
+ recipient,
630
+ };
631
+
632
+ const fees = await api.estimateFees(transactionIntent);
633
+
634
+ expect(buildSimple.mock.calls[0][0]).toEqual({
635
+ sender: "address1",
636
+ data: {
637
+ function: "0x1::aptos_account::transfer_coins",
638
+ typeArguments: ["0x1::aptos_coin::AptosCoin"],
639
+ functionArguments: ["address2", 100n],
640
+ },
641
+ options: {
642
+ maxGasAmount: 200,
643
+ gasUnitPrice: 100,
644
+ expireTimestamp: Number(Math.ceil(+time / 1_000_000 + 2 * 60)),
645
+ },
646
+ });
647
+
648
+ expect(fees.value.toString()).toEqual("40");
649
+ });
650
+
651
+ it("estimates the fees for token coin", async () => {
652
+ const gasEstimation = { gas_estimate: 100 };
653
+ const buildSimple = jest.fn().mockResolvedValue({ rawTransaction: {} });
654
+
655
+ const time = new Date("2025-05-29");
656
+ jest.useFakeTimers().setSystemTime(time);
657
+
658
+ mockedAptos.mockImplementation(() => ({
659
+ getLedgerInfo: jest.fn().mockResolvedValue({
660
+ ledger_timestamp: time,
661
+ }),
662
+ transaction: {
663
+ build: {
664
+ simple: buildSimple,
665
+ },
666
+ simulate: {
667
+ simple: jest.fn().mockResolvedValue([
668
+ {
669
+ gas_used: 10,
670
+ gas_unit_price: 2,
671
+ },
672
+ ]),
673
+ },
674
+ },
675
+ getGasPriceEstimation: jest.fn().mockReturnValue(gasEstimation),
676
+ }));
677
+
678
+ const amount = BigInt(100);
679
+ const sender: AptosSender = {
680
+ xpub: "xpub",
681
+ freshAddress: "address1",
682
+ };
683
+ const recipient = "address2";
684
+
685
+ const api = new AptosAPI("aptos");
686
+ const transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
687
+ asset: {
688
+ type: "token",
689
+ standard: "coin",
690
+ contractAddress: "0x111",
691
+ },
692
+ type: "send",
693
+ sender,
694
+ amount,
695
+ recipient,
696
+ };
697
+
698
+ const fees = await api.estimateFees(transactionIntent);
699
+
700
+ expect(buildSimple.mock.calls[0][0]).toEqual({
701
+ sender: "address1",
702
+ data: {
703
+ function: "0x1::aptos_account::transfer_coins",
704
+ typeArguments: ["0x111"],
705
+ functionArguments: ["address2", 100n],
706
+ },
707
+ options: {
708
+ maxGasAmount: 200,
709
+ gasUnitPrice: 100,
710
+ expireTimestamp: Number(Math.ceil(+time / 1_000_000 + 2 * 60)),
711
+ },
712
+ });
713
+
714
+ expect(fees.value.toString()).toEqual("20");
715
+ });
716
+
717
+ it("estimates the fees for token FA", async () => {
718
+ const gasEstimation = { gas_estimate: 100 };
719
+ const buildSimple = jest.fn().mockResolvedValue({ rawTransaction: {} });
720
+ const time = new Date("2025-05-29");
721
+ jest.useFakeTimers().setSystemTime(time);
722
+
723
+ mockedAptos.mockImplementation(() => ({
724
+ getLedgerInfo: jest.fn().mockResolvedValue({
725
+ ledger_timestamp: time,
726
+ }),
727
+ transaction: {
728
+ build: {
729
+ simple: buildSimple,
730
+ },
731
+ simulate: {
732
+ simple: jest.fn().mockResolvedValue([
733
+ {
734
+ gas_used: 10,
735
+ gas_unit_price: 3,
736
+ },
737
+ ]),
738
+ },
739
+ },
740
+ getGasPriceEstimation: jest.fn().mockReturnValue(gasEstimation),
741
+ }));
742
+
743
+ const amount = BigInt(100);
744
+ const sender: AptosSender = {
745
+ xpub: "xpub",
746
+ freshAddress: "address1",
747
+ };
748
+ const recipient = "address2";
749
+
750
+ const api = new AptosAPI("aptos");
751
+ const transactionIntent: TransactionIntent<AptosAsset, AptosExtra, AptosSender> = {
752
+ asset: {
753
+ type: "token",
754
+ standard: "fungible_asset",
755
+ contractAddress: "0x111",
756
+ },
757
+ type: "send",
758
+ sender,
759
+ amount,
760
+ recipient,
761
+ };
762
+
763
+ const fees = await api.estimateFees(transactionIntent);
764
+
765
+ expect(buildSimple.mock.calls[0][0]).toEqual({
766
+ sender: "address1",
767
+ data: {
768
+ function: "0x1::primary_fungible_store::transfer",
769
+ typeArguments: ["0x1::fungible_asset::Metadata"],
770
+ functionArguments: ["0x111", "address2", 100n],
771
+ },
772
+ options: {
773
+ maxGasAmount: 200,
774
+ gasUnitPrice: 100,
775
+ expireTimestamp: Number(Math.ceil(+time / 1_000_000 + 2 * 60)),
776
+ },
777
+ });
778
+
779
+ expect(fees.value.toString()).toEqual("30");
780
+ });
781
+ });
782
+
783
+ describe("getBalances", () => {
784
+ it("returns an array of AptosBalances objects", async () => {
785
+ const assets = [{ asset_type: APTOS_ASSET_ID, amount: 200 }];
786
+ const mockGetCurrentFungibleAssetBalances = jest.fn().mockResolvedValue(assets);
787
+ mockedAptos.mockImplementation(() => ({
788
+ getCurrentFungibleAssetBalances: mockGetCurrentFungibleAssetBalances,
789
+ }));
790
+
791
+ const address = "0x42";
792
+
793
+ const api = new AptosAPI("aptos");
794
+ const balances = await api.getBalances(address);
795
+
796
+ expect(mockGetCurrentFungibleAssetBalances).toHaveBeenCalledWith({
797
+ options: {
798
+ offset: 0,
799
+ limit: 1000,
800
+ where: {
801
+ asset_type: { _eq: APTOS_ASSET_ID },
802
+ owner_address: { _eq: address },
803
+ },
804
+ },
805
+ });
806
+ expect(balances).toHaveLength(1);
807
+ expect(balances[0].contractAddress).toBe(assets[0].asset_type);
808
+ expect(balances[0].amount).toStrictEqual(BigNumber(assets[0].amount));
809
+ });
810
+ });
811
+
812
+ describe("listOperations", () => {
813
+ it("list of operations", async () => {
814
+ const api = new AptosAPI("aptos");
815
+ const address = "0x12345";
816
+ const pagination: Pagination = { minHeight: 0 };
817
+
818
+ const txs: AptosTransaction[] = [
819
+ {
820
+ version: "2532591427",
821
+ hash: "0x3f35",
822
+ state_change_hash: "0xb480",
823
+ event_root_hash: "0x3fa1",
824
+ state_checkpoint_hash: null,
825
+ gas_used: "12",
826
+ success: true,
827
+ vm_status: "Executed successfully",
828
+ accumulator_root_hash: "0x319f",
829
+ changes: [
830
+ {
831
+ address: "0x4e5e",
832
+ state_key_hash: "0x3c0c",
833
+ data: {
834
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
835
+ data: {
836
+ coin: {
837
+ value: "4000000",
838
+ },
839
+ deposit_events: {
840
+ counter: "9",
841
+ guid: {
842
+ id: {
843
+ addr: "0x4e5e",
844
+ creation_num: "4",
845
+ },
846
+ },
847
+ },
848
+ frozen: false,
849
+ withdraw_events: {
850
+ counter: "6",
851
+ guid: {
852
+ id: {
853
+ addr: "0x4e5e",
854
+ creation_num: "5",
855
+ },
856
+ },
857
+ },
858
+ },
859
+ },
860
+ type: "write_resource",
861
+ },
862
+ {
863
+ address: address,
864
+ state_key_hash: "0x1709",
865
+ data: {
866
+ type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
867
+ data: {
868
+ coin: {
869
+ value: "68254118",
870
+ },
871
+ deposit_events: {
872
+ counter: "46",
873
+ guid: {
874
+ id: {
875
+ addr: address,
876
+ creation_num: "2",
877
+ },
878
+ },
879
+ },
880
+ frozen: false,
881
+ withdraw_events: {
882
+ counter: "89",
883
+ guid: {
884
+ id: {
885
+ addr: address,
886
+ creation_num: "3",
887
+ },
888
+ },
889
+ },
890
+ },
891
+ },
892
+ type: "write_resource",
893
+ },
894
+ {
895
+ address: address,
896
+ state_key_hash: "0x5520",
897
+ data: {
898
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
899
+ data: {
900
+ coin: {
901
+ value: "1000000",
902
+ },
903
+ deposit_events: {
904
+ counter: "7",
905
+ guid: {
906
+ id: {
907
+ addr: address,
908
+ creation_num: "10",
909
+ },
910
+ },
911
+ },
912
+ frozen: false,
913
+ withdraw_events: {
914
+ counter: "13",
915
+ guid: {
916
+ id: {
917
+ addr: address,
918
+ creation_num: "11",
919
+ },
920
+ },
921
+ },
922
+ },
923
+ },
924
+ type: "write_resource",
925
+ },
926
+ {
927
+ address: address,
928
+ state_key_hash: "0x6f1e",
929
+ data: {
930
+ type: "0x1::account::Account",
931
+ data: {
932
+ authentication_key: address,
933
+ coin_register_events: {
934
+ counter: "5",
935
+ guid: {
936
+ id: {
937
+ addr: address,
938
+ creation_num: "0",
939
+ },
940
+ },
941
+ },
942
+ guid_creation_num: "12",
943
+ key_rotation_events: {
944
+ counter: "0",
945
+ guid: {
946
+ id: {
947
+ addr: address,
948
+ creation_num: "1",
949
+ },
950
+ },
951
+ },
952
+ rotation_capability_offer: {
953
+ for: {
954
+ vec: [],
955
+ },
956
+ },
957
+ sequence_number: "122",
958
+ signer_capability_offer: {
959
+ for: {
960
+ vec: [],
961
+ },
962
+ },
963
+ },
964
+ },
965
+ type: "write_resource",
966
+ },
967
+ {
968
+ state_key_hash: "0x6e4b",
969
+ handle: "0x1b85",
970
+ key: "0x0619",
971
+ value: "0x1ddaf8da3b1497010000000000000000",
972
+ type: "write_table_item",
973
+ },
974
+ ],
975
+ sender: address,
976
+ sequence_number: "121",
977
+ max_gas_amount: "12",
978
+ gas_unit_price: "100",
979
+ expiration_timestamp_secs: "1743177404",
980
+ payload: {
981
+ function: "0x1::aptos_account::transfer_coins",
982
+ type_arguments: ["0xd111::staked_coin::StakedAptos"],
983
+ arguments: ["0x4e5e", "1500000"],
984
+ type: "entry_function_payload",
985
+ },
986
+ events: [
987
+ {
988
+ guid: {
989
+ creation_number: "11",
990
+ account_address: address,
991
+ },
992
+ sequence_number: "12",
993
+ type: "0x1::coin::WithdrawEvent",
994
+ data: {
995
+ amount: "1500000",
996
+ },
997
+ },
998
+ {
999
+ guid: {
1000
+ creation_number: "4",
1001
+ account_address: "0x4e5e",
1002
+ },
1003
+ sequence_number: "8",
1004
+ type: "0x1::coin::DepositEvent",
1005
+ data: {
1006
+ amount: "1500000",
1007
+ },
1008
+ },
1009
+ {
1010
+ guid: {
1011
+ creation_number: "0",
1012
+ account_address: "0x0",
1013
+ },
1014
+ sequence_number: "0",
1015
+ type: "0x1::transaction_fee::FeeStatement",
1016
+ data: {
1017
+ execution_gas_units: "6",
1018
+ io_gas_units: "6",
1019
+ storage_fee_octas: "0",
1020
+ storage_fee_refund_octas: "0",
1021
+ total_charge_gas_units: "12",
1022
+ },
1023
+ },
1024
+ ],
1025
+ timestamp: "1743177360481259",
1026
+ type: TransactionResponseType.User,
1027
+ block: {
1028
+ height: 311948147,
1029
+ hash: "0x6d02",
1030
+ },
1031
+ },
1032
+ {
1033
+ version: "2532549325",
1034
+ hash: "0x9a6b",
1035
+ state_change_hash: "0xa424",
1036
+ event_root_hash: "0x0321",
1037
+ state_checkpoint_hash: null,
1038
+ gas_used: "12",
1039
+ success: true,
1040
+ vm_status: "Executed successfully",
1041
+ accumulator_root_hash: "0xede9",
1042
+ changes: [
1043
+ {
1044
+ address: "0x4e5e",
1045
+ state_key_hash: "0x3c0c",
1046
+ data: {
1047
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
1048
+ data: {
1049
+ coin: {
1050
+ value: "2500000",
1051
+ },
1052
+ deposit_events: {
1053
+ counter: "8",
1054
+ guid: {
1055
+ id: {
1056
+ addr: "0x4e5e",
1057
+ creation_num: "4",
1058
+ },
1059
+ },
1060
+ },
1061
+ frozen: false,
1062
+ withdraw_events: {
1063
+ counter: "6",
1064
+ guid: {
1065
+ id: {
1066
+ addr: "0x4e5e",
1067
+ creation_num: "5",
1068
+ },
1069
+ },
1070
+ },
1071
+ },
1072
+ },
1073
+ type: "write_resource",
1074
+ },
1075
+ {
1076
+ address: address,
1077
+ state_key_hash: "0x1709",
1078
+ data: {
1079
+ type: "0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>",
1080
+ data: {
1081
+ coin: {
1082
+ value: "68255318",
1083
+ },
1084
+ deposit_events: {
1085
+ counter: "46",
1086
+ guid: {
1087
+ id: {
1088
+ addr: address,
1089
+ creation_num: "2",
1090
+ },
1091
+ },
1092
+ },
1093
+ frozen: false,
1094
+ withdraw_events: {
1095
+ counter: "89",
1096
+ guid: {
1097
+ id: {
1098
+ addr: address,
1099
+ creation_num: "3",
1100
+ },
1101
+ },
1102
+ },
1103
+ },
1104
+ },
1105
+ type: "write_resource",
1106
+ },
1107
+ {
1108
+ address: address,
1109
+ state_key_hash: "0x5520",
1110
+ data: {
1111
+ type: "0x1::coin::CoinStore<0xd111::staked_coin::StakedAptos>",
1112
+ data: {
1113
+ coin: {
1114
+ value: "2500000",
1115
+ },
1116
+ deposit_events: {
1117
+ counter: "7",
1118
+ guid: {
1119
+ id: {
1120
+ addr: address,
1121
+ creation_num: "10",
1122
+ },
1123
+ },
1124
+ },
1125
+ frozen: false,
1126
+ withdraw_events: {
1127
+ counter: "12",
1128
+ guid: {
1129
+ id: {
1130
+ addr: address,
1131
+ creation_num: "11",
1132
+ },
1133
+ },
1134
+ },
1135
+ },
1136
+ },
1137
+ type: "write_resource",
1138
+ },
1139
+ {
1140
+ address: address,
1141
+ state_key_hash: "0x6f1e",
1142
+ data: {
1143
+ type: "0x1::account::Account",
1144
+ data: {
1145
+ authentication_key: address,
1146
+ coin_register_events: {
1147
+ counter: "5",
1148
+ guid: {
1149
+ id: {
1150
+ addr: address,
1151
+ creation_num: "0",
1152
+ },
1153
+ },
1154
+ },
1155
+ guid_creation_num: "12",
1156
+ key_rotation_events: {
1157
+ counter: "0",
1158
+ guid: {
1159
+ id: {
1160
+ addr: address,
1161
+ creation_num: "1",
1162
+ },
1163
+ },
1164
+ },
1165
+ rotation_capability_offer: {
1166
+ for: {
1167
+ vec: [],
1168
+ },
1169
+ },
1170
+ sequence_number: "121",
1171
+ signer_capability_offer: {
1172
+ for: {
1173
+ vec: [],
1174
+ },
1175
+ },
1176
+ },
1177
+ },
1178
+ type: "write_resource",
1179
+ },
1180
+ {
1181
+ state_key_hash: "0x6e4b",
1182
+ handle: "0x1b85",
1183
+ key: "0x0619",
1184
+ value: "0xe86e0039581497010000000000000000",
1185
+ type: "write_table_item",
1186
+ },
1187
+ ],
1188
+ sender: address,
1189
+ sequence_number: "120",
1190
+ max_gas_amount: "12",
1191
+ gas_unit_price: "100",
1192
+ expiration_timestamp_secs: "1743176706",
1193
+ payload: {
1194
+ function: "0x1::aptos_account::transfer_coins",
1195
+ type_arguments: ["0xd111::staked_coin::StakedAptos"],
1196
+ arguments: ["0x4e5e", "2500000"],
1197
+ type: "entry_function_payload",
1198
+ },
1199
+ events: [
1200
+ {
1201
+ guid: {
1202
+ creation_number: "11",
1203
+ account_address: address,
1204
+ },
1205
+ sequence_number: "11",
1206
+ type: "0x1::coin::WithdrawEvent",
1207
+ data: {
1208
+ amount: "2500000",
1209
+ },
1210
+ },
1211
+ {
1212
+ guid: {
1213
+ creation_number: "4",
1214
+ account_address: "0x4e5e",
1215
+ },
1216
+ sequence_number: "7",
1217
+ type: "0x1::coin::DepositEvent",
1218
+ data: {
1219
+ amount: "2500000",
1220
+ },
1221
+ },
1222
+ {
1223
+ guid: {
1224
+ creation_number: "0",
1225
+ account_address: "0x0",
1226
+ },
1227
+ sequence_number: "0",
1228
+ type: "0x1::transaction_fee::FeeStatement",
1229
+ data: {
1230
+ execution_gas_units: "6",
1231
+ io_gas_units: "6",
1232
+ storage_fee_octas: "0",
1233
+ storage_fee_refund_octas: "0",
1234
+ total_charge_gas_units: "12",
1235
+ },
1236
+ },
1237
+ ],
1238
+ timestamp: "1743176594693251",
1239
+ type: TransactionResponseType.User,
1240
+ block: {
1241
+ height: 311942427,
1242
+ hash: "0x8655",
1243
+ },
1244
+ },
1245
+ ];
1246
+
1247
+ const transactions: AptosTransaction[] = txs;
1248
+
1249
+ api.getAccountInfo = jest.fn().mockResolvedValue({ transactions });
1250
+
1251
+ const ops = await api.listOperations(address, pagination);
1252
+
1253
+ expect(ops[0]).toHaveLength(2);
1254
+ expect(ops[1]).toBe("");
1255
+ });
1256
+ });
1257
+ });