@ledgerhq/live-common 25.2.0-next.0 → 26.0.0-next.2

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 (320) hide show
  1. package/lib/__tests__/test-helpers/setup.js +2 -0
  2. package/lib/__tests__/test-helpers/setup.js.map +1 -1
  3. package/lib/account/helpers.d.ts.map +1 -1
  4. package/lib/account/helpers.js +1 -0
  5. package/lib/account/helpers.js.map +1 -1
  6. package/lib/account/serialization.d.ts.map +1 -1
  7. package/lib/account/serialization.js +4 -0
  8. package/lib/account/serialization.js.map +1 -1
  9. package/lib/data/icons/react/index.d.ts +1 -0
  10. package/lib/data/icons/react/index.d.ts.map +1 -1
  11. package/lib/data/icons/react/index.js +7 -5
  12. package/lib/data/icons/react/index.js.map +1 -1
  13. package/lib/data/icons/react/osmo.d.ts +8 -0
  14. package/lib/data/icons/react/osmo.d.ts.map +1 -0
  15. package/lib/data/icons/react/osmo.js +39 -0
  16. package/lib/data/icons/react/osmo.js.map +1 -0
  17. package/lib/data/icons/reactNative/index.d.ts +1 -0
  18. package/lib/data/icons/reactNative/index.d.ts.map +1 -1
  19. package/lib/data/icons/reactNative/index.js +7 -5
  20. package/lib/data/icons/reactNative/index.js.map +1 -1
  21. package/lib/data/icons/reactNative/osmo.d.ts +8 -0
  22. package/lib/data/icons/reactNative/osmo.d.ts.map +1 -0
  23. package/lib/data/icons/reactNative/osmo.js +40 -0
  24. package/lib/data/icons/reactNative/osmo.js.map +1 -0
  25. package/lib/env.d.ts +15 -5
  26. package/lib/env.d.ts.map +1 -1
  27. package/lib/env.js +10 -0
  28. package/lib/env.js.map +1 -1
  29. package/lib/env.react.d.ts +1 -1
  30. package/lib/env.react.d.ts.map +1 -1
  31. package/lib/families/cosmos/CosmosValidatorsManager.d.ts +26 -0
  32. package/lib/families/cosmos/CosmosValidatorsManager.d.ts.map +1 -0
  33. package/lib/families/cosmos/CosmosValidatorsManager.js +365 -0
  34. package/lib/families/cosmos/CosmosValidatorsManager.js.map +1 -0
  35. package/lib/families/cosmos/account.d.ts +2 -2
  36. package/lib/families/cosmos/account.d.ts.map +1 -1
  37. package/lib/families/cosmos/account.js +19 -6
  38. package/lib/families/cosmos/account.js.map +1 -1
  39. package/lib/families/cosmos/api/Cosmos.d.ts +27 -15
  40. package/lib/families/cosmos/api/Cosmos.d.ts.map +1 -1
  41. package/lib/families/cosmos/api/Cosmos.js +418 -410
  42. package/lib/families/cosmos/api/Cosmos.js.map +1 -1
  43. package/lib/families/cosmos/bridge/js.d.ts.map +1 -1
  44. package/lib/families/cosmos/bridge/js.js +5 -5
  45. package/lib/families/cosmos/bridge/js.js.map +1 -1
  46. package/lib/families/cosmos/bridge/mock.js +1 -1
  47. package/lib/families/cosmos/bridge/mock.js.map +1 -1
  48. package/lib/families/cosmos/bridge.integration.test.js +5 -5
  49. package/lib/families/cosmos/bridge.integration.test.js.map +1 -1
  50. package/lib/families/cosmos/cli-transaction.d.ts +3 -3
  51. package/lib/families/cosmos/cli-transaction.d.ts.map +1 -1
  52. package/lib/families/cosmos/cli-transaction.js +4 -5
  53. package/lib/families/cosmos/cli-transaction.js.map +1 -1
  54. package/lib/families/cosmos/js-buildTransaction.js +3 -3
  55. package/lib/families/cosmos/js-buildTransaction.js.map +1 -1
  56. package/lib/families/cosmos/js-createTransaction.js +1 -1
  57. package/lib/families/cosmos/js-createTransaction.js.map +1 -1
  58. package/lib/families/cosmos/js-getTransactionStatus.d.ts +17 -3
  59. package/lib/families/cosmos/js-getTransactionStatus.d.ts.map +1 -1
  60. package/lib/families/cosmos/js-getTransactionStatus.js +224 -176
  61. package/lib/families/cosmos/js-getTransactionStatus.js.map +1 -1
  62. package/lib/families/cosmos/js-prepareTransaction.js +2 -2
  63. package/lib/families/cosmos/js-prepareTransaction.js.map +1 -1
  64. package/lib/families/cosmos/js-signOperation.js +3 -3
  65. package/lib/families/cosmos/js-signOperation.js.map +1 -1
  66. package/lib/families/cosmos/js-synchronisation.js +2 -2
  67. package/lib/families/cosmos/js-synchronisation.js.map +1 -1
  68. package/lib/families/cosmos/logic.js +1 -1
  69. package/lib/families/cosmos/logic.js.map +1 -1
  70. package/lib/families/cosmos/mock.js +1 -1
  71. package/lib/families/cosmos/mock.js.map +1 -1
  72. package/lib/families/cosmos/react.d.ts +4 -4
  73. package/lib/families/cosmos/react.d.ts.map +1 -1
  74. package/lib/families/cosmos/react.js +59 -26
  75. package/lib/families/cosmos/react.js.map +1 -1
  76. package/lib/families/cosmos/react.test.js +17 -15
  77. package/lib/families/cosmos/react.test.js.map +1 -1
  78. package/lib/families/cosmos/specs.js +2 -2
  79. package/lib/families/cosmos/specs.js.map +1 -1
  80. package/lib/families/cosmos/speculos-deviceActions.d.ts.map +1 -1
  81. package/lib/families/cosmos/speculos-deviceActions.js +1 -1
  82. package/lib/families/cosmos/speculos-deviceActions.js.map +1 -1
  83. package/lib/families/cosmos/transaction.d.ts +2 -2
  84. package/lib/families/cosmos/transaction.d.ts.map +1 -1
  85. package/lib/families/cosmos/transaction.js +4 -4
  86. package/lib/families/cosmos/transaction.js.map +1 -1
  87. package/lib/families/cosmos/types.d.ts +31 -13
  88. package/lib/families/cosmos/types.d.ts.map +1 -1
  89. package/lib/families/cosmos/utils.d.ts +1 -0
  90. package/lib/families/cosmos/utils.d.ts.map +1 -1
  91. package/lib/families/cosmos/utils.js +7 -1
  92. package/lib/families/cosmos/utils.js.map +1 -1
  93. package/lib/families/cosmos/validators.d.ts +3 -5
  94. package/lib/families/cosmos/validators.d.ts.map +1 -1
  95. package/lib/families/cosmos/validators.js +4 -317
  96. package/lib/families/cosmos/validators.js.map +1 -1
  97. package/lib/families/filecoin/bridge/account.d.ts.map +1 -1
  98. package/lib/families/filecoin/bridge/account.js +11 -5
  99. package/lib/families/filecoin/bridge/account.js.map +1 -1
  100. package/lib/families/osmosis/OsmosisSupplyTypes.d.ts +48 -0
  101. package/lib/families/osmosis/OsmosisSupplyTypes.d.ts.map +1 -0
  102. package/lib/families/osmosis/OsmosisSupplyTypes.js +3 -0
  103. package/lib/families/osmosis/OsmosisSupplyTypes.js.map +1 -0
  104. package/lib/families/osmosis/account.d.ts +14 -0
  105. package/lib/families/osmosis/account.d.ts.map +1 -0
  106. package/lib/families/osmosis/account.js +60 -0
  107. package/lib/families/osmosis/account.js.map +1 -0
  108. package/lib/families/osmosis/api/sdk.d.ts +35 -0
  109. package/lib/families/osmosis/api/sdk.d.ts.map +1 -0
  110. package/lib/families/osmosis/api/sdk.js +478 -0
  111. package/lib/families/osmosis/api/sdk.js.map +1 -0
  112. package/lib/families/osmosis/api/sdk.types.d.ts +57 -0
  113. package/lib/families/osmosis/api/sdk.types.d.ts.map +1 -0
  114. package/lib/families/osmosis/api/sdk.types.js +15 -0
  115. package/lib/families/osmosis/api/sdk.types.js.map +1 -0
  116. package/lib/families/osmosis/api/sdk.unit.test.d.ts +2 -0
  117. package/lib/families/osmosis/api/sdk.unit.test.d.ts.map +1 -0
  118. package/lib/families/osmosis/api/sdk.unit.test.js +50 -0
  119. package/lib/families/osmosis/api/sdk.unit.test.js.map +1 -0
  120. package/lib/families/osmosis/bridge/js.d.ts +8 -0
  121. package/lib/families/osmosis/bridge/js.d.ts.map +1 -0
  122. package/lib/families/osmosis/bridge/js.js +98 -0
  123. package/lib/families/osmosis/bridge/js.js.map +1 -0
  124. package/lib/families/osmosis/bridge.integration.test.d.ts +2 -0
  125. package/lib/families/osmosis/bridge.integration.test.d.ts.map +1 -0
  126. package/lib/families/osmosis/bridge.integration.test.js +383 -0
  127. package/lib/families/osmosis/bridge.integration.test.js.map +1 -0
  128. package/lib/families/osmosis/cli-transaction.d.ts +38 -0
  129. package/lib/families/osmosis/cli-transaction.d.ts.map +1 -0
  130. package/lib/families/osmosis/cli-transaction.js +119 -0
  131. package/lib/families/osmosis/cli-transaction.js.map +1 -0
  132. package/lib/families/osmosis/deviceTransactionConfig.d.ts +25 -0
  133. package/lib/families/osmosis/deviceTransactionConfig.d.ts.map +1 -0
  134. package/lib/families/osmosis/deviceTransactionConfig.js +132 -0
  135. package/lib/families/osmosis/deviceTransactionConfig.js.map +1 -0
  136. package/lib/families/osmosis/errors.d.ts +4 -0
  137. package/lib/families/osmosis/errors.d.ts.map +1 -0
  138. package/lib/families/osmosis/errors.js +8 -0
  139. package/lib/families/osmosis/errors.js.map +1 -0
  140. package/lib/families/osmosis/hw-getAddress.d.ts +4 -0
  141. package/lib/families/osmosis/hw-getAddress.d.ts.map +1 -0
  142. package/lib/families/osmosis/hw-getAddress.js +64 -0
  143. package/lib/families/osmosis/hw-getAddress.js.map +1 -0
  144. package/lib/families/osmosis/js-buildTransaction.d.ts +14 -0
  145. package/lib/families/osmosis/js-buildTransaction.d.ts.map +1 -0
  146. package/lib/families/osmosis/js-buildTransaction.js +303 -0
  147. package/lib/families/osmosis/js-buildTransaction.js.map +1 -0
  148. package/lib/families/osmosis/js-estimateMaxSpendable.d.ts +15 -0
  149. package/lib/families/osmosis/js-estimateMaxSpendable.d.ts.map +1 -0
  150. package/lib/families/osmosis/js-estimateMaxSpendable.js +67 -0
  151. package/lib/families/osmosis/js-estimateMaxSpendable.js.map +1 -0
  152. package/lib/families/osmosis/js-getFeesForTransaction.d.ts +15 -0
  153. package/lib/families/osmosis/js-getFeesForTransaction.d.ts.map +1 -0
  154. package/lib/families/osmosis/js-getFeesForTransaction.js +85 -0
  155. package/lib/families/osmosis/js-getFeesForTransaction.js.map +1 -0
  156. package/lib/families/osmosis/js-getTransactionStatus.d.ts +3 -0
  157. package/lib/families/osmosis/js-getTransactionStatus.d.ts.map +1 -0
  158. package/lib/families/osmosis/js-getTransactionStatus.js +10 -0
  159. package/lib/families/osmosis/js-getTransactionStatus.js.map +1 -0
  160. package/lib/families/osmosis/js-signOperation.d.ts +10 -0
  161. package/lib/families/osmosis/js-signOperation.d.ts.map +1 -0
  162. package/lib/families/osmosis/js-signOperation.js +211 -0
  163. package/lib/families/osmosis/js-signOperation.js.map +1 -0
  164. package/lib/families/osmosis/js-synchronization.d.ts +9 -0
  165. package/lib/families/osmosis/js-synchronization.d.ts.map +1 -0
  166. package/lib/families/osmosis/js-synchronization.js +176 -0
  167. package/lib/families/osmosis/js-synchronization.js.map +1 -0
  168. package/lib/families/osmosis/js-transaction.d.ts +23 -0
  169. package/lib/families/osmosis/js-transaction.d.ts.map +1 -0
  170. package/lib/families/osmosis/js-transaction.js +177 -0
  171. package/lib/families/osmosis/js-transaction.js.map +1 -0
  172. package/lib/families/osmosis/logic.d.ts +5 -0
  173. package/lib/families/osmosis/logic.d.ts.map +1 -0
  174. package/lib/families/osmosis/logic.js +22 -0
  175. package/lib/families/osmosis/logic.js.map +1 -0
  176. package/lib/families/osmosis/preloadedData.d.ts +9 -0
  177. package/lib/families/osmosis/preloadedData.d.ts.map +1 -0
  178. package/lib/families/osmosis/preloadedData.js +32 -0
  179. package/lib/families/osmosis/preloadedData.js.map +1 -0
  180. package/lib/families/osmosis/serialization.d.ts +7 -0
  181. package/lib/families/osmosis/serialization.d.ts.map +1 -0
  182. package/lib/families/osmosis/serialization.js +5 -0
  183. package/lib/families/osmosis/serialization.js.map +1 -0
  184. package/lib/families/osmosis/specs.d.ts +7 -0
  185. package/lib/families/osmosis/specs.d.ts.map +1 -0
  186. package/lib/families/osmosis/specs.js +402 -0
  187. package/lib/families/osmosis/specs.js.map +1 -0
  188. package/lib/families/osmosis/speculos-deviceActions.d.ts +7 -0
  189. package/lib/families/osmosis/speculos-deviceActions.d.ts.map +1 -0
  190. package/lib/families/osmosis/speculos-deviceActions.js +120 -0
  191. package/lib/families/osmosis/speculos-deviceActions.js.map +1 -0
  192. package/lib/families/osmosis/transaction.d.ts +10 -0
  193. package/lib/families/osmosis/transaction.d.ts.map +1 -0
  194. package/lib/families/osmosis/transaction.js +13 -0
  195. package/lib/families/osmosis/transaction.js.map +1 -0
  196. package/lib/families/osmosis/types.d.ts +38 -0
  197. package/lib/families/osmosis/types.d.ts.map +1 -0
  198. package/lib/families/osmosis/types.js +3 -0
  199. package/lib/families/osmosis/types.js.map +1 -0
  200. package/lib/families/osmosis/utils.d.ts +8 -0
  201. package/lib/families/osmosis/utils.d.ts.map +1 -0
  202. package/lib/families/osmosis/utils.js +28 -0
  203. package/lib/families/osmosis/utils.js.map +1 -0
  204. package/lib/families/osmosis/validators.d.ts +4 -0
  205. package/lib/families/osmosis/validators.d.ts.map +1 -0
  206. package/lib/families/osmosis/validators.js +131 -0
  207. package/lib/families/osmosis/validators.js.map +1 -0
  208. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  209. package/lib/featureFlags/defaultFeatures.js +3 -0
  210. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  211. package/lib/generated/account.d.ts +7 -1
  212. package/lib/generated/account.d.ts.map +1 -1
  213. package/lib/generated/account.js +4 -2
  214. package/lib/generated/account.js.map +1 -1
  215. package/lib/generated/bridge/js.d.ts +4 -0
  216. package/lib/generated/bridge/js.d.ts.map +1 -1
  217. package/lib/generated/bridge/js.js +14 -12
  218. package/lib/generated/bridge/js.js.map +1 -1
  219. package/lib/generated/cli-transaction.d.ts +33 -2
  220. package/lib/generated/cli-transaction.d.ts.map +1 -1
  221. package/lib/generated/cli-transaction.js +14 -12
  222. package/lib/generated/cli-transaction.js.map +1 -1
  223. package/lib/generated/deviceTransactionConfig.d.ts +4 -1
  224. package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
  225. package/lib/generated/deviceTransactionConfig.js +14 -12
  226. package/lib/generated/deviceTransactionConfig.js.map +1 -1
  227. package/lib/generated/hw-getAddress.d.ts +1 -0
  228. package/lib/generated/hw-getAddress.d.ts.map +1 -1
  229. package/lib/generated/hw-getAddress.js +14 -12
  230. package/lib/generated/hw-getAddress.js.map +1 -1
  231. package/lib/generated/specs.d.ts +3 -0
  232. package/lib/generated/specs.d.ts.map +1 -1
  233. package/lib/generated/specs.js +14 -12
  234. package/lib/generated/specs.js.map +1 -1
  235. package/lib/generated/speculos-deviceActions.d.ts +3 -0
  236. package/lib/generated/speculos-deviceActions.d.ts.map +1 -1
  237. package/lib/generated/speculos-deviceActions.js +14 -12
  238. package/lib/generated/speculos-deviceActions.js.map +1 -1
  239. package/lib/generated/transaction.d.ts +9 -1
  240. package/lib/generated/transaction.d.ts.map +1 -1
  241. package/lib/generated/transaction.js +14 -12
  242. package/lib/generated/transaction.js.map +1 -1
  243. package/lib/generated/types.d.ts +8 -4
  244. package/lib/generated/types.d.ts.map +1 -1
  245. package/lib/reconciliation.d.ts.map +1 -1
  246. package/lib/reconciliation.js +9 -0
  247. package/lib/reconciliation.js.map +1 -1
  248. package/package.json +8 -3
  249. package/src/__tests__/test-helpers/setup.ts +2 -0
  250. package/src/account/helpers.ts +1 -0
  251. package/src/account/serialization.ts +6 -0
  252. package/src/data/icons/react/index.tsx +1 -0
  253. package/src/data/icons/react/osmo.tsx +14 -0
  254. package/src/data/icons/reactNative/index.tsx +1 -0
  255. package/src/data/icons/reactNative/osmo.tsx +15 -0
  256. package/src/data/icons/svg/OSMO.svg +7 -0
  257. package/src/env.ts +10 -0
  258. package/src/families/cosmos/CosmosValidatorsManager.ts +420 -0
  259. package/src/families/cosmos/account.ts +29 -10
  260. package/src/families/cosmos/api/Cosmos.ts +267 -257
  261. package/src/families/cosmos/bridge/js.ts +6 -7
  262. package/src/families/cosmos/bridge/mock.ts +1 -1
  263. package/src/families/cosmos/bridge.integration.test.ts +5 -5
  264. package/src/families/cosmos/cli-transaction.ts +7 -8
  265. package/src/families/cosmos/js-buildTransaction.ts +4 -4
  266. package/src/families/cosmos/js-createTransaction.ts +1 -1
  267. package/src/families/cosmos/js-getTransactionStatus.ts +276 -226
  268. package/src/families/cosmos/js-prepareTransaction.ts +3 -3
  269. package/src/families/cosmos/js-signOperation.ts +4 -4
  270. package/src/families/cosmos/js-synchronisation.ts +3 -3
  271. package/src/families/cosmos/logic.ts +1 -1
  272. package/src/families/cosmos/mock.ts +1 -1
  273. package/src/families/cosmos/react.test.ts +25 -14
  274. package/src/families/cosmos/react.ts +73 -21
  275. package/src/families/cosmos/specs.ts +2 -2
  276. package/src/families/cosmos/speculos-deviceActions.ts +1 -2
  277. package/src/families/cosmos/transaction.ts +4 -6
  278. package/src/families/cosmos/types.ts +41 -13
  279. package/src/families/cosmos/utils.ts +8 -0
  280. package/src/families/cosmos/validators.ts +5 -363
  281. package/src/families/filecoin/bridge/account.ts +12 -5
  282. package/src/families/osmosis/OsmosisSupplyTypes.ts +53 -0
  283. package/src/families/osmosis/__snapshots__/bridge.integration.test.ts.snap +852 -0
  284. package/src/families/osmosis/account.ts +65 -0
  285. package/src/families/osmosis/api/sdk.ts +530 -0
  286. package/src/families/osmosis/api/sdk.types.ts +65 -0
  287. package/src/families/osmosis/api/sdk.unit.test.ts +70 -0
  288. package/src/families/osmosis/bridge/js.ts +64 -0
  289. package/src/families/osmosis/bridge.integration.test.ts +467 -0
  290. package/src/families/osmosis/cli-transaction.ts +145 -0
  291. package/src/families/osmosis/deviceTransactionConfig.ts +174 -0
  292. package/src/families/osmosis/errors.ts +13 -0
  293. package/src/families/osmosis/hw-getAddress.ts +14 -0
  294. package/src/families/osmosis/js-buildTransaction.ts +306 -0
  295. package/src/families/osmosis/js-estimateMaxSpendable.ts +26 -0
  296. package/src/families/osmosis/js-getFeesForTransaction.ts +44 -0
  297. package/src/families/osmosis/js-getTransactionStatus.ts +9 -0
  298. package/src/families/osmosis/js-signOperation.ts +172 -0
  299. package/src/families/osmosis/js-synchronization.ts +122 -0
  300. package/src/families/osmosis/js-transaction.ts +96 -0
  301. package/src/families/osmosis/logic.ts +26 -0
  302. package/src/families/osmosis/preloadedData.ts +32 -0
  303. package/src/families/osmosis/serialization.ts +6 -0
  304. package/src/families/osmosis/specs.ts +393 -0
  305. package/src/families/osmosis/speculos-deviceActions.ts +94 -0
  306. package/src/families/osmosis/transaction.ts +20 -0
  307. package/src/families/osmosis/types.ts +48 -0
  308. package/src/families/osmosis/utils.ts +31 -0
  309. package/src/families/osmosis/validators.ts +79 -0
  310. package/src/featureFlags/defaultFeatures.ts +3 -0
  311. package/src/generated/account.ts +3 -0
  312. package/src/generated/bridge/js.ts +3 -0
  313. package/src/generated/cli-transaction.ts +3 -0
  314. package/src/generated/deviceTransactionConfig.ts +5 -0
  315. package/src/generated/hw-getAddress.ts +3 -0
  316. package/src/generated/specs.ts +3 -0
  317. package/src/generated/speculos-deviceActions.ts +3 -0
  318. package/src/generated/transaction.ts +3 -0
  319. package/src/generated/types.ts +8 -0
  320. package/src/reconciliation.ts +16 -0
