Skip to content

Commit

Permalink
fix: fix logo type mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
twhy committed Sep 14, 2023
1 parent 63b48bf commit ab3508b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
6 changes: 2 additions & 4 deletions packages/react/src/modal/components/views/WalletList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,14 @@ function DynamicWalletList({ wallets, onClose }: DynamicWalletListProps) {
}
})
.map((wallet, i) => {
const props = getWalletProp(wallet.walletInfo);
return {
...props,
logo: typeof props.logo === 'object' ? props.logo.major : props.logo,
...getWalletProp(wallet.walletInfo),
// subLogo can either be 'walletConnect' or a valid <img /> src attribute
subLogo:
wallet.walletInfo.mode === 'wallet-connect'
? 'walletConnect'
: undefined,
btmLogo: typeof props.logo === 'object' ? props.logo.minor : wallet.walletInfo.extends,
btmLogo: typeof wallet.walletInfo.logo === 'object' ? wallet.walletInfo.logo.minor : wallet.walletInfo.extends,
badge: ({ MetaMask: 'SNAP' })[wallet.walletInfo.extends],
shape: (i < 2 && isLargeScreen ? 'square' : 'list') as ('square' | 'list'),
downloadUrl: '',
Expand Down
21 changes: 10 additions & 11 deletions packages/react/src/modal/components/views/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,22 @@ export type ModalViewImplGetter = (
props: WalletViewProps | WalletListViewProps
) => ModalViewImpl;

export const defaultModalViews: Record<keyof ModalViews, ModalViewImplGetter> =
{
Connecting: ConnectingView,
Connected: ConnectedView,
Error: ErrorView,
NotExist: NotExistView,
Rejected: RejectedView,
QRCode: QRCodeView,
WalletList: WalletListView,
};
export const defaultModalViews: Record<keyof ModalViews, ModalViewImplGetter> = {
Connecting: ConnectingView,
Connected: ConnectedView,
Error: ErrorView,
NotExist: NotExistView,
Rejected: RejectedView,
QRCode: QRCodeView,
WalletList: WalletListView,
};

export function getWalletProp(wallet: Wallet) {
const { prettyName, mode, name, logo, mobileDisabled } = wallet;
return {
name,
prettyName,
logo,
logo: typeof logo === 'object' ? logo.major : logo,
mobileDisabled:
typeof mobileDisabled === 'boolean' ? mobileDisabled : mobileDisabled(),
isMobile: mode === 'wallet-connect',
Expand Down

0 comments on commit ab3508b

Please sign in to comment.