Skip to content

Commit

Permalink
fix: if chain switching is not support by mobile wallet, show message…
Browse files Browse the repository at this point in the history
… to end user (#272)

* wip: debugging

* fix: testing

* fix: check to see if supports chain switching

* chore: apos is upsetting to look at
  • Loading branch information
nickbytes committed Apr 27, 2022
1 parent df6c310 commit 6052e20
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/rainbowkit/src/components/ChainModal/ChainModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface ChainModalProps {
onClose: () => void;
networkData: ReturnType<typeof useNetwork>[0]['data'];
networkError: ReturnType<typeof useNetwork>[0]['error'];
onSwitchNetwork?: (chainId: number) => unknown;
onSwitchNetwork?: (chainId: number) => unknown | undefined;
}

export function ChainModal({
Expand Down Expand Up @@ -81,7 +81,7 @@ export function ChainModal({
<CloseButton onClose={onClose} />
</Box>
<Box display="flex" flexDirection="column" gap="4" padding="2">
{onSwitchNetwork &&
{onSwitchNetwork ? (
networkData.chains.map((chain, idx) => {
const isCurrentChain = chain.id === networkData.chain?.id;
const switching = chain.id === switchingToChain;
Expand Down Expand Up @@ -188,7 +188,12 @@ export function ChainModal({
)}
</Fragment>
);
})}
})
) : (
<Text color="modalText" size="14" weight="medium">
Your wallet does not support switching networks.
</Text>
)}
</Box>
</Box>
</DialogContent>
Expand Down

2 comments on commit 6052e20

@vercel
Copy link

@vercel vercel bot commented on 6052e20 Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 6052e20 Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

rainbowkit-site – ./

rainbowkit-site-rainbowdotme.vercel.app
rainbowkit-site-git-main-rainbowdotme.vercel.app
rainbowkit.vercel.app

Please sign in to comment.