@ledgerhq/live-common 27.2.0 → 27.3.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/lib/apps/logic.test.js +1 -1
  2. package/lib/apps/logic.test.js.map +1 -1
  3. package/lib/apps/polyfill.d.ts +1 -1
  4. package/lib/apps/polyfill.d.ts.map +1 -1
  5. package/lib/apps/polyfill.js +6 -3
  6. package/lib/apps/polyfill.js.map +1 -1
  7. package/lib/apps/polyfill.test.d.ts +2 -0
  8. package/lib/apps/polyfill.test.d.ts.map +1 -0
  9. package/lib/apps/polyfill.test.js +25 -0
  10. package/lib/apps/polyfill.test.js.map +1 -0
  11. package/lib/apps/support.d.ts.map +1 -1
  12. package/lib/apps/support.js +3 -2
  13. package/lib/apps/support.js.map +1 -1
  14. package/lib/bot/engine.d.ts.map +1 -1
  15. package/lib/bot/engine.js +154 -45
  16. package/lib/bot/engine.js.map +1 -1
  17. package/lib/bot/formatters.d.ts +1 -1
  18. package/lib/bot/formatters.d.ts.map +1 -1
  19. package/lib/bot/formatters.js +9 -3
  20. package/lib/bot/formatters.js.map +1 -1
  21. package/lib/bot/index.d.ts.map +1 -1
  22. package/lib/bot/index.js +29 -11
  23. package/lib/bot/index.js.map +1 -1
  24. package/lib/bot/specs.d.ts +12 -1
  25. package/lib/bot/specs.d.ts.map +1 -1
  26. package/lib/bot/specs.js +75 -1
  27. package/lib/bot/specs.js.map +1 -1
  28. package/lib/bot/types.d.ts +18 -1
  29. package/lib/bot/types.d.ts.map +1 -1
  30. package/lib/currencies/sortByMarketcap.d.ts.map +1 -1
  31. package/lib/currencies/sortByMarketcap.js +5 -1
  32. package/lib/currencies/sortByMarketcap.js.map +1 -1
  33. package/lib/currencies/support.d.ts.map +1 -1
  34. package/lib/currencies/support.js +2 -1
  35. package/lib/currencies/support.js.map +1 -1
  36. package/lib/derivation.d.ts.map +1 -1
  37. package/lib/derivation.js +2 -4
  38. package/lib/derivation.js.map +1 -1
  39. package/lib/env.js +1 -1
  40. package/lib/exchange/swap/getExchangeRates.d.ts.map +1 -1
  41. package/lib/exchange/swap/getExchangeRates.js +6 -3
  42. package/lib/exchange/swap/getExchangeRates.js.map +1 -1
  43. package/lib/exchange/swap/getProviders.d.ts.map +1 -1
  44. package/lib/exchange/swap/getProviders.js +45 -5
  45. package/lib/exchange/swap/getProviders.js.map +1 -1
  46. package/lib/exchange/swap/getProviders.test.d.ts +2 -0
  47. package/lib/exchange/swap/getProviders.test.d.ts.map +1 -0
  48. package/lib/exchange/swap/getProviders.test.js +519 -0
  49. package/lib/exchange/swap/getProviders.test.js.map +1 -0
  50. package/lib/exchange/swap/hooks/useProviderRates.d.ts +1 -0
  51. package/lib/exchange/swap/hooks/useProviderRates.d.ts.map +1 -1
  52. package/lib/exchange/swap/hooks/useProviderRates.js +19 -4
  53. package/lib/exchange/swap/hooks/useProviderRates.js.map +1 -1
  54. package/lib/exchange/swap/hooks/useProviderRates.test.js +42 -0
  55. package/lib/exchange/swap/hooks/useProviderRates.test.js.map +1 -1
  56. package/lib/exchange/swap/hooks/useSwapTransaction.d.ts +1 -0
  57. package/lib/exchange/swap/hooks/useSwapTransaction.d.ts.map +1 -1
  58. package/lib/exchange/swap/hooks/useSwapTransaction.js +2 -1
  59. package/lib/exchange/swap/hooks/useSwapTransaction.js.map +1 -1
  60. package/lib/exchange/swap/index.d.ts +2 -1
  61. package/lib/exchange/swap/index.d.ts.map +1 -1
  62. package/lib/exchange/swap/index.js +11 -1
  63. package/lib/exchange/swap/index.js.map +1 -1
  64. package/lib/exchange/swap/index.test.js +22 -0
  65. package/lib/exchange/swap/index.test.js.map +1 -1
  66. package/lib/exchange/swap/mock.js +1 -1
  67. package/lib/exchange/swap/mock.js.map +1 -1
  68. package/lib/exchange/swap/types.d.ts +14 -0
  69. package/lib/exchange/swap/types.d.ts.map +1 -1
  70. package/lib/exchange/swap/utils/index.d.ts +1 -0
  71. package/lib/exchange/swap/utils/index.d.ts.map +1 -1
  72. package/lib/exchange/swap/utils/index.js +6 -1
  73. package/lib/exchange/swap/utils/index.js.map +1 -1
  74. package/lib/exchange/swap/utils/index.test.js +12 -0
  75. package/lib/exchange/swap/utils/index.test.js.map +1 -1
  76. package/lib/families/algorand/specs.d.ts.map +1 -1
  77. package/lib/families/algorand/specs.js +2 -0
  78. package/lib/families/algorand/specs.js.map +1 -1
  79. package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
  80. package/lib/families/algorand/speculos-deviceActions.js +2 -29
  81. package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
  82. package/lib/families/bitcoin/specs.d.ts +0 -1
  83. package/lib/families/bitcoin/specs.d.ts.map +1 -1
  84. package/lib/families/bitcoin/specs.js +65 -48
  85. package/lib/families/bitcoin/specs.js.map +1 -1
  86. package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
  87. package/lib/families/bitcoin/speculos-deviceActions.js +2 -22
  88. package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
  89. package/lib/families/cardano/specs.d.ts.map +1 -1
  90. package/lib/families/cardano/specs.js +9 -4
  91. package/lib/families/cardano/specs.js.map +1 -1
  92. package/lib/families/cardano/speculos-deviceActions.d.ts.map +1 -1
  93. package/lib/families/cardano/speculos-deviceActions.js +2 -10
  94. package/lib/families/cardano/speculos-deviceActions.js.map +1 -1
  95. package/lib/families/celo/specs/createSendMutation.d.ts +1 -0
  96. package/lib/families/celo/specs/createSendMutation.d.ts.map +1 -1
  97. package/lib/families/celo/specs/createSendMutation.js +7 -5
  98. package/lib/families/celo/specs/createSendMutation.js.map +1 -1
  99. package/lib/families/celo/specs.d.ts.map +1 -1
  100. package/lib/families/celo/specs.js +1 -0
  101. package/lib/families/celo/specs.js.map +1 -1
  102. package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -1
  103. package/lib/families/celo/speculos-deviceActions.js +3 -10
  104. package/lib/families/celo/speculos-deviceActions.js.map +1 -1
  105. package/lib/families/cosmos/helpers.d.ts +9 -0
  106. package/lib/families/cosmos/helpers.d.ts.map +1 -0
  107. package/lib/families/cosmos/helpers.js +20 -0
  108. package/lib/families/cosmos/helpers.js.map +1 -0
  109. package/lib/families/cosmos/helpers.unit.test.d.ts +2 -0
  110. package/lib/families/cosmos/helpers.unit.test.d.ts.map +1 -0
  111. package/lib/families/cosmos/helpers.unit.test.js +56 -0
  112. package/lib/families/cosmos/helpers.unit.test.js.map +1 -0
  113. package/lib/families/cosmos/js-signOperation.d.ts.map +1 -1
  114. package/lib/families/cosmos/js-signOperation.js +5 -3
  115. package/lib/families/cosmos/js-signOperation.js.map +1 -1
  116. package/lib/families/cosmos/js-synchronisation.d.ts.map +1 -1
  117. package/lib/families/cosmos/js-synchronisation.js +99 -95
  118. package/lib/families/cosmos/js-synchronisation.js.map +1 -1
  119. package/lib/families/cosmos/specs.d.ts.map +1 -1
  120. package/lib/families/cosmos/specs.js +5 -1
  121. package/lib/families/cosmos/specs.js.map +1 -1
  122. package/lib/families/crypto_org/specs.d.ts.map +1 -1
  123. package/lib/families/crypto_org/specs.js +9 -8
  124. package/lib/families/crypto_org/specs.js.map +1 -1
  125. package/lib/families/elrond/specs.d.ts.map +1 -1
  126. package/lib/families/elrond/specs.js +1 -0
  127. package/lib/families/elrond/specs.js.map +1 -1
  128. package/lib/families/elrond/speculos-deviceActions.d.ts.map +1 -1
  129. package/lib/families/elrond/speculos-deviceActions.js +3 -8
  130. package/lib/families/elrond/speculos-deviceActions.js.map +1 -1
  131. package/lib/families/ethereum/specs.d.ts.map +1 -1
  132. package/lib/families/ethereum/specs.js +20 -8
  133. package/lib/families/ethereum/specs.js.map +1 -1
  134. package/lib/families/ethereum/speculos-deviceActions.d.ts.map +1 -1
  135. package/lib/families/ethereum/speculos-deviceActions.js +10 -33
  136. package/lib/families/ethereum/speculos-deviceActions.js.map +1 -1
  137. package/lib/families/evm/specs.d.ts.map +1 -1
  138. package/lib/families/evm/specs.js +20 -10
  139. package/lib/families/evm/specs.js.map +1 -1
  140. package/lib/families/evm/speculos-deviceActions.d.ts.map +1 -1
  141. package/lib/families/evm/speculos-deviceActions.js +5 -25
  142. package/lib/families/evm/speculos-deviceActions.js.map +1 -1
  143. package/lib/families/filecoin/specs.d.ts.map +1 -1
  144. package/lib/families/filecoin/specs.js +3 -0
  145. package/lib/families/filecoin/specs.js.map +1 -1
  146. package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
  147. package/lib/families/filecoin/speculos-deviceActions.js +6 -7
  148. package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
  149. package/lib/families/hedera/specs.d.ts.map +1 -1
  150. package/lib/families/hedera/specs.js +2 -0
  151. package/lib/families/hedera/specs.js.map +1 -1
  152. package/lib/families/osmosis/specs.d.ts.map +1 -1
  153. package/lib/families/osmosis/specs.js +3 -0
  154. package/lib/families/osmosis/specs.js.map +1 -1
  155. package/lib/families/polkadot/specs.d.ts.map +1 -1
  156. package/lib/families/polkadot/specs.js +4 -1
  157. package/lib/families/polkadot/specs.js.map +1 -1
  158. package/lib/families/polkadot/speculos-deviceActions.d.ts.map +1 -1
  159. package/lib/families/polkadot/speculos-deviceActions.js +3 -10
  160. package/lib/families/polkadot/speculos-deviceActions.js.map +1 -1
  161. package/lib/families/ripple/specs.d.ts.map +1 -1
  162. package/lib/families/ripple/specs.js +2 -0
  163. package/lib/families/ripple/specs.js.map +1 -1
  164. package/lib/families/ripple/speculos-deviceActions.d.ts.map +1 -1
  165. package/lib/families/ripple/speculos-deviceActions.js +2 -22
  166. package/lib/families/ripple/speculos-deviceActions.js.map +1 -1
  167. package/lib/families/solana/specs.d.ts.map +1 -1
  168. package/lib/families/solana/specs.js +7 -3
  169. package/lib/families/solana/specs.js.map +1 -1
  170. package/lib/families/solana/speculos-deviceActions.d.ts.map +1 -1
  171. package/lib/families/solana/speculos-deviceActions.js +5 -7
  172. package/lib/families/solana/speculos-deviceActions.js.map +1 -1
  173. package/lib/families/stellar/specs.d.ts.map +1 -1
  174. package/lib/families/stellar/specs.js +1 -0
  175. package/lib/families/stellar/specs.js.map +1 -1
  176. package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
  177. package/lib/families/stellar/speculos-deviceActions.js +4 -8
  178. package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
  179. package/lib/families/tezos/specs.d.ts.map +1 -1
  180. package/lib/families/tezos/specs.js +6 -1
  181. package/lib/families/tezos/specs.js.map +1 -1
  182. package/lib/families/tezos/speculos-deviceActions.d.ts.map +1 -1
  183. package/lib/families/tezos/speculos-deviceActions.js +6 -11
  184. package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
  185. package/lib/families/tron/specs.d.ts.map +1 -1
  186. package/lib/families/tron/specs.js +16 -1
  187. package/lib/families/tron/specs.js.map +1 -1
  188. package/lib/families/tron/speculos-deviceActions.d.ts.map +1 -1
  189. package/lib/families/tron/speculos-deviceActions.js +2 -14
  190. package/lib/families/tron/speculos-deviceActions.js.map +1 -1
  191. package/lib/families/tron/synchronisation.integration.test.d.ts +2 -0
  192. package/lib/families/tron/synchronisation.integration.test.d.ts.map +1 -0
  193. package/lib/families/tron/{synchronisation.test.js → synchronisation.integration.test.js} +1 -1
  194. package/lib/families/tron/synchronisation.integration.test.js.map +1 -0
  195. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  196. package/lib/featureFlags/defaultFeatures.js +6 -0
  197. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  198. package/lib/generated/specs.d.ts +0 -1
  199. package/lib/generated/specs.d.ts.map +1 -1
  200. package/lib/hw/actions/installLanguage.js +1 -1
  201. package/lib/hw/extractOnboardingState.d.ts +5 -1
  202. package/lib/hw/extractOnboardingState.d.ts.map +1 -1
  203. package/lib/hw/extractOnboardingState.js +17 -9
  204. package/lib/hw/extractOnboardingState.js.map +1 -1
  205. package/lib/hw/extractOnboardingState.test.js +21 -11
  206. package/lib/hw/extractOnboardingState.test.js.map +1 -1
  207. package/lib/load/speculos.d.ts.map +1 -1
  208. package/lib/load/speculos.js +39 -15
  209. package/lib/load/speculos.js.map +1 -1
  210. package/lib/manager/hooks.d.ts +4 -1
  211. package/lib/manager/hooks.d.ts.map +1 -1
  212. package/lib/manager/hooks.js +4 -3
  213. package/lib/manager/hooks.js.map +1 -1
  214. package/lib/manager/localization.js +2 -2
  215. package/lib/manager/localization.js.map +1 -1
  216. package/lib/mock/account.d.ts.map +1 -1
  217. package/lib/mock/account.js +17 -19
  218. package/lib/mock/account.js.map +1 -1
  219. package/lib/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
  220. package/lib/notifications/ServiceStatusProvider/index.js +5 -1
  221. package/lib/notifications/ServiceStatusProvider/index.js.map +1 -1
  222. package/lib/postOnboarding/PostOnboardingProvider.d.ts +20 -0
  223. package/lib/postOnboarding/PostOnboardingProvider.d.ts.map +1 -0
  224. package/lib/postOnboarding/PostOnboardingProvider.js +33 -0
  225. package/lib/postOnboarding/PostOnboardingProvider.js.map +1 -0
  226. package/lib/postOnboarding/actions.d.ts +20 -0
  227. package/lib/postOnboarding/actions.d.ts.map +1 -0
  228. package/lib/postOnboarding/actions.js +37 -0
  229. package/lib/postOnboarding/actions.js.map +1 -0
  230. package/lib/postOnboarding/hooks/index.d.ts +6 -0
  231. package/lib/postOnboarding/hooks/index.d.ts.map +1 -0
  232. package/lib/postOnboarding/hooks/index.js +22 -0
  233. package/lib/postOnboarding/hooks/index.js.map +1 -0
  234. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.d.ts +8 -0
  235. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.d.ts.map +1 -0
  236. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.js +16 -0
  237. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.js.map +1 -0
  238. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.d.ts +2 -0
  239. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.d.ts.map +1 -0
  240. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.js +75 -0
  241. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.js.map +1 -0
  242. package/lib/postOnboarding/hooks/usePostOnboardingContext.d.ts +3 -0
  243. package/lib/postOnboarding/hooks/usePostOnboardingContext.d.ts.map +1 -0
  244. package/lib/postOnboarding/hooks/usePostOnboardingContext.js +10 -0
  245. package/lib/postOnboarding/hooks/usePostOnboardingContext.js.map +1 -0
  246. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.d.ts +8 -0
  247. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.d.ts.map +1 -0
  248. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.js +20 -0
  249. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.js.map +1 -0
  250. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.d.ts +2 -0
  251. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.d.ts.map +1 -0
  252. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.js +64 -0
  253. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.js.map +1 -0
  254. package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts +12 -0
  255. package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts.map +1 -0
  256. package/lib/postOnboarding/hooks/usePostOnboardingHubState.js +65 -0
  257. package/lib/postOnboarding/hooks/usePostOnboardingHubState.js.map +1 -0
  258. package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.d.ts +2 -0
  259. package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.d.ts.map +1 -0
  260. package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.js +129 -0
  261. package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.js.map +1 -0
  262. package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.d.ts +13 -0
  263. package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.d.ts.map +1 -0
  264. package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.js +34 -0
  265. package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.js.map +1 -0
  266. package/lib/postOnboarding/mock.d.ts +8 -0
  267. package/lib/postOnboarding/mock.d.ts.map +1 -0
  268. package/lib/postOnboarding/mock.js +46 -0
  269. package/lib/postOnboarding/mock.js.map +1 -0
  270. package/lib/postOnboarding/reducer.d.ts +22 -0
  271. package/lib/postOnboarding/reducer.d.ts.map +1 -0
  272. package/lib/postOnboarding/reducer.js +71 -0
  273. package/lib/postOnboarding/reducer.js.map +1 -0
  274. package/lib/postOnboarding/reducer.test.d.ts +2 -0
  275. package/lib/postOnboarding/reducer.test.d.ts.map +1 -0
  276. package/lib/postOnboarding/reducer.test.js +251 -0
  277. package/lib/postOnboarding/reducer.test.js.map +1 -0
  278. package/package.json +24 -20
  279. package/src/__tests__/__snapshots__/portfolio.v2.ts.snap +16 -0
  280. package/src/apps/__snapshots__/logic.test.ts.snap +18 -11
  281. package/src/apps/logic.test.ts +1 -2
  282. package/src/apps/polyfill.test.ts +24 -0
  283. package/src/apps/polyfill.ts +7 -2
  284. package/src/apps/support.ts +2 -1
  285. package/src/bot/engine.ts +178 -35
  286. package/src/bot/formatters.ts +15 -2
  287. package/src/bot/index.ts +48 -19
  288. package/src/bot/specs.ts +95 -1
  289. package/src/bot/types.ts +23 -1
  290. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +55 -6
  291. package/src/currencies/sortByMarketcap.ts +6 -1
  292. package/src/currencies/support.ts +2 -1
  293. package/src/derivation.ts +2 -4
  294. package/src/env.ts +1 -1
  295. package/src/exchange/swap/getExchangeRates.ts +12 -5
  296. package/src/exchange/swap/getProviders.test.ts +450 -0
  297. package/src/exchange/swap/getProviders.ts +31 -8
  298. package/src/exchange/swap/hooks/useProviderRates.test.ts +43 -0
  299. package/src/exchange/swap/hooks/useProviderRates.ts +22 -3
  300. package/src/exchange/swap/hooks/useSwapTransaction.ts +3 -1
  301. package/src/exchange/swap/index.test.ts +36 -1
  302. package/src/exchange/swap/index.ts +15 -0
  303. package/src/exchange/swap/mock.ts +2 -2
  304. package/src/exchange/swap/types.ts +11 -0
  305. package/src/exchange/swap/utils/index.test.ts +19 -0
  306. package/src/exchange/swap/utils/index.ts +5 -0
  307. package/src/families/algorand/specs.ts +3 -1
  308. package/src/families/algorand/speculos-deviceActions.ts +4 -35
  309. package/src/families/bitcoin/specs.ts +72 -56
  310. package/src/families/bitcoin/speculos-deviceActions.ts +3 -26
  311. package/src/families/cardano/specs.ts +9 -4
  312. package/src/families/cardano/speculos-deviceActions.ts +3 -14
  313. package/src/families/celo/specs/createSendMutation.ts +5 -3
  314. package/src/families/celo/specs.ts +2 -0
  315. package/src/families/celo/speculos-deviceActions.ts +6 -14
  316. package/src/families/cosmos/__snapshots__/bridge.integration.test.ts.snap +24 -44
  317. package/src/families/cosmos/helpers.ts +21 -0
  318. package/src/families/cosmos/helpers.unit.test.ts +63 -0
  319. package/src/families/cosmos/js-signOperation.ts +6 -3
  320. package/src/families/cosmos/js-synchronisation.ts +120 -119
  321. package/src/families/cosmos/specs.ts +11 -2
  322. package/src/families/crypto_org/specs.ts +12 -19
  323. package/src/families/elrond/specs.ts +1 -0
  324. package/src/families/elrond/speculos-deviceActions.ts +4 -9
  325. package/src/families/ethereum/specs.ts +34 -38
  326. package/src/families/ethereum/speculos-deviceActions.ts +16 -46
  327. package/src/families/evm/specs.ts +18 -8
  328. package/src/families/evm/speculos-deviceActions.ts +7 -35
  329. package/src/families/filecoin/specs.ts +4 -1
  330. package/src/families/filecoin/speculos-deviceActions.ts +7 -8
  331. package/src/families/hedera/specs.ts +3 -1
  332. package/src/families/osmosis/specs.ts +4 -1
  333. package/src/families/polkadot/specs.ts +11 -2
  334. package/src/families/polkadot/speculos-deviceActions.ts +5 -16
  335. package/src/families/ripple/specs.ts +3 -1
  336. package/src/families/ripple/speculos-deviceActions.ts +3 -28
  337. package/src/families/solana/specs.ts +15 -4
  338. package/src/families/solana/speculos-deviceActions.ts +6 -8
  339. package/src/families/stellar/specs.ts +1 -0
  340. package/src/families/stellar/speculos-deviceActions.ts +5 -11
  341. package/src/families/tezos/specs.ts +7 -5
  342. package/src/families/tezos/speculos-deviceActions.ts +9 -16
  343. package/src/families/tron/specs.ts +31 -3
  344. package/src/families/tron/speculos-deviceActions.ts +4 -12
  345. package/src/families/tron/{synchronisation.test.ts → synchronisation.integration.test.ts} +0 -0
  346. package/src/featureFlags/defaultFeatures.ts +6 -0
  347. package/src/hw/actions/installLanguage.ts +1 -1
  348. package/src/hw/extractOnboardingState.test.ts +29 -12
  349. package/src/hw/extractOnboardingState.ts +17 -9
  350. package/src/load/speculos.ts +42 -21
  351. package/src/manager/hooks.ts +6 -6
  352. package/src/manager/localization.ts +2 -2
  353. package/src/mock/account.ts +18 -20
  354. package/src/notifications/ServiceStatusProvider/index.tsx +8 -1
  355. package/src/postOnboarding/PostOnboardingProvider.tsx +49 -0
  356. package/src/postOnboarding/actions.ts +40 -0
  357. package/src/postOnboarding/hooks/index.ts +5 -0
  358. package/src/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.ts +82 -0
  359. package/src/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.ts +12 -0
  360. package/src/postOnboarding/hooks/usePostOnboardingContext.ts +9 -0
  361. package/src/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.ts +83 -0
  362. package/src/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.ts +22 -0
  363. package/src/postOnboarding/hooks/usePostOnboardingHubState.test.ts +184 -0
  364. package/src/postOnboarding/hooks/usePostOnboardingHubState.ts +56 -0
  365. package/src/postOnboarding/hooks/useStartPostOnboardingCallback.ts +38 -0
  366. package/src/postOnboarding/mock.ts +53 -0
  367. package/src/postOnboarding/reducer.test.ts +247 -0
  368. package/src/postOnboarding/reducer.ts +105 -0
  369. package/lib/families/tron/synchronisation.test.d.ts +0 -2
  370. package/lib/families/tron/synchronisation.test.d.ts.map +0 -1
  371. package/lib/families/tron/synchronisation.test.js.map +0 -1
