stargate: Add logs helper

This commit is contained in:
willclarktech 2020-12-09 15:49:37 +00:00
parent 879a733b5b
commit 4b35668981
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
4 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,6 @@
export * as codec from "./codec";
export { getMsgType, getMsgTypeUrl } from "./encoding";
export { parseRawLog } from "./logs";
export {
AuthExtension,
BankExtension,

View File

@ -0,0 +1,11 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { logs } from "@cosmjs/launchpad";
export function parseRawLog(input = "[]"): readonly logs.Log[] {
const logsToParse = JSON.parse(input).map(({ events }: { events: readonly unknown[] }, i: number) => ({
msg_index: i,
events,
log: "",
}));
return logs.parseLogs(logsToParse);
}

View File

@ -1,5 +1,6 @@
export * as codec from "./codec";
export { getMsgType, getMsgTypeUrl } from "./encoding";
export { parseRawLog } from "./logs";
export {
AuthExtension,
BankExtension,

2
packages/stargate/types/logs.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import { logs } from "@cosmjs/launchpad";
export declare function parseRawLog(input?: string): readonly logs.Log[];