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