Merge branch 'add-new-msgs' of github.com:cosmos/cosmjs into add-new-msgs

This commit is contained in:
Milan Steiner 2022-02-07 09:11:07 +01:00
commit c99fe5653d
5 changed files with 22 additions and 21 deletions

View File

@ -13,8 +13,14 @@ and this project adheres to
`AminoTypesOptions`. This is an object with a required `prefix` field. Before
the prefix defaulted to "cosmos" but this is almost never the right choice for
CosmJS users that need to add Amino types manually. ([#989])
- @cosmjs/stargate: `MsgSend` and `Coin` are now parts of `defaultRegistryTypes`. ([#994])
- @cosmjs/proto-signing: `Registry`'s constructor can now override default types. ([#994])
- @cosmjs/tendermint-rpc: The property `evidence` in the interface `Block` is now
non-optional. ([#1011])
[#989]: https://github.com/cosmos/cosmjs/issues/989
[#994]: https://github.com/cosmos/cosmjs/issues/994
[#1011]: https://github.com/cosmos/cosmjs/issues/1011
### Removed

View File

@ -81,26 +81,20 @@ export class Registry {
* actual implementations. Those implementations are typically generated with ts-proto
* but we also support protobuf.js as a type generator.
*
* By default, a `new Registry()` constains amost no types. `Coin` and `MsgSend` are in there
* for historic reasons but this does not make a lot of sense.
* If there is no parameter given, a `new Registry()` adds the types `Coin` and `MsgSend`
* for historic reasons. Those can be overriden by customTypes.
*
* There are currently two methods for adding new types:
* 1. Using the `register()` method
* 2. Passing custom types to the constructor.
* This only creates confusion for users. The reason here is historical.
* Using `register()` is recommended and 2. is deprecated because its behaviour
* will change in https://github.com/cosmos/cosmjs/issues/994.
*
* There is currently no way to unregister/override the default types. We should
* change the `customTypes` argument to override the default types if set.
* See https://github.com/cosmos/cosmjs/issues/994
* 1. Passing types to the constructor.
* 2. Using the `register()` method
*/
public constructor(customTypes: Iterable<[string, GeneratedType]> = []) {
public constructor(customTypes?: Iterable<[string, GeneratedType]>) {
const { cosmosCoin, cosmosMsgSend } = defaultTypeUrls;
this.types = new Map<string, GeneratedType>([
this.types = customTypes
? new Map<string, GeneratedType>([...customTypes])
: new Map<string, GeneratedType>([
[cosmosCoin, Coin],
[cosmosMsgSend, MsgSend],
...customTypes,
]);
}

View File

@ -15,7 +15,7 @@ import {
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
import { assert, assertDefined } from "@cosmjs/utils";
import { MsgExec, MsgGrant, MsgRevoke } from "cosmjs-types/cosmos/authz/v1beta1/tx";
import { MsgMultiSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { MsgMultiSend, MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { Coin } from "cosmjs-types/cosmos/base/v1beta1/coin";
import {
MsgFundCommunityPool,
@ -74,6 +74,8 @@ import { calculateFee, GasPrice } from "./fee";
import { DeliverTxResponse, StargateClient } from "./stargateclient";
export const defaultRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [
["/cosmos.base.v1beta1.Coin", Coin],
["/cosmos.bank.v1beta1.MsgSend", MsgSend],
["/cosmos.bank.v1beta1.MsgMultiSend", MsgMultiSend],
["/cosmos.distribution.v1beta1.MsgFundCommunityPool", MsgFundCommunityPool],
["/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", MsgSetWithdrawAddress],

View File

@ -757,7 +757,7 @@ function decodeBlock(data: RpcBlock): responses.Block {
txs: data.data.txs ? assertArray(data.data.txs).map(fromBase64) : [],
// Lift up .evidence.evidence to just .evidence
// See https://github.com/tendermint/tendermint/issues/7697
evidence: data.evidence?.evidence,
evidence: data.evidence?.evidence ?? [],
};
}

View File

@ -227,8 +227,7 @@ export interface Block {
*/
readonly lastCommit: Commit | null;
readonly txs: readonly Uint8Array[];
// This field becomes non-optional in 0.28 (https://github.com/cosmos/cosmjs/issues/1011)
readonly evidence?: readonly Evidence[];
readonly evidence: readonly Evidence[];
}
/**