Skip to content

Commit

Permalink
fix: refactor type
Browse files Browse the repository at this point in the history
  • Loading branch information
montelaidev committed Jun 24, 2024
1 parent 87009cd commit 9eb76f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ui/hooks/useMultichainSelector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('useMultichainSelector', () => {
});

it('uses selectedAccount if account is not provided', () => {
const { result } = renderUseMultichainHook(getMultichainIsEvm, mockAccount);
const { result } = renderUseMultichainHook(getMultichainIsEvm, null);

expect(result.current).toBe(true);
});
Expand Down
29 changes: 16 additions & 13 deletions ui/selectors/multichain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,28 @@ import {
getShouldShowFiat,
} from '.';

export type MultichainState = AccountsState & {
export type RatesState = {
metamask: {
balances: {
[accountId: string]: {
[assetId: string]: {
amount: string;
unit: string;
};
};
[ticker: string]: {
conversionDate: number;
conversionRate: string;
};
rates: {
[ticker: string]: {
conversionDate: number;
conversionRate: string;
};
};

export type BalancesState = {
metamask: {
[accountId: string]: {
[assetId: string]: {
amount: string;
unit: string;
};
};
};
};

export type MultichainState = AccountsState & RatesState & BalancesState;

export type MultichainNetwork = {
nickname: string;
isEvmNetwork: boolean;
Expand Down Expand Up @@ -133,7 +136,7 @@ export function getMultichainIsEvm(

// There are no selected account during onboarding. we default to the original EVM behavior.
return (
!isOnboarded ?? !selectedAccount ?? isEvmAccountType(selectedAccount.type)
!isOnboarded || !selectedAccount || isEvmAccountType(selectedAccount.type)
);
}

Expand Down

0 comments on commit 9eb76f2

Please sign in to comment.