Skip to content

Conversation

@tomiiide
Copy link
Contributor

@tomiiide tomiiide commented Nov 17, 2025

Which Jira task is linked to this PR?

https://lifi.atlassian.net/browse/LF-13181

Why was it implemented this way?

Explain the reasoning behind the implementation. Were there alternative approaches? Why was this solution chosen?
The solana provider specifies a wallet interface to generalize use without depending on a specific wallet / adapter type as before (e.g SignerWalletAdapter from @solana/wallet-adapter-base )

All it requires is that the wallet can handle transactions types from @solana/kit

import type { Address, Transaction } from '@solana/kit'

export interface SolanaWallet {
  signTransaction(transaction: Transaction): Promise<Transaction>
  account: {
    address: Address
    publicKey: Uint8Array
  }
}

Type conversions

Since signTransaction only deals with Transaction types from the @solana/kit, if using web3.js, you have to convert to/from transactions and address types like in the examples below:

import { Solana } from '@lifi/sdk'
import { VersionedTransaction } from '@solana/web3.js'
import { address } from '@solana/addresses'
import { fromVersionedTransaction } from '@solana/compat'
import { getTransactionCodec, type Transaction } from '@solana/transactions'

Solana({
  async getWallet() {
    return {
      account: {
        address: address(wallet.adapter.publicKey.toString()),
        publicKey: wallet.adapter.publicKey.toBytes(),
      },
      async signTransaction(transaction: Transaction) {
        const transactionCodec = getTransactionCodec()
        const transactionBytes = transactionCodec.encode(transaction)

        const web3Transaction = VersionedTransaction.deserialize(
          new Uint8Array(transactionBytes)
        )

        const signedWeb3Transaction = await (
          wallet?.adapter as SignerWalletAdapter
        ).signTransaction(web3Transaction)

        return fromVersionedTransaction(signedWeb3Transaction)
      },
    }
  },
})

Visual showcase (Screenshots or Videos)

If applicable, attach screenshots, GIFs, or videos to showcase the functionality, UI changes, or bug fixes.

Checklist before requesting a review

  • I have performed a self-review and testing of my code.
  • This pull request is focused and addresses a single problem.
  • If this PR modifies the SDK API or adds new features that require documentation, I have updated the documentation in the public-docs repository.

@tomiiide tomiiide self-assigned this Nov 17, 2025
@tomiiide tomiiide marked this pull request as ready for review November 18, 2025 11:37
@tomiiide tomiiide requested a review from chybisov November 18, 2025 11:37
@tomiiide tomiiide requested a review from chybisov November 18, 2025 14:45
@tomiiide tomiiide changed the title Lf 13181 upgrade to solana kit wallet chore: upgrade solana provider to @solana/kit Nov 18, 2025
@tomiiide tomiiide changed the title chore: upgrade solana provider to @solana/kit chore(solana): upgrade @solana/web3.js to @solana/kit Nov 18, 2025
@tomiiide
Copy link
Contributor Author

Moved to #327 to be on the latest modular architecture

@tomiiide tomiiide closed this Nov 19, 2025
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.

3 participants