-
Notifications
You must be signed in to change notification settings - Fork 805
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
Adding tokenfactory denom metadata endpoint #1444
Merged
dssei
merged 8 commits into
main
from
SEI-6857_add_tokenfcatory_denom_metadata_endpoint
Mar 19, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a631d0d
a working draft
dssei 1420944
add a test for new endpoint
dssei 1773f23
update proto comment
dssei c1b1098
fix linting issue
dssei ba9e3b9
Merge branch 'main' of github.com:sei-protocol/sei-chain into SEI-685…
dssei 79c47e7
update readme
dssei 8ca641b
rollback auto-generated proto version updates
dssei fd78490
Merge branch 'main' into SEI-6857_add_tokenfcatory_denom_metadata_end…
dssei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Code generation | ||
|
||
To generate the code for the protobuf files, first install the `ignite` tool. | ||
We need version v0.23.0, which is outdated, but works with the current version of the codebase. | ||
Pull binaries from the [releases page](https://github.com/ignite/cli/releases/tag/v0.23.0) or install from source code | ||
following instructions. | ||
|
||
Verify the installation by running `ignite version`: | ||
|
||
```bash | ||
% ignite version | ||
· | ||
· 🛸 Ignite CLI v28.2.0 is available! | ||
· | ||
· To upgrade your Ignite CLI version, see the upgrade doc: https://docs.ignite.com/guide/install.html#upgrading-your-ignite-cli-installation | ||
· | ||
·· | ||
|
||
Ignite CLI version: v0.23.0 | ||
Ignite CLI build date: 2022-07-24T18:17:44Z | ||
Ignite CLI source hash: 64df9aef958b3e8bc04b40d9feeb03426075ea89 | ||
Your OS: darwin | ||
Your arch: arm64 | ||
Your go version: go version go1.22.0 darwin/arm64 | ||
Your uname -a: Darwin 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:32:11 PDT 2023; root:xnu-10002.41.9~7/RELEASE_ARM64_T6030 arm64 | ||
Your cwd: /repos/sei-chain | ||
Is on Gitpod: false | ||
|
||
``` | ||
Then, to generate the code, run the following command: | ||
|
||
```bash | ||
ignite generate proto-go | ||
``` |
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,81 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"fmt" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
"github.com/sei-protocol/sei-chain/x/tokenfactory/types" | ||
) | ||
|
||
func (suite *KeeperTestSuite) TestDenomMetadataRequest() { | ||
var ( | ||
req *types.QueryDenomMetadataRequest | ||
expMetadata = banktypes.Metadata{} | ||
) | ||
tokenFactoryDenom := "factory/sei1gxskuzvhr4s8sdm2rpruaf7yx2dnmjn0zfdu9q/NEWCOIN" | ||
testCases := []struct { | ||
msg string | ||
malleate func() | ||
expPass bool | ||
}{ | ||
{ | ||
"empty denom", | ||
func() { | ||
req = &types.QueryDenomMetadataRequest{} | ||
}, | ||
false, | ||
}, | ||
{ | ||
"not found denom", | ||
func() { | ||
req = &types.QueryDenomMetadataRequest{ | ||
Denom: tokenFactoryDenom, | ||
} | ||
}, | ||
false, | ||
}, | ||
{ | ||
"success", | ||
func() { | ||
|
||
expMetadata = banktypes.Metadata{ | ||
Description: "Token factory custom token", | ||
DenomUnits: []*banktypes.DenomUnit{ | ||
{ | ||
Denom: tokenFactoryDenom, | ||
Exponent: 0, | ||
Aliases: []string{tokenFactoryDenom}, | ||
}, | ||
}, | ||
Base: tokenFactoryDenom, | ||
Display: tokenFactoryDenom, | ||
} | ||
|
||
suite.App.BankKeeper.SetDenomMetaData(suite.Ctx, expMetadata) | ||
req = &types.QueryDenomMetadataRequest{ | ||
Denom: expMetadata.Base, | ||
} | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { | ||
suite.SetupTest() // reset | ||
|
||
tc.malleate() | ||
ctx := sdk.WrapSDKContext(suite.Ctx) | ||
|
||
res, err := suite.queryClient.DenomMetadata(ctx, req) | ||
|
||
if tc.expPass { | ||
suite.Require().NoError(err) | ||
suite.Require().NotNil(res) | ||
suite.Require().Equal(expMetadata, res.Metadata) | ||
} else { | ||
suite.Require().Error(err) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for generating the proto files or for generating the openapi yml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its for both, will add another readme for docs generation in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nicee!