@ledgerhq/live-common 34.49.0-nightly.3 → 34.49.0-nightly.5
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/bridge/react/BridgeSync.d.ts.map +1 -1
- package/lib/bridge/react/BridgeSync.js +17 -4
- package/lib/bridge/react/BridgeSync.js.map +1 -1
- package/lib/bridge/syncSessionManager/index.d.ts +18 -0
- package/lib/bridge/syncSessionManager/index.d.ts.map +1 -0
- package/lib/bridge/syncSessionManager/index.js +75 -0
- package/lib/bridge/syncSessionManager/index.js.map +1 -0
- package/lib/bridge/syncSessionManager/index.test.d.ts +2 -0
- package/lib/bridge/syncSessionManager/index.test.d.ts.map +1 -0
- package/lib/bridge/syncSessionManager/index.test.js +118 -0
- package/lib/bridge/syncSessionManager/index.test.js.map +1 -0
- package/lib/deposit/deposit.integration.test.js +60 -1
- package/lib/deposit/deposit.integration.test.js.map +1 -1
- package/lib/e2e/data/deviceLabelsData.js +2 -2
- package/lib/e2e/data/deviceLabelsData.js.map +1 -1
- package/lib/e2e/enum/Account.d.ts +1 -0
- package/lib/e2e/enum/Account.d.ts.map +1 -1
- package/lib/e2e/enum/Account.js +2 -1
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/DeviceLabels.d.ts +3 -9
- package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib/e2e/enum/DeviceLabels.js +2 -8
- package/lib/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib/e2e/families/bitcoin.d.ts +1 -0
- package/lib/e2e/families/bitcoin.d.ts.map +1 -1
- package/lib/e2e/families/bitcoin.js +28 -1
- package/lib/e2e/families/bitcoin.js.map +1 -1
- package/lib/e2e/families/tezos.d.ts.map +1 -1
- package/lib/e2e/families/tezos.js +5 -3
- package/lib/e2e/families/tezos.js.map +1 -1
- package/lib/e2e/index.d.ts +2 -0
- package/lib/e2e/index.d.ts.map +1 -1
- package/lib/e2e/models/Swap.d.ts +2 -0
- package/lib/e2e/models/Swap.d.ts.map +1 -1
- package/lib/e2e/models/Swap.js +6 -0
- package/lib/e2e/models/Swap.js.map +1 -1
- package/lib/e2e/speculos.d.ts +8 -0
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +23 -31
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/exchange/providers/swap.js +2 -2
- package/lib/exchange/providers/swap.js.map +1 -1
- package/lib/families/celo/bridge.integration.test.js +4 -1
- package/lib/families/celo/bridge.integration.test.js.map +1 -1
- package/lib/families/cosmos/datasets/axelar.integration.test.js +4 -1
- package/lib/families/cosmos/datasets/axelar.integration.test.js.map +1 -1
- package/lib/families/cosmos/datasets/desmos.integration.test.js +4 -1
- package/lib/families/cosmos/datasets/desmos.integration.test.js.map +1 -1
- package/lib/families/cosmos/datasets/onomy.integration.test.js +4 -1
- package/lib/families/cosmos/datasets/onomy.integration.test.js.map +1 -1
- package/lib/families/filecoin/bridge.integration.test.js +4 -1
- package/lib/families/filecoin/bridge.integration.test.js.map +1 -1
- package/lib/families/kaspa/bridge.integration.test.js +4 -1
- package/lib/families/kaspa/bridge.integration.test.js.map +1 -1
- package/lib/families/mina/bridge.integration.test.js +4 -1
- package/lib/families/mina/bridge.integration.test.js.map +1 -1
- package/lib/families/multiversx/synchronisation.integration.test.js +4 -1
- package/lib/families/multiversx/synchronisation.integration.test.js.map +1 -1
- package/lib/families/ton/bridge.integration.test.js +4 -1
- package/lib/families/ton/bridge.integration.test.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +1 -0
- package/lib/featureFlags/defaultFeatures.js.map +1 -1
- package/lib/featureFlags/useFeature.d.ts +1 -1
- package/lib/featureFlags/useFeature.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts +1 -0
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/modules/useLeftMarketTrendModule.d.ts +1 -0
- package/lib/modularDrawer/hooks/modules/useLeftMarketTrendModule.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/modules/useRightMarketTrendModule.d.ts +1 -0
- package/lib/modularDrawer/hooks/modules/useRightMarketTrendModule.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
- package/lib/notifications/ServiceStatusProvider/entry-points.d.ts +3 -0
- package/lib/notifications/ServiceStatusProvider/entry-points.d.ts.map +1 -0
- package/lib/notifications/ServiceStatusProvider/entry-points.js +3 -0
- package/lib/notifications/ServiceStatusProvider/entry-points.js.map +1 -0
- package/lib/notifications/ServiceStatusProvider/index.d.ts +18 -1
- package/lib/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.js +47 -9
- package/lib/notifications/ServiceStatusProvider/index.js.map +1 -1
- package/lib/notifications/ServiceStatusProvider/index.test.d.ts +2 -0
- package/lib/notifications/ServiceStatusProvider/index.test.d.ts.map +1 -0
- package/lib/notifications/ServiceStatusProvider/index.test.js +88 -0
- package/lib/notifications/ServiceStatusProvider/index.test.js.map +1 -0
- package/lib/notifications/ServiceStatusProvider/ledger-components.d.ts +2 -0
- package/lib/notifications/ServiceStatusProvider/ledger-components.d.ts.map +1 -0
- package/lib/notifications/ServiceStatusProvider/ledger-components.js +17 -0
- package/lib/notifications/ServiceStatusProvider/ledger-components.js.map +1 -0
- package/lib/notifications/ServiceStatusProvider/mocks/ledgerStatus.d.ts +154 -0
- package/lib/notifications/ServiceStatusProvider/mocks/ledgerStatus.d.ts.map +1 -0
- package/lib/notifications/ServiceStatusProvider/mocks/ledgerStatus.js +1192 -0
- package/lib/notifications/ServiceStatusProvider/mocks/ledgerStatus.js.map +1 -0
- package/lib/notifications/ServiceStatusProvider/types.d.ts +3 -1
- package/lib/notifications/ServiceStatusProvider/types.d.ts.map +1 -1
- package/lib/wallet-api/react.d.ts +1 -1
- package/lib/wallet-api/react.d.ts.map +1 -1
- package/lib/wallet-api/react.js +1 -1
- package/lib/wallet-api/react.js.map +1 -1
- package/lib-es/bridge/react/BridgeSync.d.ts.map +1 -1
- package/lib-es/bridge/react/BridgeSync.js +17 -4
- package/lib-es/bridge/react/BridgeSync.js.map +1 -1
- package/lib-es/bridge/syncSessionManager/index.d.ts +18 -0
- package/lib-es/bridge/syncSessionManager/index.d.ts.map +1 -0
- package/lib-es/bridge/syncSessionManager/index.js +68 -0
- package/lib-es/bridge/syncSessionManager/index.js.map +1 -0
- package/lib-es/bridge/syncSessionManager/index.test.d.ts +2 -0
- package/lib-es/bridge/syncSessionManager/index.test.d.ts.map +1 -0
- package/lib-es/bridge/syncSessionManager/index.test.js +116 -0
- package/lib-es/bridge/syncSessionManager/index.test.js.map +1 -0
- package/lib-es/deposit/deposit.integration.test.js +37 -1
- package/lib-es/deposit/deposit.integration.test.js.map +1 -1
- package/lib-es/e2e/data/deviceLabelsData.js +2 -2
- package/lib-es/e2e/data/deviceLabelsData.js.map +1 -1
- package/lib-es/e2e/enum/Account.d.ts +1 -0
- package/lib-es/e2e/enum/Account.d.ts.map +1 -1
- package/lib-es/e2e/enum/Account.js +2 -1
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.d.ts +3 -9
- package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.js +2 -8
- package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib-es/e2e/families/bitcoin.d.ts +1 -0
- package/lib-es/e2e/families/bitcoin.d.ts.map +1 -1
- package/lib-es/e2e/families/bitcoin.js +27 -1
- package/lib-es/e2e/families/bitcoin.js.map +1 -1
- package/lib-es/e2e/families/tezos.d.ts.map +1 -1
- package/lib-es/e2e/families/tezos.js +6 -4
- package/lib-es/e2e/families/tezos.js.map +1 -1
- package/lib-es/e2e/index.d.ts +2 -0
- package/lib-es/e2e/index.d.ts.map +1 -1
- package/lib-es/e2e/models/Swap.d.ts +2 -0
- package/lib-es/e2e/models/Swap.d.ts.map +1 -1
- package/lib-es/e2e/models/Swap.js +6 -0
- package/lib-es/e2e/models/Swap.js.map +1 -1
- package/lib-es/e2e/speculos.d.ts +8 -0
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +23 -32
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/exchange/providers/swap.js +2 -2
- package/lib-es/exchange/providers/swap.js.map +1 -1
- package/lib-es/families/celo/bridge.integration.test.js +4 -1
- package/lib-es/families/celo/bridge.integration.test.js.map +1 -1
- package/lib-es/families/cosmos/datasets/axelar.integration.test.js +4 -1
- package/lib-es/families/cosmos/datasets/axelar.integration.test.js.map +1 -1
- package/lib-es/families/cosmos/datasets/desmos.integration.test.js +4 -1
- package/lib-es/families/cosmos/datasets/desmos.integration.test.js.map +1 -1
- package/lib-es/families/cosmos/datasets/onomy.integration.test.js +4 -1
- package/lib-es/families/cosmos/datasets/onomy.integration.test.js.map +1 -1
- package/lib-es/families/filecoin/bridge.integration.test.js +4 -1
- package/lib-es/families/filecoin/bridge.integration.test.js.map +1 -1
- package/lib-es/families/kaspa/bridge.integration.test.js +4 -1
- package/lib-es/families/kaspa/bridge.integration.test.js.map +1 -1
- package/lib-es/families/mina/bridge.integration.test.js +4 -1
- package/lib-es/families/mina/bridge.integration.test.js.map +1 -1
- package/lib-es/families/multiversx/synchronisation.integration.test.js +4 -1
- package/lib-es/families/multiversx/synchronisation.integration.test.js.map +1 -1
- package/lib-es/families/ton/bridge.integration.test.js +4 -1
- package/lib-es/families/ton/bridge.integration.test.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +1 -0
- package/lib-es/featureFlags/defaultFeatures.js.map +1 -1
- package/lib-es/featureFlags/useFeature.d.ts +1 -1
- package/lib-es/featureFlags/useFeature.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts +1 -0
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/modules/useLeftMarketTrendModule.d.ts +1 -0
- package/lib-es/modularDrawer/hooks/modules/useLeftMarketTrendModule.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/modules/useRightMarketTrendModule.d.ts +1 -0
- package/lib-es/modularDrawer/hooks/modules/useRightMarketTrendModule.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/entry-points.d.ts +3 -0
- package/lib-es/notifications/ServiceStatusProvider/entry-points.d.ts.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/entry-points.js +2 -0
- package/lib-es/notifications/ServiceStatusProvider/entry-points.js.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/index.d.ts +18 -1
- package/lib-es/notifications/ServiceStatusProvider/index.d.ts.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.js +47 -9
- package/lib-es/notifications/ServiceStatusProvider/index.js.map +1 -1
- package/lib-es/notifications/ServiceStatusProvider/index.test.d.ts +2 -0
- package/lib-es/notifications/ServiceStatusProvider/index.test.d.ts.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/index.test.js +86 -0
- package/lib-es/notifications/ServiceStatusProvider/index.test.js.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/ledger-components.d.ts +2 -0
- package/lib-es/notifications/ServiceStatusProvider/ledger-components.d.ts.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/ledger-components.js +14 -0
- package/lib-es/notifications/ServiceStatusProvider/ledger-components.js.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/mocks/ledgerStatus.d.ts +154 -0
- package/lib-es/notifications/ServiceStatusProvider/mocks/ledgerStatus.d.ts.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/mocks/ledgerStatus.js +1189 -0
- package/lib-es/notifications/ServiceStatusProvider/mocks/ledgerStatus.js.map +1 -0
- package/lib-es/notifications/ServiceStatusProvider/types.d.ts +3 -1
- package/lib-es/notifications/ServiceStatusProvider/types.d.ts.map +1 -1
- package/lib-es/wallet-api/react.d.ts +1 -1
- package/lib-es/wallet-api/react.d.ts.map +1 -1
- package/lib-es/wallet-api/react.js +1 -1
- package/lib-es/wallet-api/react.js.map +1 -1
- package/package.json +67 -67
- package/src/bridge/react/BridgeSync.tsx +17 -3
- package/src/bridge/syncSessionManager/index.test.ts +151 -0
- package/src/bridge/syncSessionManager/index.ts +93 -0
- package/src/deposit/deposit.integration.test.ts +41 -2
- package/src/e2e/data/deviceLabelsData.ts +2 -2
- package/src/e2e/enum/Account.ts +7 -0
- package/src/e2e/enum/DeviceLabels.ts +2 -8
- package/src/e2e/families/bitcoin.ts +33 -1
- package/src/e2e/families/tezos.ts +13 -4
- package/src/e2e/models/Swap.ts +8 -0
- package/src/e2e/speculos.ts +26 -35
- package/src/exchange/providers/swap.ts +2 -2
- package/src/families/celo/bridge.integration.test.ts +4 -1
- package/src/families/cosmos/datasets/__snapshots__/babylon.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/cosmos.integration.test.ts.snap +299 -4
- package/src/families/cosmos/datasets/__snapshots__/cryptoOrg.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/injective.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/mantra.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/osmosis.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/persistence.integration.test.ts.snap +4 -4
- package/src/families/cosmos/datasets/__snapshots__/stargaze.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/__snapshots__/xion.integration.test.ts.snap +2 -2
- package/src/families/cosmos/datasets/axelar.integration.test.ts +4 -1
- package/src/families/cosmos/datasets/desmos.integration.test.ts +4 -1
- package/src/families/cosmos/datasets/onomy.integration.test.ts +4 -1
- package/src/families/filecoin/bridge.integration.test.ts +4 -1
- package/src/families/internet_computer/__snapshots__/bridge.integration.test.ts.snap +60 -3
- package/src/families/kaspa/bridge.integration.test.ts +4 -1
- package/src/families/mina/bridge.integration.test.ts +4 -1
- package/src/families/multiversx/synchronisation.integration.test.ts +5 -1
- package/src/families/polkadot/__snapshots__/bridge.integration.test.ts.snap +50 -4
- package/src/families/stacks/__snapshots__/bridge.integration.test.ts.snap +23 -3
- package/src/families/stellar/__snapshots__/bridge.integration.test.ts.snap +1490 -60
- package/src/families/ton/bridge.integration.test.ts +4 -1
- package/src/featureFlags/defaultFeatures.ts +1 -0
- package/src/notifications/ServiceStatusProvider/entry-points.ts +3 -0
- package/src/notifications/ServiceStatusProvider/index.test.ts +102 -0
- package/src/notifications/ServiceStatusProvider/index.tsx +61 -13
- package/src/notifications/ServiceStatusProvider/ledger-components.ts +13 -0
- package/src/notifications/ServiceStatusProvider/mocks/ledgerStatus.ts +1188 -0
- package/src/notifications/ServiceStatusProvider/types.ts +4 -1
- package/src/wallet-api/react.ts +3 -3
- package/src/families/celo/__snapshots__/bridge.integration.test.ts.snap +0 -285
- package/src/families/cosmos/datasets/__snapshots__/axelar.integration.test.ts.snap +0 -45
- package/src/families/cosmos/datasets/__snapshots__/desmos.integration.test.ts.snap +0 -45
- package/src/families/cosmos/datasets/__snapshots__/onomy.integration.test.ts.snap +0 -45
- package/src/families/filecoin/__snapshots__/bridge.integration.test.ts.snap +0 -242
- package/src/families/kaspa/__snapshots__/bridge.integration.test.ts.snap +0 -66
- package/src/families/mina/__snapshots__/bridge.integration.test.ts.snap +0 -169
- package/src/families/ton/__snapshots__/bridge.integration.test.ts.snap +0 -338
@@ -0,0 +1,151 @@
|
|
1
|
+
import { createSyncSessionManager } from ".";
|
2
|
+
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
3
|
+
import { setSupportedCurrencies } from "../../currencies";
|
4
|
+
import { genAccount } from "../../mock/account";
|
5
|
+
|
6
|
+
jest.mock("@ledgerhq/logs", () => ({
|
7
|
+
log: jest.fn(),
|
8
|
+
}));
|
9
|
+
|
10
|
+
setSupportedCurrencies(["bitcoin", "ethereum"]);
|
11
|
+
|
12
|
+
describe("syncSessionManager", () => {
|
13
|
+
afterEach(() => {
|
14
|
+
jest.clearAllMocks();
|
15
|
+
jest.useRealTimers();
|
16
|
+
});
|
17
|
+
|
18
|
+
test("tracks SyncSuccessAllAccounts with correct aggregates when all accounts complete", () => {
|
19
|
+
const trackAnalytics = jest.fn();
|
20
|
+
const session = createSyncSessionManager(trackAnalytics);
|
21
|
+
|
22
|
+
const BTC = getCryptoCurrencyById("bitcoin");
|
23
|
+
const ETH = getCryptoCurrencyById("ethereum");
|
24
|
+
const a1 = genAccount("a1", { currency: BTC, operationsSize: 3 });
|
25
|
+
const a2 = genAccount("a2", { currency: BTC, operationsSize: 5 });
|
26
|
+
const a3 = genAccount("a3", { currency: ETH, operationsSize: 7 });
|
27
|
+
const accounts = [a1, a2, a3];
|
28
|
+
|
29
|
+
const nowSpy = jest
|
30
|
+
.spyOn(Date, "now")
|
31
|
+
// start time
|
32
|
+
.mockReturnValueOnce(1_000)
|
33
|
+
// end time (when last account completes)
|
34
|
+
.mockReturnValueOnce(5_000);
|
35
|
+
|
36
|
+
session.start(["a1", "a2", "a3"], "initial");
|
37
|
+
|
38
|
+
// Completing accounts one by one should only trigger analytics on last one
|
39
|
+
session.onAccountSyncDone("a1", accounts);
|
40
|
+
expect(trackAnalytics).not.toHaveBeenCalled();
|
41
|
+
|
42
|
+
session.onAccountSyncDone("a2", accounts);
|
43
|
+
expect(trackAnalytics).not.toHaveBeenCalled();
|
44
|
+
|
45
|
+
session.onAccountSyncDone("a3", accounts);
|
46
|
+
|
47
|
+
expect(trackAnalytics).toHaveBeenCalledTimes(1);
|
48
|
+
expect(trackAnalytics).toHaveBeenCalledWith(
|
49
|
+
"SyncSuccessAllAccounts",
|
50
|
+
expect.objectContaining({
|
51
|
+
duration: 4, // (5000 - 1000) / 1000
|
52
|
+
accountsCount: accounts.length,
|
53
|
+
operationsCount: a1.operationsCount + a2.operationsCount + a3.operationsCount,
|
54
|
+
chains: ["Bitcoin", "Ethereum"],
|
55
|
+
reason: "initial",
|
56
|
+
}),
|
57
|
+
);
|
58
|
+
|
59
|
+
nowSpy.mockRestore();
|
60
|
+
});
|
61
|
+
|
62
|
+
test("ignores subsequent 'initial' sessions after the first completion", () => {
|
63
|
+
const trackAnalytics = jest.fn();
|
64
|
+
const session = createSyncSessionManager(trackAnalytics);
|
65
|
+
|
66
|
+
const BTC = getCryptoCurrencyById("bitcoin");
|
67
|
+
const ETH = getCryptoCurrencyById("ethereum");
|
68
|
+
const a1 = genAccount("a1", { currency: BTC });
|
69
|
+
const a2 = genAccount("a2", { currency: ETH });
|
70
|
+
a1.operationsCount = 2;
|
71
|
+
a2.operationsCount = 1;
|
72
|
+
const accounts = [a1, a2];
|
73
|
+
|
74
|
+
const nowSpy = jest
|
75
|
+
.spyOn(Date, "now")
|
76
|
+
.mockReturnValueOnce(10_000) // first start
|
77
|
+
.mockReturnValueOnce(14_000); // first completion
|
78
|
+
|
79
|
+
// First initial session completes => tracked once
|
80
|
+
session.start(["a1", "a2"], "initial");
|
81
|
+
session.onAccountSyncDone("a1", accounts);
|
82
|
+
session.onAccountSyncDone("a2", accounts);
|
83
|
+
|
84
|
+
expect(trackAnalytics).toHaveBeenCalledTimes(1);
|
85
|
+
expect(trackAnalytics.mock.calls[0][0]).toBe("SyncSuccessAllAccounts");
|
86
|
+
|
87
|
+
// Next initial session should be ignored entirely
|
88
|
+
session.start(["a1"], "initial");
|
89
|
+
session.onAccountSyncDone("a1", accounts);
|
90
|
+
|
91
|
+
expect(trackAnalytics).toHaveBeenCalledTimes(1);
|
92
|
+
|
93
|
+
nowSpy.mockRestore();
|
94
|
+
});
|
95
|
+
|
96
|
+
test("does nothing if onAccountSyncDone is called without a started session", () => {
|
97
|
+
const trackAnalytics = jest.fn();
|
98
|
+
const session = createSyncSessionManager(trackAnalytics);
|
99
|
+
const BTC = getCryptoCurrencyById("bitcoin");
|
100
|
+
const acc = genAccount("x1", { currency: BTC });
|
101
|
+
acc.operationsCount = 1;
|
102
|
+
const accounts = [acc];
|
103
|
+
|
104
|
+
session.onAccountSyncDone("x1", accounts);
|
105
|
+
expect(trackAnalytics).not.toHaveBeenCalled();
|
106
|
+
});
|
107
|
+
test("tracks SyncSuccessAllAccounts with correct aggregates when all accounts complete and errors", () => {
|
108
|
+
const trackAnalytics = jest.fn();
|
109
|
+
const session = createSyncSessionManager(trackAnalytics);
|
110
|
+
|
111
|
+
const BTC = getCryptoCurrencyById("bitcoin");
|
112
|
+
const ETH = getCryptoCurrencyById("ethereum");
|
113
|
+
const a1 = genAccount("a1", { currency: BTC, operationsSize: 3 });
|
114
|
+
const a2 = genAccount("a2", { currency: BTC, operationsSize: 5 });
|
115
|
+
const a3 = genAccount("a3", { currency: ETH, operationsSize: 7 });
|
116
|
+
const accounts = [a1, a2, a3];
|
117
|
+
|
118
|
+
const nowSpy = jest
|
119
|
+
.spyOn(Date, "now")
|
120
|
+
// start time
|
121
|
+
.mockReturnValueOnce(1_000)
|
122
|
+
// end time (when last account completes)
|
123
|
+
.mockReturnValueOnce(5_000);
|
124
|
+
|
125
|
+
session.start(["a1", "a2", "a3"], "initial");
|
126
|
+
|
127
|
+
// Completing accounts one by one should only trigger analytics on last one
|
128
|
+
session.onAccountSyncDone("a1", accounts);
|
129
|
+
expect(trackAnalytics).not.toHaveBeenCalled();
|
130
|
+
|
131
|
+
session.onAccountSyncDone("a2", accounts, true);
|
132
|
+
expect(trackAnalytics).not.toHaveBeenCalled();
|
133
|
+
|
134
|
+
session.onAccountSyncDone("a3", accounts, true);
|
135
|
+
|
136
|
+
expect(trackAnalytics).toHaveBeenCalledTimes(1);
|
137
|
+
expect(trackAnalytics).toHaveBeenCalledWith(
|
138
|
+
"SyncSuccessAllAccounts",
|
139
|
+
expect.objectContaining({
|
140
|
+
duration: 4, // (5000 - 1000) / 1000
|
141
|
+
accountsCount: accounts.length,
|
142
|
+
operationsCount: a1.operationsCount + a2.operationsCount + a3.operationsCount,
|
143
|
+
chains: ["Bitcoin", "Ethereum"],
|
144
|
+
reason: "initial",
|
145
|
+
syncWithErrors: 2,
|
146
|
+
}),
|
147
|
+
);
|
148
|
+
|
149
|
+
nowSpy.mockRestore();
|
150
|
+
});
|
151
|
+
});
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import { log } from "@ledgerhq/logs";
|
2
|
+
import { Account } from "@ledgerhq/types-live";
|
3
|
+
import { Props } from "../react/BridgeSync";
|
4
|
+
|
5
|
+
type Session = {
|
6
|
+
reason: string;
|
7
|
+
startTime: number;
|
8
|
+
accountIds: string[];
|
9
|
+
remaining: Set<string>;
|
10
|
+
errorsCount: number;
|
11
|
+
};
|
12
|
+
|
13
|
+
// Session manager factory to track global sync sessions (Accounts)
|
14
|
+
export function createSyncSessionManager(trackAnalytics: Props["trackAnalytics"]) {
|
15
|
+
let current: Session | null = null;
|
16
|
+
|
17
|
+
let hasTrackedInitial = false;
|
18
|
+
|
19
|
+
const start = (ids: string[], reason: string) => {
|
20
|
+
if (reason === "initial" && hasTrackedInitial) return;
|
21
|
+
current = {
|
22
|
+
reason,
|
23
|
+
startTime: Date.now(),
|
24
|
+
accountIds: ids,
|
25
|
+
remaining: new Set(ids),
|
26
|
+
errorsCount: 0,
|
27
|
+
};
|
28
|
+
logSyncSession("started", { reason, accounts: ids.length });
|
29
|
+
};
|
30
|
+
|
31
|
+
/**
|
32
|
+
*
|
33
|
+
* @param accountId - the account id that has completed sync
|
34
|
+
* @param accounts - the accounts that will be synced
|
35
|
+
* @param hadError - whether the account sync had an error
|
36
|
+
*
|
37
|
+
*/
|
38
|
+
const onAccountSyncDone = (accountId: string, accounts: Account[], hadError = false) => {
|
39
|
+
if (!current) return;
|
40
|
+
|
41
|
+
current.remaining.delete(accountId);
|
42
|
+
if (hadError) {
|
43
|
+
current.errorsCount += 1;
|
44
|
+
}
|
45
|
+
|
46
|
+
if (current.remaining.size === 0) {
|
47
|
+
trackSessionAnalytics(trackAnalytics, current, accounts);
|
48
|
+
|
49
|
+
if (current.reason === "initial") {
|
50
|
+
hasTrackedInitial = true;
|
51
|
+
}
|
52
|
+
current = null;
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
return { start, onAccountSyncDone } as const;
|
57
|
+
}
|
58
|
+
|
59
|
+
export function getTotalOperations(accounts: Account[]): number {
|
60
|
+
return accounts.reduce((sum, acc) => sum + acc.operationsCount, 0);
|
61
|
+
}
|
62
|
+
|
63
|
+
export function getUniqueChains(accounts: Account[]): string[] {
|
64
|
+
return [...new Set(accounts.map(acc => acc.currency.name))];
|
65
|
+
}
|
66
|
+
|
67
|
+
export function trackSessionAnalytics(
|
68
|
+
trackAnalytics: Props["trackAnalytics"],
|
69
|
+
session: Session,
|
70
|
+
accounts: Account[],
|
71
|
+
) {
|
72
|
+
const duration = (Date.now() - session.startTime) / 1000;
|
73
|
+
const totalOps = getTotalOperations(accounts);
|
74
|
+
const chains = getUniqueChains(accounts);
|
75
|
+
|
76
|
+
trackAnalytics("SyncSuccessAllAccounts", {
|
77
|
+
duration,
|
78
|
+
accountsCount: accounts.length,
|
79
|
+
operationsCount: totalOps,
|
80
|
+
chains,
|
81
|
+
reason: session.reason,
|
82
|
+
syncWithErrors: session.errorsCount,
|
83
|
+
});
|
84
|
+
|
85
|
+
logSyncSession("finished", { reason: session.reason, duration: `${duration}s` });
|
86
|
+
}
|
87
|
+
|
88
|
+
function logSyncSession(event: "started" | "finished", data: Record<string, string | number>) {
|
89
|
+
const serialized = Object.entries(data)
|
90
|
+
.map(([key, value]) => `${key}=${value}`)
|
91
|
+
.join(", ");
|
92
|
+
log("bridge", `SyncSession ${event} ${serialized}`);
|
93
|
+
}
|
@@ -4,10 +4,49 @@
|
|
4
4
|
import "../__tests__/test-helpers/setup";
|
5
5
|
import { renderHook, waitFor } from "@testing-library/react";
|
6
6
|
import { useGroupedCurrenciesByProvider } from ".";
|
7
|
-
import { GroupedCurrencies, LoadingBasedGroupedCurrencies } from "./type";
|
8
|
-
|
7
|
+
import { GroupedCurrencies, LoadingBasedGroupedCurrencies, MappedAsset } from "./type";
|
8
|
+
import * as api from "./api";
|
9
|
+
|
10
|
+
// Mock the API module
|
11
|
+
jest.mock("./api");
|
12
|
+
const mockGetMappedAssets = api.getMappedAssets as jest.MockedFunction<typeof api.getMappedAssets>;
|
13
|
+
|
14
|
+
// Create mock data for testing
|
15
|
+
const mockMappedAssets: MappedAsset[] = [
|
16
|
+
{
|
17
|
+
$type: "Coin",
|
18
|
+
ledgerId: "bitcoin",
|
19
|
+
providerId: "coingecko",
|
20
|
+
name: "Bitcoin",
|
21
|
+
ticker: "BTC",
|
22
|
+
status: "active",
|
23
|
+
reason: null,
|
24
|
+
data: {
|
25
|
+
img: "https://crypto-icons.example.com/bitcoin.png",
|
26
|
+
marketCapRank: 1,
|
27
|
+
},
|
28
|
+
},
|
29
|
+
{
|
30
|
+
$type: "Coin",
|
31
|
+
ledgerId: "ethereum",
|
32
|
+
providerId: "coingecko",
|
33
|
+
name: "Ethereum",
|
34
|
+
ticker: "ETH",
|
35
|
+
status: "active",
|
36
|
+
reason: null,
|
37
|
+
data: {
|
38
|
+
img: "https://crypto-icons.example.com/ethereum.png",
|
39
|
+
marketCapRank: 2,
|
40
|
+
},
|
41
|
+
},
|
42
|
+
];
|
9
43
|
|
10
44
|
describe("useGroupedCurrenciesByProvider", () => {
|
45
|
+
beforeEach(() => {
|
46
|
+
// Mock the API call to return our test data
|
47
|
+
mockGetMappedAssets.mockResolvedValue(mockMappedAssets);
|
48
|
+
});
|
49
|
+
|
11
50
|
afterEach(() => {
|
12
51
|
jest.clearAllMocks();
|
13
52
|
});
|
@@ -54,7 +54,7 @@ export const DEVICE_LABELS_CONFIG: DeviceLabelsConfig = {
|
|
54
54
|
[AppInfos.MULTIVERS_X.name]: DeviceLabels.SIGN,
|
55
55
|
[AppInfos.NEAR.name]: DeviceLabels.CONTINUE_TO_ACTION,
|
56
56
|
[AppInfos.SOLANA.name]: DeviceLabels.APPROVE,
|
57
|
-
[AppInfos.TEZOS.name]: DeviceLabels.
|
57
|
+
[AppInfos.TEZOS.name]: DeviceLabels.ACCEPT_RISK,
|
58
58
|
default: DeviceLabels.CAPS_APPROVE,
|
59
59
|
},
|
60
60
|
},
|
@@ -87,12 +87,12 @@ export const DEVICE_LABELS_CONFIG: DeviceLabelsConfig = {
|
|
87
87
|
},
|
88
88
|
delegateConfirm: {
|
89
89
|
[AppInfos.CELO.name]: DeviceLabels.ACCEPT,
|
90
|
+
[AppInfos.TEZOS.name]: DeviceLabels.ACCEPT_AND_SEND,
|
90
91
|
[AppInfos.COSMOS.name]: DeviceLabels.CAPS_APPROVE,
|
91
92
|
[AppInfos.INJECTIVE.name]: DeviceLabels.CAPS_APPROVE,
|
92
93
|
[AppInfos.MULTIVERS_X.name]: DeviceLabels.SIGN,
|
93
94
|
[AppInfos.NEAR.name]: DeviceLabels.CONTINUE_TO_ACTION,
|
94
95
|
[AppInfos.SOLANA.name]: DeviceLabels.SIGN_TRANSACTION,
|
95
|
-
[AppInfos.TEZOS.name]: DeviceLabels.ACCEPT_RISK,
|
96
96
|
[AppInfos.OSMOSIS.name]: DeviceLabels.CAPS_APPROVE,
|
97
97
|
default: DeviceLabels.APPROVE,
|
98
98
|
},
|
package/src/e2e/enum/Account.ts
CHANGED
@@ -248,6 +248,13 @@ export class Account {
|
|
248
248
|
"0xa1baa625c5E6A9304cB7AcD86d2fee6B710eC3eB",
|
249
249
|
1,
|
250
250
|
undefined,
|
251
|
+
);
|
252
|
+
static readonly ETH_2_WITH_ENS = new Account(
|
253
|
+
Currency.ETH,
|
254
|
+
"Ethereum 2",
|
255
|
+
"0xa1baa625c5E6A9304cB7AcD86d2fee6B710eC3eB",
|
256
|
+
1,
|
257
|
+
undefined,
|
251
258
|
"speculos.eth",
|
252
259
|
);
|
253
260
|
static readonly ETH_2_LOWER_CASE = new Account(
|
@@ -6,9 +6,8 @@ export enum DeviceLabels {
|
|
6
6
|
ADDRESS = "Address",
|
7
7
|
AMOUNT = "Amount",
|
8
8
|
APPROVE = "Approve",
|
9
|
-
|
9
|
+
BITCOIN_IS_READY = "Bitcoin is ready",
|
10
10
|
CAPS_APPROVE = "APPROVE",
|
11
|
-
CAPS_REJECT = "REJECT",
|
12
11
|
CHAIN_ID = "Chain ID",
|
13
12
|
CONFIRM = "Confirm",
|
14
13
|
CONNECT = "Connect",
|
@@ -19,19 +18,14 @@ export enum DeviceLabels {
|
|
19
18
|
DELEGATE_FROM = "Delegate from",
|
20
19
|
DELEGATE_STAKE = "Delegate stake",
|
21
20
|
DEPOSIT = "Deposit",
|
22
|
-
DEST = "Dest",
|
23
|
-
DESTINATION = "Destination",
|
24
21
|
EXPERT_MODE = "Expert mode",
|
25
22
|
FEES = "Fees",
|
26
|
-
FINALIZE = "Finalize",
|
27
23
|
GET = "Get",
|
28
24
|
I_UNDERSTAND = "I understand",
|
29
25
|
LEDGER_LIVE_WILL_BE = "Ledger Live will be",
|
30
|
-
METHOD_NAME = "Method name",
|
31
26
|
NEW_ORDINARY = "New ordinary",
|
32
27
|
PLEASE_REVIEW = "Please",
|
33
28
|
PUBKEY = "Pubkey",
|
34
|
-
PUBLICKEY = "Public Key Hash",
|
35
29
|
READY = "Ready",
|
36
30
|
RECEIVE_ADDRESS_DOES_NOT_BELONG = "Receive address does",
|
37
31
|
RECEIVER = "Receiver",
|
@@ -51,6 +45,7 @@ export enum DeviceLabels {
|
|
51
45
|
STAKE_KEY = "Stake key",
|
52
46
|
TO = "To",
|
53
47
|
TRANSACTION_FEE = "Transaction fee",
|
48
|
+
TRANSACTION_SIGNED = "Transaction Signed",
|
54
49
|
TRANSFER = "Transfer",
|
55
50
|
TURN_ON_SYNC = "Turn on sync",
|
56
51
|
TURN_ON_SYNC2 = "Turn On sync",
|
@@ -63,5 +58,4 @@ export enum DeviceLabels {
|
|
63
58
|
VERIFY_SOLANA_ADDRESS = "Verify Solana address",
|
64
59
|
VIEW_ACTION = "View action",
|
65
60
|
VIEW_HEADER = "View Header",
|
66
|
-
WALLET_ID = "Wallet ID",
|
67
61
|
}
|
@@ -1,7 +1,15 @@
|
|
1
1
|
import expect from "expect";
|
2
2
|
import { Transaction } from "../models/Transaction";
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
pressBoth,
|
5
|
+
pressUntilTextFound,
|
6
|
+
waitFor,
|
7
|
+
containsSubstringInEvent,
|
8
|
+
getSpeculosModel,
|
9
|
+
} from "../speculos";
|
4
10
|
import { DeviceLabels } from "../enum/DeviceLabels";
|
11
|
+
import { Device } from "../enum/Device";
|
12
|
+
import invariant from "invariant";
|
5
13
|
|
6
14
|
export async function sendBTCBasedCoin(tx: Transaction) {
|
7
15
|
const events = await pressUntilTextFound(DeviceLabels.ACCEPT);
|
@@ -14,3 +22,27 @@ export async function sendBTCBasedCoin(tx: Transaction) {
|
|
14
22
|
await pressUntilTextFound(DeviceLabels.ACCEPT);
|
15
23
|
await pressBoth();
|
16
24
|
}
|
25
|
+
|
26
|
+
export async function sendBTC(tx: Transaction) {
|
27
|
+
const speculosDevice = getSpeculosModel();
|
28
|
+
try {
|
29
|
+
const events =
|
30
|
+
speculosDevice === Device.LNS
|
31
|
+
? await pressUntilTextFound(DeviceLabels.CONTINUE)
|
32
|
+
: await pressUntilTextFound(DeviceLabels.SIGN_TRANSACTION);
|
33
|
+
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
|
34
|
+
expect(isAmountCorrect).toBeTruthy();
|
35
|
+
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
|
36
|
+
expect(isAddressCorrect).toBeTruthy();
|
37
|
+
await pressBoth();
|
38
|
+
if (speculosDevice === Device.LNS) {
|
39
|
+
await pressUntilTextFound(DeviceLabels.SIGN);
|
40
|
+
await pressBoth();
|
41
|
+
await waitFor(DeviceLabels.BITCOIN_IS_READY);
|
42
|
+
} else {
|
43
|
+
await waitFor(DeviceLabels.TRANSACTION_SIGNED);
|
44
|
+
}
|
45
|
+
} catch (e) {
|
46
|
+
invariant(false, `Error while sending BTC transaction: ${e}`);
|
47
|
+
}
|
48
|
+
}
|
@@ -1,14 +1,23 @@
|
|
1
|
-
import {
|
2
|
-
|
1
|
+
import {
|
2
|
+
getDelegateEvents,
|
3
|
+
getDeviceLabels,
|
4
|
+
getSpeculosModel,
|
5
|
+
pressBoth,
|
6
|
+
pressUntilTextFound,
|
7
|
+
} from "../speculos";
|
3
8
|
import { Delegate } from "../models/Delegate";
|
4
9
|
import { DeviceModelId } from "@ledgerhq/types-devices";
|
10
|
+
import { DeviceLabels } from "../enum/DeviceLabels";
|
5
11
|
|
6
12
|
export async function delegateTezos(delegatingAccount: Delegate) {
|
13
|
+
const { delegateConfirmLabel } = getDeviceLabels(delegatingAccount.account.currency.speculosApp);
|
14
|
+
|
7
15
|
await getDelegateEvents(delegatingAccount);
|
16
|
+
await pressUntilTextFound(delegateConfirmLabel);
|
8
17
|
await pressBoth();
|
9
18
|
|
10
|
-
if (getSpeculosModel()
|
11
|
-
await pressUntilTextFound(DeviceLabels.
|
19
|
+
if (getSpeculosModel() == DeviceModelId.nanoS) {
|
20
|
+
await pressUntilTextFound(DeviceLabels.ACCEPT_AND_SEND);
|
12
21
|
await pressBoth();
|
13
22
|
}
|
14
23
|
}
|
package/src/e2e/models/Swap.ts
CHANGED
@@ -27,4 +27,12 @@ export class Swap extends Transaction {
|
|
27
27
|
public get getAmount(): string {
|
28
28
|
return this.amount;
|
29
29
|
}
|
30
|
+
|
31
|
+
public get getAccountToDebit(): Account {
|
32
|
+
return this.accountToDebit;
|
33
|
+
}
|
34
|
+
|
35
|
+
public get getAccountToCredit(): Account {
|
36
|
+
return this.accountToCredit;
|
37
|
+
}
|
30
38
|
}
|
package/src/e2e/speculos.ts
CHANGED
@@ -19,7 +19,7 @@ import { Account } from "./enum/Account";
|
|
19
19
|
import { Device as CryptoWallet } from "./enum/Device";
|
20
20
|
import { Currency } from "./enum/Currency";
|
21
21
|
import expect from "expect";
|
22
|
-
import { sendBTCBasedCoin } from "./families/bitcoin";
|
22
|
+
import { sendBTC, sendBTCBasedCoin } from "./families/bitcoin";
|
23
23
|
import { sendEVM, sendEvmNFT } from "./families/evm";
|
24
24
|
import { sendPolkadot } from "./families/polkadot";
|
25
25
|
import { sendAlgorand } from "./families/algorand";
|
@@ -630,7 +630,7 @@ type DeviceLabelsReturn = {
|
|
630
630
|
receiveVerifyLabel: string;
|
631
631
|
};
|
632
632
|
|
633
|
-
function getDeviceLabels(appInfo: AppInfos): DeviceLabelsReturn {
|
633
|
+
export function getDeviceLabels(appInfo: AppInfos): DeviceLabelsReturn {
|
634
634
|
const deviceModel = getSpeculosModel();
|
635
635
|
const deviceConfig = DEVICE_LABELS_CONFIG[deviceModel] ?? DEVICE_LABELS_CONFIG.default;
|
636
636
|
|
@@ -668,6 +668,12 @@ export async function signSendTransaction(tx: Transaction) {
|
|
668
668
|
case Currency.ETH:
|
669
669
|
await sendEVM(tx);
|
670
670
|
break;
|
671
|
+
case Currency.BTC:
|
672
|
+
await sendBTC(tx);
|
673
|
+
break;
|
674
|
+
case Currency.ETH_USDT:
|
675
|
+
await sendEVM(tx);
|
676
|
+
break;
|
671
677
|
case Currency.DOGE:
|
672
678
|
case Currency.BCH:
|
673
679
|
await sendBTCBasedCoin(tx);
|
@@ -759,6 +765,7 @@ export async function getDelegateEvents(delegatingAccount: Delegate): Promise<st
|
|
759
765
|
);
|
760
766
|
|
761
767
|
await waitFor(delegateVerifyLabel);
|
768
|
+
|
762
769
|
return await pressUntilTextFound(delegateConfirmLabel);
|
763
770
|
}
|
764
771
|
|
@@ -768,54 +775,38 @@ export async function verifyAmountsAndAcceptSwap(swap: Swap, amount: string) {
|
|
768
775
|
getSpeculosModel() === DeviceModelId.nanoS
|
769
776
|
? await pressUntilTextFound(DeviceLabels.ACCEPT_AND_SEND)
|
770
777
|
: await pressUntilTextFound(DeviceLabels.SIGN_TRANSACTION);
|
771
|
-
|
778
|
+
verifySwapData(swap, events, amount);
|
772
779
|
await pressBoth();
|
773
780
|
}
|
774
781
|
|
775
782
|
export async function verifyAmountsAndAcceptSwapForDifferentSeed(swap: Swap, amount: string) {
|
776
|
-
await waitFor(DeviceLabels.
|
777
|
-
await pressUntilTextFound(DeviceLabels.I_UNDERSTAND);
|
778
|
-
await pressBoth();
|
783
|
+
await waitFor(DeviceLabels.REVIEW_TRANSACTION);
|
779
784
|
const events = await pressUntilTextFound(DeviceLabels.SIGN_TRANSACTION);
|
780
|
-
|
785
|
+
verifySwapData(swap, events, amount);
|
781
786
|
await pressBoth();
|
782
787
|
}
|
783
788
|
|
784
789
|
export async function verifyAmountsAndRejectSwap(swap: Swap, amount: string) {
|
785
790
|
await waitFor(DeviceLabels.REVIEW_TRANSACTION);
|
786
791
|
const events = await pressUntilTextFound(DeviceLabels.REJECT);
|
787
|
-
|
792
|
+
verifySwapData(swap, events, amount);
|
788
793
|
await pressBoth();
|
789
794
|
}
|
790
795
|
|
791
|
-
|
792
|
-
const
|
793
|
-
expect(sendAmountScreen).toBeTruthy();
|
794
|
-
verifySwapGetAmountScreen(swap, events);
|
795
|
-
verifySwapFeesAmountScreen(swap, events);
|
796
|
-
}
|
797
|
-
|
798
|
-
function verifySwapGetAmountScreen(swap: Swap, events: string[]) {
|
799
|
-
const parsedAmountToReceive = extractNumberFromString(swap.amountToReceive);
|
800
|
-
swap.amountToReceive =
|
801
|
-
parsedAmountToReceive.length < 19
|
802
|
-
? parsedAmountToReceive
|
803
|
-
: parsedAmountToReceive.substring(0, 18);
|
796
|
+
function verifySwapData(swap: Swap, events: string[], amount: string) {
|
797
|
+
const swapPair = `swap ${swap.getAccountToDebit.currency.ticker} to ${swap.getAccountToCredit.currency.ticker}`;
|
804
798
|
|
805
|
-
|
806
|
-
|
799
|
+
if (getSpeculosModel() !== DeviceModelId.nanoS) {
|
800
|
+
expectDeviceScreenContains(swapPair, events, "Swap pair not found on the device screen");
|
801
|
+
}
|
802
|
+
expectDeviceScreenContains(amount, events, `Amount ${amount} not found on the device screen`);
|
807
803
|
}
|
808
804
|
|
809
|
-
function
|
810
|
-
const
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
805
|
+
function expectDeviceScreenContains(substring: string, events: string[], message: string) {
|
806
|
+
const found = containsSubstringInEvent(substring, events);
|
807
|
+
if (!found) {
|
808
|
+
throw new Error(
|
809
|
+
`${message}. Expected events to contain "${substring}". Got: ${JSON.stringify(events)}`,
|
810
|
+
);
|
811
|
+
}
|
816
812
|
}
|
817
|
-
|
818
|
-
const extractNumberFromString = (input: string | undefined): string => {
|
819
|
-
const match = input?.match(/[\d.]+/);
|
820
|
-
return match ? match[0] : "";
|
821
|
-
};
|
@@ -177,9 +177,9 @@ const DEFAULT_SWAP_PROVIDERS: Record<string, ProviderConfig & Partial<Additional
|
|
177
177
|
type: "CEX",
|
178
178
|
name: "NEAR Intents",
|
179
179
|
needsBearerToken: false,
|
180
|
-
termsOfUseUrl: "https://
|
180
|
+
termsOfUseUrl: "https://swapkit.dev/terms-of-service/",
|
181
181
|
supportUrl: "https://ledgerhelp.swapkit.dev/",
|
182
|
-
mainUrl: "https://www.
|
182
|
+
mainUrl: "https://www.near.org/intents",
|
183
183
|
needsKYC: false,
|
184
184
|
version: 2,
|
185
185
|
publicKey: {
|
@@ -2,4 +2,7 @@ import "../../__tests__/test-helpers/setup";
|
|
2
2
|
import { testBridge } from "../../__tests__/test-helpers/bridge";
|
3
3
|
import { dataset } from "@ledgerhq/coin-celo/test/bridgeDatasetTest";
|
4
4
|
|
5
|
-
|
5
|
+
// FIXME: Disabled due to obsolete APDU data and gas estimation issues
|
6
|
+
describe.skip("celo integration", () => {
|
7
|
+
testBridge(dataset);
|
8
|
+
});
|
@@ -3,7 +3,7 @@
|
|
3
3
|
exports[`babylon currency bridge scanAccounts babylon seed 1 1`] = `
|
4
4
|
[
|
5
5
|
{
|
6
|
-
"balance": "
|
6
|
+
"balance": "1000003",
|
7
7
|
"currencyId": "babylon",
|
8
8
|
"derivationMode": "",
|
9
9
|
"freshAddress": "bbn1uwpws077a0a9pclapv3f2fyj5u0mlh6ewmds8n",
|
@@ -12,7 +12,7 @@ exports[`babylon currency bridge scanAccounts babylon seed 1 1`] = `
|
|
12
12
|
"index": 0,
|
13
13
|
"pendingOperations": [],
|
14
14
|
"seedIdentifier": "03cd9e27aa78eddce3fda5f8050db35196b188d80d10bd04aab15e5669defee8b0",
|
15
|
-
"spendableBalance": "
|
15
|
+
"spendableBalance": "1000003",
|
16
16
|
"swapHistory": [],
|
17
17
|
"syncHash": undefined,
|
18
18
|
"used": true,
|