@ledgerhq/coin-sui 0.2.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (459) hide show
  1. package/.eslintrc.js +23 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +19 -0
  4. package/CHANGELOG.md +18 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest.config.js +9 -0
  7. package/jest.integ.config.js +7 -0
  8. package/lib/api/chain/index.d.ts +16 -0
  9. package/lib/api/chain/index.d.ts.map +1 -0
  10. package/lib/api/chain/index.js +3 -0
  11. package/lib/api/chain/index.js.map +1 -0
  12. package/lib/bridge/bridge.integration.test.d.ts +4 -0
  13. package/lib/bridge/bridge.integration.test.d.ts.map +1 -0
  14. package/lib/bridge/bridge.integration.test.js +136 -0
  15. package/lib/bridge/bridge.integration.test.js.map +1 -0
  16. package/lib/bridge/broadcast.d.ts +12 -0
  17. package/lib/bridge/broadcast.d.ts.map +1 -0
  18. package/lib/bridge/broadcast.js +20 -0
  19. package/lib/bridge/broadcast.js.map +1 -0
  20. package/lib/bridge/broadcast.test.d.ts +2 -0
  21. package/lib/bridge/broadcast.test.d.ts.map +1 -0
  22. package/lib/bridge/broadcast.test.js +48 -0
  23. package/lib/bridge/broadcast.test.js.map +1 -0
  24. package/lib/bridge/buildOptimisticOperation.d.ts +4 -0
  25. package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -0
  26. package/lib/bridge/buildOptimisticOperation.js +76 -0
  27. package/lib/bridge/buildOptimisticOperation.js.map +1 -0
  28. package/lib/bridge/buildOptimisticOperation.test.d.ts +2 -0
  29. package/lib/bridge/buildOptimisticOperation.test.d.ts.map +1 -0
  30. package/lib/bridge/buildOptimisticOperation.test.js +52 -0
  31. package/lib/bridge/buildOptimisticOperation.test.js.map +1 -0
  32. package/lib/bridge/buildTransaction.d.ts +9 -0
  33. package/lib/bridge/buildTransaction.d.ts.map +1 -0
  34. package/lib/bridge/buildTransaction.js +19 -0
  35. package/lib/bridge/buildTransaction.js.map +1 -0
  36. package/lib/bridge/buildTransaction.test.d.ts +2 -0
  37. package/lib/bridge/buildTransaction.test.d.ts.map +1 -0
  38. package/lib/bridge/buildTransaction.test.js +17 -0
  39. package/lib/bridge/buildTransaction.test.js.map +1 -0
  40. package/lib/bridge/createTransaction.d.ts +10 -0
  41. package/lib/bridge/createTransaction.d.ts.map +1 -0
  42. package/lib/bridge/createTransaction.js +24 -0
  43. package/lib/bridge/createTransaction.js.map +1 -0
  44. package/lib/bridge/estimateMaxSpendable.d.ts +14 -0
  45. package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
  46. package/lib/bridge/estimateMaxSpendable.js +44 -0
  47. package/lib/bridge/estimateMaxSpendable.js.map +1 -0
  48. package/lib/bridge/estimateMaxSpendable.test.d.ts +2 -0
  49. package/lib/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  50. package/lib/bridge/estimateMaxSpendable.test.js +25 -0
  51. package/lib/bridge/estimateMaxSpendable.test.js.map +1 -0
  52. package/lib/bridge/formatters.d.ts +10 -0
  53. package/lib/bridge/formatters.d.ts.map +1 -0
  54. package/lib/bridge/formatters.js +24 -0
  55. package/lib/bridge/formatters.js.map +1 -0
  56. package/lib/bridge/formatters.test.d.ts +2 -0
  57. package/lib/bridge/formatters.test.d.ts.map +1 -0
  58. package/lib/bridge/formatters.test.js +18 -0
  59. package/lib/bridge/formatters.test.js.map +1 -0
  60. package/lib/bridge/getFeesForTransaction.d.ts +15 -0
  61. package/lib/bridge/getFeesForTransaction.d.ts.map +1 -0
  62. package/lib/bridge/getFeesForTransaction.js +32 -0
  63. package/lib/bridge/getFeesForTransaction.js.map +1 -0
  64. package/lib/bridge/getFeesForTransaction.test.d.ts +2 -0
  65. package/lib/bridge/getFeesForTransaction.test.d.ts.map +1 -0
  66. package/lib/bridge/getFeesForTransaction.test.js +35 -0
  67. package/lib/bridge/getFeesForTransaction.test.js.map +1 -0
  68. package/lib/bridge/getTransactionStatus.d.ts +12 -0
  69. package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
  70. package/lib/bridge/getTransactionStatus.js +59 -0
  71. package/lib/bridge/getTransactionStatus.js.map +1 -0
  72. package/lib/bridge/getTransactionStatus.test.d.ts +2 -0
  73. package/lib/bridge/getTransactionStatus.test.d.ts.map +1 -0
  74. package/lib/bridge/getTransactionStatus.test.js +48 -0
  75. package/lib/bridge/getTransactionStatus.test.js.map +1 -0
  76. package/lib/bridge/index.d.ts +10 -0
  77. package/lib/bridge/index.d.ts.map +1 -0
  78. package/lib/bridge/index.js +63 -0
  79. package/lib/bridge/index.js.map +1 -0
  80. package/lib/bridge/preload.d.ts +11 -0
  81. package/lib/bridge/preload.d.ts.map +1 -0
  82. package/lib/bridge/preload.js +41 -0
  83. package/lib/bridge/preload.js.map +1 -0
  84. package/lib/bridge/prepareTransaction.d.ts +13 -0
  85. package/lib/bridge/prepareTransaction.d.ts.map +1 -0
  86. package/lib/bridge/prepareTransaction.js +43 -0
  87. package/lib/bridge/prepareTransaction.js.map +1 -0
  88. package/lib/bridge/prepareTransaction.test.d.ts +2 -0
  89. package/lib/bridge/prepareTransaction.test.d.ts.map +1 -0
  90. package/lib/bridge/prepareTransaction.test.js +45 -0
  91. package/lib/bridge/prepareTransaction.test.js.map +1 -0
  92. package/lib/bridge/serialization.d.ts +7 -0
  93. package/lib/bridge/serialization.d.ts.map +1 -0
  94. package/lib/bridge/serialization.js +27 -0
  95. package/lib/bridge/serialization.js.map +1 -0
  96. package/lib/bridge/serialization.test.d.ts +2 -0
  97. package/lib/bridge/serialization.test.d.ts.map +1 -0
  98. package/lib/bridge/serialization.test.js +131 -0
  99. package/lib/bridge/serialization.test.js.map +1 -0
  100. package/lib/bridge/signOperation.d.ts +9 -0
  101. package/lib/bridge/signOperation.d.ts.map +1 -0
  102. package/lib/bridge/signOperation.js +72 -0
  103. package/lib/bridge/signOperation.js.map +1 -0
  104. package/lib/bridge/signOperation.test.d.ts +2 -0
  105. package/lib/bridge/signOperation.test.d.ts.map +1 -0
  106. package/lib/bridge/signOperation.test.js +76 -0
  107. package/lib/bridge/signOperation.test.js.map +1 -0
  108. package/lib/bridge/synchronisation.d.ts +21 -0
  109. package/lib/bridge/synchronisation.d.ts.map +1 -0
  110. package/lib/bridge/synchronisation.js +65 -0
  111. package/lib/bridge/synchronisation.js.map +1 -0
  112. package/lib/bridge/synchronisation.test.d.ts +2 -0
  113. package/lib/bridge/synchronisation.test.d.ts.map +1 -0
  114. package/lib/bridge/synchronisation.test.js +118 -0
  115. package/lib/bridge/synchronisation.test.js.map +1 -0
  116. package/lib/bridge/transaction.d.ts +15 -0
  117. package/lib/bridge/transaction.d.ts.map +1 -0
  118. package/lib/bridge/transaction.js +55 -0
  119. package/lib/bridge/transaction.js.map +1 -0
  120. package/lib/bridge/transaction.test.d.ts +2 -0
  121. package/lib/bridge/transaction.test.d.ts.map +1 -0
  122. package/lib/bridge/transaction.test.js +65 -0
  123. package/lib/bridge/transaction.test.js.map +1 -0
  124. package/lib/bridge/utils.d.ts +27 -0
  125. package/lib/bridge/utils.d.ts.map +1 -0
  126. package/lib/bridge/utils.js +57 -0
  127. package/lib/bridge/utils.js.map +1 -0
  128. package/lib/config.d.ts +15 -0
  129. package/lib/config.d.ts.map +1 -0
  130. package/lib/config.js +9 -0
  131. package/lib/config.js.map +1 -0
  132. package/lib/index.d.ts +3 -0
  133. package/lib/index.d.ts.map +1 -0
  134. package/lib/index.js +21 -0
  135. package/lib/index.js.map +1 -0
  136. package/lib/logic/broadcast.d.ts +9 -0
  137. package/lib/logic/broadcast.d.ts.map +1 -0
  138. package/lib/logic/broadcast.js +26 -0
  139. package/lib/logic/broadcast.js.map +1 -0
  140. package/lib/logic/craftTransaction.d.ts +17 -0
  141. package/lib/logic/craftTransaction.d.ts.map +1 -0
  142. package/lib/logic/craftTransaction.js +22 -0
  143. package/lib/logic/craftTransaction.js.map +1 -0
  144. package/lib/logic/estimateFees.d.ts +10 -0
  145. package/lib/logic/estimateFees.d.ts.map +1 -0
  146. package/lib/logic/estimateFees.js +20 -0
  147. package/lib/logic/estimateFees.js.map +1 -0
  148. package/lib/logic/index.d.ts +4 -0
  149. package/lib/logic/index.d.ts.map +1 -0
  150. package/lib/logic/index.js +10 -0
  151. package/lib/logic/index.js.map +1 -0
  152. package/lib/network/index.d.ts +18 -0
  153. package/lib/network/index.d.ts.map +1 -0
  154. package/lib/network/index.js +17 -0
  155. package/lib/network/index.js.map +1 -0
  156. package/lib/network/sdk.d.ts +61 -0
  157. package/lib/network/sdk.d.ts.map +1 -0
  158. package/lib/network/sdk.integration.test.d.ts +2 -0
  159. package/lib/network/sdk.integration.test.d.ts.map +1 -0
  160. package/lib/network/sdk.integration.test.js +70 -0
  161. package/lib/network/sdk.integration.test.js.map +1 -0
  162. package/lib/network/sdk.js +205 -0
  163. package/lib/network/sdk.js.map +1 -0
  164. package/lib/network/sdk.test.d.ts +2 -0
  165. package/lib/network/sdk.test.d.ts.map +1 -0
  166. package/lib/network/sdk.test.js +166 -0
  167. package/lib/network/sdk.test.js.map +1 -0
  168. package/lib/signer/getAddress.d.ts +6 -0
  169. package/lib/signer/getAddress.d.ts.map +1 -0
  170. package/lib/signer/getAddress.js +20 -0
  171. package/lib/signer/getAddress.js.map +1 -0
  172. package/lib/signer/getAddress.test.d.ts +2 -0
  173. package/lib/signer/getAddress.test.d.ts.map +1 -0
  174. package/lib/signer/getAddress.test.js +106 -0
  175. package/lib/signer/getAddress.test.js.map +1 -0
  176. package/lib/signer/index.d.ts +6 -0
  177. package/lib/signer/index.d.ts.map +1 -0
  178. package/lib/signer/index.js +11 -0
  179. package/lib/signer/index.js.map +1 -0
  180. package/lib/test/cli.d.ts +16 -0
  181. package/lib/test/cli.d.ts.map +1 -0
  182. package/lib/test/cli.js +16 -0
  183. package/lib/test/cli.js.map +1 -0
  184. package/lib/types/bridge.d.ts +72 -0
  185. package/lib/types/bridge.d.ts.map +1 -0
  186. package/lib/types/bridge.fixture.d.ts +30 -0
  187. package/lib/types/bridge.fixture.d.ts.map +1 -0
  188. package/lib/types/bridge.fixture.js +86 -0
  189. package/lib/types/bridge.fixture.js.map +1 -0
  190. package/lib/types/bridge.js +3 -0
  191. package/lib/types/bridge.js.map +1 -0
  192. package/lib/types/index.d.ts +4 -0
  193. package/lib/types/index.d.ts.map +1 -0
  194. package/lib/types/index.js +20 -0
  195. package/lib/types/index.js.map +1 -0
  196. package/lib/types/model.d.ts +6 -0
  197. package/lib/types/model.d.ts.map +1 -0
  198. package/lib/types/model.js +3 -0
  199. package/lib/types/model.js.map +1 -0
  200. package/lib/types/signer.d.ts +13 -0
  201. package/lib/types/signer.d.ts.map +1 -0
  202. package/lib/types/signer.js +3 -0
  203. package/lib/types/signer.js.map +1 -0
  204. package/lib/utils.d.ts +7 -0
  205. package/lib/utils.d.ts.map +1 -0
  206. package/lib/utils.js +13 -0
  207. package/lib/utils.js.map +1 -0
  208. package/lib-es/api/chain/index.d.ts +16 -0
  209. package/lib-es/api/chain/index.d.ts.map +1 -0
  210. package/lib-es/api/chain/index.js +2 -0
  211. package/lib-es/api/chain/index.js.map +1 -0
  212. package/lib-es/bridge/bridge.integration.test.d.ts +4 -0
  213. package/lib-es/bridge/bridge.integration.test.d.ts.map +1 -0
  214. package/lib-es/bridge/bridge.integration.test.js +130 -0
  215. package/lib-es/bridge/bridge.integration.test.js.map +1 -0
  216. package/lib-es/bridge/broadcast.d.ts +12 -0
  217. package/lib-es/bridge/broadcast.d.ts.map +1 -0
  218. package/lib-es/bridge/broadcast.js +16 -0
  219. package/lib-es/bridge/broadcast.js.map +1 -0
  220. package/lib-es/bridge/broadcast.test.d.ts +2 -0
  221. package/lib-es/bridge/broadcast.test.d.ts.map +1 -0
  222. package/lib-es/bridge/broadcast.test.js +46 -0
  223. package/lib-es/bridge/broadcast.test.js.map +1 -0
  224. package/lib-es/bridge/buildOptimisticOperation.d.ts +4 -0
  225. package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -0
  226. package/lib-es/bridge/buildOptimisticOperation.js +69 -0
  227. package/lib-es/bridge/buildOptimisticOperation.js.map +1 -0
  228. package/lib-es/bridge/buildOptimisticOperation.test.d.ts +2 -0
  229. package/lib-es/bridge/buildOptimisticOperation.test.d.ts.map +1 -0
  230. package/lib-es/bridge/buildOptimisticOperation.test.js +47 -0
  231. package/lib-es/bridge/buildOptimisticOperation.test.js.map +1 -0
  232. package/lib-es/bridge/buildTransaction.d.ts +9 -0
  233. package/lib-es/bridge/buildTransaction.d.ts.map +1 -0
  234. package/lib-es/bridge/buildTransaction.js +11 -0
  235. package/lib-es/bridge/buildTransaction.js.map +1 -0
  236. package/lib-es/bridge/buildTransaction.test.d.ts +2 -0
  237. package/lib-es/bridge/buildTransaction.test.d.ts.map +1 -0
  238. package/lib-es/bridge/buildTransaction.test.js +15 -0
  239. package/lib-es/bridge/buildTransaction.test.js.map +1 -0
  240. package/lib-es/bridge/createTransaction.d.ts +10 -0
  241. package/lib-es/bridge/createTransaction.d.ts.map +1 -0
  242. package/lib-es/bridge/createTransaction.js +20 -0
  243. package/lib-es/bridge/createTransaction.js.map +1 -0
  244. package/lib-es/bridge/estimateMaxSpendable.d.ts +14 -0
  245. package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
  246. package/lib-es/bridge/estimateMaxSpendable.js +37 -0
  247. package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
  248. package/lib-es/bridge/estimateMaxSpendable.test.d.ts +2 -0
  249. package/lib-es/bridge/estimateMaxSpendable.test.d.ts.map +1 -0
  250. package/lib-es/bridge/estimateMaxSpendable.test.js +23 -0
  251. package/lib-es/bridge/estimateMaxSpendable.test.js.map +1 -0
  252. package/lib-es/bridge/formatters.d.ts +10 -0
  253. package/lib-es/bridge/formatters.d.ts.map +1 -0
  254. package/lib-es/bridge/formatters.js +19 -0
  255. package/lib-es/bridge/formatters.js.map +1 -0
  256. package/lib-es/bridge/formatters.test.d.ts +2 -0
  257. package/lib-es/bridge/formatters.test.d.ts.map +1 -0
  258. package/lib-es/bridge/formatters.test.js +16 -0
  259. package/lib-es/bridge/formatters.test.js.map +1 -0
  260. package/lib-es/bridge/getFeesForTransaction.d.ts +15 -0
  261. package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -0
  262. package/lib-es/bridge/getFeesForTransaction.js +29 -0
  263. package/lib-es/bridge/getFeesForTransaction.js.map +1 -0
  264. package/lib-es/bridge/getFeesForTransaction.test.d.ts +2 -0
  265. package/lib-es/bridge/getFeesForTransaction.test.d.ts.map +1 -0
  266. package/lib-es/bridge/getFeesForTransaction.test.js +30 -0
  267. package/lib-es/bridge/getFeesForTransaction.test.js.map +1 -0
  268. package/lib-es/bridge/getTransactionStatus.d.ts +12 -0
  269. package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
  270. package/lib-es/bridge/getTransactionStatus.js +55 -0
  271. package/lib-es/bridge/getTransactionStatus.js.map +1 -0
  272. package/lib-es/bridge/getTransactionStatus.test.d.ts +2 -0
  273. package/lib-es/bridge/getTransactionStatus.test.d.ts.map +1 -0
  274. package/lib-es/bridge/getTransactionStatus.test.js +43 -0
  275. package/lib-es/bridge/getTransactionStatus.test.js.map +1 -0
  276. package/lib-es/bridge/index.d.ts +10 -0
  277. package/lib-es/bridge/index.d.ts.map +1 -0
  278. package/lib-es/bridge/index.js +56 -0
  279. package/lib-es/bridge/index.js.map +1 -0
  280. package/lib-es/bridge/preload.d.ts +11 -0
  281. package/lib-es/bridge/preload.d.ts.map +1 -0
  282. package/lib-es/bridge/preload.js +32 -0
  283. package/lib-es/bridge/preload.js.map +1 -0
  284. package/lib-es/bridge/prepareTransaction.d.ts +13 -0
  285. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
  286. package/lib-es/bridge/prepareTransaction.js +36 -0
  287. package/lib-es/bridge/prepareTransaction.js.map +1 -0
  288. package/lib-es/bridge/prepareTransaction.test.d.ts +2 -0
  289. package/lib-es/bridge/prepareTransaction.test.d.ts.map +1 -0
  290. package/lib-es/bridge/prepareTransaction.test.js +40 -0
  291. package/lib-es/bridge/prepareTransaction.test.js.map +1 -0
  292. package/lib-es/bridge/serialization.d.ts +7 -0
  293. package/lib-es/bridge/serialization.d.ts.map +1 -0
  294. package/lib-es/bridge/serialization.js +20 -0
  295. package/lib-es/bridge/serialization.js.map +1 -0
  296. package/lib-es/bridge/serialization.test.d.ts +2 -0
  297. package/lib-es/bridge/serialization.test.d.ts.map +1 -0
  298. package/lib-es/bridge/serialization.test.js +126 -0
  299. package/lib-es/bridge/serialization.test.js.map +1 -0
  300. package/lib-es/bridge/signOperation.d.ts +9 -0
  301. package/lib-es/bridge/signOperation.d.ts.map +1 -0
  302. package/lib-es/bridge/signOperation.js +68 -0
  303. package/lib-es/bridge/signOperation.js.map +1 -0
  304. package/lib-es/bridge/signOperation.test.d.ts +2 -0
  305. package/lib-es/bridge/signOperation.test.d.ts.map +1 -0
  306. package/lib-es/bridge/signOperation.test.js +71 -0
  307. package/lib-es/bridge/signOperation.test.js.map +1 -0
  308. package/lib-es/bridge/synchronisation.d.ts +21 -0
  309. package/lib-es/bridge/synchronisation.d.ts.map +1 -0
  310. package/lib-es/bridge/synchronisation.js +61 -0
  311. package/lib-es/bridge/synchronisation.js.map +1 -0
  312. package/lib-es/bridge/synchronisation.test.d.ts +2 -0
  313. package/lib-es/bridge/synchronisation.test.d.ts.map +1 -0
  314. package/lib-es/bridge/synchronisation.test.js +113 -0
  315. package/lib-es/bridge/synchronisation.test.js.map +1 -0
  316. package/lib-es/bridge/transaction.d.ts +15 -0
  317. package/lib-es/bridge/transaction.d.ts.map +1 -0
  318. package/lib-es/bridge/transaction.js +49 -0
  319. package/lib-es/bridge/transaction.js.map +1 -0
  320. package/lib-es/bridge/transaction.test.d.ts +2 -0
  321. package/lib-es/bridge/transaction.test.d.ts.map +1 -0
  322. package/lib-es/bridge/transaction.test.js +63 -0
  323. package/lib-es/bridge/transaction.test.js.map +1 -0
  324. package/lib-es/bridge/utils.d.ts +27 -0
  325. package/lib-es/bridge/utils.d.ts.map +1 -0
  326. package/lib-es/bridge/utils.js +51 -0
  327. package/lib-es/bridge/utils.js.map +1 -0
  328. package/lib-es/config.d.ts +15 -0
  329. package/lib-es/config.d.ts.map +1 -0
  330. package/lib-es/config.js +4 -0
  331. package/lib-es/config.js.map +1 -0
  332. package/lib-es/index.d.ts +3 -0
  333. package/lib-es/index.d.ts.map +1 -0
  334. package/lib-es/index.js +3 -0
  335. package/lib-es/index.js.map +1 -0
  336. package/lib-es/logic/broadcast.d.ts +9 -0
  337. package/lib-es/logic/broadcast.d.ts.map +1 -0
  338. package/lib-es/logic/broadcast.js +19 -0
  339. package/lib-es/logic/broadcast.js.map +1 -0
  340. package/lib-es/logic/craftTransaction.d.ts +17 -0
  341. package/lib-es/logic/craftTransaction.d.ts.map +1 -0
  342. package/lib-es/logic/craftTransaction.js +15 -0
  343. package/lib-es/logic/craftTransaction.js.map +1 -0
  344. package/lib-es/logic/estimateFees.d.ts +10 -0
  345. package/lib-es/logic/estimateFees.d.ts.map +1 -0
  346. package/lib-es/logic/estimateFees.js +13 -0
  347. package/lib-es/logic/estimateFees.js.map +1 -0
  348. package/lib-es/logic/index.d.ts +4 -0
  349. package/lib-es/logic/index.d.ts.map +1 -0
  350. package/lib-es/logic/index.js +4 -0
  351. package/lib-es/logic/index.js.map +1 -0
  352. package/lib-es/network/index.d.ts +18 -0
  353. package/lib-es/network/index.d.ts.map +1 -0
  354. package/lib-es/network/index.js +10 -0
  355. package/lib-es/network/index.js.map +1 -0
  356. package/lib-es/network/sdk.d.ts +61 -0
  357. package/lib-es/network/sdk.d.ts.map +1 -0
  358. package/lib-es/network/sdk.integration.test.d.ts +2 -0
  359. package/lib-es/network/sdk.integration.test.d.ts.map +1 -0
  360. package/lib-es/network/sdk.integration.test.js +65 -0
  361. package/lib-es/network/sdk.integration.test.js.map +1 -0
  362. package/lib-es/network/sdk.js +189 -0
  363. package/lib-es/network/sdk.js.map +1 -0
  364. package/lib-es/network/sdk.test.d.ts +2 -0
  365. package/lib-es/network/sdk.test.d.ts.map +1 -0
  366. package/lib-es/network/sdk.test.js +164 -0
  367. package/lib-es/network/sdk.test.js.map +1 -0
  368. package/lib-es/signer/getAddress.d.ts +6 -0
  369. package/lib-es/signer/getAddress.d.ts.map +1 -0
  370. package/lib-es/signer/getAddress.js +18 -0
  371. package/lib-es/signer/getAddress.js.map +1 -0
  372. package/lib-es/signer/getAddress.test.d.ts +2 -0
  373. package/lib-es/signer/getAddress.test.d.ts.map +1 -0
  374. package/lib-es/signer/getAddress.test.js +101 -0
  375. package/lib-es/signer/getAddress.test.js.map +1 -0
  376. package/lib-es/signer/index.d.ts +6 -0
  377. package/lib-es/signer/index.d.ts.map +1 -0
  378. package/lib-es/signer/index.js +6 -0
  379. package/lib-es/signer/index.js.map +1 -0
  380. package/lib-es/test/cli.d.ts +16 -0
  381. package/lib-es/test/cli.d.ts.map +1 -0
  382. package/lib-es/test/cli.js +13 -0
  383. package/lib-es/test/cli.js.map +1 -0
  384. package/lib-es/types/bridge.d.ts +72 -0
  385. package/lib-es/types/bridge.d.ts.map +1 -0
  386. package/lib-es/types/bridge.fixture.d.ts +30 -0
  387. package/lib-es/types/bridge.fixture.d.ts.map +1 -0
  388. package/lib-es/types/bridge.fixture.js +80 -0
  389. package/lib-es/types/bridge.fixture.js.map +1 -0
  390. package/lib-es/types/bridge.js +2 -0
  391. package/lib-es/types/bridge.js.map +1 -0
  392. package/lib-es/types/index.d.ts +4 -0
  393. package/lib-es/types/index.d.ts.map +1 -0
  394. package/lib-es/types/index.js +4 -0
  395. package/lib-es/types/index.js.map +1 -0
  396. package/lib-es/types/model.d.ts +6 -0
  397. package/lib-es/types/model.d.ts.map +1 -0
  398. package/lib-es/types/model.js +2 -0
  399. package/lib-es/types/model.js.map +1 -0
  400. package/lib-es/types/signer.d.ts +13 -0
  401. package/lib-es/types/signer.d.ts.map +1 -0
  402. package/lib-es/types/signer.js +2 -0
  403. package/lib-es/types/signer.js.map +1 -0
  404. package/lib-es/utils.d.ts +7 -0
  405. package/lib-es/utils.d.ts.map +1 -0
  406. package/lib-es/utils.js +9 -0
  407. package/lib-es/utils.js.map +1 -0
  408. package/package.json +152 -0
  409. package/src/api/chain/index.ts +17 -0
  410. package/src/bridge/bridge.integration.test.ts +140 -0
  411. package/src/bridge/broadcast.test.ts +52 -0
  412. package/src/bridge/broadcast.ts +21 -0
  413. package/src/bridge/buildOptimisticOperation.test.ts +53 -0
  414. package/src/bridge/buildOptimisticOperation.ts +105 -0
  415. package/src/bridge/buildTransaction.test.ts +17 -0
  416. package/src/bridge/buildTransaction.ts +14 -0
  417. package/src/bridge/createTransaction.ts +23 -0
  418. package/src/bridge/estimateMaxSpendable.test.ts +27 -0
  419. package/src/bridge/estimateMaxSpendable.ts +46 -0
  420. package/src/bridge/formatters.test.ts +17 -0
  421. package/src/bridge/formatters.ts +26 -0
  422. package/src/bridge/getFeesForTransaction.test.ts +36 -0
  423. package/src/bridge/getFeesForTransaction.ts +37 -0
  424. package/src/bridge/getTransactionStatus.test.ts +57 -0
  425. package/src/bridge/getTransactionStatus.ts +73 -0
  426. package/src/bridge/index.ts +77 -0
  427. package/src/bridge/preload.ts +46 -0
  428. package/src/bridge/prepareTransaction.test.ts +47 -0
  429. package/src/bridge/prepareTransaction.ts +44 -0
  430. package/src/bridge/serialization.test.ts +135 -0
  431. package/src/bridge/serialization.ts +24 -0
  432. package/src/bridge/signOperation.test.ts +80 -0
  433. package/src/bridge/signOperation.ts +101 -0
  434. package/src/bridge/synchronisation.test.ts +140 -0
  435. package/src/bridge/synchronisation.ts +75 -0
  436. package/src/bridge/transaction.test.ts +73 -0
  437. package/src/bridge/transaction.ts +61 -0
  438. package/src/bridge/utils.ts +69 -0
  439. package/src/config.ts +19 -0
  440. package/src/index.ts +3 -0
  441. package/src/logic/broadcast.ts +19 -0
  442. package/src/logic/craftTransaction.ts +28 -0
  443. package/src/logic/estimateFees.ts +14 -0
  444. package/src/logic/index.ts +3 -0
  445. package/src/network/index.ts +17 -0
  446. package/src/network/sdk.integration.test.ts +75 -0
  447. package/src/network/sdk.test.ts +203 -0
  448. package/src/network/sdk.ts +262 -0
  449. package/src/signer/getAddress.test.ts +119 -0
  450. package/src/signer/getAddress.ts +26 -0
  451. package/src/signer/index.ts +7 -0
  452. package/src/test/cli.ts +21 -0
  453. package/src/types/bridge.fixture.ts +84 -0
  454. package/src/types/bridge.ts +95 -0
  455. package/src/types/index.ts +3 -0
  456. package/src/types/model.ts +7 -0
  457. package/src/types/signer.ts +12 -0
  458. package/src/utils.ts +8 -0
  459. package/tsconfig.json +14 -0
