Open vexelgray opened 1 week ago
Hello,
Try ".... sendTransaction(transaction. serialize() )" on first line of your ts object.
Or try this :
import { Transaction, Connection} from "@solana/web3.js";
const wallet = ;
const serializedTransaction = Buffer.from(transaction, "base64");
const txt = Transaction.from(serializedTransaction);
const signedTransaction = await wallet.signTransaction(txt);
const signature = await connection.sendTransaction( signedTransaction.serialize() );
const result = await connection.confirmTransaction(signature); return { result, signature };
Hey @jcatal
The transaction sends correctly and lands, so I believe the way it is constructed is not the issue. The problem occurs when using the confirmation method, as it seems to expect a GenericArray, which is causing the error.
The transaction is a versionedTransaction, which I construct in the following way:
const messageV0 = new TransactionMessage({
instructions: [
myInstructions,
...innerTransaction.instructions,
],
payerKey: wallet.publicKey,
recentBlockhash: latestBlockHash.blockhash
}).compileToV0Message();
const transaction = new VersionedTransaction(messageV0);
transaction.sign([wallet]);
I also tried converting the versionedTransaction to a transaction in the following way, which also works and lands:
const message = TransactionMessage.decompile(transaction.message);
let tx = new Transaction();
message.instructions.map((ix) => {
tx = tx.add(ix);
});
tx.feePayer = message.payerKey;
tx.recentBlockhash = message.recentBlockhash;
let signer: Signer = wallet!
const tx_sig = await sendAndConfirmTransaction(this.connection, tx, [signer]);
But the same issue occurs, the transaction lands, but the following error appears:
Error parsing optional "signature" as "Signature": ErrorObject { code: InvalidParams, message: "Invalid params", data: Some(RawValue("invalid type: string \"5RfJ7N9KmMjCg6VYNCFH2zb2X3pNfuDWgimrCLKAAiVzfzN4mETJt8cEibbLxXCttAcURqjP7EGwYiV6LXbp2jWv\", expected struct GenericArray at line 1 column 90")) }
You can probably find some infos about the error, in the source code of lite-rpc : /lite-rpc/src/rpc_pubsub.rs, at line 8 and line 48 It seems to use solana_sdk::signature::Signature links for solana-sdk signature infos : https://docs.rs/solana-sdk/latest/solana_sdk/signature/struct.Signature.html https://docs.rs/solana-sdk/latest/solana_sdk/signature/enum.ParseSignatureError.html https://docs.rs/solana-sdk/latest/src/solana_sdk/signature.rs.html#30 --> you can read : "#[deprecated (since = "1.16.4", note = "Please use 'Signature::from' or 'Signature::try_from' instead")]" --> the current lite-rpc version seems to use solana-sdk = "~1.18.15", see cargo.toml file, line 31 on root dir of lite-rpc. --> so try to replace line 8 on /lite-rpc/src/rpc_pubsub.rs, from "use solana_sdk::signature::Signature;" to "use solana_sdk::signature::Signature::from;" or "use solana_sdk::signature::Signature::try_from;"
It seems that doesn't solve the problem, as it can't be imported in the way you mentioned.
Whether I try to import solana_sdk::signature::Signature::from or solana_sdk::signature::Signature::try_from, the compiler shows an error:
error[E0432]: unresolved import `solana_sdk::signature::Signature`
--> lite-rpc/src/rpc_pubsub.rs:8:28
|
8 | use solana_sdk::signature::Signature::try_from;
| ^^^^^^^^^ `Signature` is a struct, not a module
It seems that doesn't solve the problem either...
Hello, Maybe you may modify the code, instead of modifying the "use solana_sdk::signature..." For instance if the code contains "signature", or "Signature", then you may modify it following the source code of https://docs.rs/solana-sdk/latest/src/solana_sdk/signature.rs.html#93 --> "from(signature: Signature)" instead of "signature" or "Signature" for example --> l'm trying to figure out what to do, I have the same problem
I have the same problem than your, it seems to be a problem of arrays too, it says `type|type 'expected instead of [this that].
It seems new update solve the problem, but only working with Transaction not versionedTransaction
Ok will fix the issue with versioned transactions.
It seems new update solve the problem, but only working with Transaction not versionedTransaction
How do you send versioned trasnsaction ?
This tests work for me :
function createVersionedMessage(blockhash: string, payer: PublicKey): MessageV0 {
return new MessageV0({
header: {
numRequiredSignatures: 1,
numReadonlySignedAccounts: 0,
numReadonlyUnsignedAccounts: 0,
},
staticAccountKeys: [payer, MEMO_PROGRAM_ID],
recentBlockhash: blockhash,
compiledInstructions: [{
programIdIndex: 1,
accountKeyIndexes: [],
data: Buffer.from(crypto.randomBytes(20).toString('hex')),
}],
addressTableLookups: [],
})
}
test('send and confirm versioned transaction', async () => {
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash();
const message = createVersionedMessage(blockhash, payer.publicKey);
let versionedTransaction = new VersionedTransaction( message, [payer.secretKey])
versionedTransaction.sign([payer])
const signature = await connection.sendRawTransaction(versionedTransaction.serialize(), {});
console.log(`https://explorer.solana.com/tx/${signature}`);
await connection.confirmTransaction({
blockhash,
lastValidBlockHeight,
signature,
abortSignal: undefined
});
});
Thank you godemodegalactus, for your replies and good work, you are very capable 👍
Nice! It's working with versionedTx with the new release!
Thank you!
Hey!
I am using Lite-RPC and everything seems to be working correctly, however, when I try to confirm the transaction, I see this in the logs and the transaction never confirms:
I am using the following code in my Typescript client:
Could you please help me with this issue?
Regards