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