@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
@@ -31,10 +31,12 @@ const cache = makeBridgeCacheSystem({
31
31
  },
32
32
  });
33
33
  describe("cosmos/react", () => {
34
- describe("useCosmosPreloadData", () => {
34
+ describe("useCosmosFamilyPreloadData", () => {
35
35
  it("should return Cosmos preload data and updates", async () => {
36
36
  const { prepare } = setup();
37
- const { result } = renderHook(() => hooks.useCosmosPreloadData());
37
+ const { result } = renderHook(() =>
38
+ hooks.useCosmosFamilyPreloadData("cosmos")
39
+ );
38
40
  const data = getCurrentCosmosPreloadData();
39
41
  expect(result.current).toStrictEqual(data);
40
42
  await act(() => prepare());
@@ -46,7 +48,7 @@ describe("cosmos/react", () => {
46
48
  const { account, prepare } = setup();
47
49
  await prepare();
48
50
  const { result } = renderHook(() =>
49
- hooks.useCosmosMappedDelegations(account)
51
+ hooks.useCosmosFamilyMappedDelegations(account)
50
52
  );
51
53
  const delegations = account.cosmosResources?.delegations;
52
54
  invariant(delegations, "cosmos: delegations is required");
@@ -72,13 +74,13 @@ describe("cosmos/react", () => {
72
74
  const { account, prepare } = setup();
73
75
  await prepare();
74
76
  const { result } = renderHook(() =>
75
- hooks.useCosmosMappedDelegations(account, "claimReward")
77
+ hooks.useCosmosFamilyMappedDelegations(account, "claimReward")
76
78
  );
77
79
  expect(result.current.length).toBe(3);
78
80
  });
79
81
  });
80
82
  });
81
- describe("useCosmosDelegationsQuerySelector", () => {
83
+ describe("useCosmosFamilyDelegationsQuerySelector", () => {
82
84
  it("should return delegations filtered by query as options", async () => {
83
85
  const { account, transaction, prepare } = setup();
84
86
  await prepare();
@@ -99,7 +101,10 @@ describe("cosmos/react", () => {
99
101
  })),
100
102
  };
101
103
  const { result } = renderHook(() =>
102
- hooks.useCosmosDelegationsQuerySelector(account, newTx as Transaction)
104
+ hooks.useCosmosFamilyDelegationsQuerySelector(
105
+ account,
106
+ newTx as Transaction
107
+ )
103
108
  );
104
109
  expect(result.current.options.length).toBe(delegations.length);
105
110
  act(() => {
@@ -125,7 +130,10 @@ describe("cosmos/react", () => {
125
130
  })),
126
131
  };
127
132
  const { result } = renderHook(() =>
128
- hooks.useCosmosDelegationsQuerySelector(account, newTx as Transaction)
133
+ hooks.useCosmosFamilyDelegationsQuerySelector(
134
+ account,
135
+ newTx as Transaction
136
+ )
129
137
  );
130
138
  expect(
131
139
  (
@@ -134,7 +142,7 @@ describe("cosmos/react", () => {
134
142
  ).validatorAddress
135
143
  ).toBe(delegations[0].validatorAddress);
136
144
  });
137
- it("should find delegation by cosmosSourceValidator field and return as value for redelegate", async () => {
145
+ it("should find delegation by sourceValidator field and return as value for redelegate", async () => {
138
146
  const { account, transaction, prepare } = setup();
139
147
  await prepare();
140
148
  invariant(
@@ -143,7 +151,7 @@ describe("cosmos/react", () => {
143
151
  );
144
152
  const delegations =
145
153
  (account.cosmosResources as CosmosResources).delegations || [];
146
- const cosmosSourceValidator =
154
+ const sourceValidator =
147
155
  delegations[delegations.length - 1].validatorAddress;
148
156
  const newTx = {
149
157
  ...transaction,
@@ -152,17 +160,20 @@ describe("cosmos/react", () => {
152
160
  address: validatorAddress,
153
161
  amount,
154
162
  })),
155
- cosmosSourceValidator,
163
+ sourceValidator,
156
164
  };
157
165
  const { result } = renderHook(() =>
158
- hooks.useCosmosDelegationsQuerySelector(account, newTx as Transaction)
166
+ hooks.useCosmosFamilyDelegationsQuerySelector(
167
+ account,
168
+ newTx as Transaction
169
+ )
159
170
  );
160
171
  expect(
161
172
  (
162
173
  (result.current.value as CosmosMappedDelegation)
163
174
  .validator as CosmosValidatorItem
164
175
  ).validatorAddress
165
- ).toBe(cosmosSourceValidator);
176
+ ).toBe(sourceValidator);
166
177
  });
167
178
  });
168
179
  describe("useSortedValidators", () => {
@@ -170,7 +181,7 @@ describe("cosmos/react", () => {
170
181
  const { account, prepare } = setup();
171
182
  await prepare();
172
183
  const { result: preloadDataResult } = renderHook(() =>
173
- hooks.useCosmosPreloadData()
184
+ hooks.useCosmosFamilyPreloadData("cosmos")
174
185
  );
175
186
  const { validators } = preloadDataResult.current;
176
187
  const delegations = (account.cosmosResources?.delegations || []).map(
@@ -192,7 +203,7 @@ describe("cosmos/react", () => {
192
203
  describe("reorderValidators", () => {
193
204
  it("should return a list of Validators with Ledger first", () => {
194
205
  const { result } = renderHook(() =>
195
- hooks.useLedgerFirstShuffledValidatorsCosmos()
206
+ hooks.useLedgerFirstShuffledValidatorsCosmosFamily("cosmos")
196
207
  );
197
208
  expect(result.current[0].validatorAddress).toBe(LEDGER_VALIDATOR_ADDRESS);
198
209
  });
@@ -25,20 +25,52 @@ import { getAccountUnit } from "../../account";
25
25
  import useMemoOnce from "../../hooks/useMemoOnce";
26
26
  import { LEDGER_VALIDATOR_ADDRESS } from "./utils";
27
27
 
28
- export function useCosmosPreloadData(): CosmosPreloadData {
29
- const [state, setState] = useState(getCurrentCosmosPreloadData);
28
+ // Add Cosmos-families imports below:
29
+ import {
30
+ getCurrentOsmosisPreloadData,
31
+ getOsmosisPreloadDataUpdates,
32
+ } from "../osmosis/preloadedData";
33
+ import { LEDGER_OSMOSIS_VALIDATOR_ADDRESS } from "../osmosis/utils";
34
+
35
+ export function useCosmosFamilyPreloadData(
36
+ currencyName: string
37
+ ): CosmosPreloadData {
38
+ let getCurrent;
39
+ let getUpdates;
40
+
41
+ if (currencyName == "cosmos") {
42
+ getCurrent = getCurrentCosmosPreloadData;
43
+ getUpdates = getCosmosPreloadDataUpdates;
44
+ }
45
+ if (currencyName == "osmosis") {
46
+ getCurrent = getCurrentOsmosisPreloadData;
47
+ getUpdates = getOsmosisPreloadDataUpdates;
48
+ }
49
+
50
+ const [state, setState] = useState(getCurrent);
30
51
  useEffect(() => {
31
- const sub = getCosmosPreloadDataUpdates().subscribe(setState);
52
+ const sub = getUpdates().subscribe(setState);
32
53
  return () => sub.unsubscribe();
33
- }, []);
54
+ }, [getCurrent, getUpdates]);
34
55
  return state;
35
56
  }
36
57
 
37
- export function useCosmosMappedDelegations(
58
+ // export function useCosmosPreloadData(): CosmosPreloadData {
59
+ // const [state, setState] = useState(getCurrentCosmosPreloadData);
60
+ // useEffect(() => {
61
+ // const sub = getCosmosPreloadDataUpdates().subscribe(setState);
62
+ // return () => sub.unsubscribe();
63
+ // }, []);
64
+ // return state;
65
+ // }
66
+
67
+ export function useCosmosFamilyMappedDelegations(
38
68
  account: CosmosAccount,
39
69
  mode?: CosmosOperationMode
40
70
  ): CosmosMappedDelegation[] {
41
- const { validators } = useCosmosPreloadData();
71
+ const currencyName = account.currency.name.toLowerCase();
72
+ const { validators } = useCosmosFamilyPreloadData(currencyName);
73
+
42
74
  const delegations = account.cosmosResources?.delegations;
43
75
  invariant(delegations, "cosmos: delegations is required");
44
76
  const unit = getAccountUnit(account);
@@ -54,7 +86,7 @@ export function useCosmosMappedDelegations(
54
86
  }, [delegations, validators, mode, unit]);
55
87
  }
56
88
 
57
- export function useCosmosDelegationsQuerySelector(
89
+ export function useCosmosFamilyDelegationsQuerySelector(
58
90
  account: CosmosAccount,
59
91
  transaction: Transaction,
60
92
  delegationSearchFilter: CosmosSearchFilter = defaultSearchFilter
@@ -65,7 +97,10 @@ export function useCosmosDelegationsQuerySelector(
65
97
  value: CosmosMappedDelegation | null | undefined;
66
98
  } {
67
99
  const [query, setQuery] = useState<string>("");
68
- const delegations = useCosmosMappedDelegations(account, transaction.mode);
100
+ const delegations = useCosmosFamilyMappedDelegations(
101
+ account,
102
+ transaction.mode
103
+ );
69
104
  const options = useMemo<CosmosMappedDelegation[]>(
70
105
  () => delegations.filter(delegationSearchFilter(query)),
71
106
  [query, delegations, delegationSearchFilter]
@@ -75,12 +110,12 @@ export function useCosmosDelegationsQuerySelector(
75
110
  switch (transaction.mode) {
76
111
  case "redelegate":
77
112
  invariant(
78
- transaction.cosmosSourceValidator,
79
- "cosmos: cosmosSourceValidator is required"
113
+ transaction.sourceValidator,
114
+ "cosmos: sourceValidator is required"
80
115
  );
81
116
  return options.find(
82
117
  ({ validatorAddress }) =>
83
- validatorAddress === transaction.cosmosSourceValidator
118
+ validatorAddress === transaction.sourceValidator
84
119
  );
85
120
 
86
121
  default:
@@ -143,6 +178,7 @@ export function useSortedValidators(
143
178
  return sr;
144
179
  }
145
180
 
181
+ // Nothing using this function?
146
182
  export function useMappedExtraOperationDetails({
147
183
  account,
148
184
  extra,
@@ -150,7 +186,7 @@ export function useMappedExtraOperationDetails({
150
186
  account: CosmosAccount;
151
187
  extra: CosmosExtraTxInfo;
152
188
  }): CosmosExtraTxInfo {
153
- const { validators } = useCosmosPreloadData();
189
+ const { validators } = useCosmosFamilyPreloadData("cosmos");
154
190
  const unit = getAccountUnit(account);
155
191
  return {
156
192
  validators: extra.validators
@@ -159,24 +195,40 @@ export function useMappedExtraOperationDetails({
159
195
  validator: extra.validator
160
196
  ? mapDelegationInfo([extra.validator], validators, unit)[0]
161
197
  : undefined,
162
- cosmosSourceValidator: extra.cosmosSourceValidator
163
- ? extra.cosmosSourceValidator
164
- : undefined,
198
+ sourceValidator: extra.sourceValidator ? extra.sourceValidator : undefined,
199
+ autoClaimedRewards:
200
+ extra.autoClaimedRewards != null
201
+ ? extra.autoClaimedRewards
202
+ : "empty string",
165
203
  };
166
204
  }
167
205
 
168
- export function useLedgerFirstShuffledValidatorsCosmos(
206
+ export function useLedgerFirstShuffledValidatorsCosmosFamily(
207
+ currencyName: string,
169
208
  searchInput?: string
170
209
  ): CosmosValidatorItem[] {
171
- const data = useCosmosPreloadData();
210
+ let data;
211
+ let ledgerValidatorAddress;
212
+ if (currencyName == "osmosis") {
213
+ data = getCurrentOsmosisPreloadData();
214
+ ledgerValidatorAddress = LEDGER_OSMOSIS_VALIDATOR_ADDRESS;
215
+ } else {
216
+ data = getCurrentCosmosPreloadData();
217
+ ledgerValidatorAddress = LEDGER_VALIDATOR_ADDRESS;
218
+ }
172
219
 
173
220
  return useMemo(() => {
174
- return reorderValidators(data?.validators ?? [], searchInput);
175
- }, [data, searchInput]);
221
+ return reorderValidators(
222
+ data?.validators ?? [],
223
+ ledgerValidatorAddress,
224
+ searchInput
225
+ );
226
+ }, [data, ledgerValidatorAddress, searchInput]);
176
227
  }
177
228
 
178
229
  function reorderValidators(
179
230
  validators: CosmosValidatorItem[],
231
+ ledgerValidatorAddress: string,
180
232
  searchInput?: string
181
233
  ): CosmosValidatorItem[] {
182
234
  const sortedValidators = validators
@@ -190,12 +242,12 @@ function reorderValidators(
190
242
 
191
243
  // move Ledger validator to the first position
192
244
  const ledgerValidator = sortedValidators.find(
193
- (v) => v.validatorAddress === LEDGER_VALIDATOR_ADDRESS
245
+ (v) => v.validatorAddress === ledgerValidatorAddress
194
246
  );
195
247
 
196
248
  if (ledgerValidator) {
197
249
  const sortedValidatorsLedgerFirst = sortedValidators.filter(
198
- (v) => v.validatorAddress !== LEDGER_VALIDATOR_ADDRESS
250
+ (v) => v.validatorAddress !== ledgerValidatorAddress
199
251
  );
200
252
  sortedValidatorsLedgerFirst.unshift(ledgerValidator);
201
253
 
@@ -308,7 +308,7 @@ const cosmos: AppSpec<Transaction> = {
308
308
  {
309
309
  mode: "redelegate",
310
310
  memo: "LedgerLiveBot",
311
- cosmosSourceValidator: (sourceDelegation as CosmosDelegation)
311
+ sourceValidator: (sourceDelegation as CosmosDelegation)
312
312
  .validatorAddress,
313
313
  validators: [
314
314
  {
@@ -341,7 +341,7 @@ const cosmos: AppSpec<Transaction> = {
341
341
  .find(
342
342
  (d) =>
343
343
  d.validatorDstAddress === v.address &&
344
- d.validatorSrcAddress === transaction.cosmosSourceValidator
344
+ d.validatorSrcAddress === transaction.sourceValidator
345
345
  );
346
346
  invariant(d, "redelegated %s must be found in account", v.address);
347
347
  expect({
@@ -31,8 +31,7 @@ const acceptTransaction: DeviceAction<Transaction, any> = deviceActionFlow({
31
31
  {
32
32
  title: "Validator Source",
33
33
  button: "Rr",
34
- expectedValue: ({ transaction }) =>
35
- transaction.cosmosSourceValidator || "",
34
+ expectedValue: ({ transaction }) => transaction.sourceValidator || "",
36
35
  },
37
36
  {
38
37
  title: "Validator Dest",
@@ -19,7 +19,7 @@ export const formatTransaction = (
19
19
  recipient,
20
20
  validators,
21
21
  memo,
22
- cosmosSourceValidator,
22
+ sourceValidator,
23
23
  useAllAmount,
24
24
  }: Transaction,
25
25
  account: Account
@@ -50,9 +50,7 @@ ${
50
50
  v.address
51
51
  )
52
52
  .join("\n")
53
- }${
54
- !cosmosSourceValidator ? "" : "\n source validator=" + cosmosSourceValidator
55
- }
53
+ }${!sourceValidator ? "" : "\n source validator=" + sourceValidator}
56
54
  with fees=${fees ? formatCurrencyUnit(getAccountUnit(account), fees) : "?"}${
57
55
  !memo ? "" : `\n memo=${memo}`
58
56
  }`;
@@ -71,7 +69,7 @@ export const fromTransactionRaw = (tr: TransactionRaw): Transaction => {
71
69
  fees: tr.fees ? new BigNumber(tr.fees) : null,
72
70
  gas: tr.gas ? new BigNumber(tr.gas) : null,
73
71
  memo: tr.memo,
74
- cosmosSourceValidator: tr.cosmosSourceValidator,
72
+ sourceValidator: tr.sourceValidator,
75
73
  validators: tr.validators
76
74
  ? tr.validators.map((v) => ({ ...v, amount: new BigNumber(v.amount) }))
77
75
  : [],
@@ -92,7 +90,7 @@ export const toTransactionRaw = (t: Transaction): TransactionRaw => {
92
90
  fees: t.fees ? t.fees.toString() : null,
93
91
  gas: t.gas ? t.gas.toString() : null,
94
92
  memo: t.memo,
95
- cosmosSourceValidator: t.cosmosSourceValidator,
93
+ sourceValidator: t.sourceValidator,
96
94
  validators: t.validators
97
95
  ? t.validators.map((v) => ({ ...v, amount: v.amount.toString() }))
98
96
  : [],
@@ -102,14 +102,25 @@ export type CosmosOperationMode =
102
102
  | "redelegate"
103
103
  | "claimReward"
104
104
  | "claimRewardCompound";
105
- export type NetworkInfo = {
106
- family: "cosmos";
105
+
106
+ export type CosmosLikeNetworkInfo = {
107
+ family: string;
107
108
  fees: BigNumber;
108
109
  };
109
- export type NetworkInfoRaw = {
110
- family: "cosmos";
110
+
111
+ export type CosmosLikeNetworkInfoRaw = {
112
+ family: string;
111
113
  fees: string;
112
114
  };
115
+
116
+ export type NetworkInfo = CosmosLikeNetworkInfo & {
117
+ family: "cosmos";
118
+ };
119
+
120
+ export type NetworkInfoRaw = CosmosLikeNetworkInfoRaw & {
121
+ family: "cosmos";
122
+ };
123
+
113
124
  export type CosmosOperation = Operation & {
114
125
  extra: CosmosExtraTxInfo;
115
126
  };
@@ -118,38 +129,55 @@ export type CosmosOperationRaw = OperationRaw & {
118
129
  };
119
130
  export type CosmosExtraTxInfo = {
120
131
  validators?: CosmosDelegationInfo[];
121
- cosmosSourceValidator?: string | null | undefined;
132
+ sourceValidator?: string | null | undefined;
122
133
  validator?: CosmosDelegationInfo;
134
+ autoClaimedRewards?: string | null | undefined; // this is experimental to better represent auto claimed rewards
123
135
  };
124
136
 
125
137
  export type CosmosDelegationInfo = {
126
138
  address: string;
127
139
  amount: BigNumber;
128
140
  };
141
+
129
142
  export type CosmosDelegationInfoRaw = {
130
143
  address: string;
131
144
  amount: string;
132
145
  };
133
146
 
134
- export type Transaction = TransactionCommon & {
135
- family: "cosmos";
147
+ export type CosmosClaimedRewardInfo = {
148
+ amount: BigNumber;
149
+ };
150
+
151
+ export type CosmosLikeTransaction = TransactionCommon & {
152
+ family: string;
136
153
  mode: CosmosOperationMode;
137
- networkInfo: NetworkInfo | null | undefined;
154
+ networkInfo: CosmosLikeNetworkInfo | null | undefined;
138
155
  fees: BigNumber | null | undefined;
139
156
  gas: BigNumber | null | undefined;
140
157
  memo: string | null | undefined;
141
158
  validators: CosmosDelegationInfo[];
142
- cosmosSourceValidator: string | null | undefined;
159
+ sourceValidator: string | null | undefined;
143
160
  };
144
- export type TransactionRaw = TransactionCommonRaw & {
145
- family: "cosmos";
161
+
162
+ export type Transaction = CosmosLikeTransaction & {
163
+ family: "cosmos" | "osmosis";
164
+ networkInfo: NetworkInfo | null | undefined;
165
+ };
166
+
167
+ export type CosmosLikeTransactionRaw = TransactionCommonRaw & {
168
+ family: string;
146
169
  mode: CosmosOperationMode;
147
- networkInfo: NetworkInfoRaw | null | undefined;
170
+ networkInfo: CosmosLikeNetworkInfoRaw | null | undefined;
148
171
  fees: string | null | undefined;
149
172
  gas: string | null | undefined;
150
173
  memo: string | null | undefined;
151
174
  validators: CosmosDelegationInfoRaw[];
152
- cosmosSourceValidator: string | null | undefined;
175
+ sourceValidator: string | null | undefined;
176
+ };
177
+
178
+ export type TransactionRaw = CosmosLikeTransactionRaw & {
179
+ family: "cosmos" | "osmosis";
180
+ networkInfo: NetworkInfoRaw | null | undefined;
153
181
  };
154
182
 
155
183
  export type StatusErrorMap = {
@@ -1,2 +1,10 @@
1
+ // Import here other Cosmos-based Ledger Validators
2
+ import { LEDGER_OSMOSIS_VALIDATOR_ADDRESS } from "../osmosis/utils";
3
+
1
4
  export const LEDGER_VALIDATOR_ADDRESS =
2
5
  "cosmosvaloper10wljxpl03053h9690apmyeakly3ylhejrucvtm";
6
+
7
+ export const COSMOS_FAMILY_LEDGER_VALIDATOR_ADDRESSES = [
8
+ LEDGER_VALIDATOR_ADDRESS,
9
+ LEDGER_OSMOSIS_VALIDATOR_ADDRESS,
10
+ ];