diff --git a/CHANGELOG.md b/CHANGELOG.md index 264926d868..9b3c174511 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to waiting for block inclusion. ([#1396]) - @cosmjs/cosmwasm-stargate: Add Amino JSON support for `MsgStoreCode.instantiate_permission`. ([#334]) +- @cosmjs/stargate: Add group and gov v1 message types [#334]: https://github.com/cosmos/cosmjs/issues/334 [#1266]: https://github.com/cosmos/cosmjs/issues/1266 diff --git a/packages/stargate/src/index.ts b/packages/stargate/src/index.ts index 5a41e4dfad..d009351df8 100644 --- a/packages/stargate/src/index.ts +++ b/packages/stargate/src/index.ts @@ -33,6 +33,7 @@ export { createEvidenceAminoConverters, createFeegrantAminoConverters, createGovAminoConverters, + createGroupAminoConverters, createIbcAminoConverters, createSlashingAminoConverters, createStakingAminoConverters, diff --git a/packages/stargate/src/modules/gov/aminomessages.ts b/packages/stargate/src/modules/gov/aminomessages.ts index e4de005a4a..d364f46830 100644 --- a/packages/stargate/src/modules/gov/aminomessages.ts +++ b/packages/stargate/src/modules/gov/aminomessages.ts @@ -103,6 +103,9 @@ export function isAminoMsgDeposit(msg: AminoMsg): msg is AminoMsgDeposit { } export function createGovAminoConverters(): AminoConverters { + // Gov v1 types missing, see + // https://github.com/cosmos/cosmjs/issues/1442 + return { "/cosmos.gov.v1beta1.MsgDeposit": { aminoType: "cosmos-sdk/MsgDeposit", diff --git a/packages/stargate/src/modules/gov/messages.ts b/packages/stargate/src/modules/gov/messages.ts index d926e389ef..334e5d7d00 100644 --- a/packages/stargate/src/modules/gov/messages.ts +++ b/packages/stargate/src/modules/gov/messages.ts @@ -1,13 +1,35 @@ import { EncodeObject, GeneratedType } from "@cosmjs/proto-signing"; +import { + MsgDeposit as V1MsgDeposit, + MsgSubmitProposal as V1MsgSubmitProposal, + MsgUpdateParams as V1MsgUpdateParams, + MsgVote as V1MsgVote, + MsgVoteWeighted as V1MsgVoteWeighted, +} from "cosmjs-types/cosmos/gov/v1/tx"; import { MsgDeposit, MsgSubmitProposal, MsgVote, MsgVoteWeighted } from "cosmjs-types/cosmos/gov/v1beta1/tx"; export const govTypes: ReadonlyArray<[string, GeneratedType]> = [ + ["/cosmos.gov.v1.MsgDeposit", V1MsgDeposit], + ["/cosmos.gov.v1.MsgSubmitProposal", V1MsgSubmitProposal], + ["/cosmos.gov.v1.MsgUpdateParams", V1MsgUpdateParams], + ["/cosmos.gov.v1.MsgVote", V1MsgVote], + ["/cosmos.gov.v1.MsgVoteWeighted", V1MsgVoteWeighted], + ["/cosmos.gov.v1beta1.MsgDeposit", MsgDeposit], ["/cosmos.gov.v1beta1.MsgSubmitProposal", MsgSubmitProposal], ["/cosmos.gov.v1beta1.MsgVote", MsgVote], ["/cosmos.gov.v1beta1.MsgVoteWeighted", MsgVoteWeighted], ]; +// There are no EncodeObject implementations for the new v1 message types because +// those things don't scale (https://github.com/cosmos/cosmjs/issues/1440). We need to +// address this more fundamentally. Users can use +// const msg = { +// typeUrl: "/cosmos.gov.v1.MsgDeposit", +// value: MsgDeposit.fromPartial({ ... }) +// } +// in their app. + export interface MsgDepositEncodeObject extends EncodeObject { readonly typeUrl: "/cosmos.gov.v1beta1.MsgDeposit"; readonly value: Partial; diff --git a/packages/stargate/src/modules/group/aminomessages.ts b/packages/stargate/src/modules/group/aminomessages.ts new file mode 100644 index 0000000000..95cd8ba667 --- /dev/null +++ b/packages/stargate/src/modules/group/aminomessages.ts @@ -0,0 +1,6 @@ +import { AminoConverters } from "../../aminotypes"; + +export function createGroupAminoConverters(): AminoConverters { + // Missing, see https://github.com/cosmos/cosmjs/issues/1441 + return {}; +} diff --git a/packages/stargate/src/modules/group/messages.ts b/packages/stargate/src/modules/group/messages.ts new file mode 100644 index 0000000000..951c9a0ad0 --- /dev/null +++ b/packages/stargate/src/modules/group/messages.ts @@ -0,0 +1,43 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { + MsgCreateGroup, + MsgCreateGroupPolicy, + MsgCreateGroupWithPolicy, + MsgExec, + MsgLeaveGroup, + MsgSubmitProposal, + MsgUpdateGroupAdmin, + MsgUpdateGroupMembers, + MsgUpdateGroupMetadata, + MsgUpdateGroupPolicyAdmin, + MsgUpdateGroupPolicyDecisionPolicy, + MsgUpdateGroupPolicyMetadata, + MsgVote, + MsgWithdrawProposal, +} from "cosmjs-types/cosmos/group/v1/tx"; + +export const groupTypes: ReadonlyArray<[string, GeneratedType]> = [ + ["/cosmos.group.v1.MsgCreateGroup", MsgCreateGroup], + ["/cosmos.group.v1.MsgCreateGroupPolicy", MsgCreateGroupPolicy], + ["/cosmos.group.v1.MsgCreateGroupWithPolicy", MsgCreateGroupWithPolicy], + ["/cosmos.group.v1.MsgExec", MsgExec], + ["/cosmos.group.v1.MsgLeaveGroup", MsgLeaveGroup], + ["/cosmos.group.v1.MsgSubmitProposal", MsgSubmitProposal], + ["/cosmos.group.v1.MsgUpdateGroupAdmin", MsgUpdateGroupAdmin], + ["/cosmos.group.v1.MsgUpdateGroupMembers", MsgUpdateGroupMembers], + ["/cosmos.group.v1.MsgUpdateGroupMetadata", MsgUpdateGroupMetadata], + ["/cosmos.group.v1.MsgUpdateGroupPolicyAdmin", MsgUpdateGroupPolicyAdmin], + ["/cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy", MsgUpdateGroupPolicyDecisionPolicy], + ["/cosmos.group.v1.MsgUpdateGroupPolicyMetadata", MsgUpdateGroupPolicyMetadata], + ["/cosmos.group.v1.MsgVote", MsgVote], + ["/cosmos.group.v1.MsgWithdrawProposal", MsgWithdrawProposal], +]; + +// There are no EncodeObject implementations for the new v1 message types because +// those things don't scale (https://github.com/cosmos/cosmjs/issues/1440). We need to +// address this more fundamentally. Users can use +// const msg = { +// typeUrl: "/cosmos.group.v1.MsgCreateGroup", +// value: MsgCreateGroup.fromPartial({ ... }) +// } +// in their app. diff --git a/packages/stargate/src/modules/index.ts b/packages/stargate/src/modules/index.ts index 3a63f0b067..7d41cd24e5 100644 --- a/packages/stargate/src/modules/index.ts +++ b/packages/stargate/src/modules/index.ts @@ -64,6 +64,8 @@ export { MsgVoteWeightedEncodeObject, } from "./gov/messages"; export { GovExtension, GovParamsType, GovProposalId, setupGovExtension } from "./gov/queries"; +export { createGroupAminoConverters } from "./group/aminomessages"; +export { groupTypes } from "./group/messages"; export { AminoMsgTransfer, createIbcAminoConverters, isAminoMsgTransfer } from "./ibc/aminomessages"; export { ibcTypes, isMsgTransferEncodeObject, MsgTransferEncodeObject } from "./ibc/messages"; export { IbcExtension, setupIbcExtension } from "./ibc/queries"; diff --git a/packages/stargate/src/signingstargateclient.ts b/packages/stargate/src/signingstargateclient.ts index 0c089fc7ac..a255629c2c 100644 --- a/packages/stargate/src/signingstargateclient.ts +++ b/packages/stargate/src/signingstargateclient.ts @@ -36,6 +36,7 @@ import { distributionTypes, feegrantTypes, govTypes, + groupTypes, ibcTypes, MsgDelegateEncodeObject, MsgSendEncodeObject, @@ -64,6 +65,7 @@ export const defaultRegistryTypes: ReadonlyArray<[string, GeneratedType]> = [ ...distributionTypes, ...feegrantTypes, ...govTypes, + ...groupTypes, ...stakingTypes, ...ibcTypes, ...vestingTypes,