tendermint-rpc: Update BroadcastTxCommitResponse type
This commit is contained in:
parent
53b216d1fb
commit
d9520990dd
@ -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 {
|
||||
|
||||
@ -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),
|
||||
|
||||
8
packages/tendermint-rpc/types/responses.d.ts
vendored
8
packages/tendermint-rpc/types/responses.d.ts
vendored
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user