@ledgerhq/live-common 21.25.1 → 21.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/lib/account/support.d.ts.map +1 -1
  2. package/lib/account/support.js +1 -25
  3. package/lib/account/support.js.map +1 -1
  4. package/lib/api/Ethereum.d.ts.map +1 -1
  5. package/lib/api/Ethereum.js +1 -4
  6. package/lib/api/Ethereum.js.map +1 -1
  7. package/lib/api/explorerConfig/index.d.ts.map +1 -1
  8. package/lib/api/explorerConfig/index.js +0 -4
  9. package/lib/api/explorerConfig/index.js.map +1 -1
  10. package/lib/errors.d.ts +3 -0
  11. package/lib/errors.d.ts.map +1 -1
  12. package/lib/errors.js +3 -2
  13. package/lib/errors.js.map +1 -1
  14. package/lib/families/bitcoin/test-dataset.js +1 -1
  15. package/lib/families/bitcoin/test-dataset.js.map +1 -1
  16. package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
  17. package/lib/families/bitcoin/wallet-btc/crypto/base.js +19 -20
  18. package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
  19. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.d.ts.map +1 -1
  20. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js +4 -5
  21. package/lib/families/bitcoin/wallet-btc/crypto/bitcoin.js.map +1 -1
  22. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.d.ts.map +1 -1
  23. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +3 -4
  24. package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
  25. package/lib/families/bitcoin/wallet-btc/crypto/decred.d.ts.map +1 -1
  26. package/lib/families/bitcoin/wallet-btc/crypto/decred.js +3 -4
  27. package/lib/families/bitcoin/wallet-btc/crypto/decred.js.map +1 -1
  28. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.d.ts.map +1 -1
  29. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js +3 -4
  30. package/lib/families/bitcoin/wallet-btc/crypto/litecoin.js.map +1 -1
  31. package/lib/families/bitcoin/wallet-btc/crypto/zec.d.ts.map +1 -1
  32. package/lib/families/bitcoin/wallet-btc/crypto/zec.js +3 -4
  33. package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
  34. package/lib/families/bitcoin/wallet-btc/crypto/zen.d.ts.map +1 -1
  35. package/lib/families/bitcoin/wallet-btc/crypto/zen.js +3 -4
  36. package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
  37. package/lib/families/ethereum/modules/send.d.ts.map +1 -1
  38. package/lib/families/ethereum/modules/send.js +3 -1
  39. package/lib/families/ethereum/modules/send.js.map +1 -1
  40. package/lib/families/tezos/bridge/js.d.ts.map +1 -1
  41. package/lib/families/tezos/bridge/js.js +19 -20
  42. package/lib/families/tezos/bridge/js.js.map +1 -1
  43. package/lib/families/tezos/hw-getAddress.d.ts.map +1 -1
  44. package/lib/families/tezos/hw-getAddress.js +1 -3
  45. package/lib/families/tezos/hw-getAddress.js.map +1 -1
  46. package/lib/families/tezos/synchronisation.d.ts.map +1 -1
  47. package/lib/families/tezos/synchronisation.js +1 -1
  48. package/lib/families/tezos/synchronisation.js.map +1 -1
  49. package/package.json +3 -3
  50. package/src/account/support.ts +1 -25
  51. package/src/api/Ethereum.ts +1 -4
  52. package/src/api/explorerConfig/index.ts +0 -4
  53. package/src/errors.ts +3 -0
  54. package/src/families/bitcoin/test-dataset.ts +1 -1
  55. package/src/families/bitcoin/wallet-btc/crypto/base.ts +41 -20
  56. package/src/families/bitcoin/wallet-btc/crypto/bitcoin.ts +12 -5
  57. package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +11 -4
  58. package/src/families/bitcoin/wallet-btc/crypto/decred.ts +11 -4
  59. package/src/families/bitcoin/wallet-btc/crypto/litecoin.ts +11 -4
  60. package/src/families/bitcoin/wallet-btc/crypto/zec.ts +11 -4
  61. package/src/families/bitcoin/wallet-btc/crypto/zen.ts +11 -4
  62. package/src/families/ethereum/modules/send.ts +3 -0
  63. package/src/families/tezos/bridge/js.ts +41 -40
  64. package/src/families/tezos/hw-getAddress.ts +1 -3
  65. package/src/families/tezos/synchronisation.ts +4 -3
  66. package/src/.DS_Store +0 -0
  67. package/src/__tests__/.DS_Store +0 -0
  68. package/src/currencies/__snapshots__/.DS_Store +0 -0