@@ -1,16 +1,17 @@
1
1
  import invariant from "invariant";
2
2
  import { getCryptoCurrencyById, parseCurrencyUnit } from "../../../currencies";
3
- import { pickSiblings } from "../../../bot/specs";
3
+ import { genericTestDestination, pickSiblings } from "../../../bot/specs";
4
4
  import { MutationSpec } from "../../../bot/types";
5
5
  import type { Transaction } from "../types";
6
6
 
7
- const maxAccount = 3;
7
+ const maxAccount = 10;
8
8
  const currency = getCryptoCurrencyById("celo");
9
- const minimalAmount = parseCurrencyUnit(currency.units[0], "0.001");
9
+ export const minimalAmount = parseCurrencyUnit(currency.units[0], "0.001");
10
10
 
11
11
  export const createSend50PercentMutation = (): MutationSpec<Transaction> => ({
12
12
  name: "Celo: Move 50% to another account",
13
13
  maxRun: 1,
14
+ testDestination: genericTestDestination,
14
15
  transaction: ({ account, siblings, bridge, maxSpendable }) => {
15
16
  invariant(
16
17
  maxSpendable.gt(minimalAmount),
@@ -29,6 +30,7 @@ export const createSend50PercentMutation = (): MutationSpec<Transaction> => ({
29
30
  export const createSendMaxMutation = (): MutationSpec<Transaction> => ({
30
31
  name: "Celo: Send max to another account",
31
32
  maxRun: 1,
33
+ testDestination: genericTestDestination,
32
34
  transaction: ({ account, siblings, bridge, maxSpendable }) => {
33
35
  invariant(
34
36
  maxSpendable.gt(minimalAmount),
@@ -1,6 +1,7 @@
1
1
  import { DeviceModelId } from "@ledgerhq/devices";
2
2
  import { getCryptoCurrencyById } from "../../currencies";
3
3
  import {
4
+ minimalAmount,
4
5
  createLockMutation,
5
6
  createRegisterAccountMutation,
6
7
  createSend50PercentMutation,
@@ -35,6 +36,7 @@ const celo: AppSpec<Transaction> = {
35
36
  },
36
37
  testTimeout: 2 * 60 * 1000,
37
38
  genericDeviceAction: acceptTransaction,
39
+ minViableAmount: minimalAmount,
38
40
  mutations: [
39
41
  send50PercentMutation,
40
42
  sendMaxMutation,
@@ -1,7 +1,7 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
- import { deviceActionFlow } from "../../bot/specs";
4
- import { formatCurrencyUnit } from "../../currencies";
3
+ import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
4
+
5
5
  const typeWording = {
6
6
  send: "Send",
7
7
  lock: "Lock",
@@ -23,18 +23,10 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
23
23
  {
24
24
  title: "Amount",
25
25
  button: "Rr",
26
- expectedValue: ({ account, status }) => {
27
- const formattedValue =
28
- "CELO " +
29
- formatCurrencyUnit(account.unit, status.amount, {
30
- disableRounding: true,
31
- });
32
- if (!formattedValue.includes(".")) {
33
- // if the value is pure integer, in the app it will automatically add an .0
34
- return formattedValue + ".0";
35
- }
36
- return formattedValue;
37
- },
26
+ expectedValue: ({ account, status }) =>
27
+ formatDeviceAmount(account.currency, status.amount, {
28
+ forceFloating: true,
29
+ }),
38
30
  },
39
31
  {
40
32
  title: "Address",
@@ -217,23 +217,19 @@ Array [
217
217
  "address": "cosmosvaloper1vf44d85es37hwl9f4h9gv0e064m0lla60j9luj",
218
218
  "amount": "180",
219
219
  },
220
- Object {
221
- "address": "cosmosvaloper1vf44d85es37hwl9f4h9gv0e064m0lla60j9luj",
222
- "amount": "180",
223
- },
224
220
  ],
225
221
  },
226
222
  "fee": "10619",
227
223
  "hash": "1F069773A16D0B028E3F90E23290B52DA7708082D258A22B8B786C615C272D5C",
228
- "id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-1F069773A16D0B028E3F90E23290B52DA7708082D258A22B8B786C615C272D5C-DELEGATE",
224
+ "id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-1F069773A16D0B028E3F90E23290B52DA7708082D258A22B8B786C615C272D5C-REWARD",
229
225
  "operator": undefined,
230
226
  "recipients": Array [],
231
227
  "senders": Array [],
232
228
  "standard": undefined,
233
229
  "tokenId": undefined,
234
230
  "transactionSequenceNumber": 89,
235
- "type": "DELEGATE",
236
- "value": "10619",
231
+ "type": "REWARD",
232
+ "value": "180",
237
233
  },
238
234
  Object {
239
235
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -258,7 +254,7 @@ Array [
258
254
  "tokenId": undefined,
259
255
  "transactionSequenceNumber": 86,
260
256
  "type": "REWARD",
261
- "value": "5847",
257
+ "value": "12037",
262
258
  },
263
259
  Object {
264
260
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -403,7 +399,7 @@ Array [
403
399
  "tokenId": undefined,
404
400
  "transactionSequenceNumber": 75,
405
401
  "type": "REWARD",
406
- "value": "7392",
402
+ "value": "239",
407
403
  },
408
404
  Object {
409
405
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -465,23 +461,19 @@ Array [
465
461
  "address": "cosmosvaloper1hjct6q7npsspsg3dgvzk3sdf89spmlpfdn6m9d",
466
462
  "amount": "6166",
467
463
  },
468
- Object {
469
- "address": "cosmosvaloper1hjct6q7npsspsg3dgvzk3sdf89spmlpfdn6m9d",
470
- "amount": "6166",
471
- },
472
464
  ],
473
465
  },
474
466
  "fee": "10650",
475
467
  "hash": "72E55F86B856BA8558F63075D653D02795A1FF4F33053398F221FF3FBBB02601",
476
- "id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-72E55F86B856BA8558F63075D653D02795A1FF4F33053398F221FF3FBBB02601-DELEGATE",
468
+ "id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-72E55F86B856BA8558F63075D653D02795A1FF4F33053398F221FF3FBBB02601-REWARD",
477
469
  "operator": undefined,
478
470
  "recipients": Array [],
479
471
  "senders": Array [],
480
472
  "standard": undefined,
481
473
  "tokenId": undefined,
482
474
  "transactionSequenceNumber": 87,
483
- "type": "DELEGATE",
484
- "value": "10650",
475
+ "type": "REWARD",
476
+ "value": "6166",
485
477
  },
486
478
  Object {
487
479
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -542,23 +534,19 @@ Array [
542
534
  "address": "cosmosvaloper1grgelyng2v6v3t8z87wu3sxgt9m5s03xfytvz7",
543
535
  "amount": "65",
544
536
  },
545
- Object {
546
- "address": "cosmosvaloper1grgelyng2v6v3t8z87wu3sxgt9m5s03xfytvz7",
547
- "amount": "65",
548
- },
549
537
  ],
550
538
  },
551
539
  "fee": "10414",
552
540
  "hash": "8440FE9905C9BCBD71A6A366AC150ECBD0EFFD040F5D39B255EE4708364497A2",
553
- "id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-8440FE9905C9BCBD71A6A366AC150ECBD0EFFD040F5D39B255EE4708364497A2-DELEGATE",
541
+ "id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-8440FE9905C9BCBD71A6A366AC150ECBD0EFFD040F5D39B255EE4708364497A2-REWARD",
554
542
  "operator": undefined,
555
543
  "recipients": Array [],
556
544
  "senders": Array [],
557
545
  "standard": undefined,
558
546
  "tokenId": undefined,
559
547
  "transactionSequenceNumber": 88,
560
- "type": "DELEGATE",
561
- "value": "10414",
548
+ "type": "REWARD",
549
+ "value": "65",
562
550
  },
563
551
  Object {
564
552
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -607,7 +595,7 @@ Array [
607
595
  "tokenId": undefined,
608
596
  "transactionSequenceNumber": 0,
609
597
  "type": "REWARD",
610
- "value": "9838",
598
+ "value": "15935",
611
599
  },
612
600
  Object {
613
601
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -704,7 +692,7 @@ Array [
704
692
  "tokenId": undefined,
705
693
  "transactionSequenceNumber": 85,
706
694
  "type": "REWARD",
707
- "value": "5854",
695
+ "value": "136432",
708
696
  },
709
697
  Object {
710
698
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -753,7 +741,7 @@ Array [
753
741
  "tokenId": undefined,
754
742
  "transactionSequenceNumber": 84,
755
743
  "type": "REWARD",
756
- "value": "6208",
744
+ "value": "47300",
757
745
  },
758
746
  Object {
759
747
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -790,23 +778,19 @@ Array [
790
778
  "address": "cosmosvaloper1crqm3598z6qmyn2kkcl9dz7uqs4qdqnr6s8jdn",
791
779
  "amount": "34610",
792
780
  },
793
- Object {
794
- "address": "cosmosvaloper1crqm3598z6qmyn2kkcl9dz7uqs4qdqnr6s8jdn",
795
- "amount": "34610",
796
- },
797
781
  ],
798
782
  },
799
783
  "fee": "10913",
800
784
  "hash": "B8D042E6B4AFB580E2D6DD20F2EDCD4E97791EF46DDD0AE112D7B771F6A9B0A4",
801
- "id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-B8D042E6B4AFB580E2D6DD20F2EDCD4E97791EF46DDD0AE112D7B771F6A9B0A4-DELEGATE",
785
+ "id": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:-B8D042E6B4AFB580E2D6DD20F2EDCD4E97791EF46DDD0AE112D7B771F6A9B0A4-REWARD",
802
786
  "operator": undefined,
803
787
  "recipients": Array [],
804
788
  "senders": Array [],
805
789
  "standard": undefined,
806
790
  "tokenId": undefined,
807
791
  "transactionSequenceNumber": 82,
808
- "type": "DELEGATE",
809
- "value": "10913",
792
+ "type": "REWARD",
793
+ "value": "34610",
810
794
  },
811
795
  Object {
812
796
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -928,7 +912,7 @@ Array [
928
912
  "tokenId": undefined,
929
913
  "transactionSequenceNumber": 81,
930
914
  "type": "REWARD",
931
- "value": "6197",
915
+ "value": "2347",
932
916
  },
933
917
  Object {
934
918
  "accountId": "js:2:cosmos:cosmos1g84934jpu3v5de5yqukkkhxmcvsw3u2ajxvpdl:",
@@ -977,7 +961,7 @@ Array [
977
961
  "tokenId": undefined,
978
962
  "transactionSequenceNumber": 83,
979
963
  "type": "REWARD",
980
- "value": "5972",
964
+ "value": "281690",
981
965
  },
982
966
  ],
983
967
  Array [
@@ -1078,7 +1062,7 @@ Array [
1078
1062
  "tokenId": undefined,
1079
1063
  "transactionSequenceNumber": 3,
1080
1064
  "type": "REDELEGATE",
1081
- "value": "11237",
1065
+ "value": "11233",
1082
1066
  },
1083
1067
  Object {
1084
1068
  "accountId": "js:2:cosmos:cosmos108uy5q9jt59gwugq5yrdhkzcd9jryslmpcstk5:",
@@ -1491,7 +1475,7 @@ Array [
1491
1475
  "tokenId": undefined,
1492
1476
  "transactionSequenceNumber": 5,
1493
1477
  "type": "DELEGATE",
1494
- "value": "11042",
1478
+ "value": "10906",
1495
1479
  },
1496
1480
  ],
1497
1481
  Array [
@@ -1724,23 +1708,19 @@ Array [
1724
1708
  "address": "cosmosvaloper17zcpywlhgcpk7ff505vr8mnc4wwpv5fcta6enz",
1725
1709
  "amount": "0",
1726
1710
  },
1727
- Object {
1728
- "address": "cosmosvaloper17zcpywlhgcpk7ff505vr8mnc4wwpv5fcta6enz",
1729
- "amount": "1",
1730
- },
1731
1711
  ],
1732
1712
  },
1733
1713
  "fee": "8399",
1734
1714
  "hash": "DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F10501",
1735
- "id": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:-DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F10501-DELEGATE",
1715
+ "id": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:-DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F10501-REWARD",
1736
1716
  "operator": undefined,
1737
1717
  "recipients": Array [],
1738
1718
  "senders": Array [],
1739
1719
  "standard": undefined,
1740
1720
  "tokenId": undefined,
1741
1721
  "transactionSequenceNumber": 25,
1742
- "type": "DELEGATE",
1743
- "value": "8399",
1722
+ "type": "REWARD",
1723
+ "value": "0",
1744
1724
  },
1745
1725
  Object {
1746
1726
  "accountId": "js:2:cosmos:cosmos1cgc696ay2pg6d4gcejek2y8la66j7e5y3c7kyw:",
@@ -0,0 +1,21 @@
1
+ type Message = {
2
+ type: string;
3
+ attributes: { [key: string]: any };
4
+ };
5
+
6
+ export const getMainMessage = (messages: Message[]): Message => {
7
+ const messagePriorities: string[] = [
8
+ "withdraw_rewards",
9
+ "unbond",
10
+ "redelegate",
11
+ "delegate",
12
+ "transfer",
13
+ ];
14
+ const sortedTypes = messages
15
+ .filter((m) => messagePriorities.includes(m.type))
16
+ .sort(
17
+ (a, b) =>
18
+ messagePriorities.indexOf(a.type) - messagePriorities.indexOf(b.type)
19
+ );
20
+ return sortedTypes[0];
21
+ };
@@ -0,0 +1,63 @@
1
+ import { getMainMessage } from "./helpers";
2
+
3
+ describe("getMainMessage", () => {
4
+ it("should return reward message with delegate and reward messages (claim rewards, compound)", () => {
5
+ const exec = getMainMessage([
6
+ {
7
+ type: "delegate",
8
+ attributes: {},
9
+ },
10
+ {
11
+ type: "withdraw_rewards",
12
+ attributes: {},
13
+ },
14
+ ]);
15
+ expect(exec.type).toEqual("withdraw_rewards");
16
+ });
17
+
18
+ it("should return unbond message with unbound and transfer messages", () => {
19
+ expect(
20
+ getMainMessage([
21
+ {
22
+ type: "unbond",
23
+ attributes: {},
24
+ },
25
+ {
26
+ type: "transfer",
27
+ attributes: {},
28
+ },
29
+ ]).type
30
+ ).toEqual("unbond");
31
+ });
32
+
33
+ it("should return first transfer message with multiple transfer messages", () => {
34
+ const firstTransfer = {
35
+ type: "transfer",
36
+ attributes: {},
37
+ };
38
+ expect(
39
+ getMainMessage([
40
+ firstTransfer,
41
+ {
42
+ type: "transfer",
43
+ attributes: {},
44
+ },
45
+ ])
46
+ ).toEqual(firstTransfer);
47
+ });
48
+
49
+ it("should return redelegate message with delegate/redelegate messages", () => {
50
+ expect(
51
+ getMainMessage([
52
+ {
53
+ type: "delegate",
54
+ attributes: {},
55
+ },
56
+ {
57
+ type: "redelegate",
58
+ attributes: {},
59
+ },
60
+ ]).type
61
+ ).toEqual("redelegate");
62
+ });
63
+ });
@@ -153,9 +153,12 @@ const signOperation = ({
153
153
  id: encodeOperationId(accountId, hash, type),
154
154
  hash,
155
155
  type,
156
- value: transaction.useAllAmount
157
- ? account.spendableBalance
158
- : transaction.amount.plus(fee),
156
+ value:
157
+ type === "REWARD"
158
+ ? new BigNumber(0)
159
+ : transaction.useAllAmount
160
+ ? account.spendableBalance
161
+ : transaction.amount.plus(fee),
159
162
  fee,
160
163
  extra,
161
164
  blockHash: null,
@@ -11,6 +11,25 @@ import { pubkeyToAddress, decodeBech32Pubkey } from "@cosmjs/amino";
11
11
  import { encodeOperationId } from "../../operation";
12
12
  import { CosmosDelegationInfo } from "./types";
13
13
  import type { Operation, OperationType } from "@ledgerhq/types-live";
14
+ import { getMainMessage } from "./helpers";
15
+
16
+ const getBlankOperation = (tx, fees, id) => ({
17
+ id: "",
18
+ hash: tx.txhash,
19
+ type: "" as OperationType,
20
+ value: new BigNumber(0),
21
+ fee: fees,
22
+ blockHash: null,
23
+ blockHeight: tx.height,
24
+ senders: [] as string[],
25
+ recipients: [] as string[],
26
+ accountId: id,
27
+ date: new Date(tx.timestamp),
28
+ extra: {
29
+ validators: [] as CosmosDelegationInfo[],
30
+ },
31
+ transactionSequenceNumber: parseInt(tx.tx.auth_info.signer_infos[0].sequence),
32
+ });
14
33
 
15
34
  const txToOps = (info: any, id: string, txs: any): Operation[] => {
16
35
  const { address, currency } = info;
@@ -23,126 +42,108 @@ const txToOps = (info: any, id: string, txs: any): Operation[] => {
23
42
  if (elem.denom === currency.units[1].code) fees = fees.plus(elem.amount);
24
43
  });
25
44
 
26
- const op: Operation = {
27
- id: "",
28
- hash: tx.txhash,
29
- type: "" as OperationType,
30
- value: new BigNumber(0),
31
- fee: fees,
32
- blockHash: null,
33
- blockHeight: tx.height,
34
- senders: [] as string[],
35
- recipients: [] as string[],
36
- accountId: id,
37
- date: new Date(tx.timestamp),
38
- extra: {
39
- validators: [] as CosmosDelegationInfo[],
40
- },
41
- transactionSequenceNumber: parseInt(
42
- tx.tx.auth_info.signer_infos[0].sequence
43
- ),
44
- };
45
-
46
- tx.logs.forEach((log) => {
47
- log.events.forEach((message) => {
48
- // parse attributes as key:value
49
- const attributes: { [id: string]: any } = {};
50
- message.attributes.forEach(
51
- (item) => (attributes[item.key] = item.value)
52
- );
53
-
54
- // https://docs.cosmos.network/v0.42/modules/staking/07_events.html
55
- switch (message.type) {
56
- case "transfer":
57
- if (
58
- attributes.sender &&
59
- attributes.recipient &&
60
- attributes.amount
61
- ) {
62
- op.senders.push(attributes.sender);
63
- op.recipients.push(attributes.recipient);
64
-
65
- if (attributes.amount.indexOf(currency.units[1].code) != -1) {
66
- op.value = op.value.plus(
67
- attributes.amount.replace(currency.units[1].code, "")
68
- );
69
- }
70
-
71
- if (!op.type && attributes.sender === address) {
72
- op.type = "OUT";
73
- op.value = op.value.plus(fees);
74
- } else if (!op.type && attributes.recipient === address) {
75
- op.type = "IN";
76
- }
77
- }
78
- break;
79
-
80
- case "withdraw_rewards":
81
- if (
82
- (attributes.amount &&
83
- attributes.amount.indexOf(currency.units[1].code) != -1) ||
84
- // handle specifc case with empty amount value like
85
- // tx DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F1050
86
- attributes.amount === ""
87
- ) {
88
- op.type = "REWARD";
89
- op.value = new BigNumber(fees);
90
- op.extra.validators.push({
91
- address: attributes.validator,
92
- amount:
93
- attributes.amount.replace(currency.units[1].code, "") || 0,
94
- });
95
- }
96
- break;
97
-
98
- case "delegate":
99
- if (
100
- attributes.amount &&
101
- attributes.amount.indexOf(currency.units[1].code) != -1
102
- ) {
103
- op.type = "DELEGATE";
104
- op.value = new BigNumber(fees);
105
- op.extra.validators.push({
106
- address: attributes.validator,
107
- amount: attributes.amount.replace(currency.units[1].code, ""),
108
- });
109
- }
110
- break;
111
-
112
- case "redelegate":
113
- if (
114
- attributes.amount &&
115
- attributes.amount.indexOf(currency.units[1].code) != -1 &&
116
- attributes.destination_validator &&
117
- attributes.source_validator
118
- ) {
119
- op.type = "REDELEGATE";
120
- op.value = new BigNumber(fees);
121
- op.extra.validators.push({
122
- address: attributes.destination_validator,
123
- amount: attributes.amount.replace(currency.units[1].code, ""),
124
- });
125
- op.extra.sourceValidator = attributes.source_validator;
126
- }
127
- break;
128
-
129
- case "unbond":
130
- if (
131
- attributes.amount &&
132
- attributes.amount.indexOf(currency.units[1].code) != -1 &&
133
- attributes.validator
134
- ) {
135
- op.type = "UNDELEGATE";
136
- op.value = new BigNumber(fees);
137
- op.extra.validators.push({
138
- address: attributes.validator,
139
- amount: attributes.amount.replace(currency.units[1].code, ""),
140
- });
141
- }
142
- break;
45
+ const op: Operation = getBlankOperation(tx, fees, id);
46
+
47
+ const messages = tx.logs.map((log) => log.events).flat(1);
48
+
49
+ const message = getMainMessage(messages);
50
+
51
+ if (message == null) {
52
+ continue;
53
+ }
54
+
55
+ // parse attributes as key:value
56
+ const attributes: { [id: string]: any } = {};
57
+ message.attributes.forEach((item) => (attributes[item.key] = item.value));
58
+
59
+ // https://docs.cosmos.network/v0.42/modules/staking/07_events.html
60
+ switch (message.type) {
61
+ case "transfer":
62
+ if (attributes.sender && attributes.recipient && attributes.amount) {
63
+ op.senders.push(attributes.sender);
64
+ op.recipients.push(attributes.recipient);
65
+
66
+ if (attributes.amount.indexOf(currency.units[1].code) != -1) {
67
+ op.value = op.value.plus(
68
+ attributes.amount.replace(currency.units[1].code, "")
69
+ );
70
+ }
71
+
72
+ if (!op.type && attributes.sender === address) {
73
+ op.type = "OUT";
74
+ op.value = op.value.plus(fees);
75
+ } else if (!op.type && attributes.recipient === address) {
76
+ op.type = "IN";
77
+ }
143
78
  }
144
- });
145
- });
79
+ break;
80
+
81
+ case "withdraw_rewards":
82
+ if (
83
+ (attributes.amount &&
84
+ attributes.amount.indexOf(currency.units[1].code) != -1) ||
85
+ // handle specifc case with empty amount value like
86
+ // tx DF458FE6A82C310837D7A33735FA5298BCF71B0BFF7A4134641AAE30F6F1050
87
+ attributes.amount === ""
88
+ ) {
89
+ op.type = "REWARD";
90
+ const reward = message.attributes
91
+ .find((attr) => attr.key === "amount")
92
+ .value.replace("uatom", "");
93
+ op.value = new BigNumber(reward || 0);
94
+ op.extra.validators.push({
95
+ address: attributes.validator,
96
+ amount: attributes.amount.replace(currency.units[1].code, "") || 0,
97
+ });
98
+ }
99
+ break;
100
+
101
+ case "delegate":
102
+ if (
103
+ attributes.amount &&
104
+ attributes.amount.indexOf(currency.units[1].code) != -1
105
+ ) {
106
+ op.type = "DELEGATE";
107
+ op.value = new BigNumber(fees);
108
+ op.extra.validators.push({
109
+ address: attributes.validator,
110
+ amount: attributes.amount.replace(currency.units[1].code, ""),
111
+ });
112
+ }
113
+ break;
114
+
115
+ case "redelegate":
116
+ if (
117
+ attributes.amount &&
118
+ attributes.amount.indexOf(currency.units[1].code) != -1 &&
119
+ attributes.destination_validator &&
120
+ attributes.source_validator
121
+ ) {
122
+ op.type = "REDELEGATE";
123
+ op.value = new BigNumber(fees);
124
+ op.extra.validators.push({
125
+ address: attributes.destination_validator,
126
+ amount: attributes.amount.replace(currency.units[1].code, ""),
127
+ });
128
+ op.extra.sourceValidator = attributes.source_validator;
129
+ }
130
+ break;
131
+
132
+ case "unbond":
133
+ if (
134
+ attributes.amount &&
135
+ attributes.amount.indexOf(currency.units[1].code) != -1 &&
136
+ attributes.validator
137
+ ) {
138
+ op.type = "UNDELEGATE";
139
+ op.value = new BigNumber(fees);
140
+ op.extra.validators.push({
141
+ address: attributes.validator,
142
+ amount: attributes.amount.replace(currency.units[1].code, ""),
143
+ });
144
+ }
145
+ break;
146
+ }
146
147
 
147
148
  if (!["IN", "OUT"].includes(op.type)) {
148
149
  op.senders = [];