Let Registry constructor argument override types

This commit is contained in:
Milan Steiner 2022-02-01 16:17:27 +01:00
parent d9df9dae8e
commit 7af2c64732
2 changed files with 5 additions and 3 deletions

View File

@ -95,12 +95,13 @@ export class Registry {
* change the `customTypes` argument to override the default types if set.
* See https://github.com/cosmos/cosmjs/issues/994
*/
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

@ -72,6 +72,7 @@ import { calculateFee, GasPrice } from "./fee";
import { DeliverTxResponse, StargateClient } from "./stargateclient";
export const defaultRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [
["/cosmos.base.v1beta1.Coin", Coin],
["/cosmos.bank.v1beta1.MsgMultiSend", MsgMultiSend],
["/cosmos.distribution.v1beta1.MsgFundCommunityPool", MsgFundCommunityPool],
["/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", MsgSetWithdrawAddress],