@ledgerhq/live-common 27.2.0-nightly.4 → 27.2.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 (202) hide show
  1. package/lib/bot/index.d.ts.map +1 -1
  2. package/lib/bot/index.js +3 -8
  3. package/lib/bot/index.js.map +1 -1
  4. package/lib/bot/specs.d.ts +0 -9
  5. package/lib/bot/specs.d.ts.map +1 -1
  6. package/lib/bot/specs.js +1 -49
  7. package/lib/bot/specs.js.map +1 -1
  8. package/lib/currencies/support.d.ts.map +1 -1
  9. package/lib/currencies/support.js +1 -2
  10. package/lib/currencies/support.js.map +1 -1
  11. package/lib/derivation.d.ts.map +1 -1
  12. package/lib/derivation.js +4 -2
  13. package/lib/derivation.js.map +1 -1
  14. package/lib/env.js +1 -1
  15. package/lib/exchange/swap/getExchangeRates.d.ts.map +1 -1
  16. package/lib/exchange/swap/getExchangeRates.js +1 -1
  17. package/lib/exchange/swap/getExchangeRates.js.map +1 -1
  18. package/lib/exchange/swap/getProviders.d.ts.map +1 -1
  19. package/lib/exchange/swap/getProviders.js +5 -45
  20. package/lib/exchange/swap/getProviders.js.map +1 -1
  21. package/lib/exchange/swap/index.d.ts +1 -2
  22. package/lib/exchange/swap/index.d.ts.map +1 -1
  23. package/lib/exchange/swap/index.js +1 -11
  24. package/lib/exchange/swap/index.js.map +1 -1
  25. package/lib/exchange/swap/index.test.js +0 -22
  26. package/lib/exchange/swap/index.test.js.map +1 -1
  27. package/lib/exchange/swap/mock.js +1 -1
  28. package/lib/exchange/swap/mock.js.map +1 -1
  29. package/lib/exchange/swap/types.d.ts +0 -14
  30. package/lib/exchange/swap/types.d.ts.map +1 -1
  31. package/lib/families/algorand/speculos-deviceActions.d.ts.map +1 -1
  32. package/lib/families/algorand/speculos-deviceActions.js +29 -2
  33. package/lib/families/algorand/speculos-deviceActions.js.map +1 -1
  34. package/lib/families/bitcoin/specs.d.ts.map +1 -1
  35. package/lib/families/bitcoin/specs.js +1 -0
  36. package/lib/families/bitcoin/specs.js.map +1 -1
  37. package/lib/families/bitcoin/speculos-deviceActions.d.ts.map +1 -1
  38. package/lib/families/bitcoin/speculos-deviceActions.js +22 -2
  39. package/lib/families/bitcoin/speculos-deviceActions.js.map +1 -1
  40. package/lib/families/cardano/specs.d.ts.map +1 -1
  41. package/lib/families/cardano/specs.js +3 -4
  42. package/lib/families/cardano/specs.js.map +1 -1
  43. package/lib/families/cardano/speculos-deviceActions.d.ts.map +1 -1
  44. package/lib/families/cardano/speculos-deviceActions.js +10 -2
  45. package/lib/families/cardano/speculos-deviceActions.js.map +1 -1
  46. package/lib/families/celo/speculos-deviceActions.d.ts.map +1 -1
  47. package/lib/families/celo/speculos-deviceActions.js +10 -3
  48. package/lib/families/celo/speculos-deviceActions.js.map +1 -1
  49. package/lib/families/elrond/speculos-deviceActions.d.ts.map +1 -1
  50. package/lib/families/elrond/speculos-deviceActions.js +8 -3
  51. package/lib/families/elrond/speculos-deviceActions.js.map +1 -1
  52. package/lib/families/ethereum/speculos-deviceActions.d.ts.map +1 -1
  53. package/lib/families/ethereum/speculos-deviceActions.js +33 -10
  54. package/lib/families/ethereum/speculos-deviceActions.js.map +1 -1
  55. package/lib/families/evm/specs.d.ts.map +1 -1
  56. package/lib/families/evm/specs.js +5 -9
  57. package/lib/families/evm/specs.js.map +1 -1
  58. package/lib/families/evm/speculos-deviceActions.d.ts.map +1 -1
  59. package/lib/families/evm/speculos-deviceActions.js +25 -5
  60. package/lib/families/evm/speculos-deviceActions.js.map +1 -1
  61. package/lib/families/filecoin/speculos-deviceActions.d.ts.map +1 -1
  62. package/lib/families/filecoin/speculos-deviceActions.js +7 -6
  63. package/lib/families/filecoin/speculos-deviceActions.js.map +1 -1
  64. package/lib/families/polkadot/speculos-deviceActions.d.ts.map +1 -1
  65. package/lib/families/polkadot/speculos-deviceActions.js +10 -3
  66. package/lib/families/polkadot/speculos-deviceActions.js.map +1 -1
  67. package/lib/families/ripple/speculos-deviceActions.d.ts.map +1 -1
  68. package/lib/families/ripple/speculos-deviceActions.js +22 -2
  69. package/lib/families/ripple/speculos-deviceActions.js.map +1 -1
  70. package/lib/families/solana/speculos-deviceActions.d.ts.map +1 -1
  71. package/lib/families/solana/speculos-deviceActions.js +7 -5
  72. package/lib/families/solana/speculos-deviceActions.js.map +1 -1
  73. package/lib/families/stellar/api/horizon.d.ts.map +1 -1
  74. package/lib/families/stellar/api/horizon.js +10 -15
  75. package/lib/families/stellar/api/horizon.js.map +1 -1
  76. package/lib/families/stellar/speculos-deviceActions.d.ts.map +1 -1
  77. package/lib/families/stellar/speculos-deviceActions.js +8 -4
  78. package/lib/families/stellar/speculos-deviceActions.js.map +1 -1
  79. package/lib/families/tezos/speculos-deviceActions.d.ts.map +1 -1
  80. package/lib/families/tezos/speculos-deviceActions.js +11 -6
  81. package/lib/families/tezos/speculos-deviceActions.js.map +1 -1
  82. package/lib/families/tron/speculos-deviceActions.d.ts.map +1 -1
  83. package/lib/families/tron/speculos-deviceActions.js +14 -2
  84. package/lib/families/tron/speculos-deviceActions.js.map +1 -1
  85. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  86. package/lib/featureFlags/defaultFeatures.js +0 -3
  87. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  88. package/lib/hw/extractOnboardingState.d.ts +1 -5
  89. package/lib/hw/extractOnboardingState.d.ts.map +1 -1
  90. package/lib/hw/extractOnboardingState.js +9 -17
  91. package/lib/hw/extractOnboardingState.js.map +1 -1
  92. package/lib/hw/extractOnboardingState.test.js +11 -21
  93. package/lib/hw/extractOnboardingState.test.js.map +1 -1
  94. package/package.json +19 -23
  95. package/src/bot/index.ts +12 -11
  96. package/src/bot/specs.ts +0 -45
  97. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +35 -1
  98. package/src/currencies/support.ts +1 -2
  99. package/src/derivation.ts +4 -2
  100. package/src/env.ts +1 -1
  101. package/src/exchange/swap/getExchangeRates.ts +3 -7
  102. package/src/exchange/swap/getProviders.ts +8 -31
  103. package/src/exchange/swap/index.test.ts +1 -36
  104. package/src/exchange/swap/index.ts +0 -15
  105. package/src/exchange/swap/mock.ts +2 -2
  106. package/src/exchange/swap/types.ts +0 -11
  107. package/src/families/algorand/speculos-deviceActions.ts +35 -4
  108. package/src/families/bitcoin/specs.ts +1 -0
  109. package/src/families/bitcoin/speculos-deviceActions.ts +26 -3
  110. package/src/families/cardano/specs.ts +3 -4
  111. package/src/families/cardano/speculos-deviceActions.ts +14 -3
  112. package/src/families/celo/speculos-deviceActions.ts +14 -6
  113. package/src/families/elrond/speculos-deviceActions.ts +9 -4
  114. package/src/families/ethereum/speculos-deviceActions.ts +46 -16
  115. package/src/families/evm/specs.ts +8 -12
  116. package/src/families/evm/speculos-deviceActions.ts +35 -7
  117. package/src/families/filecoin/speculos-deviceActions.ts +8 -7
  118. package/src/families/polkadot/speculos-deviceActions.ts +16 -5
  119. package/src/families/ripple/speculos-deviceActions.ts +28 -3
  120. package/src/families/solana/speculos-deviceActions.ts +8 -6
  121. package/src/families/stellar/api/horizon.ts +6 -10
  122. package/src/families/stellar/speculos-deviceActions.ts +11 -5
  123. package/src/families/tezos/speculos-deviceActions.ts +16 -9
  124. package/src/families/tron/speculos-deviceActions.ts +12 -4
  125. package/src/featureFlags/defaultFeatures.ts +0 -3
  126. package/src/hw/extractOnboardingState.test.ts +12 -29
  127. package/src/hw/extractOnboardingState.ts +9 -17
  128. package/lib/exchange/swap/getProviders.test.d.ts +0 -2
  129. package/lib/exchange/swap/getProviders.test.d.ts.map +0 -1
  130. package/lib/exchange/swap/getProviders.test.js +0 -519
  131. package/lib/exchange/swap/getProviders.test.js.map +0 -1
  132. package/lib/postOnboarding/PostOnboardingProvider.d.ts +0 -20
  133. package/lib/postOnboarding/PostOnboardingProvider.d.ts.map +0 -1
  134. package/lib/postOnboarding/PostOnboardingProvider.js +0 -33
  135. package/lib/postOnboarding/PostOnboardingProvider.js.map +0 -1
  136. package/lib/postOnboarding/actions.d.ts +0 -20
  137. package/lib/postOnboarding/actions.d.ts.map +0 -1
  138. package/lib/postOnboarding/actions.js +0 -37
  139. package/lib/postOnboarding/actions.js.map +0 -1
  140. package/lib/postOnboarding/hooks/index.d.ts +0 -6
  141. package/lib/postOnboarding/hooks/index.d.ts.map +0 -1
  142. package/lib/postOnboarding/hooks/index.js +0 -22
  143. package/lib/postOnboarding/hooks/index.js.map +0 -1
  144. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.d.ts +0 -8
  145. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.d.ts.map +0 -1
  146. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.js +0 -16
  147. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.js.map +0 -1
  148. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.d.ts +0 -2
  149. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.d.ts.map +0 -1
  150. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.js +0 -75
  151. package/lib/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.js.map +0 -1
  152. package/lib/postOnboarding/hooks/usePostOnboardingContext.d.ts +0 -3
  153. package/lib/postOnboarding/hooks/usePostOnboardingContext.d.ts.map +0 -1
  154. package/lib/postOnboarding/hooks/usePostOnboardingContext.js +0 -10
  155. package/lib/postOnboarding/hooks/usePostOnboardingContext.js.map +0 -1
  156. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.d.ts +0 -8
  157. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.d.ts.map +0 -1
  158. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.js +0 -20
  159. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.js.map +0 -1
  160. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.d.ts +0 -2
  161. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.d.ts.map +0 -1
  162. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.js +0 -64
  163. package/lib/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.js.map +0 -1
  164. package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts +0 -12
  165. package/lib/postOnboarding/hooks/usePostOnboardingHubState.d.ts.map +0 -1
  166. package/lib/postOnboarding/hooks/usePostOnboardingHubState.js +0 -65
  167. package/lib/postOnboarding/hooks/usePostOnboardingHubState.js.map +0 -1
  168. package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.d.ts +0 -2
  169. package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.d.ts.map +0 -1
  170. package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.js +0 -129
  171. package/lib/postOnboarding/hooks/usePostOnboardingHubState.test.js.map +0 -1
  172. package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.d.ts +0 -13
  173. package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.d.ts.map +0 -1
  174. package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.js +0 -34
  175. package/lib/postOnboarding/hooks/useStartPostOnboardingCallback.js.map +0 -1
  176. package/lib/postOnboarding/mock.d.ts +0 -8
  177. package/lib/postOnboarding/mock.d.ts.map +0 -1
  178. package/lib/postOnboarding/mock.js +0 -46
  179. package/lib/postOnboarding/mock.js.map +0 -1
  180. package/lib/postOnboarding/reducer.d.ts +0 -22
  181. package/lib/postOnboarding/reducer.d.ts.map +0 -1
  182. package/lib/postOnboarding/reducer.js +0 -71
  183. package/lib/postOnboarding/reducer.js.map +0 -1
  184. package/lib/postOnboarding/reducer.test.d.ts +0 -2
  185. package/lib/postOnboarding/reducer.test.d.ts.map +0 -1
  186. package/lib/postOnboarding/reducer.test.js +0 -251
  187. package/lib/postOnboarding/reducer.test.js.map +0 -1
  188. package/src/exchange/swap/getProviders.test.ts +0 -450
  189. package/src/postOnboarding/PostOnboardingProvider.tsx +0 -49
  190. package/src/postOnboarding/actions.ts +0 -40
  191. package/src/postOnboarding/hooks/index.ts +0 -5
  192. package/src/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.test.ts +0 -82
  193. package/src/postOnboarding/hooks/useAllPostOnboardingActionsCompleted.ts +0 -12
  194. package/src/postOnboarding/hooks/usePostOnboardingContext.ts +0 -9
  195. package/src/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.test.ts +0 -83
  196. package/src/postOnboarding/hooks/usePostOnboardingEntryPointVisibleOnWallet.ts +0 -22
  197. package/src/postOnboarding/hooks/usePostOnboardingHubState.test.ts +0 -184
  198. package/src/postOnboarding/hooks/usePostOnboardingHubState.ts +0 -56
  199. package/src/postOnboarding/hooks/useStartPostOnboardingCallback.ts +0 -38
  200. package/src/postOnboarding/mock.ts +0 -53
  201. package/src/postOnboarding/reducer.test.ts +0 -247
  202. package/src/postOnboarding/reducer.ts +0 -105
