diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f3f24c0..0ddbe274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,12 +36,16 @@ and this project adheres to - @cosmjs/stargate and @cosmjs/cosmwasm-stargate: Add simulation support ([#931]). - @cosmjs/tendermint-rpc: Remove `Tendermint33Client` and related symbols. +- @cosmjs/cosmwasm-stargate: Add support for wasmd 0.21. This changes the AMINO + JSON representation of `Msg{Execute,Instantiate,Migrate}Contract.msg` from + base64 strings to JSON objects. ([#948]) [#865]: https://github.com/cosmos/cosmjs/issues/865 [#897]: https://github.com/cosmos/cosmjs/issues/897 [#928]: https://github.com/cosmos/cosmjs/issues/928 [#931]: https://github.com/cosmos/cosmjs/pull/931 [#709]: https://github.com/cosmos/cosmjs/issues/709 +[#948]: https://github.com/cosmos/cosmjs/pull/948 ## [0.26.5] - 2021-11-20 diff --git a/packages/cosmwasm-stargate/README.md b/packages/cosmwasm-stargate/README.md index ce7fbd2f..213de50a 100644 --- a/packages/cosmwasm-stargate/README.md +++ b/packages/cosmwasm-stargate/README.md @@ -8,6 +8,7 @@ An SDK to build CosmWasm clients. | CosmWasm | x/wasm | @cosmjs/cosmwasm-stargate | | --------------- | --------- | ------------------------- | +| 0.16-1.0.0-beta | 0.21 | `^0.27.0` | | 0.16-1.0.0-beta | 0.18-0.20 | `^0.26.0` | | 0.14 | 0.16 | `^0.25.0` | | 0.13 | 0.14-0.15 | `^0.24.0` | diff --git a/packages/cosmwasm-stargate/src/aminotypes.spec.ts b/packages/cosmwasm-stargate/src/aminotypes.spec.ts index 31f4e30f..85739353 100644 --- a/packages/cosmwasm-stargate/src/aminotypes.spec.ts +++ b/packages/cosmwasm-stargate/src/aminotypes.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { fromBase64, toBase64, toUtf8 } from "@cosmjs/encoding"; +import { fromBase64, toUtf8 } from "@cosmjs/encoding"; import { AminoTypes, coins } from "@cosmjs/stargate"; import { MsgClearAdmin, @@ -64,7 +64,7 @@ describe("AminoTypes", () => { sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", code_id: "12345", label: "sticky", - msg: toBase64(toUtf8(`{"foo":"bar"}`)), + msg: { foo: "bar" }, funds: coins(1234, "ucosm"), admin: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", }, @@ -92,7 +92,7 @@ describe("AminoTypes", () => { sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", code_id: "12345", label: "sticky", - msg: toBase64(toUtf8(`{"foo":"bar"}`)), + msg: { foo: "bar" }, funds: coins(1234, "ucosm"), admin: undefined, }, @@ -157,7 +157,7 @@ describe("AminoTypes", () => { value: { sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", - msg: toBase64(toUtf8(`{"foo":"bar"}`)), + msg: { foo: "bar" }, funds: coins(1234, "ucosm"), }, }; @@ -181,7 +181,7 @@ describe("AminoTypes", () => { sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", code_id: "98765", - msg: toBase64(toUtf8(`{"foo":"bar"}`)), + msg: { foo: "bar" }, }, }; expect(aminoMsg).toEqual(expected); @@ -218,7 +218,7 @@ describe("AminoTypes", () => { sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", code_id: "12345", label: "sticky", - msg: toBase64(toUtf8(`{"foo":"bar"}`)), + msg: { foo: "bar" }, funds: coins(1234, "ucosm"), admin: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5", }, @@ -246,7 +246,7 @@ describe("AminoTypes", () => { sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", code_id: "12345", label: "sticky", - msg: toBase64(toUtf8(`{"foo":"bar"}`)), + msg: { foo: "bar" }, funds: coins(1234, "ucosm"), }, }; @@ -312,7 +312,7 @@ describe("AminoTypes", () => { value: { sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", - msg: toBase64(toUtf8(`{"foo":"bar"}`)), + msg: { foo: "bar" }, funds: coins(1234, "ucosm"), }, }; @@ -336,7 +336,7 @@ describe("AminoTypes", () => { sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6", contract: "cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k", code_id: "98765", - msg: toBase64(toUtf8(`{"foo":"bar"}`)), + msg: { foo: "bar" }, }, }; const msg = new AminoTypes({ additions: cosmWasmTypes }).fromAmino(aminoMsg); diff --git a/packages/cosmwasm-stargate/src/aminotypes.ts b/packages/cosmwasm-stargate/src/aminotypes.ts index 202bb4a5..b9aa88da 100644 --- a/packages/cosmwasm-stargate/src/aminotypes.ts +++ b/packages/cosmwasm-stargate/src/aminotypes.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { fromBase64, toBase64 } from "@cosmjs/encoding"; +import { fromBase64, fromUtf8, toBase64, toUtf8 } from "@cosmjs/encoding"; import { AminoConverter, Coin } from "@cosmjs/stargate"; import { MsgClearAdmin, @@ -45,8 +45,8 @@ export interface AminoMsgExecuteContract { readonly sender: string; /** Bech32 account address */ readonly contract: string; - /** Execute message as base64 encoded JSON */ - readonly msg: string; + /** Execute message as JavaScript object */ + readonly msg: any; readonly funds: readonly Coin[]; }; } @@ -65,8 +65,8 @@ export interface AminoMsgInstantiateContract { readonly code_id: string; /** Human-readable label for this contract */ readonly label: string; - /** Instantiate message as base64 encoded JSON */ - readonly msg: string; + /** Instantiate message as JavaScript object */ + readonly msg: any; readonly funds: readonly Coin[]; /** Bech32-encoded admin address */ readonly admin?: string; @@ -87,8 +87,8 @@ export interface AminoMsgMigrateContract { readonly contract: string; /** The new code */ readonly code_id: string; - /** Migrate message as base64 encoded JSON */ - readonly msg: string; + /** Migrate message as JavaScript object */ + readonly msg: any; }; } @@ -150,7 +150,7 @@ export const cosmWasmTypes: Record = { sender: sender, code_id: codeId.toString(), label: label, - msg: toBase64(msg), + msg: JSON.parse(fromUtf8(msg)), funds: funds, admin: admin || undefined, }), @@ -165,7 +165,7 @@ export const cosmWasmTypes: Record = { sender: sender, codeId: Long.fromString(code_id), label: label, - msg: fromBase64(msg), + msg: toUtf8(JSON.stringify(msg)), funds: [...funds], admin: admin ?? "", }), @@ -199,13 +199,13 @@ export const cosmWasmTypes: Record = { toAmino: ({ sender, contract, msg, funds }: MsgExecuteContract): AminoMsgExecuteContract["value"] => ({ sender: sender, contract: contract, - msg: toBase64(msg), + msg: JSON.parse(fromUtf8(msg)), funds: funds, }), fromAmino: ({ sender, contract, msg, funds }: AminoMsgExecuteContract["value"]): MsgExecuteContract => ({ sender: sender, contract: contract, - msg: fromBase64(msg), + msg: toUtf8(JSON.stringify(msg)), funds: [...funds], }), }, @@ -215,7 +215,7 @@ export const cosmWasmTypes: Record = { sender: sender, contract: contract, code_id: codeId.toString(), - msg: toBase64(msg), + msg: JSON.parse(fromUtf8(msg)), }), fromAmino: ({ sender, @@ -226,7 +226,7 @@ export const cosmWasmTypes: Record = { sender: sender, contract: contract, codeId: Long.fromString(code_id), - msg: fromBase64(msg), + msg: toUtf8(JSON.stringify(msg)), }), }, }; diff --git a/scripts/wasmd/env b/scripts/wasmd/env index af8496cf..8e350f38 100644 --- a/scripts/wasmd/env +++ b/scripts/wasmd/env @@ -1,5 +1,5 @@ # Choose from https://hub.docker.com/r/cosmwasm/wasmd/tags REPOSITORY="cosmwasm/wasmd" -VERSION="v0.20.0" +VERSION="v0.21.0" CONTAINER_NAME="wasmd"