mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
Merge branch 'main' into add-new-msgs
This commit is contained in:
commit
cc2ff476c0
@ -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
|
||||
|
||||
|
@ -81,27 +81,21 @@ 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>([
|
||||
[cosmosCoin, Coin],
|
||||
[cosmosMsgSend, MsgSend],
|
||||
...customTypes,
|
||||
]);
|
||||
this.types = customTypes
|
||||
? new Map<string, GeneratedType>([...customTypes])
|
||||
: new Map<string, GeneratedType>([
|
||||
[cosmosCoin, Coin],
|
||||
[cosmosMsgSend, MsgSend],
|
||||
]);
|
||||
}
|
||||
|
||||
public register(typeUrl: string, type: GeneratedType): void {
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
|
||||
import { assert, assertDefined } from "@cosmjs/utils";
|
||||
import { MsgExec, MsgGrant, MsgRevoke } from "cosmjs-types/authz/staking/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],
|
||||
|
@ -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 ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user