Web3Auth / web3auth-web

Simple infrastructure that enables Web3 wallets and applications to provide seamless user logins for both mainstream and Web3.0 users.
https://web3auth.io/docs
Other
419 stars 227 forks source link

SolanaWallet does not support signing transactions from new @solana/web3.js SDK #1678

Open lithdew opened 8 months ago

lithdew commented 8 months ago

SolanaWallet does not support signing transactions from the new @solana/web3.js SDK.

As a recommendation to support any Solana transaction in general, it would be great if the SolanaWallet.signTransaction method and its related methods take in a transaction (or multiple transactions) as a Uint8Array rather than a web3.js' Transaction | VersionedTransaction type.

This would also be another step forward in avoiding having @solana/web3.js as a dependency on any of the web3auth packages.

The new SDK and its documentation can be found here: https://github.com/solana-labs/solana-web3.js/tree/master/packages/library

Here is a snippet of how I would expect the whole transaction creation + signing flow with the new web3js SDK look like:

    const tx = pipe(
        createTransaction({ version: 0 }),
        (tx) => setTransactionFeePayer(ctx.session!.publicKey as Address, tx),
        (tx) => setTransactionLifetimeUsingBlockhash(input.lifetime, tx),
        (tx) =>
            appendTransactionInstruction(
                fromLegacySolanaInstruction(
                    ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }),
                ),
                tx,
            ),
    );

    const decoded = atob(tx.value);
    const bytes = new Uint8Array(decoded.length);
    for (let i = 0; i < decoded.length; i++) {
        bytes[i] = decoded.charCodeAt(i);
    }

    // Web3auth
    const signed = await wallet.signTransaction(bytes);
augchan42 commented 1 month ago

Is this still an issue or are you using an older version of the Solana client?