Skip to content
This repository was archived by the owner on Jul 15, 2022. It is now read-only.

Commit d7865dd

Browse files
Merge branch 'LedgerHQ:master' into master
2 parents 862d3c3 + 91f92bb commit d7865dd

File tree

20 files changed

+227
-118
lines changed

20 files changed

+227
-118
lines changed

cli/yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3940,9 +3940,9 @@ [email protected]:
39403940
integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==
39413941

39423942
follow-redirects@^1.10.0, follow-redirects@^1.14.0, follow-redirects@^1.14.4, follow-redirects@^1.14.7:
3943-
version "1.14.7"
3944-
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
3945-
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==
3943+
version "1.14.8"
3944+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
3945+
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
39463946

39473947
foreach@^2.0.5:
39483948
version "2.0.5"
@@ -6954,9 +6954,9 @@ url-parse-lax@^3.0.0:
69546954
prepend-http "^2.0.0"
69556955

69566956
url-parse@^1.4.3, url-parse@^1.5.1:
6957-
version "1.5.4"
6958-
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.4.tgz#e4f645a7e2a0852cc8a66b14b292a3e9a11a97fd"
6959-
integrity sha512-ITeAByWWoqutFClc/lRZnFplgXgEZr3WJ6XngMM/N9DMIm4K8zXPCZ1Jdu0rERwO84w1WC5wkle2ubwTA4NTBg==
6957+
version "1.5.7"
6958+
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.7.tgz#00780f60dbdae90181f51ed85fb24109422c932a"
6959+
integrity sha512-HxWkieX+STA38EDk7CE9MEryFeHCKzgagxlGvsdS7WBImq9Mk+PGwiT56w82WI3aicwJA8REp42Cxo98c8FZMA==
69606960
dependencies:
69616961
querystringify "^2.1.1"
69626962
requires-port "^1.0.0"

mobile-test-app/yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,9 +3345,9 @@ [email protected]:
33453345
integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==
33463346

33473347
follow-redirects@^1.10.0, follow-redirects@^1.14.0:
3348-
version "1.14.7"
3349-
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
3350-
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==
3348+
version "1.14.8"
3349+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc"
3350+
integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA==
33513351

33523352
for-in@^1.0.2:
33533353
version "1.0.2"
@@ -6870,9 +6870,9 @@ urix@^0.1.0:
68706870
integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=
68716871

68726872
url-parse@^1.4.3:
6873-
version "1.5.3"
6874-
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.3.tgz#71c1303d38fb6639ade183c2992c8cc0686df862"
6875-
integrity sha512-IIORyIQD9rvj0A4CLWsHkBBJuNqWpFQe224b6j9t/ABmquIS0qDU2pY6kl6AuOrL5OkCXHMCFNe1jBcuAggjvQ==
6873+
version "1.5.7"
6874+
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.7.tgz#00780f60dbdae90181f51ed85fb24109422c932a"
6875+
integrity sha512-HxWkieX+STA38EDk7CE9MEryFeHCKzgagxlGvsdS7WBImq9Mk+PGwiT56w82WI3aicwJA8REp42Cxo98c8FZMA==
68766876
dependencies:
68776877
querystringify "^2.1.1"
68786878
requires-port "^1.0.0"

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "git",
99
"url": "https://github.com/LedgerHQ/ledger-live-common"
1010
},
11-
"version": "21.32.5",
11+
"version": "21.33.0",
1212
"main": "lib/index.js",
1313
"types": "lib/index.d.ts",
1414
"license": "Apache-2.0",
@@ -49,13 +49,13 @@
4949
"@ethereumjs/common": "^2.6.0",
5050
"@ethereumjs/tx": "^3.4.0",
5151
"@ledgerhq/compressjs": "1.3.2",
52-
"@ledgerhq/cryptoassets": "6.24.1",
52+
"@ledgerhq/cryptoassets": "6.25.0",
5353
"@ledgerhq/devices": "6.24.1",
5454
"@ledgerhq/errors": "6.10.0",
5555
"@ledgerhq/hw-app-algorand": "6.24.1",
5656
"@ledgerhq/hw-app-btc": "6.24.1",
5757
"@ledgerhq/hw-app-cosmos": "6.24.1",
58-
"@ledgerhq/hw-app-eth": "6.24.1",
58+
"@ledgerhq/hw-app-eth": "6.25.0",
5959
"@ledgerhq/hw-app-polkadot": "6.24.1",
6060
"@ledgerhq/hw-app-solana": "^6.24.1",
6161
"@ledgerhq/hw-app-str": "6.24.1",

