@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,15 @@
1
+ import type { AccountLike, Account } from "@ledgerhq/types-live";
2
+ import type { Transaction, TransactionStatus } from "./types";
3
+ import type { CommonDeviceTransactionField as DeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
4
+ export type ExtraDeviceTransactionField = {
5
+ type: "icon.fees";
6
+ label: string;
7
+ };
8
+ declare function getDeviceTransactionConfig({ transaction, account, parentAccount, status: { amount }, }: {
9
+ account: AccountLike;
10
+ parentAccount?: Account;
11
+ transaction: Transaction;
12
+ status: TransactionStatus;
13
+ }): Array<DeviceTransactionField>;
14
+ export default getDeviceTransactionConfig;
15
+ //# sourceMappingURL=deviceTransactionConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceTransactionConfig.d.ts","sourceRoot":"","sources":["../src/deviceTransactionConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,KAAK,EAAE,4BAA4B,IAAI,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAG1H,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,iBAAS,0BAA0B,CAAC,EAClC,WAAW,EACX,OAAO,EACP,aAAa,EACb,MAAM,EAAE,EAAE,MAAM,EAAE,GACnB,EAAE;IACD,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,KAAK,CAAC,sBAAsB,CAAC,CAqBhC;AAED,eAAe,0BAA0B,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { getMainAccount } from "@ledgerhq/coin-framework/account/index";
2
+ function getDeviceTransactionConfig({ transaction, account, parentAccount, status: { amount }, }) {
3
+ const fields = [];
4
+ const mainAccount = getMainAccount(account, parentAccount);
5
+ const { mode } = transaction;
6
+ if (!amount.isZero()) {
7
+ fields.push({
8
+ type: "amount",
9
+ label: "Amount",
10
+ });
11
+ }
12
+ if (mode !== "send") {
13
+ fields.push({
14
+ type: "address",
15
+ label: "From Address",
16
+ address: mainAccount.freshAddress,
17
+ });
18
+ }
19
+ return fields;
20
+ }
21
+ export default getDeviceTransactionConfig;
22
+ //# sourceMappingURL=deviceTransactionConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceTransactionConfig.js","sourceRoot":"","sources":["../src/deviceTransactionConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAOxE,SAAS,0BAA0B,CAAC,EAClC,WAAW,EACX,OAAO,EACP,aAAa,EACb,MAAM,EAAE,EAAE,MAAM,EAAE,GAMnB;IACC,MAAM,MAAM,GAAkC,EAAE,CAAC;IACjD,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC;IAE7B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,cAAc;YACrB,OAAO,EAAE,WAAW,CAAC,YAAY;SAClC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,eAAe,0BAA0B,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const IconAllFundsWarning: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
2
+ [key: string]: unknown;
3
+ }>;
4
+ export declare const IconValidatorsRequired: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
5
+ [key: string]: unknown;
6
+ }>;
7
+ export declare const IconDoMaxSendInstead: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
8
+ [key: string]: unknown;
9
+ }>;
10
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB;;EAAgD,CAAC;AACjF,eAAO,MAAM,sBAAsB;;EAAmD,CAAC;AACvF,eAAO,MAAM,oBAAoB;;EAAiD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { createCustomErrorClass } from "@ledgerhq/errors";
2
+ export const IconAllFundsWarning = createCustomErrorClass("IconAllFundsWarning");
3
+ export const IconValidatorsRequired = createCustomErrorClass("IconValidatorsRequired");
4
+ export const IconDoMaxSendInstead = createCustomErrorClass("IconDoMaxSendInstead");
5
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,qBAAqB,CAAC,CAAC;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAAsB,CAAC,wBAAwB,CAAC,CAAC;AACvF,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import type { AccountLike, Account } from "@ledgerhq/types-live";
3
+ import type { Transaction } from "./types";
4
+ /**
5
+ * Returns the maximum possible amount for transaction
6
+ *
7
+ * @param {Object} param - the account, parentAccount and transaction
8
+ */
9
+ export declare const estimateMaxSpendable: ({ account, parentAccount, transaction, }: {
10
+ account: AccountLike;
11
+ parentAccount: Account | null | undefined;
12
+ transaction: Transaction | null | undefined;
13
+ }) => Promise<BigNumber>;
14
+ //# sourceMappingURL=estimateMaxSpendable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimateMaxSpendable.d.ts","sourceRoot":"","sources":["../src/estimateMaxSpendable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,SAAS,CAAC;AAKxD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;aAKtB,WAAW;mBACL,OAAO,GAAG,IAAI,GAAG,SAAS;iBAC5B,WAAW,GAAG,IAAI,GAAG,SAAS;MACzC,QAAQ,SAAS,CAYpB,CAAC"}
@@ -0,0 +1,31 @@
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 { getMainAccount } from "@ledgerhq/coin-framework/account/index";
11
+ import { createTransaction } from "./createTransaction";
12
+ import getEstimatedFees from "./getFeesForTransaction";
13
+ import { calculateAmount } from "./logic";
14
+ /**
15
+ * Returns the maximum possible amount for transaction
16
+ *
17
+ * @param {Object} param - the account, parentAccount and transaction
18
+ */
19
+ export const estimateMaxSpendable = (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, parentAccount, transaction, }) {
20
+ const acc = getMainAccount(account, parentAccount);
21
+ const tx = Object.assign(Object.assign(Object.assign({}, createTransaction()), transaction), { useAllAmount: true });
22
+ const fees = yield getEstimatedFees({
23
+ account: acc,
24
+ transaction: tx,
25
+ });
26
+ return calculateAmount({
27
+ account: acc,
28
+ transaction: Object.assign(Object.assign({}, tx), { fees }),
29
+ });
30
+ });
31
+ //# sourceMappingURL=estimateMaxSpendable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimateMaxSpendable.js","sourceRoot":"","sources":["../src/estimateMaxSpendable.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAQb,EAAE,4CARkB,EACzC,OAAO,EACP,aAAa,EACb,WAAW,GAKZ;IACC,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,EAAE,aAAa,CAAgB,CAAC;IAClE,MAAM,EAAE,iDAAQ,iBAAiB,EAAE,GAAK,WAAW,KAAE,YAAY,EAAE,IAAI,GAAE,CAAC;IAC1E,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC;QAClC,OAAO,EAAE,GAAG;QACZ,WAAW,EAAE,EAAE;KAChB,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;QACrB,OAAO,EAAE,GAAG;QACZ,WAAW,kCAAO,EAAE,KAAE,IAAI,GAAE;KAC7B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import type { IconAccount, Transaction } from "./types";
3
+ /**
4
+ * Fetch the transaction fees for a transaction
5
+ *
6
+ * @param {IconAccount} account
7
+ * @param {Transaction} transaction
8
+ */
9
+ declare const getEstimatedFees: ({ account, transaction, }: {
10
+ account: IconAccount;
11
+ transaction: Transaction;
12
+ }) => Promise<BigNumber>;
13
+ export default getEstimatedFees;
14
+ //# sourceMappingURL=getFeesForTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFeesForTransaction.d.ts","sourceRoot":"","sources":["../src/getFeesForTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOxD;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB;aAIX,WAAW;iBACP,WAAW;MACtB,QAAQ,SAAS,CAuBpB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,42 @@
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 { getFees } from "./api/node";
12
+ import { buildTransaction } from "./buildTransaction";
13
+ import { getStepPrice } from "./api/node";
14
+ import { FEES_SAFETY_BUFFER, calculateAmount } from "./logic";
15
+ import { getAbandonSeedAddress } from "@ledgerhq/cryptoassets";
16
+ /**
17
+ * Fetch the transaction fees for a transaction
18
+ *
19
+ * @param {IconAccount} account
20
+ * @param {Transaction} transaction
21
+ */
22
+ const getEstimatedFees = (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, transaction, }) {
23
+ const tx = Object.assign(Object.assign({}, transaction), { recipient: getAbandonSeedAddress(account.currency.id),
24
+ // Always use a fake recipient to estimate fees
25
+ amount: calculateAmount({
26
+ account,
27
+ transaction: Object.assign(Object.assign({}, transaction), { fees: new BigNumber(0) }),
28
+ }) });
29
+ try {
30
+ const { unsigned } = yield buildTransaction(account, tx);
31
+ const stepLimit = yield getFees(unsigned, account);
32
+ transaction.stepLimit = stepLimit;
33
+ const stepPrice = yield getStepPrice(account);
34
+ return stepLimit.multipliedBy(stepPrice);
35
+ }
36
+ catch (_error) {
37
+ // Fix ME, the API of Icon throws an error when getting the fee with maximum balance
38
+ return FEES_SAFETY_BUFFER;
39
+ }
40
+ });
41
+ export default getEstimatedFees;
42
+ //# sourceMappingURL=getFeesForTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getFeesForTransaction.js","sourceRoot":"","sources":["../src/getFeesForTransaction.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,KAMF,EAAE,4CANO,EAC9B,OAAO,EACP,WAAW,GAIZ;IACC,MAAM,EAAE,mCACH,WAAW,KACd,SAAS,EAAE,qBAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,+CAA+C;QAC/C,MAAM,EAAE,eAAe,CAAC;YACtB,OAAO;YACP,WAAW,kCACN,WAAW,KACd,IAAI,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC,GACvB;SACF,CAAC,GACH,CAAC;IACF,IAAI,CAAC;QACH,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACzD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC;QAClC,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,SAAS,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,oFAAoF;QACpF,OAAO,kBAAkB,CAAC;IAC5B,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { IconAccount, Transaction, TransactionStatus } from "./types";
2
+ export declare const getSendTransactionStatus: (account: IconAccount, transaction: Transaction) => Promise<TransactionStatus>;
3
+ export declare const getTransactionStatus: (account: IconAccount, transaction: Transaction) => Promise<TransactionStatus>;
4
+ //# sourceMappingURL=getTransactionStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTransactionStatus.d.ts","sourceRoot":"","sources":["../src/getTransactionStatus.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAc3E,eAAO,MAAM,wBAAwB,YAC1B,WAAW,eACP,WAAW,KACvB,QAAQ,iBAAiB,CA4E3B,CAAC;AAEF,eAAO,MAAM,oBAAoB,YACtB,WAAW,eACP,WAAW,KACvB,QAAQ,iBAAiB,CA8B3B,CAAC"}
@@ -0,0 +1,109 @@
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 { NotEnoughBalance, RecipientRequired, InvalidAddress, FeeNotLoaded, InvalidAddressBecauseDestinationIsAlsoSource, AmountRequired, } from "@ledgerhq/errors";
12
+ import { EXISTENTIAL_DEPOSIT, EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN, FEES_SAFETY_BUFFER, calculateAmount, getMinimumBalance, isSelfTransaction, isValidAddress, } from "./logic";
13
+ import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
14
+ import { IconAllFundsWarning, IconDoMaxSendInstead } from "./errors";
15
+ export const getSendTransactionStatus = (account, transaction) => __awaiter(void 0, void 0, void 0, function* () {
16
+ var _a, _b;
17
+ const errors = {};
18
+ const warnings = {};
19
+ // Check if fees are loaded
20
+ if (!transaction.fees) {
21
+ errors.fees = new FeeNotLoaded();
22
+ }
23
+ // Validate recipient
24
+ if (!transaction.recipient) {
25
+ errors.recipient = new RecipientRequired();
26
+ }
27
+ else if (isSelfTransaction(account, transaction)) {
28
+ errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
29
+ }
30
+ else if (!isValidAddress(transaction.recipient)) {
31
+ errors.recipient = new InvalidAddress("", {
32
+ currencyName: account.currency.name,
33
+ });
34
+ }
35
+ const estimatedFees = transaction.fees || new BigNumber(0);
36
+ const amount = calculateAmount({ account, transaction });
37
+ const totalSpent = amount.plus(estimatedFees);
38
+ // Check if amount is valid
39
+ if (amount.lte(0) && !transaction.useAllAmount) {
40
+ errors.amount = new AmountRequired();
41
+ }
42
+ else {
43
+ const minimumBalanceExistential = getMinimumBalance(account);
44
+ const leftover = account.spendableBalance.minus(totalSpent);
45
+ if (minimumBalanceExistential.gt(0) &&
46
+ leftover.lt(minimumBalanceExistential) &&
47
+ leftover.gt(0)) {
48
+ errors.amount = new IconDoMaxSendInstead("Balance cannot be below {{minimumBalance}}. Send max to empty account.", {
49
+ minimumBalance: formatCurrencyUnit(account.currency.units[0], EXISTENTIAL_DEPOSIT, {
50
+ showCode: true,
51
+ }),
52
+ });
53
+ }
54
+ else if (!errors.amount &&
55
+ !transaction.useAllAmount &&
56
+ account.spendableBalance.lte(EXISTENTIAL_DEPOSIT.plus(EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN))) {
57
+ errors.amount = new NotEnoughBalance();
58
+ }
59
+ else if (totalSpent.gt(account.spendableBalance)) {
60
+ errors.amount = new NotEnoughBalance();
61
+ }
62
+ if (!errors.amount &&
63
+ new BigNumber((_a = account.iconResources) === null || _a === void 0 ? void 0 : _a.totalDelegated)
64
+ .plus((_b = account.iconResources) === null || _b === void 0 ? void 0 : _b.votingPower)
65
+ .gt(0) &&
66
+ (transaction.useAllAmount ||
67
+ account.spendableBalance.minus(totalSpent).lt(FEES_SAFETY_BUFFER))) {
68
+ warnings.amount = new IconAllFundsWarning();
69
+ }
70
+ if (totalSpent.gt(account.spendableBalance)) {
71
+ errors.amount = new NotEnoughBalance();
72
+ }
73
+ }
74
+ return Promise.resolve({
75
+ errors,
76
+ warnings,
77
+ estimatedFees,
78
+ amount: amount.lt(0) ? new BigNumber(0) : amount,
79
+ totalSpent,
80
+ });
81
+ });
82
+ export const getTransactionStatus = (account, transaction) => __awaiter(void 0, void 0, void 0, function* () {
83
+ switch (transaction.mode) {
84
+ case "send":
85
+ return yield getSendTransactionStatus(account, transaction);
86
+ default: {
87
+ const errors = {};
88
+ const warnings = {};
89
+ const amount = calculateAmount({ account, transaction });
90
+ const estimatedFees = transaction.fees || new BigNumber(0);
91
+ const totalSpent = amount.plus(estimatedFees);
92
+ if (totalSpent.gt(account.spendableBalance)) {
93
+ errors.amount = new NotEnoughBalance();
94
+ }
95
+ // Validate amount
96
+ if (amount.lte(0) && !transaction.useAllAmount) {
97
+ errors.amount = new AmountRequired();
98
+ }
99
+ return {
100
+ errors,
101
+ warnings,
102
+ estimatedFees,
103
+ amount: amount.lt(0) ? new BigNumber(0) : amount,
104
+ totalSpent,
105
+ };
106
+ }
107
+ }
108
+ });
109
+ //# sourceMappingURL=getTransactionStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTransactionStatus.js","sourceRoot":"","sources":["../src/getTransactionStatus.ts"],"names":[],"mappings":";;;;;;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,WAAW,CAAC,IAAI,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAE9C,IAAI,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC5C,MAAM,CAAC,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;YACzC,CAAC;YAED,kBAAkB;YAClB,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;gBAC/C,MAAM,CAAC,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;YACvC,CAAC;YAED,OAAO;gBACL,MAAM;gBACN,QAAQ;gBACR,aAAa;gBACb,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM;gBAChD,UAAU;aACX,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAA,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
2
+ import { SignerContext } from "@ledgerhq/coin-framework/signer";
3
+ import { IconSigner } from "./signer";
4
+ declare const resolver: (signerContext: SignerContext<IconSigner>) => GetAddressFn;
5
+ export default resolver;
6
+ //# sourceMappingURL=hw-getAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hw-getAddress.d.ts","sourceRoot":"","sources":["../src/hw-getAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mDAAmD,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAe,UAAU,EAAE,MAAM,UAAU,CAAC;AAEnD,QAAA,MAAM,QAAQ,kBAAmB,cAAc,UAAU,CAAC,KAAG,YAW5D,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,21 @@
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
+ const resolver = (signerContext) => {
11
+ return (deviceId_1, _a) => __awaiter(void 0, [deviceId_1, _a], void 0, function* (deviceId, { path, verify }) {
12
+ const r = (yield signerContext(deviceId, signer => signer.getAddress(path, verify || false)));
13
+ return {
14
+ address: r.address,
15
+ publicKey: r.publicKey,
16
+ path,
17
+ };
18
+ });
19
+ };
20
+ export default resolver;
21
+ //# sourceMappingURL=hw-getAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hw-getAddress.js","sourceRoot":"","sources":["../src/hw-getAddress.ts"],"names":[],"mappings":";;;;;;;;;AAKA,MAAM,QAAQ,GAAG,CAAC,aAAwC,EAAgB,EAAE;IAC1E,OAAO,iBAA8D,EAAE,wDAAzD,QAAgB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAqB;QACjE,MAAM,CAAC,GAAG,CAAC,MAAM,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAChD,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC,CACzC,CAAgB,CAAC;QAClB,OAAO;YACL,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,IAAI;SACL,CAAC;IACJ,CAAC,CAAA,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Account } from "@ledgerhq/types-live";
2
+ export declare function initAccount(account: Account): void;
3
+ //# sourceMappingURL=initAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initAccount.d.ts","sourceRoot":"","sources":["../src/initAccount.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAMlD"}
@@ -0,0 +1,9 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ export function initAccount(account) {
3
+ account.iconResources = {
4
+ nonce: 0,
5
+ votingPower: BigNumber(0),
6
+ totalDelegated: BigNumber(0),
7
+ };
8
+ }
9
+ //# sourceMappingURL=initAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initAccount.js","sourceRoot":"","sources":["../src/initAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,MAAM,UAAU,WAAW,CAAC,OAAgB;IACzC,OAAuB,CAAC,aAAa,GAAG;QACvC,KAAK,EAAE,CAAC;QACR,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;QACzB,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;KAC7B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
3
+ import type { Account } from "@ledgerhq/types-live";
4
+ import type { IconAccount, Transaction } from "./types";
5
+ /**
6
+ * @param {string|number|BigNumber} value value as loop
7
+ * @returns {BigNumber} value as ICX
8
+ */
9
+ export declare const convertLoopToIcx: (value: string | number | BigNumber) => BigNumber;
10
+ /**
11
+ * @param {string|number|BigNumber} value value as ICX
12
+ * @returns {BigNumber} value as loop
13
+ */
14
+ export declare const convertICXtoLoop: (value: string | number | BigNumber) => BigNumber;
15
+ export declare const EXISTENTIAL_DEPOSIT: BigNumber;
16
+ export declare const EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN: BigNumber;
17
+ export declare const FEES_SAFETY_BUFFER: BigNumber;
18
+ export declare const MAX_AMOUNT_INPUT: BigNumber;
19
+ /**
20
+ * Returns true if address is a valid md5
21
+ *
22
+ * @param {string} address
23
+ */
24
+ export declare const isValidAddress: (address: string) => boolean;
25
+ /**
26
+ * Returns true if transaction is a self transaction
27
+ *
28
+ * @param {Account} account
29
+ * @param {Transaction} transaction
30
+ */
31
+ export declare const isSelfTransaction: (account: Account, transaction: Transaction) => boolean;
32
+ /**
33
+ * Returns nonce for an account
34
+ *
35
+ * @param {Account} account
36
+ */
37
+ export declare const getNonce: (account: IconAccount) => number;
38
+ /**
39
+ * Returns true if the current currency is testnet
40
+ *
41
+ * @param {currency} CryptoCurrency
42
+ */
43
+ export declare function isTestnet(currency: CryptoCurrency): boolean;
44
+ export declare function getNid(currency: CryptoCurrency): number;
45
+ /**
46
+ * Calculates correct amount if useAllAmount
47
+ *
48
+ * @param {*} param
49
+ */
50
+ export declare const calculateAmount: ({ account, transaction, }: {
51
+ account: IconAccount;
52
+ transaction: Transaction;
53
+ }) => BigNumber;
54
+ export declare const getMinimumBalance: (account: Account) => BigNumber;
55
+ //# sourceMappingURL=logic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../src/logic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAIxD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,GAAG,MAAM,GAAG,SAAS,KAAG,SAErE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,GAAG,MAAM,GAAG,SAAS,KAAG,SAErE,CAAC;AAEF,eAAO,MAAM,mBAAmB,WAA4B,CAAC;AAC7D,eAAO,MAAM,sCAAsC,WAA4B,CAAC;AAChF,eAAO,MAAM,kBAAkB,WAA4B,CAAC;AAC5D,eAAO,MAAM,gBAAgB,WAAyB,CAAC;AACvD;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,OAGhD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,YAAa,OAAO,eAAe,WAAW,KAAG,OAE9E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,YAAa,WAAW,KAAG,MAW/C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAE3D;AAED,wBAAgB,MAAM,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAMvD;AAaD;;;;GAIG;AACH,eAAO,MAAM,eAAe;aAIjB,WAAW;iBACP,WAAW;MACtB,SAkBH,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,OAAO,KAAG,SAKpD,CAAC"}
@@ -0,0 +1,109 @@
1
+ import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
2
+ import { BigNumber } from "bignumber.js";
3
+ import IconService from "icon-sdk-js";
4
+ const { IconAmount } = IconService;
5
+ import { BERLIN_TESTNET_NID, MAINNET_NID } from "./constants";
6
+ /**
7
+ * @param {string|number|BigNumber} value value as loop
8
+ * @returns {BigNumber} value as ICX
9
+ */
10
+ export const convertLoopToIcx = (value) => {
11
+ return new BigNumber(IconAmount.fromLoop(value, IconAmount.Unit.ICX.toString()));
12
+ };
13
+ /**
14
+ * @param {string|number|BigNumber} value value as ICX
15
+ * @returns {BigNumber} value as loop
16
+ */
17
+ export const convertICXtoLoop = (value) => {
18
+ return new BigNumber(IconAmount.toLoop(value, IconAmount.Unit.ICX.toString()));
19
+ };
20
+ export const EXISTENTIAL_DEPOSIT = convertICXtoLoop(0.00125);
21
+ export const EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN = convertICXtoLoop(0.00125);
22
+ export const FEES_SAFETY_BUFFER = convertICXtoLoop(0.00125); // Arbitrary buffer for paying fees of next transactions
23
+ export const MAX_AMOUNT_INPUT = convertICXtoLoop(5000);
24
+ /**
25
+ * Returns true if address is a valid md5
26
+ *
27
+ * @param {string} address
28
+ */
29
+ export const isValidAddress = (address) => {
30
+ if (!address)
31
+ return false;
32
+ return !!address.match(/^[a-z0-9]{42}$/);
33
+ };
34
+ /**
35
+ * Returns true if transaction is a self transaction
36
+ *
37
+ * @param {Account} account
38
+ * @param {Transaction} transaction
39
+ */
40
+ export const isSelfTransaction = (account, transaction) => {
41
+ return transaction.recipient === account.freshAddress;
42
+ };
43
+ /**
44
+ * Returns nonce for an account
45
+ *
46
+ * @param {Account} account
47
+ */
48
+ export const getNonce = (account) => {
49
+ var _a;
50
+ const lastPendingOp = account.pendingOperations[0];
51
+ const nonce = Math.max(((_a = account.iconResources) === null || _a === void 0 ? void 0 : _a.nonce) || 0, lastPendingOp && typeof lastPendingOp.transactionSequenceNumber === "number"
52
+ ? lastPendingOp.transactionSequenceNumber + 1
53
+ : 0);
54
+ return nonce;
55
+ };
56
+ /**
57
+ * Returns true if the current currency is testnet
58
+ *
59
+ * @param {currency} CryptoCurrency
60
+ */
61
+ export function isTestnet(currency) {
62
+ return getCryptoCurrencyById(currency.id).isTestnetFor ? true : false;
63
+ }
64
+ export function getNid(currency) {
65
+ let nid = MAINNET_NID;
66
+ if (isTestnet(currency)) {
67
+ nid = BERLIN_TESTNET_NID;
68
+ }
69
+ return nid;
70
+ }
71
+ /**
72
+ * Calculate the real spendable
73
+ *
74
+ * @param {*} account
75
+ * @param {*} transaction
76
+ */
77
+ const calculateMaxSend = (account, transaction) => {
78
+ const amount = account.spendableBalance.minus(transaction.fees || 0);
79
+ return amount.lt(0) ? new BigNumber(0) : BigNumber(amount.toFixed(5));
80
+ };
81
+ /**
82
+ * Calculates correct amount if useAllAmount
83
+ *
84
+ * @param {*} param
85
+ */
86
+ export const calculateAmount = ({ account, transaction, }) => {
87
+ let amount = transaction.amount;
88
+ if (transaction.useAllAmount) {
89
+ switch (transaction.mode) {
90
+ case "send":
91
+ amount = calculateMaxSend(account, transaction);
92
+ break;
93
+ default:
94
+ amount = account.spendableBalance.minus(transaction.fees || 0);
95
+ break;
96
+ }
97
+ }
98
+ else if (transaction.amount.gt(MAX_AMOUNT_INPUT)) {
99
+ return new BigNumber(MAX_AMOUNT_INPUT);
100
+ }
101
+ return amount.lt(0) ? new BigNumber(0) : amount;
102
+ };
103
+ export const getMinimumBalance = (account) => {
104
+ const lockedBalance = account.balance.minus(account.spendableBalance);
105
+ return lockedBalance.lte(EXISTENTIAL_DEPOSIT)
106
+ ? EXISTENTIAL_DEPOSIT.minus(lockedBalance)
107
+ : new BigNumber(0);
108
+ };
109
+ //# sourceMappingURL=logic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic.js","sourceRoot":"","sources":["../src/logic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,WAAW,MAAM,aAAa,CAAC;AAItC,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE9D;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAkC,EAAa,EAAE;IAChF,OAAO,IAAI,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,M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C,WAAW,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;gBAC/D,MAAM;QACV,CAAC;IACH,CAAC;SAAM,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACnD,OAAO,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAgB,EAAa,EAAE;IAC/D,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACtE,OAAO,aAAa,CAAC,GAAG,CAAC,mBAAmB,CAAC;QAC3C,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,aAAa,CAAC;QAC1C,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { IconAccount, Transaction } from "./types";
2
+ /**
3
+ * Prepare transaction before checking status
4
+ *
5
+ * @param {IconAccount} account
6
+ * @param {Transaction} transaction
7
+ */
8
+ export declare const prepareTransaction: (account: IconAccount, transaction: Transaction) => Promise<Transaction>;
9
+ //# sourceMappingURL=prepareTransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../src/prepareTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAMxD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,YACpB,WAAW,eACP,WAAW,KACvB,QAAQ,WAAW,CAQrB,CAAC"}
@@ -0,0 +1,26 @@
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 getEstimatedFees from "./getFeesForTransaction";
11
+ const sameFees = (a, b) => (!a || !b ? a === b : a.eq(b));
12
+ /**
13
+ * Prepare transaction before checking status
14
+ *
15
+ * @param {IconAccount} account
16
+ * @param {Transaction} transaction
17
+ */
18
+ export const prepareTransaction = (account, transaction) => __awaiter(void 0, void 0, void 0, function* () {
19
+ let fees = transaction.fees;
20
+ fees = yield getEstimatedFees({ account, transaction });
21
+ if (fees && !sameFees(fees, transaction.fees)) {
22
+ return Object.assign(Object.assign({}, transaction), { fees });
23
+ }
24
+ return transaction;
25
+ });
26
+ //# sourceMappingURL=prepareTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareTransaction.js","sourceRoot":"","sources":["../src/prepareTransaction.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AAGvD,MAAM,QAAQ,GAAG,CAAC,CAAY,EAAE,CAAoB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAExF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,OAAoB,EACpB,WAAwB,EACF,EAAE;IACxB,IAAI,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;IAC5B,IAAI,GAAG,MAAM,gBAAgB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IAExD,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9C,uCAAY,WAAW,KAAE,IAAI,IAAG;IAClC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAA,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { IconResourcesRaw, IconResources } from "./types";
2
+ import { AccountRaw, Account } from "@ledgerhq/types-live";
3
+ export declare function toIconResourcesRaw(resources: IconResources): IconResourcesRaw;
4
+ export declare function fromIconResourcesRaw(rawResources: IconResourcesRaw): IconResources;
5
+ export declare function assignToAccountRaw(account: Account, accountRaw: AccountRaw): void;
6
+ export declare function assignFromAccountRaw(accountRaw: AccountRaw, account: Account): void;
7
+ //# sourceMappingURL=serialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAA+B,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE3D,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,aAAa,GAAG,gBAAgB,CAO7E;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,gBAAgB,GAAG,aAAa,CAOlF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAKjF;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,QAI5E"}