@@ -0,0 +1,145 @@
1
+ import { from, Observable } from "rxjs";
2
+ import { map } from "rxjs/operators";
3
+ import invariant from "invariant";
4
+ import flatMap from "lodash/flatMap";
5
+ import zipWith from "lodash/zipWith";
6
+ import { BigNumber } from "bignumber.js";
7
+ import osmosisValidatorsManager from "./validators";
8
+
9
+ import type { Transaction } from "../../generated/types";
10
+ import type {
11
+ Account,
12
+ AccountLike,
13
+ AccountLikeArray,
14
+ } from "@ledgerhq/types-live";
15
+ import { CosmosDelegationInfo } from "../cosmos/types";
16
+
17
+ const options = [
18
+ {
19
+ name: "mode",
20
+ type: String,
21
+ desc: "mode of transaction: send, delegate, undelegate",
22
+ },
23
+ {
24
+ name: "fees",
25
+ type: String,
26
+ desc: "how much fees",
27
+ },
28
+ {
29
+ name: "gasLimit",
30
+ type: String,
31
+ desc: "how much gasLimit. default is estimated with the recipient",
32
+ },
33
+ {
34
+ name: "memo",
35
+ type: String,
36
+ desc: "add a memo to a transaction",
37
+ },
38
+ {
39
+ name: "sourceValidator",
40
+ type: String,
41
+ desc: "for redelegate, add a source validator",
42
+ },
43
+ {
44
+ name: "osmosisValidator",
45
+ type: String,
46
+ multiple: true,
47
+ desc: "address of recipient validator that will receive the delegate",
48
+ },
49
+ {
50
+ name: "osmosisAmountValidator",
51
+ type: String,
52
+ multiple: true,
53
+ desc: "Amount that the validator will receive",
54
+ },
55
+ ];
56
+
57
+ function inferAccounts(account: Account): AccountLikeArray {
58
+ invariant(account.currency.family === "osmosis", "osmosis family");
59
+
60
+ const accounts: Account[] = [account];
61
+ return accounts;
62
+ }
63
+
64
+ function inferTransactions(
65
+ transactions: Array<{
66
+ account: AccountLike;
67
+ transaction: Transaction;
68
+ mainAccount: Account;
69
+ }>,
70
+ opts: Record<string, any>,
71
+ { inferAmount }: any
72
+ ): Transaction[] {
73
+ return flatMap(transactions, ({ transaction, account }) => {
74
+ invariant(transaction.family === "osmosis", "osmosis family");
75
+ const validatorsAddresses: string[] = opts["osmosisValidator"] || [];
76
+
77
+ const validatorsAmounts: BigNumber[] = (
78
+ opts["osmosisAmountValidator"] || []
79
+ ).map((value) => {
80
+ return inferAmount(account, value);
81
+ });
82
+ const validators: CosmosDelegationInfo[] = zipWith(
83
+ validatorsAddresses,
84
+ validatorsAmounts,
85
+ (address, amount) => ({
86
+ address,
87
+ amount: amount || new BigNumber(0),
88
+ })
89
+ );
90
+
91
+ return {
92
+ ...transaction,
93
+ family: "osmosis",
94
+ mode: opts.mode || "send",
95
+ fees: opts.fees ? inferAmount(account, opts.fees) : null,
96
+ gas: opts.gasLimit ? new BigNumber(opts.gasLimit) : null,
97
+ memo: opts.memo,
98
+ validators: validators,
99
+ sourceValidator: opts.sourceValidator,
100
+ } as Transaction;
101
+ });
102
+ }
103
+
104
+ const osmosisValidatorsFormatters = {
105
+ json: (list) => JSON.stringify(list),
106
+ default: (list) =>
107
+ list
108
+ .map(
109
+ (v) =>
110
+ `${v.validatorAddress} "${v.name}" ${v.votingPower} ${v.commission} ${v.estimatedYearlyRewardsRate}`
111
+ )
112
+ .join("\n"),
113
+ };
114
+
115
+ const osmosisValidators = {
116
+ args: [
117
+ {
118
+ name: "format",
119
+ desc: Object.keys(osmosisValidatorsFormatters).join(" | "),
120
+ type: String,
121
+ },
122
+ ],
123
+ job: ({
124
+ format,
125
+ }: Partial<{
126
+ format: string;
127
+ }>): Observable<string> =>
128
+ from(osmosisValidatorsManager.getValidators()).pipe(
129
+ map((validators) => {
130
+ const f =
131
+ (format && osmosisValidatorsFormatters[format]) ||
132
+ osmosisValidatorsFormatters.default;
133
+ return f(validators);
134
+ })
135
+ ),
136
+ };
137
+
138
+ export default {
139
+ options,
140
+ inferAccounts,
141
+ inferTransactions,
142
+ commands: {
143
+ osmosisValidators,
144
+ },
145
+ };
@@ -0,0 +1,174 @@
1
+ import type { AccountLike } from "@ledgerhq/types-live";
2
+ import type { DeviceTransactionField } from "../../transaction";
3
+ import type { TransactionStatus } from "./types";
4
+ import { Transaction } from "./types";
5
+
6
+ export type ExtraDeviceTransactionField =
7
+ | {
8
+ type: "cosmos.delegateValidators";
9
+ label: string;
10
+ }
11
+ | {
12
+ type: "cosmos.validatorName";
13
+ label: string;
14
+ }
15
+ | {
16
+ type: "cosmos.sourceValidatorName";
17
+ label: string;
18
+ }
19
+ | {
20
+ type: "osmosis.extendedAmount";
21
+ label: string;
22
+ value?: string;
23
+ };
24
+
25
+ function getDeviceTransactionConfig({
26
+ transaction,
27
+ status: { estimatedFees, totalSpent },
28
+ }: {
29
+ account: AccountLike;
30
+ transaction: Transaction;
31
+ status: TransactionStatus;
32
+ }): Array<DeviceTransactionField> {
33
+ const { mode, memo, validators } = transaction;
34
+ const fields: Array<DeviceTransactionField> = [];
35
+
36
+ switch (mode) {
37
+ case "send":
38
+ fields.push({
39
+ type: "osmosis.extendedAmount",
40
+ label: "Amount",
41
+ });
42
+ break;
43
+
44
+ case "delegate":
45
+ fields.push({
46
+ type: "text",
47
+ label: "Type",
48
+ value: "Delegate",
49
+ });
50
+
51
+ fields.push({
52
+ type: "cosmos.delegateValidators",
53
+ label: "Validators",
54
+ });
55
+ break;
56
+
57
+ case "undelegate":
58
+ fields.push({
59
+ type: "text",
60
+ label: "Type",
61
+ value: "Undelegate",
62
+ });
63
+
64
+ fields.push({
65
+ type: "osmosis.extendedAmount",
66
+ label: "Amount",
67
+ value: validators[0].amount.toString(),
68
+ });
69
+ fields.push({
70
+ type: "cosmos.validatorName",
71
+ label: "Validator",
72
+ });
73
+ break;
74
+
75
+ case "redelegate":
76
+ fields.push({
77
+ type: "text",
78
+ label: "Type",
79
+ value: "Redelegate",
80
+ });
81
+
82
+ fields.push({
83
+ type: "osmosis.extendedAmount",
84
+ label: "Amount",
85
+ value: validators[0].amount.toString(),
86
+ });
87
+
88
+ fields.push({
89
+ type: "cosmos.validatorName",
90
+ label: "Validator Dest",
91
+ });
92
+
93
+ fields.push({
94
+ type: "cosmos.sourceValidatorName",
95
+ label: "Validator Source",
96
+ });
97
+ break;
98
+
99
+ case "claimReward":
100
+ fields.push({
101
+ type: "text",
102
+ label: "Type",
103
+ value: "Withdraw Reward",
104
+ });
105
+ fields.push({
106
+ type: "cosmos.validatorName",
107
+ label: "Validator",
108
+ });
109
+ break;
110
+
111
+ case "claimRewardCompound":
112
+ fields.push({
113
+ type: "text",
114
+ label: "Type",
115
+ value: "Withdraw Reward",
116
+ });
117
+ fields.push({
118
+ type: "cosmos.validatorName",
119
+ label: "Validator",
120
+ });
121
+ fields.push({
122
+ type: "text",
123
+ label: "Type",
124
+ value: "Delegate",
125
+ });
126
+ fields.push({
127
+ type: "cosmos.delegateValidators",
128
+ label: "Validators",
129
+ });
130
+ break;
131
+
132
+ default:
133
+ break;
134
+ }
135
+
136
+ if (!estimatedFees.isNaN() && !estimatedFees.isZero()) {
137
+ fields.push({
138
+ type: "osmosis.extendedAmount",
139
+ label: "Fee",
140
+ value: estimatedFees.toString(),
141
+ });
142
+ }
143
+
144
+ if (memo) {
145
+ fields.push({
146
+ type: "text",
147
+ label: "Memo",
148
+ value: memo,
149
+ });
150
+ }
151
+
152
+ if (mode === "claimReward" || mode === "claimRewardCompound") {
153
+ let label = "Amount to be received";
154
+ label += mode === "claimRewardCompound" ? " and delegated" : "";
155
+ fields.push({
156
+ type: "osmosis.extendedAmount",
157
+ label: label,
158
+ value: validators[0].amount.toString(),
159
+ });
160
+ validators[0].amount;
161
+ } else if (mode === "undelegate" || mode === "redelegate") {
162
+ return fields;
163
+ } else {
164
+ fields.push({
165
+ type: "osmosis.extendedAmount",
166
+ label: "Total",
167
+ value: totalSpent.toString(),
168
+ });
169
+ }
170
+
171
+ return fields;
172
+ }
173
+
174
+ export default getDeviceTransactionConfig;
@@ -0,0 +1,13 @@
1
+ import { createCustomErrorClass } from "@ledgerhq/errors";
2
+
3
+ export const OsmosisWrongSignatureHeader = createCustomErrorClass(
4
+ "OsmosisWrongSignatureHeader"
5
+ );
6
+
7
+ export const OsmosisSignatureSize = createCustomErrorClass(
8
+ "OsmosisSignatureSize"
9
+ );
10
+
11
+ export const OsmosisErrorBroadcasting = createCustomErrorClass(
12
+ "OsmosisErrorBroadcasting"
13
+ );
@@ -0,0 +1,14 @@
1
+ import Cosmos from "@ledgerhq/hw-app-cosmos";
2
+ import type { Resolver } from "../../hw/getAddress/types";
3
+
4
+ const resolver: Resolver = async (transport, { path, verify, currency }) => {
5
+ const cosmos = new Cosmos(transport);
6
+ const r = await cosmos.getAddress(path, currency.id, verify || false);
7
+ return {
8
+ address: r.address,
9
+ publicKey: r.publicKey,
10
+ path,
11
+ };
12
+ };
13
+
14
+ export default resolver;
@@ -0,0 +1,306 @@
1
+ import type { Account } from "@ledgerhq/types-live";
2
+ import { Transaction } from "./types";
3
+ import { SignMode } from "cosmjs-types/cosmos/tx/signing/v1beta1/signing";
4
+ import { cosmos } from "@keplr-wallet/cosmos";
5
+ import { AminoMsg, AminoSignResponse } from "@cosmjs/amino";
6
+ import {
7
+ MsgBeginRedelegate,
8
+ MsgDelegate,
9
+ MsgUndelegate,
10
+ } from "cosmjs-types/cosmos/staking/v1beta1/tx";
11
+ import {
12
+ AminoMsgSend,
13
+ AminoMsgDelegate,
14
+ AminoMsgUndelegate,
15
+ AminoMsgBeginRedelegate,
16
+ AminoMsgWithdrawDelegatorReward,
17
+ } from "@cosmjs/stargate";
18
+ import Long from "long";
19
+ import { Coin } from "@keplr-wallet/proto-types/cosmos/base/v1beta1/coin";
20
+ import { PubKey } from "@keplr-wallet/proto-types/cosmos/crypto/secp256k1/keys";
21
+ import {
22
+ AuthInfo,
23
+ TxRaw,
24
+ Fee,
25
+ } from "@keplr-wallet/proto-types/cosmos/tx/v1beta1/tx";
26
+ import { TxBody } from "cosmjs-types/cosmos/tx/v1beta1/tx";
27
+ import { MsgWithdrawDelegatorReward } from "cosmjs-types/cosmos/distribution/v1beta1/tx";
28
+
29
+ type ProtoMsg = {
30
+ typeUrl: string;
31
+ value: Uint8Array;
32
+ };
33
+
34
+ export const buildTransaction = async (
35
+ account: Account,
36
+ transaction: Transaction
37
+ ): Promise<{ aminoMsgs: AminoMsg[]; protoMsgs: ProtoMsg[] }> => {
38
+ const aminoMsgs: Array<AminoMsg> = [];
39
+ const protoMsgs: Array<ProtoMsg> = [];
40
+
41
+ switch (transaction.mode) {
42
+ case "send":
43
+ if (transaction.recipient && transaction.amount.gt(0)) {
44
+ const aminoMsg: AminoMsgSend = {
45
+ type: "cosmos-sdk/MsgSend",
46
+ value: {
47
+ from_address: account.freshAddress,
48
+ to_address: transaction.recipient,
49
+ amount: [
50
+ {
51
+ denom: account.currency.units[1].code,
52
+ amount: transaction.amount.toString(),
53
+ },
54
+ ],
55
+ },
56
+ };
57
+ aminoMsgs.push(aminoMsg);
58
+
59
+ // PROTO MESSAGE
60
+ protoMsgs.push({
61
+ typeUrl: "/cosmos.bank.v1beta1.MsgSend",
62
+ value: cosmos.bank.v1beta1.MsgSend.encode({
63
+ fromAddress: account.freshAddress,
64
+ toAddress: transaction.recipient,
65
+ amount: [
66
+ {
67
+ denom: account.currency.units[1].code,
68
+ amount: transaction.amount.toString(),
69
+ },
70
+ ],
71
+ }).finish(),
72
+ });
73
+ }
74
+ break;
75
+ case "delegate":
76
+ if (transaction.validators && transaction.validators.length > 0) {
77
+ const validator = transaction.validators[0];
78
+ if (validator && validator.address && transaction.amount.gt(0)) {
79
+ //todo this should not be gt0, but the minimum required by osmosis to stake
80
+ const aminoMsg: AminoMsgDelegate = {
81
+ type: "cosmos-sdk/MsgDelegate",
82
+ value: {
83
+ delegator_address: account.freshAddress,
84
+ validator_address: validator.address,
85
+ amount: {
86
+ denom: account.currency.units[1].code,
87
+ amount: transaction.amount.toString(),
88
+ },
89
+ },
90
+ };
91
+ aminoMsgs.push(aminoMsg);
92
+
93
+ // PROTO MESSAGE
94
+ protoMsgs.push({
95
+ typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
96
+ value: MsgDelegate.encode({
97
+ delegatorAddress: account.freshAddress,
98
+ validatorAddress: validator.address,
99
+ amount: {
100
+ denom: account.currency.units[1].code,
101
+ amount: transaction.amount.toString(),
102
+ },
103
+ }).finish(),
104
+ });
105
+ }
106
+ }
107
+ break;
108
+
109
+ case "redelegate":
110
+ if (
111
+ transaction.sourceValidator &&
112
+ transaction.validators &&
113
+ transaction.validators.length > 0 &&
114
+ transaction.validators[0].address &&
115
+ transaction.validators[0].amount.gt(0)
116
+ ) {
117
+ const validator = transaction.validators[0];
118
+ const aminoMsg: AminoMsgBeginRedelegate = {
119
+ type: "cosmos-sdk/MsgBeginRedelegate",
120
+ value: {
121
+ delegator_address: account.freshAddress,
122
+ validator_src_address: transaction.sourceValidator,
123
+ validator_dst_address: validator.address,
124
+ amount: {
125
+ denom: account.currency.units[1].code,
126
+ amount: validator.amount.toString(),
127
+ },
128
+ },
129
+ };
130
+ aminoMsgs.push(aminoMsg);
131
+
132
+ // PROTO MESSAGE
133
+ protoMsgs.push({
134
+ typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate",
135
+ value: MsgBeginRedelegate.encode({
136
+ delegatorAddress: account.freshAddress,
137
+ validatorSrcAddress: transaction.sourceValidator,
138
+ validatorDstAddress: validator.address,
139
+ amount: {
140
+ denom: account.currency.units[1].code,
141
+ amount: validator.amount.toString(),
142
+ },
143
+ }).finish(),
144
+ });
145
+ }
146
+ break;
147
+
148
+ case "undelegate":
149
+ if (transaction.validators && transaction.validators.length > 0) {
150
+ const validator = transaction.validators[0];
151
+ if (validator && validator.address /*&& transaction.amount.gt(0)*/) {
152
+ //todo verify what minimum is required by osmosis to undelegate
153
+ const aminoMsg: AminoMsgUndelegate = {
154
+ type: "cosmos-sdk/MsgUndelegate",
155
+ value: {
156
+ delegator_address: account.freshAddress,
157
+ validator_address: validator.address,
158
+ amount: {
159
+ denom: account.currency.units[1].code,
160
+ amount: validator.amount.toString(),
161
+ },
162
+ },
163
+ };
164
+ aminoMsgs.push(aminoMsg);
165
+
166
+ // PROTO MESSAGE
167
+ protoMsgs.push({
168
+ typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate",
169
+ value: MsgUndelegate.encode({
170
+ delegatorAddress: account.freshAddress,
171
+ validatorAddress: validator.address,
172
+ amount: {
173
+ denom: account.currency.units[1].code,
174
+ amount: validator.amount.toString(),
175
+ },
176
+ }).finish(),
177
+ });
178
+ }
179
+ }
180
+ break;
181
+ case "claimReward":
182
+ if (
183
+ transaction.validators &&
184
+ transaction.validators.length > 0 &&
185
+ transaction.validators[0].address
186
+ ) {
187
+ const validator = transaction.validators[0];
188
+ const aminoMsg: AminoMsgWithdrawDelegatorReward = {
189
+ type: "cosmos-sdk/MsgWithdrawDelegationReward",
190
+ value: {
191
+ delegator_address: account.freshAddress,
192
+ validator_address: validator.address,
193
+ },
194
+ };
195
+ aminoMsgs.push(aminoMsg);
196
+
197
+ // PROTO MESSAGE
198
+ protoMsgs.push({
199
+ typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
200
+ value: MsgWithdrawDelegatorReward.encode({
201
+ delegatorAddress: account.freshAddress,
202
+ validatorAddress: validator.address,
203
+ }).finish(),
204
+ });
205
+ }
206
+ break;
207
+ case "claimRewardCompound":
208
+ if (
209
+ transaction.validators &&
210
+ transaction.validators.length > 0 &&
211
+ transaction.validators[0].address &&
212
+ transaction.validators[0].amount.gt(0)
213
+ ) {
214
+ const validator = transaction.validators[0];
215
+ // AMINO MESSAGES
216
+ const aminoWithdrawRewardMsg: AminoMsgWithdrawDelegatorReward = {
217
+ type: "cosmos-sdk/MsgWithdrawDelegationReward",
218
+ value: {
219
+ delegator_address: account.freshAddress,
220
+ validator_address: validator.address,
221
+ },
222
+ };
223
+ const aminoDelegateMsg: AminoMsgDelegate = {
224
+ type: "cosmos-sdk/MsgDelegate",
225
+ value: {
226
+ delegator_address: account.freshAddress,
227
+ validator_address: validator.address,
228
+ amount: {
229
+ denom: account.currency.units[1].code,
230
+ amount: validator.amount.toString(),
231
+ },
232
+ },
233
+ };
234
+ aminoMsgs.push(aminoWithdrawRewardMsg, aminoDelegateMsg);
235
+
236
+ // PROTO MESSAGES
237
+ protoMsgs.push({
238
+ typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
239
+ value: MsgWithdrawDelegatorReward.encode({
240
+ delegatorAddress: account.freshAddress,
241
+ validatorAddress: validator.address,
242
+ }).finish(),
243
+ });
244
+ protoMsgs.push({
245
+ typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
246
+ value: MsgDelegate.encode({
247
+ delegatorAddress: account.freshAddress,
248
+ validatorAddress: validator.address,
249
+ amount: {
250
+ denom: account.currency.units[1].code,
251
+ amount: validator.amount.toString(),
252
+ },
253
+ }).finish(),
254
+ });
255
+ }
256
+ break;
257
+ }
258
+ return { aminoMsgs, protoMsgs };
259
+ };
260
+
261
+ export const postBuildTransaction = async (
262
+ signResponse: AminoSignResponse,
263
+ protoMsgs: Array<ProtoMsg>
264
+ ): Promise<Uint8Array> => {
265
+ const signed_tx_bytes = TxRaw.encode({
266
+ bodyBytes: TxBody.encode(
267
+ TxBody.fromPartial({
268
+ messages: protoMsgs,
269
+ memo: signResponse.signed.memo,
270
+ timeoutHeight: undefined,
271
+ extensionOptions: [],
272
+ nonCriticalExtensionOptions: [],
273
+ })
274
+ ).finish(),
275
+ authInfoBytes: AuthInfo.encode({
276
+ signerInfos: [
277
+ {
278
+ publicKey: {
279
+ typeUrl: "/cosmos.crypto.secp256k1.PubKey",
280
+ value: PubKey.encode({
281
+ key: Buffer.from(signResponse.signature.pub_key.value, "base64"),
282
+ }).finish(),
283
+ },
284
+ modeInfo: {
285
+ single: {
286
+ mode: SignMode.SIGN_MODE_LEGACY_AMINO_JSON,
287
+ },
288
+ multi: undefined,
289
+ },
290
+ sequence: Long.fromString(signResponse.signed.sequence),
291
+ },
292
+ ],
293
+ fee: Fee.fromPartial({
294
+ amount: signResponse.signed.fee.amount
295
+ ? (signResponse.signed.fee.amount as Coin[])
296
+ : undefined,
297
+ gasLimit: signResponse.signed.fee.gas,
298
+ }),
299
+ }).finish(),
300
+ signatures: [Buffer.from(signResponse.signature.signature, "base64")],
301
+ }).finish();
302
+
303
+ return signed_tx_bytes;
304
+ };
305
+
306
+ export default buildTransaction;
@@ -0,0 +1,26 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import type { AccountLike, Account } from "@ledgerhq/types-live";
3
+ import { getMainAccount } from "../../account";
4
+ import getEstimatedFees from "./js-getFeesForTransaction";
5
+ import { CosmosOperationMode } from "../cosmos/types";
6
+
7
+ /**
8
+ * Returns the maximum possible amount for transaction, considering fees
9
+ *
10
+ * @param {Object} param - account, parentAccount
11
+ */
12
+ const estimateMaxSpendable = async ({
13
+ account,
14
+ parentAccount,
15
+ mode,
16
+ }: {
17
+ account: AccountLike;
18
+ parentAccount: Account | null | undefined;
19
+ mode: CosmosOperationMode;
20
+ }): Promise<BigNumber> => {
21
+ const a = getMainAccount(account, parentAccount);
22
+ const fees = await getEstimatedFees(mode);
23
+ return BigNumber.max(0, a.spendableBalance.minus(fees));
24
+ };
25
+
26
+ export default estimateMaxSpendable;