From 7af2c64732d028b4a0bc76e2ad1ff413fa024290 Mon Sep 17 00:00:00 2001 From: Milan Steiner Date: Tue, 1 Feb 2022 16:17:27 +0100 Subject: [PATCH] Let Registry constructor argument override types --- packages/proto-signing/src/registry.ts | 7 ++++--- packages/stargate/src/signingstargateclient.ts | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/proto-signing/src/registry.ts b/packages/proto-signing/src/registry.ts index 90dbf127..760db180 100644 --- a/packages/proto-signing/src/registry.ts +++ b/packages/proto-signing/src/registry.ts @@ -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([ + this.types = customTypes ? new Map([ + ...customTypes + ]) : new Map([ [cosmosCoin, Coin], [cosmosMsgSend, MsgSend], - ...customTypes, ]); } diff --git a/packages/stargate/src/signingstargateclient.ts b/packages/stargate/src/signingstargateclient.ts index 0d34e1c7..5b00c2cf 100644 --- a/packages/stargate/src/signingstargateclient.ts +++ b/packages/stargate/src/signingstargateclient.ts @@ -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],