Skip to content

Commit

Permalink
fix: AE wallet select prompting issue #82
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufseyrek committed Dec 18, 2024
1 parent a4eb249 commit 73b539a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/context/WalletProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const WalletProvider: React.FC<{ children: ReactNode }> = (props) => {
const isAeWalletDetectionEnded = useRef<boolean>(false);
const ethereumWalletDetected = useRef<boolean>(false);
const aeternityWalletDetected = useRef<boolean>(false);
const aeternityWalletAddress = useRef<string | undefined>(undefined);

useEffect(() => {
(async function () {
Expand Down Expand Up @@ -47,7 +48,15 @@ const WalletProvider: React.FC<{ children: ReactNode }> = (props) => {
})();
}, []);

useEffect(() => {
// For some reason, the wallet address state is not updated properly when the ae wallet is connected
// Therefore, we need to use a ref to store the address and update the state manually
aeternityWalletAddress.current = aeternityAddress;
}, [aeternityAddress]);

const connectAeternityWallet = useCallback(async () => {
if (aeternityWalletAddress.current) return;

if (isAeWalletDetectionEnded.current) {
setShowAeWalletSelect(true);
} else {
Expand Down

0 comments on commit 73b539a

Please sign in to comment.