@ledgerhq/coin-icon 0.4.1-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 (341) hide show
  1. package/.eslintrc.js +20 -0
  2. package/.turbo/turbo-build.log +4 -0
  3. package/.unimportedrc.json +41 -0
  4. package/CHANGELOG.md +495 -0
  5. package/LICENSE.txt +21 -0
  6. package/jest.config.js +11 -0
  7. package/lib/__test__/api/index.unit.test.d.ts +2 -0
  8. package/lib/__test__/api/index.unit.test.d.ts.map +1 -0
  9. package/lib/__test__/api/index.unit.test.js +173 -0
  10. package/lib/__test__/api/index.unit.test.js.map +1 -0
  11. package/lib/__test__/unit/buildTransaction.test.d.ts +2 -0
  12. package/lib/__test__/unit/buildTransaction.test.d.ts.map +1 -0
  13. package/lib/__test__/unit/buildTransaction.test.js +76 -0
  14. package/lib/__test__/unit/buildTransaction.test.js.map +1 -0
  15. package/lib/__test__/unit/getFeesForTransaction.unit.test.d.ts +2 -0
  16. package/lib/__test__/unit/getFeesForTransaction.unit.test.d.ts.map +1 -0
  17. package/lib/__test__/unit/getFeesForTransaction.unit.test.js +101 -0
  18. package/lib/__test__/unit/getFeesForTransaction.unit.test.js.map +1 -0
  19. package/lib/__test__/unit/getTransactionStatus.unit.test.d.ts +2 -0
  20. package/lib/__test__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
  21. package/lib/__test__/unit/getTransactionStatus.unit.test.js +178 -0
  22. package/lib/__test__/unit/getTransactionStatus.unit.test.js.map +1 -0
  23. package/lib/__test__/unit/logic.unit.test.d.ts +2 -0
  24. package/lib/__test__/unit/logic.unit.test.d.ts.map +1 -0
  25. package/lib/__test__/unit/logic.unit.test.js +112 -0
  26. package/lib/__test__/unit/logic.unit.test.js.map +1 -0
  27. package/lib/__test__/unit/serializations.unit.test.d.ts +2 -0
  28. package/lib/__test__/unit/serializations.unit.test.d.ts.map +1 -0
  29. package/lib/__test__/unit/serializations.unit.test.js +73 -0
  30. package/lib/__test__/unit/serializations.unit.test.js.map +1 -0
  31. package/lib/__test__/unit/transaction.unit.test.d.ts +2 -0
  32. package/lib/__test__/unit/transaction.unit.test.d.ts.map +1 -0
  33. package/lib/__test__/unit/transaction.unit.test.js +130 -0
  34. package/lib/__test__/unit/transaction.unit.test.js.map +1 -0
  35. package/lib/account.d.ts +7 -0
  36. package/lib/account.d.ts.map +1 -0
  37. package/lib/account.js +26 -0
  38. package/lib/account.js.map +1 -0
  39. package/lib/api/api-type.d.ts +62 -0
  40. package/lib/api/api-type.d.ts.map +1 -0
  41. package/lib/api/api-type.js +3 -0
  42. package/lib/api/api-type.js.map +1 -0
  43. package/lib/api/index.d.ts +13 -0
  44. package/lib/api/index.d.ts.map +1 -0
  45. package/lib/api/index.js +134 -0
  46. package/lib/api/index.js.map +1 -0
  47. package/lib/api/node.d.ts +31 -0
  48. package/lib/api/node.d.ts.map +1 -0
  49. package/lib/api/node.js +112 -0
  50. package/lib/api/node.js.map +1 -0
  51. package/lib/bridge/index.d.ts +13 -0
  52. package/lib/bridge/index.d.ts.map +1 -0
  53. package/lib/bridge/index.js +71 -0
  54. package/lib/bridge/index.js.map +1 -0
  55. package/lib/bridge.integration.test.d.ts +4 -0
  56. package/lib/bridge.integration.test.d.ts.map +1 -0
  57. package/lib/bridge.integration.test.js +105 -0
  58. package/lib/bridge.integration.test.js.map +1 -0
  59. package/lib/broadcast.d.ts +9 -0
  60. package/lib/broadcast.d.ts.map +1 -0
  61. package/lib/broadcast.js +25 -0
  62. package/lib/broadcast.js.map +1 -0
  63. package/lib/buildTransaction.d.ts +12 -0
  64. package/lib/buildTransaction.d.ts.map +1 -0
  65. package/lib/buildTransaction.js +55 -0
  66. package/lib/buildTransaction.js.map +1 -0
  67. package/lib/cli-transaction.d.ts +16 -0
  68. package/lib/cli-transaction.d.ts.map +1 -0
  69. package/lib/cli-transaction.js +35 -0
  70. package/lib/cli-transaction.js.map +1 -0
  71. package/lib/config.d.ts +15 -0
  72. package/lib/config.d.ts.map +1 -0
  73. package/lib/config.js +17 -0
  74. package/lib/config.js.map +1 -0
  75. package/lib/constants.d.ts +14 -0
  76. package/lib/constants.d.ts.map +1 -0
  77. package/lib/constants.js +17 -0
  78. package/lib/constants.js.map +1 -0
  79. package/lib/createTransaction.d.ts +8 -0
  80. package/lib/createTransaction.d.ts.map +1 -0
  81. package/lib/createTransaction.js +19 -0
  82. package/lib/createTransaction.js.map +1 -0
  83. package/lib/deviceTransactionConfig.d.ts +15 -0
  84. package/lib/deviceTransactionConfig.d.ts.map +1 -0
  85. package/lib/deviceTransactionConfig.js +24 -0
  86. package/lib/deviceTransactionConfig.js.map +1 -0
  87. package/lib/errors.d.ts +10 -0
  88. package/lib/errors.d.ts.map +1 -0
  89. package/lib/errors.js +8 -0
  90. package/lib/errors.js.map +1 -0
  91. package/lib/estimateMaxSpendable.d.ts +14 -0
  92. package/lib/estimateMaxSpendable.d.ts.map +1 -0
  93. package/lib/estimateMaxSpendable.js +38 -0
  94. package/lib/estimateMaxSpendable.js.map +1 -0
  95. package/lib/getFeesForTransaction.d.ts +14 -0
  96. package/lib/getFeesForTransaction.d.ts.map +1 -0
  97. package/lib/getFeesForTransaction.js +44 -0
  98. package/lib/getFeesForTransaction.js.map +1 -0
  99. package/lib/getTransactionStatus.d.ts +4 -0
  100. package/lib/getTransactionStatus.d.ts.map +1 -0
  101. package/lib/getTransactionStatus.js +114 -0
  102. package/lib/getTransactionStatus.js.map +1 -0
  103. package/lib/hw-getAddress.d.ts +6 -0
  104. package/lib/hw-getAddress.d.ts.map +1 -0
  105. package/lib/hw-getAddress.js +23 -0
  106. package/lib/hw-getAddress.js.map +1 -0
  107. package/lib/initAccount.d.ts +3 -0
  108. package/lib/initAccount.d.ts.map +1 -0
  109. package/lib/initAccount.js +13 -0
  110. package/lib/initAccount.js.map +1 -0
  111. package/lib/logic.d.ts +55 -0
  112. package/lib/logic.d.ts.map +1 -0
  113. package/lib/logic.js +124 -0
  114. package/lib/logic.js.map +1 -0
  115. package/lib/prepareTransaction.d.ts +9 -0
  116. package/lib/prepareTransaction.d.ts.map +1 -0
  117. package/lib/prepareTransaction.js +33 -0
  118. package/lib/prepareTransaction.js.map +1 -0
  119. package/lib/serialization.d.ts +7 -0
  120. package/lib/serialization.d.ts.map +1 -0
  121. package/lib/serialization.js +36 -0
  122. package/lib/serialization.js.map +1 -0
  123. package/lib/signOperation.d.ts +10 -0
  124. package/lib/signOperation.d.ts.map +1 -0
  125. package/lib/signOperation.js +96 -0
  126. package/lib/signOperation.js.map +1 -0
  127. package/lib/signer.d.ts +14 -0
  128. package/lib/signer.d.ts.map +1 -0
  129. package/lib/signer.js +3 -0
  130. package/lib/signer.js.map +1 -0
  131. package/lib/specs.d.ts +7 -0
  132. package/lib/specs.d.ts.map +1 -0
  133. package/lib/specs.js +100 -0
  134. package/lib/specs.js.map +1 -0
  135. package/lib/speculos-deviceActions.d.ts +4 -0
  136. package/lib/speculos-deviceActions.d.ts.map +1 -0
  137. package/lib/speculos-deviceActions.js +44 -0
  138. package/lib/speculos-deviceActions.js.map +1 -0
  139. package/lib/synchronization.d.ts +3 -0
  140. package/lib/synchronization.d.ts.map +1 -0
  141. package/lib/synchronization.js +76 -0
  142. package/lib/synchronization.js.map +1 -0
  143. package/lib/transaction.d.ts +15 -0
  144. package/lib/transaction.d.ts.map +1 -0
  145. package/lib/transaction.js +39 -0
  146. package/lib/transaction.js.map +1 -0
  147. package/lib/types/bridge.fixture.d.ts +5 -0
  148. package/lib/types/bridge.fixture.d.ts.map +1 -0
  149. package/lib/types/bridge.fixture.js +77 -0
  150. package/lib/types/bridge.fixture.js.map +1 -0
  151. package/lib/types/index.d.ts +46 -0
  152. package/lib/types/index.d.ts.map +1 -0
  153. package/lib/types/index.js +3 -0
  154. package/lib/types/index.js.map +1 -0
  155. package/lib-es/__test__/api/index.unit.test.d.ts +2 -0
  156. package/lib-es/__test__/api/index.unit.test.d.ts.map +1 -0
  157. package/lib-es/__test__/api/index.unit.test.js +145 -0
  158. package/lib-es/__test__/api/index.unit.test.js.map +1 -0
  159. package/lib-es/__test__/unit/buildTransaction.test.d.ts +2 -0
  160. package/lib-es/__test__/unit/buildTransaction.test.d.ts.map +1 -0
  161. package/lib-es/__test__/unit/buildTransaction.test.js +71 -0
  162. package/lib-es/__test__/unit/buildTransaction.test.js.map +1 -0
  163. package/lib-es/__test__/unit/getFeesForTransaction.unit.test.d.ts +2 -0
  164. package/lib-es/__test__/unit/getFeesForTransaction.unit.test.d.ts.map +1 -0
  165. package/lib-es/__test__/unit/getFeesForTransaction.unit.test.js +73 -0
  166. package/lib-es/__test__/unit/getFeesForTransaction.unit.test.js.map +1 -0
  167. package/lib-es/__test__/unit/getTransactionStatus.unit.test.d.ts +2 -0
  168. package/lib-es/__test__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
  169. package/lib-es/__test__/unit/getTransactionStatus.unit.test.js +153 -0
  170. package/lib-es/__test__/unit/getTransactionStatus.unit.test.js.map +1 -0
  171. package/lib-es/__test__/unit/logic.unit.test.d.ts +2 -0
  172. package/lib-es/__test__/unit/logic.unit.test.d.ts.map +1 -0
  173. package/lib-es/__test__/unit/logic.unit.test.js +107 -0
  174. package/lib-es/__test__/unit/logic.unit.test.js.map +1 -0
  175. package/lib-es/__test__/unit/serializations.unit.test.d.ts +2 -0
  176. package/lib-es/__test__/unit/serializations.unit.test.d.ts.map +1 -0
  177. package/lib-es/__test__/unit/serializations.unit.test.js +71 -0
  178. package/lib-es/__test__/unit/serializations.unit.test.js.map +1 -0
  179. package/lib-es/__test__/unit/transaction.unit.test.d.ts +2 -0
  180. package/lib-es/__test__/unit/transaction.unit.test.d.ts.map +1 -0
  181. package/lib-es/__test__/unit/transaction.unit.test.js +128 -0
  182. package/lib-es/__test__/unit/transaction.unit.test.js.map +1 -0
  183. package/lib-es/account.d.ts +7 -0
  184. package/lib-es/account.d.ts.map +1 -0
  185. package/lib-es/account.js +24 -0
  186. package/lib-es/account.js.map +1 -0
  187. package/lib-es/api/api-type.d.ts +62 -0
  188. package/lib-es/api/api-type.d.ts.map +1 -0
  189. package/lib-es/api/api-type.js +2 -0
  190. package/lib-es/api/api-type.js.map +1 -0
  191. package/lib-es/api/index.d.ts +13 -0
  192. package/lib-es/api/index.d.ts.map +1 -0
  193. package/lib-es/api/index.js +123 -0
  194. package/lib-es/api/index.js.map +1 -0
  195. package/lib-es/api/node.d.ts +31 -0
  196. package/lib-es/api/node.d.ts.map +1 -0
  197. package/lib-es/api/node.js +99 -0
  198. package/lib-es/api/node.js.map +1 -0
  199. package/lib-es/bridge/index.d.ts +13 -0
  200. package/lib-es/bridge/index.d.ts.map +1 -0
  201. package/lib-es/bridge/index.js +62 -0
  202. package/lib-es/bridge/index.js.map +1 -0
  203. package/lib-es/bridge.integration.test.d.ts +4 -0
  204. package/lib-es/bridge.integration.test.d.ts.map +1 -0
  205. package/lib-es/bridge.integration.test.js +99 -0
  206. package/lib-es/bridge.integration.test.js.map +1 -0
  207. package/lib-es/broadcast.d.ts +9 -0
  208. package/lib-es/broadcast.d.ts.map +1 -0
  209. package/lib-es/broadcast.js +21 -0
  210. package/lib-es/broadcast.js.map +1 -0
  211. package/lib-es/buildTransaction.d.ts +12 -0
  212. package/lib-es/buildTransaction.d.ts.map +1 -0
  213. package/lib-es/buildTransaction.js +48 -0
  214. package/lib-es/buildTransaction.js.map +1 -0
  215. package/lib-es/cli-transaction.d.ts +16 -0
  216. package/lib-es/cli-transaction.d.ts.map +1 -0
  217. package/lib-es/cli-transaction.js +29 -0
  218. package/lib-es/cli-transaction.js.map +1 -0
  219. package/lib-es/config.d.ts +15 -0
  220. package/lib-es/config.d.ts.map +1 -0
  221. package/lib-es/config.js +12 -0
  222. package/lib-es/config.js.map +1 -0
  223. package/lib-es/constants.d.ts +14 -0
  224. package/lib-es/constants.d.ts.map +1 -0
  225. package/lib-es/constants.js +14 -0
  226. package/lib-es/constants.js.map +1 -0
  227. package/lib-es/createTransaction.d.ts +8 -0
  228. package/lib-es/createTransaction.d.ts.map +1 -0
  229. package/lib-es/createTransaction.js +15 -0
  230. package/lib-es/createTransaction.js.map +1 -0
  231. package/lib-es/deviceTransactionConfig.d.ts +15 -0
  232. package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
  233. package/lib-es/deviceTransactionConfig.js +22 -0
  234. package/lib-es/deviceTransactionConfig.js.map +1 -0
  235. package/lib-es/errors.d.ts +10 -0
  236. package/lib-es/errors.d.ts.map +1 -0
  237. package/lib-es/errors.js +5 -0
  238. package/lib-es/errors.js.map +1 -0
  239. package/lib-es/estimateMaxSpendable.d.ts +14 -0
  240. package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
  241. package/lib-es/estimateMaxSpendable.js +31 -0
  242. package/lib-es/estimateMaxSpendable.js.map +1 -0
  243. package/lib-es/getFeesForTransaction.d.ts +14 -0
  244. package/lib-es/getFeesForTransaction.d.ts.map +1 -0
  245. package/lib-es/getFeesForTransaction.js +42 -0
  246. package/lib-es/getFeesForTransaction.js.map +1 -0
  247. package/lib-es/getTransactionStatus.d.ts +4 -0
  248. package/lib-es/getTransactionStatus.d.ts.map +1 -0
  249. package/lib-es/getTransactionStatus.js +109 -0
  250. package/lib-es/getTransactionStatus.js.map +1 -0
  251. package/lib-es/hw-getAddress.d.ts +6 -0
  252. package/lib-es/hw-getAddress.d.ts.map +1 -0
  253. package/lib-es/hw-getAddress.js +21 -0
  254. package/lib-es/hw-getAddress.js.map +1 -0
  255. package/lib-es/initAccount.d.ts +3 -0
  256. package/lib-es/initAccount.d.ts.map +1 -0
  257. package/lib-es/initAccount.js +9 -0
  258. package/lib-es/initAccount.js.map +1 -0
  259. package/lib-es/logic.d.ts +55 -0
  260. package/lib-es/logic.d.ts.map +1 -0
  261. package/lib-es/logic.js +109 -0
  262. package/lib-es/logic.js.map +1 -0
  263. package/lib-es/prepareTransaction.d.ts +9 -0
  264. package/lib-es/prepareTransaction.d.ts.map +1 -0
  265. package/lib-es/prepareTransaction.js +26 -0
  266. package/lib-es/prepareTransaction.js.map +1 -0
  267. package/lib-es/serialization.d.ts +7 -0
  268. package/lib-es/serialization.d.ts.map +1 -0
  269. package/lib-es/serialization.js +29 -0
  270. package/lib-es/serialization.js.map +1 -0
  271. package/lib-es/signOperation.d.ts +10 -0
  272. package/lib-es/signOperation.d.ts.map +1 -0
  273. package/lib-es/signOperation.js +89 -0
  274. package/lib-es/signOperation.js.map +1 -0
  275. package/lib-es/signer.d.ts +14 -0
  276. package/lib-es/signer.d.ts.map +1 -0
  277. package/lib-es/signer.js +2 -0
  278. package/lib-es/signer.js.map +1 -0
  279. package/lib-es/specs.d.ts +7 -0
  280. package/lib-es/specs.d.ts.map +1 -0
  281. package/lib-es/specs.js +95 -0
  282. package/lib-es/specs.js.map +1 -0
  283. package/lib-es/speculos-deviceActions.d.ts +4 -0
  284. package/lib-es/speculos-deviceActions.d.ts.map +1 -0
  285. package/lib-es/speculos-deviceActions.js +41 -0
  286. package/lib-es/speculos-deviceActions.js.map +1 -0
  287. package/lib-es/synchronization.d.ts +3 -0
  288. package/lib-es/synchronization.d.ts.map +1 -0
  289. package/lib-es/synchronization.js +69 -0
  290. package/lib-es/synchronization.js.map +1 -0
  291. package/lib-es/transaction.d.ts +15 -0
  292. package/lib-es/transaction.d.ts.map +1 -0
  293. package/lib-es/transaction.js +33 -0
  294. package/lib-es/transaction.js.map +1 -0
  295. package/lib-es/types/bridge.fixture.d.ts +5 -0
  296. package/lib-es/types/bridge.fixture.d.ts.map +1 -0
  297. package/lib-es/types/bridge.fixture.js +68 -0
  298. package/lib-es/types/bridge.fixture.js.map +1 -0
  299. package/lib-es/types/index.d.ts +46 -0
  300. package/lib-es/types/index.d.ts.map +1 -0
  301. package/lib-es/types/index.js +2 -0
  302. package/lib-es/types/index.js.map +1 -0
  303. package/package.json +85 -0
  304. package/src/__test__/api/index.unit.test.ts +151 -0
  305. package/src/__test__/unit/buildTransaction.test.ts +76 -0
  306. package/src/__test__/unit/getFeesForTransaction.unit.test.ts +76 -0
  307. package/src/__test__/unit/getTransactionStatus.unit.test.ts +172 -0
  308. package/src/__test__/unit/logic.unit.test.ts +145 -0
  309. package/src/__test__/unit/serializations.unit.test.ts +92 -0
  310. package/src/__test__/unit/transaction.unit.test.ts +144 -0
  311. package/src/account.ts +30 -0
  312. package/src/api/api-type.ts +65 -0
  313. package/src/api/index.ts +156 -0
  314. package/src/api/node.ts +115 -0
  315. package/src/bridge/index.ts +76 -0
  316. package/src/bridge.integration.test.ts +107 -0
  317. package/src/broadcast.ts +18 -0
  318. package/src/buildTransaction.ts +53 -0
  319. package/src/cli-transaction.ts +49 -0
  320. package/src/config.ts +29 -0
  321. package/src/constants.ts +14 -0
  322. package/src/createTransaction.ts +16 -0
  323. package/src/deviceTransactionConfig.ts +44 -0
  324. package/src/errors.ts +5 -0
  325. package/src/estimateMaxSpendable.ts +34 -0
  326. package/src/getFeesForTransaction.ts +46 -0
  327. package/src/getTransactionStatus.ts +139 -0
  328. package/src/hw-getAddress.ts +19 -0
  329. package/src/initAccount.ts +11 -0
  330. package/src/logic.ts +132 -0
  331. package/src/prepareTransaction.ts +24 -0
  332. package/src/serialization.ts +34 -0
  333. package/src/signOperation.ts +140 -0
  334. package/src/signer.ts +14 -0
  335. package/src/specs.ts +124 -0
  336. package/src/speculos-deviceActions.ts +46 -0
  337. package/src/synchronization.ts +70 -0
  338. package/src/transaction.ts +60 -0
  339. package/src/types/bridge.fixture.ts +75 -0
  340. package/src/types/index.ts +61 -0
  341. package/tsconfig.json +12 -0
