Skip to content

Commit

Permalink
fix: Checkout Connect Widget to wrap web3provider (#1568)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamoftrees authored Mar 6, 2024
1 parent ad8c959 commit e9f6830
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions packages/checkout/widgets-lib/src/lib/hooks/useWalletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ export const useWalletConnect = () => {
} else {
// eslint-disable-next-line no-console
console.log('activate succeeded but there is no connected session');

if (displayUri.current !== '') {
walletConnectModal?.openModal({
uri: displayUri.current,
})
.then((result) => {
setWalletConnectBusy(false);
resolve(result);
})
.catch((error) => {
// Error opening WalletConnect Modal
setWalletConnectBusy(true);
reject(error);
});
} else {
// if we don't have a display uri and no connected session
// call connect to generate display_uri event
ethereumProvider?.connect();
}
}
// eslint-disable-next-line no-console
}).catch((err) => console.log('activate existing pairing error', err));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ export const rawImageStyle = {
width: '32px',
height: '32px',
padding: '6px',
left: 'base.spacing.x3',
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
useCallback, useContext, useEffect, useState,
} from 'react';
import { Web3Provider } from '@ethersproject/providers';
import { useTranslation } from 'react-i18next';
import { isWalletConnectProvider } from 'lib/provider';
import { SimpleTextBody } from '../../../components/Body/SimpleTextBody';
Expand Down Expand Up @@ -40,7 +41,7 @@ export function SwitchNetworkZkEVM() {
connectDispatch({
payload: {
type: ConnectActions.SET_PROVIDER,
provider,
provider: new Web3Provider(provider.provider as any),
},
});

Expand Down

0 comments on commit e9f6830

Please sign in to comment.