Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support to MsgUpdateSubspaceFeeTokens #758

Merged
merged 10 commits into from
Aug 29, 2023
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Protoc 👷
uses: arduino/setup-protoc@v2
with:
version: "3.x"
version: "23.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node 👷
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
with:
node-version: 16

- name: Install Protobuf compiler 👷
if: env.GIT_DIFF
run: |
sudo apt-get update
sudo apt-get -y install protobuf-compiler
- name: Setup Protoc 👷
uses: arduino/setup-protoc@v2
with:
version: "23.4"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install 🔨
if: env.GIT_DIFF
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/modules/aminoconverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { AminoConverter as RelationshipsV1AminoConverter } from "./relationships
import { AminoConverter as ReportsV1AminoConverter } from "./reports/v1";
import { AminoConverter as StakingV1Beta1AminoConverter } from "./staking/v1beta1";
import { AminoConverter as SubspacesV3AminoConverter } from "./subspaces/v3";
import { AminoConverter as TokenFactoryV1AminoConverter } from "./tokenfactory/v1";

export const DesmosAminoConverter = {
...createBankAminoConverters(),
Expand All @@ -41,6 +42,7 @@ export const DesmosAminoConverter = {
...ReportsV1AminoConverter,
...StakingV1Beta1AminoConverter,
...SubspacesV3AminoConverter,
...TokenFactoryV1AminoConverter,
};

export default DesmosAminoConverter;
1 change: 1 addition & 0 deletions packages/core/src/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ export * as Reports from "./reports";
export * as Staking from "./staking";
export * as Subspaces from "./subspaces";
export * as Supply from "./supply";
export * as TokenFactory from "./tokenfactory";
6 changes: 6 additions & 0 deletions packages/core/src/modules/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ import {
SubspacesV3Extension,
} from "./subspaces/v3";
import { setupSupplyV1Extension, SupplyV1Extension } from "./supply/v1";
import {
setupTokenFactoryV1Extension,
TokenFactoryV1Extension,
} from "./tokenfactory/v1";

export type DesmosQueryClient = QueryClient &
AuthzV1Beta1Extension &
Expand All @@ -50,6 +54,7 @@ export type DesmosQueryClient = QueryClient &
ReactionsExtension &
ReportsV1Extension &
SupplyV1Extension &
TokenFactoryV1Extension &
WasmExtension &
IbcExtension;

Expand All @@ -74,6 +79,7 @@ export function buildDesmosQueryClient(
setupSupplyV1Extension,
setupWasmExtension,
setupIbcExtension,
setupTokenFactoryV1Extension,
)
: undefined;
}
2 changes: 2 additions & 0 deletions packages/core/src/modules/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { registry as RelationshipsV1Registry } from "./relationships/v1";
import { registry as ReportsV1Registry } from "./reports/v1";
import { registry as StakingV1Beta1Registry } from "./staking/v1beta1";
import { registry as SubspacesV3Registry } from "./subspaces/v3";
import { registry as TokenFactoryV1Registry } from "./tokenfactory/v1";

