@ledgerhq/coin-sui 0.16.0 → 0.17.0-nightly.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +2 -1
  3. package/CHANGELOG.md +22 -0
  4. package/lib/api/index.d.ts.map +1 -1
  5. package/lib/api/index.js +1 -0
  6. package/lib/api/index.js.map +1 -1
  7. package/lib/logic/estimateFees.d.ts +4 -1
  8. package/lib/logic/estimateFees.d.ts.map +1 -1
  9. package/lib/logic/estimateFees.js +2 -1
  10. package/lib/logic/estimateFees.js.map +1 -1
  11. package/lib/logic/getValidators.d.ts +3 -0
  12. package/lib/logic/getValidators.d.ts.map +1 -0
  13. package/lib/logic/getValidators.js +24 -0
  14. package/lib/logic/getValidators.js.map +1 -0
  15. package/lib/logic/index.d.ts +1 -0
  16. package/lib/logic/index.d.ts.map +1 -1
  17. package/lib/logic/index.js +3 -1
  18. package/lib/logic/index.js.map +1 -1
  19. package/lib/network/index.d.ts +3 -2
  20. package/lib/network/index.d.ts.map +1 -1
  21. package/lib/network/index.js +3 -1
  22. package/lib/network/index.js.map +1 -1
  23. package/lib/network/sdk.d.ts +4 -1
  24. package/lib/network/sdk.d.ts.map +1 -1
  25. package/lib/network/sdk.js +54 -23
  26. package/lib/network/sdk.js.map +1 -1
  27. package/lib/{bridge/bridge.integration.test.d.ts → test/bridge.dataset.d.ts} +1 -1
  28. package/lib/test/bridge.dataset.d.ts.map +1 -0
  29. package/lib/{bridge/bridge.integration.test.js → test/bridge.dataset.js} +2 -2
  30. package/lib/test/bridge.dataset.js.map +1 -0
  31. package/lib-es/api/index.d.ts.map +1 -1
  32. package/lib-es/api/index.js +2 -1
  33. package/lib-es/api/index.js.map +1 -1
  34. package/lib-es/logic/estimateFees.d.ts +4 -1
  35. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  36. package/lib-es/logic/estimateFees.js +2 -1
  37. package/lib-es/logic/estimateFees.js.map +1 -1
  38. package/lib-es/logic/getValidators.d.ts +3 -0
  39. package/lib-es/logic/getValidators.d.ts.map +1 -0
  40. package/lib-es/logic/getValidators.js +20 -0
  41. package/lib-es/logic/getValidators.js.map +1 -0
  42. package/lib-es/logic/index.d.ts +1 -0
  43. package/lib-es/logic/index.d.ts.map +1 -1
  44. package/lib-es/logic/index.js +1 -0
  45. package/lib-es/logic/index.js.map +1 -1
  46. package/lib-es/network/index.d.ts +3 -2
  47. package/lib-es/network/index.d.ts.map +1 -1
  48. package/lib-es/network/index.js +3 -2
  49. package/lib-es/network/index.js.map +1 -1
  50. package/lib-es/network/sdk.d.ts +4 -1
  51. package/lib-es/network/sdk.d.ts.map +1 -1
  52. package/lib-es/network/sdk.js +52 -22
  53. package/lib-es/network/sdk.js.map +1 -1
  54. package/lib-es/{bridge/bridge.integration.test.d.ts → test/bridge.dataset.d.ts} +1 -1
  55. package/lib-es/test/bridge.dataset.d.ts.map +1 -0
  56. package/lib-es/{bridge/bridge.integration.test.js → test/bridge.dataset.js} +2 -2
  57. package/lib-es/test/bridge.dataset.js.map +1 -0
  58. package/package.json +5 -9
  59. package/src/api/index.integration.test.ts +80 -7
  60. package/src/api/index.ts +2 -0
  61. package/src/logic/estimateFees.test.ts +22 -16
  62. package/src/logic/estimateFees.ts +6 -1
  63. package/src/logic/getValidators.test.ts +92 -0
  64. package/src/logic/getValidators.ts +23 -0
  65. package/src/logic/index.ts +1 -0
  66. package/src/network/index.ts +3 -0
  67. package/src/network/sdk.test.ts +134 -60
  68. package/src/network/sdk.ts +58 -23
  69. package/src/{bridge/bridge.integration.test.ts → test/bridge.dataset.ts} +1 -1
  70. package/lib/api/index.integration.test.d.ts +0 -2
  71. package/lib/api/index.integration.test.d.ts.map +0 -1
  72. package/lib/api/index.integration.test.js +0 -173
  73. package/lib/api/index.integration.test.js.map +0 -1
  74. package/lib/api/index.test.d.ts +0 -2
  75. package/lib/api/index.test.d.ts.map +0 -1
  76. package/lib/api/index.test.js +0 -173
  77. package/lib/api/index.test.js.map +0 -1
  78. package/lib/bridge/bridge.integration.test.d.ts.map +0 -1
  79. package/lib/bridge/bridge.integration.test.js.map +0 -1
  80. package/lib/bridge/broadcast.test.d.ts +0 -2
  81. package/lib/bridge/broadcast.test.d.ts.map +0 -1
  82. package/lib/bridge/broadcast.test.js +0 -48
  83. package/lib/bridge/broadcast.test.js.map +0 -1
  84. package/lib/bridge/buildOptimisticOperation.test.d.ts +0 -2
  85. package/lib/bridge/buildOptimisticOperation.test.d.ts.map +0 -1
  86. package/lib/bridge/buildOptimisticOperation.test.js +0 -52
  87. package/lib/bridge/buildOptimisticOperation.test.js.map +0 -1
  88. package/lib/bridge/buildTransaction.integration.test.d.ts +0 -2
  89. package/lib/bridge/buildTransaction.integration.test.d.ts.map +0 -1
  90. package/lib/bridge/buildTransaction.integration.test.js +0 -72
  91. package/lib/bridge/buildTransaction.integration.test.js.map +0 -1
  92. package/lib/bridge/buildTransaction.test.d.ts +0 -2
  93. package/lib/bridge/buildTransaction.test.d.ts.map +0 -1
  94. package/lib/bridge/buildTransaction.test.js +0 -231
  95. package/lib/bridge/buildTransaction.test.js.map +0 -1
  96. package/lib/bridge/estimateMaxSpendable.test.d.ts +0 -2
  97. package/lib/bridge/estimateMaxSpendable.test.d.ts.map +0 -1
  98. package/lib/bridge/estimateMaxSpendable.test.js +0 -52
  99. package/lib/bridge/estimateMaxSpendable.test.js.map +0 -1
  100. package/lib/bridge/formatters.test.d.ts +0 -2
  101. package/lib/bridge/formatters.test.d.ts.map +0 -1
  102. package/lib/bridge/formatters.test.js +0 -18
  103. package/lib/bridge/formatters.test.js.map +0 -1
  104. package/lib/bridge/getFeesForTransaction.test.d.ts +0 -2
  105. package/lib/bridge/getFeesForTransaction.test.d.ts.map +0 -1
  106. package/lib/bridge/getFeesForTransaction.test.js +0 -35
  107. package/lib/bridge/getFeesForTransaction.test.js.map +0 -1
  108. package/lib/bridge/getTransactionStatus.test.d.ts +0 -2
  109. package/lib/bridge/getTransactionStatus.test.d.ts.map +0 -1
  110. package/lib/bridge/getTransactionStatus.test.js +0 -69
  111. package/lib/bridge/getTransactionStatus.test.js.map +0 -1
  112. package/lib/bridge/index.test.d.ts +0 -2
  113. package/lib/bridge/index.test.d.ts.map +0 -1
  114. package/lib/bridge/index.test.js +0 -265
  115. package/lib/bridge/index.test.js.map +0 -1
  116. package/lib/bridge/preload.test.d.ts +0 -2
  117. package/lib/bridge/preload.test.d.ts.map +0 -1
  118. package/lib/bridge/preload.test.js +0 -52
  119. package/lib/bridge/preload.test.js.map +0 -1
  120. package/lib/bridge/prepareTransaction.test.d.ts +0 -2
  121. package/lib/bridge/prepareTransaction.test.d.ts.map +0 -1
  122. package/lib/bridge/prepareTransaction.test.js +0 -97
  123. package/lib/bridge/prepareTransaction.test.js.map +0 -1
  124. package/lib/bridge/serialization.test.d.ts +0 -2
  125. package/lib/bridge/serialization.test.d.ts.map +0 -1
  126. package/lib/bridge/serialization.test.js +0 -131
  127. package/lib/bridge/serialization.test.js.map +0 -1
  128. package/lib/bridge/signOperation.integration.test.d.ts +0 -2
  129. package/lib/bridge/signOperation.integration.test.d.ts.map +0 -1
  130. package/lib/bridge/signOperation.integration.test.js +0 -80
  131. package/lib/bridge/signOperation.integration.test.js.map +0 -1
  132. package/lib/bridge/signOperation.test.d.ts +0 -2
  133. package/lib/bridge/signOperation.test.d.ts.map +0 -1
  134. package/lib/bridge/signOperation.test.js +0 -445
  135. package/lib/bridge/signOperation.test.js.map +0 -1
  136. package/lib/bridge/synchronisation.test.d.ts +0 -2
  137. package/lib/bridge/synchronisation.test.d.ts.map +0 -1
  138. package/lib/bridge/synchronisation.test.js +0 -505
  139. package/lib/bridge/synchronisation.test.js.map +0 -1
  140. package/lib/bridge/transaction.test.d.ts +0 -2
  141. package/lib/bridge/transaction.test.d.ts.map +0 -1
  142. package/lib/bridge/transaction.test.js +0 -68
  143. package/lib/bridge/transaction.test.js.map +0 -1
  144. package/lib/logic/broadcast.test.d.ts +0 -2
  145. package/lib/logic/broadcast.test.d.ts.map +0 -1
  146. package/lib/logic/broadcast.test.js +0 -62
  147. package/lib/logic/broadcast.test.js.map +0 -1
  148. package/lib/logic/combine.test.d.ts +0 -2
  149. package/lib/logic/combine.test.d.ts.map +0 -1
  150. package/lib/logic/combine.test.js +0 -37
  151. package/lib/logic/combine.test.js.map +0 -1
  152. package/lib/logic/craftTransaction.integration.test.d.ts +0 -2
  153. package/lib/logic/craftTransaction.integration.test.d.ts.map +0 -1
  154. package/lib/logic/craftTransaction.integration.test.js +0 -98
  155. package/lib/logic/craftTransaction.integration.test.js.map +0 -1
  156. package/lib/logic/craftTransaction.test.d.ts +0 -2
  157. package/lib/logic/craftTransaction.test.d.ts.map +0 -1
  158. package/lib/logic/craftTransaction.test.js +0 -127
  159. package/lib/logic/craftTransaction.test.js.map +0 -1
  160. package/lib/logic/estimateFees.integration.test.d.ts +0 -2
  161. package/lib/logic/estimateFees.integration.test.d.ts.map +0 -1
  162. package/lib/logic/estimateFees.integration.test.js +0 -82
  163. package/lib/logic/estimateFees.integration.test.js.map +0 -1
  164. package/lib/logic/estimateFees.test.d.ts +0 -2
  165. package/lib/logic/estimateFees.test.d.ts.map +0 -1
  166. package/lib/logic/estimateFees.test.js +0 -70
  167. package/lib/logic/estimateFees.test.js.map +0 -1
  168. package/lib/logic/getBalance.integration.test.d.ts +0 -2
  169. package/lib/logic/getBalance.integration.test.d.ts.map +0 -1
  170. package/lib/logic/getBalance.integration.test.js +0 -56
  171. package/lib/logic/getBalance.integration.test.js.map +0 -1
  172. package/lib/logic/getBalance.test.d.ts +0 -2
  173. package/lib/logic/getBalance.test.d.ts.map +0 -1
  174. package/lib/logic/getBalance.test.js +0 -64
  175. package/lib/logic/getBalance.test.js.map +0 -1
  176. package/lib/logic/lastBlock.test.d.ts +0 -2
  177. package/lib/logic/lastBlock.test.d.ts.map +0 -1
  178. package/lib/logic/lastBlock.test.js +0 -27
  179. package/lib/logic/lastBlock.test.js.map +0 -1
  180. package/lib/logic/listOperations.test.d.ts +0 -2
  181. package/lib/logic/listOperations.test.d.ts.map +0 -1
  182. package/lib/logic/listOperations.test.js +0 -79
  183. package/lib/logic/listOperations.test.js.map +0 -1
  184. package/lib/network/sdk.integration.test.d.ts +0 -2
  185. package/lib/network/sdk.integration.test.d.ts.map +0 -1
  186. package/lib/network/sdk.integration.test.js +0 -215
  187. package/lib/network/sdk.integration.test.js.map +0 -1
  188. package/lib/network/sdk.test.d.ts +0 -2
  189. package/lib/network/sdk.test.d.ts.map +0 -1
  190. package/lib/network/sdk.test.js +0 -1784
  191. package/lib/network/sdk.test.js.map +0 -1
  192. package/lib/signer/getAddress.test.d.ts +0 -2
  193. package/lib/signer/getAddress.test.d.ts.map +0 -1
  194. package/lib/signer/getAddress.test.js +0 -106
  195. package/lib/signer/getAddress.test.js.map +0 -1
  196. package/lib/test/config.test.d.ts +0 -2
  197. package/lib/test/config.test.d.ts.map +0 -1
  198. package/lib/test/config.test.js +0 -44
  199. package/lib/test/config.test.js.map +0 -1
  200. package/lib-es/api/index.integration.test.d.ts +0 -2
  201. package/lib-es/api/index.integration.test.d.ts.map +0 -1
  202. package/lib-es/api/index.integration.test.js +0 -171
  203. package/lib-es/api/index.integration.test.js.map +0 -1
  204. package/lib-es/api/index.test.d.ts +0 -2
  205. package/lib-es/api/index.test.d.ts.map +0 -1
  206. package/lib-es/api/index.test.js +0 -148
  207. package/lib-es/api/index.test.js.map +0 -1
  208. package/lib-es/bridge/bridge.integration.test.d.ts.map +0 -1
  209. package/lib-es/bridge/bridge.integration.test.js.map +0 -1
  210. package/lib-es/bridge/broadcast.test.d.ts +0 -2
  211. package/lib-es/bridge/broadcast.test.d.ts.map +0 -1
  212. package/lib-es/bridge/broadcast.test.js +0 -46
  213. package/lib-es/bridge/broadcast.test.js.map +0 -1
  214. package/lib-es/bridge/buildOptimisticOperation.test.d.ts +0 -2
  215. package/lib-es/bridge/buildOptimisticOperation.test.d.ts.map +0 -1
  216. package/lib-es/bridge/buildOptimisticOperation.test.js +0 -47
  217. package/lib-es/bridge/buildOptimisticOperation.test.js.map +0 -1
  218. package/lib-es/bridge/buildTransaction.integration.test.d.ts +0 -2
  219. package/lib-es/bridge/buildTransaction.integration.test.d.ts.map +0 -1
  220. package/lib-es/bridge/buildTransaction.integration.test.js +0 -67
  221. package/lib-es/bridge/buildTransaction.integration.test.js.map +0 -1
  222. package/lib-es/bridge/buildTransaction.test.d.ts +0 -2
  223. package/lib-es/bridge/buildTransaction.test.d.ts.map +0 -1
  224. package/lib-es/bridge/buildTransaction.test.js +0 -229
  225. package/lib-es/bridge/buildTransaction.test.js.map +0 -1
  226. package/lib-es/bridge/estimateMaxSpendable.test.d.ts +0 -2
  227. package/lib-es/bridge/estimateMaxSpendable.test.d.ts.map +0 -1
  228. package/lib-es/bridge/estimateMaxSpendable.test.js +0 -50
  229. package/lib-es/bridge/estimateMaxSpendable.test.js.map +0 -1
  230. package/lib-es/bridge/formatters.test.d.ts +0 -2
  231. package/lib-es/bridge/formatters.test.d.ts.map +0 -1
  232. package/lib-es/bridge/formatters.test.js +0 -16
  233. package/lib-es/bridge/formatters.test.js.map +0 -1
  234. package/lib-es/bridge/getFeesForTransaction.test.d.ts +0 -2
  235. package/lib-es/bridge/getFeesForTransaction.test.d.ts.map +0 -1
  236. package/lib-es/bridge/getFeesForTransaction.test.js +0 -30
  237. package/lib-es/bridge/getFeesForTransaction.test.js.map +0 -1
  238. package/lib-es/bridge/getTransactionStatus.test.d.ts +0 -2
  239. package/lib-es/bridge/getTransactionStatus.test.d.ts.map +0 -1
  240. package/lib-es/bridge/getTransactionStatus.test.js +0 -64
  241. package/lib-es/bridge/getTransactionStatus.test.js.map +0 -1
  242. package/lib-es/bridge/index.test.d.ts +0 -2
  243. package/lib-es/bridge/index.test.d.ts.map +0 -1
  244. package/lib-es/bridge/index.test.js +0 -260
  245. package/lib-es/bridge/index.test.js.map +0 -1
  246. package/lib-es/bridge/preload.test.d.ts +0 -2
  247. package/lib-es/bridge/preload.test.d.ts.map +0 -1
  248. package/lib-es/bridge/preload.test.js +0 -50
  249. package/lib-es/bridge/preload.test.js.map +0 -1
  250. package/lib-es/bridge/prepareTransaction.test.d.ts +0 -2
  251. package/lib-es/bridge/prepareTransaction.test.d.ts.map +0 -1
  252. package/lib-es/bridge/prepareTransaction.test.js +0 -92
  253. package/lib-es/bridge/prepareTransaction.test.js.map +0 -1
  254. package/lib-es/bridge/serialization.test.d.ts +0 -2
  255. package/lib-es/bridge/serialization.test.d.ts.map +0 -1
  256. package/lib-es/bridge/serialization.test.js +0 -126
  257. package/lib-es/bridge/serialization.test.js.map +0 -1
  258. package/lib-es/bridge/signOperation.integration.test.d.ts +0 -2
  259. package/lib-es/bridge/signOperation.integration.test.d.ts.map +0 -1
  260. package/lib-es/bridge/signOperation.integration.test.js +0 -75
  261. package/lib-es/bridge/signOperation.integration.test.js.map +0 -1
  262. package/lib-es/bridge/signOperation.test.d.ts +0 -2
  263. package/lib-es/bridge/signOperation.test.d.ts.map +0 -1
  264. package/lib-es/bridge/signOperation.test.js +0 -440
  265. package/lib-es/bridge/signOperation.test.js.map +0 -1
  266. package/lib-es/bridge/synchronisation.test.d.ts +0 -2
  267. package/lib-es/bridge/synchronisation.test.d.ts.map +0 -1
  268. package/lib-es/bridge/synchronisation.test.js +0 -477
  269. package/lib-es/bridge/synchronisation.test.js.map +0 -1
  270. package/lib-es/bridge/transaction.test.d.ts +0 -2
  271. package/lib-es/bridge/transaction.test.d.ts.map +0 -1
  272. package/lib-es/bridge/transaction.test.js +0 -66
  273. package/lib-es/bridge/transaction.test.js.map +0 -1
  274. package/lib-es/logic/broadcast.test.d.ts +0 -2
  275. package/lib-es/logic/broadcast.test.d.ts.map +0 -1
  276. package/lib-es/logic/broadcast.test.js +0 -57
  277. package/lib-es/logic/broadcast.test.js.map +0 -1
  278. package/lib-es/logic/combine.test.d.ts +0 -2
  279. package/lib-es/logic/combine.test.d.ts.map +0 -1
  280. package/lib-es/logic/combine.test.js +0 -35
  281. package/lib-es/logic/combine.test.js.map +0 -1
  282. package/lib-es/logic/craftTransaction.integration.test.d.ts +0 -2
  283. package/lib-es/logic/craftTransaction.integration.test.d.ts.map +0 -1
  284. package/lib-es/logic/craftTransaction.integration.test.js +0 -93
  285. package/lib-es/logic/craftTransaction.integration.test.js.map +0 -1
  286. package/lib-es/logic/craftTransaction.test.d.ts +0 -2
  287. package/lib-es/logic/craftTransaction.test.d.ts.map +0 -1
  288. package/lib-es/logic/craftTransaction.test.js +0 -122
  289. package/lib-es/logic/craftTransaction.test.js.map +0 -1
  290. package/lib-es/logic/estimateFees.integration.test.d.ts +0 -2
  291. package/lib-es/logic/estimateFees.integration.test.d.ts.map +0 -1
  292. package/lib-es/logic/estimateFees.integration.test.js +0 -77
  293. package/lib-es/logic/estimateFees.integration.test.js.map +0 -1
  294. package/lib-es/logic/estimateFees.test.d.ts +0 -2
  295. package/lib-es/logic/estimateFees.test.d.ts.map +0 -1
  296. package/lib-es/logic/estimateFees.test.js +0 -65
  297. package/lib-es/logic/estimateFees.test.js.map +0 -1
  298. package/lib-es/logic/getBalance.integration.test.d.ts +0 -2
  299. package/lib-es/logic/getBalance.integration.test.d.ts.map +0 -1
  300. package/lib-es/logic/getBalance.integration.test.js +0 -51
  301. package/lib-es/logic/getBalance.integration.test.js.map +0 -1
  302. package/lib-es/logic/getBalance.test.d.ts +0 -2
  303. package/lib-es/logic/getBalance.test.d.ts.map +0 -1
  304. package/lib-es/logic/getBalance.test.js +0 -62
  305. package/lib-es/logic/getBalance.test.js.map +0 -1
  306. package/lib-es/logic/lastBlock.test.d.ts +0 -2
  307. package/lib-es/logic/lastBlock.test.d.ts.map +0 -1
  308. package/lib-es/logic/lastBlock.test.js +0 -25
  309. package/lib-es/logic/lastBlock.test.js.map +0 -1
  310. package/lib-es/logic/listOperations.test.d.ts +0 -2
  311. package/lib-es/logic/listOperations.test.d.ts.map +0 -1
  312. package/lib-es/logic/listOperations.test.js +0 -77
  313. package/lib-es/logic/listOperations.test.js.map +0 -1
  314. package/lib-es/network/sdk.integration.test.d.ts +0 -2
  315. package/lib-es/network/sdk.integration.test.d.ts.map +0 -1
  316. package/lib-es/network/sdk.integration.test.js +0 -210
  317. package/lib-es/network/sdk.integration.test.js.map +0 -1
  318. package/lib-es/network/sdk.test.d.ts +0 -2
  319. package/lib-es/network/sdk.test.d.ts.map +0 -1
  320. package/lib-es/network/sdk.test.js +0 -1756
  321. package/lib-es/network/sdk.test.js.map +0 -1
  322. package/lib-es/signer/getAddress.test.d.ts +0 -2
  323. package/lib-es/signer/getAddress.test.d.ts.map +0 -1
  324. package/lib-es/signer/getAddress.test.js +0 -101
  325. package/lib-es/signer/getAddress.test.js.map +0 -1
  326. package/lib-es/test/config.test.d.ts +0 -2
  327. package/lib-es/test/config.test.d.ts.map +0 -1
  328. package/lib-es/test/config.test.js +0 -39
  329. package/lib-es/test/config.test.js.map +0 -1
