@ledgerhq/live-common 27.1.0 → 27.2.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/socket.js.map +1 -1
- package/lib/bot/index.d.ts.map +1 -1
- package/lib/bot/index.js +90 -81
- package/lib/bot/index.js.map +1 -1
- package/lib/bot/specs.d.ts.map +1 -1
- package/lib/bot/specs.js +11 -2
- package/lib/bot/specs.js.map +1 -1
- package/lib/errors.d.ts +306 -102
- package/lib/errors.d.ts.map +1 -1
- package/lib/exchange/swap/getKYCStatus.d.ts.map +1 -1
- package/lib/exchange/swap/getKYCStatus.js +1 -1
- package/lib/exchange/swap/getKYCStatus.js.map +1 -1
- package/lib/families/bitcoin/cache.js +3 -3
- package/lib/families/bitcoin/cache.js.map +1 -1
- package/lib/families/bitcoin/errors.d.ts +3 -1
- package/lib/families/bitcoin/errors.d.ts.map +1 -1
- package/lib/families/bitcoin/hw-signMessage.d.ts +5 -3
- package/lib/families/bitcoin/hw-signMessage.d.ts.map +1 -1
- package/lib/families/bitcoin/hw-signMessage.js +2 -2
- package/lib/families/bitcoin/hw-signMessage.js.map +1 -1
- package/lib/families/cardano/errors.d.ts +6 -2
- package/lib/families/cardano/errors.d.ts.map +1 -1
- package/lib/families/celo/errors.d.ts +3 -1
- package/lib/families/celo/errors.d.ts.map +1 -1
- package/lib/families/cosmos/specs.d.ts.map +1 -1
- package/lib/families/cosmos/specs.js +12 -8
- package/lib/families/cosmos/specs.js.map +1 -1
- package/lib/families/crypto_org/errors.d.ts +9 -3
- package/lib/families/crypto_org/errors.d.ts.map +1 -1
- package/lib/families/ethereum/hw-signMessage.d.ts +7 -3
- package/lib/families/ethereum/hw-signMessage.d.ts.map +1 -1
- package/lib/families/ethereum/hw-signMessage.js +73 -14
- package/lib/families/ethereum/hw-signMessage.js.map +1 -1
- package/lib/families/ethereum/hw-signMessage.test.js +99 -23
- package/lib/families/ethereum/hw-signMessage.test.js.map +1 -1
- package/lib/families/ethereum/transaction.d.ts +1 -1
- package/lib/families/ethereum/transaction.d.ts.map +1 -1
- package/lib/families/ethereum/types.d.ts +6 -8
- package/lib/families/ethereum/types.d.ts.map +1 -1
- package/lib/families/filecoin/bridge.integration.test.js +1 -1
- package/lib/families/filecoin/bridge.integration.test.js.map +1 -1
- package/lib/families/filecoin/hw-signMessage.d.ts +5 -3
- package/lib/families/filecoin/hw-signMessage.d.ts.map +1 -1
- package/lib/families/filecoin/hw-signMessage.js +2 -2
- package/lib/families/filecoin/hw-signMessage.js.map +1 -1
- package/lib/families/osmosis/errors.d.ts +9 -3
- package/lib/families/osmosis/errors.d.ts.map +1 -1
- package/lib/families/osmosis/specs.d.ts.map +1 -1
- package/lib/families/osmosis/specs.js +32 -22
- package/lib/families/osmosis/specs.js.map +1 -1
- package/lib/families/polkadot/errors.d.ts +36 -12
- package/lib/families/polkadot/errors.d.ts.map +1 -1
- package/lib/families/solana/errors.d.ts +60 -20
- package/lib/families/solana/errors.d.ts.map +1 -1
- package/lib/families/stellar/api/horizon.js +3 -3
- package/lib/families/stellar/api/horizon.js.map +1 -1
- package/lib/families/stellar/errors.d.ts +33 -11
- package/lib/families/stellar/errors.d.ts.map +1 -1
- package/lib/families/tezos/bridge/js.js.map +1 -1
- package/lib/families/tron/specs.js +1 -1
- package/lib/families/tron/specs.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +9 -3
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/generated/hw-signMessage.d.ts +10 -3
- package/lib/generated/hw-signMessage.d.ts.map +1 -1
- package/lib/hw/connectApp.js.map +1 -1
- package/lib/hw/connectManager.js.map +1 -1
- package/lib/hw/deviceAccess.d.ts +1 -1
- package/lib/hw/deviceAccess.d.ts.map +1 -1
- package/lib/hw/deviceAccess.js.map +1 -1
- package/lib/hw/getOnboardingStatePolling.d.ts +1 -1
- package/lib/hw/getOnboardingStatePolling.d.ts.map +1 -1
- package/lib/hw/getOnboardingStatePolling.js +1 -0
- package/lib/hw/getOnboardingStatePolling.js.map +1 -1
- package/lib/hw/installLanguage.js.map +1 -1
- package/lib/hw/signMessage/index.d.ts +5 -5
- package/lib/hw/signMessage/index.d.ts.map +1 -1
- package/lib/hw/signMessage/index.js +10 -6
- package/lib/hw/signMessage/index.js.map +1 -1
- package/lib/hw/signMessage/index.test.js +42 -43
- package/lib/hw/signMessage/index.test.js.map +1 -1
- package/lib/hw/signMessage/types.d.ts +1 -1
- package/lib/hw/signMessage/types.d.ts.map +1 -1
- package/lib/hw/uninstallLanguage.js.map +1 -1
- package/lib/walletconnect/index.d.ts +1 -1
- package/lib/walletconnect/index.d.ts.map +1 -1
- package/lib/walletconnect/index.js +1 -9
- package/lib/walletconnect/index.js.map +1 -1
- package/lib/walletconnect/walletconnect.test.js.map +1 -1
- package/package.json +17 -17
- package/src/api/socket.ts +1 -1
- package/src/bot/index.ts +174 -113
- package/src/bot/specs.ts +16 -2
- package/src/exchange/swap/getKYCStatus.ts +3 -1
- package/src/families/bitcoin/cache.ts +2 -2
- package/src/families/bitcoin/hw-signMessage.ts +3 -3
- package/src/families/cosmos/specs.ts +14 -10
- package/src/families/ethereum/hw-signMessage.test.ts +105 -21
- package/src/families/ethereum/hw-signMessage.ts +68 -16
- package/src/families/ethereum/types.ts +6 -8
- package/src/families/filecoin/__snapshots__/bridge.integration.test.ts.snap +27 -0
- package/src/families/filecoin/bridge.integration.test.ts +6 -2
- package/src/families/filecoin/hw-signMessage.ts +3 -3
- package/src/families/osmosis/specs.ts +35 -25
- package/src/families/stellar/api/horizon.ts +4 -4
- package/src/families/tezos/bridge/js.ts +1 -1
- package/src/families/tron/specs.ts +1 -1
- package/src/featureFlags/defaultFeatures.ts +9 -3
- package/src/hw/connectApp.ts +1 -1
- package/src/hw/connectManager.ts +1 -1
- package/src/hw/deviceAccess.ts +2 -2
- package/src/hw/getOnboardingStatePolling.ts +5 -1
- package/src/hw/installLanguage.ts +1 -1
- package/src/hw/signMessage/index.test.ts +48 -45
- package/src/hw/signMessage/index.ts +23 -9
- package/src/hw/signMessage/types.ts +4 -1
- package/src/hw/uninstallLanguage.ts +1 -1
- package/src/walletconnect/index.ts +3 -11
- package/src/walletconnect/walletconnect.test.ts +2 -0
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import { DeviceModelId } from "@ledgerhq/devices";
|
|
27
27
|
import { acceptTransaction } from "./speculos-deviceActions";
|
|
28
28
|
|
|
29
|
-
const minAmount = new BigNumber(
|
|
29
|
+
const minAmount = new BigNumber(10000);
|
|
30
30
|
const maxAccounts = 32;
|
|
31
31
|
|
|
32
32
|
// amounts of delegation are not exact so we are applying an approximation
|
|
@@ -158,13 +158,13 @@ const cosmos: AppSpec<Transaction> = {
|
|
|
158
158
|
"already enough delegations"
|
|
159
159
|
);
|
|
160
160
|
const data = getCurrentCosmosPreloadData();
|
|
161
|
-
const count = 1 + Math.
|
|
161
|
+
const count = 1 + Math.round(2 * Math.random() * Math.random());
|
|
162
162
|
let remaining = getMaxDelegationAvailable(
|
|
163
163
|
account as CosmosAccount,
|
|
164
164
|
count
|
|
165
165
|
)
|
|
166
166
|
.minus(minAmount.times(2))
|
|
167
|
-
.times(0.
|
|
167
|
+
.times(0.1 * Math.random());
|
|
168
168
|
invariant(remaining.gt(0), "not enough funds in account for delegate");
|
|
169
169
|
const all = data.validators.filter(
|
|
170
170
|
(v) =>
|
|
@@ -222,7 +222,7 @@ const cosmos: AppSpec<Transaction> = {
|
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
224
|
name: "undelegate",
|
|
225
|
-
maxRun:
|
|
225
|
+
maxRun: 5,
|
|
226
226
|
transaction: ({ account, bridge }) => {
|
|
227
227
|
invariant(canUndelegate(account as CosmosAccount), "can undelegate");
|
|
228
228
|
const { cosmosResources } = account as CosmosAccount;
|
|
@@ -246,8 +246,8 @@ const cosmos: AppSpec<Transaction> = {
|
|
|
246
246
|
);
|
|
247
247
|
invariant(undelegateCandidate, "already pending");
|
|
248
248
|
|
|
249
|
-
const amount = (undelegateCandidate as CosmosDelegation).amount
|
|
250
|
-
.times(Math.random() > 0.
|
|
249
|
+
const amount = (undelegateCandidate as CosmosDelegation).amount
|
|
250
|
+
.times(Math.random() > 0.2 ? 1 : Math.random()) // most of the time, undelegate all
|
|
251
251
|
.integerValue();
|
|
252
252
|
invariant(amount.gt(0), "random amount to be positive");
|
|
253
253
|
|
|
@@ -406,10 +406,14 @@ const cosmos: AppSpec<Transaction> = {
|
|
|
406
406
|
const d = (cosmosResources as CosmosResources).delegations.find(
|
|
407
407
|
(d) => d.validatorAddress === v.address
|
|
408
408
|
);
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
409
|
+
botTest("delegation exists in account", () =>
|
|
410
|
+
invariant(d, "delegation %s must be found in account", v.address)
|
|
411
|
+
);
|
|
412
|
+
botTest("reward is no longer claimable after claim", () =>
|
|
413
|
+
invariant(
|
|
414
|
+
!canClaimRewards(account as CosmosAccount, d as CosmosDelegation),
|
|
415
|
+
"reward no longer be claimable"
|
|
416
|
+
)
|
|
413
417
|
);
|
|
414
418
|
});
|
|
415
419
|
},
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "../../__tests__/test-helpers/setup";
|
|
2
2
|
|
|
3
|
-
import EIP712Message from "@ledgerhq/hw-app-eth/
|
|
4
|
-
import
|
|
3
|
+
import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712";
|
|
4
|
+
import testEIP712Message from "@ledgerhq/hw-app-eth/tests/sample-messages/0.json";
|
|
5
|
+
import ethSign from "./hw-signMessage";
|
|
5
6
|
import { setEnv } from "../../env";
|
|
7
|
+
import { createFixtureCryptoCurrency } from "../../mock/fixtures/cryptoCurrencies";
|
|
6
8
|
|
|
7
9
|
const signPersonalMessage = jest.fn(() =>
|
|
8
10
|
Promise.resolve({
|
|
@@ -25,14 +27,81 @@ const signEIP712Message = jest.fn(() =>
|
|
|
25
27
|
v: 28,
|
|
26
28
|
})
|
|
27
29
|
);
|
|
30
|
+
// We only need to mock the defaut class returned
|
|
28
31
|
jest.mock("@ledgerhq/hw-app-eth", () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const originalModule = jest.requireActual("@ledgerhq/hw-app-eth");
|
|
33
|
+
return {
|
|
34
|
+
...originalModule,
|
|
35
|
+
default: class {
|
|
36
|
+
signPersonalMessage = signPersonalMessage;
|
|
37
|
+
signEIP712HashedMessage = signEIP712HashedMessage;
|
|
38
|
+
signEIP712Message = signEIP712Message;
|
|
39
|
+
},
|
|
33
40
|
};
|
|
34
41
|
});
|
|
35
42
|
|
|
43
|
+
describe("prepareMessageToSign", () => {
|
|
44
|
+
it("returns a MessageData object when message to sign is a simple string", () => {
|
|
45
|
+
// Given
|
|
46
|
+
const currency = createFixtureCryptoCurrency("ethereum");
|
|
47
|
+
const path = "44'/60'/0'/0/0";
|
|
48
|
+
const derivationMode = "ethM";
|
|
49
|
+
const message = "4d6573736167652064652074657374";
|
|
50
|
+
const expectedRawMessage = "0x4d6573736167652064652074657374";
|
|
51
|
+
|
|
52
|
+
// When
|
|
53
|
+
const result = ethSign.prepareMessageToSign(
|
|
54
|
+
currency,
|
|
55
|
+
path,
|
|
56
|
+
derivationMode,
|
|
57
|
+
message
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Then
|
|
61
|
+
expect(result).toEqual({
|
|
62
|
+
currency,
|
|
63
|
+
path: "44'/60'/0'/0/0",
|
|
64
|
+
derivationMode: "ethM",
|
|
65
|
+
message: "Message de test",
|
|
66
|
+
rawMessage: expectedRawMessage,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("returns a TypedMessageData object when message to sign is an EIP712Message", () => {
|
|
71
|
+
// Given
|
|
72
|
+
const currency = createFixtureCryptoCurrency("ethereum");
|
|
73
|
+
const path = "44'/60'/0'/0/0";
|
|
74
|
+
const derivationMode = "ethM";
|
|
75
|
+
// testEIP712MessageHex
|
|
76
|
+
const message =
|
|
77
|
+
"7b0d0a2020202022646f6d61696e223a207b0d0a202020202020202022636861696e4964223a20352c0d0a2020202020202020226e616d65223a20224574686572204d61696c222c0d0a202020202020202022766572696679696e67436f6e7472616374223a2022307843634343636363634343434363434343434343634363436363436343434363436363636363636343222c0d0a20202020202020202276657273696f6e223a202231220d0a202020207d2c0d0a20202020226d657373616765223a207b0d0a202020202020202022636f6e74656e7473223a202248656c6c6f2c20426f6221222c0d0a20202020202020202266726f6d223a207b0d0a202020202020202020202020226e616d65223a2022436f77222c0d0a2020202020202020202020202277616c6c657473223a205b0d0a2020202020202020202020202020202022307843443261336439463933384531334344393437456330354162433746453733344466384444383236222c0d0a2020202020202020202020202020202022307844656144626565666445416462656566644561646245454664656164626545466445614462656546220d0a2020202020202020202020205d0d0a20202020202020207d2c0d0a202020202020202022746f223a207b0d0a202020202020202020202020226e616d65223a2022426f62222c0d0a2020202020202020202020202277616c6c657473223a205b0d0a2020202020202020202020202020202022307862426242424242626242424262626242626242626262624242624262626262426242626242426242222c0d0a2020202020202020202020202020202022307842304264614265613537423042444142654135376230626441424541353762304244616245613537222c0d0a2020202020202020202020202020202022307842304230623062306230623042303030303030303030303030303030303030303030303030303030220d0a2020202020202020202020205d0d0a20202020202020207d0d0a202020207d2c0d0a20202020227072696d61727954797065223a20224d61696c222c0d0a20202020227479706573223a207b0d0a202020202020202022454950373132446f6d61696e223a205b0d0a2020202020202020202020207b20226e616d65223a20226e616d65222c202274797065223a2022737472696e6722207d2c0d0a2020202020202020202020207b20226e616d65223a202276657273696f6e222c202274797065223a2022737472696e6722207d2c0d0a2020202020202020202020207b20226e616d65223a2022636861696e4964222c202274797065223a202275696e7432353622207d2c0d0a2020202020202020202020207b20226e616d65223a2022766572696679696e67436f6e7472616374222c202274797065223a20226164647265737322207d0d0a20202020202020205d2c0d0a2020202020202020224d61696c223a205b0d0a2020202020202020202020207b20226e616d65223a202266726f6d222c202274797065223a2022506572736f6e22207d2c0d0a2020202020202020202020207b20226e616d65223a2022746f222c202274797065223a2022506572736f6e22207d2c0d0a2020202020202020202020207b20226e616d65223a2022636f6e74656e7473222c202274797065223a2022737472696e6722207d0d0a20202020202020205d2c0d0a202020202020202022506572736f6e223a205b0d0a2020202020202020202020207b20226e616d65223a20226e616d65222c202274797065223a2022737472696e6722207d2c0d0a2020202020202020202020207b20226e616d65223a202277616c6c657473222c202274797065223a2022616464726573735b5d22207d0d0a20202020202020205d0d0a202020207d0d0a7d0d0a";
|
|
78
|
+
|
|
79
|
+
// When
|
|
80
|
+
const result = ethSign.prepareMessageToSign(
|
|
81
|
+
currency,
|
|
82
|
+
path,
|
|
83
|
+
derivationMode,
|
|
84
|
+
message
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
// Then
|
|
88
|
+
expect(result).toEqual({
|
|
89
|
+
currency,
|
|
90
|
+
path,
|
|
91
|
+
derivationMode,
|
|
92
|
+
message: testEIP712Message,
|
|
93
|
+
rawMessage: "0x" + message,
|
|
94
|
+
hashes: {
|
|
95
|
+
stringHash: "",
|
|
96
|
+
domainHash:
|
|
97
|
+
"0x6137beb405d9ff777172aa879e33edb34a1460e701802746c5ef96e741710e59",
|
|
98
|
+
messageHash:
|
|
99
|
+
"0x5476346eb09179b1f7d245c11a27ae6c498a419d7fad4d984d5b1e0ad081662a",
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
36
105
|
describe("Eth hw-signMessage", () => {
|
|
37
106
|
beforeEach(() => {
|
|
38
107
|
jest.clearAllMocks();
|
|
@@ -40,7 +109,7 @@ describe("Eth hw-signMessage", () => {
|
|
|
40
109
|
|
|
41
110
|
describe("parsing", () => {
|
|
42
111
|
it("should be using the signPersonalMessage method with string message", async () => {
|
|
43
|
-
await
|
|
112
|
+
await ethSign.signMessage({} as any, {
|
|
44
113
|
path: "",
|
|
45
114
|
message: "test",
|
|
46
115
|
rawMessage: "0xtest",
|
|
@@ -50,32 +119,47 @@ describe("Eth hw-signMessage", () => {
|
|
|
50
119
|
});
|
|
51
120
|
|
|
52
121
|
it("should be using the signEIP712HashedMessage method with stringified message", async () => {
|
|
53
|
-
await
|
|
122
|
+
await ethSign.signMessage({} as any, {
|
|
54
123
|
path: "",
|
|
55
|
-
message: JSON.stringify(
|
|
124
|
+
message: JSON.stringify(testEIP712Message),
|
|
56
125
|
rawMessage: "0xtest",
|
|
57
126
|
});
|
|
58
127
|
|
|
59
128
|
expect(signEIP712HashedMessage).toHaveBeenCalledTimes(1);
|
|
60
129
|
});
|
|
61
130
|
|
|
62
|
-
it("should be using the
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
await hwSignMessage({} as any, {
|
|
131
|
+
it("should be using the signEIP712HashedMessage method with EIP712Message message", async () => {
|
|
132
|
+
await ethSign.signMessage({} as any, {
|
|
66
133
|
path: "",
|
|
67
|
-
message: EIP712Message,
|
|
134
|
+
message: testEIP712Message as EIP712Message,
|
|
68
135
|
rawMessage: "0xtest",
|
|
69
136
|
});
|
|
70
137
|
|
|
71
|
-
expect(
|
|
72
|
-
|
|
138
|
+
expect(signEIP712HashedMessage).toHaveBeenCalledTimes(1);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe("when EXPERIMENTAL_EIP712 env variable is set to true", () => {
|
|
142
|
+
beforeAll(() => {
|
|
143
|
+
setEnv("EXPERIMENTAL_EIP712", true);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
afterAll(() => {
|
|
147
|
+
setEnv("EXPERIMENTAL_EIP712", false);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("should be using the signEIP712Message method with EIP712Message message", async () => {
|
|
151
|
+
await ethSign.signMessage({} as any, {
|
|
152
|
+
path: "",
|
|
153
|
+
message: testEIP712Message as EIP712Message,
|
|
154
|
+
rawMessage: "0xtest",
|
|
155
|
+
});
|
|
156
|
+
});
|
|
73
157
|
});
|
|
74
158
|
});
|
|
75
159
|
|
|
76
160
|
describe("value of v", () => {
|
|
77
161
|
it("should returning parity for signPersonalMessage", async () => {
|
|
78
|
-
const { rsv } = await
|
|
162
|
+
const { rsv } = await ethSign.signMessage({} as any, {
|
|
79
163
|
path: "",
|
|
80
164
|
message: "test",
|
|
81
165
|
rawMessage: "0xtest",
|
|
@@ -85,9 +169,9 @@ describe("Eth hw-signMessage", () => {
|
|
|
85
169
|
});
|
|
86
170
|
|
|
87
171
|
it("should not be returning parity for signEIP712HashedMessage", async () => {
|
|
88
|
-
const { rsv } = await
|
|
172
|
+
const { rsv } = await ethSign.signMessage({} as any, {
|
|
89
173
|
path: "",
|
|
90
|
-
message: JSON.stringify(
|
|
174
|
+
message: JSON.stringify(testEIP712Message),
|
|
91
175
|
rawMessage: "0xtest",
|
|
92
176
|
});
|
|
93
177
|
|
|
@@ -97,9 +181,9 @@ describe("Eth hw-signMessage", () => {
|
|
|
97
181
|
it("should not be returning parity for signEIP712Message", async () => {
|
|
98
182
|
setEnv("EXPERIMENTAL_EIP712", true);
|
|
99
183
|
|
|
100
|
-
const { rsv } = await
|
|
184
|
+
const { rsv } = await ethSign.signMessage({} as any, {
|
|
101
185
|
path: "",
|
|
102
|
-
message:
|
|
186
|
+
message: testEIP712Message,
|
|
103
187
|
rawMessage: "0xtest",
|
|
104
188
|
});
|
|
105
189
|
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import Eth, { isEIP712Message } from "@ledgerhq/hw-app-eth";
|
|
1
2
|
import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712/EIP712.types";
|
|
2
|
-
import Eth from "@ledgerhq/hw-app-eth";
|
|
3
3
|
import Transport from "@ledgerhq/hw-transport";
|
|
4
4
|
import { TypedDataUtils } from "eth-sig-util";
|
|
5
5
|
import { bufferToHex } from "ethereumjs-util";
|
|
6
6
|
import { getEnv } from "../../env";
|
|
7
7
|
import type { MessageData, Result } from "../../hw/signMessage/types";
|
|
8
8
|
import type { TypedMessageData } from "./types";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
import { DerivationMode } from "../../derivation";
|
|
10
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
11
|
+
|
|
12
|
+
type EthSignMessage = (
|
|
13
|
+
transport: Transport,
|
|
14
|
+
message: Pick<
|
|
15
|
+
MessageData | TypedMessageData,
|
|
16
|
+
"path" | "message" | "rawMessage"
|
|
17
|
+
>
|
|
13
18
|
) => Promise<Result>;
|
|
14
19
|
|
|
15
20
|
export const domainHash = (message: EIP712Message): Buffer => {
|
|
@@ -29,18 +34,65 @@ export const messageHash = (message: EIP712Message): Buffer => {
|
|
|
29
34
|
);
|
|
30
35
|
};
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
function tryConvertToJSON(message: string): string | EIP712Message {
|
|
38
|
+
try {
|
|
39
|
+
const parsedMessage = JSON.parse(message);
|
|
40
|
+
if (isEIP712Message(parsedMessage)) {
|
|
41
|
+
return parsedMessage as EIP712Message;
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
// Not a JSON message
|
|
45
|
+
}
|
|
46
|
+
return message;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const prepareMessageToSign = (
|
|
50
|
+
currency: CryptoCurrency,
|
|
51
|
+
path: string,
|
|
52
|
+
derivationMode: DerivationMode,
|
|
53
|
+
message: string
|
|
54
|
+
): MessageData | TypedMessageData => {
|
|
55
|
+
const hexToStringMessage = Buffer.from(message, "hex").toString();
|
|
56
|
+
const parsedMessage = tryConvertToJSON(hexToStringMessage);
|
|
57
|
+
|
|
58
|
+
const messageData = {
|
|
59
|
+
currency,
|
|
60
|
+
path,
|
|
61
|
+
derivationMode,
|
|
62
|
+
rawMessage: "0x" + message,
|
|
63
|
+
};
|
|
64
|
+
if (typeof parsedMessage === "string") {
|
|
65
|
+
return {
|
|
66
|
+
...messageData,
|
|
67
|
+
message: parsedMessage,
|
|
68
|
+
};
|
|
69
|
+
} else {
|
|
70
|
+
return {
|
|
71
|
+
...messageData,
|
|
72
|
+
message: parsedMessage,
|
|
73
|
+
hashes: {
|
|
74
|
+
stringHash: "",
|
|
75
|
+
domainHash: bufferToHex(domainHash(parsedMessage)),
|
|
76
|
+
messageHash: bufferToHex(messageHash(parsedMessage)),
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type PartialMessageData = {
|
|
83
|
+
path: string;
|
|
84
|
+
message: string | EIP712Message;
|
|
85
|
+
rawMessage: string;
|
|
86
|
+
};
|
|
87
|
+
const signMessage: EthSignMessage = async (
|
|
88
|
+
transport: Transport,
|
|
89
|
+
{ path, message, rawMessage }: PartialMessageData
|
|
35
90
|
) => {
|
|
36
91
|
const eth = new Eth(transport);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return message;
|
|
42
|
-
}
|
|
43
|
-
})();
|
|
92
|
+
let parsedMessage = message;
|
|
93
|
+
if (typeof message === "string") {
|
|
94
|
+
parsedMessage = tryConvertToJSON(message);
|
|
95
|
+
}
|
|
44
96
|
|
|
45
97
|
let result: Awaited<ReturnType<typeof eth.signPersonalMessage>>;
|
|
46
98
|
if (typeof parsedMessage === "string") {
|
|
@@ -70,4 +122,4 @@ const resolver: EthResolver = async (
|
|
|
70
122
|
};
|
|
71
123
|
};
|
|
72
124
|
|
|
73
|
-
export default
|
|
125
|
+
export default { prepareMessageToSign, signMessage };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712/EIP712.types";
|
|
2
1
|
import type { BigNumber } from "bignumber.js";
|
|
2
|
+
import { EIP712Message } from "@ledgerhq/hw-app-eth/lib/modules/EIP712/EIP712.types";
|
|
3
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
3
4
|
import type { TransactionMode, ModeModule } from "./modules";
|
|
4
5
|
import type { Range, RangeRaw } from "../../range";
|
|
5
|
-
import type { DerivationMode } from "../../derivation";
|
|
6
6
|
import type {
|
|
7
7
|
TransactionCommon,
|
|
8
8
|
TransactionCommonRaw,
|
|
9
9
|
TransactionStatusCommon,
|
|
10
10
|
TransactionStatusCommonRaw,
|
|
11
11
|
} from "@ledgerhq/types-live";
|
|
12
|
-
import type {
|
|
12
|
+
import type { MessageData } from "../../hw/signMessage/types";
|
|
13
13
|
|
|
14
14
|
export type EthereumGasLimitRequest = {
|
|
15
15
|
from?: string;
|
|
@@ -61,14 +61,12 @@ export type TransactionRaw = TransactionCommonRaw & {
|
|
|
61
61
|
collectionName?: string;
|
|
62
62
|
quantities?: string[];
|
|
63
63
|
};
|
|
64
|
-
export type TypedMessageData = {
|
|
65
|
-
currency: CryptoCurrency;
|
|
66
|
-
path: string;
|
|
67
|
-
verify?: boolean;
|
|
68
|
-
derivationMode: DerivationMode;
|
|
64
|
+
export type TypedMessageData = Omit<MessageData, "message"> & {
|
|
69
65
|
message: EIP712Message;
|
|
70
66
|
hashes: {
|
|
71
67
|
stringHash: string;
|
|
68
|
+
domainHash: string;
|
|
69
|
+
messageHash: string;
|
|
72
70
|
};
|
|
73
71
|
};
|
|
74
72
|
|
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`filecoin currency bridge scanAccounts filecoin seed 1 1`] = `
|
|
4
4
|
Array [
|
|
5
|
+
Object {
|
|
6
|
+
"balance": "1000000000000000",
|
|
7
|
+
"currencyId": "filecoin",
|
|
8
|
+
"derivationMode": "gliflegacy",
|
|
9
|
+
"freshAddress": "t15lauyzdivqj7m3yob3rxmzdsy7uyhfflwyheuri",
|
|
10
|
+
"freshAddressPath": "44'/1'/0'/0/0",
|
|
11
|
+
"freshAddresses": Array [
|
|
12
|
+
Object {
|
|
13
|
+
"address": "t15lauyzdivqj7m3yob3rxmzdsy7uyhfflwyheuri",
|
|
14
|
+
"derivationPath": "44'/1'/0'/0/0",
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
"id": "js:2:filecoin:t15lauyzdivqj7m3yob3rxmzdsy7uyhfflwyheuri:gliflegacy",
|
|
18
|
+
"index": 0,
|
|
19
|
+
"name": "Filecoin 1",
|
|
20
|
+
"nfts": undefined,
|
|
21
|
+
"operationsCount": 0,
|
|
22
|
+
"pendingOperations": Array [],
|
|
23
|
+
"seedIdentifier": "04ca7b02cafdf36e8b4caaf530a96b949764af71b956b2a3328b7a10940794c860f574a9199be98bde3c261887fec8e5fd94bc5f104908bf5f992f52ef2a89abb0",
|
|
24
|
+
"spendableBalance": "1000000000000000",
|
|
25
|
+
"starred": false,
|
|
26
|
+
"swapHistory": Array [],
|
|
27
|
+
"syncHash": undefined,
|
|
28
|
+
"unitMagnitude": 18,
|
|
29
|
+
"used": true,
|
|
30
|
+
},
|
|
5
31
|
Object {
|
|
6
32
|
"balance": "100000000000000000",
|
|
7
33
|
"currencyId": "filecoin",
|
|
@@ -59,6 +85,7 @@ Array [
|
|
|
59
85
|
|
|
60
86
|
exports[`filecoin currency bridge scanAccounts filecoin seed 1 2`] = `
|
|
61
87
|
Array [
|
|
88
|
+
Array [],
|
|
62
89
|
Array [
|
|
63
90
|
Object {
|
|
64
91
|
"accountId": "js:2:filecoin:f1p74d4mlmeyc4agflhjqsnvoyzyfdai7fmkyso2a:",
|
|
@@ -31,9 +31,13 @@ const filecoin: CurrenciesData<Transaction> = {
|
|
|
31
31
|
=> 06010000142c000080cd010080000000800000000000000000
|
|
32
32
|
<= 04ca7b02cafdf36e8b4caaf530a96b949764af71b956b2a3328b7a10940794c860f574a9199be98bde3c261887fec8e5fd94bc5f104908bf5f992f52ef2a89abb015017ff83e316c2605c018ab3a6126d5d8ce0a3023e529663170373464346d6c6d657963346167666c686a71736e766f797a796664616937666d6b79736f32619000
|
|
33
33
|
=> 0600000000
|
|
34
|
-
<=
|
|
34
|
+
<= 0000160500311000049000
|
|
35
35
|
=> 06010000142c00008001000080000000800000000000000000
|
|
36
|
-
<=
|
|
36
|
+
<= 04d493dab3ff63d6f0673454f8f6d6adec08db19e8c0298c65cfcace76a10757774afdee518b15a8b82452531bcb7860eefce02a89ef9051037646f5d4d6bd74171501eac14c6468ac13f66f0e0ee3766472c7e98394ab297431356c6175797a646976716a376d33796f623372786d7a6473793775796866666c777968657572699000
|
|
37
|
+
=> 0600000000
|
|
38
|
+
<= 0000160500311000049000
|
|
39
|
+
=> 06010000142c00008001000080000000800000000001000000
|
|
40
|
+
<= 040cbb57791d797268e34340565393f8a014ae754026159973fbe46bdcef3b6d28d155f4923256a2beb9bcff3bd39e5066d1c778306f28a2d4faa3a66dbf70453e150148c9b66fef1fce116652099bec6301ced31e56472974316a6465336d33377064376862637a737362676e36797979627a336a7234767368676370696b32619000
|
|
37
41
|
=> 0600000000
|
|
38
42
|
<= 0000160500311000049000
|
|
39
43
|
=> 06010000142c000080cd010080000000800000000001000000
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Fil from "@zondax/ledger-filecoin";
|
|
2
2
|
import { log } from "@ledgerhq/logs";
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { SignMessage, Result } from "../../hw/signMessage/types";
|
|
5
5
|
import { getBufferFromString, getPath, isError } from "./utils";
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const signMessage: SignMessage = async (
|
|
8
8
|
transport,
|
|
9
9
|
{ path, message }
|
|
10
10
|
): Promise<Result> => {
|
|
@@ -27,4 +27,4 @@ const resolver: Resolver = async (
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export default
|
|
30
|
+
export default { signMessage };
|
|
@@ -192,13 +192,15 @@ const osmosis: AppSpec<Transaction> = {
|
|
|
192
192
|
(d) => d.validatorAddress === v.address
|
|
193
193
|
);
|
|
194
194
|
invariant(d, "delegated %s must be found in account", v.address);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
195
|
+
botTest("delegator have planned address and amount", () =>
|
|
196
|
+
expect({
|
|
197
|
+
address: v.address,
|
|
198
|
+
amount: approximateValue(v.amount),
|
|
199
|
+
}).toMatchObject({
|
|
200
|
+
address: (d as CosmosDelegation).validatorAddress,
|
|
201
|
+
amount: approximateValue((d as CosmosDelegation).amount),
|
|
202
|
+
})
|
|
203
|
+
);
|
|
202
204
|
});
|
|
203
205
|
},
|
|
204
206
|
},
|
|
@@ -260,13 +262,15 @@ const osmosis: AppSpec<Transaction> = {
|
|
|
260
262
|
(d) => d.validatorAddress === v.address
|
|
261
263
|
);
|
|
262
264
|
invariant(d, "undelegated %s must be found in account", v.address);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
265
|
+
botTest("validator have planned address and amount", () =>
|
|
266
|
+
expect({
|
|
267
|
+
address: v.address,
|
|
268
|
+
amount: approximateValue(v.amount),
|
|
269
|
+
}).toMatchObject({
|
|
270
|
+
address: (d as CosmosUnbonding).validatorAddress,
|
|
271
|
+
amount: approximateValue((d as CosmosUnbonding).amount),
|
|
272
|
+
})
|
|
273
|
+
);
|
|
270
274
|
});
|
|
271
275
|
},
|
|
272
276
|
},
|
|
@@ -338,13 +342,15 @@ const osmosis: AppSpec<Transaction> = {
|
|
|
338
342
|
d.validatorSrcAddress === transaction.sourceValidator
|
|
339
343
|
);
|
|
340
344
|
invariant(d, "redelegated %s must be found in account", v.address);
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
345
|
+
botTest("validator have planned address and amount", () =>
|
|
346
|
+
expect({
|
|
347
|
+
address: v.address,
|
|
348
|
+
amount: approximateValue(v.amount),
|
|
349
|
+
}).toMatchObject({
|
|
350
|
+
address: (d as CosmosRedelegation).validatorDstAddress,
|
|
351
|
+
amount: approximateValue((d as CosmosRedelegation).amount),
|
|
352
|
+
})
|
|
353
|
+
);
|
|
348
354
|
}
|
|
349
355
|
});
|
|
350
356
|
},
|
|
@@ -385,10 +391,14 @@ const osmosis: AppSpec<Transaction> = {
|
|
|
385
391
|
const d = (cosmosResources as CosmosResources).delegations.find(
|
|
386
392
|
(d) => d.validatorAddress === v.address
|
|
387
393
|
);
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
394
|
+
botTest("delegation exists in account", () =>
|
|
395
|
+
invariant(d, "delegation %s must be found in account", v.address)
|
|
396
|
+
);
|
|
397
|
+
botTest("reward is no longer claimable after claim", () =>
|
|
398
|
+
invariant(
|
|
399
|
+
!canClaimRewards(account as CosmosAccount, d as CosmosDelegation),
|
|
400
|
+
"reward no longer be claimable"
|
|
401
|
+
)
|
|
392
402
|
);
|
|
393
403
|
});
|
|
394
404
|
},
|
|
@@ -191,21 +191,21 @@ export const fetchOperations = async ({
|
|
|
191
191
|
.includeFailed(true)
|
|
192
192
|
.join("transactions")
|
|
193
193
|
.call();
|
|
194
|
-
} catch (e:
|
|
194
|
+
} catch (e: unknown) {
|
|
195
195
|
// FIXME: terrible hacks, because Stellar SDK fails to cast network failures to typed errors in react-native...
|
|
196
196
|
// (https://github.com/stellar/js-stellar-sdk/issues/638)
|
|
197
|
-
const errorMsg = e ? e
|
|
197
|
+
const errorMsg = e ? String(e) : "";
|
|
198
198
|
|
|
199
199
|
if (e instanceof NotFoundError || errorMsg.match(/status code 404/)) {
|
|
200
200
|
return [];
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
if (errorMsg.match(/status code 4[0-9]{2}/)) {
|
|
204
|
-
|
|
204
|
+
throw new LedgerAPI4xx();
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
if (errorMsg.match(/status code 5[0-9]{2}/)) {
|
|
208
|
-
|
|
208
|
+
throw new LedgerAPI5xx();
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
if (
|
|
@@ -43,7 +43,7 @@ import { InvalidAddressBecauseAlreadyDelegated } from "../../../errors";
|
|
|
43
43
|
import api from "../api/tzkt";
|
|
44
44
|
|
|
45
45
|
const validateRecipient = (currency, recipient) => {
|
|
46
|
-
let recipientError = null;
|
|
46
|
+
let recipientError: Error | null = null;
|
|
47
47
|
const recipientWarning = null;
|
|
48
48
|
if (!recipient) {
|
|
49
49
|
recipientError = new RecipientRequired("");
|
|
@@ -90,7 +90,7 @@ const tron: AppSpec<Transaction> = {
|
|
|
90
90
|
},
|
|
91
91
|
test: ({ account }) => {
|
|
92
92
|
botTest("account spendable balance is zero", () =>
|
|
93
|
-
|
|
93
|
+
expectedApproximate(account.spendableBalance, new BigNumber(0))
|
|
94
94
|
);
|
|
95
95
|
},
|
|
96
96
|
},
|
|
@@ -50,9 +50,6 @@ export const defaultFeatures: DefaultFeatures = {
|
|
|
50
50
|
currencyFlareMobile: {
|
|
51
51
|
enabled: false,
|
|
52
52
|
},
|
|
53
|
-
currency: {
|
|
54
|
-
enabled: false,
|
|
55
|
-
},
|
|
56
53
|
ratings: {
|
|
57
54
|
enabled: false,
|
|
58
55
|
params: {
|
|
@@ -103,4 +100,13 @@ export const defaultFeatures: DefaultFeatures = {
|
|
|
103
100
|
counterValue: {
|
|
104
101
|
enabled: false,
|
|
105
102
|
},
|
|
103
|
+
llmUsbFirmwareUpdate: {
|
|
104
|
+
enabled: false,
|
|
105
|
+
},
|
|
106
|
+
ptxSmartRouting: {
|
|
107
|
+
enabled: false,
|
|
108
|
+
},
|
|
109
|
+
ptxSmartRoutingMobile: {
|
|
110
|
+
enabled: false,
|
|
111
|
+
},
|
|
106
112
|
};
|
package/src/hw/connectApp.ts
CHANGED