Skip to content

Commit

Permalink
refactoring according to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lendihop committed Feb 6, 2025
1 parent a6465f6 commit 878b47b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 15 deletions.
5 changes: 4 additions & 1 deletion src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export const App: FC<Props> = ({ env }) => (
<AwaitFonts>
<BootAnimation>
{env.confirmWindow ? (
<ConfirmPage />
<>
<ConfirmPage />
<ToasterProvider />
</>
) : (
<>
<AppRootHooks />
Expand Down
2 changes: 0 additions & 2 deletions src/app/ConfirmPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Spinner from 'app/atoms/Spinner/Spinner';
import { SuspenseContainer } from 'app/atoms/SuspenseContainer';
import { LAYOUT_CONTAINER_CLASSNAME } from 'app/layouts/containers';
import Unlock from 'app/pages/Unlock/Unlock';
import { ToasterProvider } from 'app/toaster';
import { t } from 'lib/i18n';
import { useRetryableSWR } from 'lib/swr';
import { useTempleClient } from 'lib/temple/front/client';
Expand Down Expand Up @@ -46,7 +45,6 @@ const ConfirmPage = memo(() => {
}
>
<ConfirmDAppForm />
<ToasterProvider />
</SuspenseContainer>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/ChainSettings/use-chain-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { nanoid } from 'nanoid';
import { ArtificialError } from 'app/defaults';
import { t } from 'lib/i18n';
import { EvmChainSpecs, TezosChainSpecs } from 'lib/temple/chains-specs';
import { COLORS } from 'lib/ui/colors';
import { getRandomColor } from 'lib/ui/colors';
import { loadEvmChainId } from 'temple/evm';
import { OneOfChains, useAllEvmChains, useAllTezosChains, useTempleNetworksActions } from 'temple/front';
import { BlockExplorer, useChainBlockExplorers } from 'temple/front/use-block-explorers';
Expand Down Expand Up @@ -88,7 +88,7 @@ export const useChainOperations = (chainKind: TempleChainKind, chainId: string |
name,
rpcBaseURL: url,
id: rpcId,
color: COLORS[Math.floor(Math.random() * COLORS.length)]
color: getRandomColor()
};

abortSignal.throwIfAborted();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ArtificialError } from 'app/defaults';
import { toastError } from 'app/toaster';
import { EvmAssetStandard } from 'lib/evm/types';
import { t } from 'lib/i18n';
import { COLORS } from 'lib/ui/colors';
import { getRandomColor } from 'lib/ui/colors';
import { generateEntityNameFromUrl } from 'lib/utils';
import { loadEvmChainId } from 'temple/evm';
import { useTempleNetworksActions } from 'temple/front';
Expand Down Expand Up @@ -66,7 +66,7 @@ export const useAddNetwork = (
id: nanoid(),
rpcBaseURL: rpcUrl,
name: rpcName,
color: COLORS[Math.floor(Math.random() * COLORS.length)]
color: getRandomColor()
};
const blockExplorerInput = explorerUrl
? {
Expand Down
5 changes: 2 additions & 3 deletions src/lib/temple/back/evm-dapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { EVM_TOKEN_SLUG } from 'lib/assets/defaults';
import { BLOCKCHAIN_EXPLORERS_OVERRIDES_STORAGE_KEY, EVM_CHAINS_SPECS_STORAGE_KEY } from 'lib/constants';
import { EvmAssetStandard } from 'lib/evm/types';
import { fetchFromStorage, putToStorage } from 'lib/storage';
import { COLORS } from 'lib/ui/colors';
import { getRandomColor } from 'lib/ui/colors';
import { generateEntityNameFromUrl, isTruthy } from 'lib/utils';
import { getReadOnlyEvm } from 'temple/evm';
import { EVMErrorCodes, evmRpcMethodsNames, RETURNED_ACCOUNTS_CAVEAT_NAME } from 'temple/evm/constants';
Expand Down Expand Up @@ -325,7 +325,6 @@ export const addChain = async (origin: string, currentChainId: string, params: A
!customEvmNetworks.some(n => n.rpcBaseURL === rpcUrl) &&
!EVM_DEFAULT_NETWORKS.some(n => n.rpcBaseURL === rpcUrl)
) {
console.log(2);
const updatedSettings = await vault.updateSettings({
customEvmNetworks: [
...customEvmNetworks,
Expand All @@ -334,7 +333,7 @@ export const addChain = async (origin: string, currentChainId: string, params: A
name: chainMetadata.name,
chain: TempleChainKind.EVM,
chainId: chainIdNum,
color: COLORS[Math.floor(Math.random() * COLORS.length)],
color: getRandomColor(),
rpcBaseURL: rpcUrl,
default: false
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/temple/back/evm-validation-schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
array as arraySchema,
mixed as mixedSchema,
object as objectSchema,
tuple as tupleSchema,
Expand All @@ -15,6 +14,7 @@ import {
evmAddressValidationSchema,
hexStringSchema,
oldTypedDataValidationSchema,
stringArraySchema,
typedDataValidationSchema
} from './utils';

Expand Down Expand Up @@ -72,9 +72,9 @@ export const addEthChainPayloadValidationSchema = tupleSchema([
decimals: numberSchema().integer().positive().required()
})
.required(),
rpcUrls: arraySchema().of(stringSchema().required()).required(),
blockExplorerUrls: arraySchema().of(stringSchema().required()),
iconUrls: arraySchema().of(stringSchema().required())
rpcUrls: stringArraySchema().required(),
blockExplorerUrls: stringArraySchema(),
iconUrls: stringArraySchema()
})
.required(),
hexStringSchema()
Expand Down
2 changes: 2 additions & 0 deletions src/lib/temple/back/evm-validation-schemas/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ export const typedDataValidationSchema = (): ObjectSchema<TypedDataDefinition> =
domain: typedDataDomainSchema,
message: arbitraryObjectSchema
});

export const stringArraySchema = () => arraySchema().of(stringSchema().required());
4 changes: 3 additions & 1 deletion src/lib/ui/colors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const COLORS = [
const COLORS = [
'#f7fafc',
'#edf2f7',
'#e2e8f0',
Expand Down Expand Up @@ -90,3 +90,5 @@ export const COLORS = [
'#97266d',
'#702459'
];

export const getRandomColor = () => COLORS[Math.floor(Math.random() * COLORS.length)];

0 comments on commit 878b47b

Please sign in to comment.