@ledgerhq/live-common 21.7.0 → 21.7.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.
- package/lib/env.d.ts +10 -5
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +5 -0
- package/lib/env.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/swap/getKYCStatus.d.ts.map +1 -1
- package/lib/exchange/swap/getKYCStatus.js +11 -5
- package/lib/exchange/swap/getKYCStatus.js.map +1 -1
- package/lib/exchange/swap/mock.d.ts +2 -1
- package/lib/exchange/swap/mock.d.ts.map +1 -1
- package/lib/exchange/swap/mock.js +15 -1
- package/lib/exchange/swap/mock.js.map +1 -1
- package/lib/families/bitcoin/specs.js +1 -1
- package/lib/families/bitcoin/specs.js.map +1 -1
- package/lib/families/elrond/test-dataset.d.ts.map +1 -1
- package/lib/families/elrond/test-dataset.js +79 -76
- package/lib/families/elrond/test-dataset.js.map +1 -1
- package/lib/families/ethereum/test-dataset.d.ts.map +1 -1
- package/lib/families/ethereum/test-dataset.js +2 -3
- package/lib/families/ethereum/test-dataset.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/__tests__/.DS_Store +0 -0
- package/src/__tests__/__snapshots__/.DS_Store +0 -0
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +26898 -111
- package/src/env.ts +5 -0
- package/src/exchange/swap/getKYCStatus.ts +5 -1
- package/src/exchange/swap/mock.ts +11 -0
- package/src/families/bitcoin/specs.ts +1 -1
- package/src/families/elrond/test-dataset.ts +89 -84
- package/src/families/ethereum/test-dataset.ts +2 -3
package/src/env.ts
CHANGED
|
@@ -366,6 +366,11 @@ const envDefinitions = {
|
|
|
366
366
|
parser: stringParser,
|
|
367
367
|
desc: "switch the app into a MOCK mode for test purpose, the value will be used as a seed for the rng. Avoid falsy values.",
|
|
368
368
|
},
|
|
369
|
+
MOCK_SWAP_KYC: {
|
|
370
|
+
def: "",
|
|
371
|
+
parser: stringParser,
|
|
372
|
+
desc: "mock the server response for the exchange KYC check, options are 'open', 'pending', 'closed' or 'approved'.",
|
|
373
|
+
},
|
|
369
374
|
OPERATION_ADDRESSES_LIMIT: {
|
|
370
375
|
def: 100,
|
|
371
376
|
parser: intParser,
|
|
@@ -2,11 +2,15 @@ import network from "../../network";
|
|
|
2
2
|
import { getSwapAPIBaseURL } from "./";
|
|
3
3
|
import type { GetKYCStatus } from "./types";
|
|
4
4
|
import { SwapCheckKYCStatusFailed } from "../../errors";
|
|
5
|
+
import { getEnv } from "../../env";
|
|
6
|
+
import { mockGetKYCStatus } from "./mock";
|
|
5
7
|
export const getKYCStatus: GetKYCStatus = async (
|
|
6
8
|
provider: string,
|
|
7
9
|
id: string
|
|
8
10
|
) => {
|
|
9
|
-
|
|
11
|
+
const mockedStatus = getEnv("MOCK_SWAP_KYC");
|
|
12
|
+
if (mockedStatus) return mockGetKYCStatus(id, mockedStatus);
|
|
13
|
+
|
|
10
14
|
const res = await network({
|
|
11
15
|
method: "GET",
|
|
12
16
|
url: `${getSwapAPIBaseURL()}/provider/${provider}/user/${id}`,
|
|
@@ -4,7 +4,9 @@ import type {
|
|
|
4
4
|
ExchangeRate,
|
|
5
5
|
GetMultipleStatus,
|
|
6
6
|
GetProviders,
|
|
7
|
+
KYCStatus,
|
|
7
8
|
SwapRequestEvent,
|
|
9
|
+
ValidKYCStatus,
|
|
8
10
|
} from "./types";
|
|
9
11
|
import { getAccountUnit } from "../../account";
|
|
10
12
|
import type { Transaction, TokenCurrency, CryptoCurrency } from "../../types";
|
|
@@ -176,3 +178,12 @@ export const mockGetStatus: GetMultipleStatus = async (statusList) => {
|
|
|
176
178
|
await new Promise((r) => setTimeout(r, 800));
|
|
177
179
|
return statusList.map((s) => ({ ...s, status: "finished" }));
|
|
178
180
|
};
|
|
181
|
+
|
|
182
|
+
export const mockGetKYCStatus = async (
|
|
183
|
+
id: string,
|
|
184
|
+
status: ValidKYCStatus
|
|
185
|
+
): Promise<KYCStatus> => {
|
|
186
|
+
//Fake delay to show the pending state in the UI
|
|
187
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
188
|
+
return { id, status };
|
|
189
|
+
};
|
|
@@ -5,101 +5,106 @@ import {
|
|
|
5
5
|
NotEnoughBalance,
|
|
6
6
|
InvalidAddress,
|
|
7
7
|
} from "@ledgerhq/errors";
|
|
8
|
-
import type { DatasetTest } from "../../types";
|
|
8
|
+
import type { DatasetTest, CurrenciesData } from "../../types";
|
|
9
9
|
import type { Transaction } from "./types";
|
|
10
10
|
const TEST_ADDRESS =
|
|
11
11
|
"erd1vgfp3g7azqjx4wsmtt7067m0l62v3psmqzr24j6xvywj2tlz0gesvyzsq2";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
|
+
const elrond: CurrenciesData<Transaction> = {
|
|
14
|
+
scanAccounts: [
|
|
15
|
+
{
|
|
16
|
+
name: "elrond seed 1",
|
|
17
|
+
apdus: `
|
|
18
|
+
=> ed030000080000000000000000
|
|
19
|
+
<= 3e6572643176676670336737617a716a783477736d7474373036376d306c3632763370736d717a7232346a36787679776a32746c7a3067657376797a7371329000
|
|
20
|
+
=> ed030000080000000080000000
|
|
21
|
+
<= 3e6572643176676670336737617a716a783477736d7474373036376d306c3632763370736d717a7232346a36787679776a32746c7a3067657376797a7371329000
|
|
22
|
+
=> ed030000080000000080000001
|
|
23
|
+
<= 3e65726431706d33676a65326c6d643576796c6463767579366a7078676465347261706a70756a76756a6b65653661376a77327a6d6834747172653739367a9000
|
|
24
|
+
`,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
accounts: [
|
|
28
|
+
{
|
|
29
|
+
raw: {
|
|
30
|
+
id: `js:2:elrond:${TEST_ADDRESS}:`,
|
|
31
|
+
seedIdentifier: `${TEST_ADDRESS}`,
|
|
32
|
+
name: "Elrond 1",
|
|
33
|
+
derivationMode: "",
|
|
34
|
+
index: 0,
|
|
35
|
+
freshAddress: `${TEST_ADDRESS}`,
|
|
36
|
+
freshAddressPath: "44'/508'/0'/0/0'",
|
|
37
|
+
freshAddresses: [],
|
|
38
|
+
blockHeight: 0,
|
|
39
|
+
operations: [],
|
|
40
|
+
pendingOperations: [],
|
|
41
|
+
currencyId: "elrond",
|
|
42
|
+
unitMagnitude: 10,
|
|
43
|
+
lastSyncDate: "",
|
|
44
|
+
balance: "299569965",
|
|
45
|
+
},
|
|
46
|
+
transactions: [
|
|
17
47
|
{
|
|
18
|
-
name: "
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
48
|
+
name: "recipient and sender must not be the same",
|
|
49
|
+
transaction: fromTransactionRaw({
|
|
50
|
+
family: "elrond",
|
|
51
|
+
recipient: `${TEST_ADDRESS}`,
|
|
52
|
+
amount: "100000000",
|
|
53
|
+
mode: "send",
|
|
54
|
+
fees: null,
|
|
55
|
+
}),
|
|
56
|
+
expectedStatus: {
|
|
57
|
+
amount: new BigNumber("100000000"),
|
|
58
|
+
errors: {
|
|
59
|
+
recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
|
|
60
|
+
},
|
|
61
|
+
warnings: {},
|
|
62
|
+
},
|
|
27
63
|
},
|
|
28
|
-
],
|
|
29
|
-
accounts: [
|
|
30
64
|
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
pendingOperations: [],
|
|
43
|
-
currencyId: "elrond",
|
|
44
|
-
unitMagnitude: 10,
|
|
45
|
-
lastSyncDate: "",
|
|
46
|
-
balance: "299569965",
|
|
47
|
-
},
|
|
48
|
-
transactions: [
|
|
49
|
-
{
|
|
50
|
-
name: "recipient and sender must not be the same",
|
|
51
|
-
transaction: fromTransactionRaw({
|
|
52
|
-
family: "elrond",
|
|
53
|
-
recipient: `${TEST_ADDRESS}`,
|
|
54
|
-
amount: "100000000",
|
|
55
|
-
mode: "send",
|
|
56
|
-
fees: null,
|
|
57
|
-
}),
|
|
58
|
-
expectedStatus: {
|
|
59
|
-
amount: new BigNumber("100000000"),
|
|
60
|
-
errors: {
|
|
61
|
-
recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
|
|
62
|
-
},
|
|
63
|
-
warnings: {},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: "Not a valid address",
|
|
68
|
-
transaction: fromTransactionRaw({
|
|
69
|
-
family: "elrond",
|
|
70
|
-
recipient: "elrondinv",
|
|
71
|
-
amount: "100000000",
|
|
72
|
-
mode: "send",
|
|
73
|
-
fees: null,
|
|
74
|
-
}),
|
|
75
|
-
expectedStatus: {
|
|
76
|
-
errors: {
|
|
77
|
-
recipient: new InvalidAddress(),
|
|
78
|
-
},
|
|
79
|
-
warnings: {},
|
|
80
|
-
},
|
|
65
|
+
name: "Not a valid address",
|
|
66
|
+
transaction: fromTransactionRaw({
|
|
67
|
+
family: "elrond",
|
|
68
|
+
recipient: "elrondinv",
|
|
69
|
+
amount: "100000000",
|
|
70
|
+
mode: "send",
|
|
71
|
+
fees: null,
|
|
72
|
+
}),
|
|
73
|
+
expectedStatus: {
|
|
74
|
+
errors: {
|
|
75
|
+
recipient: new InvalidAddress(),
|
|
81
76
|
},
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
77
|
+
warnings: {},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "Not enough balance",
|
|
82
|
+
transaction: fromTransactionRaw({
|
|
83
|
+
family: "elrond",
|
|
84
|
+
recipient:
|
|
85
|
+
"erd1frj909pfums4m8aza596595l9pl56crwdj077vs2aqcw6ynl28wsfkw9rd",
|
|
86
|
+
amount: "1000000000000000000000000",
|
|
87
|
+
mode: "send",
|
|
88
|
+
fees: null,
|
|
89
|
+
}),
|
|
90
|
+
expectedStatus: {
|
|
91
|
+
errors: {
|
|
92
|
+
amount: new NotEnoughBalance(),
|
|
98
93
|
},
|
|
99
|
-
|
|
94
|
+
warnings: {},
|
|
95
|
+
},
|
|
100
96
|
},
|
|
101
97
|
],
|
|
102
98
|
},
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const dataset: DatasetTest<Transaction> = {
|
|
103
|
+
implementations: ["js"],
|
|
104
|
+
currencies: {
|
|
105
|
+
// FIXME: temporarily disabled until a solution is found for an inconstency between two sync
|
|
106
|
+
// elrond,
|
|
103
107
|
},
|
|
104
108
|
};
|
|
109
|
+
|
|
105
110
|
export default dataset;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "@ledgerhq/errors";
|
|
9
9
|
import { fromTransactionRaw } from "./transaction";
|
|
10
10
|
import type { Transaction } from "./types";
|
|
11
|
-
|
|
11
|
+
import ethereumScanAccounts1 from "./datasets/ethereum.scanAccounts.1";
|
|
12
12
|
import ethereum_classic from "./datasets/ethereum_classic";
|
|
13
13
|
import { syncAccount } from "../../__tests__/test-helpers/bridge";
|
|
14
14
|
export const ethereum1: AccountRaw = {
|
|
@@ -39,8 +39,7 @@ const dataset: DatasetTest<Transaction> = {
|
|
|
39
39
|
implementations: ["mock", "js"],
|
|
40
40
|
currencies: {
|
|
41
41
|
ethereum: {
|
|
42
|
-
scanAccounts: [],
|
|
43
|
-
// scanAccounts: [ethereumScanAccounts1],
|
|
42
|
+
scanAccounts: [ethereumScanAccounts1],
|
|
44
43
|
accounts: [
|
|
45
44
|
{
|
|
46
45
|
implementations: ["js"],
|