@@ -0,0 +1,262 @@
1
+ import {
2
+ PaginatedTransactionResponse,
3
+ QueryTransactionBlocksParams,
4
+ SuiClient,
5
+ ExecuteTransactionBlockParams,
6
+ TransactionEffects,
7
+ } from "@mysten/sui/client";
8
+ import { TransactionBlockData, SuiTransactionBlockResponse, SuiCallArg } from "@mysten/sui/client";
9
+ import { Transaction } from "@mysten/sui/transactions";
10
+ import { BigNumber } from "bignumber.js";
11
+ import type { Operation, OperationType } from "@ledgerhq/types-live";
12
+
13
+ import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
14
+
15
+ import { makeLRUCache, minutes } from "@ledgerhq/live-network/cache";
16
+ import { getEnv } from "@ledgerhq/live-env";
17
+
18
+ import type { Transaction as TransactionType } from "../types";
19
+ import type { CreateExtrinsicArg } from "../logic/craftTransaction";
20
+ import { ensureAddressFormat } from "../utils";
21
+
22
+ type AsyncApiFunction<T> = (api: SuiClient) => Promise<T>;
23
+
24
+ const rpcUrl = getEnv("API_SUI_NODE_PROXY");
25
+
26
+ let api: SuiClient | null = null;
27
+
28
+ const TRANSACTIONS_REQUEST_LIMIT = 100;
29
+
30
+ const BLOCK_HEIGHT = 5; // sui has no block height metainfo, we use it simulate proper icon statuses in apps
31
+
32
+ /**
33
+ * Connects to Sui Api
34
+ */
35
+ async function withApi<T>(execute: AsyncApiFunction<T>) {
36
+ if (!api) {
37
+ api = new SuiClient({ url: rpcUrl });
38
+ }
39
+
40
+ const result = await execute(api);
41
+ return result;
42
+ }
43
+
44
+ export const getBalanceCached = makeLRUCache(
45
+ ({ api, owner }: { api: SuiClient; owner: string }) => api.getBalance({ owner }),
46
+ (params: { api: SuiClient; owner: string }) => params.owner,
47
+ minutes(1),
48
+ );
49
+
50
+ /**
51
+ * Get account balance
52
+ */
53
+ export const getAccount = async (addr: string) =>
54
+ withApi(async api => {
55
+ const balance = await getBalanceCached({ api, owner: addr });
56
+ return {
57
+ blockHeight: BLOCK_HEIGHT * 2,
58
+ balance: BigNumber(balance.totalBalance),
59
+ };
60
+ });
61
+
62
+ /**
63
+ * Returns true if account is the signer
64
+ */
65
+ export function isSender(addr: string, transaction?: TransactionBlockData): boolean {
66
+ return transaction?.sender === ensureAddressFormat(addr);
67
+ }
68
+
69
+ /**
70
+ * Map transaction to an Operation Type
71
+ */
72
+ export function getOperationType(addr: string, transaction?: TransactionBlockData): OperationType {
73
+ return isSender(addr, transaction) ? "OUT" : "IN";
74
+ }
75
+
76
+ /**
77
+ * Extract senders from transaction
78
+ */
79
+ export const getOperationSenders = (transaction?: TransactionBlockData): string[] => {
80
+ return transaction?.sender ? [transaction?.sender] : [];
81
+ };
82
+
83
+ /**
84
+ * Extract recipients from transaction
85
+ */
86
+ export const getOperationRecipients = (transaction?: TransactionBlockData): string[] => {
87
+ if (transaction?.transaction.kind === "ProgrammableTransaction") {
88
+ if (!transaction?.transaction?.inputs) return [];
89
+ const recipients: string[] = [];
90
+ transaction.transaction.inputs.forEach((input: SuiCallArg) => {
91
+ if ("valueType" in input && input.valueType === "address") {
92
+ recipients.push(String(input.value));
93
+ }
94
+ });
95
+ return recipients;
96
+ }
97
+ return [];
98
+ };
99
+
100
+ /**
101
+ * Extract value from transaction
102
+ */
103
+ export const getOperationAmount = (
104
+ address: string,
105
+ transaction: SuiTransactionBlockResponse,
106
+ ): BigNumber => {
107
+ let amount = new BigNumber(0);
108
+ if (!transaction?.balanceChanges) return amount;
109
+ for (const balanceChange of transaction.balanceChanges) {
110
+ if (
111
+ typeof balanceChange.owner !== "string" &&
112
+ "AddressOwner" in balanceChange.owner &&
113
+ balanceChange.owner.AddressOwner === address
114
+ ) {
115
+ if (balanceChange.amount[0] === "-") {
116
+ amount = amount.minus(balanceChange.amount);
117
+ } else {
118
+ amount = amount.plus(balanceChange.amount);
119
+ }
120
+ }
121
+ }
122
+ return amount;
123
+ };
124
+
125
+ /**
126
+ * Extract fee from transaction
127
+ */
128
+ export const getOperationFee = (transaction: SuiTransactionBlockResponse): BigNumber => {
129
+ const gas = transaction.effects!.gasUsed;
130
+
131
+ const computationCost = BigNumber(gas.computationCost);
132
+ const storageCost = BigNumber(gas.storageCost);
133
+ const storageRebate = BigNumber(gas.storageRebate);
134
+
135
+ return computationCost.plus(storageCost).minus(storageRebate);
136
+ };
137
+
138
+ /**
139
+ * Extract date from transaction
140
+ */
141
+ export const getOperationDate = (transaction: SuiTransactionBlockResponse): Date => {
142
+ return new Date(parseInt(transaction.timestampMs!));
143
+ };
144
+
145
+ /**
146
+ * Map the Sui history transaction to a Ledger Live Operation
147
+ */
148
+ export function transactionToOperation(
149
+ accountId: string,
150
+ address: string,
151
+ transaction: SuiTransactionBlockResponse,
152
+ ): Operation {
153
+ const type = getOperationType(address, transaction.transaction?.data);
154
+ const hash = transaction.digest;
155
+ return {
156
+ id: encodeOperationId(accountId, hash, type),
157
+ accountId,
158
+ blockHash: hash,
159
+ blockHeight: BLOCK_HEIGHT,
160
+ date: getOperationDate(transaction),
161
+ extra: {},
162
+ fee: getOperationFee(transaction),
163
+ hasFailed: transaction.effects?.status.status != "success",
164
+ hash,
165
+ recipients: getOperationRecipients(transaction.transaction?.data),
166
+ senders: getOperationSenders(transaction.transaction?.data),
167
+ type,
168
+ value: getOperationAmount(address, transaction),
169
+ };
170
+ }
171
+
172
+ /**
173
+ * Fetch operation list
174
+ */
175
+ export const getOperations = async (
176
+ accountId: string,
177
+ addr: string,
178
+ inCursor?: string | null | undefined,
179
+ outCursor?: string | null | undefined,
180
+ ): Promise<Operation[]> =>
181
+ withApi(async api => {
182
+ const sentOps = await loadOperation({ api, type: "OUT", addr, cursor: outCursor });
183
+ const receivedOps = await loadOperation({ api, type: "IN", addr, cursor: inCursor });
184
+ const rawTransactions = [...sentOps, ...receivedOps].sort(
185
+ (a, b) => Number(b.timestampMs) - Number(a.timestampMs),
186
+ );
187
+
188
+ return rawTransactions.map(transaction => transactionToOperation(accountId, addr, transaction));
189
+ });
190
+
191
+ const getTotalGasUsed = (effects?: TransactionEffects | null): bigint => {
192
+ const gasSummary = effects?.gasUsed;
193
+ if (!gasSummary) return BigInt(0);
194
+ return (
195
+ BigInt(gasSummary.computationCost) +
196
+ BigInt(gasSummary.storageCost) -
197
+ BigInt(gasSummary.storageRebate)
198
+ );
199
+ };
200
+
201
+ export const paymentInfo = async (sender: string, fakeTransaction: TransactionType) =>
202
+ withApi(async api => {
203
+ const tx = new Transaction();
204
+ tx.setSender(ensureAddressFormat(sender));
205
+ const [coin] = tx.splitCoins(tx.gas, [fakeTransaction.amount.toNumber()]);
206
+ tx.transferObjects([coin], fakeTransaction.recipient);
207
+ const txb = await tx.build({ client: api });
208
+ const dryRunTxResponse = await api.dryRunTransactionBlock({ transactionBlock: txb });
209
+ const fees = getTotalGasUsed(dryRunTxResponse.effects);
210
+ return {
211
+ gasBudget: dryRunTxResponse.input.gasData.budget,
212
+ totalGasUsed: fees,
213
+ fees,
214
+ };
215
+ });
216
+
217
+ export const createTransaction = async (address: string, transaction: CreateExtrinsicArg) =>
218
+ withApi(async api => {
219
+ const tx = new Transaction();
220
+ tx.setSender(ensureAddressFormat(address));
221
+
222
+ const [coin] = tx.splitCoins(tx.gas, [transaction.amount.toNumber()]);
223
+ tx.transferObjects([coin], transaction.recipient);
224
+
225
+ return tx.build({ client: api });
226
+ });
227
+
228
+ export const executeTransactionBlock = async (params: ExecuteTransactionBlockParams) =>
229
+ withApi(async api => {
230
+ return api.executeTransactionBlock(params);
231
+ });
232
+
233
+ // load from curos point or from begining until we reach the end
234
+ const loadOperation = async (params: {
235
+ api: SuiClient;
236
+ type: OperationType;
237
+ addr: string;
238
+ cursor?: string | null | undefined;
239
+ }): Promise<PaginatedTransactionResponse["data"]> => {
240
+ const { api, addr, type, cursor } = params;
241
+ const filter: QueryTransactionBlocksParams["filter"] =
242
+ type === "IN" ? { ToAddress: addr } : { FromAddress: addr };
243
+
244
+ const { data, nextCursor, hasNextPage } = await api.queryTransactionBlocks({
245
+ filter,
246
+ cursor,
247
+ order: "ascending",
248
+ options: {
249
+ showInput: true,
250
+ showBalanceChanges: true,
251
+ showEffects: true, // To get transaction status and gas fee details
252
+ },
253
+ limit: TRANSACTIONS_REQUEST_LIMIT,
254
+ });
255
+
256
+ if (hasNextPage) {
257
+ const newData = await loadOperation({ api, type, addr, cursor: nextCursor });
258
+ return [...newData, ...data];
259
+ }
260
+
261
+ return data;
262
+ };
@@ -0,0 +1,119 @@
1
+ import getAddressResolver from "./";
2
+
3
+ describe("getAddress resolver", () => {
4
+ const mockDeviceId = "mock-device-id";
5
+ const mockPath = "44'/784'/0'/0'/0'";
6
+
7
+ it("should successfully resolve an address", async () => {
8
+ // Mock address and public key data
9
+ const mockAddress = Buffer.from("0x123abc");
10
+ const mockPublicKey = Buffer.from("deadbeef");
11
+
12
+ const mockSigner = {
13
+ getPublicKey: jest.fn().mockResolvedValue({
14
+ address: mockAddress,
15
+ publicKey: mockPublicKey,
16
+ }),
17
+ };
18
+
19
+ const mockSignerContext = jest
20
+ .fn()
21
+ .mockImplementation((deviceId, callback) => callback(mockSigner));
22
+
23
+ const getAddress = getAddressResolver(mockSignerContext);
24
+
25
+ const result = await getAddress(mockDeviceId, {
26
+ currency: {
27
+ type: "CryptoCurrency",
28
+ id: "sui",
29
+ coinType: 784,
30
+ name: "Sui",
31
+ managerAppName: "Sui",
32
+ ticker: "SUI",
33
+ scheme: "sui",
34
+ color: "#000",
35
+ family: "sui",
36
+ units: [{ name: "Sui", code: "SUI", magnitude: 9 }],
37
+ explorerViews: [],
38
+ },
39
+ path: "44'/784'/0'/0'/0'",
40
+ derivationMode: "sui",
41
+ });
42
+
43
+ expect(result).toEqual({
44
+ address: "0x" + mockAddress.toString("hex"),
45
+ publicKey: mockPublicKey.toString("hex"),
46
+ path: mockPath,
47
+ });
48
+ });
49
+
50
+ it("should throw error when address is missing", async () => {
51
+ const mockSigner = {
52
+ getPublicKey: jest.fn().mockResolvedValue({
53
+ address: null,
54
+ publicKey: Buffer.from("deadbeef"),
55
+ }),
56
+ };
57
+
58
+ const mockSignerContext = jest
59
+ .fn()
60
+ .mockImplementation((deviceId, callback) => callback(mockSigner));
61
+
62
+ const getAddress = getAddressResolver(mockSignerContext);
63
+
64
+ await expect(
65
+ getAddress(mockDeviceId, {
66
+ currency: {
67
+ type: "CryptoCurrency",
68
+ id: "sui",
69
+ coinType: 784,
70
+ name: "Sui",
71
+ managerAppName: "Sui",
72
+ ticker: "SUI",
73
+ scheme: "sui",
74
+ color: "#000",
75
+ family: "sui",
76
+ units: [{ name: "Sui", code: "SUI", magnitude: 9 }],
77
+ explorerViews: [],
78
+ },
79
+ path: "44'/784'/0'/0'/0'",
80
+ derivationMode: "sui",
81
+ }),
82
+ ).rejects.toThrow("Failed to get address from device");
83
+ });
84
+
85
+ it("should throw error when publicKey is missing", async () => {
86
+ const mockSigner = {
87
+ getPublicKey: jest.fn().mockResolvedValue({
88
+ address: Buffer.from("0x123abc"),
89
+ publicKey: null,
90
+ }),
91
+ };
92
+
93
+ const mockSignerContext = jest
94
+ .fn()
95
+ .mockImplementation((deviceId, callback) => callback(mockSigner));
96
+
97
+ const getAddress = getAddressResolver(mockSignerContext);
98
+
99
+ await expect(
100
+ getAddress(mockDeviceId, {
101
+ currency: {
102
+ type: "CryptoCurrency",
103
+ id: "sui",
104
+ coinType: 784,
105
+ name: "Sui",
106
+ managerAppName: "Sui",
107
+ ticker: "SUI",
108
+ scheme: "sui",
109
+ color: "#000",
110
+ family: "sui",
111
+ units: [{ name: "Sui", code: "SUI", magnitude: 9 }],
112
+ explorerViews: [],
113
+ },
114
+ path: "44'/784'/0'/0'/0'",
115
+ derivationMode: "sui",
116
+ }),
117
+ ).rejects.toThrow("Failed to get address from device");
118
+ });
119
+ });
@@ -0,0 +1,26 @@
1
+ import { log } from "@ledgerhq/logs";
2
+ import type { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
3
+ import type { SignerContext } from "@ledgerhq/coin-framework/signer";
4
+ import type { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
5
+ import type { SuiSigner } from "../types";
6
+ import { ensureAddressFormat } from "../utils";
7
+
8
+ const resolver = (signerContext: SignerContext<SuiSigner>): GetAddressFn => {
9
+ return async (deviceId: string, { path, verify }: GetAddressOptions) => {
10
+ log("debug", "start getAddress process");
11
+
12
+ const result = await signerContext(deviceId, signer => signer.getPublicKey(path, verify));
13
+
14
+ if (!result.address || !result.publicKey) {
15
+ throw Error("Failed to get address from device");
16
+ }
17
+
18
+ return {
19
+ address: ensureAddressFormat(Buffer.from(result.address).toString("hex")),
20
+ publicKey: Buffer.from(result.publicKey).toString("hex"),
21
+ path,
22
+ };
23
+ };
24
+ };
25
+
26
+ export default resolver;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This directory is the home for all types and logic based on Ledgers signer.
3
+ */
4
+
5
+ import getAddress from "./getAddress";
6
+
7
+ export default getAddress;
@@ -0,0 +1,21 @@
1
+ type Options =
2
+ | { name: string; type: StringConstructor; desc: string }
3
+ | { name: string; type: StringConstructor; desc: string; multiple: boolean };
4
+
5
+ const options: Array<Options> = [
6
+ {
7
+ name: "mode",
8
+ type: String,
9
+ desc: "mode of transaction: send",
10
+ },
11
+ ];
12
+
13
+ export type CliTools = {
14
+ options: Array<Options>;
15
+ };
16
+
17
+ export default function makeCliTools(): CliTools {
18
+ return {
19
+ options,
20
+ };
21
+ }
@@ -0,0 +1,84 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { SuiAccount } from "./bridge";
3
+
4
+ export const createFixtureAccount = (overrides = {}) =>
5
+ ({
6
+ type: "Account",
7
+ id: "js:2:sui:0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0:sui",
8
+ used: true,
9
+ seedIdentifier: "99807c4b6e1b8b25120f633f5f7816a393e4d3e7f84bdf24bd8afe725911be91",
10
+ derivationMode: "sui",
11
+ index: 0,
12
+ freshAddress: "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
13
+ freshAddressPath: "44'/784'/0'/0'/0'",
14
+ blockHeight: 10,
15
+ creationDate: new Date(),
16
+ balance: BigNumber(17997970360),
17
+ spendableBalance: BigNumber(17997970360),
18
+ operations: [],
19
+ operationsCount: 2,
20
+ pendingOperations: [],
21
+ currency: {
22
+ type: "CryptoCurrency",
23
+ id: "sui",
24
+ coinType: 784,
25
+ name: "Sui",
26
+ managerAppName: "Sui",
27
+ ticker: "SUI",
28
+ scheme: "sui",
29
+ color: "#000",
30
+ family: "sui",
31
+ units: [{ name: "Sui", code: "SUI", magnitude: 9 }],
32
+ explorerViews: [
33
+ {
34
+ tx: "https://suiscan.xyz/mainnet/tx/$hash",
35
+ address: "https://suiscan.xyz/mainnet/account/$address",
36
+ },
37
+ {
38
+ tx: "https://suivision.xyz/txblock/$hash",
39
+ address: "https://suivision.xyz/account/$address",
40
+ },
41
+ ],
42
+ },
43
+ lastSyncDate: new Date(),
44
+ swapHistory: [],
45
+ balanceHistoryCache: {
46
+ HOUR: {
47
+ balances: [0],
48
+ latestDate: new Date().getMilliseconds(),
49
+ },
50
+ DAY: { balances: [0], latestDate: new Date().getMilliseconds() },
51
+ WEEK: { balances: [0], latestDate: new Date().getMilliseconds() },
52
+ },
53
+ subAccounts: [],
54
+ suiResources: { nonce: 0 },
55
+ ...overrides,
56
+ }) as SuiAccount;
57
+
58
+ export const createFixtureTransaction = (overrides = {}) => ({
59
+ family: "sui" as const,
60
+ mode: "send",
61
+ amount: BigNumber(3000000000),
62
+ recipient: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
63
+ useAllAmount: false,
64
+ fees: BigNumber(3976000),
65
+ errors: {},
66
+ skipVerify: true,
67
+ ...overrides,
68
+ });
69
+
70
+ export const createFixtureOperation = (overrides = {}) => ({
71
+ hash: "44298e5b1b7d73efc",
72
+ fee: BigNumber(3976000),
73
+ blockHash: null,
74
+ blockHeight: null,
75
+ extra: { transferAmount: BigNumber(1000000000) },
76
+ id: "js:2:sui:0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0:sui--OUT",
77
+ type: "OUT" as const,
78
+ value: BigNumber(1003976000),
79
+ senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
80
+ recipients: ["0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24"],
81
+ accountId: "js:2:sui:0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0:sui",
82
+ date: new Date(),
83
+ ...overrides,
84
+ });
@@ -0,0 +1,95 @@
1
+ import type { BigNumber } from "bignumber.js";
2
+ import type {
3
+ TransactionCommon,
4
+ TransactionCommonRaw,
5
+ TransactionStatusCommon,
6
+ TransactionStatusCommonRaw,
7
+ Operation,
8
+ OperationRaw,
9
+ } from "@ledgerhq/types-live";
10
+ import type { Account, AccountRaw } from "@ledgerhq/types-live";
11
+
12
+ /**
13
+ * Sui account resources
14
+ */
15
+ export type SuiResources = object;
16
+
17
+ /**
18
+ * Sui account resources from raw JSON
19
+ */
20
+ export type SuiResourcesRaw = object;
21
+
22
+ /**
23
+ * Sui transaction
24
+ */
25
+ export type Transaction = TransactionCommon & {
26
+ mode: string;
27
+ family: "sui";
28
+ amount: BigNumber | null;
29
+ fees?: BigNumber | null;
30
+ errors: Record<string, Error>;
31
+ skipVerify?: boolean;
32
+ // add here all transaction-specific fields when implement other modes than "send"
33
+ };
34
+
35
+ /**
36
+ * Sui transaction from a raw JSON
37
+ */
38
+ export type TransactionRaw = TransactionCommonRaw & {
39
+ family: "sui";
40
+ mode: string;
41
+ fees?: string;
42
+ // also the transaction fields as raw JSON data
43
+ };
44
+
45
+ /**
46
+ * Sui currency data that will be preloaded.
47
+ * You can for instance add a list of validators for Proof-of-Stake blockchains,
48
+ * or any volatile data that could not be set as constants in the code (staking progress, fee estimation variables, etc.)
49
+ */
50
+ export type SuiPreloadData = object;
51
+
52
+ export type SuiAccount = Account & {
53
+ // On some blockchain, an account can have resources (gained, delegated, ...)
54
+ suiResources?: SuiResources;
55
+ };
56
+
57
+ export type SuiAccountRaw = AccountRaw & {
58
+ suiResources?: SuiResourcesRaw;
59
+ };
60
+
61
+ export type TransactionStatus = TransactionStatusCommon;
62
+ export type TransactionStatusRaw = TransactionStatusCommonRaw;
63
+
64
+ export type SuiOperation = Operation<SuiOperationExtra>;
65
+ export type SuiOperationRaw = OperationRaw<SuiOperationExtraRaw>;
66
+
67
+ export type SuiOperationExtra = {
68
+ transferAmount?: BigNumber;
69
+ };
70
+ export type SuiOperationExtraRaw = Record<string, string>;
71
+
72
+ export type SuiSignedOperation = {
73
+ operation: SuiOperation;
74
+ signature: string;
75
+ rawData: {
76
+ unsigned: string;
77
+ serializedSignature: string;
78
+ };
79
+ };
80
+
81
+ export type TransferCommand = {
82
+ kind: "transfer";
83
+ sender: string;
84
+ recipient: string;
85
+ amount: number;
86
+ };
87
+
88
+ export type Command = TransferCommand;
89
+
90
+ export type CommandDescriptor = {
91
+ command: Command;
92
+ fee: number;
93
+ warnings: Record<string, Error>;
94
+ errors: Record<string, Error>;
95
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./bridge";
2
+ export * from "./model";
3
+ export * from "./signer";
@@ -0,0 +1,7 @@
1
+ export type SuiOperationMode = "send";
2
+
3
+ export type AccountInfoResponse = Record<string, string>;
4
+
5
+ export type CoreTransaction = {
6
+ unsigned: Uint8Array;
7
+ };
@@ -0,0 +1,12 @@
1
+ import Sui from "@ledgerhq/hw-app-sui";
2
+
3
+ export type SuiAddress = {
4
+ pubKey: string;
5
+ address: string;
6
+ return_code: number;
7
+ };
8
+ export type SuiSignature = {
9
+ signature: null | string;
10
+ return_code: number;
11
+ };
12
+ export interface SuiSigner extends Sui {}
package/src/utils.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Ensures that the address is in the format `0x...`
3
+ * @param addr The address to ensure the format of
4
+ * @returns The address in the format `0x...`
5
+ */
6
+ export function ensureAddressFormat(addr: string): `0x${string}` {
7
+ return (addr?.startsWith("0x") ? addr : `0x${addr}`) as `0x${string}`;
8
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../../../tsconfig.base",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationMap": true,
6
+ "downlevelIteration": true,
7
+ "lib": ["es2020", "dom"],
8
+ "rootDir": "./src",
9
+ "exactOptionalPropertyTypes": true,
10
+ "module": "ESNext",
11
+ "moduleResolution": "bundler"
12
+ },
13
+ "include": ["src/**/*"]
14
+ }