micro-sol-signer
micro-sol-signer copied to clipboard
Add helper method to get base64 encoded `Message`
I've faced with the task of calculating the fee for a transaction.
Solana has RPC method getFeeForMessage https://docs.solana.com/ru/api/http#getfeeformessage
But the parameter is Message not a Transaction. Library doesn't allow to get Message directly and keys specific logic are incapsulated in the Transaction encoder.
Current solution to get a Message:
const tx = sol.createTx(address, toAddress, amount, fee, blockhash);
const decodedTx = sol.TransactionRaw.decode(base64.decode(tx));
const message = base64.encode(sol.Message.encode(decodedTx.msg)));
I think it is better to split logic between Message, Transaction, and TransactionRaw to be able to get specific data.