Rename fromTendermint34Event to fromTendermintEvent
and let it support both Tendermint 0.34 and 0.37 events as input
This commit is contained in:
parent
3d0546a582
commit
3daa7b6c4a
@ -21,6 +21,8 @@ and this project adheres to
|
||||
- @cosmjs/proto-signing: Remove `fromJSON`/`toJSON` from `TsProtoGeneratedType`
|
||||
such that generated types are not required to generate those anymore. The
|
||||
methods were provided by ts-proto but we never needed them. ([#1329])
|
||||
- @cosmjs/stargate: Rename `fromTendermint34Event` to `fromTendermintEvent` and
|
||||
let it support both Tendermint 0.34 and 0.37 events as input.
|
||||
|
||||
[#1002]: https://github.com/cosmos/cosmjs/issues/1002
|
||||
[#1240]: https://github.com/cosmos/cosmjs/pull/1240
|
||||
|
||||
@ -10,7 +10,7 @@ import {
|
||||
BroadcastTxError,
|
||||
Coin,
|
||||
DeliverTxResponse,
|
||||
fromTendermint34Event,
|
||||
fromTendermintEvent,
|
||||
IndexedTx,
|
||||
isSearchByHeightQuery,
|
||||
isSearchBySentFromOrToQuery,
|
||||
@ -464,7 +464,7 @@ export class CosmWasmClient {
|
||||
height: tx.height,
|
||||
hash: toHex(tx.hash).toUpperCase(),
|
||||
code: tx.result.code,
|
||||
events: tx.result.events.map(fromTendermint34Event),
|
||||
events: tx.result.events.map(fromTendermintEvent),
|
||||
rawLog: tx.result.log || "",
|
||||
tx: tx.tx,
|
||||
gasUsed: tx.result.gasUsed,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { fromUtf8 } from "@cosmjs/encoding";
|
||||
import { tendermint34 } from "@cosmjs/tendermint-rpc";
|
||||
import { tendermint34, tendermint37 } from "@cosmjs/tendermint-rpc";
|
||||
|
||||
/**
|
||||
* An event attribute.
|
||||
@ -30,16 +30,16 @@ export interface Event {
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a Tendemrint 0.34 event with binary encoded key and value
|
||||
* Takes a Tendermint 0.34 or 0.37 event with binary encoded key and value
|
||||
* and converts it into an `Event` with string attributes.
|
||||
*/
|
||||
export function fromTendermint34Event(event: tendermint34.Event): Event {
|
||||
export function fromTendermintEvent(event: tendermint34.Event | tendermint37.Event): Event {
|
||||
return {
|
||||
type: event.type,
|
||||
attributes: event.attributes.map(
|
||||
(attr): Attribute => ({
|
||||
key: fromUtf8(attr.key, true),
|
||||
value: fromUtf8(attr.value, true),
|
||||
key: typeof attr.key == "string" ? attr.key : fromUtf8(attr.key, true),
|
||||
value: typeof attr.value == "string" ? attr.value : fromUtf8(attr.value, true),
|
||||
}),
|
||||
),
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
export { Account, accountFromAny, AccountParser } from "./accounts";
|
||||
export { AminoConverter, AminoConverters, AminoTypes } from "./aminotypes";
|
||||
export { Attribute, Event, fromTendermint34Event } from "./events";
|
||||
export { Attribute, Event, fromTendermintEvent } from "./events";
|
||||
export { calculateFee, GasPrice } from "./fee";
|
||||
export * as logs from "./logs";
|
||||
export {
|
||||
|
||||
@ -10,7 +10,7 @@ import { QueryDelegatorDelegationsResponse } from "cosmjs-types/cosmos/staking/v
|
||||
import { DelegationResponse } from "cosmjs-types/cosmos/staking/v1beta1/staking";
|
||||
|
||||
import { Account, accountFromAny, AccountParser } from "./accounts";
|
||||
import { Event, fromTendermint34Event } from "./events";
|
||||
import { Event, fromTendermintEvent } from "./events";
|
||||
import {
|
||||
AuthExtension,
|
||||
BankExtension,
|
||||
@ -471,7 +471,7 @@ export class StargateClient {
|
||||
height: tx.height,
|
||||
hash: toHex(tx.hash).toUpperCase(),
|
||||
code: tx.result.code,
|
||||
events: tx.result.events.map(fromTendermint34Event),
|
||||
events: tx.result.events.map(fromTendermintEvent),
|
||||
rawLog: tx.result.log || "",
|
||||
tx: tx.tx,
|
||||
gasUsed: tx.result.gasUsed,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user