@@ -74,8 +74,14 @@ class Decred extends Base {
74
74
  account: number,
75
75
  index: number
76
76
  ): string {
77
- if (Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`]) {
78
- return Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`];
77
+ if (
78
+ Base.addressCache[
79
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
80
+ ]
81
+ ) {
82
+ return Base.addressCache[
83
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
84
+ ];
79
85
  }
80
86
  let buffer: Buffer;
81
87
  try {
@@ -90,8 +96,9 @@ class Decred extends Base {
90
96
  const hd = new BIP32(X, chainCode, this.network, depth, i);
91
97
  const publicKey = hd.derive(account).derive(index).publicKey;
92
98
  const address = Decred.getAddressFromPk(publicKey);
93
- Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`] =
94
- address;
99
+ Base.addressCache[
100
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
101
+ ] = address;
95
102
  return address;
96
103
  }
97
104
  }
@@ -59,8 +59,14 @@ class Litecoin extends Base implements ICrypto {
59
59
  account: number,
60
60
  index: number
61
61
  ): string {
62
- if (Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`]) {
63
- return Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`];
62
+ if (
63
+ Base.addressCache[
64
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
65
+ ]
66
+ ) {
67
+ return Base.addressCache[
68
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
69
+ ];
64
70
  }
65
71
  let address: string;
66
72
  switch (derivationMode) {
@@ -76,8 +82,9 @@ class Litecoin extends Base implements ICrypto {
76
82
  default:
77
83
  throw new Error("Should not be reachable");
78
84
  }
79
- Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`] =
80
- address;
85
+ Base.addressCache[
86
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
87
+ ] = address;
81
88
  return address;
82
89
  }
83
90
 