export const DesmosRegistry: ReadonlyArray<[string, GeneratedType]> = [
...defaultRegistryTypes,
Expand All @@ -32,6 +33,7 @@ export const DesmosRegistry: ReadonlyArray<[string, GeneratedType]> = [
...ReportsV1Registry,
...StakingV1Beta1Registry,
...SubspacesV3Registry,
...TokenFactoryV1Registry,
];

export default DesmosRegistry;
8 changes: 8 additions & 0 deletions packages/core/src/modules/subspaces/v3/aminoconverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
MsgRemoveUserFromUserGroup,
MsgSetUserGroupPermissions,
MsgSetUserPermissions,
MsgUpdateSubspaceFeeTokens,
} from "@desmoslabs/desmjs-types/desmos/subspaces/v3/msgs";
import { GenericSubspaceAuthorization } from "@desmoslabs/desmjs-types/desmos/subspaces/v3/authz/authz";
import Long from "long";
Expand Down Expand Up @@ -69,6 +70,8 @@ import {
MsgSetUserGroupPermissionsTypeUrl,
MsgSetUserPermissionsAminoType,
MsgSetUserPermissionsTypeUrl,
MsgUpdateSubspaceFeeTokensAminoType,
MsgUpdateSubspaceFeeTokensTypeUrl,
} from "./consts";
import {
fromOmitEmptyArray,
Expand Down Expand Up @@ -357,4 +360,9 @@ export const AminoConverter: AminoConverters = {
signer: fromOmitEmptyString(msg.signer),
}),
},
[MsgUpdateSubspaceFeeTokensTypeUrl]: {
aminoType: MsgUpdateSubspaceFeeTokensAminoType,
toAmino: MsgUpdateSubspaceFeeTokens.toAmino,
fromAmino: MsgUpdateSubspaceFeeTokens.fromAmino,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { MsgSubmitProposal } from "@desmoslabs/desmjs-types/cosmos/gov/v1/tx";
import { coin } from "@cosmjs/amino";
import { MsgUpdateSubspaceFeeTokens } from "@desmoslabs/desmjs-types/desmos/subspaces/v3/msgs";
import {
broadcastTest,
createSubspaceToken,
createTestSubspace,
} from "../../../testutils";
import {
MsgSubmitProposalEncodeObject,
MsgSubmitProposalTypeUrl,
} from "../../gov/v1";

describe("Broadcast desmos.subspaces.v3 messages", () => {
jest.setTimeout(60 * 1000);

describe("Broadcast MsgUpdateSubspaceFeeTokens", () => {
broadcastTest(
"MsgUpdateSubspaceFeeTokensTypeUrl",
async (signer, client, [address]) => {
const subspaceId = await createTestSubspace(client, address);

const newFeeToken = await createSubspaceToken(
client,
subspaceId,
address,
);

const govMessage: MsgSubmitProposalEncodeObject = {
typeUrl: MsgSubmitProposalTypeUrl,
value: MsgSubmitProposal.fromPartial({
initialDeposit: [coin(100000, "stake")],
messages: [
MsgUpdateSubspaceFeeTokens.toProtoMsg(
MsgUpdateSubspaceFeeTokens.fromPartial({
subspaceId,
additionalFeeTokens: [coin(1000, newFeeToken)],
authority: "desmos10d07y265gmmuvt4z0w9aw880jnsr700jw674pt",
}),
),
],
proposer: address,
summary: "Test proposal",
title: "Test proposal",
metadata: "Proposal metadata",
}),
};

// Test broadcast the gov message.
await client.signAndBroadcast(address, [govMessage], "auto");
},
);
});
});
4 changes: 4 additions & 0 deletions packages/core/src/modules/subspaces/v3/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ export const MsgRemoveUserFromUserGroupAminoType =
export const MsgSetUserPermissionsTypeUrl =
"/desmos.subspaces.v3.MsgSetUserPermissions";
export const MsgSetUserPermissionsAminoType = "desmos/MsgSetUserPermissions";
export const MsgUpdateSubspaceFeeTokensTypeUrl =
"/desmos.subspaces.v3.MsgUpdateSubspaceFeeTokens";
export const MsgUpdateSubspaceFeeTokensAminoType =
"desmos/MsgUpdateSubspaceFeeTokens";
16 changes: 16 additions & 0 deletions packages/core/src/modules/subspaces/v3/encodeobjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
MsgRemoveUserFromUserGroup,
MsgSetUserGroupPermissions,
MsgSetUserPermissions,
MsgUpdateSubspaceFeeTokens,
} from "@desmoslabs/desmjs-types/desmos/subspaces/v3/msgs";
import {
MsgAddUserToUserGroupTypeUrl,
Expand All @@ -32,6 +33,7 @@ import {
MsgRemoveUserFromUserGroupTypeUrl,
MsgSetUserGroupPermissionsTypeUrl,
MsgSetUserPermissionsTypeUrl,
MsgUpdateSubspaceFeeTokensTypeUrl,
} from "./consts";

export interface MsgCreateSubspaceEncodeObject extends EncodeObject {
Expand Down Expand Up @@ -243,3 +245,17 @@ export function isMsgSetUserPermissionsEncodeObject(
MsgSetUserPermissionsTypeUrl
);
}

export interface MsgUpdateSubspaceFeeTokensEncodeObject extends EncodeObject {
readonly typeUrl: typeof MsgUpdateSubspaceFeeTokensTypeUrl;
readonly value: MsgUpdateSubspaceFeeTokens;
}

export function isMsgUpdateSubspaceFeeTokensEncodeObject(
encodeObject: EncodeObject,
): encodeObject is MsgUpdateSubspaceFeeTokensEncodeObject {
return (
(encodeObject as MsgUpdateSubspaceFeeTokensEncodeObject).typeUrl ===
MsgUpdateSubspaceFeeTokensTypeUrl
);
}
3 changes: 3 additions & 0 deletions packages/core/src/modules/subspaces/v3/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
MsgRemoveUserFromUserGroup,
MsgSetUserGroupPermissions,
MsgSetUserPermissions,
MsgUpdateSubspaceFeeTokens,
} from "@desmoslabs/desmjs-types/desmos/subspaces/v3/msgs";
import { GenericSubspaceAuthorization } from "@desmoslabs/desmjs-types/desmos/subspaces/v3/authz/authz";
import {
Expand All @@ -34,6 +35,7 @@ import {
MsgRemoveUserFromUserGroupTypeUrl,
MsgSetUserGroupPermissionsTypeUrl,
MsgSetUserPermissionsTypeUrl,
MsgUpdateSubspaceFeeTokensTypeUrl,
} from "./consts";

// eslint-disable-next-line import/prefer-default-export
Expand All @@ -55,4 +57,5 @@ export const registry: ReadonlyArray<[string, GeneratedType]> = [
[MsgAddUserToUserGroupTypeUrl, MsgAddUserToUserGroup],
[MsgRemoveUserFromUserGroupTypeUrl, MsgRemoveUserFromUserGroup],
[MsgSetUserPermissionsTypeUrl, MsgSetUserPermissions],
[MsgUpdateSubspaceFeeTokensTypeUrl, MsgUpdateSubspaceFeeTokens],
];
1 change: 1 addition & 0 deletions packages/core/src/modules/tokenfactory/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as v1 from "./v1";
49 changes: 49 additions & 0 deletions packages/core/src/modules/tokenfactory/v1/aminoconverter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { AminoConverters } from "@cosmjs/stargate";
import {
MsgBurn,
MsgCreateDenom,
MsgMint,
MsgSetDenomMetadata,
MsgUpdateParams,
} from "@desmoslabs/desmjs-types/desmos/tokenfactory/v1/msgs";
import {
MsgBurnAminoType,
MsgBurnTypeUrl,
MsgCreateDenomAminoType,
MsgCreateDenomTypeUrl,
MsgMintAminoType,
MsgMintTypeUrl,
MsgSetDenomMetadataAminoType,
MsgSetDenomMetadataTypeUrl,
MsgUpdateParamsAminoType,
MsgUpdateParamsTypeUrl,
} from "./consts";

// eslint-disable-next-line import/prefer-default-export
export const AminoConverter: AminoConverters = {
[MsgCreateDenomTypeUrl]: {
aminoType: MsgCreateDenomAminoType,
toAmino: MsgCreateDenom.toAmino,
fromAmino: MsgCreateDenom.fromAmino,
},
[MsgMintTypeUrl]: {
aminoType: MsgMintAminoType,
toAmino: MsgMint.toAmino,
fromAmino: MsgMint.fromAmino,
},
[MsgBurnTypeUrl]: {
aminoType: MsgBurnAminoType,
toAmino: MsgBurn.toAmino,
fromAmino: MsgBurn.fromAmino,
},
[MsgSetDenomMetadataTypeUrl]: {
aminoType: MsgSetDenomMetadataAminoType,
toAmino: MsgSetDenomMetadata.toAmino,
fromAmino: MsgSetDenomMetadata.fromAmino,
},
[MsgUpdateParamsTypeUrl]: {
aminoType: MsgUpdateParamsAminoType,
toAmino: MsgUpdateParams.toAmino,
fromAmino: MsgUpdateParams.fromAmino,
},
};
Loading