@ledgerhq/live-common 34.40.0-nightly.3 → 34.40.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/e2e/enum/Provider.d.ts +0 -3
- package/lib/e2e/enum/Provider.d.ts.map +1 -1
- package/lib/e2e/enum/Provider.js +0 -3
- package/lib/e2e/enum/Provider.js.map +1 -1
- package/lib/exchange/error.d.ts +0 -1
- package/lib/exchange/error.d.ts.map +1 -1
- package/lib/exchange/error.js +1 -11
- package/lib/exchange/error.js.map +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.js +1 -1
- package/lib/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/lib/exchange/swap/postSwapState.d.ts.map +1 -1
- package/lib/exchange/swap/postSwapState.js +9 -19
- package/lib/exchange/swap/postSwapState.js.map +1 -1
- package/lib/exchange/swap/setBroadcastTransaction.d.ts +2 -3
- package/lib/exchange/swap/setBroadcastTransaction.d.ts.map +1 -1
- package/lib/exchange/swap/setBroadcastTransaction.js +2 -4
- package/lib/exchange/swap/setBroadcastTransaction.js.map +1 -1
- package/lib/exchange/swap/types.d.ts +0 -59
- package/lib/exchange/swap/types.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +0 -1
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/hw/connectManager.js +6 -6
- package/lib/hw/connectManager.js.map +1 -1
- package/lib/hw/getOnboardingStatePolling.d.ts.map +1 -1
- package/lib/hw/getOnboardingStatePolling.js +2 -0
- package/lib/hw/getOnboardingStatePolling.js.map +1 -1
- package/lib/hw/getOnboardingStatePolling.test.js +24 -0
- package/lib/hw/getOnboardingStatePolling.test.js.map +1 -1
- package/lib/wallet-api/Exchange/server.d.ts +10 -29
- package/lib/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib/wallet-api/Exchange/server.js +7 -204
- package/lib/wallet-api/Exchange/server.js.map +1 -1
- package/lib/wallet-api/Exchange/server.test.js +1 -3
- package/lib/wallet-api/Exchange/server.test.js.map +1 -1
- package/lib-es/e2e/enum/Provider.d.ts +0 -3
- package/lib-es/e2e/enum/Provider.d.ts.map +1 -1
- package/lib-es/e2e/enum/Provider.js +0 -3
- package/lib-es/e2e/enum/Provider.js.map +1 -1
- package/lib-es/exchange/error.d.ts +0 -1
- package/lib-es/exchange/error.d.ts.map +1 -1
- package/lib-es/exchange/error.js +0 -9
- package/lib-es/exchange/error.js.map +1 -1
- package/lib-es/exchange/swap/getCompleteSwapHistory.js +1 -1
- package/lib-es/exchange/swap/getCompleteSwapHistory.js.map +1 -1
- package/lib-es/exchange/swap/postSwapState.d.ts.map +1 -1
- package/lib-es/exchange/swap/postSwapState.js +7 -17
- package/lib-es/exchange/swap/postSwapState.js.map +1 -1
- package/lib-es/exchange/swap/setBroadcastTransaction.d.ts +2 -3
- package/lib-es/exchange/swap/setBroadcastTransaction.d.ts.map +1 -1
- package/lib-es/exchange/swap/setBroadcastTransaction.js +2 -4
- package/lib-es/exchange/swap/setBroadcastTransaction.js.map +1 -1
- package/lib-es/exchange/swap/types.d.ts +0 -59
- package/lib-es/exchange/swap/types.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +0 -1
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/hw/connectManager.js +6 -6
- package/lib-es/hw/connectManager.js.map +1 -1
- package/lib-es/hw/getOnboardingStatePolling.d.ts.map +1 -1
- package/lib-es/hw/getOnboardingStatePolling.js +2 -0
- package/lib-es/hw/getOnboardingStatePolling.js.map +1 -1
- package/lib-es/hw/getOnboardingStatePolling.test.js +24 -0
- package/lib-es/hw/getOnboardingStatePolling.test.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.d.ts +10 -29
- package/lib-es/wallet-api/Exchange/server.d.ts.map +1 -1
- package/lib-es/wallet-api/Exchange/server.js +9 -206
- package/lib-es/wallet-api/Exchange/server.js.map +1 -1
- package/lib-es/wallet-api/Exchange/server.test.js +1 -3
- package/lib-es/wallet-api/Exchange/server.test.js.map +1 -1
- package/package.json +45 -45
- package/src/e2e/enum/Provider.ts +0 -3
- package/src/exchange/error.ts +0 -10
- package/src/exchange/swap/getCompleteSwapHistory.ts +1 -1
- package/src/exchange/swap/postSwapState.ts +6 -24
- package/src/exchange/swap/setBroadcastTransaction.ts +2 -6
- package/src/exchange/swap/types.ts +0 -64
- package/src/featureFlags/defaultFeatures.ts +0 -1
- package/src/hw/connectManager.ts +14 -14
- package/src/hw/getOnboardingStatePolling.test.ts +29 -0
- package/src/hw/getOnboardingStatePolling.ts +2 -0
- package/src/wallet-api/Exchange/server.test.ts +5 -7
- package/src/wallet-api/Exchange/server.ts +32 -344
- package/lib/exchange/swap/api/v5/actions.d.ts +0 -3
- package/lib/exchange/swap/api/v5/actions.d.ts.map +0 -1
- package/lib/exchange/swap/api/v5/actions.js +0 -36
- package/lib/exchange/swap/api/v5/actions.js.map +0 -1
- package/lib/exchange/swap/transactionStrategies.d.ts +0 -25
- package/lib/exchange/swap/transactionStrategies.d.ts.map +0 -1
- package/lib/exchange/swap/transactionStrategies.js +0 -152
- package/lib/exchange/swap/transactionStrategies.js.map +0 -1
- package/lib-es/exchange/swap/api/v5/actions.d.ts +0 -3
- package/lib-es/exchange/swap/api/v5/actions.d.ts.map +0 -1
- package/lib-es/exchange/swap/api/v5/actions.js +0 -29
- package/lib-es/exchange/swap/api/v5/actions.js.map +0 -1
- package/lib-es/exchange/swap/transactionStrategies.d.ts +0 -25
- package/lib-es/exchange/swap/transactionStrategies.d.ts.map +0 -1
- package/lib-es/exchange/swap/transactionStrategies.js +0 -140
- package/lib-es/exchange/swap/transactionStrategies.js.map +0 -1
- package/src/exchange/swap/api/v5/actions.ts +0 -36
- package/src/exchange/swap/transactionStrategies.ts +0 -234
@@ -11,15 +11,13 @@ export const setBroadcastTransaction = ({
|
|
11
11
|
targetCurrencyId,
|
12
12
|
hardwareWalletType,
|
13
13
|
swapType,
|
14
|
-
swapAppVersion,
|
15
14
|
}: {
|
16
|
-
result: { operation: Operation
|
15
|
+
result: { operation: Operation; swapId: string };
|
17
16
|
provider: string;
|
18
17
|
sourceCurrencyId?: string;
|
19
18
|
targetCurrencyId?: string;
|
20
19
|
hardwareWalletType?: DeviceModelId;
|
21
20
|
swapType?: TradeMethod;
|
22
|
-
swapAppVersion?: string;
|
23
21
|
}) => {
|
24
22
|
const { operation, swapId } = result;
|
25
23
|
|
@@ -38,18 +36,16 @@ export const setBroadcastTransaction = ({
|
|
38
36
|
targetCurrencyId,
|
39
37
|
hardwareWalletType,
|
40
38
|
swapType: swapType,
|
41
|
-
swapAppVersion,
|
42
39
|
});
|
43
40
|
} else {
|
44
41
|
postSwapAccepted({
|
45
42
|
provider,
|
46
43
|
swapId,
|
47
|
-
transactionId:
|
44
|
+
transactionId: operation.hash,
|
48
45
|
sourceCurrencyId,
|
49
46
|
targetCurrencyId,
|
50
47
|
hardwareWalletType,
|
51
48
|
swapType,
|
52
|
-
swapAppVersion,
|
53
49
|
});
|
54
50
|
}
|
55
51
|
};
|
@@ -4,7 +4,6 @@ import { Account, AccountLike, AccountRaw, AccountRawLike, Operation } from "@le
|
|
4
4
|
import { BigNumber } from "bignumber.js";
|
5
5
|
import { Result as UseBridgeTransactionResult } from "../../bridge/useBridgeTransaction";
|
6
6
|
import { Transaction, TransactionRaw } from "../../generated/types";
|
7
|
-
|
8
7
|
export type { SwapLiveError } from "@ledgerhq/wallet-api-exchange-module";
|
9
8
|
|
10
9
|
export type ExchangeSwap = {
|
@@ -199,7 +198,6 @@ type SwapStateRequest = {
|
|
199
198
|
targetCurrencyId: string;
|
200
199
|
hardwareWalletType: DeviceModelId;
|
201
200
|
swapType: TradeMethod;
|
202
|
-
swapAppVersion?: string;
|
203
201
|
}>;
|
204
202
|
|
205
203
|
export type SwapStateAcceptedRequest = SwapStateRequest & {
|
@@ -338,65 +336,3 @@ export type SwapTransactionType = UseBridgeTransactionResult & {
|
|
338
336
|
fromAmountError?: Error;
|
339
337
|
fromAmountWarning?: Error;
|
340
338
|
};
|
341
|
-
|
342
|
-
export type SwapPayloadRequestData = {
|
343
|
-
provider: string;
|
344
|
-
deviceTransactionId: string;
|
345
|
-
fromAccountAddress: string;
|
346
|
-
toAccountAddress: string;
|
347
|
-
fromAccountCurrency: string;
|
348
|
-
toAccountCurrency: string;
|
349
|
-
amount: string;
|
350
|
-
amountInAtomicUnit: number;
|
351
|
-
quoteId?: string;
|
352
|
-
toNewTokenId?: string;
|
353
|
-
};
|
354
|
-
export type SwapPayloadResponse = {
|
355
|
-
binaryPayload: string;
|
356
|
-
signature: string;
|
357
|
-
payinAddress: string;
|
358
|
-
swapId: string;
|
359
|
-
payinExtraId?: string;
|
360
|
-
extraTransactionParameters?: string;
|
361
|
-
};
|
362
|
-
|
363
|
-
export type ConfirmSwapRequest = {
|
364
|
-
provider: string;
|
365
|
-
swapId: string;
|
366
|
-
transactionId: string;
|
367
|
-
sourceCurrencyId?: string;
|
368
|
-
targetCurrencyId?: string;
|
369
|
-
hardwareWalletType?: string;
|
370
|
-
};
|
371
|
-
|
372
|
-
export type CancelSwapRequest = {
|
373
|
-
provider: string;
|
374
|
-
swapId: string;
|
375
|
-
statusCode?: string;
|
376
|
-
errorMessage?: string;
|
377
|
-
sourceCurrencyId?: string;
|
378
|
-
targetCurrencyId?: string;
|
379
|
-
hardwareWalletType?: string;
|
380
|
-
swapType?: string;
|
381
|
-
swapStep?: string;
|
382
|
-
};
|
383
|
-
|
384
|
-
export type SwapBackendResponse = {
|
385
|
-
provider: string;
|
386
|
-
swapId: string;
|
387
|
-
apiExtraFee: number;
|
388
|
-
apiFee: number;
|
389
|
-
refundAddress: string;
|
390
|
-
amountExpectedFrom: number;
|
391
|
-
amountExpectedTo: number;
|
392
|
-
status: string;
|
393
|
-
from: string;
|
394
|
-
to: string;
|
395
|
-
payinAddress: string;
|
396
|
-
payoutAddress: string;
|
397
|
-
createdAt: string; // ISO-8601
|
398
|
-
binaryPayload: string;
|
399
|
-
signature: string;
|
400
|
-
payinExtraId?: string;
|
401
|
-
extraTransactionParameters?: string;
|
402
|
-
};
|
package/src/hw/connectManager.ts
CHANGED
@@ -64,6 +64,20 @@ const cmd = (transport: Transport, { request }: Input): Observable<ConnectManage
|
|
64
64
|
throw new DeviceNotOnboarded();
|
65
65
|
}
|
66
66
|
|
67
|
+
if (deviceInfo.isBootloader) {
|
68
|
+
return of({
|
69
|
+
type: "bootloader",
|
70
|
+
deviceInfo,
|
71
|
+
} as ConnectManagerEvent);
|
72
|
+
}
|
73
|
+
|
74
|
+
if (deviceInfo.isOSU) {
|
75
|
+
return of({
|
76
|
+
type: "osu",
|
77
|
+
deviceInfo,
|
78
|
+
} as ConnectManagerEvent);
|
79
|
+
}
|
80
|
+
|
67
81
|
if (
|
68
82
|
isCharonSupported(
|
69
83
|
deviceInfo.seVersion ?? "",
|
@@ -79,20 +93,6 @@ const cmd = (transport: Transport, { request }: Input): Observable<ConnectManage
|
|
79
93
|
}
|
80
94
|
}
|
81
95
|
|
82
|
-
if (deviceInfo.isBootloader) {
|
83
|
-
return of({
|
84
|
-
type: "bootloader",
|
85
|
-
deviceInfo,
|
86
|
-
} as ConnectManagerEvent);
|
87
|
-
}
|
88
|
-
|
89
|
-
if (deviceInfo.isOSU) {
|
90
|
-
return of({
|
91
|
-
type: "osu",
|
92
|
-
deviceInfo,
|
93
|
-
} as ConnectManagerEvent);
|
94
|
-
}
|
95
|
-
|
96
96
|
return concat(
|
97
97
|
of({
|
98
98
|
type: "listingApps",
|
@@ -13,6 +13,7 @@ import { withDevice } from "./deviceAccess";
|
|
13
13
|
import { getVersion } from "../device/use-cases/getVersionUseCase";
|
14
14
|
import { extractOnboardingState, OnboardingState, OnboardingStep } from "./extractOnboardingState";
|
15
15
|
import { SeedPhraseType } from "@ledgerhq/types-live";
|
16
|
+
import { DeviceDisconnectedWhileSendingError } from "@ledgerhq/device-management-kit";
|
16
17
|
|
17
18
|
jest.mock("./deviceAccess");
|
18
19
|
jest.mock("../device/use-cases/getVersionUseCase");
|
@@ -95,6 +96,34 @@ describe("getOnboardingStatePolling", () => {
|
|
95
96
|
// The timeout is equal to pollingPeriodMs by default
|
96
97
|
jest.advanceTimersByTime(pollingPeriodMs - 1);
|
97
98
|
});
|
99
|
+
|
100
|
+
it("should update the onboarding state to null and keep track of the allowed DMK error", done => {
|
101
|
+
mockedGetVersion.mockRejectedValue(
|
102
|
+
new DeviceDisconnectedWhileSendingError("An allowed error"),
|
103
|
+
);
|
104
|
+
mockedExtractOnboardingState.mockReturnValue(anOnboardingState);
|
105
|
+
|
106
|
+
const device = aDevice;
|
107
|
+
|
108
|
+
getOnboardingStatePolling({
|
109
|
+
deviceId: device.deviceId,
|
110
|
+
pollingPeriodMs,
|
111
|
+
}).subscribe({
|
112
|
+
next: value => {
|
113
|
+
try {
|
114
|
+
expect(value.onboardingState).toBeNull();
|
115
|
+
expect(value.allowedError).toBeInstanceOf(DeviceDisconnectedWhileSendingError);
|
116
|
+
expect(value.lockedDevice).toBe(false);
|
117
|
+
done();
|
118
|
+
} catch (expectError) {
|
119
|
+
done(expectError);
|
120
|
+
}
|
121
|
+
},
|
122
|
+
});
|
123
|
+
|
124
|
+
// The timeout is equal to pollingPeriodMs by default
|
125
|
+
jest.advanceTimersByTime(pollingPeriodMs - 1);
|
126
|
+
});
|
98
127
|
});
|
99
128
|
|
100
129
|
describe("and when the error is due to a locked device", () => {
|
@@ -16,6 +16,7 @@ import {
|
|
16
16
|
} from "@ledgerhq/errors";
|
17
17
|
import { FirmwareInfo } from "@ledgerhq/types-live";
|
18
18
|
import { extractOnboardingState, OnboardingState } from "./extractOnboardingState";
|
19
|
+
import { DeviceDisconnectedWhileSendingError } from "@ledgerhq/device-management-kit";
|
19
20
|
|
20
21
|
export type OnboardingStatePollingResult = {
|
21
22
|
onboardingState: OnboardingState | null;
|
@@ -143,6 +144,7 @@ export const isAllowedOnboardingStatePollingError = (error: unknown): boolean =>
|
|
143
144
|
error instanceof TransportExchangeTimeoutError ||
|
144
145
|
error instanceof DisconnectedDevice ||
|
145
146
|
error instanceof DisconnectedDeviceDuringOperation ||
|
147
|
+
error instanceof DeviceDisconnectedWhileSendingError ||
|
146
148
|
error instanceof CantOpenDevice ||
|
147
149
|
error instanceof TransportRaceCondition ||
|
148
150
|
error instanceof TransportStatusError ||
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import {
|
1
|
+
import { handlers } from "./server";
|
2
|
+
import { AppBranch, AppPlatform, Visibility } from "../types";
|
3
|
+
import { of } from "rxjs";
|
2
4
|
import {
|
3
5
|
ExchangeStartParams,
|
4
6
|
ExchangeStartSellParams,
|
5
7
|
ExchangeStartSwapParams,
|
6
8
|
} from "@ledgerhq/wallet-api-exchange-module";
|
7
|
-
import {
|
8
|
-
import { of } from "rxjs";
|
9
|
+
import { RpcRequest } from "@ledgerhq/wallet-api-core";
|
9
10
|
import { genAccount } from "../../mock/account";
|
10
|
-
import {
|
11
|
-
import { handlers } from "./server";
|
11
|
+
import { WalletContext, WalletHandlers } from "@ledgerhq/wallet-api-server";
|
12
12
|
|
13
13
|
const mockTracking = {
|
14
14
|
startExchangeRequested: jest.fn(),
|
@@ -46,7 +46,6 @@ const testAppManifest = {
|
|
46
46
|
|
47
47
|
const mockUiStartExchange = jest.fn();
|
48
48
|
const mockUiCompleteExchange = jest.fn();
|
49
|
-
const mockUiSwap = jest.fn();
|
50
49
|
const mockUiError = jest.fn();
|
51
50
|
const mockIsReady = jest.fn();
|
52
51
|
|
@@ -55,7 +54,6 @@ const mockUiHooks = {
|
|
55
54
|
"custom.exchange.complete": mockUiCompleteExchange,
|
56
55
|
"custom.exchange.error": mockUiError,
|
57
56
|
"custom.isReady": mockIsReady,
|
58
|
-
"custom.exchange.swap": mockUiSwap,
|
59
57
|
};
|
60
58
|
|
61
59
|
// Mock converter id to send back the id received in params.
|