Skip to content

Commit a1f5dbb

Browse files
fix: apply comments
1 parent 1ca038b commit a1f5dbb

File tree

8 files changed

+233
-164
lines changed

8 files changed

+233
-164
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
"dev:queue-manager": "node ./scripts/dev-watch/command.mjs --project @rango-dev/queue-manager-demo",
3737
"dev:widget:type-checker": "node ./scripts/dev-ts-check/command.mjs --project @rango-dev/widget-app",
3838
"dev:widget:dev-server": "yarn --cwd ./widget/app/ dev",
39-
"dev:widget": "concurrently \"yarn dev:widget:dev-server\" \"yarn dev:widget:type-checker\"",
39+
"dev:widget": "npm-run-all --parallel dev:widget:dev-server dev:widget:type-checker",
4040
"dev:playground:type-checker": "node ./scripts/dev-ts-check/command.mjs --project @rango-dev/widget-playground",
4141
"dev:playground:dev-server": "yarn --cwd ./widget/playground/ dev",
42-
"dev:playground": "concurrently \"yarn dev:playground:dev-server\" \"yarn dev:playground:type-checker\"",
42+
"dev:playground": "npm-run-all --parallel dev:playground:dev-server dev:playground:type-checker",
4343
"lint": "nx run-many --target=lint",
4444
"format": "nx run-many --target=format",
4545
"publish": "node ./scripts/publish/command.mjs",
@@ -81,7 +81,6 @@
8181
"buffer": "^5.5.0",
8282
"chalk": "^5.2.0",
8383
"command-line-args": "^5.2.1",
84-
"concurrently": "^9.2.0",
8584
"conventional-changelog-angular": "^5.0.13",
8685
"conventional-changelog-cli": "^2.2.2",
8786
"conventional-commits-filter": "^2.0.7",
@@ -104,6 +103,7 @@
104103
"globals": "^15.14.0",
105104
"happy-dom": "^14.12.0",
106105
"lint-staged": "^13.2.2",
106+
"npm-run-all": "^4.1.5",
107107
"nx": "16.2.1",
108108
"os-browserify": "^0.3.0",
109109
"parcel": "^2.11.0",

widget/embedded/src/containers/Inputs/SourceInput/SourceInput.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { PropTypes } from './SourceInput.types';
22

3+
import { i18n } from '@lingui/core';
34
import { Divider, SwapInput } from '@rango-dev/ui';
45
import { useWallets } from '@rango-dev/wallets-react';
56
import BigNumber from 'bignumber.js';
67
import React from 'react';
7-
import { useTranslation } from 'react-i18next';
88
import { useNavigate } from 'react-router-dom';
99

1010
import { SwitchFromAndToButton } from '../../../components/SwitchFromAndTo';
@@ -29,11 +29,11 @@ import { FromContainer, swapInputStyles } from './SourceInput.styles';
2929
export function SourceInput(props: PropTypes) {
3030
const { onClickToken } = props;
3131
const {
32-
selectedWallets: { source: selectedSourceWallet },
3332
connectedWallets,
3433
getBalanceFor,
3534
fetchStatus: fetchingMetaStatus,
3635
} = useAppStore();
36+
const sourceWallet = useAppStore().sourceWallet();
3737
const {
3838
fromToken,
3939
fromBlockchain,
@@ -43,16 +43,14 @@ export function SourceInput(props: PropTypes) {
4343
setInputAmount,
4444
sanitizeInputAmount,
4545
} = useQuoteStore();
46-
const { t } = useTranslation();
4746
const { getWalletInfo } = useWallets();
4847
const navigate = useNavigate();
49-
const relatedWallet = selectedSourceWallet
48+
const relatedWallet = sourceWallet
5049
? {
51-
...selectedSourceWallet,
52-
image: getWalletInfo(selectedSourceWallet.type).img,
50+
...sourceWallet,
51+
image: getWalletInfo(sourceWallet.walletType).img,
5352
}
54-
: null;
55-
53+
: undefined;
5654
const fetchingBalance = fromToken
5755
? isFetchingBalance(connectedWallets, fromToken.blockchain)
5856
: false;
@@ -97,7 +95,7 @@ export function SourceInput(props: PropTypes) {
9795
return (
9896
<FromContainer>
9997
<SwapInputLabel
100-
label={t('From')}
98+
label={i18n.t('From')}
10199
onClickWallet={onClickWallet}
102100
relatedWallet={relatedWallet}
103101
/>
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1+
import type { ConnectedWallet } from '../../store/slices/wallets';
2+
13
export type PropTypes = {
24
label: string;
35
onClickWallet: () => void;
4-
relatedWallet: {
5-
address: string;
6-
type: string;
7-
image: string;
8-
} | null;
6+
relatedWallet?: ConnectedWallet & { image?: string };
97
};

widget/embedded/src/hooks/useUpdateSelectedWalelts.ts/useUpdateSelectedWallets.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ import { useQuoteStore } from '../../store/quote';
1414
*/
1515
export function useUpdateSelectedWallets() {
1616
const { fromToken } = useQuoteStore();
17-
const { checkAndUpdateSelectedWalletsIfNeeded, connectedWallets } =
18-
useAppStore();
17+
const { checkAndUpdateSelectedWalletIfNeeded } = useAppStore();
1918

2019
useEffect(() => {
21-
checkAndUpdateSelectedWalletsIfNeeded(connectedWallets);
22-
}, [fromToken]);
20+
checkAndUpdateSelectedWalletIfNeeded('source');
21+
}, [fromToken?.blockchain, fromToken?.address, fromToken?.symbol]);
2322
}

widget/embedded/src/pages/SourceWalletPage.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ export const ListContainer = styled('div', {
3131
export function SourceWalletPage() {
3232
const { t } = useTranslation();
3333
const { fromBlockchain } = useQuoteStore();
34-
const { selectedWallets, setWalletsAsSelected } = useAppStore();
34+
const { connectedWallets, setSourceWallet } = useAppStore();
35+
const sourceWallet = useAppStore().sourceWallet();
3536
const navigate = useNavigate();
3637
const location = useLocation();
3738
const sourceBlockchain = fromBlockchain?.name;
@@ -50,8 +51,8 @@ export function SourceWalletPage() {
5051

5152
const isSelected = (walletType: string, blockchain: string) => {
5253
return (
53-
selectedWallets.source?.blockchain === blockchain &&
54-
selectedWallets.source?.type === walletType
54+
sourceWallet?.chain === blockchain &&
55+
sourceWallet?.walletType === walletType
5556
);
5657
};
5758

@@ -76,13 +77,14 @@ export function SourceWalletPage() {
7677
//
7778
}}
7879
selectWallet={(wallet) => {
79-
setWalletsAsSelected({
80-
source: {
80+
setSourceWallet(
81+
{
8182
address: wallet.address,
8283
blockchain: wallet.chain,
8384
type: wallet.walletType,
8485
},
85-
});
86+
connectedWallets
87+
);
8688
}}
8789
/>
8890
</ListContainer>

0 commit comments

Comments
 (0)