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