@ledgerhq/live-common 27.3.2 → 27.4.0-next.1

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 (258) hide show
  1. package/lib/__tests__/environment.test.d.ts +2 -0
  2. package/lib/__tests__/environment.test.d.ts.map +1 -0
  3. package/lib/__tests__/environment.test.js +13 -0
  4. package/lib/__tests__/environment.test.js.map +1 -0
  5. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js +0 -31
  6. package/lib/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.js.map +1 -1
  7. package/lib/account/support.d.ts.map +1 -1
  8. package/lib/account/support.js +3 -2
  9. package/lib/account/support.js.map +1 -1
  10. package/lib/apps/hw.d.ts +4 -1
  11. package/lib/apps/hw.d.ts.map +1 -1
  12. package/lib/apps/hw.js +10 -4
  13. package/lib/apps/hw.js.map +1 -1
  14. package/lib/apps/mock.d.ts +1 -0
  15. package/lib/apps/mock.d.ts.map +1 -1
  16. package/lib/apps/mock.js +24 -2
  17. package/lib/apps/mock.js.map +1 -1
  18. package/lib/apps/runner.d.ts +8 -1
  19. package/lib/apps/runner.d.ts.map +1 -1
  20. package/lib/apps/runner.js +15 -3
  21. package/lib/apps/runner.js.map +1 -1
  22. package/lib/apps/support.js +1 -1
  23. package/lib/bot/engine.d.ts.map +1 -1
  24. package/lib/bot/engine.js +5 -2
  25. package/lib/bot/engine.js.map +1 -1
  26. package/lib/bot/index.d.ts.map +1 -1
  27. package/lib/bot/index.js +5 -3
  28. package/lib/bot/index.js.map +1 -1
  29. package/lib/bot/types.d.ts +2 -0
  30. package/lib/bot/types.d.ts.map +1 -1
  31. package/lib/data/icons/react/index.d.ts +1 -0
  32. package/lib/data/icons/react/index.d.ts.map +1 -1
  33. package/lib/data/icons/react/index.js +3 -1
  34. package/lib/data/icons/react/index.js.map +1 -1
  35. package/lib/data/icons/react/yae.d.ts +8 -0
  36. package/lib/data/icons/react/yae.d.ts.map +1 -0
  37. package/lib/data/icons/react/yae.js +36 -0
  38. package/lib/data/icons/react/yae.js.map +1 -0
  39. package/lib/data/icons/reactNative/index.d.ts +1 -0
  40. package/lib/data/icons/reactNative/index.d.ts.map +1 -1
  41. package/lib/data/icons/reactNative/index.js +3 -1
  42. package/lib/data/icons/reactNative/index.js.map +1 -1
  43. package/lib/data/icons/reactNative/yae.d.ts +8 -0
  44. package/lib/data/icons/reactNative/yae.d.ts.map +1 -0
  45. package/lib/data/icons/reactNative/yae.js +37 -0
  46. package/lib/data/icons/reactNative/yae.js.map +1 -0
  47. package/lib/exchange/hw-app-exchange/Exchange.js +4 -4
  48. package/lib/families/bitcoin/account.d.ts.map +1 -1
  49. package/lib/families/bitcoin/bech32m.d.ts +2 -8
  50. package/lib/families/bitcoin/bech32m.d.ts.map +1 -1
  51. package/lib/families/bitcoin/bridge/js.d.ts.map +1 -1
  52. package/lib/families/bitcoin/bridge/js.js.map +1 -1
  53. package/lib/families/bitcoin/bridge/mock.d.ts.map +1 -1
  54. package/lib/families/bitcoin/bridge/mock.js.map +1 -1
  55. package/lib/families/bitcoin/cache.d.ts +2 -15
  56. package/lib/families/bitcoin/cache.d.ts.map +1 -1
  57. package/lib/families/bitcoin/js-getFeesForTransaction.d.ts +2 -15
  58. package/lib/families/bitcoin/js-getFeesForTransaction.d.ts.map +1 -1
  59. package/lib/families/bitcoin/js-synchronisation.d.ts.map +1 -1
  60. package/lib/families/bitcoin/js-synchronisation.js.map +1 -1
  61. package/lib/families/bitcoin/logic.d.ts +1 -1
  62. package/lib/families/bitcoin/logic.d.ts.map +1 -1
  63. package/lib/families/bitcoin/logic.js.map +1 -1
  64. package/lib/families/bitcoin/presync.d.ts.map +1 -1
  65. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts +0 -2
  66. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
  67. package/lib/families/bitcoin/wallet-btc/crypto/base.js +0 -16
  68. package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
  69. package/lib/families/bitcoin/wallet-btc/crypto/bip32.d.ts +4 -3
  70. package/lib/families/bitcoin/wallet-btc/crypto/bip32.d.ts.map +1 -1
  71. package/lib/families/bitcoin/wallet-btc/crypto/bip32.js +3 -1
  72. package/lib/families/bitcoin/wallet-btc/crypto/bip32.js.map +1 -1
  73. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts +2 -3
  74. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts.map +1 -1
  75. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +0 -7
  76. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
  77. package/lib/families/bitcoin/wallet-btc/crypto/factory.d.ts.map +1 -1
  78. package/lib/families/bitcoin/wallet-btc/crypto/factory.js +0 -3
  79. package/lib/families/bitcoin/wallet-btc/crypto/factory.js.map +1 -1
  80. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.d.ts +2 -3
  81. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.d.ts.map +1 -1
  82. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js +0 -16
  83. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js.map +1 -1
  84. package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts +0 -1
  85. package/lib/families/bitcoin/wallet-btc/crypto/types.d.ts.map +1 -1
  86. package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts +0 -2
  87. package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
  88. package/lib/families/bitcoin/wallet-btc/crypto/zec.js +0 -5
  89. package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
  90. package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts +0 -2
  91. package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
  92. package/lib/families/bitcoin/wallet-btc/crypto/zen.js +0 -5
  93. package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
  94. package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts +11 -5
  95. package/lib/families/bitcoin/wallet-btc/explorer/index.d.ts.map +1 -1
  96. package/lib/families/bitcoin/wallet-btc/explorer/index.js +8 -40
  97. package/lib/families/bitcoin/wallet-btc/explorer/index.js.map +1 -1
  98. package/lib/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.d.ts +1 -1
  99. package/lib/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.d.ts.map +1 -1
  100. package/lib/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.js.map +1 -1
  101. package/lib/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.d.ts +1 -1
  102. package/lib/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.d.ts.map +1 -1
  103. package/lib/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.js.map +1 -1
  104. package/lib/families/bitcoin/wallet-btc/pickingstrategies/Merge.d.ts +1 -1
  105. package/lib/families/bitcoin/wallet-btc/pickingstrategies/Merge.d.ts.map +1 -1
  106. package/lib/families/bitcoin/wallet-btc/pickingstrategies/Merge.js.map +1 -1
  107. package/lib/families/bitcoin/wallet-btc/storage/index.d.ts +1 -5
  108. package/lib/families/bitcoin/wallet-btc/storage/index.d.ts.map +1 -1
  109. package/lib/families/bitcoin/wallet-btc/storage/index.js +7 -9
  110. package/lib/families/bitcoin/wallet-btc/storage/index.js.map +1 -1
  111. package/lib/families/bitcoin/wallet-btc/utils.d.ts +3 -3
  112. package/lib/families/bitcoin/wallet-btc/utils.d.ts.map +1 -1
  113. package/lib/families/bitcoin/wallet-btc/utils.js +2 -11
  114. package/lib/families/bitcoin/wallet-btc/utils.js.map +1 -1
  115. package/lib/families/bitcoin/wallet-btc/wallet.d.ts +10 -7
  116. package/lib/families/bitcoin/wallet-btc/wallet.d.ts.map +1 -1
  117. package/lib/families/bitcoin/wallet-btc/wallet.js +1 -18
  118. package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
  119. package/lib/families/bitcoin/wallet-btc/xpub.d.ts +1 -9
  120. package/lib/families/bitcoin/wallet-btc/xpub.d.ts.map +1 -1
  121. package/lib/families/bitcoin/wallet-btc/xpub.js +60 -208
  122. package/lib/families/bitcoin/wallet-btc/xpub.js.map +1 -1
  123. package/lib/families/cardano/js-synchronisation.js +1 -1
  124. package/lib/families/cardano/js-synchronisation.js.map +1 -1
  125. package/lib/families/cardano/specs.js +1 -1
  126. package/lib/families/celo/specs/createSendMutation.d.ts.map +1 -1
  127. package/lib/families/celo/specs/createSendMutation.js +0 -2
  128. package/lib/families/celo/specs/createSendMutation.js.map +1 -1
  129. package/lib/families/celo/specs.js +1 -1
  130. package/lib/families/crypto_org/specs.d.ts.map +1 -1
  131. package/lib/families/crypto_org/specs.js +3 -2
  132. package/lib/families/crypto_org/specs.js.map +1 -1
  133. package/lib/families/ethereum/specs.js +3 -3
  134. package/lib/families/ethereum/specs.js.map +1 -1
  135. package/lib/families/evm/specs.js +6 -6
  136. package/lib/families/evm/specs.js.map +1 -1
  137. package/lib/families/filecoin/specs.d.ts.map +1 -1
  138. package/lib/families/filecoin/specs.js +1 -2
  139. package/lib/families/filecoin/specs.js.map +1 -1
  140. package/lib/families/hedera/api/network.d.ts.map +1 -1
  141. package/lib/families/hedera/api/network.js +16 -8
  142. package/lib/families/hedera/api/network.js.map +1 -1
  143. package/lib/families/hedera/errors.d.ts +4 -0
  144. package/lib/families/hedera/errors.d.ts.map +1 -0
  145. package/lib/families/hedera/errors.js +6 -0
  146. package/lib/families/hedera/errors.js.map +1 -0
  147. package/lib/families/hedera/specs.d.ts.map +1 -1
  148. package/lib/families/hedera/specs.js +0 -11
  149. package/lib/families/hedera/specs.js.map +1 -1
  150. package/lib/families/osmosis/specs.js +1 -1
  151. package/lib/families/polkadot/specs.d.ts.map +1 -1
  152. package/lib/families/polkadot/specs.js +1 -0
  153. package/lib/families/polkadot/specs.js.map +1 -1
  154. package/lib/families/solana/specs.d.ts.map +1 -1
  155. package/lib/families/solana/specs.js +1 -0
  156. package/lib/families/solana/specs.js.map +1 -1
  157. package/lib/families/tezos/bakers.whitelist-default.d.ts.map +1 -1
  158. package/lib/families/tezos/bakers.whitelist-default.js +1 -1
  159. package/lib/families/tezos/bakers.whitelist-default.js.map +1 -1
  160. package/lib/families/tezos/bridge/js.d.ts.map +1 -1
  161. package/lib/families/tezos/bridge/js.js +2 -1
  162. package/lib/families/tezos/bridge/js.js.map +1 -1
  163. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  164. package/lib/featureFlags/defaultFeatures.js +6 -0
  165. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  166. package/lib/hw/actions/app.d.ts +7 -0
  167. package/lib/hw/actions/app.d.ts.map +1 -1
  168. package/lib/hw/actions/app.js +25 -11
  169. package/lib/hw/actions/app.js.map +1 -1
  170. package/lib/hw/connectApp.d.ts +4 -0
  171. package/lib/hw/connectApp.d.ts.map +1 -1
  172. package/lib/hw/connectApp.js +10 -1
  173. package/lib/hw/connectApp.js.map +1 -1
  174. package/lib/manager/localization.d.ts +1 -1
  175. package/lib/manager/localization.d.ts.map +1 -1
  176. package/lib/manager/localization.js +1 -1
  177. package/lib/manager/localization.js.map +1 -1
  178. package/lib/rxjs/operators/retryWithDelay.d.ts +12 -0
  179. package/lib/rxjs/operators/retryWithDelay.d.ts.map +1 -0
  180. package/lib/rxjs/operators/retryWithDelay.js +28 -0
  181. package/lib/rxjs/operators/retryWithDelay.js.map +1 -0
  182. package/lib/rxjs/operators/throwIf.d.ts +23 -0
  183. package/lib/rxjs/operators/throwIf.d.ts.map +1 -0
  184. package/lib/rxjs/operators/throwIf.js +37 -0
  185. package/lib/rxjs/operators/throwIf.js.map +1 -0
  186. package/package.json +5 -5
  187. package/src/__tests__/environment.test.ts +12 -0
  188. package/src/__tests__/families/bitcoin/wallet-btc/xpub.syncing.integration.test.ts +0 -33
  189. package/src/account/support.ts +3 -2
  190. package/src/apps/hw.ts +17 -4
  191. package/src/apps/mock.ts +24 -2
  192. package/src/apps/runner.ts +28 -4
  193. package/src/apps/support.ts +1 -1
  194. package/src/bot/engine.ts +9 -1
  195. package/src/bot/index.ts +7 -2
  196. package/src/bot/types.ts +3 -0
  197. package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +33 -0
  198. package/src/data/icons/react/index.tsx +1 -0
  199. package/src/data/icons/react/yae.tsx +14 -0
  200. package/src/data/icons/reactNative/index.tsx +1 -0
  201. package/src/data/icons/reactNative/yae.tsx +15 -0
  202. package/src/data/icons/svg/YAE.svg +4 -0
  203. package/src/exchange/hw-app-exchange/Exchange.ts +4 -4
  204. package/src/families/algorand/__snapshots__/bridge.integration.test.ts.snap +807 -27
  205. package/src/families/bitcoin/account.ts +1 -1
  206. package/src/families/bitcoin/bech32m.ts +2 -2
  207. package/src/families/bitcoin/bridge/js.ts +6 -3
  208. package/src/families/bitcoin/bridge/mock.ts +6 -2
  209. package/src/families/bitcoin/js-getFeesForTransaction.ts +1 -1
  210. package/src/families/bitcoin/js-synchronisation.ts +0 -1
  211. package/src/families/bitcoin/logic.ts +5 -2
  212. package/src/families/bitcoin/presync.ts +1 -1
  213. package/src/families/bitcoin/specs.ts +1 -1
  214. package/src/families/bitcoin/wallet-btc/crypto/base.ts +0 -20
  215. package/src/families/bitcoin/wallet-btc/crypto/bip32.ts +6 -5
  216. package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +1 -9
  217. package/src/families/bitcoin/wallet-btc/crypto/factory.ts +1 -4
  218. package/src/families/bitcoin/wallet-btc/crypto/litecoin.ts +1 -20
  219. package/src/families/bitcoin/wallet-btc/crypto/types.ts +0 -3
  220. package/src/families/bitcoin/wallet-btc/crypto/zec.ts +1 -7
  221. package/src/families/bitcoin/wallet-btc/crypto/zen.ts +1 -7
  222. package/src/families/bitcoin/wallet-btc/explorer/index.ts +24 -49
  223. package/src/families/bitcoin/wallet-btc/pickingstrategies/CoinSelect.ts +6 -1
  224. package/src/families/bitcoin/wallet-btc/pickingstrategies/DeepFirst.ts +6 -1
  225. package/src/families/bitcoin/wallet-btc/pickingstrategies/Merge.ts +6 -1
  226. package/src/families/bitcoin/wallet-btc/storage/index.ts +34 -20
  227. package/src/families/bitcoin/wallet-btc/utils.ts +16 -21
  228. package/src/families/bitcoin/wallet-btc/wallet.ts +17 -31
  229. package/src/families/bitcoin/wallet-btc/xpub.ts +41 -150
  230. package/src/families/cardano/js-synchronisation.ts +1 -1
  231. package/src/families/cardano/specs.ts +1 -1
  232. package/src/families/celo/specs/createSendMutation.ts +1 -3
  233. package/src/families/celo/specs.ts +1 -1
  234. package/src/families/crypto_org/specs.ts +3 -2
  235. package/src/families/ethereum/specs.ts +3 -3
  236. package/src/families/evm/specs.ts +6 -6
  237. package/src/families/filecoin/__snapshots__/bridge.integration.test.ts.snap +24 -2
  238. package/src/families/filecoin/specs.ts +1 -2
  239. package/src/families/hedera/api/network.ts +10 -3
  240. package/src/families/hedera/errors.ts +5 -0
  241. package/src/families/hedera/specs.ts +0 -17
  242. package/src/families/osmosis/__snapshots__/bridge.integration.test.ts.snap +101 -3
  243. package/src/families/osmosis/specs.ts +1 -1
  244. package/src/families/polkadot/specs.ts +1 -0
  245. package/src/families/solana/specs.ts +1 -0
  246. package/src/families/tezos/bakers.whitelist-default.ts +0 -2
  247. package/src/families/tezos/bridge/js.ts +4 -1
  248. package/src/featureFlags/defaultFeatures.ts +6 -0
  249. package/src/hw/actions/app.ts +35 -4
  250. package/src/hw/connectApp.ts +18 -1
  251. package/src/manager/localization.ts +2 -2
  252. package/src/rxjs/operators/retryWithDelay.ts +36 -0
  253. package/src/rxjs/operators/throwIf.ts +40 -0
  254. package/lib/families/bitcoin/wallet-btc/utils/eventemitter.d.ts +0 -6
  255. package/lib/families/bitcoin/wallet-btc/utils/eventemitter.d.ts.map +0 -1
  256. package/lib/families/bitcoin/wallet-btc/utils/eventemitter.js +0 -64
  257. package/lib/families/bitcoin/wallet-btc/utils/eventemitter.js.map +0 -1
  258. package/src/families/bitcoin/wallet-btc/utils/eventemitter.ts +0 -9