@@ -1,6 +1,17 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
3
+ import { formatCurrencyUnit } from "../../currencies";
4
+ import { deviceActionFlow } from "../../bot/specs";
5
+ import type { Unit } from "@ledgerhq/types-cryptoassets";
6
+ import BigNumber from "bignumber.js";
7
+
8
+ function expectedValue(unit: Unit, value: BigNumber) {
9
+ return formatCurrencyUnit(unit, value, {
10
+ showCode: true,
11
+ disableRounding: true,
12
+ showAllDigits: true,
13
+ });
14
+ }
4
15
 
5
16
  export const acceptTransaction: DeviceAction<Transaction, any> =
6
17
  deviceActionFlow({
@@ -27,7 +38,7 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
27
38
  button: "LRlr",
28
39
  ignoreAssertionFailure: true,
29
40
  expectedValue: ({ account, status }) =>
30
- formatDeviceAmount(account.currency, status.amount),
41
+ expectedValue(account.unit, status.amount),
31
42
  },
32
43
  {
33
44
  title: "Asset fingerprint",
@@ -49,7 +60,7 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
49
60
  button: "LRlr",
50
61
  ignoreAssertionFailure: true,
51
62
  expectedValue: ({ account, status }) =>
52
- formatDeviceAmount(account.currency, status.estimatedFees),
63
+ expectedValue(account.unit, status.estimatedFees),
53
64
  },
54
65
  {
55
66
  title: "Transaction TTL",
@@ -1,7 +1,7 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
4
-
3
+ import { deviceActionFlow } from "../../bot/specs";
4
+ import { formatCurrencyUnit } from "../../currencies";
5
5
  const typeWording = {
6
6
  send: "Send",
7
7
  lock: "Lock",
@@ -23,10 +23,18 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
23
23
  {
24
24
  title: "Amount",
25
25
  button: "Rr",
26
- expectedValue: ({ account, status }) =>
27
- formatDeviceAmount(account.currency, status.amount, {
28
- forceFloating: true,
29
- }),
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
+ },
30
38
  },
31
39
  {
32
40
  title: "Address",
@@ -1,6 +1,7 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
3
+ import { deviceActionFlow } from "../../bot/specs";
4
+ import { formatCurrencyUnit } from "../../currencies";
4
5
 
5
6
  export const acceptTransaction: DeviceAction<Transaction, any> =
6
7
  deviceActionFlow({
@@ -14,9 +15,13 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
14
15
  title: "Amount",
15
16
  button: "Rr",
16
17
  expectedValue: ({ account, transaction }) =>
17
- formatDeviceAmount(account.currency, transaction.amount, {
18
- postfixCode: true,
19
- }),
18
+ formatCurrencyUnit(account.unit, transaction.amount, {
19
+ showCode: true,
20
+ disableRounding: true,
21
+ joinFragmentsSeparator: " ",
22
+ })
23
+ .replace(/\s+/g, " ")
24
+ .replace("egld", "EGLD"), // FIXME
20
25
  },
21
26
  {
22
27
  title: "Fee",
@@ -1,6 +1,7 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
3
+ import { formatCurrencyUnit, findCompoundToken } from "../../currencies";
4
+ import { deviceActionFlow } from "../../bot/specs";
4
5
 
5
6
  function subAccount(subAccountId, account) {
6
7
  const sub = (account.subAccounts || []).find((a) => a.id === subAccountId);
@@ -9,8 +10,28 @@ function subAccount(subAccountId, account) {
9
10
  return sub;
10
11
  }
11
12
 
13
+ function expectedCompoundToken(t) {
14
+ if (!t) {
15
+ throw new Error("compound token was expected");
16
+ }
17
+
18
+ return t;
19
+ }
20
+
12
21
  const maxFeesExpectedValue = ({ account, status }) =>
13
- formatDeviceAmount(account.currency, status.estimatedFees);
22
+ formatCurrencyUnit(
23
+ {
24
+ ...account.unit,
25
+ code: account.currency.deviceTicker || account.unit.code,
26
+ prefixCode: true,
27
+ },
28
+ status.estimatedFees,
29
+ {
30
+ showCode: true,
31
+ disableRounding: true,
32
+ joinFragmentsSeparator: " ",
33
+ }
34
+ ).replace(/\s/g, " ");
14
35
 
15
36
  export const acceptTransaction: DeviceAction<Transaction, any> =
16
37
  deviceActionFlow({
@@ -45,6 +66,16 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
45
66
  return "Unlimited " + a.token.ticker;
46
67
  }
47
68
 
69
+ const unit = !a
70
+ ? {
71
+ ...account.unit,
72
+ code: account.currency.deviceTicker || account.unit.code,
73
+ }
74
+ : (transaction.mode === "compound.withdraw" &&
75
+ transaction.useAllAmount
76
+ ? expectedCompoundToken(findCompoundToken(a.token))
77
+ : a.token
78
+ ).units[0];
48
79
  const amount =
49
80
  a &&
50
81
  a.compoundBalance &&
@@ -52,20 +83,19 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
52
83
  transaction.useAllAmount
53
84
  ? a.compoundBalance
54
85
  : status.amount;
55
-
56
- if (
57
- a &&
58
- transaction.mode === "compound.withdraw" &&
59
- transaction.useAllAmount
60
- ) {
61
- return formatDeviceAmount(a.compoundBalance, amount);
62
- }
63
-
64
- if (a) {
65
- return formatDeviceAmount(a.token, amount);
66
- }
67
-
68
- return formatDeviceAmount(account.currency, amount);
86
+ return formatCurrencyUnit(
87
+ {
88
+ ...unit,
89
+ code: account.currency.deviceTicker || account.unit.code,
90
+ prefixCode: true,
91
+ },
92
+ amount,
93
+ {
94
+ showCode: true,
95
+ disableRounding: true,
96
+ joinFragmentsSeparator: " ",
97
+ }
98
+ ).replace(/\s/g, " ");
69
99
  },
70
100
  },
71
101
  {
@@ -3,7 +3,7 @@ import invariant from "invariant";
3
3
  import { DeviceModelId } from "@ledgerhq/devices";
4
4
  import { getCryptoCurrencyById, parseCurrencyUnit } from "../../currencies";
5
5
  import { acceptTransaction } from "./speculos-deviceActions";
6
- import { botTest, pickSiblings } from "../../bot/specs";
6
+ import { pickSiblings } from "../../bot/specs";
7
7
  import type { AppSpec } from "../../bot/types";
8
8
  import type { Transaction } from "./types";
9
9
 
@@ -14,7 +14,7 @@ const transactionCheck =
14
14
  ({ maxSpendable }) => {
15
15
  invariant(
16
16
  maxSpendable.gt(
17
- parseCurrencyUnit(getCryptoCurrencyById(currencyId).units[0], "1")
17
+ parseCurrencyUnit(getCryptoCurrencyById(currencyId).units[0], "0.01")
18
18
  ),
19
19
  `${currencyId} balance is too low`
20
20
  );
@@ -45,17 +45,13 @@ const evmBasicMutations = ({ maxAccount }) => [
45
45
  "operation time to be older than 60s"
46
46
  );
47
47
  const estimatedGas = transaction.gasLimit.times(
48
- transaction.gasPrice || transaction.maxFeePerGas || 0
48
+ transaction.gasPrice || 0
49
49
  );
50
- botTest("operation fee is not exceeding estimated gas", () =>
51
- expect(operation.fee.toNumber()).toBeLessThanOrEqual(
52
- estimatedGas.toNumber()
53
- )
50
+ expect(operation.fee.toNumber()).toBeLessThanOrEqual(
51
+ estimatedGas.toNumber()
54
52
  );
55
- botTest("account balance moved with operation value", () =>
56
- expect(account.balance.toString()).toBe(
57
- accountBeforeTransaction.balance.minus(operation.value).toString()
58
- )
53
+ expect(account.balance.toString()).toBe(
54
+ accountBeforeTransaction.balance.minus(operation.value).toString()
59
55
  );
60
56
  },
61
57
  },
@@ -122,7 +118,7 @@ const songbird: AppSpec<Transaction> = {
122
118
  };
123
119
 
124
120
  const flare: AppSpec<Transaction> = {
125
- name: "Flare",
121
+ name: "Moonbeam",
126
122
  currency: getCryptoCurrencyById("flare"),
127
123
  appQuery: {
128
124
  model: DeviceModelId.nanoS,
@@ -1,6 +1,7 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
3
+ import { formatCurrencyUnit } from "../../currencies";
4
+ import { deviceActionFlow } from "../../bot/specs";
4
5
 
5
6
  function subAccount(subAccountId, account) {
6
7
  const sub = (account.subAccounts || []).find((a) => a.id === subAccountId);
@@ -10,7 +11,19 @@ function subAccount(subAccountId, account) {
10
11
  }
11
12
 
12
13
  const maxFeesExpectedValue = ({ account, status }) =>
13
- formatDeviceAmount(account.currency, status.estimatedFees);
14
+ formatCurrencyUnit(
15
+ {
16
+ ...account.unit,
17
+ code: account.currency.deviceTicker || account.unit.code,
18
+ prefixCode: true,
19
+ },
20
+ status.estimatedFees,
21
+ {
22
+ showCode: true,
23
+ disableRounding: true,
24
+ joinFragmentsSeparator: " ",
25
+ }
26
+ ).replace(/\s/g, " ");
14
27
 
15
28
  export const acceptTransaction: DeviceAction<Transaction, any> =
16
29
  deviceActionFlow({
@@ -31,11 +44,26 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
31
44
  ? subAccount(transaction.subAccountId, account)
32
45
  : null;
33
46
 
34
- if (a) {
35
- return formatDeviceAmount(a.token, status.amount);
36
- }
37
-
38
- return formatDeviceAmount(account.currency, status.amount);
47
+ const unit = !a
48
+ ? {
49
+ ...account.unit,
50
+ code: account.currency.deviceTicker || account.unit.code,
51
+ }
52
+ : a.token.units[0];
53
+ const amount = status.amount;
54
+ return formatCurrencyUnit(
55
+ {
56
+ ...unit,
57
+ code: account.currency.deviceTicker || account.unit.code,
58
+ prefixCode: true,
59
+ },
60
+ amount,
61
+ {
62
+ showCode: true,
63
+ disableRounding: true,
64
+ joinFragmentsSeparator: " ",
65
+ }
66
+ ).replace(/\s/g, " ");
39
67
  },
40
68
  },
41
69
  {
@@ -1,6 +1,7 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
3
+ import { deviceActionFlow } from "../../bot/specs";
4
+ import { formatCurrencyUnit } from "../../currencies";
4
5
 
5
6
  export const acceptTransaction: DeviceAction<Transaction, any> =
6
7
  deviceActionFlow({
@@ -24,8 +25,8 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
24
25
  title: "Value",
25
26
  button: "Rr",
26
27
  expectedValue: ({ account, status }) =>
27
- formatDeviceAmount(account.currency, status.amount, {
28
- hideCode: true,
28
+ formatCurrencyUnit(account.unit, status.amount, {
29
+ disableRounding: true,
29
30
  showAllDigits: true,
30
31
  }),
31
32
  },
@@ -38,8 +39,8 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
38
39
  title: "Gas Premium",
39
40
  button: "Rr",
40
41
  expectedValue: ({ account, transaction }) =>
41
- formatDeviceAmount(account.currency, transaction.gasPremium, {
42
- hideCode: true,
42
+ formatCurrencyUnit(account.unit, transaction.gasPremium, {
43
+ disableRounding: true,
43
44
  showAllDigits: true,
44
45
  }),
45
46
  },
@@ -47,8 +48,8 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
47
48
  title: "Gas Fee Cap",
48
49
  button: "Rr",
49
50
  expectedValue: ({ account, transaction }) =>
50
- formatDeviceAmount(account.currency, transaction.gasFeeCap, {
51
- hideCode: true,
51
+ formatCurrencyUnit(account.unit, transaction.gasFeeCap, {
52
+ disableRounding: true,
52
53
  showAllDigits: true,
53
54
  }),
54
55
  },
@@ -1,6 +1,7 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { PolkadotAccount, Transaction } from "./types";
3
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
3
+ import { deviceActionFlow } from "../../bot/specs";
4
+ import { formatCurrencyUnit } from "../../currencies";
4
5
 
5
6
  export const acceptTransaction: DeviceAction<Transaction, any> =
6
7
  deviceActionFlow({
@@ -21,10 +22,20 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
21
22
  {
22
23
  title: "Amount",
23
24
  button: "Rr",
24
- expectedValue: ({ account, transaction }) =>
25
- formatDeviceAmount(account.currency, transaction.amount, {
26
- forceFloating: true,
27
- }),
25
+ expectedValue: ({ account, transaction }) => {
26
+ const formattedValue =
27
+ "DOT " +
28
+ formatCurrencyUnit(account.unit, transaction.amount, {
29
+ disableRounding: true,
30
+ });
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
+
37
+ return formattedValue;
38
+ },
28
39
  },
29
40
  {
30
41
  title: "Chain",
@@ -1,6 +1,7 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
3
+ import { formatCurrencyUnit } from "../../currencies";
4
+ import { deviceActionFlow } from "../../bot/specs";
4
5
 
5
6
  export const acceptTransaction: DeviceAction<Transaction, any> =
6
7
  deviceActionFlow({
@@ -14,13 +15,37 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
14
15
  title: "Amount",
15
16
  button: "Rr",
16
17
  expectedValue: ({ account, status }) =>
17
- formatDeviceAmount(account.currency, status.amount),
18
+ formatCurrencyUnit(
19
+ {
20
+ ...account.unit,
21
+ code: account.currency.deviceTicker || account.unit.code,
22
+ prefixCode: true,
23
+ },
24
+ status.amount,
25
+ {
26
+ showCode: true,
27
+ disableRounding: true,
28
+ joinFragmentsSeparator: " ",
29
+ }
30
+ ).replace(/\s/g, " "),
18
31
  },
19
32
  {
20
33
  title: "Fee",
21
34
  button: "Rr",
22
35
  expectedValue: ({ account, status }) =>
23
- formatDeviceAmount(account.currency, status.estimatedFees),
36
+ formatCurrencyUnit(
37
+ {
38
+ ...account.unit,
39
+ code: account.currency.deviceTicker || account.unit.code,
40
+ prefixCode: true,
41
+ },
42
+ status.estimatedFees,
43
+ {
44
+ showCode: true,
45
+ disableRounding: true,
46
+ joinFragmentsSeparator: " ",
47
+ }
48
+ ).replace(/\s/g, " "),
24
49
  },
25
50
  {
26
51
  title: "Destination Tag",
@@ -1,6 +1,7 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
3
+ import { formatCurrencyUnit } from "../../currencies";
4
+ import { deviceActionFlow } from "../../bot/specs";
4
5
  import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
5
6
  import BigNumber from "bignumber.js";
6
7
  import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
@@ -16,11 +17,12 @@ function ellipsis(str: string) {
16
17
  return `${str.slice(0, 7)}..${str.slice(-7)}`;
17
18
  }
18
19
 
19
- function formatAmount(c: CryptoCurrency, amount: number) {
20
- const currency = getMainCurrency(c);
21
- return formatDeviceAmount(currency, new BigNumber(amount), {
22
- postfixCode: true,
23
- });
20
+ function formatAmount(currency: CryptoCurrency, amount: number) {
21
+ const unit = getMainCurrency(currency).units[0];
22
+ return formatCurrencyUnit(unit, new BigNumber(amount), {
23
+ disableRounding: true,
24
+ showCode: true,
25
+ }).replace(/\s/g, " ");
24
26
  }
25
27
 
26
28
  export const acceptTransferTransaction: DeviceAction<Transaction, any> =
@@ -3,7 +3,7 @@ import StellarSdk, {
3
3
  // @ts-expect-error stellar-sdk ts definition missing?
4
4
  AccountRecord,
5
5
  NotFoundError,
6
- NetworkError as StellarSdkNetworkError,
6
+ NetworkError,
7
7
  } from "stellar-sdk";
8
8
  import { getEnv } from "../../../env";
9
9
  import { getCryptoCurrencyById, parseCurrencyUnit } from "../../../currencies";
@@ -14,7 +14,7 @@ import {
14
14
  rawOperationsToOperations,
15
15
  getReservedBalance,
16
16
  } from "../logic";
17
- import { LedgerAPI4xx, LedgerAPI5xx, NetworkError } from "@ledgerhq/errors";
17
+ import { NetworkDown, LedgerAPI4xx, LedgerAPI5xx } from "@ledgerhq/errors";
18
18
  import { requestInterceptor, responseInterceptor } from "../../../network";
19
19
  import type { BalanceAsset } from "../types";
20
20
  import { NetworkCongestionLevel, Signer } from "../types";
@@ -127,12 +127,8 @@ export const fetchAccount = async (
127
127
  assets = account.balances?.filter((balance) => {
128
128
  return balance.asset_type !== "native";
129
129
  });
130
- } catch (e: any) {
131
- if (e instanceof NotFoundError || e?.response?.status === 400) {
132
- balance.balance = "0";
133
- } else {
134
- throw new NetworkError();
135
- }
130
+ } catch (e) {
131
+ balance.balance = "0";
136
132
  }
137
133
 
138
134
  const formattedBalance = parseCurrencyUnit(
@@ -209,11 +205,11 @@ export const fetchOperations = async ({
209
205
  }
210
206
 
211
207
  if (
212
- e instanceof StellarSdkNetworkError ||
208
+ e instanceof NetworkError ||
213
209
  errorMsg.match(/ECONNRESET|ECONNREFUSED|ENOTFOUND|EPIPE|ETIMEDOUT/) ||
214
210
  errorMsg.match(/undefined is not an object/)
215
211
  ) {
216
- throw new NetworkError();
212
+ throw new NetworkDown();
217
213
  }
218
214
 
219
215
  throw e;
@@ -1,11 +1,14 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
2
  import type { Transaction } from "./types";
3
3
  import { formatCurrencyUnit } from "../../currencies";
4
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
4
+ import { deviceActionFlow } from "../../bot/specs";
5
5
 
6
6
  const expectedAmount = ({ account, status, transaction }) => {
7
7
  if (transaction.assetCode && transaction.assetIssuer) {
8
- const amount = formatDeviceAmount(account.currency, status.amount);
8
+ const amount = formatCurrencyUnit(account.unit, status.amount, {
9
+ disableRounding: true,
10
+ useGrouping: false,
11
+ });
9
12
 
10
13
  return `${amount} ${transaction.assetCode}@${truncateAddress(
11
14
  transaction.assetIssuer,
@@ -14,9 +17,12 @@ const expectedAmount = ({ account, status, transaction }) => {
14
17
  )}`;
15
18
  }
16
19
 
17
- return formatDeviceAmount(account.currency, status.amount, {
18
- postfixCode: true,
19
- });
20
+ return (
21
+ formatCurrencyUnit(account.unit, status.amount, {
22
+ disableRounding: true,
23
+ useGrouping: false,
24
+ }) + " XLM"
25
+ );
20
26
  };
21
27
 
22
28
  const truncateAddress = (stellarAddress: string, start = 6, end = 6) =>
@@ -1,7 +1,8 @@
1
1
  // @flow
2
2
  import type { DeviceAction } from "../../bot/types";
3
3
  import type { Transaction } from "./types";
4
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
4
+ import { formatCurrencyUnit } from "../../currencies";
5
+ import { deviceActionFlow } from "../../bot/specs";
5
6
 
6
7
  export const acceptTransaction: DeviceAction<Transaction, any> =
7
8
  deviceActionFlow({
@@ -37,18 +38,24 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
37
38
  {
38
39
  title: "Amount",
39
40
  button: "Rr",
40
- expectedValue: ({ account, transaction }) =>
41
- formatDeviceAmount(account.currency, transaction.amount, {
42
- hideCode: true,
43
- }),
41
+ expectedValue: ({ account, transaction }) => {
42
+ const amount = transaction.amount;
43
+ return formatCurrencyUnit(account.unit, amount, {
44
+ disableRounding: true,
45
+ joinFragmentsSeparator: " ",
46
+ }).replace(/\s/g, " ");
47
+ },
44
48
  },
45
49
  {
46
50
  title: "Fee",
47
51
  button: "Rr",
48
- expectedValue: ({ account, status }) =>
49
- formatDeviceAmount(account.currency, status.estimatedFees, {
50
- hideCode: true,
51
- }),
52
+ expectedValue: ({ account, status }) => {
53
+ const amount = status.estimatedFees;
54
+ return formatCurrencyUnit(account.currency.units[0], amount, {
55
+ disableRounding: true,
56
+ joinFragmentsSeparator: " ",
57
+ }).replace(/\s/g, " ");
58
+ },
52
59
  },
53
60
  {
54
61
  title: "Source",
@@ -1,5 +1,6 @@
1
1
  import type { DeviceAction } from "../../bot/types";
2
- import { deviceActionFlow, formatDeviceAmount } from "../../bot/specs";
2
+ import { deviceActionFlow } from "../../bot/specs";
3
+ import { formatCurrencyUnit } from "../../currencies";
3
4
  import type { Transaction, Vote } from "./types";
4
5
 
5
6
  function subAccount(subAccountId, account) {
@@ -39,9 +40,16 @@ export const acceptTransaction: DeviceAction<Transaction, any> =
39
40
  title: "Amount",
40
41
  button: "Rr",
41
42
  expectedValue: ({ account, status }) =>
42
- formatDeviceAmount(account.currency, status.amount, {
43
- hideCode: true,
44
- }),
43
+ formatCurrencyUnit(
44
+ {
45
+ ...account.unit,
46
+ code: account.currency.deviceTicker || account.unit.code,
47
+ },
48
+ status.amount,
49
+ {
50
+ disableRounding: true,
51
+ }
52
+ ),
45
53
  },
46
54
  {
47
55
  title: "Token",
@@ -109,7 +109,4 @@ export const defaultFeatures: DefaultFeatures = {
109
109
  ptxSmartRoutingMobile: {
110
110
  enabled: false,
111
111
  },
112
- mockFeature: {
113
- enabled: false,
114
- },
115
112
  };