Skip to content

Commit

Permalink
feat(trading): exclude NON_SUITE receive option when noExternalAddres…
Browse files Browse the repository at this point in the history
…s tag
  • Loading branch information
FreeWall authored and tomasklim committed Feb 24, 2025
1 parent 85ab261 commit 69464ce
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"@testing-library/user-event": "14.5.2",
"@trezor/eslint": "workspace:*",
"@types/file-saver": "^2.0.6",
"@types/invity-api": "^1.1.2",
"@types/invity-api": "^1.1.3",
"@types/jws": "^3.2.10",
"@types/pako": "^2.0.3",
"@types/pdfmake": "^0.2.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const getSelectAccountOptions = (
suiteReceiveAccounts: Account[] | undefined,
device: TrezorDevice | undefined,
isSupportedNetwork: boolean,
nonSuiteAccount: boolean,
): TradingVerifyFormAccountOptionProps[] => {
const selectAccountOptions: TradingVerifyFormAccountOptionProps[] = [];

Expand All @@ -41,7 +42,9 @@ const getSelectAccountOptions = (
selectAccountOptions.push({ type: 'ADD_SUITE' });
}

selectAccountOptions.push({ type: 'NON_SUITE' });
if (nonSuiteAccount) {
selectAccountOptions.push({ type: 'NON_SUITE' });
}

return selectAccountOptions;
};
Expand All @@ -62,6 +65,7 @@ const getTranslationIds = (type: TradingAccountType | undefined): TradingGetTran

const useTradingVerifyAccount = ({
cryptoId,
nonSuiteAccount,
}: TradingVerifyAccountProps): TradingVerifyAccountReturnProps => {
const selectedAccount = useSelector(state => state.wallet.selectedAccount);
const accounts = useSelector(state => state.wallet.accounts);
Expand Down Expand Up @@ -101,8 +105,14 @@ const useTradingVerifyAccount = ({
}, [accounts, cryptoId, device, isDebug, symbol]);

const selectAccountOptions = useMemo(
() => getSelectAccountOptions(suiteReceiveAccounts, device, isSupportedNetwork),
[device, suiteReceiveAccounts, isSupportedNetwork],
() =>
getSelectAccountOptions(
suiteReceiveAccounts,
device,
isSupportedNetwork,
nonSuiteAccount,
),
[device, suiteReceiveAccounts, isSupportedNetwork, nonSuiteAccount],
);
const preselectedAccount = useMemo(
() =>
Expand Down
1 change: 1 addition & 0 deletions packages/suite/src/types/trading/tradingVerify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface TradingVerifyFormAccountOptionProps {

export interface TradingVerifyAccountProps {
cryptoId: CryptoId | undefined;
nonSuiteAccount: boolean;
}

export interface TradingGetTranslationIdsProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export const TradingOfferBuy = ({
paymentMethodName,
}: TradingOfferBuyProps) => {
const cryptoId = selectedQuote?.receiveCurrency;
const tradingVerifyAccount = useTradingVerifyAccount({ cryptoId });
const tradingVerifyAccount = useTradingVerifyAccount({
cryptoId,
nonSuiteAccount: !selectedQuote.tags?.includes('noExternalAddress'),
});

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export const TradingOfferExchange = ({
}: TradingOfferExchangeProps) => {
const { exchangeStep } = useTradingFormContext<TradingExchangeType>();
const cryptoId = selectedQuote?.receive;
const tradingVerifyAccount = useTradingVerifyAccount({ cryptoId });
const tradingVerifyAccount = useTradingVerifyAccount({
cryptoId,
nonSuiteAccount: !selectedQuote.tags?.includes('noExternalAddress'),
});

const steps: TradingSelectedOfferStepperItemProps[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion suite-common/trading/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
},
"devDependencies": {
"@suite-common/test-utils": "workspace:*",
"@types/invity-api": "^1.1.2"
"@types/invity-api": "^1.1.3"
}
}
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9717,7 +9717,7 @@ __metadata:
"@trezor/connect": "workspace:*"
"@trezor/env-utils": "workspace:*"
"@trezor/utils": "workspace:*"
"@types/invity-api": "npm:^1.1.2"
"@types/invity-api": "npm:^1.1.3"
uuid: "npm:^11.0.5"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -12653,7 +12653,7 @@ __metadata:
"@trezor/urls": "workspace:*"
"@trezor/utils": "workspace:*"
"@types/file-saver": "npm:^2.0.6"
"@types/invity-api": "npm:^1.1.2"
"@types/invity-api": "npm:^1.1.3"
"@types/jws": "npm:^3.2.10"
"@types/pako": "npm:^2.0.3"
"@types/pdfmake": "npm:^0.2.9"
Expand Down Expand Up @@ -13565,10 +13565,10 @@ __metadata:
languageName: node
linkType: hard

"@types/invity-api@npm:^1.1.2":
version: 1.1.2
resolution: "@types/invity-api@npm:1.1.2"
checksum: 10/4c3f638c9f6fd674a9bb9360c06dcf5a7d6c1b9750b05b3d70da83277a8145effed660b50c294833c0aef3a22a0511d8459e69ce3cf8d6e618743be2cd2fc1fb
"@types/invity-api@npm:^1.1.3":
version: 1.1.4
resolution: "@types/invity-api@npm:1.1.4"
checksum: 10/6a17f3d84274c86eb31950cb525b3a0a5bf87a7539e8ac35a011f15d354fd1c0cd7dee88bd3d475d5b973829d71817de2b019bedddd03224be85e51dabac830b
languageName: node
linkType: hard

Expand Down

0 comments on commit 69464ce

Please sign in to comment.