Skip to content

Commit

Permalink
fix issues with deploy fetching and small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ost-ptk committed Sep 10, 2024
1 parent 2b87b37 commit c517183
Show file tree
Hide file tree
Showing 19 changed files with 110 additions and 367 deletions.
28 changes: 14 additions & 14 deletions src/apps/popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ import { GlobalStyle, darkTheme, lightTheme } from '@libs/ui';

import { AppRouter } from './app-router';

const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 3 * 60 * 1000,
refetchInterval: 3 * 60 * 1000,
gcTime: 3 * 60 * 1000,
retry: false
},
mutations: {
retry: false
}
}
});

const Tree = () => {
const [state, setState] = useState<PopupState | null>(null);

const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 3 * 60 * 1000,
refetchInterval: 3 * 60 * 1000,
gcTime: 3 * 60 * 1000,
retry: false
},
mutations: {
retry: false
}
}
});

setCSPForSafari();

const isSystemDarkTheme = useSystemThemeDetector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const Cep18ActionRows = ({ deploy }: Cep18ActionRowsProps) => {
title={title}
contractPackageHash={contractPackageHash}
contractName={contractName}
iconUrl={iconUrl || DeployIcon.Cep18Default}
additionalInfo="CEP-18 Token"
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const NftActionsRows = ({ deploy }: NftActionsRowsProps) => {
contractPackageHash={contractPackageHash}
contractName={contractName}
additionalInfo="CEP-47 NFT"
iconUrl={DeployIcon.NFTDefault}
iconUrl={iconUrl || DeployIcon.NFTDefault}
/>
);
};
12 changes: 8 additions & 4 deletions src/apps/popup/pages/deploy-details/components/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ export const ContainerWithAmount = ({
fiatAmount
}: ActionContainerWithAmountProps) => (
<LeftAlignedFlexColumn gap={SpacingSize.Tiny}>
<AlignedFlexRow gap={SpacingSize.Small}>
<AlignedFlexRow gap={SpacingSize.Small} style={{ maxWidth: '296px' }}>
<Typography type="bodySemiBold">{title}</Typography>
<Typography type="bodyHash">{amount}</Typography>
<Typography type="bodyHash" ellipsis>
{amount}
</Typography>
<Typography type="bodyHash" color="contentSecondary">
CSPR
</Typography>
Expand Down Expand Up @@ -206,13 +208,15 @@ export const AmountRow = ({
const { t } = useTranslation();

return (
<AlignedFlexRow gap={SpacingSize.Small}>
<AlignedFlexRow gap={SpacingSize.Small} style={{ maxWidth: '296px' }}>
{label && (
<Typography type="captionRegular" color="contentSecondary">
<Trans t={t}>{label}</Trans>
</Typography>
)}
<Typography type="bodyHash">{amount}</Typography>
<Typography type="bodyHash" ellipsis>
{amount}
</Typography>
<Typography type="bodyHash" color="contentSecondary">
{symbol}
</Typography>
Expand Down
20 changes: 6 additions & 14 deletions src/apps/popup/pages/deploy-details/content.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { IDeploy } from 'casper-wallet-core';
import React, { useEffect, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import styled from 'styled-components';

import { DeployDetailsAction } from '@popup/pages/deploy-details/components/deploy-details-action';
import { DeployDetailsResult } from '@popup/pages/deploy-details/components/deploy-details-result';
import { getEntryPointName } from '@popup/pages/deploy-details/utils';

import { selectVaultActiveAccount } from '@background/redux/vault/selectors';

import {
AlignedSpaceBetweenFlexRow,
BorderBottomPseudoElementProps,
Expand All @@ -22,7 +19,7 @@ import {
SpacingSize,
borderBottomPseudoElementRules
} from '@libs/layout';
import { dispatchFetchExtendedDeploysInfo } from '@libs/services/account-activity-service';
import { useFetchDeploy } from '@libs/services/deploys/use-fetch-deploy';
import {
DeployStatus,
Hash,
Expand Down Expand Up @@ -69,22 +66,17 @@ export const DeployDetailsPageContent = ({

const { t } = useTranslation();

const activeAccount = useSelector(selectVaultActiveAccount);

useEffect(() => {
setSingleDeploy(deploy);
}, [deploy]);

const { deployData } = useFetchDeploy(deploy?.deployHash);

useEffect(() => {
if (deploy?.deployHash && activeAccount?.publicKey) {
dispatchFetchExtendedDeploysInfo(
deploy.deployHash,
activeAccount?.publicKey
).then(({ payload: resp }) => {
setSingleDeploy(resp);
});
if (deployData) {
setSingleDeploy(deployData);
}
}, [activeAccount?.publicKey, deploy?.deployHash]);
}, [deployData]);

if (!singleDeploy) {
return null;
Expand Down
10 changes: 0 additions & 10 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ import {
} from '@background/redux/account-balances/actions';
import {
accountBalanceChanged,
accountCasperActivityCountChanged,
accountCep18TransferDeploysDataChanged,
accountCsprTransferDeploysDataChanged,
accountCurrencyRateChanged,
accountDeploysCountChanged,
accountDeploysDataChanged,
accountErc20Changed,
accountInfoReset,
accountNftTokensAdded,
Expand Down Expand Up @@ -619,18 +614,13 @@ runtime.onMessage.addListener(
case getType(recipientPublicKeyReseted):
case getType(accountBalanceChanged):
case getType(accountCurrencyRateChanged):
case getType(accountCsprTransferDeploysDataChanged):
case getType(accountInfoReset):
case getType(accountPendingDeployHashesChanged):
case getType(accountPendingDeployHashesRemove):
case getType(accountErc20Changed):
case getType(accountCep18TransferDeploysDataChanged):
case getType(accountDeploysDataChanged):
case getType(accountNftTokensAdded):
case getType(accountNftTokensUpdated):
case getType(accountNftTokensCountChanged):
case getType(accountDeploysCountChanged):
case getType(accountCasperActivityCountChanged):
case getType(accountTrackingIdOfSentNftTokensChanged):
case getType(accountTrackingIdOfSentNftTokensRemoved):
case getType(newContactAdded):
Expand Down
29 changes: 0 additions & 29 deletions src/background/redux/account-info/actions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { createAction } from 'typesafe-actions';

import {
AccountDeploysDataType,
Cep18TransferDeploysDataType,
CsprTransferDeploysDataType
} from '@background/redux/account-info/types';

import { AccountBalance } from '@libs/services/balance-service/types';
import { ContractPackageWithBalance } from '@libs/services/erc20-service/types';
import { NFTTokenResult } from '@libs/services/nft-service/types';
Expand All @@ -22,17 +16,6 @@ export const accountCurrencyRateChanged = createAction(
'ACCOUNT_CURRENCY_RATE_CHANGED'
)<number | null>();

export const accountCsprTransferDeploysDataChanged = createAction(
'ACCOUNT_CSPR_TRANSFER_DEPLOYS_DATA_CHANGED'
)<CsprTransferDeploysDataType>();

export const accountCep18TransferDeploysDataChanged = createAction(
'ACCOUNT_CEP18_TRANSFER_DEPLOYS_DATA_CHANGED'
)<{
cep18TransferDeploysData: Cep18TransferDeploysDataType;
contractPackageHash: string;
}>();

export const accountInfoReset = createAction('ACCOUNT_INFO_RESET')();

export const accountPendingDeployHashesChanged = createAction(
Expand All @@ -43,10 +26,6 @@ export const accountPendingDeployHashesRemove = createAction(
'ACCOUNT_PENDING_TRANSACTIONS_REMOVE'
)<string>();

export const accountDeploysDataChanged = createAction(
'ACCOUNT_DEPLOYS_DATA_CHANGED'
)<AccountDeploysDataType>();

export const accountNftTokensAdded = createAction('ACCOUNT_NFT_TOKENS_ADDED')<
NFTTokenResult[] | null
>();
Expand All @@ -59,14 +38,6 @@ export const accountNftTokensCountChanged = createAction(
'ACCOUNT_NFT_TOKENS_COUNT_CHANGED'
)<number>();

export const accountDeploysCountChanged = createAction(
'ACCOUNT_DEPLOYS_COUNT_CHANGED'
)<number>();

export const accountCasperActivityCountChanged = createAction(
'ACCOUNT_CASPER_ACTIVITY_COUNT_CHANGED'
)<number>();

export const accountTrackingIdOfSentNftTokensChanged = createAction(
'ACCOUNT_TRACKING_ID_OF_SENT_NFT_TOKENS_CHANGED'
)<{
Expand Down
Loading

0 comments on commit c517183

Please sign in to comment.