diff --git a/CHANGELOG.md b/CHANGELOG.md index dece7b1a..4644d4aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,12 +28,16 @@ and this project adheres to `createWasmAminoConverters()` instead. - @cosmjs/encoding: Remove previously deprecated `Bech32` class. Please replace `Bech32.encode`/`.decode` with free the functions `toBech32`/`fromBech32`. +- @cosmjs/cosmwasm-stargate: Changed the `SigningCosmWasmClient` constructor to + include all Amino type converters that the `SigningStargateClient` uses by + default, to match the default registry types ([#1384]). [#1002]: https://github.com/cosmos/cosmjs/issues/1002 [#1240]: https://github.com/cosmos/cosmjs/pull/1240 [#1289]: https://github.com/cosmos/cosmjs/issues/1289 [#1291]: https://github.com/cosmos/cosmjs/issues/1291 [#1329]: https://github.com/cosmos/cosmjs/pull/1329 +[#1384]: https://github.com/cosmos/cosmjs/pull/1384 ### Added @@ -54,11 +58,15 @@ and this project adheres to addresses for Instantiate2 ([#1253]). - @cosmjs/stargate: Add `txIndex` to `DeliverTxResponse` and `IndexedTx` ([#1361]). +- @cosmjs/stargate: Add `createDefaultAminoConverters` to access the + `SigningStargateClient`'s list of default Amino type converters to match the + default registry types in `defaultStargateTypes` ([#1384]). [#1253]: https://github.com/cosmos/cosmjs/pull/1253 [#1308]: https://github.com/cosmos/cosmjs/pull/1308 [#1361]: https://github.com/cosmos/cosmjs/issues/1361 [#1376]: https://github.com/cosmos/cosmjs/pull/1376 +[#1384]: https://github.com/cosmos/cosmjs/pull/1384 ## [0.29.5] - 2022-12-07 diff --git a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts index 6cdad852..03f6fe2f 100644 --- a/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm-stargate/src/signingcosmwasmclient.ts @@ -17,7 +17,7 @@ import { AminoTypes, calculateFee, Coin, - createBankAminoConverters, + createDefaultAminoConverters, defaultRegistryTypes as defaultStargateTypes, DeliverTxResponse, Event, @@ -162,10 +162,6 @@ function createDeliverTxResponseErrorMessage(result: DeliverTxResponse): string return `Error when broadcasting tx ${result.transactionHash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.rawLog}`; } -function createDefaultRegistry(): Registry { - return new Registry([...defaultStargateTypes, ...wasmTypes]); -} - export interface SigningCosmWasmClientOptions { readonly registry?: Registry; readonly aminoTypes?: AminoTypes; @@ -233,8 +229,11 @@ export class SigningCosmWasmClient extends CosmWasmClient { ) { super(tmClient); const { - registry = createDefaultRegistry(), - aminoTypes = new AminoTypes({ ...createWasmAminoConverters(), ...createBankAminoConverters() }), + registry = new Registry([...defaultStargateTypes, ...wasmTypes]), + aminoTypes = new AminoTypes({ + ...createDefaultAminoConverters(), + ...createWasmAminoConverters(), + }), } = options; this.registry = registry; this.aminoTypes = aminoTypes; diff --git a/packages/stargate/src/index.ts b/packages/stargate/src/index.ts index 62560972..23720d37 100644 --- a/packages/stargate/src/index.ts +++ b/packages/stargate/src/index.ts @@ -123,6 +123,7 @@ export { SearchTxQuery, } from "./search"; export { + createDefaultAminoConverters, defaultRegistryTypes, SignerData, SigningStargateClient, diff --git a/packages/stargate/src/signingstargateclient.ts b/packages/stargate/src/signingstargateclient.ts index a1efb39b..d782e08c 100644 --- a/packages/stargate/src/signingstargateclient.ts +++ b/packages/stargate/src/signingstargateclient.ts @@ -64,10 +64,6 @@ export const defaultRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [ ...vestingTypes, ]; -function createDefaultRegistry(): Registry { - return new Registry(defaultRegistryTypes); -} - /** * Signing information for a single signer that is not included in the transaction. * @@ -92,7 +88,7 @@ export interface SigningStargateClientOptions extends StargateClientOptions { readonly gasPrice?: GasPrice; } -function createDefaultTypes(): AminoConverters { +export function createDefaultAminoConverters(): AminoConverters { return { ...createAuthzAminoConverters(), ...createBankAminoConverters(), @@ -163,7 +159,10 @@ export class SigningStargateClient extends StargateClient { options: SigningStargateClientOptions, ) { super(tmClient, options); - const { registry = createDefaultRegistry(), aminoTypes = new AminoTypes(createDefaultTypes()) } = options; + const { + registry = new Registry(defaultRegistryTypes), + aminoTypes = new AminoTypes(createDefaultAminoConverters()), + } = options; this.registry = registry; this.aminoTypes = aminoTypes; this.signer = signer;