Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed the connector issue #67

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

PoulavBhowmick03
Copy link

Fix xBull Wallet Popup Issue When Signing with Other Wallets

Fixes #60

Problem

When signing a transaction with wallets other than xBull (e.g., Freighter), the xBull wallet popup would unexpectedly appear. This caused confusion and a poor user experience.

Solution

We've updated the GreeterContractInteractions.tsx file to ensure that only the actively selected wallet is used for signing transactions. This change prevents the xBull wallet from interfering when it's not the chosen wallet.

Changes Made

  1. Updated the updateGreeting function to use the activeConnector for signing transactions.
  2. Removed dependencies on specific wallet implementations, making the code more wallet-agnostic.
  3. Added error handling and improved transaction status checking.

Specific Changes

const updateGreeting = async ({ newMessage }: UpdateGreetingValues) => {
  if (!address || !server || !activeChain || !activeConnector) {
    toast.error('Wallet not connected or missing configuration. Try again...');
    return;
  }

  setUpdateIsLoading(true);

  try {
    const account = await server.getAccount(address);
    
    const contract = new StellarSdk.Contract(contractAddressStored || '');
    const tx = new StellarSdk.TransactionBuilder(account, { 
      fee: StellarSdk.BASE_FEE,
      networkPassphrase: activeChain.networkPassphrase
    })
      .addOperation(contract.call("set_title", nativeToScVal(newMessage, {type: "string"})))
      .setTimeout(30)
      .build();

    const simulation = await server.simulateTransaction(tx);
    
    if ('results' in simulation) {
      const preparedTransaction = tx;

      const signedTransaction = await activeConnector.signTransaction(
        preparedTransaction.toXDR(),
        { networkPassphrase: activeChain.networkPassphrase }
      );
      
      // ... (rest of the function)
    }
  } catch (e) {
    console.error(e);
    toast.error('Error while sending tx. Try again…');
  } finally {
    setUpdateIsLoading(false);
  }
};

Testing

To test this fix:

  1. Connect different wallets (Freighter, Lobstr, Hana, xBull) one at a time.
  2. Attempt to change the greeting using each connected wallet.
  3. Verify that only the connected wallet's popup appears for signing.
  4. Ensure the greeting can be successfully changed with each wallet.

Additional Notes

This PR is part of the fix for issue #60. It addresses the frontend component of the problem. A corresponding update to the wallet initialization in MySorobanReactProvider.tsx may be necessary for a complete solution.

Copy link

vercel bot commented Aug 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
create-soroban-dapp ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 0:08am
create-soroban-dapp-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 0:08am

@PoulavBhowmick03
Copy link
Author

@chopan123 PTAL

@MattPoblete
Copy link
Contributor

Grabacion.de.pantalla.2024-08-30.a.la.s.8.19.20.p.m.mov

Coludn't sign the transaction

@chopan123
Copy link
Member

@PoulavBhowmick03 address this please

@PoulavBhowmick03
Copy link
Author

I will get it done in few hours

@PoulavBhowmick03
Copy link
Author

@chopan123 can you check please

@PoulavBhowmick03
Copy link
Author

@PoulavBhowmick03 address this please

PTAL

@PoulavBhowmick03
Copy link
Author

@chopan123 can you please close this issue and PR? I have received the reward for this and the work is done too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Xbull Wallet pops up when signing a transaction with freigther
3 participants