tendermint-rpc: Add gas and code space to tx data

This commit is contained in:
willclarktech 2021-04-14 12:35:49 +02:00
parent 212318d2a8
commit b25171cfef
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
2 changed files with 11 additions and 3 deletions

View File

@ -126,19 +126,25 @@ function decodeEvents(events: readonly RpcEvent[]): readonly responses.Event[] {
}
interface RpcTxData {
readonly codespace?: string;
readonly code?: number;
readonly log?: string;
/** base64 encoded */
readonly data?: string;
readonly events?: readonly RpcEvent[];
readonly gas_wanted?: string;
readonly gas_used?: string;
}
function decodeTxData(data: RpcTxData): responses.TxData {
return {
data: may(fromBase64, data.data),
log: data.log,
code: Integer.parse(assertNumber(optional<number>(data.code, 0))),
codeSpace: data.codespace,
log: data.log,
data: may(fromBase64, data.data),
events: data.events ? decodeEvents(data.events) : [],
gasWanted: Integer.parse(optional<string>(data.gas_wanted, "0")),
gasUsed: Integer.parse(optional<string>(data.gas_used, "0")),
};
}

View File

@ -176,10 +176,12 @@ export interface Event {
export interface TxData {
readonly code: number;
readonly codeSpace?: string;
readonly log?: string;
readonly data?: Uint8Array;
readonly events: readonly Event[];
// readonly fees?: any;
readonly gasWanted: number;
readonly gasUsed: number;
}
export interface TxProof {