@ledgerhq/live-common 34.47.0-nightly.6 → 34.47.0-nightly.7
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/generic-alpaca/utils.d.ts.map +1 -1
- package/lib/bridge/generic-alpaca/utils.js +1 -1
- package/lib/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib/bridge/generic-alpaca/utils.test.js +37 -0
- package/lib/bridge/generic-alpaca/utils.test.js.map +1 -1
- package/lib/e2e/enum/DeviceLabels.d.ts +2 -1
- package/lib/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib/e2e/enum/DeviceLabels.js +1 -0
- package/lib/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib/e2e/speculos.d.ts +1 -0
- package/lib/e2e/speculos.d.ts.map +1 -1
- package/lib/e2e/speculos.js +10 -2
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts +1 -1
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -1
- package/lib/modularDrawer/hooks/{modules/useAssetAccountCounts.d.ts → useAssetAccountCounts.d.ts} +1 -1
- package/lib/modularDrawer/hooks/useAssetAccountCounts.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/{modules/useAssetAccountCounts.js → useAssetAccountCounts.js} +1 -1
- package/lib/modularDrawer/hooks/useAssetAccountCounts.js.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.d.ts +13 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.js +15 -0
- package/lib/modularDrawer/hooks/useLeftAccounts.js.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.d.ts +6 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.js +19 -0
- package/lib/modularDrawer/hooks/useLeftAccountsApy.js.map +1 -0
- package/lib/modularDrawer/hooks/useLeftApy.d.ts +54 -0
- package/lib/modularDrawer/hooks/useLeftApy.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useLeftApy.js +15 -0
- package/lib/modularDrawer/hooks/useLeftApy.js.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts +57 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js +87 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +63 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js +66 -0
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.d.ts +4 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.js +41 -0
- package/lib/modularDrawer/modules/createAssetConfiguration.js.map +1 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts +6 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.js +56 -0
- package/lib/modularDrawer/modules/createNetworkConfiguration.js.map +1 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +9 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +1 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js +17 -0
- package/lib/modularDrawer/utils/buildProviderCurrenciesMap.js.map +1 -0
- package/lib/modularDrawer/utils/sortByBalance.d.ts +6 -0
- package/lib/modularDrawer/utils/sortByBalance.d.ts.map +1 -0
- package/lib/modularDrawer/utils/sortByBalance.js +32 -0
- package/lib/modularDrawer/utils/sortByBalance.js.map +1 -0
- package/lib/modularDrawer/utils/type.d.ts +89 -1
- package/lib/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.d.ts.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js +1 -1
- package/lib-es/bridge/generic-alpaca/utils.js.map +1 -1
- package/lib-es/bridge/generic-alpaca/utils.test.js +37 -0
- package/lib-es/bridge/generic-alpaca/utils.test.js.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.d.ts +2 -1
- package/lib-es/e2e/enum/DeviceLabels.d.ts.map +1 -1
- package/lib-es/e2e/enum/DeviceLabels.js +1 -0
- package/lib-es/e2e/enum/DeviceLabels.js.map +1 -1
- package/lib-es/e2e/speculos.d.ts +1 -0
- package/lib-es/e2e/speculos.d.ts.map +1 -1
- package/lib-es/e2e/speculos.js +8 -1
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts +1 -1
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/modules/useLeftApyModule.js.map +1 -1
- package/lib-es/modularDrawer/hooks/{modules/useAssetAccountCounts.d.ts → useAssetAccountCounts.d.ts} +1 -1
- package/lib-es/modularDrawer/hooks/useAssetAccountCounts.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/{modules/useAssetAccountCounts.js → useAssetAccountCounts.js} +1 -1
- package/lib-es/modularDrawer/hooks/useAssetAccountCounts.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.d.ts +13 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.js +11 -0
- package/lib-es/modularDrawer/hooks/useLeftAccounts.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.d.ts +6 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.js +15 -0
- package/lib-es/modularDrawer/hooks/useLeftAccountsApy.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftApy.d.ts +54 -0
- package/lib-es/modularDrawer/hooks/useLeftApy.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useLeftApy.js +11 -0
- package/lib-es/modularDrawer/hooks/useLeftApy.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts +57 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js +83 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +63 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js +62 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts +4 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.js +39 -0
- package/lib-es/modularDrawer/modules/createAssetConfiguration.js.map +1 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts +6 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.d.ts.map +1 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js +50 -0
- package/lib-es/modularDrawer/modules/createNetworkConfiguration.js.map +1 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts +9 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js +13 -0
- package/lib-es/modularDrawer/utils/buildProviderCurrenciesMap.js.map +1 -0
- package/lib-es/modularDrawer/utils/sortByBalance.d.ts +6 -0
- package/lib-es/modularDrawer/utils/sortByBalance.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/sortByBalance.js +25 -0
- package/lib-es/modularDrawer/utils/sortByBalance.js.map +1 -0
- package/lib-es/modularDrawer/utils/type.d.ts +89 -1
- package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/bridge/generic-alpaca/utils.test.ts +40 -0
- package/src/bridge/generic-alpaca/utils.ts +4 -3
- package/src/e2e/enum/DeviceLabels.ts +1 -0
- package/src/e2e/speculos.ts +9 -1
- package/src/modularDrawer/hooks/modules/useLeftApyModule.tsx +1 -1
- package/src/modularDrawer/hooks/{modules/useAssetAccountCounts.tsx → useAssetAccountCounts.tsx} +2 -2
- package/src/modularDrawer/hooks/useLeftAccounts.tsx +23 -0
- package/src/modularDrawer/hooks/useLeftAccountsApy.tsx +28 -0
- package/src/modularDrawer/hooks/useLeftApy.tsx +19 -0
- package/src/modularDrawer/hooks/useRightBalanceAsset.tsx +140 -0
- package/src/modularDrawer/hooks/useRightBalanceNetwork.tsx +116 -0
- package/src/modularDrawer/modules/createAssetConfiguration.ts +61 -0
- package/src/modularDrawer/modules/createNetworkConfiguration.ts +79 -0
- package/src/modularDrawer/utils/buildProviderCurrenciesMap.tsx +25 -0
- package/src/modularDrawer/utils/sortByBalance.tsx +32 -0
- package/src/modularDrawer/utils/type.ts +97 -0
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +0 -1
- package/lib/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +0 -1
- package/lib/modularDrawer/types.d.ts +0 -2
- package/lib/modularDrawer/types.d.ts.map +0 -1
- package/lib/modularDrawer/types.js +0 -3
- package/lib/modularDrawer/types.js.map +0 -1
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.d.ts.map +0 -1
- package/lib-es/modularDrawer/hooks/modules/useAssetAccountCounts.js.map +0 -1
- package/lib-es/modularDrawer/types.d.ts +0 -2
- package/lib-es/modularDrawer/types.d.ts.map +0 -1
- package/lib-es/modularDrawer/types.js +0 -2
- package/lib-es/modularDrawer/types.js.map +0 -1
- package/src/modularDrawer/types.ts +0 -1
@@ -0,0 +1,63 @@
|
|
1
|
+
import { type ReactNode } from "react";
|
2
|
+
import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
+
import { UseBalanceDeps } from "../utils/type";
|
4
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
5
|
+
export type NetworkDeps = {
|
6
|
+
balanceItem: (asset: {
|
7
|
+
fiatValue?: string;
|
8
|
+
balance?: string;
|
9
|
+
}) => ReactNode;
|
10
|
+
useBalanceDeps: UseBalanceDeps;
|
11
|
+
};
|
12
|
+
type Params = {
|
13
|
+
assets: CryptoOrTokenCurrency[];
|
14
|
+
selectedAssetId: string;
|
15
|
+
currenciesByProvider: CurrenciesByProviderId[];
|
16
|
+
};
|
17
|
+
export declare function createUseRightBalanceNetwork({ useBalanceDeps, balanceItem }: NetworkDeps): ({ assets: networks, selectedAssetId, currenciesByProvider, }: Params) => ({
|
18
|
+
rightElement: ReactNode;
|
19
|
+
name: string;
|
20
|
+
ticker: string;
|
21
|
+
units: import("@ledgerhq/types-cryptoassets").Unit[];
|
22
|
+
symbol?: string | undefined;
|
23
|
+
disableCountervalue?: boolean | undefined;
|
24
|
+
delisted?: boolean | undefined;
|
25
|
+
keywords?: string[] | undefined;
|
26
|
+
type: "CryptoCurrency";
|
27
|
+
id: import("@ledgerhq/types-cryptoassets").CryptoCurrencyId | "LBRY" | "groestcoin" | "osmo";
|
28
|
+
forkedFrom?: string | undefined;
|
29
|
+
managerAppName: string;
|
30
|
+
coinType: import("@ledgerhq/types-cryptoassets").CoinType;
|
31
|
+
scheme: string;
|
32
|
+
color: string;
|
33
|
+
family: string;
|
34
|
+
blockAvgTime?: number | undefined;
|
35
|
+
supportsSegwit?: boolean | undefined;
|
36
|
+
supportsNativeSegwit?: boolean | undefined;
|
37
|
+
isTestnetFor?: string | undefined;
|
38
|
+
bitcoinLikeInfo?: import("@ledgerhq/types-cryptoassets").BitcoinLikeInfo | undefined;
|
39
|
+
ethereumLikeInfo?: import("@ledgerhq/types-cryptoassets").EthereumLikeInfo | undefined;
|
40
|
+
explorerViews: import("@ledgerhq/types-cryptoassets").ExplorerView[];
|
41
|
+
terminated?: {
|
42
|
+
link: string;
|
43
|
+
} | undefined;
|
44
|
+
deviceTicker?: string | undefined;
|
45
|
+
explorerId?: import("@ledgerhq/types-cryptoassets").LedgerExplorerId | undefined;
|
46
|
+
} | {
|
47
|
+
rightElement: ReactNode;
|
48
|
+
name: string;
|
49
|
+
ticker: string;
|
50
|
+
units: import("@ledgerhq/types-cryptoassets").Unit[];
|
51
|
+
symbol?: string | undefined;
|
52
|
+
disableCountervalue?: boolean | undefined;
|
53
|
+
delisted?: boolean | undefined;
|
54
|
+
keywords?: string[] | undefined;
|
55
|
+
type: "TokenCurrency";
|
56
|
+
id: string;
|
57
|
+
ledgerSignature?: string | undefined;
|
58
|
+
contractAddress: string;
|
59
|
+
parentCurrency: import("@ledgerhq/types-cryptoassets").CryptoCurrency;
|
60
|
+
tokenType: string;
|
61
|
+
})[];
|
62
|
+
export {};
|
63
|
+
//# sourceMappingURL=useRightBalanceNetwork.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useRightBalanceNetwork.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/hooks/useRightBalanceNetwork.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAa,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAC;IAC5E,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF,KAAK,MAAM,GAAG;IACZ,MAAM,EAAE,qBAAqB,EAAE,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,sBAAsB,EAAE,CAAC;CAChD,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,EAAE,cAAc,EAAE,WAAW,EAAE,EAAE,WAAW,kEAKpF,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4FV"}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { useMemo } from "react";
|
2
|
+
import { compareByBalanceThenFiat } from "../utils/sortByBalance";
|
3
|
+
import { getBalanceAndFiatValueByAssets } from "../utils/getBalanceAndFiatValueByAssets";
|
4
|
+
export function createUseRightBalanceNetwork({ useBalanceDeps, balanceItem }) {
|
5
|
+
return function useRightBalanceNetwork({ assets: networks, selectedAssetId, currenciesByProvider, }) {
|
6
|
+
const { flattenedAccounts, discreet, state, counterValueCurrency, locale } = useBalanceDeps();
|
7
|
+
return useMemo(() => {
|
8
|
+
if (currenciesByProvider && currenciesByProvider.length > 0) {
|
9
|
+
const providerOfSelectedAsset = currenciesByProvider.find(provider => provider.currenciesByNetwork.some(currency => currency.id === selectedAssetId));
|
10
|
+
if (providerOfSelectedAsset) {
|
11
|
+
const pairs = networks.map(network => ({
|
12
|
+
network,
|
13
|
+
asset: providerOfSelectedAsset.currenciesByNetwork.find(currency => currency.type === "TokenCurrency"
|
14
|
+
? currency.parentCurrency.id === network.id
|
15
|
+
: currency.id === network.id),
|
16
|
+
}));
|
17
|
+
const validAssets = pairs.filter(p => p.asset).map(p => p.asset);
|
18
|
+
const allBalanceData = validAssets.length > 0
|
19
|
+
? getBalanceAndFiatValueByAssets(flattenedAccounts, validAssets, state, counterValueCurrency, discreet, locale)
|
20
|
+
: [];
|
21
|
+
const balanceMap = new Map(allBalanceData.map(b => [b.id, b]));
|
22
|
+
const networkWithBalanceData = pairs.map(({ network, asset }) => {
|
23
|
+
const balanceData = asset ? balanceMap.get(asset.id) || {} : {};
|
24
|
+
return {
|
25
|
+
network,
|
26
|
+
balanceData,
|
27
|
+
};
|
28
|
+
});
|
29
|
+
networkWithBalanceData.sort((a, b) => compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet));
|
30
|
+
return networkWithBalanceData.map(({ network, balanceData }) => ({
|
31
|
+
...network,
|
32
|
+
rightElement: balanceItem(balanceData),
|
33
|
+
}));
|
34
|
+
}
|
35
|
+
}
|
36
|
+
const networkBalanceData = getBalanceAndFiatValueByAssets(flattenedAccounts, networks, state, counterValueCurrency, discreet, locale);
|
37
|
+
const balanceMap = new Map(networkBalanceData.map(b => [b.id, b]));
|
38
|
+
const networksWithBalance = networks.map(network => {
|
39
|
+
const balanceData = balanceMap.get(network.id) || {};
|
40
|
+
return {
|
41
|
+
network,
|
42
|
+
balanceData,
|
43
|
+
};
|
44
|
+
});
|
45
|
+
networksWithBalance.sort((a, b) => compareByBalanceThenFiat(a.balanceData, b.balanceData, discreet));
|
46
|
+
return networksWithBalance.map(({ network, balanceData }) => ({
|
47
|
+
...network,
|
48
|
+
rightElement: balanceItem(balanceData),
|
49
|
+
}));
|
50
|
+
}, [
|
51
|
+
networks,
|
52
|
+
selectedAssetId,
|
53
|
+
currenciesByProvider,
|
54
|
+
flattenedAccounts,
|
55
|
+
state,
|
56
|
+
counterValueCurrency,
|
57
|
+
discreet,
|
58
|
+
locale,
|
59
|
+
]);
|
60
|
+
};
|
61
|
+
}
|
62
|
+
//# sourceMappingURL=useRightBalanceNetwork.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useRightBalanceNetwork.js","sourceRoot":"","sources":["../../../src/modularDrawer/hooks/useRightBalanceNetwork.tsx"],"names":[],"mappings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,IAAI,GAAG,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAEnE,MAAM,mBAAmB,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;gBACjD,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;gBACrD,OAAO;oBACL,OAAO;oBACP,WAAW;iBACZ,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAChC,wBAAwB,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CACjE,CAAC;YAEF,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;gBAC5D,GAAG,OAAO;gBACV,YAAY,EAAE,WAAW,CAAC,WAAW,CAAC;aACvC,CAAC,CAAC,CAAC;QACN,CAAC,EAAE;YACD,QAAQ;YACR,eAAe;YACf,oBAAoB;YACpB,iBAAiB;YACjB,KAAK;YACL,oBAAoB;YACpB,QAAQ;YACR,MAAM;SACP,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createAssetConfiguration.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/modules/createAssetConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,4BAA4B,EAA0B,MAAM,eAAe,CAAC;AAiChG,QAAA,MAAM,4BAA4B,EAAE,4BAwBjC,CAAC;AAEJ,eAAe,4BAA4B,CAAC"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { composeHooks } from "../../utils/composeHooks";
|
2
|
+
import { createUseLeftApyModule } from "../hooks/useLeftApy";
|
3
|
+
import { createUseRightBalanceAsset } from "../hooks/useRightBalanceAsset";
|
4
|
+
const getRightElement = (AssetConfigurationDeps) => (rightElement) => {
|
5
|
+
switch (rightElement) {
|
6
|
+
case "balance":
|
7
|
+
return createUseRightBalanceAsset({
|
8
|
+
useBalanceDeps: AssetConfigurationDeps.useBalanceDeps,
|
9
|
+
balanceItem: AssetConfigurationDeps.balanceItem,
|
10
|
+
});
|
11
|
+
case "marketTrend":
|
12
|
+
case "undefined":
|
13
|
+
default:
|
14
|
+
return undefined;
|
15
|
+
}
|
16
|
+
};
|
17
|
+
const getLeftElement = (AssetConfigurationDeps) => (leftElement) => {
|
18
|
+
switch (leftElement) {
|
19
|
+
case "apy":
|
20
|
+
return createUseLeftApyModule({ ApyIndicator: AssetConfigurationDeps.ApyIndicator });
|
21
|
+
case "priceVariation":
|
22
|
+
case "undefined":
|
23
|
+
default:
|
24
|
+
return undefined;
|
25
|
+
}
|
26
|
+
};
|
27
|
+
const createAssetConfigurationHook = deps => ({ assetsConfiguration, currenciesByProvider }) => {
|
28
|
+
const { rightElement = "undefined", leftElement = "undefined" } = assetsConfiguration ?? {};
|
29
|
+
const rightHook = getRightElement(deps)(rightElement);
|
30
|
+
const leftHook = getLeftElement(deps)(leftElement);
|
31
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
32
|
+
const hooks = [rightHook, leftHook].filter(Boolean);
|
33
|
+
return (assets) => {
|
34
|
+
const composedHook = composeHooks(...hooks.map(hook => (assets) => hook(assets, currenciesByProvider)));
|
35
|
+
return composedHook(assets);
|
36
|
+
};
|
37
|
+
};
|
38
|
+
export default createAssetConfigurationHook;
|
39
|
+
//# sourceMappingURL=createAssetConfiguration.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createAssetConfiguration.js","sourceRoot":"","sources":["../../../src/modularDrawer/modules/createAssetConfiguration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,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IAEF,OAAO,CAAC,MAA+B,EAAE,EAAE;QACzC,MAAM,YAAY,GAAG,YAAY,CAC/B,GAAG,KAAK,CAAC,GAAG,CACV,IAAI,CAAC,EAAE,CAAC,CAAC,MAA+B,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAChF,CACF,CAAC;QACF,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEJ,eAAe,4BAA4B,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
import { CreateNetworkConfigurationHookProps, NetworkConfigurationDeps, LeftElementKind, Network, NetworkHook, RightElementKind } from "../utils/type";
|
3
|
+
export declare const getLeftElement: (NetworkConfigurationDeps: NetworkConfigurationDeps) => (leftElement: LeftElementKind) => NetworkHook | undefined;
|
4
|
+
export declare const getRightElement: (NetworkConfigurationDeps: NetworkConfigurationDeps) => (rightElement: RightElementKind) => NetworkHook | undefined;
|
5
|
+
export declare const createNetworkConfigurationHook: (NetworkConfigurationDeps: NetworkConfigurationDeps) => ({ networksConfig, selectedAssetId, currenciesByProvider, accounts$, }: CreateNetworkConfigurationHookProps) => (assets: CryptoOrTokenCurrency[]) => Array<CryptoOrTokenCurrency & Network>;
|
6
|
+
//# sourceMappingURL=createNetworkConfiguration.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createNetworkConfiguration.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/modules/createNetworkConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAI1E,OAAO,EACL,mCAAmC,EACnC,wBAAwB,EACxB,eAAe,EACf,OAAO,EACP,WAAW,EACX,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,cAAc,wEAEX,eAAe,KAAG,WAAW,GAAG,SAgB7C,CAAC;AAEJ,eAAO,MAAM,eAAe,yEAEX,gBAAgB,KAAG,WAAW,GAAG,SAW/C,CAAC;AAEJ,eAAO,MAAM,8BAA8B,kIAOtC,mCAAmC,cAQpB,qBAAqB,EAAE,KAAG,MAAM,qBAAqB,GAAG,OAAO,CAchF,CAAC"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { createUseLeftAccountsModule } from "../hooks/useLeftAccounts";
|
2
|
+
import { createUseLeftAccountsApyModule } from "../hooks/useLeftAccountsApy";
|
3
|
+
import { createUseRightBalanceNetwork } from "../hooks/useRightBalanceNetwork";
|
4
|
+
import { composeHooks } from "../../utils/composeHooks";
|
5
|
+
export const getLeftElement = (NetworkConfigurationDeps) => (leftElement) => {
|
6
|
+
switch (leftElement) {
|
7
|
+
case "numberOfAccounts":
|
8
|
+
return createUseLeftAccountsModule({
|
9
|
+
useAccountData: NetworkConfigurationDeps.useAccountData,
|
10
|
+
accountsCount: NetworkConfigurationDeps.accountsCount,
|
11
|
+
});
|
12
|
+
case "numberOfAccountsAndApy":
|
13
|
+
return createUseLeftAccountsApyModule({
|
14
|
+
useAccountData: NetworkConfigurationDeps.useAccountData,
|
15
|
+
accountsCountAndApy: NetworkConfigurationDeps.accountsCountAndApy,
|
16
|
+
});
|
17
|
+
case "undefined":
|
18
|
+
default:
|
19
|
+
return undefined;
|
20
|
+
}
|
21
|
+
};
|
22
|
+
export const getRightElement = (NetworkConfigurationDeps) => (rightElement) => {
|
23
|
+
switch (rightElement) {
|
24
|
+
case "balance":
|
25
|
+
return createUseRightBalanceNetwork({
|
26
|
+
useBalanceDeps: NetworkConfigurationDeps.useBalanceDeps,
|
27
|
+
balanceItem: NetworkConfigurationDeps.balanceItem,
|
28
|
+
});
|
29
|
+
case "undefined":
|
30
|
+
default:
|
31
|
+
return undefined;
|
32
|
+
}
|
33
|
+
};
|
34
|
+
export const createNetworkConfigurationHook = (NetworkConfigurationDeps) => ({ networksConfig, selectedAssetId, currenciesByProvider, accounts$, }) => {
|
35
|
+
const { leftElement = "undefined", rightElement = "undefined" } = networksConfig ?? {};
|
36
|
+
const leftHook = getLeftElement(NetworkConfigurationDeps)(leftElement);
|
37
|
+
const rightHook = getRightElement(NetworkConfigurationDeps)(rightElement);
|
38
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
39
|
+
const hooks = [rightHook, leftHook].filter(Boolean);
|
40
|
+
return (assets) => {
|
41
|
+
const composedHook = composeHooks(...hooks.map(hook => (assets) => hook({
|
42
|
+
assets,
|
43
|
+
selectedAssetId,
|
44
|
+
currenciesByProvider: currenciesByProvider || [],
|
45
|
+
accounts$,
|
46
|
+
})));
|
47
|
+
return composedHook(assets);
|
48
|
+
};
|
49
|
+
};
|
50
|
+
//# sourceMappingURL=createNetworkConfiguration.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createNetworkConfiguration.js","sourceRoot":"","sources":["../../../src/modularDrawer/modules/createNetworkConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAS/E,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,MAAM,CAAC,MAAM,cAAc,GACzB,CAAC,wBAAkD,EAAE,EAAE,CACvD,CAAC,WAA4B,EAA2B,EAAE;IACxD,QAAQ,WAAW,EAAE;QACnB,KAAK,kBAAkB;YACrB,OAAO,2BAA2B,CAAC;gBACjC,cAAc,EAAE,wBAAwB,CAAC,cAAc;gBACvD,aAAa,EAAE,wBAAwB,CAAC,aAAa;aACtD,CAAC,CAAC;QACL,KAAK,wBAAwB;YAC3B,OAAO,8BAA8B,CAAC;gBACpC,cAAc,EAAE,wBAAwB,CAAC,cAAc;gBACvD,mBAAmB,EAAE,wBAAwB,CAAC,mB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C,MAAM,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
export declare const buildProviderCurrenciesMap: (currenciesByProvider?: Array<{
|
3
|
+
providerId: string;
|
4
|
+
currenciesByNetwork?: CryptoOrTokenCurrency[];
|
5
|
+
}>) => Map<string, {
|
6
|
+
mainCurrency: CryptoOrTokenCurrency;
|
7
|
+
currencies: CryptoOrTokenCurrency[];
|
8
|
+
}> | null;
|
9
|
+
//# sourceMappingURL=buildProviderCurrenciesMap.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"buildProviderCurrenciesMap.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/buildProviderCurrenciesMap.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,eAAO,MAAM,0BAA0B,0BACd,MAAM;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAC/C,CAAC;kBAMgB,qBAAqB;gBAAc,qBAAqB,EAAE;SAY7E,CAAC"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export const buildProviderCurrenciesMap = (currenciesByProvider) => {
|
2
|
+
if (!currenciesByProvider?.length)
|
3
|
+
return null;
|
4
|
+
const map = new Map();
|
5
|
+
currenciesByProvider.forEach(({ providerId, currenciesByNetwork = [] }) => {
|
6
|
+
if (currenciesByNetwork.length > 0) {
|
7
|
+
const mainCurrency = currenciesByNetwork.find(c => c.id === providerId) ?? currenciesByNetwork[0];
|
8
|
+
map.set(providerId, { mainCurrency, currencies: currenciesByNetwork });
|
9
|
+
}
|
10
|
+
});
|
11
|
+
return map;
|
12
|
+
};
|
13
|
+
//# sourceMappingURL=buildProviderCurrenciesMap.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"buildProviderCurrenciesMap.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/buildProviderCurrenciesMap.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,oBAGE,EACF,EAAE;IACF,IAAI,CAAC,oBAAoB,EAAE,MAAM;QAAE,OAAO,IAAI,CAAC;IAE/C,MAAM,GAAG,GAAG,IAAI,GAAG,EAGhB,CAAC;IAEJ,oBAAoB,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,mBAAmB,GAAG,EAAE,EAAE,EAAE,EAAE;QACxE,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE;YAClC,MAAM,YAAY,GAChB,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;YAC/E,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,mBAAmB,EAAE,CAAC,CAAC;SACxE;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { BalanceUI } from "./type";
|
2
|
+
export declare const parseFiatValue: (value?: string, discreet?: boolean) => number;
|
3
|
+
export declare function toFiatString(x?: BalanceUI): string | undefined;
|
4
|
+
export declare function hasBalance(balanceData?: BalanceUI): boolean;
|
5
|
+
export declare function compareByBalanceThenFiat(a: BalanceUI | undefined, b: BalanceUI | undefined, discreet: boolean): number;
|
6
|
+
//# sourceMappingURL=sortByBalance.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sortByBalance.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/sortByBalance.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,eAAO,MAAM,cAAc,WAAY,MAAM,aAAa,OAAO,WAGhE,CAAC;AAEF,wBAAgB,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,UAAU,CAAC,WAAW,CAAC,EAAE,SAAS,GAAG,OAAO,CAM3D;AAED,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,SAAS,GAAG,SAAS,EACxB,CAAC,EAAE,SAAS,GAAG,SAAS,EACxB,QAAQ,EAAE,OAAO,GAChB,MAAM,CAQR"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
export const parseFiatValue = (value, discreet) => {
|
2
|
+
if (!value || discreet)
|
3
|
+
return -1;
|
4
|
+
return parseFloat(value.replace(/[^0-9.-]+/g, "")) || -1;
|
5
|
+
};
|
6
|
+
export function toFiatString(x) {
|
7
|
+
return x && "fiatValue" in x ? String(x.fiatValue) : undefined;
|
8
|
+
}
|
9
|
+
export function hasBalance(balanceData) {
|
10
|
+
return (!!balanceData &&
|
11
|
+
(("fiatValue" in balanceData && !!balanceData.fiatValue) ||
|
12
|
+
("balance" in balanceData && !!balanceData.balance)));
|
13
|
+
}
|
14
|
+
export function compareByBalanceThenFiat(a, b, discreet) {
|
15
|
+
const ah = hasBalance(a);
|
16
|
+
const bh = hasBalance(b);
|
17
|
+
if (ah && !bh)
|
18
|
+
return -1;
|
19
|
+
if (!ah && bh)
|
20
|
+
return 1;
|
21
|
+
const af = parseFiatValue(toFiatString(a), discreet);
|
22
|
+
const bf = parseFiatValue(toFiatString(b), discreet);
|
23
|
+
return bf - af;
|
24
|
+
}
|
25
|
+
//# sourceMappingURL=sortByBalance.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sortByBalance.js","sourceRoot":"","sources":["../../../src/modularDrawer/utils/sortByBalance.tsx"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAE,QAAkB,EAAE,EAAE;IACnE,IAAI,CAAC,K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} from "@ledgerhq/types-cryptoassets";
|
3
|
+
import { AccountLike } from "@ledgerhq/types-live";
|
4
|
+
import { ReactNode } from "react";
|
5
|
+
import { Observable } from "rxjs";
|
6
|
+
import { WalletAPIAccount } from "../../wallet-api/types";
|
7
|
+
import { CurrenciesByProviderId } from "../../deposit/type";
|
8
|
+
import { EnhancedModularDrawerConfiguration } from "../../wallet-api/ModularDrawer/types";
|
9
|
+
export type ApyType = "NRR" | "APY" | "APR";
|
2
10
|
export type AssetType = {
|
3
11
|
name: string;
|
4
12
|
ticker: string;
|
@@ -18,4 +26,84 @@ export type ProviderBalanceResultsMap = Map<string, ProviderBalanceAsset>;
|
|
18
26
|
export type AssetWithBalance = AssetType & {
|
19
27
|
sortValue?: number;
|
20
28
|
};
|
29
|
+
export type UseBalanceDeps = () => {
|
30
|
+
flattenedAccounts: AccountLike[];
|
31
|
+
discreet: boolean;
|
32
|
+
state: CounterValuesState;
|
33
|
+
counterValueCurrency: Currency;
|
34
|
+
locale: string;
|
35
|
+
};
|
36
|
+
export type BalanceUI = {
|
37
|
+
balance?: string;
|
38
|
+
fiatValue?: string;
|
39
|
+
};
|
40
|
+
export type CreateBalanceItem = (x: BalanceUI) => React.ReactNode;
|
41
|
+
export type CreateAccountsCountAndApy = (args: {
|
42
|
+
label: string;
|
43
|
+
value: number;
|
44
|
+
type: ApyType;
|
45
|
+
}) => ReactNode;
|
46
|
+
export type NetworkWithCount = CryptoOrTokenCurrency & {
|
47
|
+
leftElement?: ReactNode;
|
48
|
+
count: number;
|
49
|
+
};
|
50
|
+
export type AccountDataItem = {
|
51
|
+
asset: CryptoOrTokenCurrency;
|
52
|
+
label: string;
|
53
|
+
count: number;
|
54
|
+
};
|
55
|
+
export type AccountModuleParams = {
|
56
|
+
assets: CryptoOrTokenCurrency[];
|
57
|
+
accounts$?: Observable<WalletAPIAccount[]>;
|
58
|
+
};
|
59
|
+
export type CreateAccountsCount = (args: {
|
60
|
+
label: string;
|
61
|
+
}) => ReactNode;
|
62
|
+
export type UseAccountData = (params: AccountModuleParams) => AccountDataItem[];
|
63
|
+
export type NetworkHookParams = {
|
64
|
+
assets: CryptoOrTokenCurrency[];
|
65
|
+
selectedAssetId: string;
|
66
|
+
currenciesByProvider: CurrenciesByProviderId[];
|
67
|
+
accounts$?: Observable<WalletAPIAccount[]>;
|
68
|
+
};
|
69
|
+
export type NetworkHook = (params: NetworkHookParams) => Array<CryptoOrTokenCurrency & Network>;
|
70
|
+
export type NetworkConfigurationDeps = {
|
71
|
+
useAccountData: UseAccountData;
|
72
|
+
accountsCount: CreateAccountsCount;
|
73
|
+
accountsCountAndApy: CreateAccountsCountAndApy;
|
74
|
+
useBalanceDeps: UseBalanceDeps;
|
75
|
+
balanceItem: CreateBalanceItem;
|
76
|
+
};
|
77
|
+
export type LeftElementKind = "numberOfAccounts" | "numberOfAccountsAndApy" | "undefined";
|
78
|
+
export type RightElementKind = "balance" | "undefined";
|
79
|
+
export type Network = {
|
80
|
+
name: string;
|
81
|
+
id: string;
|
82
|
+
ticker: string;
|
83
|
+
leftElement?: React.ReactNode;
|
84
|
+
rightElement?: React.ReactNode;
|
85
|
+
};
|
86
|
+
export type CreateNetworkConfigurationHookProps = {
|
87
|
+
networksConfig: EnhancedModularDrawerConfiguration["networks"];
|
88
|
+
currenciesByProvider?: CurrenciesByProviderId[];
|
89
|
+
selectedAssetId: string;
|
90
|
+
accounts$?: Observable<WalletAPIAccount[]>;
|
91
|
+
};
|
92
|
+
type Props = {
|
93
|
+
assetsConfiguration: EnhancedModularDrawerConfiguration["assets"];
|
94
|
+
currenciesByProvider?: CurrenciesByProviderId[];
|
95
|
+
};
|
96
|
+
export type AssetConfigurationDeps = {
|
97
|
+
ApyIndicator: (args: {
|
98
|
+
value: number;
|
99
|
+
type: ApyType;
|
100
|
+
}) => ReactNode;
|
101
|
+
useBalanceDeps: UseBalanceDeps;
|
102
|
+
balanceItem: (asset: {
|
103
|
+
fiatValue?: string;
|
104
|
+
balance?: string;
|
105
|
+
}) => ReactNode;
|
106
|
+
};
|
107
|
+
export type CreateAssetConfigurationHook = (AssetConfigurationDeps: AssetConfigurationDeps) => (props: Props) => (assets: CryptoOrTokenCurrency[]) => (CryptoOrTokenCurrency & AssetType)[];
|
108
|
+
export {};
|
21
109
|
//# sourceMappingURL=type.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/type.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../src/modularDrawer/utils/type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAE1F,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAE5C,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OA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ChD,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;CAC5C,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,mBAAmB,EAAE,kCAAkC,CAAC,QAAQ,CAAC,CAAC;IAClE,oBAAoB,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,YAAY,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,KAAK,SAAS,CAAC;IACpE,cAAc,EAAE,cAAc,CAAC;IAC/B,WAAW,EAAE,CAAC,KAAK,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAC;CAC7E,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,CACzC,sBAAsB,EAAE,sBAAsB,KAC3C,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,MAAM,EAAE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,GAAG,SAAS,CAAC,EAAE,CAAC"}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ledgerhq/live-common",
|
3
3
|
"description": "Common ground for the Ledger Live apps",
|
4
|
-
"version": "34.47.0-nightly.
|
4
|
+
"version": "34.47.0-nightly.7",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
7
7
|
"url": "https://github.com/LedgerHQ/ledger-live.git"
|
@@ -165,8 +165,6 @@
|
|
165
165
|
"xstate": "^5.19.2",
|
166
166
|
"yargs": "^17.0.0",
|
167
167
|
"zod": "^3.22.4",
|
168
|
-
"@ledgerhq/coin-algorand": "^0.9.19-nightly.1",
|
169
|
-
"@ledgerhq/coin-aptos": "^3.2.0-nightly.1",
|
170
168
|
"@ledgerhq/coin-bitcoin": "^0.21.0-nightly.1",
|
171
169
|
"@ledgerhq/coin-canton": "^0.4.0-nightly.2",
|
172
170
|
"@ledgerhq/coin-cardano": "^0.11.3-nightly.1",
|
@@ -220,9 +218,9 @@
|
|
220
218
|
"@ledgerhq/ledger-cal-service": "^1.4.0-nightly.2",
|
221
219
|
"@ledgerhq/live-config": "^3.2.0-nightly.0",
|
222
220
|
"@ledgerhq/live-countervalues": "^0.6.3-nightly.1",
|
221
|
+
"@ledgerhq/live-countervalues-react": "^0.6.0-nightly.1",
|
223
222
|
"@ledgerhq/live-dmk-shared": "^0.12.1",
|
224
223
|
"@ledgerhq/live-env": "^2.15.0-nightly.1",
|
225
|
-
"@ledgerhq/live-countervalues-react": "^0.6.0-nightly.1",
|
226
224
|
"@ledgerhq/live-hooks": "0.1.0",
|
227
225
|
"@ledgerhq/live-network": "^2.0.16-nightly.1",
|
228
226
|
"@ledgerhq/live-nft": "^0.8.19-nightly.1",
|
@@ -234,7 +232,9 @@
|
|
234
232
|
"@ledgerhq/logs": "^6.13.0",
|
235
233
|
"@ledgerhq/speculos-transport": "^0.2.9-nightly.2",
|
236
234
|
"@ledgerhq/wallet-api-acre-module": "^0.6.0",
|
237
|
-
"@ledgerhq/wallet-api-exchange-module": "^0.16.0-nightly.1"
|
235
|
+
"@ledgerhq/wallet-api-exchange-module": "^0.16.0-nightly.1",
|
236
|
+
"@ledgerhq/coin-aptos": "^3.2.0-nightly.1",
|
237
|
+
"@ledgerhq/coin-algorand": "^0.9.19-nightly.1"
|
238
238
|
},
|
239
239
|
"devDependencies": {
|
240
240
|
"@solana/web3.js": "1.95.4",
|
@@ -43,6 +43,46 @@ describe("Alpaca utils", () => {
|
|
43
43
|
recipients: ["recipient1"],
|
44
44
|
};
|
45
45
|
|
46
|
+
it("does not include fees in non native asset value", () => {
|
47
|
+
expect(
|
48
|
+
adaptCoreOperationToLiveOperation("account", {
|
49
|
+
id: "operation",
|
50
|
+
asset: { type: "token", assetOwner: "owner", assetReference: "reference" },
|
51
|
+
type: "OUT",
|
52
|
+
value: BigInt(100),
|
53
|
+
tx: {
|
54
|
+
hash: "hash",
|
55
|
+
fees: BigInt(10),
|
56
|
+
block: {
|
57
|
+
hash: "block_hash",
|
58
|
+
height: 123456,
|
59
|
+
},
|
60
|
+
date: new Date("2025-08-29T12:00:00Z"),
|
61
|
+
},
|
62
|
+
senders: ["sender"],
|
63
|
+
recipients: ["recipient"],
|
64
|
+
}),
|
65
|
+
).toEqual({
|
66
|
+
id: "account-hash-OUT",
|
67
|
+
hash: "hash",
|
68
|
+
accountId: "account",
|
69
|
+
type: "OUT",
|
70
|
+
value: new BigNumber(100), // value only
|
71
|
+
fee: new BigNumber(10),
|
72
|
+
extra: {
|
73
|
+
assetOwner: "owner",
|
74
|
+
assetReference: "reference",
|
75
|
+
},
|
76
|
+
blockHash: "block_hash",
|
77
|
+
blockHeight: 123456,
|
78
|
+
senders: ["sender"],
|
79
|
+
recipients: ["recipient"],
|
80
|
+
date: new Date("2025-08-29T12:00:00Z"),
|
81
|
+
transactionSequenceNumber: undefined,
|
82
|
+
hasFailed: false,
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
46
86
|
it("adapts a basic OUT operation", () => {
|
47
87
|
const result = adaptCoreOperationToLiveOperation(accountId, baseOp);
|
48
88
|
|
@@ -52,9 +52,10 @@ export function adaptCoreOperationToLiveOperation(accountId: string, op: CoreOpe
|
|
52
52
|
hash: op.tx.hash,
|
53
53
|
accountId,
|
54
54
|
type: opType,
|
55
|
-
value:
|
56
|
-
|
57
|
-
|
55
|
+
value:
|
56
|
+
op.asset.type === "native" && ["OUT", "FEES"].includes(opType)
|
57
|
+
? new BigNumber(op.value.toString()).plus(bnFees)
|
58
|
+
: new BigNumber(op.value.toString()),
|
58
59
|
fee: bnFees,
|
59
60
|
blockHash: op.tx.block.hash,
|
60
61
|
blockHeight: op.tx.block.height,
|
package/src/e2e/speculos.ts
CHANGED
@@ -460,7 +460,7 @@ async function retryAxiosRequest<T>(
|
|
460
460
|
throw lastError!;
|
461
461
|
}
|
462
462
|
|
463
|
-
export async function waitFor(text: string, maxAttempts =
|
463
|
+
export async function waitFor(text: string, maxAttempts = 60): Promise<string[]> {
|
464
464
|
const port = getEnv("SPECULOS_API_PORT");
|
465
465
|
const address = getSpeculosAddress();
|
466
466
|
const url = `${address}:${port}/events?stream=false¤tscreenonly=true`;
|
@@ -737,6 +737,14 @@ export async function verifyAmountsAndAcceptSwap(swap: Swap, amount: string) {
|
|
737
737
|
await pressBoth();
|
738
738
|
}
|
739
739
|
|
740
|
+
export async function verifyAmountsAndAcceptSwapForDifferentSeed(swap: Swap, amount: string) {
|
741
|
+
await pressUntilTextFound(DeviceLabels.I_UNDERSTAND);
|
742
|
+
await pressBoth();
|
743
|
+
const events = await pressUntilTextFound(DeviceLabels.SIGN_TRANSACTION);
|
744
|
+
await verifySwapData(swap, events, amount);
|
745
|
+
await pressBoth();
|
746
|
+
}
|
747
|
+
|
740
748
|
export async function verifyAmountsAndRejectSwap(swap: Swap, amount: string) {
|
741
749
|
await waitFor(DeviceLabels.REVIEW_TRANSACTION);
|
742
750
|
const events = await pressUntilTextFound(DeviceLabels.REJECT);
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React, { useMemo } from "react";
|
2
2
|
import { useSelector } from "react-redux";
|
3
3
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
4
|
-
import { ApyType } from "../../types";
|
5
4
|
import { selectInterestRateByCurrency } from "../../data/entities/interestRateSelectors";
|
5
|
+
import { ApyType } from "../../utils/type";
|
6
6
|
|
7
7
|
const isValidApyType = (type: string): type is ApyType =>
|
8
8
|
type === "NRR" || type === "APY" || type === "APR";
|
package/src/modularDrawer/hooks/{modules/useAssetAccountCounts.tsx → useAssetAccountCounts.tsx}
RENAMED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Observable } from "rxjs";
|
2
2
|
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
3
|
-
import { getAccountTuplesForCurrency } from "
|
3
|
+
import { getAccountTuplesForCurrency } from "../../utils/getAccountTuplesForCurrency";
|
4
4
|
import type { Account } from "@ledgerhq/types-live";
|
5
|
-
import { WalletAPIAccount } from "
|
5
|
+
import { WalletAPIAccount } from "../../wallet-api/types";
|
6
6
|
|
7
7
|
type AccountModuleParams = {
|
8
8
|
assets: CryptoOrTokenCurrency[];
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets";
|
2
|
+
import { ReactNode } from "react";
|
3
|
+
import { AccountModuleParams, AccountDataItem } from "../utils/type";
|
4
|
+
|
5
|
+
export const createUseLeftAccountsModule = ({
|
6
|
+
useAccountData,
|
7
|
+
accountsCount,
|
8
|
+
}: {
|
9
|
+
useAccountData: (params: AccountModuleParams) => AccountDataItem[];
|
10
|
+
accountsCount: (args: { label: string }) => ReactNode;
|
11
|
+
}) => {
|
12
|
+
return function useLeftAccountsModule(
|
13
|
+
params: AccountModuleParams,
|
14
|
+
): Array<CryptoOrTokenCurrency & { leftElement?: ReactNode; count: number }> {
|
15
|
+
const accountData = useAccountData(params);
|
16
|
+
|
17
|
+
return accountData.map(({ asset, label, count }) => ({
|
18
|
+
...asset,
|
19
|
+
leftElement: count > 0 ? accountsCount({ label }) : undefined,
|
20
|
+
count,
|
21
|
+
}));
|
22
|
+
};
|
23
|
+
};
|