-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for finding a transaction directly by its hash. In theory this endpoint should have read-your-writes (RYW) consistency whereas `/tx_search` does not. See: tendermint/tendermint#6359
- Loading branch information
Showing
9 changed files
with
356 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//! `/tx` endpoint JSON-RPC wrapper | ||
use crate::Method; | ||
use serde::{Deserialize, Serialize}; | ||
use tendermint::{abci, block}; | ||
use tendermint_proto::types::TxProof; | ||
|
||
/// Request for finding a transaction by its hash. | ||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] | ||
pub struct Request { | ||
pub hash: String, | ||
pub prove: bool, | ||
} | ||
|
||
impl Request { | ||
/// Constructor. | ||
pub fn new(hash: abci::transaction::Hash, prove: bool) -> Self { | ||
Self { | ||
hash: format!("0x{}", &hash), | ||
prove, | ||
} | ||
} | ||
} | ||
|
||
impl crate::Request for Request { | ||
type Response = Response; | ||
|
||
fn method(&self) -> Method { | ||
Method::Tx | ||
} | ||
} | ||
|
||
impl crate::SimpleRequest for Request {} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct Response { | ||
pub hash: abci::transaction::Hash, | ||
pub height: block::Height, | ||
pub index: u32, | ||
pub tx_result: abci::DeliverTx, | ||
pub tx: abci::Transaction, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub proof: Option<TxProof>, | ||
} | ||
|
||
impl crate::Response for Response {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": -1, | ||
"result": { | ||
"hash": "291B44C883803751917D547238EAC419E968C0171A3154D777B2EA8EA5039C57", | ||
"height": "2", | ||
"index": 0, | ||
"tx_result": { | ||
"code": 0, | ||
"data": "CgYKBHNlbmQ=", | ||
"log": "[{\"events\":[{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"send\"},{\"key\":\"sender\",\"value\":\"cosmos1s2tw45c7stsafk42vsz9sj09jm09y6tk4qeerh\"},{\"key\":\"module\",\"value\":\"bank\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"cosmos1nv3uf7hpuvk4em39vxr944hphujtuqa2xl7688\"},{\"key\":\"sender\",\"value\":\"cosmos1s2tw45c7stsafk42vsz9sj09jm09y6tk4qeerh\"},{\"key\":\"amount\",\"value\":\"1samoleans\"}]}]}]", | ||
"info": "", | ||
"gas_wanted": "100000", | ||
"gas_used": "75848", | ||
"events": [ | ||
{ | ||
"type": "transfer", | ||
"attributes": [ | ||
{ | ||
"key": "cmVjaXBpZW50", | ||
"value": "Y29zbW9zMTd4cGZ2YWttMmFtZzk2MnlsczZmODR6M2tlbGw4YzVsc2VycXRh", | ||
"index": true | ||
}, | ||
{ | ||
"key": "c2VuZGVy", | ||
"value": "Y29zbW9zMXMydHc0NWM3c3RzYWZrNDJ2c3o5c2owOWptMDl5NnRrNHFlZXJo", | ||
"index": true | ||
}, | ||
{ | ||
"key": "YW1vdW50", | ||
"value": "MXNhbW9sZWFucw==", | ||
"index": true | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "message", | ||
"attributes": [ | ||
{ | ||
"key": "c2VuZGVy", | ||
"value": "Y29zbW9zMXMydHc0NWM3c3RzYWZrNDJ2c3o5c2owOWptMDl5NnRrNHFlZXJo", | ||
"index": true | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "message", | ||
"attributes": [ | ||
{ | ||
"key": "YWN0aW9u", | ||
"value": "c2VuZA==", | ||
"index": true | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "transfer", | ||
"attributes": [ | ||
{ | ||
"key": "cmVjaXBpZW50", | ||
"value": "Y29zbW9zMW52M3VmN2hwdXZrNGVtMzl2eHI5NDRocGh1anR1cWEyeGw3Njg4", | ||
"index": true | ||
}, | ||
{ | ||
"key": "c2VuZGVy", | ||
"value": "Y29zbW9zMXMydHc0NWM3c3RzYWZrNDJ2c3o5c2owOWptMDl5NnRrNHFlZXJo", | ||
"index": true | ||
}, | ||
{ | ||
"key": "YW1vdW50", | ||
"value": "MXNhbW9sZWFucw==", | ||
"index": true | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "message", | ||
"attributes": [ | ||
{ | ||
"key": "c2VuZGVy", | ||
"value": "Y29zbW9zMXMydHc0NWM3c3RzYWZrNDJ2c3o5c2owOWptMDl5NnRrNHFlZXJo", | ||
"index": true | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "message", | ||
"attributes": [ | ||
{ | ||
"key": "bW9kdWxl", | ||
"value": "YmFuaw==", | ||
"index": true | ||
} | ||
] | ||
} | ||
], | ||
"codespace": "" | ||
}, | ||
"tx": "Cp8BCo4BChwvY29zbW9zLmJhbmsudjFiZXRhMS5Nc2dTZW5kEm4KLWNvc21vczFzMnR3NDVjN3N0c2FmazQydnN6OXNqMDlqbTA5eTZ0azRxZWVyaBItY29zbW9zMW52M3VmN2hwdXZrNGVtMzl2eHI5NDRocGh1anR1cWEyeGw3Njg4Gg4KCXNhbW9sZWFucxIBMRIJdGVzdCBtZW1vGKlGEmYKTgpGCh8vY29zbW9zLmNyeXB0by5zZWNwMjU2azEuUHViS2V5EiMKIQNi056vvgeqQgAUg8xRONa/j2XDlX7qcjc67RonX3JvpBIECgIIARIUCg4KCXNhbW9sZWFucxIBMRCgjQYaQLnVzSrnFPAOZ7wpXnQ3tR651N2DkYQgU9//VQrc03ysHZg3W8dVpbpEVxYO69ArPl2B5O3eTZL1a3utE0marvk=" | ||
} | ||
} |
Oops, something went wrong.