metaplex-foundation / SolanaKT

This is a open source library on kotlin for Solana protocol.
MIT License
71 stars 36 forks source link

[Bug] solana.core.Message.from(byteArray) deserialization bug #120

Open Funkatronics opened 1 year ago

Funkatronics commented 1 year ago

Describe the bug Trying to build a Transaction object from an array of bytes throws an exception. The exception is thrown by the call to solana.core.Message.from(byteArray) inside of the Transaction.from() method.

To Reproduce

Expected behavior Transaction.from(serializedBytes) should work the same as manually building the transaction like so (this is our current workaround):

Transaction().apply {
       setRecentBlockHash(recentBlockhash)
       feePayer = creator
       addInstruction(instructions)
       addSignature(creator, primarySignatureFromMwa)
}

SDK Version & Context Platform: Android Version: solana-kt:2.0.0

Additional context We are using metaplex and solanaKT with Mobile Wallet Adapter. Mobile wallet adapter uses raw byte arrays to pass around and sign transactions. This is why we need to serialize the Transaction object into bytes (for MWA signing), then rebuild the Transaction object from the signed bytes (so it can then be passed to sendTransaction or other solanakt/metaplex methods). When fixing this, I am may add some other methods/abstractions to better support raw byte array transactions.

ajamaica commented 1 year ago

I will take a look at this