@@ -93,6 +93,24 @@ describe("Sui Api", () => {
93
93
  });
94
94
  });
95
95
 
96
+ describe("listOperations (staking)", () => {
97
+ let txs: Operation[];
98
+
99
+ beforeAll(async () => {
100
+ [txs] = await module.listOperations(
101
+ "0x13d73cab19d2cf14e39289b122ed93fb0f9edd00e4c829e0cefb1f0611c54a8f",
102
+ { minHeight: 0, order: "asc" },
103
+ );
104
+ });
105
+
106
+ it("should map undelegate operations when it's not the first move call", async () => {
107
+ const tx1 = txs.find(t => t.id === "4UtCqCH3oNEdaprZR9UjaMGg6HgLn3V3q3FEcvs5vieM");
108
+ expect(tx1?.type).toBe("UNDELEGATE");
109
+ const tx2 = txs.find(t => t.id === "JEGnHCx2mtpDin216kbUBXm7V5rdMSPSUmgYbP3yxTEf");
110
+ expect(tx2?.type).toBe("UNDELEGATE");
111
+ });
112
+ });
113
+
96
114
  describe("listOperations", () => {
97
115
  let txs: Operation[];
98
116
 
@@ -182,13 +200,68 @@ describe("Sui Api", () => {
182
200
 
183
201
  describe("getBlock", () => {
184
202
  test("getBlock should get block by id or sequence number", async () => {
185
- const block = await module.getBlock(164167623);
186
- expect(block.info.height).toEqual(164167623);
187
- expect(block.info.hash).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
188
- expect(block.info.time).toEqual(new Date(1751696298663));
189
- expect(block.info.parent?.height).toEqual(164167622);
190
- expect(block.info.parent?.hash).toEqual("6VKtVnpxstb968SzSrgYJ7zy5LXgFB6PnNHSJsT8Wr4E");
191
- expect(block.transactions.length).toEqual(19);
203
+ const block = await module.getBlock(195177985);
204
+ expect(block.info.height).toEqual(195177985);
205
+ expect(block.info.hash).toEqual("AzoHwjcCXkeiWoBVyWwZcE171zjxochFmcr9eQoNQyYn");
206
+ expect(block.info.time).toEqual(new Date(1759138080141));
207
+ expect(block.info.parent?.height).toEqual(195177984);
208
+ expect(block.info.parent?.hash).toEqual("A15NYkPDyKLZS4Swik7AY2mnLxwFET4kyNV6ChZ8tVJP");
209
+ expect(block.transactions.length).toEqual(12);
210
+ const tx = block.transactions[9];
211
+ const senderOp = tx.operations[0];
212
+ const receipientOp = tx.operations[1];
213
+ expect(tx.hash).toEqual("J3ddkv4TRqr4LviCbA3JyJCji5Kg5BcaBTkd6nMY5WXN");
214
+ expect(tx.operations.length).toEqual(2);
215
+ expect(senderOp.address).toEqual(
216
+ "0x2c814ceb68d1cb7168207b16754b1cf57e735685c4e5d87c4f50906edcc57c1c",
217
+ );
218
+ expect(senderOp.peer).toEqual(
219
+ "0xb37b298c9164c28c8aaf989a49416e3c323b67bc2b96a54501b524419ebb4ead",
220
+ );
221
+ expect(senderOp.amount).toEqual(BigInt(-5));
222
+ expect(receipientOp.address).toEqual(
223
+ "0xb37b298c9164c28c8aaf989a49416e3c323b67bc2b96a54501b524419ebb4ead",
224
+ );
225
+ expect(receipientOp.peer).toEqual(
226
+ "0x2c814ceb68d1cb7168207b16754b1cf57e735685c4e5d87c4f50906edcc57c1c",
227
+ );
228
+ expect(receipientOp.amount).toEqual(BigInt(5));
229
+ });
230
+ });
231
+
232
+ describe("getValidators", () => {
233
+ it("returns at least a hundred validators with expected fields", async () => {
234
+ const page = await module.getValidators();
235
+
236
+ expect(Array.isArray(page.items)).toBeTruthy();
237
+ expect(page.items.length).toBeGreaterThanOrEqual(100);
238
+
239
+ const v = page.items[0];
240
+ expect(v).toHaveProperty("address");
241
+ expect(v).toHaveProperty("name");
242
+ expect(v).toHaveProperty("description");
243
+ expect(v).toHaveProperty("url");
244
+ expect(v).toHaveProperty("logo");
245
+ expect(v).toHaveProperty("balance");
246
+ expect(v).toHaveProperty("commissionRate");
247
+ expect(v).toHaveProperty("apy");
248
+
249
+ // values should not be empty
250
+ expect(typeof v.address).toBe("string");
251
+ expect(v.address.length).toBeGreaterThan(0);
252
+ expect(typeof v.name).toBe("string");
253
+ expect(v.name.length).toBeGreaterThan(0);
254
+ expect(typeof v.description).toBe("string");
255
+ expect((v.description as string).length).toBeGreaterThan(0);
256
+ expect(typeof v.url).toBe("string");
257
+ expect((v.url as string).length).toBeGreaterThan(0);
258
+ expect(typeof v.logo).toBe("string");
259
+ expect((v.logo as string).length).toBeGreaterThan(0);
260
+ expect(typeof v.balance === "bigint").toBeTruthy();
261
+ expect(v.balance as bigint).toBeGreaterThanOrEqual(0n);
262
+ expect(typeof v.commissionRate).toBe("string");
263
+ expect((v.commissionRate as string).length).toBeGreaterThan(0);
264
+ expect(typeof v.apy).toBe("number");
192
265
  });
193
266
  });
194
267
 
package/src/api/index.ts CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  craftTransaction,
12
12
  getStakes,
13
13
  getRewards,
14
+ getValidators as logicGetValidators,
14
15
  } from "../logic";
15
16
  import {
16
17
  AlpacaApi,
@@ -42,6 +43,7 @@ export function createApi(config: SuiConfig): AlpacaApi {
42
43
  listOperations: logicListOperations,
43
44
  getStakes,
44
45
  getRewards,
46
+ getValidators: logicGetValidators,
45
47
  };
46
48
  }
47
49
 
@@ -33,14 +33,17 @@ describe("estimateFees", () => {
33
33
 
34
34
  const result = await estimateFees(transactionIntent);
35
35
 
36
- expect(suiAPI.paymentInfo).toHaveBeenCalledWith(transactionIntent.sender, {
37
- recipient: transactionIntent.recipient,
38
- amount: BigNumber(transactionIntent.amount.toString()),
39
- coinType: "0x2::sui::SUI",
40
- errors: {},
41
- family: "sui",
42
- mode: "send",
43
- });
36
+ expect(suiAPI.paymentInfo).toHaveBeenCalledWith(
37
+ transactionIntent.sender,
38
+ expect.objectContaining({
39
+ recipient: transactionIntent.recipient,
40
+ amount: BigNumber(transactionIntent.amount.toString()),
41
+ coinType: "0x2::sui::SUI",
42
+ errors: {},
43
+ family: "sui",
44
+ mode: "send",
45
+ }),
46
+ );
44
47
  expect(result).toBe(BigInt(mockGasBudget));
45
48
  });
46
49
 
@@ -61,14 +64,17 @@ describe("estimateFees", () => {
61
64
 
62
65
  const result = await estimateFees(transactionIntent);
63
66
 
64
- expect(suiAPI.paymentInfo).toHaveBeenCalledWith(transactionIntent.sender, {
65
- recipient: transactionIntent.recipient,
66
- amount: BigNumber("0"),
67
- coinType: "0x2::sui::SUI",
68
- errors: {},
69
- family: "sui",
70
- mode: "send",
71
- });
67
+ expect(suiAPI.paymentInfo).toHaveBeenCalledWith(
68
+ transactionIntent.sender,
69
+ expect.objectContaining({
70
+ recipient: transactionIntent.recipient,
71
+ amount: BigNumber("0"),
72
+ coinType: "0x2::sui::SUI",
73
+ errors: {},
74
+ family: "sui",
75
+ mode: "send",
76
+ }),
77
+ );
72
78
  expect(result).toBe(BigInt(mockGasBudget));
73
79
  });
74
80
  });
@@ -9,7 +9,11 @@ export async function estimateFees({
9
9
  sender,
10
10
  asset,
11
11
  type,
12
- }: TransactionIntent): Promise<bigint> {
12
+ ...extra
13
+ }: TransactionIntent & {
14
+ useAllAmount?: boolean;
15
+ stakedSuiId?: string;
16
+ }): Promise<bigint> {
13
17
  let coinType = DEFAULT_COIN_TYPE;
14
18
  if (asset.type === "token" && asset.assetReference) {
15
19
  coinType = asset.assetReference;
@@ -35,6 +39,7 @@ export async function estimateFees({
35
39
  amount: BigNumber(amount.toString()),
36
40
  errors: {},
37
41
  coinType,
42
+ ...extra,
38
43
  });
39
44
  return BigInt(gasBudget);
40
45
  }
@@ -0,0 +1,92 @@
1
+ import * as network from "../network";
2
+ import { getValidators } from "./getValidators";
3
+
4
+ type NetworkValidator = {
5
+ suiAddress: string;
6
+ name: string;
7
+ description: string;
8
+ projectUrl: string;
9
+ imageUrl: string;
10
+ stakingPoolSuiBalance: string;
11
+ commissionRate: string;
12
+ apy: number;
13
+ };
14
+
15
+ jest.mock("../network", () => ({
16
+ getValidators: jest.fn(),
17
+ }));
18
+
19
+ const mockedGetValidators = jest.mocked(network.getValidators);
20
+
21
+ describe("logic/getValidators", () => {
22
+ afterEach(() => {
23
+ jest.restoreAllMocks();
24
+ });
25
+
26
+ it("maps network validators to generic Validator and returns single page", async () => {
27
+ const networkValidators: NetworkValidator[] = [
28
+ {
29
+ suiAddress: "0xabc",
30
+ name: "Validator A",
31
+ description: "desc",
32
+ projectUrl: "https://example.com",
33
+ imageUrl: "https://example.com/logo.png",
34
+ stakingPoolSuiBalance: "1234567890",
35
+ commissionRate: "0.1",
36
+ apy: 0.08,
37
+ },
38
+ {
39
+ suiAddress: "0xdef",
40
+ name: "Validator B",
41
+ description: "",
42
+ projectUrl: "",
43
+ imageUrl: "",
44
+ stakingPoolSuiBalance: "0",
45
+ commissionRate: "0",
46
+ apy: 0,
47
+ },
48
+ ];
49
+
50
+ mockedGetValidators.mockResolvedValueOnce(
51
+ networkValidators as unknown as ReturnType<typeof network.getValidators>,
52
+ );
53
+
54
+ const page = await getValidators();
55
+
56
+ expect(page.next).toBeUndefined();
57
+ expect(page.items).toHaveLength(2);
58
+
59
+ const [a, b] = page.items;
60
+ expect(a).toEqual({
61
+ address: "0xabc",
62
+ name: "Validator A",
63
+ description: "desc",
64
+ url: "https://example.com",
65
+ logo: "https://example.com/logo.png",
66
+ balance: BigInt("1234567890"),
67
+ commissionRate: "0.1",
68
+ apy: 0.08,
69
+ });
70
+
71
+ expect(b).toEqual({
72
+ address: "0xdef",
73
+ name: "Validator B",
74
+ description: "",
75
+ url: "",
76
+ logo: "",
77
+ balance: 0n,
78
+ commissionRate: "0",
79
+ apy: 0,
80
+ });
81
+ });
82
+
83
+ it("handles empty network response", async () => {
84
+ mockedGetValidators.mockResolvedValueOnce(
85
+ [] as unknown as ReturnType<typeof network.getValidators>,
86
+ );
87
+
88
+ const page = await getValidators();
89
+ expect(page.items).toEqual([]);
90
+ expect(page.next).toBeUndefined();
91
+ });
92
+ });
@@ -0,0 +1,23 @@
1
+ import { type Page, type Validator } from "@ledgerhq/coin-framework/api/index";
2
+ import { getValidators as getValidatorsFromNetwork } from "../network";
3
+
4
+ export async function getValidators(_cursor?: string): Promise<Page<Validator>> {
5
+ const validators = await getValidatorsFromNetwork();
6
+
7
+ const items: Validator[] = validators.map(v => ({
8
+ address: v.suiAddress,
9
+ name: v.name,
10
+ description: v.description,
11
+ url: v.projectUrl,
12
+ logo: v.imageUrl,
13
+ balance: BigInt(v.stakingPoolSuiBalance),
14
+ commissionRate: v.commissionRate,
15
+ apy: v.apy,
16
+ }));
17
+
18
+ return {
19
+ items,
20
+ // there is no underlying pagination, so undefined token
21
+ next: undefined,
22
+ };
23
+ }
@@ -8,3 +8,4 @@ export { getBlock, getBlockInfo } from "./getBlock";
8
8
  export { listOperations } from "./listOperations";
9
9
  export { getStakes, getRewards } from "./staking";
10
10
  export { canStake } from "./stake";
11
+ export { getValidators } from "./getValidators";
@@ -9,6 +9,7 @@ import {
9
9
  createTransaction,
10
10
  executeTransactionBlock,
11
11
  getStakes,
12
+ getValidators,
12
13
  } from "./sdk";
13
14
 
14
15
  export {
@@ -22,6 +23,7 @@ export {
22
23
  createTransaction,
23
24
  executeTransactionBlock,
24
25
  getStakes,
26
+ getValidators,
25
27
  };
26
28
 
27
29
  export default {
@@ -35,4 +37,5 @@ export default {
35
37
  createTransaction,
36
38
  executeTransactionBlock,
37
39
  getStakes,
40
+ getValidators,
38
41
  };
@@ -3,8 +3,12 @@ import coinConfig from "../config";
3
3
 
4
4
  import { BigNumber } from "bignumber.js";
5
5
  import { SuiClient } from "@mysten/sui/client";
6
- import type { TransactionBlockData, SuiTransactionBlockResponse } from "@mysten/sui/client";
7
- import assert from "assert";
6
+ import type {
7
+ TransactionBlockData,
8
+ SuiTransactionBlockResponse,
9
+ SuiTransactionBlockKind,
10
+ } from "@mysten/sui/client";
11
+ import assert, { fail } from "assert";
8
12
 
9
13
  // Mock SUI client for tests
10
14
  jest.mock("@mysten/sui/client", () => {
@@ -232,7 +236,6 @@ function mockStakingTx(address: string, amount: string) {
232
236
 
233
237
  // amount must be a positive number
234
238
  function mockUnstakingTx(address: string, amount: string) {
235
- assert(new BigNumber(amount).gte(0), "amount must be a positive number");
236
239
  return {
237
240
  digest: "undelegate_tx_digest_456",
238
241
  transaction: {
@@ -609,17 +612,48 @@ describe("SDK Functions", () => {
609
612
 
610
613
  describe("Staking Operations", () => {
611
614
  describe("Operation Type Detection", () => {
615
+ const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
612
616
  test("getOperationType should return DELEGATE for staking transaction", () => {
613
- const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
614
617
  expect(sdk.getOperationType(address, mockStakingTx(address, "-1000000000"))).toBe("DELEGATE");
615
618
  });
616
619
 
617
620
  test("getOperationType should return UNDELEGATE for unstaking transaction", () => {
618
- const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
619
621
  expect(sdk.getOperationType(address, mockUnstakingTx(address, "1000000000"))).toBe(
620
622
  "UNDELEGATE",
621
623
  );
622
624
  });
625
+
626
+ function prependOtherMoveCall(block: SuiTransactionBlockKind) {
627
+ if (block?.kind === "ProgrammableTransaction") {
628
+ block.transactions.unshift({
629
+ MoveCall: {
630
+ function: "other_function",
631
+ module: "module",
632
+ package: "package",
633
+ },
634
+ });
635
+ }
636
+ }
637
+
638
+ test("getOperationType should return UNDELEGATE when it's not the first MoveCall ", () => {
639
+ const tx = mockUnstakingTx(address, "1000");
640
+ if (tx.transaction) {
641
+ prependOtherMoveCall(tx.transaction.data.transaction);
642
+ expect(sdk.getOperationType(address, tx)).toBe("UNDELEGATE");
643
+ } else {
644
+ fail("can't prepare fixture");
645
+ }
646
+ });
647
+
648
+ test("getOperationType should return DELEGATE when it's not the first MoveCall ", () => {
649
+ const tx = mockStakingTx(address, "-1000");
650
+ if (tx.transaction) {
651
+ prependOtherMoveCall(tx.transaction.data.transaction);
652
+ expect(sdk.getOperationType(address, tx)).toBe("DELEGATE");
653
+ } else {
654
+ fail("can't prepare fixture");
655
+ }
656
+ });
623
657
  });
624
658
 
625
659
  describe("Operation Amount Calculation", () => {
@@ -661,17 +695,20 @@ describe("Staking Operations", () => {
661
695
  }
662
696
 
663
697
  test("alpaca getOperationAmount should calculate staking amount", () =>
664
- expect(alpacaOperationAmount(mockStakingTx(address, "-1000000000"))).toEqual(
698
+ expect(alpacaOperationAmount(mockStakingTx(address, "-1001050000"))).toEqual(
665
699
  new BigNumber("1000000000"),
666
700
  ));
667
701
 
702
+ // 1000 unstaked & 1050000 gas fees = -1049000 balance change
668
703
  test("alpaca getOperationAmount should calculate unstaking amount of 1000", () =>
669
- expect(alpacaOperationAmount(mockUnstakingTx(address, "1000"))).toEqual(
704
+ expect(alpacaOperationAmount(mockUnstakingTx(address, "-1049000"))).toEqual(
670
705
  new BigNumber("1000"),
671
706
  ));
672
707
 
673
708
  test("alpaca getOperationAmount should calculate unstaking amount of 0", () =>
674
- expect(alpacaOperationAmount(mockUnstakingTx(address, "0"))).toEqual(new BigNumber("0")));
709
+ expect(alpacaOperationAmount(mockUnstakingTx(address, "-1050000"))).toEqual(
710
+ new BigNumber("0"),
711
+ ));
675
712
 
676
713
  test("alpaca getOperationAmount should calculate amount correctly for SUI", () =>
677
714
  expect(alpacaOperationAmount(mockTransaction)).toEqual(new BigNumber("9998990120")));
@@ -824,7 +861,7 @@ describe("Staking Operations", () => {
824
861
  test("transactionToOp should map staking transaction correctly", () => {
825
862
  const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
826
863
 
827
- const operation = sdk.alpacaTransactionToOp(address, mockStakingTx(address, "-1000000000"));
864
+ const operation = sdk.alpacaTransactionToOp(address, mockStakingTx(address, "-1001050000"));
828
865
 
829
866
  expect(operation.id).toEqual("delegate_tx_digest_123");
830
867
  expect(operation.type).toEqual("DELEGATE");
@@ -838,7 +875,7 @@ describe("Staking Operations", () => {
838
875
  test("transactionToOp should map unstaking transaction correctly", () => {
839
876
  const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
840
877
 
841
- const operation = sdk.alpacaTransactionToOp(address, mockUnstakingTx(address, "1000000000"));
878
+ const operation = sdk.alpacaTransactionToOp(address, mockUnstakingTx(address, "998950000"));
842
879
 
843
880
  expect(operation.id).toEqual("undelegate_tx_digest_456");
844
881
  expect(operation.type).toEqual("UNDELEGATE");
@@ -1737,17 +1774,22 @@ describe("filterOperations", () => {
1737
1774
  describe("conversion methods", () => {
1738
1775
  test("toBlockOperation should map native transfers correctly", () => {
1739
1776
  expect(
1740
- sdk.toBlockOperation(mockTransaction, {
1741
- owner: {
1742
- AddressOwner: "0x65449f57946938c84c5127",
1777
+ sdk.toBlockOperation(
1778
+ mockTransaction,
1779
+ {
1780
+ owner: {
1781
+ AddressOwner: "0x65449f57946938c84c5127",
1782
+ },
1783
+ coinType: sdk.DEFAULT_COIN_TYPE,
1784
+ amount: "-10000000000",
1743
1785
  },
1744
- coinType: sdk.DEFAULT_COIN_TYPE,
1745
- amount: "-10000000000",
1746
- }),
1786
+ BigNumber(0),
1787
+ ),
1747
1788
  ).toEqual([
1748
1789
  {
1749
1790
  type: "transfer",
1750
1791
  address: "0x65449f57946938c84c5127",
1792
+ peer: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
1751
1793
  amount: -10000000000n,
1752
1794
  asset: { type: "native" },
1753
1795
  },
@@ -1756,68 +1798,89 @@ describe("filterOperations", () => {
1756
1798
 
1757
1799
  test("toBlockOperation should ignore transfers from shared owner", () => {
1758
1800
  expect(
1759
- sdk.toBlockOperation(mockTransaction, {
1760
- owner: {
1761
- Shared: {
1762
- initial_shared_version: "0",
1801
+ sdk.toBlockOperation(
1802
+ mockTransaction,
1803
+ {
1804
+ owner: {
1805
+ Shared: {
1806
+ initial_shared_version: "0",
1807
+ },
1763
1808
  },
1809
+ coinType: sdk.DEFAULT_COIN_TYPE,
1810
+ amount: "-10000000000",
1764
1811
  },
1765
- coinType: sdk.DEFAULT_COIN_TYPE,
1766
- amount: "-10000000000",
1767
- }),
1812
+ BigNumber(0),
1813
+ ),
1768
1814
  ).toEqual([]);
1769
1815
  });
1770
1816
 
1771
1817
  test("toBlockOperation should ignore transfers from object owner", () => {
1772
1818
  expect(
1773
- sdk.toBlockOperation(mockTransaction, {
1774
- owner: {
1775
- ObjectOwner: "test",
1819
+ sdk.toBlockOperation(
1820
+ mockTransaction,
1821
+ {
1822
+ owner: {
1823
+ ObjectOwner: "test",
1824
+ },
1825
+ coinType: sdk.DEFAULT_COIN_TYPE,
1826
+ amount: "-10000000000",
1776
1827
  },
1777
- coinType: sdk.DEFAULT_COIN_TYPE,
1778
- amount: "-10000000000",
1779
- }),
1828
+ BigNumber(0),
1829
+ ),
1780
1830
  ).toEqual([]);
1781
1831
  });
1782
1832
 
1783
1833
  test("toBlockOperation should ignore transfers from immutable owner", () => {
1784
1834
  expect(
1785
- sdk.toBlockOperation(mockTransaction, {
1786
- owner: "Immutable",
1787
- coinType: sdk.DEFAULT_COIN_TYPE,
1788
- amount: "-10000000000",
1789
- }),
1835
+ sdk.toBlockOperation(
1836
+ mockTransaction,
1837
+ {
1838
+ owner: "Immutable",
1839
+ coinType: sdk.DEFAULT_COIN_TYPE,
1840
+ amount: "-10000000000",
1841
+ },
1842
+ BigNumber(0),
1843
+ ),
1790
1844
  ).toEqual([]);
1791
1845
  });
1792
1846
 
1793
1847
  test("toBlockOperation should ignore transfers from consensus owner", () => {
1794
1848
  expect(
1795
- sdk.toBlockOperation(mockTransaction, {
1796
- owner: {
1797
- ConsensusAddressOwner: {
1798
- owner: "test",
1799
- start_version: "1",
1849
+ sdk.toBlockOperation(
1850
+ mockTransaction,
1851
+ {
1852
+ owner: {
1853
+ ConsensusAddressOwner: {
1854
+ owner: "test",
1855
+ start_version: "1",
1856
+ },
1800
1857
  },
1858
+ coinType: sdk.DEFAULT_COIN_TYPE,
1859
+ amount: "-10000000000",
1801
1860
  },
1802
- coinType: sdk.DEFAULT_COIN_TYPE,
1803
- amount: "-10000000000",
1804
- }),
1861
+ BigNumber(0),
1862
+ ),
1805
1863
  ).toEqual([]);
1806
1864
  });
1807
1865
 
1808
1866
  test("toBlockOperation should map token transfers correctly", () => {
1809
1867
  expect(
1810
- sdk.toBlockOperation(mockTransaction, {
1811
- owner: {
1812
- AddressOwner: "0x65449f57946938c84c5127",
1868
+ sdk.toBlockOperation(
1869
+ mockTransaction,
1870
+ {
1871
+ owner: {
1872
+ AddressOwner: "0x65449f57946938c84c5127",
1873
+ },
1874
+ coinType: "0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC",
1875
+ amount: "8824",
1813
1876
  },
1814
- coinType: "0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC",
1815
- amount: "8824",
1816
- }),
1877
+ BigNumber(0),
1878
+ ),
1817
1879
  ).toEqual([
1818
1880
  {
1819
1881
  type: "transfer",
1820
1882
  address: "0x65449f57946938c84c5127",
1883
+ peer: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
1821
1884
  amount: 8824n,
1822
1885
  asset: {
1823
1886
  type: "token",
@@ -1830,18 +1893,22 @@ describe("filterOperations", () => {
1830
1893
  test("toBlockOperation should map staking operations correctly", () => {
1831
1894
  const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
1832
1895
  expect(
1833
- sdk.toBlockOperation(mockStakingTx(address, "-1000000000"), {
1834
- owner: { AddressOwner: address },
1835
- coinType: sdk.DEFAULT_COIN_TYPE,
1836
- amount: "-10000000000",
1837
- }),
1896
+ sdk.toBlockOperation(
1897
+ mockStakingTx(address, "-1000000000"),
1898
+ {
1899
+ owner: { AddressOwner: address },
1900
+ coinType: sdk.DEFAULT_COIN_TYPE,
1901
+ amount: "-10000000000",
1902
+ },
1903
+ BigNumber(0),
1904
+ ),
1838
1905
  ).toEqual([
1839
1906
  {
1840
1907
  type: "other",
1841
1908
  operationType: "DELEGATE",
1842
1909
  address: address,
1843
1910
  asset: { type: "native" },
1844
- amount: 10000000000n,
1911
+ amount: -10000000000n,
1845
1912
  },
1846
1913
  ]);
1847
1914
  });
@@ -1849,11 +1916,15 @@ describe("filterOperations", () => {
1849
1916
  test("toBlockOperation should map unstaking operations correctly", () => {
1850
1917
  const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
1851
1918
  expect(
1852
- sdk.toBlockOperation(mockUnstakingTx(address, "1000000000"), {
1853
- owner: { AddressOwner: address },
1854
- coinType: sdk.DEFAULT_COIN_TYPE,
1855
- amount: "10000000000",
1856
- }),
1919
+ sdk.toBlockOperation(
1920
+ mockUnstakingTx(address, "1000000000"),
1921
+ {
1922
+ owner: { AddressOwner: address },
1923
+ coinType: sdk.DEFAULT_COIN_TYPE,
1924
+ amount: "10000000000",
1925
+ },
1926
+ BigNumber(0),
1927
+ ),
1857
1928
  ).toEqual([
1858
1929
  {
1859
1930
  type: "other",
@@ -1909,18 +1980,21 @@ describe("filterOperations", () => {
1909
1980
  operations: [
1910
1981
  {
1911
1982
  address: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
1912
- amount: -10000000000n,
1983
+ peer: "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
1984
+ amount: -9998990120n,
1913
1985
  asset: { type: "native" },
1914
1986
  type: "transfer",
1915
1987
  },
1916
1988
  {
1917
1989
  address: "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
1990
+ peer: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
1918
1991
  amount: 9998990120n,
1919
1992
  asset: { type: "native" },
1920
1993
  type: "transfer",
1921
1994
  },
1922
1995
  {
1923
1996
  address: "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
1997
+ peer: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
1924
1998
  amount: 500000n,
1925
1999
  asset: { type: "token", assetReference: "0x123::test::TOKEN" },
1926
2000
  type: "transfer",