-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for tokenfactory module (#755)
## Description Closes: SDK-47 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> This PR implements support for the new `x/tokenfactory` module, introducing compatibility for the following messages: - `MsgCreateDenom` - `MsgMint` - `MsgBurn` - `MsgSetDenomMetadata` - `MsgUpdateParams` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] targeted the correct branch (see [PR Targeting](https://github.com/desmos-labs/desmjs/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed all author checklist items have been addressed - [ ] confirmed that this PR does not change production code
- Loading branch information
Showing
20 changed files
with
524 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * as v1 from "./v1"; |
49 changes: 49 additions & 0 deletions
49
packages/core/src/modules/tokenfactory/v1/aminoconverter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
}; |
185 changes: 185 additions & 0 deletions
185
packages/core/src/modules/tokenfactory/v1/broadcast.integration.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
import { | ||
MsgBurn, | ||
MsgCreateDenom, | ||
MsgMint, | ||
MsgSetDenomMetadata, | ||
} from "@desmoslabs/desmjs-types/desmos/tokenfactory/v1/msgs"; | ||
import { MsgSendEncodeObject } from "@cosmjs/stargate"; | ||
import { broadcastTest, createTestSubspace } from "../../../testutils"; | ||
import { | ||
MsgBurnEncodeObject, | ||
MsgCreateDenomEncodeObject, | ||
MsgMintEncodeObject, | ||
MsgSetDenomMetadataEncodeObject, | ||
} from "./encodeobjects"; | ||
import { | ||
MsgBurnTypeUrl, | ||
MsgCreateDenomTypeUrl, | ||
MsgMintTypeUrl, | ||
MsgSetDenomMetadataTypeUrl, | ||
} from "./consts"; | ||
import { MsgSendTypeUrl } from "../../bank/v1beta1"; | ||
|
||
describe("Broadcast desmos.tokenfactory.v1 messages", () => { | ||
jest.setTimeout(60 * 1000); | ||
|
||
describe("Broadcast MsgCreateDenom", () => { | ||
broadcastTest("MsgCreateDenom", async (signer, client, [address]) => { | ||
const subspaceId = await createTestSubspace(client, address); | ||
|
||
// Send some coins to the subspace treasury | ||
const { subspace } = await client.querier.subspacesV3.subspace( | ||
subspaceId, | ||
); | ||
await client.signAndBroadcast( | ||
address, | ||
[ | ||
{ | ||
typeUrl: MsgSendTypeUrl, | ||
value: { | ||
amount: [{ amount: "1", denom: "stake" }], | ||
toAddress: subspace!.treasury, | ||
fromAddress: address, | ||
}, | ||
} as MsgSendEncodeObject, | ||
], | ||
"auto", | ||
); | ||
|
||
const msgCreateDenom: MsgCreateDenomEncodeObject = { | ||
typeUrl: MsgCreateDenomTypeUrl, | ||
value: MsgCreateDenom.fromPartial({ | ||
subspaceId, | ||
sender: address, | ||
subdenom: "cdenom", | ||
}), | ||
}; | ||
// Test the denom creation. | ||
await client.signAndBroadcast(address, [msgCreateDenom], "auto"); | ||
}); | ||
}); | ||
|
||
describe("Broadcast MsgMint & MsgBurn", () => { | ||
broadcastTest("MsgMint & MsgBur", async (signer, client, [address]) => { | ||
const subspaceId = await createTestSubspace(client, address); | ||
|
||
// Send some coins to the subspace treasury | ||
const { subspace } = await client.querier.subspacesV3.subspace( | ||
subspaceId, | ||
); | ||
await client.signAndBroadcast( | ||
address, | ||
[ | ||
{ | ||
typeUrl: MsgSendTypeUrl, | ||
value: { | ||
amount: [{ amount: "1", denom: "stake" }], | ||
toAddress: subspace!.treasury, | ||
fromAddress: address, | ||
}, | ||
} as MsgSendEncodeObject, | ||
], | ||
"auto", | ||
); | ||
|
||
// Create a test denom. | ||
const msgCreateDenom: MsgCreateDenomEncodeObject = { | ||
typeUrl: MsgCreateDenomTypeUrl, | ||
value: MsgCreateDenom.fromPartial({ | ||
subspaceId, | ||
sender: address, | ||
subdenom: "mintdenom", | ||
}), | ||
}; | ||
await client.signAndBroadcast(address, [msgCreateDenom], "auto"); | ||
|
||
// Test the minting. | ||
const msgMint: MsgMintEncodeObject = { | ||
typeUrl: MsgMintTypeUrl, | ||
value: MsgMint.fromPartial({ | ||
subspaceId, | ||
amount: { | ||
amount: "100000", | ||
denom: `factory/${subspace!.treasury}/mintdenom`, | ||
}, | ||
sender: address, | ||
}), | ||
}; | ||
await client.signAndBroadcast(address, [msgMint], "auto"); | ||
|
||
// Test the burning. | ||
const msgBurn: MsgBurnEncodeObject = { | ||
typeUrl: MsgBurnTypeUrl, | ||
value: MsgBurn.fromPartial({ | ||
subspaceId, | ||
amount: { | ||
amount: "50000", | ||
denom: `factory/${subspace!.treasury}/mintdenom`, | ||
}, | ||
sender: address, | ||
}), | ||
}; | ||
await client.signAndBroadcast(address, [msgBurn], "auto"); | ||
}); | ||
}); | ||
|
||
describe("Broadcast MsgSetDenomMetadata", () => { | ||
broadcastTest("MsgSetDenomMetadata", async (signer, client, [address]) => { | ||
const subspaceId = await createTestSubspace(client, address); | ||
|
||
// Send some coins to the subspace treasury | ||
const { subspace } = await client.querier.subspacesV3.subspace( | ||
subspaceId, | ||
); | ||
await client.signAndBroadcast( | ||
address, | ||
[ | ||
{ | ||
typeUrl: MsgSendTypeUrl, | ||
value: { | ||
amount: [{ amount: "1", denom: "stake" }], | ||
toAddress: subspace!.treasury, | ||
fromAddress: address, | ||
}, | ||
} as MsgSendEncodeObject, | ||
], | ||
"auto", | ||
); | ||
|
||
// Create a test denom. | ||
const msgCreateDenom: MsgCreateDenomEncodeObject = { | ||
typeUrl: MsgCreateDenomTypeUrl, | ||
value: MsgCreateDenom.fromPartial({ | ||
subspaceId, | ||
sender: address, | ||
subdenom: "test", | ||
}), | ||
}; | ||
await client.signAndBroadcast(address, [msgCreateDenom], "auto"); | ||
|
||
// Test set denom metadata. | ||
const msgSetDenomMetadata: MsgSetDenomMetadataEncodeObject = { | ||
typeUrl: MsgSetDenomMetadataTypeUrl, | ||
value: MsgSetDenomMetadata.fromPartial({ | ||
subspaceId, | ||
metadata: { | ||
name: "Test denom", | ||
description: "A random denom", | ||
symbol: "test", | ||
base: `factory/${subspace!.treasury}/test`, | ||
display: `factory/${subspace!.treasury}/test`, | ||
denomUnits: [ | ||
{ | ||
denom: `factory/${subspace!.treasury}/test`, | ||
aliases: ["test"], | ||
exponent: 0, | ||
}, | ||
], | ||
}, | ||
sender: address, | ||
}), | ||
}; | ||
await client.signAndBroadcast(address, [msgSetDenomMetadata], "auto"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const MsgCreateDenomTypeUrl = "/desmos.tokenfactory.v1.MsgCreateDenom"; | ||
export const MsgCreateDenomAminoType = "desmos/MsgCreateDenom"; | ||
export const MsgMintTypeUrl = "/desmos.tokenfactory.v1.MsgMint"; | ||
export const MsgMintAminoType = "desmos/MsgMint"; | ||
export const MsgBurnTypeUrl = "/desmos.tokenfactory.v1.MsgBurn"; | ||
export const MsgBurnAminoType = "desmos/MsgBurn"; | ||
export const MsgSetDenomMetadataTypeUrl = | ||
"/desmos.tokenfactory.v1.MsgSetDenomMetadata"; | ||
export const MsgSetDenomMetadataAminoType = "desmos/MsgSetDenomMetadata"; | ||
export const MsgUpdateParamsTypeUrl = "/desmos.tokenfactory.v1.MsgUpdateParams"; | ||
export const MsgUpdateParamsAminoType = "desmos/x/tokenfactoy/MsgUpdateParams"; |
Oops, something went wrong.