src/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("testing wallet", () => {
3434
const balance = await wallet.getAccountBalance(account);
3535

3636
expect(balance.toNumber()).toEqual(109088);
37-
}, 60000);
37+
});
3838

3939
it("should allow to store and load an account", async () => {
4040
const serializedAccount = await wallet.exportToSerializedAccount(account);

src/account/support.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { getMainAccount } from "../account";
2020
import { getAccountBridge } from "../bridge";
2121
import jsBridges from "../generated/bridge/js";
2222

23-
const experimentalIntegrations = ["algorand", "tezos"];
23+
const experimentalIntegrations = ["tezos"];
2424

2525
export function shouldUseJS(currency: CryptoCurrency) {
2626
const jsBridge = jsBridges[currency.family];

src/apps/support.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function shouldUpgrade(
2929
const appVersionsRequired = {
3030
Cosmos: ">= 2.14",
3131
Algorand: ">= 1.2.9",
32-
Polkadot: ">= 9.9140.0",
32+
Polkadot: ">= 10.9160.1",
3333
Elrond: ">= 1.0.11",
3434
Ethereum: ">= 1.9.17",
3535
};

src/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const LowerThanMinimumRelayFee = createCustomErrorClass(
2323
export const TransactionRefusedOnDevice = createCustomErrorClass(
2424
"TransactionRefusedOnDevice"
2525
);
26+
export const DeviceNotOnboarded = createCustomErrorClass("DeviceNotOnboarded");
2627
export const InvalidAddressBecauseAlreadyDelegated = createCustomErrorClass(
2728
"InvalidAddressBecauseAlreadyDelegated"
2829
);

src/families/crypto_org/js-getTransactionStatus.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
InvalidAddress,
66
FeeNotLoaded,
77
AmountRequired,
8+
InvalidAddressBecauseDestinationIsAlsoSource,
89
} from "@ledgerhq/errors";
910
import type { Account, TransactionStatus } from "../../types";
1011
import type { Transaction } from "./types";
@@ -46,6 +47,8 @@ const getTransactionStatus = async (
4647
errors.recipient = new RecipientRequired();
4748
} else if (!isValidAddress(t.recipient, a.currency.id)) {
4849
errors.recipient = new InvalidAddress();
50+
} else if (t.mode === "send" && a.freshAddress === t.recipient) {
51+
errors.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
4952
}
5053

5154
return Promise.resolve({

src/families/tezos/bridge/js.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
FeeTooHigh,
1313
InvalidAddressBecauseDestinationIsAlsoSource,
1414
RecommendUndelegation,
15+
NotEnoughBalanceBecauseDestinationNotCreated,
1516
} from "@ledgerhq/errors";
1617
import { validateRecipient } from "../../../bridge/shared";
1718
import type {
@@ -35,9 +36,12 @@ import { signOperation } from "../signOperation";
3536
import { patchOperationWithHash } from "../../../operation";
3637
import { log } from "@ledgerhq/logs";
3738
import { InvalidAddressBecauseAlreadyDelegated } from "../../../errors";
39+
import api from "../api/tzkt";
3840

3941
const receive = makeAccountBridgeReceive();
4042

43+
const EXISTENTIAL_DEPOSIT = new BigNumber(275000);
44+
4145
const createTransaction: () => Transaction = () => ({
4246
family: "tezos",
4347
mode: "send",
@@ -71,6 +75,7 @@ const getTransactionStatus = async (
7175
} = {};
7276

7377
const estimatedFees = t.estimatedFees || new BigNumber(0);
78+
let amount = t.amount;
7479

7580
const { tezosResources } = account;
7681
if (!tezosResources) throw new Error("tezosResources is missing");
@@ -95,14 +100,30 @@ const getTransactionStatus = async (
95100
}
96101

97102
if (t.mode === "send") {
98-
if (!errors.amount && t.amount.eq(0)) {
103+
const spendableBalance = account.balance.minus(EXISTENTIAL_DEPOSIT).lt(0)
104+
? account.balance.minus(EXISTENTIAL_DEPOSIT)
105+
: account.balance;
106+
if (!errors.amount && t.amount.eq(0) && !t.useAllAmount) {
99107
errors.amount = new AmountRequired();
100-
} else if (!errors.amount && t.amount.lt(0)) {
108+
} else if (!errors.amount && t.amount.gt(spendableBalance)) {
101109
errors.amount = new NotEnoughBalance();
110+
if (t.useAllAmount) {
111+
amount = new BigNumber(0);
112+
}
102113
} else if (t.amount.gt(0) && estimatedFees.times(10).gt(t.amount)) {
103114
warnings.feeTooHigh = new FeeTooHigh();
104115
}
105116

117+
if (
118+
!errors.amount &&
119+
(await api.getAccountByAddress(t.recipient)).type === "empty" &&
120+
t.amount.lt(EXISTENTIAL_DEPOSIT)
121+
) {
122+
errors.amount = new NotEnoughBalanceBecauseDestinationNotCreated("", {
123+
minimalAmount: "0.275 XTZ",
124+
});
125+
}
126+
106127
const thresholdWarning = 0.5 * 10 ** account.currency.units[0].magnitude;
107128

108129
if (
@@ -146,8 +167,8 @@ const getTransactionStatus = async (
146167
errors,
147168
warnings,
148169
estimatedFees,
149-
amount: t.amount,
150-
totalSpent: t.amount.plus(estimatedFees),
170+
amount: amount,
171+
totalSpent: amount.plus(estimatedFees),
151172
};
152173
return Promise.resolve(result);
153174
};
@@ -222,7 +243,6 @@ const prepareTransaction = async (
222243
default:
223244
throw new Error("unsupported mode=" + transaction.mode);
224245
}
225-
226246
if (t.useAllAmount) {
227247
const totalFees = out.suggestedFeeMutez + out.burnFeeMutez;
228248
const maxAmount = account.balance

src/families/tezos/datasets/tezos.scanAccounts.1.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@ export default {
55
apdus: `
66
=> 800200000d038000002c800006c180000000
77
<= 2102ac76ba226118e2d593d09cd7e395546b7540c0e7fb3eb430da59f7982af632969000
8-
=> 8002000015058000002c800006c1800000008000000080000000
9-
<= 2102f7ed85c519f7d39a664935a410d1a41ca302dfa3eee228e92cbe0dc12aba7a189000
108
=> 8002000015058000002c800006c1800000008000000080000001
119
<= 2102b058662fd530e6463d774e3951a40ddd5e430dbeb62673f90caca0cec58735fd9000
12-
=> 800200000d038000002c800006c180000000
13-
<= 2102ac76ba226118e2d593d09cd7e395546b7540c0e7fb3eb430da59f7982af632969000
14-
=> 8002000011048000002c800006c18000000080000000
15-
<= 210294e8344ae6df2d3123fa100b5abd40cee339c67838b1c34c4f243cc582f4d2d89000
1610
=> 8002000011048000002c800006c18000000080000001
1711
<= 2102670e5e92d06e725b68edda589678fdf0f85a582df06ee634d841cf8042db63839000
18-
=> 800200000d038000002c800006c180000000
19-
<= 2102ac76ba226118e2d593d09cd7e395546b7540c0e7fb3eb430da59f7982af632969000
2012
=> 8002000015058000002c800006c1800000008000000080000000
2113
<= 2102f7ed85c519f7d39a664935a410d1a41ca302dfa3eee228e92cbe0dc12aba7a189000
2214
=> 8002000015058000002c800006c1800000018000000080000000
@@ -31,8 +23,6 @@ export default {
3123
<= 21020162dc75ad3c2b6e097d15a1513033c60d8a033f2312ff5a6ead812228d9d6539000
3224
=> 8002000015058000002c800006c1800000068000000080000000
3325
<= 21021831897c4224296519d496d32fdf9e17fb4af680635c5dbbc46cde84fe11dcc99000
34-
=> 800200000d038000002c800006c180000000
35-
<= 2102ac76ba226118e2d593d09cd7e395546b7540c0e7fb3eb430da59f7982af632969000
3626
=> 8002000011048000002c800006c18000000080000000
3727
<= 210294e8344ae6df2d3123fa100b5abd40cee339c67838b1c34c4f243cc582f4d2d89000
3828
=> 8002000011048000002c800006c18000000180000000

0 commit comments

Comments
 (0)