tendermint-rpc: Update BroadcastTxCommitResponse type

This commit is contained in:
willclarktech 2020-08-12 13:19:19 +02:00
parent 53b216d1fb
commit d9520990dd
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
3 changed files with 11 additions and 11 deletions

View File

@ -69,20 +69,20 @@ export function broadcastTxSyncSuccess(res: BroadcastTxSyncResponse): boolean {
}
export interface BroadcastTxCommitResponse {
readonly height?: number;
readonly height: number;
readonly hash: TxHash;
readonly checkTx: TxData;
readonly deliverTx?: TxData;
}
/**
* Returns true iff transaction made it sucessfully into a block
* (i.e. sucess in `check_tx` and `deliver_tx` field)
* Returns true iff transaction made it successfully into a block
* (i.e. success in `check_tx` and `deliver_tx` field)
*/
export function broadcastTxCommitSuccess(res: BroadcastTxCommitResponse): boolean {
export function broadcastTxCommitSuccess(response: BroadcastTxCommitResponse): boolean {
// code must be 0 on success
// deliverTx may be present but empty on failure
return res.checkTx.code === 0 && !!res.deliverTx && res.deliverTx.code === 0;
return response.checkTx.code === 0 && !!response.deliverTx && response.deliverTx.code === 0;
}
export interface CommitResponse {

View File

@ -345,7 +345,7 @@ function decodeBroadcastTxSync(data: RpcBroadcastTxSyncResponse): responses.Broa
}
interface RpcBroadcastTxCommitResponse {
readonly height?: IntegerString;
readonly height: IntegerString;
readonly hash: HexString;
readonly check_tx: RpcTxData;
readonly deliver_tx?: RpcTxData;
@ -353,7 +353,7 @@ interface RpcBroadcastTxCommitResponse {
function decodeBroadcastTxCommit(data: RpcBroadcastTxCommitResponse): responses.BroadcastTxCommitResponse {
return {
height: may(Integer.parse, data.height),
height: Integer.parse(data.height),
hash: fromHex(assertNotEmpty(data.hash)) as TxHash,
checkTx: decodeTxData(assertObject(data.check_tx)),
deliverTx: may(decodeTxData, data.deliver_tx),

View File

@ -55,16 +55,16 @@ export interface BroadcastTxSyncResponse extends TxData {
*/
export declare function broadcastTxSyncSuccess(res: BroadcastTxSyncResponse): boolean;
export interface BroadcastTxCommitResponse {
readonly height?: number;
readonly height: number;
readonly hash: TxHash;
readonly checkTx: TxData;
readonly deliverTx?: TxData;
}
/**
* Returns true iff transaction made it sucessfully into a block
* (i.e. sucess in `check_tx` and `deliver_tx` field)
* Returns true iff transaction made it successfully into a block
* (i.e. success in `check_tx` and `deliver_tx` field)
*/
export declare function broadcastTxCommitSuccess(res: BroadcastTxCommitResponse): boolean;
export declare function broadcastTxCommitSuccess(response: BroadcastTxCommitResponse): boolean;
export interface CommitResponse {
readonly header: Header;
readonly commit: Commit;