@@ -53,12 +53,19 @@ class ZCash implements ICrypto {
53
53
  account: number,
54
54
  index: number
55
55
  ): string {
56
- if (Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`]) {
57
- return Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`];
56
+ if (
57
+ Base.addressCache[
58
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
59
+ ]
60
+ ) {
61
+ return Base.addressCache[
62
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
63
+ ];
58
64
  }
59
65
  const address = this.getLegacyAddress(xpub, account, index);
60
- Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`] =
61
- address;
66
+ Base.addressCache[
67
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
68
+ ] = address;
62
69
  return address;
63
70
  }
64
71
 
@@ -73,12 +73,19 @@ class Zen implements ICrypto {
73
73
  account: number,
74
74
  index: number
75
75
  ): string {
76
- if (Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`]) {
77
- return Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`];
76
+ if (
77
+ Base.addressCache[
78
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
79
+ ]
80
+ ) {
81
+ return Base.addressCache[
82
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
83
+ ];
78
84
  }
79
85
  const address = this.getLegacyAddress(xpub, account, index);
80
- Base.addressCache[`${derivationMode}-${xpub}-${account}-${index}`] =
81
- address;
86
+ Base.addressCache[
87
+ `${this.network.name}-${derivationMode}-${xpub}-${account}-${index}`
88
+ ] = address;
82
89
  return address;
83
90
  }
84
91
 
@@ -189,6 +189,9 @@ const send: ModeModule = {
189
189
  ];
190
190
  }
191
191
  },
192
+
193
+ // This is resolution config is necessary for plugins like Lido and stuff cause they use the send mode
194
+ getResolutionConfig: () => ({ erc20: true, externalPlugins: true }),
192
195
  };
193
196
 
194
197
  function serializeTransactionData(
@@ -30,6 +30,7 @@ import { getEnv } from "../../../env";
30
30
  import { signOperation } from "../signOperation";
31
31
  import { patchOperationWithHash } from "../../../operation";
32
32
  import { log } from "@ledgerhq/logs";
33
+ import { InvalidAddressBecauseAlreadyDelegated } from "../../../errors";
33
34
 
34
35
  const receive = makeAccountBridgeReceive();
35
36
 
@@ -70,54 +71,52 @@ const getTransactionStatus = async (
70
71
  const { tezosResources } = account;
71
72
  if (!tezosResources) throw new Error("tezosResources is missing");
72
73
 
73
- if (!t.taquitoError) {
74
- if (t.mode !== "undelegate") {
75
- if (account.freshAddress === t.recipient) {
76
- errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
77
- } else {
78
- const { recipientError, recipientWarning } = await validateRecipient(
79
- account.currency,
80
- t.recipient
81
- );
74
+ if (t.mode !== "undelegate") {
75
+ if (account.freshAddress === t.recipient) {
76
+ errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
77
+ } else {
78
+ const { recipientError, recipientWarning } = await validateRecipient(
79
+ account.currency,
80
+ t.recipient
81
+ );
82
82
 
83
- if (recipientError) {
84
- errors.recipient = recipientError;
85
- }
83
+ if (recipientError) {
84
+ errors.recipient = recipientError;
85
+ }
86
86
 
87
- if (recipientWarning) {
88
- warnings.recipient = recipientWarning;
89
- }
87
+ if (recipientWarning) {
88
+ warnings.recipient = recipientWarning;
90
89
  }
91
90
  }
91
+ }
92
92
 
93
- if (t.mode === "send") {
94
- if (!errors.amount && t.amount.eq(0)) {
95
- errors.amount = new AmountRequired();
96
- } else if (!errors.amount && t.amount.lt(0)) {
97
- errors.amount = new NotEnoughBalance();
98
- } else if (t.amount.gt(0) && estimatedFees.times(10).gt(t.amount)) {
99
- warnings.feeTooHigh = new FeeTooHigh();
100
- }
93
+ if (t.mode === "send") {
94
+ if (!errors.amount && t.amount.eq(0)) {
95
+ errors.amount = new AmountRequired();
96
+ } else if (!errors.amount && t.amount.lt(0)) {
97
+ errors.amount = new NotEnoughBalance();
98
+ } else if (t.amount.gt(0) && estimatedFees.times(10).gt(t.amount)) {
99
+ warnings.feeTooHigh = new FeeTooHigh();
100
+ }
101
101
 
102
- const thresholdWarning = 0.5 * 10 ** account.currency.units[0].magnitude;
103
-
104
- if (
105
- !errors.amount &&
106
- account.balance
107
- .minus(t.amount)
108
- .minus(estimatedFees)
109
- .lt(thresholdWarning)
110
- ) {
111
- if (isAccountDelegating(account)) {
112
- if (t.useAllAmount) {
113
- errors.amount = new RecommendUndelegation();
114
- } else {
115
- warnings.amount = new RecommendUndelegation();
116
- }
102
+ const thresholdWarning = 0.5 * 10 ** account.currency.units[0].magnitude;
103
+
104
+ if (
105
+ !errors.amount &&
106
+ account.balance.minus(t.amount).minus(estimatedFees).lt(thresholdWarning)
107
+ ) {
108
+ if (isAccountDelegating(account)) {
109
+ if (t.useAllAmount) {
110
+ errors.amount = new RecommendUndelegation();
111
+ } else {
112
+ warnings.amount = new RecommendUndelegation();
117
113
  }
118
114
  }
119
115
  }
120
- } else {
116
+ }
117
+
118
+ // if we also have taquitoError, we interprete them and they override the previously inferred errors
119
+ if (t.taquitoError) {
121
120
  log("taquitoerror", String(t.taquitoError));
122
121
 
123
122
  // remap taquito errors
@@ -127,7 +126,9 @@ const getTransactionStatus = async (
127
126
  } else {
128
127
  errors.amount = new NotEnoughBalanceToDelegate();
129
128
  }
130
- } else {
129
+ } else if (t.taquitoError.endsWith("delegate.unchanged")) {
130
+ errors.recipient = new InvalidAddressBecauseAlreadyDelegated();
131
+ } else if (!errors.amount) {
131
132
  // unidentified error case
132
133
  errors.amount = new Error(t.taquitoError);
133
134
  }
@@ -3,9 +3,7 @@ import type { Resolver } from "../../hw/getAddress/types";
3
3
 
4
4
  const resolver: Resolver = async (transport, { path, verify }) => {
5
5
  const xtz = new Xtz(transport);
6
- const r = await xtz.getAddress(path, {
7
- verify,
8
- });
6
+ const r = await xtz.getAddress(path, { verify });
9
7
  return { ...r, path };
10
8
  };
11
9
 
@@ -48,9 +48,10 @@ export const getAccountShape: GetAccountShape = async (infoInput) => {
48
48
  derivationMode,
49
49
  });
50
50
 
51
- const initialStableOperations = initialAccount
52
- ? initialAccount.operations
53
- : [];
51
+ const initialStableOperations =
52
+ initialAccount && initialAccount.id === accountId
53
+ ? initialAccount.operations
54
+ : [];
54
55
 
55
56
  // fetch transactions, incrementally if possible
56
57
  const mostRecentStableOperation = initialStableOperations[0];
package/src/.DS_Store DELETED
Binary file
Binary file