vechain-sdk-js
vechain-sdk-js copied to clipboard
🐛 [BUG] - `transactions.getTransaction()` does not respect `pending` options
Description
When requesting pending options, the thorClient
does ignore the pending
flag and returns no data.
The query builder internally seem to not map correctly the pending
option to the client request:
https://github.com/vechain/vechain-sdk-js/blob/main/packages/network/src/thor-client/transactions/transactions-module.ts#L68
This should be:
pending: options?.pending
Reproduction URL
No response
Reproduction steps
Use the following snippet to listen for new transactions:
import { subscriptions, ThorClient } from '@vechain/sdk-network';
import WebSocket from 'ws';
const ws = new WebSocket(subscriptions.getNewTransactionsSubscriptionUrl('https://mainnet.vechain.org'));
const thor = ThorClient.fromUrl('https://mainnet.vechain.org');
ws.onmessage = async (message) => {
const addedTx = JSON.parse(message.data);
console.log('New transaction', addedTx);
const tx = await thor.transactions.getTransaction(addedTx.id, {
pending: true,
});
// always returns null, if delayed until next block, will return data
console.log(tx);
};
// some helper to debug the websocket activity
ws.onopen = () => {
console.log('Connected, listening for new Transactions');
};
ws.onclose = () => {
console.log('Disconnected');
};
ws.onerror = (err) => {
console.error(err);
};
Screenshots

Logs
No response
OS
No response