Skip to content

Commit

Permalink
chore: update to RXJS 7
Browse files Browse the repository at this point in the history
  • Loading branch information
valpinkman committed Aug 29, 2023
1 parent a46453e commit 228b4c9
Show file tree
Hide file tree
Showing 60 changed files with 738 additions and 652 deletions.
19 changes: 10 additions & 9 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ function readPackage(pkg, context) {
Because we're still using rxjs v6 everywhere
We only added rxjs v7 as an alias on rxjs7
*/
addDependencies("@ledgerhq/wallet-api-server", {
rxjs: pkg.peerDependencies?.rxjs ?? "*",
}),
removeDependencies("@ledgerhq/wallet-api-server", ["rxjs"], {
kind: "peerDependencies",
}),
// addDependencies("@ledgerhq/wallet-api-server", {
// rxjs: pkg.peerDependencies?.rxjs ?? "*",
// }),
// removeDependencies("@ledgerhq/wallet-api-server", ["rxjs"], {
// kind: "peerDependencies",
// }),

/*
The following packages are broken and do not declare their dependencies properly.
So we are going to patch these until the maintainers fix their own stuff…
Expand Down Expand Up @@ -189,9 +190,9 @@ function readPackage(pkg, context) {
addPeerDependencies("any-observable", {
rxjs: "*",
}),
addPeerDependencies("rxjs-compat", {
rxjs: "*",
}),
// addPeerDependencies("rxjs-compat", {
// rxjs: "*",
// }),
addPeerDependencies("@cspotcode/source-map-support", {
"source-map-support": "*",
}),
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"qrloop": "^1.2.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rxjs": "^6.6.7",
"rxjs": "^7.8.1",
"winston": "^3.5.1",
"ws": "^8.6.0"
},
Expand Down
8 changes: 4 additions & 4 deletions apps/cli/src/commands/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getMainAccount,
} from "@ledgerhq/live-common/account/index";
import { getAbandonSeedAddress, findTokenById } from "@ledgerhq/cryptoassets";
import { from } from "rxjs";
import { from, lastValueFrom } from "rxjs";
import { BigNumber } from "bignumber.js";
import commandLineArgs from "command-line-args";
import { delay } from "@ledgerhq/live-common/promise";
Expand Down Expand Up @@ -105,9 +105,9 @@ const exec = async (opts: SwapJobOpts) => {
console.log("• Open the destination currency app");
await delay(8000);
let toParentAccount: Account | null = null;
let toAccount: Account | SubAccount | undefined = await scan(secondAccountOpts)
.pipe(take(1))
.toPromise();
let toAccount: Account | SubAccount | undefined = await lastValueFrom(
scan(secondAccountOpts).pipe(take(1)),
);
invariant(toAccount, `✖ No account found`);
const { tokenId: tokenId2 } = secondAccountOpts;

Expand Down
8 changes: 1 addition & 7 deletions apps/ledger-live-desktop/.unimportedrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@
"ignorePatterns": ["**/node_modules/**"],
"ignoreUnresolved": ["unzip-crx-3", "../../../../release-notes.json"],
"ignoreUnimported": ["**/*.test.*", "**/*.spec.*", "**/*.d.ts", "**/types.js", "**/types.*"],
"ignoreUnused": [
"@types/semver",
"@types/qrcode",
"@types/react-key-handler",
"rxjs7",
"prop-types"
],
"ignoreUnused": ["@types/semver", "@types/qrcode", "@types/react-key-handler", "prop-types"],
"aliases": {
"~/*": ["./src/*"]
}
Expand Down
3 changes: 1 addition & 2 deletions apps/ledger-live-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@
"redux-thunk": "^2.4.0",
"reselect": "^4.1.4",
"rimraf": "^4.4.1",
"rxjs": "^6.6.7",
"rxjs7": "npm:[email protected]",
"rxjs": "^7.8.1",
"secp256k1": "^4.0.2",
"semver": "^7.1.3",
"styled-components": "^5.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DeviceInfo, DeviceModelInfo, idsToLanguage } from "@ledgerhq/types-live
import { isEqual } from "lodash";
import { useCallback, useEffect, useState } from "react";
import { useSelector } from "react-redux";
import { from } from "rxjs";
import { from, lastValueFrom } from "rxjs";
import { Languages } from "~/config/languages";
import { setDrawer } from "~/renderer/drawers/Provider";
import { languageSelector } from "~/renderer/reducers/settings";
Expand All @@ -21,12 +21,12 @@ export const useChangeLanguagePrompt = ({ device }: useChangeLanguagePromptParam

const refreshDeviceInfo = useCallback(() => {
if (!device) return;
withDevice(device.deviceId)(transport => from(getDeviceInfo(transport)))
.toPromise()
.then((deviceInfo: DeviceInfo) => {
lastValueFrom(withDevice(device.deviceId)(transport => from(getDeviceInfo(transport)))).then(
(deviceInfo: DeviceInfo) => {
if (!isEqual(deviceInfo, deviceModelInfo?.deviceInfo))
setDeviceModelInfo({ deviceInfo, modelId: device.modelId, apps: [] });
});
},
);
}, [device, deviceModelInfo?.deviceInfo]);

const currentLanguage = useSelector(languageSelector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import { DeviceInfo } from "@ledgerhq/types-live";
import connectManager from "@ledgerhq/live-common/hw/connectManager";
import { mockedEventEmitter } from "~/renderer/components/debug/DebugMock";
import { from } from "rxjs";
import { from, lastValueFrom } from "rxjs";
import getDeviceInfo from "@ledgerhq/live-common/hw/getDeviceInfo";
import { getEnv } from "@ledgerhq/live-env";
import ExitChecksDrawer, {
Expand Down Expand Up @@ -102,11 +102,11 @@ const SyncOnboardingScreen: React.FC<SyncOnboardingScreenProps> = ({

const refreshIsBootloaderMode = useCallback(() => {
if (!device) return;
withDevice(device.deviceId)(transport => from(getDeviceInfo(transport)))
.toPromise()
.then((deviceInfo: DeviceInfo) => {
lastValueFrom(withDevice(device.deviceId)(transport => from(getDeviceInfo(transport)))).then(
(deviceInfo: DeviceInfo) => {
setIsBootloader(deviceInfo?.isBootloader);
});
},
);
}, [device]);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { RowContainer, RowInnerContainer } from "./shared";
import styled from "styled-components";
import Plus from "~/renderer/icons/Plus";
import { darken } from "~/renderer/styles/helpers";
import { Observable } from "rxjs7";
import { Observable } from "rxjs";
import { WalletAPIAccount } from "@ledgerhq/live-common/wallet-api/types";
import { useTranslation } from "react-i18next";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { WalletAPIAccount } from "@ledgerhq/live-common/wallet-api/types";
import Text from "~/renderer/components/Text";
import { CurrencyList } from "./CurrencyList";
import SelectAccountDrawer from "./SelectAccountDrawer";
import { Observable } from "rxjs7";
import { Observable } from "rxjs";
import { getEnv } from "@ledgerhq/live-env";

const options = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Account, AccountLike } from "@ledgerhq/types-live";
import { CryptoCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";
import Text from "~/renderer/components/Text";
import { AccountList } from "./AccountList";
import { Observable } from "rxjs7";
import { Observable } from "rxjs";
import { WalletAPIAccount } from "@ledgerhq/live-common/wallet-api/types";
const AccountSelectorDrawerContainer = styled.div`
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setSecp256k1Instance } from "@ledgerhq/live-common/families/bitcoin/wallet-btc/crypto/secp256k1";
import { Subject } from "rxjs";
import { Subject, lastValueFrom } from "rxjs";
import { first } from "rxjs/operators";
import { initWorker } from "../../webworkers";

Expand All @@ -20,7 +20,7 @@ function runJob(message: { publicKey: string; tweak: string }): Promise<{ respon
const id = idCounter++;
const worker = workers[id % publicKeyTweakAddWorkerCount]; // round robin with the counter
return worker.then(w => {
const promise = publicKeyTweakAddWorkerResponses.pipe(first(e => e.id === id)).toPromise();
const promise = lastValueFrom(publicKeyTweakAddWorkerResponses.pipe(first(e => e.id === id)));
w.postMessage({ ...message, id });
return promise;
});
Expand Down
26 changes: 13 additions & 13 deletions apps/ledger-live-desktop/src/renderer/screens/manager/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Result, createAction } from "@ledgerhq/live-common/hw/actions/manager";
import Dashboard from "~/renderer/screens/manager/Dashboard";
import { SyncSkipUnderPriority } from "@ledgerhq/live-common/bridge/react/index";
import DeviceAction from "~/renderer/components/DeviceAction";
import { from } from "rxjs";
import { from, lastValueFrom } from "rxjs";
import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import getDeviceInfo from "@ledgerhq/live-common/hw/getDeviceInfo";
import connectManager from "@ledgerhq/live-common/hw/connectManager";
Expand Down Expand Up @@ -32,19 +32,19 @@ const Manager = () => {
const dispatch = useDispatch();
const refreshDeviceInfo = useCallback(() => {
if (result?.device) {
withDevice(result.device.deviceId)(transport => from(getDeviceInfo(transport)))
.toPromise()
.then(deviceInfo => {
setResult({
...result,
deviceInfo,
});
dispatch(
setLastSeenDevice({
deviceInfo,
}),
);
lastValueFrom(
withDevice(result.device.deviceId)(transport => from(getDeviceInfo(transport))),
).then(deviceInfo => {
setResult({
...result,
deviceInfo,
});
dispatch(
setLastSeenDevice({
deviceInfo,
}),
);
});
}
}, [result, dispatch]);
const onResult = useCallback(result => setResult(result), []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { useCallback, useEffect, useMemo } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch, useSelector } from "react-redux";
import { Languages, Language } from "~/config/languages";
import { from } from "rxjs";
import { from, lastValueFrom } from "rxjs";
import { setLanguage, setLastSeenDevice } from "~/renderer/actions/settings";
import Track from "~/renderer/analytics/Track";
import { track } from "~/renderer/analytics/segment";
Expand Down Expand Up @@ -43,12 +43,12 @@ const LanguageSelect: React.FC<Props> = ({ disableLanguagePrompt }) => {
const currentDevice = useSelector(getCurrentDevice);
const refreshDeviceInfo = useCallback(() => {
if (currentDevice) {
withDevice(currentDevice.deviceId)(transport => from(getDeviceInfo(transport)))
.toPromise()
.then((deviceInfo: DeviceInfo) => {
if (!isEqual(deviceInfo, lastSeenDevice?.deviceInfo))
dispatch(setLastSeenDevice({ deviceInfo }));
});
lastValueFrom(
withDevice(currentDevice.deviceId)(transport => from(getDeviceInfo(transport))),
).then((deviceInfo: DeviceInfo) => {
if (!isEqual(deviceInfo, lastSeenDevice?.deviceInfo))
dispatch(setLastSeenDevice({ deviceInfo }));
});
}
}, [currentDevice, lastSeenDevice?.deviceInfo, dispatch]);

Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/ios/ledgerlivemobile/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.16.1</string>
<string>3.29.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
4 changes: 1 addition & 3 deletions apps/ledger-live-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@
"redux-thunk": "2.4.2",
"reselect": "4.0.0",
"rn-fetch-blob": "^0.12.0",
"rxjs": "^6.6.6",
"rxjs-compat": "^6.6.6",
"rxjs7": "npm:[email protected]",
"rxjs": "^7.8.1",
"semver": "^7.3.7",
"storyly-react-native": "2.0.1",
"styled-components": "^5.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { WalletAPIAccount } from "@ledgerhq/live-common/wallet-api/types";
import type { CryptoOrTokenCurrency, TokenCurrency } from "@ledgerhq/types-cryptoassets";

import type { Account, AccountLike } from "@ledgerhq/types-live";
import { Observable } from "rxjs7";
import { Observable } from "rxjs";
import { NavigatorScreenParams } from "@react-navigation/native";
import { NavigatorName, ScreenName } from "../../../const";
import { AddAccountsNavigatorParamList } from "./AddAccountsNavigator";
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/src/navigation/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ function scrollSectionListToTop(compRef: SectionList | Animated<SectionList>): v
}

export function scrollToTop(): void {
scrollSubject.next();
scrollSubject.next(undefined);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import RNRestart from "react-native-restart";
import { useDispatch, useSelector } from "react-redux";
import { useAvailableLanguagesForDevice } from "@ledgerhq/live-common/manager/hooks";
import { Device } from "@ledgerhq/live-common/hw/actions/types";
import { from } from "rxjs";
import { from, lastValueFrom } from "rxjs";
import { DeviceModelInfo, idsToLanguage, Language } from "@ledgerhq/types-live";
import { withDevice } from "@ledgerhq/live-common/hw/deviceAccess";
import getDeviceInfo from "@ledgerhq/live-common/hw/getDeviceInfo";
Expand Down Expand Up @@ -53,11 +53,11 @@ function OnboardingStepLanguage({ navigation }: NavigationProps) {
const onActionFinished = useCallback(() => {
setPreventPromptBackdropClick(false);
if (lastConnectedDevice && lastSeenDevice) {
withDevice(lastConnectedDevice?.deviceId)(transport => from(getDeviceInfo(transport)))
.toPromise()
.then(deviceInfo => {
dispatch(setLastSeenDevice(deviceInfo));
});
lastValueFrom(
withDevice(lastConnectedDevice?.deviceId)(transport => from(getDeviceInfo(transport))),
).then(deviceInfo => {
dispatch(setLastSeenDevice(deviceInfo));
});
}
}, [lastConnectedDevice, lastSeenDevice, dispatch]);

Expand Down
2 changes: 1 addition & 1 deletion libs/coin-algorand/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"invariant": "^2.2.2",
"lodash": "^4.17.21",
"prando": "^6.0.1",
"rxjs": "^6.6.7"
"rxjs": "^7.8.1"
},
"devDependencies": {
"@types/invariant": "^2.2.2",
Expand Down
2 changes: 1 addition & 1 deletion libs/coin-evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"invariant": "^2.2.2",
"lodash": "^4.17.21",
"react-native-get-random-values": "^1.8.0",
"rxjs": "^6.6.7"
"rxjs": "^7.8.1"
},
"devDependencies": {
"@types/invariant": "^2.2.2",
Expand Down
2 changes: 1 addition & 1 deletion libs/coin-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"lru-cache": "^7.14.1",
"numeral": "^2.0.6",
"prando": "^6.0.1",
"rxjs": "^6.6.7"
"rxjs": "^7.8.1"
},
"devDependencies": {
"@types/invariant": "^2.2.2",
Expand Down
2 changes: 1 addition & 1 deletion libs/coin-polkadot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"expect": "^27.4.6",
"invariant": "^2.2.2",
"lodash": "^4.17.21",
"rxjs": "^6.6.7"
"rxjs": "^7.8.1"
},
"devDependencies": {
"@types/invariant": "^2.2.2",
Expand Down
2 changes: 1 addition & 1 deletion libs/env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"types": "lib/index.d.ts",
"license": "Apache-2.0",
"dependencies": {
"rxjs": "^6.6.7",
"rxjs": "^7.8.1",
"utility-types": "^3.10.0"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion libs/ledger-live-common/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ yarn upgrade-interactive -i --latest
| ripple-lib | XRP coin integration | monthly |
| rlp | Ethereum coin integration | monthly |
| rxjs | generic helper | BLOCKED by issue revealed when trying to upgrade. **ticket missing** |
| rxjs-compat | generic helper | BLOCKED by issue revealed when trying to upgrade. **ticket missing** |
| secp256k1 | Bitcoin coin integration | monthly |
| semver | generic helper | monthly |
| sha.js | generic helper for crypto | monthly |
Expand Down
8 changes: 3 additions & 5 deletions libs/ledger-live-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@
"@cosmjs/proto-signing": "^0.26.5",
"@cosmjs/stargate": "^0.26.5",
"@crypto-org-chain/chain-jslib": "1.1.2",
"@elrondnetwork/erdjs": "11.0.0",
"@elrondnetwork/erdjs-network-providers": "^1.1.2",
"@dfinity/agent": "^0.15.6",
"@dfinity/candid": "^0.15.6",
"@dfinity/principal": "^0.15.6",
"@elrondnetwork/erdjs": "11.0.0",
"@elrondnetwork/erdjs-network-providers": "^1.1.2",
"@ethereumjs/common": "^2.6.2",
"@ethereumjs/tx": "^3.5.0",
"@ethersproject/bignumber": "^5.7.0",
Expand Down Expand Up @@ -249,9 +249,7 @@
"ripple-binary-codec": "^1.3.0",
"ripple-bs58check": "^2.0.2",
"rlp": "^3.0.0",
"rxjs": "6",
"rxjs-compat": "^6.6.7",
"rxjs7": "npm:[email protected]",
"rxjs": "^7.8.1",
"secp256k1": "^4.0.3",
"semver": "^7.3.5",
"sha.js": "^2.4.11",
Expand Down
Loading

0 comments on commit 228b4c9

Please sign in to comment.