@@ -5,7 +5,7 @@ import { perCoinLogic } from "./logic";
5
5
 
6
6
  const sortUTXO = (a, b) => b.value.minus(a.value).toNumber();
7
7
 
8
- function injectGetAddressParams(account: BitcoinAccount) {
8
+ function injectGetAddressParams(account: BitcoinAccount): any {
9
9
  const perCoin = perCoinLogic[account.currency.id];
10
10
 
11
11
  if (perCoin && perCoin.injectGetAddressParams) {
@@ -114,12 +114,12 @@ function __decode(str: string, LIMIT?: number) {
114
114
  return { prefix, words };
115
115
  }
116
116
 
117
- function decodeUnsafe(str: string, LIMIT?: number) {
117
+ function decodeUnsafe(str: string, LIMIT?: number): any {
118
118
  const res = __decode(str, LIMIT);
119
119
  if (typeof res === "object") return res;
120
120
  }
121
121
 
122
- function decode(str: string, LIMIT?: number) {
122
+ function decode(str: string, LIMIT?: number): any {
123
123
  const res = __decode(str, LIMIT);
124
124
  if (typeof res === "object") return res;
125
125
 
@@ -11,6 +11,7 @@ import { perCoinLogic } from "../logic";
11
11
  import { makeAccountBridgeReceive } from "../../../bridge/jsHelpers";
12
12
  import * as explorerConfigAPI from "../../../api/explorerConfig";
13
13
  import { AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
14
+ import { FullConfigOverrides } from "../../../api/explorerConfig/types";
14
15
 
15
16
  const receive = makeAccountBridgeReceive({
16
17
  injectGetAddressParams: (account) => {
@@ -22,7 +23,7 @@ const receive = makeAccountBridgeReceive({
22
23
  },
23
24
  });
24
25
 
25
- const updateTransaction = (t, patch) => {
26
+ const updateTransaction = (t, patch): any => {
26
27
  const updatedT = { ...t, ...patch };
27
28
 
28
29
  // We accept case-insensitive addresses as input from user,
@@ -34,14 +35,16 @@ const updateTransaction = (t, patch) => {
34
35
  return updatedT;
35
36
  };
36
37
 
37
- const preload = async () => {
38
+ const preload = async (): Promise<{
39
+ explorerConfig: FullConfigOverrides | null | undefined;
40
+ }> => {
38
41
  const explorerConfig = await explorerConfigAPI.preload();
39
42
  return {
40
43
  explorerConfig,
41
44
  };
42
45
  };
43
46
 
44
- const hydrate = (maybeConfig: any) => {
47
+ const hydrate = (maybeConfig: any): void => {
45
48
  if (
46
49
  typeof maybeConfig === "object" &&
47
50
  maybeConfig &&
@@ -37,9 +37,13 @@ const createTransaction = (): Transaction => ({
37
37
  },
38
38
  });
39
39
 
40
- const updateTransaction = (t, patch) => ({ ...t, ...patch });
40
+ const updateTransaction = (t, patch): any => ({ ...t, ...patch });
41
41
 
42
- const estimateMaxSpendable = ({ account, parentAccount, transaction }) => {
42
+ const estimateMaxSpendable = ({
43
+ account,
44
+ parentAccount,
45
+ transaction,
46
+ }): Promise<BigNumber> => {
43
47
  const mainAccount = getMainAccount(account, parentAccount);
44
48
  const estimatedFees = transaction
45
49
  ? defaultGetFees(mainAccount, transaction)
@@ -10,7 +10,7 @@ const getFeesForTransaction = async ({
10
10
  }: {
11
11
  account: Account;
12
12
  transaction: Transaction;
13
- }) => {
13
+ }): Promise<{ fees: BigNumber; txInputs: any; txOutputs: any }> => {
14
14
  const walletTx = await buildTransaction(account, transaction);
15
15
  const fees = new BigNumber(walletTx.fee).integerValue();
16
16
  let txInputs = walletTx.inputs.map((i) => {
@@ -164,7 +164,6 @@ const getAccountShape: GetAccountShape = async (info) => {
164
164
  const blockHeight = currentBlock?.height;
165
165
 
166
166
  span = startSpan("sync", "getAccountTransactions");
167
- // @ts-expect-error return from wallet-btc should be typed
168
167
  const { txs: transactions } = await wallet.getAccountTransactions(
169
168
  walletAccount
170
169
  );
@@ -35,7 +35,10 @@ const minFees = {
35
35
  };
36
36
  export const getMinRelayFee = (currency: CryptoCurrency): number =>
37
37
  minFees[currency.id] || 0;
38
- export const inferFeePerByte = (t: Transaction, networkInfo: NetworkInfo) => {
38
+ export const inferFeePerByte = (
39
+ t: Transaction,
40
+ networkInfo: NetworkInfo
41
+ ): BigNumber => {
39
42
  if (t.feesStrategy) {
40
43
  const speed = networkInfo.feeItems.items.find(
41
44
  (item) => t.feesStrategy === item.speed
@@ -137,7 +140,7 @@ type CoinLogic = {
137
140
  injectGetAddressParams?: (arg0: Account) => any;
138
141
  };
139
142
 
140
- export const bchToCashaddrAddressWithoutPrefix = (recipient) =>
143
+ export const bchToCashaddrAddressWithoutPrefix = (recipient): string =>
141
144
  recipient ? recipient.substring(recipient.indexOf(":") + 1) : recipient;
142
145
 
143
146
  export const perCoinLogic: Record<
@@ -1,6 +1,6 @@
1
1
  import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
2
2
  import { requiresSatStackReady } from "./satstack";
3
- export default async function presync(currency: CryptoCurrency) {
3
+ export default async function presync(currency: CryptoCurrency): Promise<void> {
4
4
  if (currency.id === "bitcoin") {
5
5
  await requiresSatStackReady();
6
6
  }
@@ -56,7 +56,7 @@ const genericTest = ({
56
56
  transaction,
57
57
  status,
58
58
  accountBeforeTransaction,
59
- }) => {
59
+ }): void => {
60
60
  invariant(
61
61
  Date.now() - operation.date < 1000000,
62
62
  "operation time to be recent"
@@ -1,8 +1,6 @@
1
1
  // from https://github.com/LedgerHQ/xpub-scan/blob/master/src/actions/deriveAddresses.ts
2
2
 
3
3
  import * as bjs from "bitcoinjs-lib";
4
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
- // @ts-ignore
6
4
  import { toOutputScript } from "bitcoinjs-lib/src/address";
7
5
  import bs58check from "bs58check";
8
6
  import { DerivationModes } from "../types";
@@ -27,12 +25,10 @@ export function fallbackValidateAddress(address: string): boolean {
27
25
  }
28
26
 
29
27
  class Base implements ICrypto {
30
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
28
  network: any;
32
29
  protected static bip32Cache = {}; // xpub + account + index to publicKey
33
30
  public static addressCache = {}; // derivationMode + xpub + account + index to address
34
31
 
35
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
32
  constructor({ network }: { network: any }) {
37
33
  this.network = network;
38
34
  this.network.dustThreshold = 3000;
@@ -181,22 +177,6 @@ class Base implements ICrypto {
181
177
  }
182
178
  }
183
179
 
184
- // infer address type from its syntax
185
- getDerivationMode(address: string): DerivationModes {
186
- if (address.match("^(bc1|tb1).*")) {
187
- return DerivationModes.NATIVE_SEGWIT;
188
- }
189
- if (address.match("^(3|2|M).*")) {
190
- return DerivationModes.SEGWIT;
191
- }
192
- if (address.match("^(1|n|m|L).*")) {
193
- return DerivationModes.LEGACY;
194
- }
195
- throw new Error(
196
- "INVALID ADDRESS: ".concat(address).concat(" is not a valid address")
197
- );
198
- }
199
-
200
180
  toOutputScript(address: string): Buffer {
201
181
  return toOutputScript(address, this.network);
202
182
  }
@@ -4,14 +4,15 @@ import { getSecp256k1Instance } from "./secp256k1";
4
4
 
5
5
  // the BIP32 class is inspired from https://github.com/bitcoinjs/bip32/blob/master/src/bip32.js
6
6
  class BIP32 {
7
- publicKey: any;
8
- chainCode: any;
7
+ publicKey: Buffer;
8
+ chainCode: Buffer;
9
9
  network: any;
10
10
  depth: number;
11
11
  index: number;
12
12
  constructor(
13
- publicKey: any,
14
- chainCode: any,
13
+ publicKey: Buffer,
14
+ chainCode: Buffer,
15
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
15
16
  network: any,
16
17
  depth = 0,
17
18
  index = 0
@@ -24,7 +25,7 @@ class BIP32 {
24
25
  this.depth = depth;
25
26
  this.index = index;
26
27
  }
27
- async derive(index: number) {
28
+ async derive(index: number): Promise<BIP32> {
28
29
  const data = Buffer.allocUnsafe(37);
29
30
  this.publicKey.copy(data, 0);
30
31
  data.writeUInt32BE(index, 33);
@@ -1,9 +1,6 @@
1
1
  import bchaddr from "bchaddrjs";
2
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
- // @ts-ignore
4
2
  import { toOutputScript } from "bitcoinjs-lib/src/address";
5
3
  import { InvalidAddress } from "@ledgerhq/errors";
6
- import { DerivationModes } from "../types";
7
4
  import Base from "./base";
8
5
 
9
6
  // a mock explorer class that just use js objects
@@ -41,12 +38,7 @@ class BitcoinCash extends Base {
41
38
  return await this.getLegacyBitcoinCashAddress(xpub, account, index);
42
39
  }
43
40
 
44
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
45
- getDerivationMode(address: string) {
46
- return DerivationModes.LEGACY;
47
- }
48
-
49
- toOutputScript(address: string) {
41
+ toOutputScript(address: string): Buffer {
50
42
  if (!this.validateAddress(address)) {
51
43
  throw new InvalidAddress();
52
44
  }
@@ -1,11 +1,8 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
- // @ts-ignore
4
1
  import coininfo from "coininfo";
5
2
  import { Currency, ICrypto } from "./types";
6
3
  import * as crypto from "./index";
7
4
 
8
- export default function cryptoFactory(currency: Currency) {
5
+ export default function cryptoFactory(currency: Currency): ICrypto {
9
6
  let res: ICrypto;
10
7
  switch (currency) {
11
8
  case "bitcoin": {
@@ -1,8 +1,5 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-ignore
3
1
  import { toOutputScript } from "bitcoinjs-lib/src/address";
4
2
  import * as bech32 from "bech32";
5
- import { DerivationModes } from "../types";
6
3
  import Base from "./base";
7
4
 
8
5
  // Todo copy paste from bitcoin.ts. we can merge them later
@@ -18,23 +15,7 @@ class Litecoin extends Base {
18
15
  this.network.usesTimestampedTransaction = false;
19
16
  }
20
17
 
21
- // infer address type from its syntax
22
- getDerivationMode(address: string) {
23
- if (address.match("^(ltc1).*")) {
24
- return DerivationModes.NATIVE_SEGWIT;
25
- }
26
- if (address.match("^(3|2|M).*")) {
27
- return DerivationModes.SEGWIT;
28
- }
29
- if (address.match("^(1|n|m|L).*")) {
30
- return DerivationModes.LEGACY;
31
- }
32
- throw new Error(
33
- "INVALID ADDRESS: ".concat(address).concat(" is not a valid address")
34
- );
35
- }
36
-
37
- toOutputScript(address: string) {
18
+ toOutputScript(address: string): Buffer {
38
19
  return toOutputScript(address, this.network);
39
20
  }
40
21
 
@@ -13,9 +13,6 @@ export interface ICrypto {
13
13
  account: number,
14
14
  index: number
15
15
  ): Promise<string>;
16
-
17
- getDerivationMode(address: string): string;
18
-
19
16
  toOutputScript(address: string): Buffer;
20
17
  validateAddress(address: string): boolean;
21
18
  isTaprootAddress(address: string): boolean;
@@ -1,7 +1,6 @@
1
1
  import bs58check from "bs58check";
2
2
  import * as bjs from "bitcoinjs-lib";
3
3
  import { InvalidAddress } from "@ledgerhq/errors";
4
- import { DerivationModes } from "../types";
5
4
  import Base from "./base";
6
5
 
7
6
  class ZCash extends Base {
@@ -44,12 +43,7 @@ class ZCash extends Base {
44
43
  return await this.getLegacyAddress(xpub, account, index);
45
44
  }
46
45
 
47
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
- getDerivationMode(address: string) {
49
- return DerivationModes.LEGACY;
50
- }
51
-
52
- toOutputScript(address: string) {
46
+ toOutputScript(address: string): Buffer {
53
47
  if (!this.validateAddress(address)) {
54
48
  throw new InvalidAddress();
55
49
  }
@@ -1,6 +1,5 @@
1
1
  import bs58check from "bs58check";
2
2
  import { InvalidAddress } from "@ledgerhq/errors";
3
- import { DerivationModes } from "../types";
4
3
  import Base from "./base";
5
4
  import * as bjs from "bitcoinjs-lib";
6
5
 
@@ -62,12 +61,7 @@ class Zen extends Base {
62
61
  return await this.getLegacyAddress(xpub, account, index);
63
62
  }
64
63
 
65
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
66
- getDerivationMode(address: string) {
67
- return DerivationModes.LEGACY;
68
- }
69
-
70
- toOutputScript(address: string) {
64
+ toOutputScript(address: string): Buffer {
71
65
  if (!this.validateAddress(address)) {
72
66
  throw new InvalidAddress();
73
67
  }
@@ -6,7 +6,6 @@ import genericPool, { Pool } from "generic-pool";
6
6
 
7
7
  import JSONBigNumber from "@ledgerhq/json-bignumber";
8
8
  import { Address, Block, TX } from "../storage/types";
9
- import EventEmitter from "../utils/eventemitter";
10
9
  import { IExplorer } from "./types";
11
10
  import {
12
11
  requestInterceptor,
@@ -14,7 +13,15 @@ import {
14
13
  errorInterceptor,
15
14
  } from "../../../../network";
16
15
 
17
- class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
16
+ type ExplorerParams = {
17
+ no_token?: string;
18
+ noToken?: string;
19
+ batch_size?: number;
20
+ block_hash?: string;
21
+ blockHash?: string;
22
+ };
23
+
24
+ class BitcoinLikeExplorer implements IExplorer {
18
25
  client: Pool<{ client: AxiosInstance }>;
19
26
 
20
27
  underlyingClient: AxiosInstance;
@@ -32,8 +39,6 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
32
39
  explorerVersion: "v2" | "v3";
33
40
  disableBatchSize?: boolean;
34
41
  }) {
35
- super();
36
-
37
42
  const clientParams: AxiosRequestConfig = {
38
43
  baseURL: explorerURI,
39
44
  };
@@ -82,7 +87,7 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
82
87
  client.interceptors.response.use(responseInterceptor, errorInterceptor);
83
88
  }
84
89
 
85
- async broadcast(tx: string) {
90
+ async broadcast(tx: string): Promise<any> {
86
91
  const url = "/transactions/send";
87
92
  const client = await this.client.acquire();
88
93
  const res = await client.client.post(url, { tx });
@@ -90,32 +95,24 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
90
95
  return res;
91
96
  }
92
97
 
93
- async getTxHex(txId: string) {
98
+ async getTxHex(txId: string): Promise<string> {
94
99
  const url = `/transactions/${txId}/hex`;
95
100
 
96
- this.emit("fetching-transaction-tx", { url, txId });
97
-
98
101
  // TODO add a test for failure (at the sync level)
99
102
  const client = await this.client.acquire();
100
103
  const res: any = (await client.client.get(url)).data;
101
104
  await this.client.release(client);
102
105
 
103
- this.emit("fetched-transaction-tx", { url, tx: res[0] });
104
-
105
106
  return res[0].hex;
106
107
  }
107
108
 
108
- async getCurrentBlock() {
109
+ async getCurrentBlock(): Promise<Block | null> {
109
110
  const url = `/blocks/current`;
110
111
 
111
- this.emit("fetching-block", { url });
112
-
113
112
  const client = await this.client.acquire();
114
113
  const res: any = (await client.client.get(url)).data;
115
114
  await this.client.release(client);
116
115
 
117
- this.emit("fetched-block", { url, block: res });
118
-
119
116
  if (!res) {
120
117
  return null;
121
118
  }
@@ -129,17 +126,13 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
129
126
  return block;
130
127
  }
131
128
 
132
- async getBlockByHeight(height: number) {
129
+ async getBlockByHeight(height: number): Promise<Block | null> {
133
130
  const url = `/blocks/${height}`;
134
131
 
135
- this.emit("fetching-block", { url, height });
136
-
137
132
  const client = await this.client.acquire();
138
133
  const res: any = (await client.client.get(url)).data;
139
134
  await this.client.release(client);
140
135
 
141
- this.emit("fetched-block", { url, block: res[0] });
142
-
143
136
  if (!res[0]) {
144
137
  return null;
145
138
  }
@@ -153,36 +146,26 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
153
146
  return block;
154
147
  }
155
148
 
156
- async getFees() {
149
+ async getFees(): Promise<any> {
157
150
  const url = `/fees`;
158
151
 
159
- this.emit("fetching-fees", { url });
160
-
161
152
  // TODO add a test for failure (at the sync level)
162
153
  const client = await this.client.acquire();
163
154
  const fees = (await client.client.get(url)).data;
164
155
  await this.client.release(client);
165
156
 
166
- this.emit("fetching-fees", { url, fees });
167
-
168
157
  return fees;
169
158
  }
170
159
 
171
- async getRelayFee() {
160
+ async getRelayFee(): Promise<number> {
172
161
  const client = await this.client.acquire();
173
162
  const fees = (await client.client.get(`/network`)).data;
174
163
  await this.client.release(client);
175
164
  return parseFloat(fees["relay_fee"]);
176
165
  }
177
166
 
178
- async getPendings(address: Address, nbMax?: number) {
179
- const params: {
180
- no_token?: string;
181
- noToken?: string;
182
- batch_size?: number;
183
- block_hash?: string;
184
- blockHash?: string;
185
- } =
167
+ async getPendings(address: Address, nbMax?: number): Promise<TX[]> {
168
+ const params: ExplorerParams =
186
169
  this.explorerVersion === "v2"
187
170
  ? {
188
171
  noToken: "true",
@@ -199,12 +182,12 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
199
182
  return pendingsTxs;
200
183
  }
201
184
 
202
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
203
- async fetchTxs(address: Address, params: any) {
185
+ async fetchTxs(
186
+ address: Address,
187
+ params: ExplorerParams
188
+ ): Promise<{ txs: TX[] }> {
204
189
  const url = `/addresses/${address.address}/transactions`;
205
190
 
206
- this.emit("fetching-address-transaction", { url, params });
207
-
208
191
  // TODO add a test for failure (at the sync level)
209
192
  const client = await this.client.acquire();
210
193
  let res: { txs: TX[] } = { txs: [] };
@@ -229,12 +212,10 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
229
212
  } finally {
230
213
  await this.client.release(client);
231
214
  }
232
- this.emit("fetched-address-transaction", { url, params, res });
233
215
  return res;
234
216
  }
235
217
 
236
- // eslint-disable-next-line class-methods-use-this,@typescript-eslint/no-explicit-any
237
- hydrateTx(address: Address, tx: TX) {
218
+ hydrateTx(address: Address, tx: TX): void {
238
219
  // no need to keep those as they change
239
220
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
240
221
  // @ts-ignore
@@ -281,14 +262,8 @@ class BitcoinLikeExplorer extends EventEmitter implements IExplorer {
281
262
  batchSize: number,
282
263
  address: Address,
283
264
  lastTx: TX | undefined
284
- ) {
285
- const params: {
286
- no_token?: string;
287
- noToken?: string;
288
- batch_size?: number;
289
- block_hash?: string;
290
- blockHash?: string;
291
- } =
265
+ ): Promise<TX[]> {
266
+ const params: ExplorerParams =
292
267
  this.explorerVersion === "v2"
293
268
  ? {
294
269
  noToken: "true",
@@ -15,7 +15,12 @@ export class CoinSelect extends PickingStrategy {
15
15
  xpub: Xpub,
16
16
  outputs: OutputInfo[],
17
17
  feePerByte: number
18
- ) {
18
+ ): Promise<{
19
+ unspentUtxos: Output[];
20
+ totalValue: BigNumber;
21
+ fee: number;
22
+ needChangeoutput: boolean;
23
+ }> {
19
24
  // get the utxos to use as input
20
25
  // from all addresses of the account
21
26
  const addresses = await xpub.getXpubAddresses();
@@ -14,7 +14,12 @@ export class DeepFirst extends PickingStrategy {
14
14
  xpub: Xpub,
15
15
  outputs: OutputInfo[],
16
16
  feePerByte: number
17
- ) {
17
+ ): Promise<{
18
+ unspentUtxos: Output[];
19
+ totalValue: BigNumber;
20
+ fee: number;
21
+ needChangeoutput: boolean;
22
+ }> {
18
23
  // get the utxos to use as input
19
24
  // from all addresses of the account
20
25
  const addresses = await xpub.getXpubAddresses();
@@ -14,7 +14,12 @@ export class Merge extends PickingStrategy {
14
14
  xpub: Xpub,
15
15
  outputs: OutputInfo[],
16
16
  feePerByte: number
17
- ) {
17
+ ): Promise<{
18
+ unspentUtxos: Output[];
19
+ totalValue: BigNumber;
20
+ fee: number;
21
+ needChangeoutput: boolean;
22
+ }> {
18
23
  // get the utxos to use as input
19
24
  // from all addresses of the account
20
25
  const addresses = await xpub.getXpubAddresses();