@@ -0,0 +1,29 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ export function toIconResourcesRaw(resources) {
3
+ const { nonce, votingPower, totalDelegated } = resources;
4
+ return {
5
+ nonce,
6
+ votingPower: votingPower.toString(),
7
+ totalDelegated: totalDelegated.toString(),
8
+ };
9
+ }
10
+ export function fromIconResourcesRaw(rawResources) {
11
+ const { nonce, votingPower, totalDelegated } = rawResources;
12
+ return {
13
+ nonce,
14
+ votingPower: new BigNumber(votingPower || 0),
15
+ totalDelegated: new BigNumber(totalDelegated || 0),
16
+ };
17
+ }
18
+ export function assignToAccountRaw(account, accountRaw) {
19
+ const iconAccount = account;
20
+ if (iconAccount.iconResources) {
21
+ accountRaw.iconResources = toIconResourcesRaw(iconAccount.iconResources);
22
+ }
23
+ }
24
+ export function assignFromAccountRaw(accountRaw, account) {
25
+ const iconResourcesRaw = accountRaw.iconResources;
26
+ if (iconResourcesRaw)
27
+ account.iconResources = fromIconResourcesRaw(iconResourcesRaw);
28
+ }
29
+ //# sourceMappingURL=serialization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,MAAM,UAAU,kBAAkB,CAAC,SAAwB;IACzD,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IACzD,OAAO;QACL,KAAK;QACL,WAAW,EAAE,WAAW,CAAC,QAAQ,EAAE;QACnC,cAAc,EAAE,cAAc,CAAC,QAAQ,EAAE;KAC1C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,YAA8B;IACjE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,YAAY,CAAC;IAC5D,OAAO;QACL,KAAK;QACL,WAAW,EAAE,IAAI,SAAS,CAAC,WAAW,IAAI,CAAC,CAAC;QAC5C,cAAc,EAAE,IAAI,SAAS,CAAC,cAAc,IAAI,CAAC,CAAC;KACnD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAgB,EAAE,UAAsB;IACzE,MAAM,WAAW,GAAG,OAAsB,CAAC;IAC3C,IAAI,WAAW,CAAC,aAAa,EAAE,CAAC;QAC7B,UAA6B,CAAC,aAAa,GAAG,kBAAkB,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAC/F,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAsB,EAAE,OAAgB;IAC3E,MAAM,gBAAgB,GAAI,UAA6B,CAAC,aAAa,CAAC;IACtE,IAAI,gBAAgB;QACjB,OAAuB,CAAC,aAAa,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;AACpF,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Transaction } from "./types";
2
+ import type { AccountBridge } from "@ledgerhq/types-live";
3
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
4
+ import { IconSigner } from "./signer";
5
+ /**
6
+ * Sign Transaction with Ledger hardware
7
+ */
8
+ export declare const buildSignOperation: (signerContext: SignerContext<IconSigner>) => AccountBridge<Transaction>["signOperation"];
9
+ export default buildSignOperation;
10
+ //# sourceMappingURL=signOperation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signOperation.d.ts","sourceRoot":"","sources":["../src/signOperation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAEV,aAAa,EAId,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAiB,UAAU,EAAE,MAAM,UAAU,CAAC;AA0CrD;;GAEG;AACH,eAAO,MAAM,kBAAkB,kBACb,cAAc,UAAU,CAAC,KAAG,cAAc,WAAW,CAAC,CAAC,eAAe,CAwElF,CAAC;AAEP,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,89 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { BigNumber } from "bignumber.js";
11
+ import { Observable } from "rxjs";
12
+ import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
13
+ import { buildTransaction } from "./buildTransaction";
14
+ import { calculateAmount, getNonce } from "./logic";
15
+ import { FeeNotLoaded } from "@ledgerhq/errors";
16
+ import IconService from "icon-sdk-js";
17
+ const { IconUtil, IconConverter } = IconService;
18
+ const buildOptimisticOperation = (account, transaction, fee) => {
19
+ const type = "OUT";
20
+ const value = new BigNumber(transaction.amount).plus(fee);
21
+ const operation = {
22
+ id: encodeOperationId(account.id, "", type),
23
+ hash: "",
24
+ type,
25
+ value,
26
+ fee,
27
+ blockHash: null,
28
+ blockHeight: null,
29
+ senders: [account.freshAddress],
30
+ recipients: [transaction.recipient].filter(Boolean),
31
+ accountId: account.id,
32
+ transactionSequenceNumber: getNonce(account),
33
+ date: new Date(),
34
+ extra: {},
35
+ };
36
+ return operation;
37
+ };
38
+ /**
39
+ * Adds signature to unsigned transaction. Will likely be a call to Icon SDK
40
+ */
41
+ const addSignature = (rawTransaction, signature) => {
42
+ return {
43
+ rawTransaction: Object.assign(Object.assign({}, rawTransaction), { signature: signature }),
44
+ signature,
45
+ };
46
+ };
47
+ /**
48
+ * Sign Transaction with Ledger hardware
49
+ */
50
+ export const buildSignOperation = (signerContext) => ({ account, transaction, deviceId, }) => new Observable(o => {
51
+ let cancelled = false;
52
+ function main() {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ var _a;
55
+ if (!transaction.fees) {
56
+ throw new FeeNotLoaded();
57
+ }
58
+ const transactionToSign = Object.assign(Object.assign({}, transaction), { amount: calculateAmount({
59
+ account: account,
60
+ transaction: transaction,
61
+ }) });
62
+ const { unsigned } = yield buildTransaction(account, transactionToSign, transactionToSign.stepLimit);
63
+ o.next({ type: "device-signature-requested" });
64
+ const res = (yield signerContext(deviceId, signer => signer.signTransaction(account.freshAddressPath, IconUtil.generateHashKey(IconConverter.toRawTransaction(unsigned)))));
65
+ const signed = addSignature(unsigned, res.signedRawTxBase64);
66
+ if (cancelled)
67
+ return;
68
+ o.next({ type: "device-signature-granted" });
69
+ if (!signed.signature) {
70
+ throw new Error("No signature");
71
+ }
72
+ const operation = buildOptimisticOperation(account, transactionToSign, (_a = transactionToSign.fees) !== null && _a !== void 0 ? _a : new BigNumber(0));
73
+ o.next({
74
+ type: "signed",
75
+ signedOperation: {
76
+ operation,
77
+ signature: signed.signature,
78
+ rawData: signed.rawTransaction,
79
+ },
80
+ });
81
+ });
82
+ }
83
+ main().then(() => o.complete(), e => o.error(e));
84
+ return () => {
85
+ cancelled = true;
86
+ };
87
+ });
88
+ export default buildSignOperation;
89
+ //# sourceMappingURL=signOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signOperation.js","sourceRoot":"","sources":["../src/signOperation.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAWlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,WAA+B,MAAM,aAAa,CAAC;AAG1D,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC;AAEhD,MAAM,wBAAwB,GAAG,CAC/B,OAAgB,EAChB,WAAwB,EACxB,GAAc,EACH,EAAE;IACb,MAAM,IAAI,GAAG,KAAK,CAAC;IACnB,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1D,MAAM,SAAS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,CAAC;AACJ,CAAC,CAAC,CAAC;AAEP,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,14 @@
1
+ export type IconAddress = {
2
+ publicKey: string;
3
+ address: string;
4
+ chainCode?: string;
5
+ };
6
+ export type IconSignature = {
7
+ signedRawTxBase64: string;
8
+ hashHex: string;
9
+ };
10
+ export interface IconSigner {
11
+ getAddress(path: string, shouldDisplay?: boolean): Promise<IconAddress>;
12
+ signTransaction(path: string, rawTxAscii: string): Promise<IconSignature>;
13
+ }
14
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACxE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC3E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { AppSpec } from "@ledgerhq/coin-framework/bot/types";
2
+ import { Transaction } from "./types";
3
+ declare const _default: {
4
+ icon: AppSpec<Transaction>;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=specs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specs.d.ts","sourceRoot":"","sources":["../src/specs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAWlE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;;;;AA4GtC,wBAEE"}
@@ -0,0 +1,95 @@
1
+ import invariant from "invariant";
2
+ import { botTest, pickSiblings } from "@ledgerhq/coin-framework/bot/specs";
3
+ import { toOperationRaw } from "@ledgerhq/coin-framework/serialization/index";
4
+ import { DeviceModelId } from "@ledgerhq/devices";
5
+ import BigNumber from "bignumber.js";
6
+ import expect from "expect";
7
+ import { acceptTransaction } from "./speculos-deviceActions";
8
+ import { EXISTENTIAL_DEPOSIT, EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN, convertICXtoLoop, } from "./logic";
9
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
10
+ const maxAccounts = 6;
11
+ const currency = getCryptoCurrencyById("icon");
12
+ // FIX ME ICON have a bug where the amounts from the API have imprecisions
13
+ const expectedApproximate = (value, expected, delta = convertICXtoLoop(0.000005)) => {
14
+ if (value.minus(expected).abs().gt(delta)) {
15
+ expect(value.toString()).toEqual(value.toString());
16
+ }
17
+ };
18
+ const icon = {
19
+ name: "Icon",
20
+ currency,
21
+ appQuery: {
22
+ model: DeviceModelId.nanoS,
23
+ appName: "Icon",
24
+ },
25
+ genericDeviceAction: acceptTransaction,
26
+ testTimeout: 2 * 60 * 1000,
27
+ transactionCheck: ({ maxSpendable }) => {
28
+ invariant(maxSpendable.gt(EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN), "balance is too low");
29
+ },
30
+ test: ({ operation, optimisticOperation }) => {
31
+ const opExpected = toOperationRaw(Object.assign({}, optimisticOperation));
32
+ delete opExpected.value;
33
+ delete opExpected.fee;
34
+ delete opExpected.date;
35
+ delete opExpected.blockHash;
36
+ delete opExpected.blockHeight;
37
+ delete opExpected.transactionSequenceNumber;
38
+ botTest("optimistic operation matches", () => expect(toOperationRaw(operation)).toMatchObject(opExpected));
39
+ },
40
+ mutations: [
41
+ {
42
+ name: "send 50%~",
43
+ maxRun: 1,
44
+ transaction: ({ account, siblings, bridge }) => {
45
+ invariant(account.spendableBalance.gt(0), "balance is 0");
46
+ const sibling = pickSiblings(siblings, maxAccounts);
47
+ let amount = account.spendableBalance.div(2).integerValue();
48
+ if (!sibling.used && amount.lt(EXISTENTIAL_DEPOSIT)) {
49
+ invariant(account.spendableBalance.gt(EXISTENTIAL_DEPOSIT), "send is too low to activate account");
50
+ amount = EXISTENTIAL_DEPOSIT;
51
+ }
52
+ return {
53
+ transaction: bridge.createTransaction(account),
54
+ updates: [
55
+ {
56
+ recipient: sibling.freshAddress,
57
+ },
58
+ {
59
+ amount,
60
+ },
61
+ ],
62
+ };
63
+ },
64
+ test: ({ accountBeforeTransaction, operation, account }) => {
65
+ botTest("account spendable balance decreased with operation", () => expectedApproximate(account.spendableBalance, accountBeforeTransaction.spendableBalance.minus(operation.value)));
66
+ },
67
+ },
68
+ {
69
+ name: "send max",
70
+ maxRun: 1,
71
+ transaction: ({ account, siblings, bridge }) => {
72
+ invariant(account.spendableBalance.gt(0), "balance is 0");
73
+ const sibling = pickSiblings(siblings, maxAccounts);
74
+ return {
75
+ transaction: bridge.createTransaction(account),
76
+ updates: [
77
+ {
78
+ recipient: sibling.freshAddress,
79
+ },
80
+ {
81
+ useAllAmount: true,
82
+ },
83
+ ],
84
+ };
85
+ },
86
+ test: ({ account }) => {
87
+ botTest("account spendable balance is zero", () => expectedApproximate(account.spendableBalance, new BigNumber(0)));
88
+ },
89
+ },
90
+ ],
91
+ };
92
+ export default {
93
+ icon,
94
+ };
95
+ //# sourceMappingURL=specs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specs.js","sourceRoot":"","sources":["../src/specs.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,Y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types";
3
+ export declare const acceptTransaction: DeviceAction<Transaction, any>;
4
+ //# sourceMappingURL=speculos-deviceActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"speculos-deviceActions.d.ts","sourceRoot":"","sources":["../src/speculos-deviceActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAS3C,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,WAAW,EAAE,GAAG,CAmC3D,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
2
+ import { deviceActionFlow, SpeculosButton } from "@ledgerhq/coin-framework/bot/specs";
3
+ import { getAccountCurrency } from "@ledgerhq/coin-framework/account/index";
4
+ const confirmWording = {
5
+ send: "transfer",
6
+ };
7
+ export const acceptTransaction = deviceActionFlow({
8
+ steps: [
9
+ {
10
+ title: "Confirm",
11
+ button: SpeculosButton.RIGHT,
12
+ expectedValue: ({ transaction }) => confirmWording[transaction.mode],
13
+ },
14
+ {
15
+ title: "Amount",
16
+ button: SpeculosButton.RIGHT,
17
+ expectedValue: ({ transaction, account }) => formatCurrencyUnit(getAccountCurrency(account).units[0], transaction.amount, {
18
+ disableRounding: true,
19
+ }),
20
+ },
21
+ {
22
+ title: "Address",
23
+ button: SpeculosButton.RIGHT,
24
+ expectedValue: ({ transaction }) => {
25
+ return transaction.recipient;
26
+ },
27
+ },
28
+ {
29
+ title: "Fees",
30
+ button: SpeculosButton.RIGHT,
31
+ expectedValue: ({ account, status }) => formatCurrencyUnit(getAccountCurrency(account).units[0], status.estimatedFees, {
32
+ disableRounding: true,
33
+ }),
34
+ },
35
+ {
36
+ title: "Accept",
37
+ button: SpeculosButton.BOTH,
38
+ },
39
+ ],
40
+ });
41
+ //# sourceMappingURL=speculos-deviceActions.js.map
@@ -0,0 +1 @@
1
+ {"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AAa,EAAE;gBAC7E,eAAe,EAAE,IAAI;aACtB,CAAC;SACL;QACD;YACE,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,cAAc,CAAC,IAAI;SAC5B;KACF;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { GetAccountShape } from "@ledgerhq/coin-framework/bridge/jsHelpers";
2
+ export declare const getAccountShape: GetAccountShape;
3
+ //# sourceMappingURL=synchronization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"synchronization.d.ts","sourceRoot":"","sources":["../src/synchronization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAQjF,eAAO,MAAM,eAAe,EAAE,eA2D7B,CAAC"}
@@ -0,0 +1,69 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { encodeAccountId } from "@ledgerhq/coin-framework/account/accountId";
11
+ import { mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
12
+ import { getAccount, getCurrentBlockHeight, getOperations } from "./api";
13
+ import BigNumber from "bignumber.js";
14
+ import { getDelegation } from "./api/node";
15
+ import { convertICXtoLoop } from "./logic";
16
+ export const getAccountShape = (info) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const { address, initialAccount, currency, derivationMode } = info;
18
+ const accountId = encodeAccountId({
19
+ type: "js",
20
+ version: "2",
21
+ currencyId: currency.id,
22
+ xpubOrAddress: address,
23
+ derivationMode,
24
+ });
25
+ try {
26
+ const oldOperations = (initialAccount === null || initialAccount === void 0 ? void 0 : initialAccount.operations) || [];
27
+ const blockHeight = yield getCurrentBlockHeight(currency);
28
+ const iconAccount = yield getAccount(info.address, currency);
29
+ // Merge new operations with the previously synced ones
30
+ const newOperations = yield getOperations(accountId, address, 0, // skip === 0 is the lastest transaction
31
+ currency, (iconAccount === null || iconAccount === void 0 ? void 0 : iconAccount.contract_updated_block) - oldOperations.length);
32
+ const operations = mergeOps(oldOperations, newOperations);
33
+ const delegationData = yield getDelegation(address, currency);
34
+ const iconResources = {
35
+ nonce: 0,
36
+ totalDelegated: delegationData.totalDelegated,
37
+ votingPower: delegationData.votingPower,
38
+ };
39
+ const balance = convertICXtoLoop((iconAccount === null || iconAccount === void 0 ? void 0 : iconAccount.balance) || 0);
40
+ const spendableBalance = balance
41
+ .minus(iconResources.totalDelegated)
42
+ .minus(iconResources.votingPower);
43
+ return {
44
+ id: accountId,
45
+ balance,
46
+ spendableBalance,
47
+ operationsCount: operations.length,
48
+ blockHeight,
49
+ iconResources,
50
+ operations,
51
+ };
52
+ }
53
+ catch (error) {
54
+ return {
55
+ id: accountId,
56
+ balance: new BigNumber(0),
57
+ spendableBalance: new BigNumber(0),
58
+ operationsCount: 0,
59
+ iconResources: {
60
+ nonce: 0,
61
+ totalDelegated: new BigNumber(0),
62
+ votingPower: new BigNumber(0),
63
+ },
64
+ blockHeight: 0,
65
+ operations: [],
66
+ };
67
+ }
68
+ });
69
+ //# sourceMappingURL=synchronization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"synchronization.js","sourceRoot":"","sources":["../src/synchronization.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAoB,MAAM,2CAA2C,CAAC;AAGvF,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,SAAS,MAAM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X,WAAW,uBAAX,WAAW,CAAE,OAAO,KAAI,CAAC,CAAC,CAAC;QAC5D,MAAM,gBAAgB,GAAG,OAAO;aAC7B,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC;aACnC,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAEpC,OAAO;YACL,EAAE,EAAE,SAAS;YACb,OAAO;YACP,gBAAgB;YAChB,eAAe,EAAE,UAAU,CAAC,MAAM;YAClC,WAAW;YACX,aAAa;YACb,UAAU;SACX,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,EAAE,EAAE,SAAS;YACb,OAAO,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;YACzB,gBAAgB,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;YAClC,eAAe,EAAE,CAAC;YAClB,aAAa,EAAE;gBACb,KAAK,EAAE,CAAC;gBACR,cAAc,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;gBAChC,WAAW,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;aAC9B;YACD,WAAW,EAAE,CAAC;YACd,UAAU,EAAE,EAAE;SACf,CAAC;IACJ,CAAC;AACH,CAAC,CAAA,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Transaction, TransactionRaw } from "./types";
2
+ import type { Account } from "@ledgerhq/types-live";
3
+ export declare const formatTransaction: ({ mode, amount, recipient, useAllAmount }: Transaction, account: Account) => string;
4
+ export declare const fromTransactionRaw: (tr: TransactionRaw) => Transaction;
5
+ export declare const toTransactionRaw: (t: Transaction) => TransactionRaw;
6
+ declare const _default: {
7
+ formatTransaction: ({ mode, amount, recipient, useAllAmount }: Transaction, account: Account) => string;
8
+ fromTransactionRaw: (tr: TransactionRaw) => Transaction;
9
+ toTransactionRaw: (t: Transaction) => TransactionRaw;
10
+ fromTransactionStatusRaw: (ts: import("@ledgerhq/types-live").TransactionStatusCommonRaw) => import("@ledgerhq/types-live").TransactionStatusCommon;
11
+ toTransactionStatusRaw: (ts: import("@ledgerhq/types-live").TransactionStatusCommon) => import("@ledgerhq/types-live").TransactionStatusCommonRaw;
12
+ formatTransactionStatus: (t: import("@ledgerhq/types-live").TransactionCommon, { errors, warnings, estimatedFees, amount, totalSpent }: import("@ledgerhq/types-live").TransactionStatusCommon, mainAccount: Account) => string;
13
+ };
14
+ export default _default;
15
+ //# sourceMappingURL=transaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAS3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIpD,eAAO,MAAM,iBAAiB,8CACe,WAAW,WAC7C,OAAO,KACf,MAYwC,CAAC;AAE5C,eAAO,MAAM,kBAAkB,OAAQ,cAAc,KAAG,WASvD,CAAC;AAEF,eAAO,MAAM,gBAAgB,MAAO,WAAW,KAAG,cASjD,CAAC;;;;;;;;;AAEF,wBAOE"}
@@ -0,0 +1,33 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { formatTransactionStatus } from "@ledgerhq/coin-framework/formatters";
3
+ import { fromTransactionCommonRaw, fromTransactionStatusRawCommon as fromTransactionStatusRaw, toTransactionCommonRaw, toTransactionStatusRawCommon as toTransactionStatusRaw, } from "@ledgerhq/coin-framework/serialization";
4
+ import { getAccountCurrency } from "@ledgerhq/coin-framework/account/index";
5
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
6
+ export const formatTransaction = ({ mode, amount, recipient, useAllAmount }, account) => `
7
+ ${mode.toUpperCase()} ${useAllAmount
8
+ ? "MAX"
9
+ : amount.isZero()
10
+ ? ""
11
+ : " " +
12
+ formatCurrencyUnit(getAccountCurrency(account).units[0], amount, {
13
+ showCode: true,
14
+ disableRounding: true,
15
+ })}${recipient ? `\nTO ${recipient}` : ""}`;
16
+ export const fromTransactionRaw = (tr) => {
17
+ const common = fromTransactionCommonRaw(tr);
18
+ return Object.assign(Object.assign({}, common), { family: tr.family, mode: tr.mode, fees: tr.fees ? new BigNumber(tr.fees) : null, stepLimit: tr.stepLimit ? new BigNumber(tr.stepLimit) : undefined });
19
+ };
20
+ export const toTransactionRaw = (t) => {
21
+ var _a, _b;
22
+ const common = toTransactionCommonRaw(t);
23
+ return Object.assign(Object.assign({}, common), { family: t.family, mode: t.mode, fees: ((_a = t.fees) === null || _a === void 0 ? void 0 : _a.toString()) || null, stepLimit: ((_b = t.stepLimit) === null || _b === void 0 ? void 0 : _b.toString()) || undefined });
24
+ };
25
+ export default {
26
+ formatTransaction,
27
+ fromTransactionRaw,
28
+ toTransactionRaw,
29
+ fromTransactionStatusRaw,
30
+ toTransactionStatusRaw,
31
+ formatTransactionStatus,
32
+ };
33
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EACL,wBAAwB,EACxB,8BAA8B,IAAI,wBAAwB,EAC1D,sBAAsB,EACtB,4BAA4B,IAAI,sBAAsB,GACvD,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAe,EACtD,OAAgB,EACR,EAAE,CACV;EACA,IAAI,CAAC,WAAW,EAAE,IAChB,YAAY;IACV,CAAC,CAAC,KAAK;IACP,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE;QACf,CAAC,CAAC,E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,uBAAuB;CACxB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { IconAccount, IconOperation, Transaction } from "./index";
2
+ export declare function createFixtureAccount(account?: Partial<IconAccount>): IconAccount;
3
+ export declare function createFixtureTransaction(tx?: Partial<Transaction>): Transaction;
4
+ export declare function createFixtureOperation(operation?: Partial<IconOperation>): IconOperation;
5
+ //# sourceMappingURL=bridge.fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.fixture.d.ts","sourceRoot":"","sources":["../../src/types/bridge.fixture.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAiB,WAAW,EAAE,MAAM,SAAS,CAAC;AAEjF,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAwChF;AAED,wBAAgB,wBAAwB,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAQ/E;AAED,wBAAgB,sBAAsB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAexF"}
@@ -0,0 +1,68 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { faker } from "@faker-js/faker";
3
+ import { listCryptoCurrencies } from "@ledgerhq/cryptoassets/currencies";
4
+ import { getAbandonSeedAddress } from "@ledgerhq/cryptoassets/abandonseed";
5
+ import { emptyHistoryCache } from "@ledgerhq/coin-framework/account/index";
6
+ export function createFixtureAccount(account) {
7
+ const currency = listCryptoCurrencies(true).find(c => c.id === "icon");
8
+ const iconResources = (account === null || account === void 0 ? void 0 : account.iconResources) || {
9
+ nonce: 0,
10
+ votingPower: BigNumber(0),
11
+ totalDelegated: BigNumber(0),
12
+ };
13
+ const freshAddress = {
14
+ address: "hx1234567890abcdef",
15
+ derivationPath: "derivation_path",
16
+ };
17
+ const id = faker.string.uuid();
18
+ const seedIdentifier = faker.string.uuid();
19
+ const index = faker.number.int();
20
+ return {
21
+ type: "Account",
22
+ id,
23
+ seedIdentifier,
24
+ derivationMode: "",
25
+ index,
26
+ freshAddress: freshAddress.address,
27
+ freshAddressPath: freshAddress.derivationPath,
28
+ used: true,
29
+ balance: (account === null || account === void 0 ? void 0 : account.balance) || new BigNumber(0),
30
+ spendableBalance: (account === null || account === void 0 ? void 0 : account.spendableBalance) || new BigNumber(0),
31
+ creationDate: faker.date.past(),
32
+ blockHeight: faker.number.int({ min: 100000, max: 200000 }),
33
+ currency,
34
+ operationsCount: (account === null || account === void 0 ? void 0 : account.operationsCount) || 0,
35
+ operations: (account === null || account === void 0 ? void 0 : account.operations) || [],
36
+ pendingOperations: (account === null || account === void 0 ? void 0 : account.pendingOperations) || [],
37
+ lastSyncDate: new Date(),
38
+ balanceHistoryCache: emptyHistoryCache,
39
+ swapHistory: [],
40
+ iconResources,
41
+ };
42
+ }
43
+ export function createFixtureTransaction(tx) {
44
+ return {
45
+ amount: (tx === null || tx === void 0 ? void 0 : tx.amount) || new BigNumber(0),
46
+ recipient: (tx === null || tx === void 0 ? void 0 : tx.recipient) || getAbandonSeedAddress("icon"),
47
+ mode: (tx === null || tx === void 0 ? void 0 : tx.mode) || "send",
48
+ family: "icon",
49
+ fees: (tx === null || tx === void 0 ? void 0 : tx.fees) || undefined,
50
+ };
51
+ }
52
+ export function createFixtureOperation(operation) {
53
+ return {
54
+ id: (operation === null || operation === void 0 ? void 0 : operation.id) || faker.string.uuid(),
55
+ hash: (operation === null || operation === void 0 ? void 0 : operation.hash) || faker.string.uuid(),
56
+ type: (operation === null || operation === void 0 ? void 0 : operation.type) || "OUT",
57
+ value: (operation === null || operation === void 0 ? void 0 : operation.value) || new BigNumber(faker.string.numeric()),
58
+ fee: (operation === null || operation === void 0 ? void 0 : operation.fee) || new BigNumber(0),
59
+ senders: (operation === null || operation === void 0 ? void 0 : operation.senders) || [],
60
+ recipients: (operation === null || operation === void 0 ? void 0 : operation.recipients) || [],
61
+ blockHeight: (operation === null || operation === void 0 ? void 0 : operation.blockHeight) || undefined,
62
+ blockHash: (operation === null || operation === void 0 ? void 0 : operation.blockHash) || undefined,
63
+ accountId: (operation === null || operation === void 0 ? void 0 : operation.accountId) || faker.string.uuid(),
64
+ date: (operation === null || operation === void 0 ? void 0 : operation.date) || faker.date.past(),
65
+ extra: {},
66
+ };
67
+ }
68
+ //# sourceMappingURL=bridge.fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridge.fixture.js","sourceRoot":"","sources":["../../src/types/bridge.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAE,CAAC;IAExE,MAAM,aAAa,GAAkB,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa,KAAI;QAC7D,KAAK,EAAE,CAAC;QACR,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;QACzB,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;KAC7B,CAAC;IAEF,MAAM,YAAY,GAAG;QACnB,OAAO,EAAE,oBAAoB;QAC7B,cAAc,EAAE,iBAAiB;KAClC,CAAC;IAEF,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC/B,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG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A,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,KAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE;QAC1C,KAAK,EAAE,EAAE;KACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { BigNumber } from "bignumber.js";
2
+ import { Account, AccountRaw, TransactionCommon, TransactionCommonRaw, TransactionStatusCommon, TransactionStatusCommonRaw, Operation } from "@ledgerhq/types-live";
3
+ /**
4
+ * Icon account resources
5
+ */
6
+ export type IconResources = {
7
+ nonce: number;
8
+ votingPower: string | BigNumber;
9
+ totalDelegated: string | BigNumber;
10
+ };
11
+ /**
12
+ * Icon account resources from raw JSON
13
+ */
14
+ export type IconResourcesRaw = {
15
+ nonce: number;
16
+ votingPower: string | BigNumber;
17
+ totalDelegated: string | BigNumber;
18
+ };
19
+ /**
20
+ * Icon transaction
21
+ */
22
+ export type Transaction = TransactionCommon & {
23
+ mode: string;
24
+ family: "icon";
25
+ fees?: BigNumber | null | undefined;
26
+ stepLimit?: BigNumber;
27
+ };
28
+ /**
29
+ * Icon transaction from a raw JSON
30
+ */
31
+ export type TransactionRaw = TransactionCommonRaw & {
32
+ family: "icon";
33
+ mode: string;
34
+ fees?: string | null | undefined;
35
+ stepLimit?: string;
36
+ };
37
+ export type IconOperation = Operation;
38
+ export type IconAccount = Account & {
39
+ iconResources: IconResources;
40
+ };
41
+ export type IconAccountRaw = AccountRaw & {
42
+ iconResources: IconResourcesRaw;
43
+ };
44
+ export type TransactionStatus = TransactionStatusCommon;
45
+ export type TransactionStatusRaw = TransactionStatusCommonRaw;
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,OAAO,EACP,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,uBAAu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