Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp not included in searchTx() response #1181

Closed
Goochie opened this issue Jun 17, 2022 · 5 comments
Closed

Timestamp not included in searchTx() response #1181

Goochie opened this issue Jun 17, 2022 · 5 comments
Labels
Question ❓ User question

Comments

@Goochie
Copy link

Goochie commented Jun 17, 2022

Is there any reason that the timestamp is not included in the returned response when it is parsed in the following function ..

private async txsQuery(query: string): Promise<readonly IndexedTx[]> {
const results = await this.forceGetTmClient().txSearchAll({ query: query });
return results.txs.map((tx) => {
return {
height: tx.height,
hash: toHex(tx.hash).toUpperCase(),
code: tx.result.code,
rawLog: tx.result.log || "",
tx: tx.tx,
gasUsed: tx.result.gasUsed,
gasWanted: tx.result.gasWanted,
};
});
}

.......... as its not included what is the expectations with regards to getting timestamp, do we have to call getBlock() ?

@Goochie Goochie changed the title TImestamp not included in searchTx() response Timestamp not included in searchTx() response Jun 17, 2022
@Goochie
Copy link
Author

Goochie commented Jun 18, 2022

I have decoded the transaction and that doesn't hold a timestamp ... what am i missing

decodeTxRawFunc(transactions[0].tx)

@webmaster128
Copy link
Member

Transactions don't have a timestamp. The only time that exists is the timestamp of the block in which the transaction was executed. To get that you need to take the height and query the block information at that height.

@webmaster128 webmaster128 added the Question ❓ User question label Jun 20, 2022
@Goochie
Copy link
Author

Goochie commented Jun 22, 2022

Thanks again :) ...... the only thing i would add is that when using the REST api you get all transactions and the timestamp ... this is where a lot of my confusion stems ie i was using the REST end points to test out data fetch ie /cosmos/tx/v1beta1/txs .... then moved to cosmJS and nothing made sense but that is all part of on boarding yourself to new tech ...... once again thanks.

@webmaster128
Copy link
Member

Yeah, right, makes sense. The reason is that the "REST" API server does exactly what I described behind the scenes to provide a convenient response to users. It's always the block time of the block in which the transaction is executed.

@webmaster128
Copy link
Member

Closing as resolved. Please feel free to re-open if you have follow-up questions that fall under the same title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question ❓ User question
Projects
None yet
Development

No branches or pull requests

2 participants