@ledgerhq/live-common 34.51.0-nightly.2 → 34.51.0-nightly.3
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/crypto-assets/index.d.ts.map +1 -1
- package/lib/bridge/crypto-assets/index.js +0 -2
- package/lib/bridge/crypto-assets/index.js.map +1 -1
- package/lib/bridge/crypto-assets/index.test.js +0 -4
- package/lib/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib/currencies/index.d.ts +1 -1
- package/lib/currencies/index.d.ts.map +1 -1
- package/lib/currencies/index.js +2 -3
- package/lib/currencies/index.js.map +1 -1
- package/lib/currencies/sortByMarketcap.test.js +1 -3
- package/lib/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib/e2e/enum/Account.d.ts +4 -0
- package/lib/e2e/enum/Account.d.ts.map +1 -1
- package/lib/e2e/enum/Account.js +4 -0
- package/lib/e2e/enum/Account.js.map +1 -1
- package/lib/e2e/enum/AppInfos.d.ts +1 -0
- package/lib/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib/e2e/enum/AppInfos.js +1 -0
- package/lib/e2e/enum/AppInfos.js.map +1 -1
- package/lib/e2e/enum/Currency.d.ts +2 -0
- package/lib/e2e/enum/Currency.d.ts.map +1 -1
- package/lib/e2e/enum/Currency.js +2 -0
- package/lib/e2e/enum/Currency.js.map +1 -1
- package/lib/e2e/enum/Network.d.ts +2 -1
- package/lib/e2e/enum/Network.d.ts.map +1 -1
- package/lib/e2e/enum/Network.js +1 -0
- package/lib/e2e/enum/Network.js.map +1 -1
- package/lib/e2e/enum/TokenType.d.ts +2 -1
- package/lib/e2e/enum/TokenType.d.ts.map +1 -1
- package/lib/e2e/enum/TokenType.js +1 -0
- package/lib/e2e/enum/TokenType.js.map +1 -1
- package/lib/e2e/enum/TransactionStatus.d.ts +4 -1
- package/lib/e2e/enum/TransactionStatus.d.ts.map +1 -1
- package/lib/e2e/enum/TransactionStatus.js +3 -0
- package/lib/e2e/enum/TransactionStatus.js.map +1 -1
- package/lib/e2e/families/sui.d.ts +2 -0
- package/lib/e2e/families/sui.d.ts.map +1 -0
- package/lib/e2e/families/sui.js +11 -0
- package/lib/e2e/families/sui.js.map +1 -0
- package/lib/e2e/index.d.ts +3 -0
- package/lib/e2e/index.d.ts.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 +23 -1
- package/lib/e2e/speculos.js.map +1 -1
- package/lib/env.react.d.ts +1 -1
- package/lib/env.react.d.ts.map +1 -1
- package/lib/exchange/providers/swap.js +4 -4
- package/lib/exchange/providers/swap.js.map +1 -1
- package/lib/exchange/swap/api/v5/__mocks__/fetchRates.mocks.d.ts.map +1 -1
- package/lib/exchange/swap/api/v5/__mocks__/fetchRates.mocks.js +1 -1
- package/lib/exchange/swap/api/v5/__mocks__/fetchRates.mocks.js.map +1 -1
- package/lib/exchange/swap/mock.js +1 -1
- package/lib/exchange/swap/mock.js.map +1 -1
- package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib/featureFlags/defaultFeatures.js +4 -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/hooks/useManifestWithSessionId.d.ts +12 -0
- package/lib/hooks/useManifestWithSessionId.d.ts.map +1 -0
- package/lib/hooks/useManifestWithSessionId.js +67 -0
- package/lib/hooks/useManifestWithSessionId.js.map +1 -0
- package/lib/hooks/useManifestWithSessionId.test.d.ts +2 -0
- package/lib/hooks/useManifestWithSessionId.test.d.ts.map +1 -0
- package/lib/hooks/useManifestWithSessionId.test.js +71 -0
- package/lib/hooks/useManifestWithSessionId.test.js.map +1 -0
- package/lib/market/utils/index.d.ts +1 -0
- package/lib/market/utils/index.d.ts.map +1 -1
- package/lib/market/utils/index.js +16 -0
- package/lib/market/utils/index.js.map +1 -1
- package/lib/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.d.ts +2 -0
- package/lib/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.js +350 -0
- package/lib/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.js.map +1 -0
- package/lib/modularDrawer/hooks/index.d.ts +2 -0
- package/lib/modularDrawer/hooks/index.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/index.js +6 -0
- package/lib/modularDrawer/hooks/index.js.map +1 -0
- package/lib/modularDrawer/hooks/useDetailedAccountsCore.d.ts +14 -0
- package/lib/modularDrawer/hooks/useDetailedAccountsCore.d.ts.map +1 -0
- package/lib/modularDrawer/hooks/useDetailedAccountsCore.js +119 -0
- package/lib/modularDrawer/hooks/useDetailedAccountsCore.js.map +1 -0
- package/lib/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js +9 -1
- package/lib/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts +6 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js +12 -4
- package/lib/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
- package/lib/modularDrawer/index.d.ts +4 -0
- package/lib/modularDrawer/index.d.ts.map +1 -0
- package/lib/modularDrawer/index.js +20 -0
- package/lib/modularDrawer/index.js.map +1 -0
- package/lib/modularDrawer/types/detailedAccount.d.ts +46 -0
- package/lib/modularDrawer/types/detailedAccount.d.ts.map +1 -0
- package/lib/modularDrawer/types/detailedAccount.js +3 -0
- package/lib/modularDrawer/types/detailedAccount.js.map +1 -0
- package/lib/modularDrawer/types/index.d.ts +2 -0
- package/lib/modularDrawer/types/index.d.ts.map +1 -0
- package/lib/modularDrawer/types/index.js +18 -0
- package/lib/modularDrawer/types/index.js.map +1 -0
- package/lib/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.d.ts +2 -0
- package/lib/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.d.ts.map +1 -0
- package/lib/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.js +106 -0
- package/lib/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.js.map +1 -0
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +3 -4
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -1
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +7 -0
- package/lib/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -1
- package/lib/modularDrawer/utils/index.d.ts +1 -0
- package/lib/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib/modularDrawer/utils/index.js +3 -1
- package/lib/modularDrawer/utils/index.js.map +1 -1
- package/lib/modularDrawer/utils/sortAccountsByFiatValue.d.ts +8 -0
- package/lib/modularDrawer/utils/sortAccountsByFiatValue.d.ts.map +1 -0
- package/lib/modularDrawer/utils/sortAccountsByFiatValue.js +17 -0
- package/lib/modularDrawer/utils/sortAccountsByFiatValue.js.map +1 -0
- package/lib/modularDrawer/utils/type.d.ts +2 -2
- package/lib/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib/platform/providers/RemoteLiveAppProvider/api/mock.json +3 -3
- package/lib/wallet-api/useDappLogic.js +1 -1
- package/lib/wallet-api/useDappLogic.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.d.ts.map +1 -1
- package/lib-es/bridge/crypto-assets/index.js +0 -2
- package/lib-es/bridge/crypto-assets/index.js.map +1 -1
- package/lib-es/bridge/crypto-assets/index.test.js +0 -4
- package/lib-es/bridge/crypto-assets/index.test.js.map +1 -1
- package/lib-es/currencies/index.d.ts +1 -1
- package/lib-es/currencies/index.d.ts.map +1 -1
- package/lib-es/currencies/index.js +1 -1
- package/lib-es/currencies/index.js.map +1 -1
- package/lib-es/currencies/sortByMarketcap.test.js +1 -3
- package/lib-es/currencies/sortByMarketcap.test.js.map +1 -1
- package/lib-es/e2e/enum/Account.d.ts +4 -0
- package/lib-es/e2e/enum/Account.d.ts.map +1 -1
- package/lib-es/e2e/enum/Account.js +4 -0
- package/lib-es/e2e/enum/Account.js.map +1 -1
- package/lib-es/e2e/enum/AppInfos.d.ts +1 -0
- package/lib-es/e2e/enum/AppInfos.d.ts.map +1 -1
- package/lib-es/e2e/enum/AppInfos.js +1 -0
- package/lib-es/e2e/enum/AppInfos.js.map +1 -1
- package/lib-es/e2e/enum/Currency.d.ts +2 -0
- package/lib-es/e2e/enum/Currency.d.ts.map +1 -1
- package/lib-es/e2e/enum/Currency.js +2 -0
- package/lib-es/e2e/enum/Currency.js.map +1 -1
- package/lib-es/e2e/enum/Network.d.ts +2 -1
- package/lib-es/e2e/enum/Network.d.ts.map +1 -1
- package/lib-es/e2e/enum/Network.js +1 -0
- package/lib-es/e2e/enum/Network.js.map +1 -1
- package/lib-es/e2e/enum/TokenType.d.ts +2 -1
- package/lib-es/e2e/enum/TokenType.d.ts.map +1 -1
- package/lib-es/e2e/enum/TokenType.js +1 -0
- package/lib-es/e2e/enum/TokenType.js.map +1 -1
- package/lib-es/e2e/enum/TransactionStatus.d.ts +4 -1
- package/lib-es/e2e/enum/TransactionStatus.d.ts.map +1 -1
- package/lib-es/e2e/enum/TransactionStatus.js +3 -0
- package/lib-es/e2e/enum/TransactionStatus.js.map +1 -1
- package/lib-es/e2e/families/sui.d.ts +2 -0
- package/lib-es/e2e/families/sui.d.ts.map +1 -0
- package/lib-es/e2e/families/sui.js +7 -0
- package/lib-es/e2e/families/sui.js.map +1 -0
- package/lib-es/e2e/index.d.ts +3 -0
- package/lib-es/e2e/index.d.ts.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 +21 -0
- package/lib-es/e2e/speculos.js.map +1 -1
- package/lib-es/env.react.d.ts +1 -1
- package/lib-es/env.react.d.ts.map +1 -1
- package/lib-es/exchange/providers/swap.js +4 -4
- package/lib-es/exchange/providers/swap.js.map +1 -1
- package/lib-es/exchange/swap/api/v5/__mocks__/fetchRates.mocks.d.ts.map +1 -1
- package/lib-es/exchange/swap/api/v5/__mocks__/fetchRates.mocks.js +1 -1
- package/lib-es/exchange/swap/api/v5/__mocks__/fetchRates.mocks.js.map +1 -1
- package/lib-es/exchange/swap/mock.js +1 -1
- package/lib-es/exchange/swap/mock.js.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.d.ts.map +1 -1
- package/lib-es/featureFlags/defaultFeatures.js +4 -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/hooks/useManifestWithSessionId.d.ts +12 -0
- package/lib-es/hooks/useManifestWithSessionId.d.ts.map +1 -0
- package/lib-es/hooks/useManifestWithSessionId.js +60 -0
- package/lib-es/hooks/useManifestWithSessionId.js.map +1 -0
- package/lib-es/hooks/useManifestWithSessionId.test.d.ts +2 -0
- package/lib-es/hooks/useManifestWithSessionId.test.d.ts.map +1 -0
- package/lib-es/hooks/useManifestWithSessionId.test.js +69 -0
- package/lib-es/hooks/useManifestWithSessionId.test.js.map +1 -0
- package/lib-es/market/utils/index.d.ts +1 -0
- package/lib-es/market/utils/index.d.ts.map +1 -1
- package/lib-es/market/utils/index.js +2 -0
- package/lib-es/market/utils/index.js.map +1 -1
- package/lib-es/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.d.ts +2 -0
- package/lib-es/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.js +345 -0
- package/lib-es/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.js.map +1 -0
- package/lib-es/modularDrawer/hooks/index.d.ts +2 -0
- package/lib-es/modularDrawer/hooks/index.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/index.js +2 -0
- package/lib-es/modularDrawer/hooks/index.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useDetailedAccountsCore.d.ts +14 -0
- package/lib-es/modularDrawer/hooks/useDetailedAccountsCore.d.ts.map +1 -0
- package/lib-es/modularDrawer/hooks/useDetailedAccountsCore.js +115 -0
- package/lib-es/modularDrawer/hooks/useDetailedAccountsCore.js.map +1 -0
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js +6 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceAsset.js.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts +6 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.d.ts.map +1 -1
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js +9 -4
- package/lib-es/modularDrawer/hooks/useRightBalanceNetwork.js.map +1 -1
- package/lib-es/modularDrawer/index.d.ts +4 -0
- package/lib-es/modularDrawer/index.d.ts.map +1 -0
- package/lib-es/modularDrawer/index.js +4 -0
- package/lib-es/modularDrawer/index.js.map +1 -0
- package/lib-es/modularDrawer/types/detailedAccount.d.ts +46 -0
- package/lib-es/modularDrawer/types/detailedAccount.d.ts.map +1 -0
- package/lib-es/modularDrawer/types/detailedAccount.js +2 -0
- package/lib-es/modularDrawer/types/detailedAccount.js.map +1 -0
- package/lib-es/modularDrawer/types/index.d.ts +2 -0
- package/lib-es/modularDrawer/types/index.d.ts.map +1 -0
- package/lib-es/modularDrawer/types/index.js +2 -0
- package/lib-es/modularDrawer/types/index.js.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.d.ts +2 -0
- package/lib-es/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.js +101 -0
- package/lib-es/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.js.map +1 -0
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts +3 -4
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js +4 -0
- package/lib-es/modularDrawer/utils/getBalanceAndFiatValueByAssets.js.map +1 -1
- package/lib-es/modularDrawer/utils/index.d.ts +1 -0
- package/lib-es/modularDrawer/utils/index.d.ts.map +1 -1
- package/lib-es/modularDrawer/utils/index.js +1 -0
- package/lib-es/modularDrawer/utils/index.js.map +1 -1
- package/lib-es/modularDrawer/utils/sortAccountsByFiatValue.d.ts +8 -0
- package/lib-es/modularDrawer/utils/sortAccountsByFiatValue.d.ts.map +1 -0
- package/lib-es/modularDrawer/utils/sortAccountsByFiatValue.js +13 -0
- package/lib-es/modularDrawer/utils/sortAccountsByFiatValue.js.map +1 -0
- package/lib-es/modularDrawer/utils/type.d.ts +2 -2
- package/lib-es/modularDrawer/utils/type.d.ts.map +1 -1
- package/lib-es/platform/providers/RemoteLiveAppProvider/api/mock.json +3 -3
- package/lib-es/wallet-api/useDappLogic.js +2 -2
- package/lib-es/wallet-api/useDappLogic.js.map +1 -1
- package/package.json +51 -51
- package/src/bridge/crypto-assets/index.test.ts +0 -4
- package/src/bridge/crypto-assets/index.ts +0 -2
- package/src/currencies/index.ts +1 -2
- package/src/currencies/sortByMarketcap.test.ts +1 -3
- package/src/e2e/enum/Account.ts +31 -0
- package/src/e2e/enum/AppInfos.ts +2 -0
- package/src/e2e/enum/Currency.ts +11 -0
- package/src/e2e/enum/Network.ts +1 -0
- package/src/e2e/enum/TokenType.ts +1 -0
- package/src/e2e/enum/TransactionStatus.ts +3 -0
- package/src/e2e/families/sui.ts +7 -0
- package/src/e2e/speculos.ts +23 -0
- package/src/exchange/providers/swap.ts +4 -4
- package/src/exchange/swap/api/v5/__mocks__/fetchRates.mocks.ts +1 -2
- package/src/exchange/swap/mock.ts +1 -1
- package/src/featureFlags/defaultFeatures.ts +5 -0
- package/src/hooks/useManifestWithSessionId.test.ts +105 -0
- package/src/hooks/useManifestWithSessionId.ts +83 -0
- package/src/market/utils/index.ts +3 -0
- package/src/modularDrawer/hooks/__tests__/useDetailedAccountsCore.test.ts +472 -0
- package/src/modularDrawer/hooks/index.ts +1 -0
- package/src/modularDrawer/hooks/useDetailedAccountsCore.ts +146 -0
- package/src/modularDrawer/hooks/useRightBalanceAsset.tsx +5 -1
- package/src/modularDrawer/hooks/useRightBalanceNetwork.tsx +10 -4
- package/src/modularDrawer/index.ts +3 -0
- package/src/modularDrawer/types/detailedAccount.ts +49 -0
- package/src/modularDrawer/types/index.ts +1 -0
- package/src/modularDrawer/utils/__tests__/sortAccountsByFiatValue.test.ts +117 -0
- package/src/modularDrawer/utils/getBalanceAndFiatValueByAssets.ts +6 -3
- package/src/modularDrawer/utils/index.ts +1 -0
- package/src/modularDrawer/utils/sortAccountsByFiatValue.ts +14 -0
- package/src/modularDrawer/utils/type.ts +3 -2
- package/src/platform/providers/RemoteLiveAppProvider/api/mock.json +3 -3
- package/src/wallet-api/useDappLogic.ts +3 -3
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.51.0-nightly.
|
|
4
|
+
"version": "34.51.0-nightly.3",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/LedgerHQ/ledger-live.git"
|
|
@@ -166,45 +166,45 @@
|
|
|
166
166
|
"xstate": "^5.19.2",
|
|
167
167
|
"yargs": "^17.0.0",
|
|
168
168
|
"zod": "^3.22.4",
|
|
169
|
-
"@ledgerhq/coin-algorand": "^0.11.0-nightly.
|
|
170
|
-
"@ledgerhq/coin-aptos": "^3.4.0-nightly.
|
|
171
|
-
"@ledgerhq/coin-bitcoin": "^0.23.0-nightly.
|
|
172
|
-
"@ledgerhq/coin-canton": "^0.8.0-nightly.
|
|
173
|
-
"@ledgerhq/coin-cardano": "^0.13.0-nightly.
|
|
174
|
-
"@ledgerhq/coin-casper": "^2.2.0-nightly.
|
|
175
|
-
"@ledgerhq/coin-celo": "^1.6.0-nightly.
|
|
176
|
-
"@ledgerhq/coin-cosmos": "^0.18.0-nightly.
|
|
177
|
-
"@ledgerhq/coin-evm": "^2.33.0-nightly.
|
|
178
|
-
"@ledgerhq/coin-filecoin": "^1.13.0-nightly.
|
|
179
|
-
"@ledgerhq/coin-framework": "^6.7.0-nightly.
|
|
180
|
-
"@ledgerhq/coin-hedera": "^1.12.0-nightly.
|
|
181
|
-
"@ledgerhq/coin-icon": "^0.13.0-nightly.
|
|
182
|
-
"@ledgerhq/coin-internet_computer": "^1.9.0-nightly.
|
|
183
|
-
"@ledgerhq/coin-kaspa": "^1.3.0-nightly.
|
|
184
|
-
"@ledgerhq/coin-mina": "^1.3.0-nightly.
|
|
185
|
-
"@ledgerhq/coin-multiversx": "^0.6.0-nightly.
|
|
186
|
-
"@ledgerhq/coin-near": "^0.14.0-nightly.
|
|
187
|
-
"@ledgerhq/coin-polkadot": "^6.11.0-nightly.
|
|
188
|
-
"@ledgerhq/coin-solana": "^0.35.0-nightly.
|
|
189
|
-
"@ledgerhq/coin-stacks": "^0.10.0-nightly.
|
|
190
|
-
"@ledgerhq/coin-stellar": "^6.5.0-nightly.
|
|
191
|
-
"@ledgerhq/coin-sui": "^0.16.0-nightly.
|
|
192
|
-
"@ledgerhq/coin-tezos": "^6.7.0-nightly.
|
|
193
|
-
"@ledgerhq/coin-ton": "^0.15.0-nightly.
|
|
194
|
-
"@ledgerhq/coin-tron": "^5.5.0-nightly.
|
|
195
|
-
"@ledgerhq/coin-vechain": "^2.11.0-nightly.
|
|
196
|
-
"@ledgerhq/coin-xrp": "^7.6.0-nightly.
|
|
197
|
-
"@ledgerhq/crypto-icons-ui": "^1.21.0-nightly.
|
|
198
|
-
"@ledgerhq/cryptoassets": "^13.31.0-nightly.
|
|
199
|
-
"@ledgerhq/device-core": "^0.6.6-nightly.
|
|
169
|
+
"@ledgerhq/coin-algorand": "^0.11.0-nightly.1",
|
|
170
|
+
"@ledgerhq/coin-aptos": "^3.4.0-nightly.1",
|
|
171
|
+
"@ledgerhq/coin-bitcoin": "^0.23.0-nightly.1",
|
|
172
|
+
"@ledgerhq/coin-canton": "^0.8.0-nightly.1",
|
|
173
|
+
"@ledgerhq/coin-cardano": "^0.13.0-nightly.1",
|
|
174
|
+
"@ledgerhq/coin-casper": "^2.2.0-nightly.1",
|
|
175
|
+
"@ledgerhq/coin-celo": "^1.6.0-nightly.1",
|
|
176
|
+
"@ledgerhq/coin-cosmos": "^0.18.0-nightly.1",
|
|
177
|
+
"@ledgerhq/coin-evm": "^2.33.0-nightly.1",
|
|
178
|
+
"@ledgerhq/coin-filecoin": "^1.13.0-nightly.1",
|
|
179
|
+
"@ledgerhq/coin-framework": "^6.7.0-nightly.1",
|
|
180
|
+
"@ledgerhq/coin-hedera": "^1.12.0-nightly.1",
|
|
181
|
+
"@ledgerhq/coin-icon": "^0.13.0-nightly.1",
|
|
182
|
+
"@ledgerhq/coin-internet_computer": "^1.9.0-nightly.1",
|
|
183
|
+
"@ledgerhq/coin-kaspa": "^1.3.0-nightly.1",
|
|
184
|
+
"@ledgerhq/coin-mina": "^1.3.0-nightly.1",
|
|
185
|
+
"@ledgerhq/coin-multiversx": "^0.6.0-nightly.1",
|
|
186
|
+
"@ledgerhq/coin-near": "^0.14.0-nightly.1",
|
|
187
|
+
"@ledgerhq/coin-polkadot": "^6.11.0-nightly.1",
|
|
188
|
+
"@ledgerhq/coin-solana": "^0.35.0-nightly.1",
|
|
189
|
+
"@ledgerhq/coin-stacks": "^0.10.0-nightly.1",
|
|
190
|
+
"@ledgerhq/coin-stellar": "^6.5.0-nightly.1",
|
|
191
|
+
"@ledgerhq/coin-sui": "^0.16.0-nightly.2",
|
|
192
|
+
"@ledgerhq/coin-tezos": "^6.7.0-nightly.1",
|
|
193
|
+
"@ledgerhq/coin-ton": "^0.15.0-nightly.1",
|
|
194
|
+
"@ledgerhq/coin-tron": "^5.5.0-nightly.1",
|
|
195
|
+
"@ledgerhq/coin-vechain": "^2.11.0-nightly.1",
|
|
196
|
+
"@ledgerhq/coin-xrp": "^7.6.0-nightly.1",
|
|
197
|
+
"@ledgerhq/crypto-icons-ui": "^1.21.0-nightly.1",
|
|
198
|
+
"@ledgerhq/cryptoassets": "^13.31.0-nightly.1",
|
|
199
|
+
"@ledgerhq/device-core": "^0.6.6-nightly.1",
|
|
200
200
|
"@ledgerhq/devices": "8.6.1",
|
|
201
201
|
"@ledgerhq/errors": "^6.26.0",
|
|
202
202
|
"@ledgerhq/hw-app-algorand": "^6.31.8",
|
|
203
203
|
"@ledgerhq/hw-app-aptos": "^6.34.8",
|
|
204
204
|
"@ledgerhq/hw-app-btc": "^10.11.2",
|
|
205
|
-
"@ledgerhq/hw-app-celo": "^6.35.1-nightly.
|
|
205
|
+
"@ledgerhq/hw-app-celo": "^6.35.1-nightly.1",
|
|
206
206
|
"@ledgerhq/hw-app-cosmos": "^6.32.8",
|
|
207
|
-
"@ledgerhq/hw-app-eth": "^6.46.1-nightly.
|
|
207
|
+
"@ledgerhq/hw-app-eth": "^6.46.1-nightly.1",
|
|
208
208
|
"@ledgerhq/hw-app-exchange": "^0.15.0",
|
|
209
209
|
"@ledgerhq/hw-app-hedera": "^1.2.8",
|
|
210
210
|
"@ledgerhq/hw-app-icon": "^1.3.8",
|
|
@@ -216,27 +216,27 @@
|
|
|
216
216
|
"@ledgerhq/hw-app-sui": "^1.4.0",
|
|
217
217
|
"@ledgerhq/hw-app-tezos": "^6.31.8",
|
|
218
218
|
"@ledgerhq/hw-app-trx": "^6.31.8",
|
|
219
|
-
"@ledgerhq/hw-app-vet": "^0.6.2-nightly.
|
|
219
|
+
"@ledgerhq/hw-app-vet": "^0.6.2-nightly.1",
|
|
220
220
|
"@ledgerhq/hw-app-xrp": "^6.32.6",
|
|
221
221
|
"@ledgerhq/hw-bolos": "^6.32.8",
|
|
222
222
|
"@ledgerhq/hw-transport": "6.31.12",
|
|
223
223
|
"@ledgerhq/hw-transport-mocker": "^6.29.12",
|
|
224
|
-
"@ledgerhq/ledger-cal-service": "^1.
|
|
225
|
-
"@ledgerhq/ledger-trust-service": "^0.3.
|
|
224
|
+
"@ledgerhq/ledger-cal-service": "^1.7.0-nightly.0",
|
|
225
|
+
"@ledgerhq/ledger-trust-service": "^0.3.15-nightly.0",
|
|
226
226
|
"@ledgerhq/live-config": "^3.2.0",
|
|
227
|
-
"@ledgerhq/live-countervalues": "^0.
|
|
228
|
-
"@ledgerhq/live-countervalues-react": "^0.
|
|
229
|
-
"@ledgerhq/live-dmk-shared": "^0.
|
|
230
|
-
"@ledgerhq/live-env": "^2.
|
|
231
|
-
"@ledgerhq/live-hooks": "0.
|
|
232
|
-
"@ledgerhq/live-network": "^2.0.
|
|
227
|
+
"@ledgerhq/live-countervalues": "^0.8.0-nightly.1",
|
|
228
|
+
"@ledgerhq/live-countervalues-react": "^0.7.0-nightly.1",
|
|
229
|
+
"@ledgerhq/live-dmk-shared": "^0.14.0-nightly.0",
|
|
230
|
+
"@ledgerhq/live-env": "^2.19.0-nightly.0",
|
|
231
|
+
"@ledgerhq/live-hooks": "0.2.0-nightly.0",
|
|
232
|
+
"@ledgerhq/live-network": "^2.0.20-nightly.0",
|
|
233
233
|
"@ledgerhq/live-promise": "^0.1.1",
|
|
234
|
-
"@ledgerhq/live-signer-canton": "^0.4.2-nightly.
|
|
235
|
-
"@ledgerhq/live-signer-evm": "^0.8.2-nightly.
|
|
236
|
-
"@ledgerhq/live-signer-solana": "^0.5.8-nightly.
|
|
237
|
-
"@ledgerhq/live-wallet": "^0.14.3-nightly.
|
|
234
|
+
"@ledgerhq/live-signer-canton": "^0.4.2-nightly.1",
|
|
235
|
+
"@ledgerhq/live-signer-evm": "^0.8.2-nightly.1",
|
|
236
|
+
"@ledgerhq/live-signer-solana": "^0.5.8-nightly.1",
|
|
237
|
+
"@ledgerhq/live-wallet": "^0.14.3-nightly.1",
|
|
238
238
|
"@ledgerhq/logs": "^6.13.0",
|
|
239
|
-
"@ledgerhq/speculos-transport": "^0.2.
|
|
239
|
+
"@ledgerhq/speculos-transport": "^0.2.13-nightly.0",
|
|
240
240
|
"@ledgerhq/wallet-api-acre-module": "^0.8.0-nightly.1",
|
|
241
241
|
"@ledgerhq/wallet-api-exchange-module": "^0.17.0-nightly.1"
|
|
242
242
|
},
|
|
@@ -277,7 +277,7 @@
|
|
|
277
277
|
"react-native": "0.77.2",
|
|
278
278
|
"react-native-svg": "15.11.2",
|
|
279
279
|
"react-redux": "^7.2.9",
|
|
280
|
-
"react-test-renderer": "
|
|
280
|
+
"react-test-renderer": "18.3.1",
|
|
281
281
|
"redux-actions": "2.6.5",
|
|
282
282
|
"timemachine": "^0.3.2",
|
|
283
283
|
"ts-jest": "^29.1.1",
|
|
@@ -286,10 +286,10 @@
|
|
|
286
286
|
"undici": "6.19.2",
|
|
287
287
|
"uuid": "^8.3.2",
|
|
288
288
|
"ws": "7",
|
|
289
|
-
"@ledgerhq/device-react": "^0.
|
|
289
|
+
"@ledgerhq/device-react": "^0.3.0-nightly.1",
|
|
290
290
|
"@ledgerhq/types-cryptoassets": "^7.29.0-nightly.0",
|
|
291
291
|
"@ledgerhq/types-devices": "^6.27.0",
|
|
292
|
-
"@ledgerhq/types-live": "^6.87.0-nightly.
|
|
292
|
+
"@ledgerhq/types-live": "^6.87.0-nightly.1"
|
|
293
293
|
},
|
|
294
294
|
"scripts": {
|
|
295
295
|
"build": "zx ./scripts/build-ts.mjs",
|
|
@@ -14,11 +14,9 @@ describe("Testing CryptoAssetStore", () => {
|
|
|
14
14
|
|
|
15
15
|
const store = getCryptoAssetsStore();
|
|
16
16
|
expect(store).toEqual({
|
|
17
|
-
findTokenByAddress: legacy.findTokenByAddress,
|
|
18
17
|
getTokenById: legacy.getTokenById,
|
|
19
18
|
findTokenById: legacy.findTokenById,
|
|
20
19
|
findTokenByAddressInCurrency: legacy.findTokenByAddressInCurrency,
|
|
21
|
-
findTokenByTicker: legacy.findTokenByTicker,
|
|
22
20
|
});
|
|
23
21
|
});
|
|
24
22
|
|
|
@@ -32,11 +30,9 @@ describe("Testing CryptoAssetStore", () => {
|
|
|
32
30
|
|
|
33
31
|
const store = getCryptoAssetsStore();
|
|
34
32
|
expect(store).toEqual({
|
|
35
|
-
findTokenByAddress: legacy.findTokenByAddress,
|
|
36
33
|
getTokenById: legacy.getTokenById,
|
|
37
34
|
findTokenById: legacy.findTokenById,
|
|
38
35
|
findTokenByAddressInCurrency: legacy.findTokenByAddressInCurrency,
|
|
39
|
-
findTokenByTicker: legacy.findTokenByTicker,
|
|
40
36
|
});
|
|
41
37
|
});
|
|
42
38
|
|
|
@@ -3,11 +3,9 @@ import * as legacy from "@ledgerhq/cryptoassets/tokens";
|
|
|
3
3
|
import type { CryptoAssetsStore } from "@ledgerhq/types-live";
|
|
4
4
|
|
|
5
5
|
const legacyStore: CryptoAssetsStore = {
|
|
6
|
-
findTokenByAddress: legacy.findTokenByAddress,
|
|
7
6
|
getTokenById: legacy.getTokenById,
|
|
8
7
|
findTokenById: legacy.findTokenById,
|
|
9
8
|
findTokenByAddressInCurrency: legacy.findTokenByAddressInCurrency,
|
|
10
|
-
findTokenByTicker: legacy.findTokenByTicker,
|
|
11
9
|
};
|
|
12
10
|
|
|
13
11
|
let cryptoAssetsStore: CryptoAssetsStore | undefined = undefined;
|
package/src/currencies/index.ts
CHANGED
|
@@ -7,9 +7,7 @@ import type { CryptoAssetsStore } from "@ledgerhq/types-live";
|
|
|
7
7
|
import { findCurrencyByTicker } from "@ledgerhq/live-countervalues/findCurrencyByTicker";
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
10
|
-
setCryptoAssetsStoreForCoinFramework({
|
|
11
|
-
findTokenByTicker: (_: string) => undefined,
|
|
12
|
-
} as CryptoAssetsStore);
|
|
10
|
+
setCryptoAssetsStoreForCoinFramework({} as CryptoAssetsStore);
|
|
13
11
|
|
|
14
12
|
test("sortCurrenciesByIds snapshot", () => {
|
|
15
13
|
const list = [...listCryptoCurrencies(), ...listTokens()];
|
package/src/e2e/enum/Account.ts
CHANGED
|
@@ -526,6 +526,19 @@ export class Account {
|
|
|
526
526
|
1,
|
|
527
527
|
);
|
|
528
528
|
|
|
529
|
+
static readonly SUI_1 = new Account(
|
|
530
|
+
Currency.SUI,
|
|
531
|
+
"Sui 1",
|
|
532
|
+
"0xc6169bcce8718609e43d179b087e6c1e2ac28e5325660af34d22fb5ce284031e",
|
|
533
|
+
0,
|
|
534
|
+
);
|
|
535
|
+
static readonly SUI_2 = new Account(
|
|
536
|
+
Currency.SUI,
|
|
537
|
+
"Sui 2",
|
|
538
|
+
"0x6644c1ce77c5e5ef8d8bd3ae2a4e18239e5d418a5e0800ed5037818399e3a7f6",
|
|
539
|
+
1,
|
|
540
|
+
);
|
|
541
|
+
|
|
529
542
|
static readonly EMPTY = new Account(Currency.BTC, "Empty", "", 0);
|
|
530
543
|
}
|
|
531
544
|
|
|
@@ -640,6 +653,24 @@ export class TokenAccount extends Account {
|
|
|
640
653
|
TokenType.TRC20,
|
|
641
654
|
Account.TRX_1,
|
|
642
655
|
);
|
|
656
|
+
|
|
657
|
+
static readonly SUI_USDC_1 = new TokenAccount(
|
|
658
|
+
Currency.SUI_USDC,
|
|
659
|
+
"SUI USDC 1",
|
|
660
|
+
Account.SUI_1.address,
|
|
661
|
+
0,
|
|
662
|
+
TokenType.ERC20,
|
|
663
|
+
Account.SUI_1,
|
|
664
|
+
);
|
|
665
|
+
|
|
666
|
+
static readonly SUI_USDC_2 = new TokenAccount(
|
|
667
|
+
Currency.SUI_USDC,
|
|
668
|
+
"SUI USDC 2",
|
|
669
|
+
Account.SUI_2.address,
|
|
670
|
+
1,
|
|
671
|
+
TokenType.ERC20,
|
|
672
|
+
Account.SUI_2,
|
|
673
|
+
);
|
|
643
674
|
}
|
|
644
675
|
|
|
645
676
|
export type AccountType = Account | TokenAccount;
|
package/src/e2e/enum/AppInfos.ts
CHANGED
package/src/e2e/enum/Currency.ts
CHANGED
|
@@ -207,4 +207,15 @@ export class Currency {
|
|
|
207
207
|
static readonly OP = new Currency("OP Mainnet", "OP", "optimism", AppInfos.ETHEREUM, [
|
|
208
208
|
Network.OPTIMISM,
|
|
209
209
|
]);
|
|
210
|
+
|
|
211
|
+
static readonly SUI = new Currency("Sui", "SUI", "sui", AppInfos.SUI, [Network.SUI]);
|
|
212
|
+
|
|
213
|
+
static readonly SUI_USDC = new Currency(
|
|
214
|
+
"USDC",
|
|
215
|
+
"USDC",
|
|
216
|
+
"sui/coin/usdc_0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::usdc",
|
|
217
|
+
AppInfos.SUI,
|
|
218
|
+
[Network.SUI],
|
|
219
|
+
"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
|
|
220
|
+
);
|
|
210
221
|
}
|
package/src/e2e/enum/Network.ts
CHANGED
package/src/e2e/speculos.ts
CHANGED
|
@@ -42,6 +42,7 @@ import { Swap } from "./models/Swap";
|
|
|
42
42
|
import { delegateOsmosis } from "./families/osmosis";
|
|
43
43
|
import { AppInfos } from "./enum/AppInfos";
|
|
44
44
|
import { DEVICE_LABELS_CONFIG } from "./data/deviceLabelsData";
|
|
45
|
+
import { sendSui } from "./families/sui";
|
|
45
46
|
|
|
46
47
|
const isSpeculosRemote = process.env.REMOTE_SPECULOS === "true";
|
|
47
48
|
|
|
@@ -344,6 +345,14 @@ export const specs: Specs = {
|
|
|
344
345
|
},
|
|
345
346
|
dependency: "",
|
|
346
347
|
},
|
|
348
|
+
Sui: {
|
|
349
|
+
currency: getCryptoCurrencyById("sui"),
|
|
350
|
+
appQuery: {
|
|
351
|
+
model: getSpeculosModel(),
|
|
352
|
+
appName: "Sui",
|
|
353
|
+
},
|
|
354
|
+
dependency: "",
|
|
355
|
+
},
|
|
347
356
|
};
|
|
348
357
|
|
|
349
358
|
export async function startSpeculos(
|
|
@@ -632,6 +641,10 @@ export async function goToSettings() {
|
|
|
632
641
|
await pressBoth();
|
|
633
642
|
}
|
|
634
643
|
|
|
644
|
+
export async function providePublicKey() {
|
|
645
|
+
await pressRightButton();
|
|
646
|
+
}
|
|
647
|
+
|
|
635
648
|
type DeviceLabelsReturn = {
|
|
636
649
|
delegateConfirmLabel: string;
|
|
637
650
|
delegateVerifyLabel: string;
|
|
@@ -660,6 +673,10 @@ export function getDeviceLabels(appInfo: AppInfos): DeviceLabelsReturn {
|
|
|
660
673
|
}
|
|
661
674
|
|
|
662
675
|
export async function expectValidAddressDevice(account: Account, addressDisplayed: string) {
|
|
676
|
+
if (account.currency === Currency.SUI_USDC) {
|
|
677
|
+
providePublicKey();
|
|
678
|
+
}
|
|
679
|
+
|
|
663
680
|
const { receiveVerifyLabel, receiveConfirmLabel } = getDeviceLabels(account.currency.speculosApp);
|
|
664
681
|
|
|
665
682
|
await waitFor(receiveVerifyLabel);
|
|
@@ -721,6 +738,12 @@ export async function signSendTransaction(tx: Transaction) {
|
|
|
721
738
|
case Currency.HBAR:
|
|
722
739
|
await sendHedera();
|
|
723
740
|
break;
|
|
741
|
+
case Currency.SUI:
|
|
742
|
+
await sendSui();
|
|
743
|
+
break;
|
|
744
|
+
case Currency.SUI_USDC:
|
|
745
|
+
await sendSui();
|
|
746
|
+
break;
|
|
724
747
|
default:
|
|
725
748
|
throw new Error(`Unsupported currency: ${currencyName.ticker}`);
|
|
726
749
|
}
|
|
@@ -140,9 +140,9 @@ const DEFAULT_SWAP_PROVIDERS: Record<string, ProviderConfig & Partial<Additional
|
|
|
140
140
|
type: "DEX",
|
|
141
141
|
needsKYC: false,
|
|
142
142
|
needsBearerToken: false,
|
|
143
|
-
termsOfUseUrl: "https://1inch.
|
|
144
|
-
supportUrl: "https://help.1inch.
|
|
145
|
-
mainUrl: "https://1inch.
|
|
143
|
+
termsOfUseUrl: "https://1inch.com/assets/Widget_1inch.com_Terms_of_Use.pdf",
|
|
144
|
+
supportUrl: "https://help.1inch.com/en/",
|
|
145
|
+
mainUrl: "https://1inch.com/",
|
|
146
146
|
},
|
|
147
147
|
paraswap: {
|
|
148
148
|
type: "DEX",
|
|
@@ -232,7 +232,7 @@ export const dexProvidersContractAddress: { [key: string]: string } = {
|
|
|
232
232
|
|
|
233
233
|
export const termsOfUse: { [key: string]: string } = {
|
|
234
234
|
paraswap: "https://paraswap.io/tos",
|
|
235
|
-
"1inch": "https://1inch.
|
|
235
|
+
"1inch": "https://1inch.com/assets/Widget_1inch.com_Terms_of_Use.pdf",
|
|
236
236
|
Uniswap: "https://uniswap.org/terms-of-service",
|
|
237
237
|
};
|
|
238
238
|
|
|
@@ -58,8 +58,7 @@ export const fetchRatesMock = (
|
|
|
58
58
|
{
|
|
59
59
|
provider: "oneinch",
|
|
60
60
|
providerType: "DEX",
|
|
61
|
-
providerURL:
|
|
62
|
-
"https://app.1inch.io/#/1/unified/swap/usdt/eth?ledgerLive=true&sourceTokenAmount=100",
|
|
61
|
+
providerURL: "https://1inch.com/swap/#/1/unified/swap/usdt/eth&sourceTokenAmount=100",
|
|
63
62
|
from: "ethereum/erc20/usd_tether__erc20_",
|
|
64
63
|
to: "ethereum",
|
|
65
64
|
amountFrom: "100",
|
|
@@ -103,7 +103,7 @@ export const mockGetExchangeRates = async (
|
|
|
103
103
|
providerType: "DEX",
|
|
104
104
|
expirationDate: new Date(),
|
|
105
105
|
tradeMethod: "float",
|
|
106
|
-
providerURL: `https://
|
|
106
|
+
providerURL: `https://1inch.com/swap/#/1/unified/swap/eth/usdt&sourceTokenAmount=${transaction.amount}`,
|
|
107
107
|
},
|
|
108
108
|
];
|
|
109
109
|
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import { renderHook, waitFor } from "@testing-library/react";
|
|
5
|
+
import { useManifestWithSessionId } from "./useManifestWithSessionId";
|
|
6
|
+
import { LiveAppManifest } from "../platform/types";
|
|
7
|
+
|
|
8
|
+
const mockFetch = jest.fn();
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
10
|
+
global.fetch = mockFetch as any;
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
13
|
+
const baseManifest = {
|
|
14
|
+
id: "test-app",
|
|
15
|
+
name: "Test App",
|
|
16
|
+
url: "https://example.com",
|
|
17
|
+
} as LiveAppManifest;
|
|
18
|
+
|
|
19
|
+
describe("useManifestWithSessionId", () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
jest.clearAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("returns null manifest during loading", async () => {
|
|
25
|
+
mockFetch.mockResolvedValueOnce({
|
|
26
|
+
ok: true,
|
|
27
|
+
json: async () => ({ providerSessionId: "abc123" }),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const { result } = renderHook(() =>
|
|
31
|
+
useManifestWithSessionId({ manifest: baseManifest, shareAnalytics: true }),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(result.current.loading).toBe(true);
|
|
35
|
+
expect(result.current.manifest).toBeNull();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("returns manifest with externalID after success", async () => {
|
|
39
|
+
mockFetch.mockResolvedValueOnce({
|
|
40
|
+
ok: true,
|
|
41
|
+
json: async () => ({ providerSessionId: "abc123" }),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const { result } = renderHook(() =>
|
|
45
|
+
useManifestWithSessionId({ manifest: baseManifest, shareAnalytics: true }),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
await waitFor(() =>
|
|
49
|
+
expect(result.current.manifest).toEqual({
|
|
50
|
+
...baseManifest,
|
|
51
|
+
url: "https://example.com/?externalID=abc123",
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect(result.current.loading).toBe(false);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("falls back to original manifest if fetch rejects", async () => {
|
|
59
|
+
mockFetch.mockRejectedValueOnce(new Error("network error"));
|
|
60
|
+
|
|
61
|
+
const { result } = renderHook(() =>
|
|
62
|
+
useManifestWithSessionId({ manifest: baseManifest, shareAnalytics: true }),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
await waitFor(() => {
|
|
66
|
+
expect(result.current.manifest).toEqual(baseManifest);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(result.current.loading).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("falls back to original manifest if response is not ok", async () => {
|
|
73
|
+
mockFetch.mockResolvedValueOnce({ ok: false });
|
|
74
|
+
|
|
75
|
+
const { result } = renderHook(() =>
|
|
76
|
+
useManifestWithSessionId({ manifest: baseManifest, shareAnalytics: true }),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
await waitFor(() => {
|
|
80
|
+
expect(result.current.manifest).toEqual(baseManifest);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(result.current.loading).toBe(false);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("returns null if manifest is not provided", async () => {
|
|
87
|
+
const { result } = renderHook(() =>
|
|
88
|
+
useManifestWithSessionId({ manifest: null, shareAnalytics: true }),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
expect(mockFetch).not.toHaveBeenCalled();
|
|
92
|
+
expect(result.current.manifest).toBeNull();
|
|
93
|
+
expect(result.current.loading).toBe(false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("skips fetch if shareAnalytics is false and just returns manifest", () => {
|
|
97
|
+
const { result } = renderHook(() =>
|
|
98
|
+
useManifestWithSessionId({ manifest: baseManifest, shareAnalytics: false }),
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect(mockFetch).not.toHaveBeenCalled();
|
|
102
|
+
expect(result.current.manifest).toEqual(baseManifest);
|
|
103
|
+
expect(result.current.loading).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { appendQueryParamsToManifestURL } from "../wallet-api/utils/appendQueryParamsToManifestURL";
|
|
3
|
+
import { LiveAppManifest } from "../platform/types";
|
|
4
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
5
|
+
|
|
6
|
+
type Options = {
|
|
7
|
+
manifest: LiveAppManifest | null | undefined;
|
|
8
|
+
shareAnalytics: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type HookResult = {
|
|
12
|
+
manifest?: LiveAppManifest | null;
|
|
13
|
+
loading: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function useManifestWithSessionId({ manifest, shareAnalytics }: Options): HookResult {
|
|
17
|
+
const [id, setId] = React.useState<string | null>(null);
|
|
18
|
+
const [loading, setLoading] = React.useState<boolean>(false);
|
|
19
|
+
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
let cancelled = false;
|
|
22
|
+
|
|
23
|
+
async function fetchId() {
|
|
24
|
+
if (!shareAnalytics || !manifest) {
|
|
25
|
+
setId(null);
|
|
26
|
+
setLoading(false);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
setLoading(true);
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const response = await fetch(getEnv("PROVIDER_SESSION_ID_ENDPOINT"), {
|
|
34
|
+
method: "GET",
|
|
35
|
+
headers: {
|
|
36
|
+
Accept: "application/json",
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (!response.ok) throw new Error("Failed to fetch session ID");
|
|
42
|
+
|
|
43
|
+
const { providerSessionId } = await response.json();
|
|
44
|
+
|
|
45
|
+
if (!cancelled) {
|
|
46
|
+
setId(providerSessionId);
|
|
47
|
+
setLoading(false);
|
|
48
|
+
}
|
|
49
|
+
} catch {
|
|
50
|
+
if (!cancelled) {
|
|
51
|
+
setId(null);
|
|
52
|
+
setLoading(false);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
fetchId();
|
|
58
|
+
|
|
59
|
+
return () => {
|
|
60
|
+
cancelled = true; // avoid setting state after unmount
|
|
61
|
+
};
|
|
62
|
+
}, [shareAnalytics]);
|
|
63
|
+
|
|
64
|
+
const customizedManifest = React.useMemo(() => {
|
|
65
|
+
if (!manifest) return null;
|
|
66
|
+
|
|
67
|
+
if (loading) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (id) {
|
|
72
|
+
const url = appendQueryParamsToManifestURL(manifest, {
|
|
73
|
+
externalID: id,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return url ? { ...manifest, url: url.toString() } : manifest;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return manifest;
|
|
80
|
+
}, [manifest, id, loading]);
|
|
81
|
+
|
|
82
|
+
return { manifest: customizedManifest, loading };
|
|
83
|
+
}
|