bank: name and symbol metadata fields (#8677)
* bank: name and symbol metadata fields * cli test * changelog
This commit is contained in:
parent
77668a3c23
commit
149bed48fd
@ -61,6 +61,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Improvements
|
||||
|
||||
* (x/bank) [\#8614](https://github.com/cosmos/cosmos-sdk/issues/8614) Add `Name` and `Symbol` fields to denom metadata
|
||||
* (x/auth) [\#8522](https://github.com/cosmos/cosmos-sdk/pull/8522) Allow to query all stored accounts
|
||||
* (crypto/types) [\#8600](https://github.com/cosmos/cosmos-sdk/pull/8600) `CompactBitArray`: optimize the `NumTrueBitsBefore` method and add an `Equal` method.
|
||||
|
||||
|
||||
@ -1711,6 +1711,8 @@ a basic token.
|
||||
| `denom_units` | [DenomUnit](#cosmos.bank.v1beta1.DenomUnit) | repeated | denom_units represents the list of DenomUnit's for a given coin |
|
||||
| `base` | [string](#string) | | base represents the base denom (should be the DenomUnit with exponent = 0). |
|
||||
| `display` | [string](#string) | | display indicates the suggested denom that should be displayed in clients. |
|
||||
| `name` | [string](#string) | | name defines the name of the token (eg: Cosmos Atom) |
|
||||
| `symbol` | [string](#string) | | symbol is the token symbol usually shown on exchanges (eg: ATOM). This can be the same as the display. |
|
||||
|
||||
|
||||
|
||||
|
||||
@ -82,4 +82,9 @@ message Metadata {
|
||||
// display indicates the suggested denom that should be
|
||||
// displayed in clients.
|
||||
string display = 4;
|
||||
// name defines the name of the token (eg: Cosmos Atom)
|
||||
string name = 5;
|
||||
// symbol is the token symbol usually shown on exchanges (eg: ATOM). This can
|
||||
// be the same as the display.
|
||||
string symbol = 6;
|
||||
}
|
||||
|
||||
@ -40,6 +40,8 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
|
||||
bankGenesis.DenomMetadata = []types.Metadata{
|
||||
{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{
|
||||
@ -57,6 +59,8 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
Display: "atom",
|
||||
},
|
||||
{
|
||||
Name: "Ethereum",
|
||||
Symbol: "ETH",
|
||||
Description: "Ethereum mainnet token",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{
|
||||
@ -246,6 +250,8 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDenomsMetadata() {
|
||||
expected: &types.QueryDenomsMetadataResponse{
|
||||
Metadatas: []types.Metadata{
|
||||
{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{
|
||||
@ -263,6 +269,8 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDenomsMetadata() {
|
||||
Display: "atom",
|
||||
},
|
||||
{
|
||||
Name: "Ethereum",
|
||||
Symbol: "ETH",
|
||||
Description: "Ethereum mainnet token",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{
|
||||
@ -293,6 +301,8 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDenomsMetadata() {
|
||||
respType: &types.QueryDenomMetadataResponse{},
|
||||
expected: &types.QueryDenomMetadataResponse{
|
||||
Metadata: types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{
|
||||
|
||||
@ -121,6 +121,8 @@ func (s *IntegrationTestSuite) TestDenomMetadataGRPCHandler() {
|
||||
&types.QueryDenomsMetadataResponse{
|
||||
Metadatas: []types.Metadata{
|
||||
{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{
|
||||
@ -151,6 +153,8 @@ func (s *IntegrationTestSuite) TestDenomMetadataGRPCHandler() {
|
||||
&types.QueryDenomMetadataResponse{},
|
||||
&types.QueryDenomMetadataResponse{
|
||||
Metadata: types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{
|
||||
|
||||
@ -33,6 +33,8 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
|
||||
bankGenesis.DenomMetadata = []types.Metadata{
|
||||
{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{
|
||||
|
||||
@ -1004,6 +1004,8 @@ func (suite *IntegrationTestSuite) TestIterateAllDenomMetaData() {
|
||||
|
||||
func (suite *IntegrationTestSuite) getTestMetadata() []types.Metadata {
|
||||
return []types.Metadata{{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
@ -1014,6 +1016,8 @@ func (suite *IntegrationTestSuite) getTestMetadata() []types.Metadata {
|
||||
Display: "atom",
|
||||
},
|
||||
{
|
||||
Name: "Token",
|
||||
Symbol: "TOKEN",
|
||||
Description: "The native staking token of the Token Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"1token", uint32(5), []string{"decitoken"}},
|
||||
|
||||
@ -327,6 +327,11 @@ type Metadata struct {
|
||||
// display indicates the suggested denom that should be
|
||||
// displayed in clients.
|
||||
Display string `protobuf:"bytes,4,opt,name=display,proto3" json:"display,omitempty"`
|
||||
// name defines the name of the token (eg: Cosmos Atom)
|
||||
Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"`
|
||||
// symbol is the token symbol usually shown on exchanges (eg: ATOM). This can
|
||||
// be the same as the display.
|
||||
Symbol string `protobuf:"bytes,6,opt,name=symbol,proto3" json:"symbol,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Metadata) Reset() { *m = Metadata{} }
|
||||
@ -390,6 +395,20 @@ func (m *Metadata) GetDisplay() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Metadata) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Metadata) GetSymbol() string {
|
||||
if m != nil {
|
||||
return m.Symbol
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Params)(nil), "cosmos.bank.v1beta1.Params")
|
||||
proto.RegisterType((*SendEnabled)(nil), "cosmos.bank.v1beta1.SendEnabled")
|
||||
@ -403,43 +422,44 @@ func init() {
|
||||
func init() { proto.RegisterFile("cosmos/bank/v1beta1/bank.proto", fileDescriptor_dd052eee12edf988) }
|
||||
|
||||
var fileDescriptor_dd052eee12edf988 = []byte{
|
||||
// 566 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xbf, 0x6f, 0x13, 0x31,
|
||||
0x14, 0x3e, 0x37, 0x4d, 0x48, 0x1d, 0x58, 0x4c, 0x86, 0x6b, 0x24, 0xee, 0x8e, 0x93, 0x90, 0x52,
|
||||
0x44, 0x2f, 0x14, 0xc4, 0x92, 0x05, 0x29, 0xa5, 0x42, 0x1d, 0x10, 0xe8, 0x2a, 0x84, 0x04, 0x43,
|
||||
0xe4, 0xc4, 0x6e, 0xb0, 0x7a, 0x67, 0x9f, 0x62, 0x1f, 0x6a, 0xfe, 0x03, 0x26, 0x60, 0x44, 0x62,
|
||||
0xe9, 0xcc, 0x88, 0xf8, 0x23, 0x3a, 0x56, 0xb0, 0x30, 0x05, 0x94, 0x2c, 0xcc, 0xfd, 0x0b, 0x90,
|
||||
0xed, 0xcb, 0x8f, 0x4a, 0x01, 0x31, 0x30, 0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0x2b, 0xf1, 0x3c, 0x36, 0xd6, 0x27, 0x0c, 0x4b, 0x2a, 0xdd, 0x52, 0x50,
|
||||
0x32, 0xd6, 0xdb, 0x30, 0xfc, 0x00, 0x60, 0xf5, 0x11, 0x55, 0x98, 0x60, 0x85, 0x51, 0x00, 0x6b,
|
||||
0x84, 0xca, 0xfe, 0x90, 0x65, 0x8a, 0x09, 0x5e, 0xd0, 0x2f, 0x5f, 0xa1, 0xfb, 0x1a, 0xc1, 0x45,
|
||||
0xda, 0xcd, 0x39, 0x53, 0xb3, 0x79, 0x79, 0x2b, 0x9f, 0xdc, 0x5c, 0x6f, 0x0c, 0xc9, 0xec, 0x28,
|
||||
0x11, 0x82, 0xeb, 0xda, 0x5d, 0xb7, 0x64, 0xb8, 0xcd, 0x59, 0xab, 0x23, 0x4c, 0x66, 0x09, 0x1e,
|
||||
0xb9, 0xeb, 0x76, 0x31, 0x8a, 0xb0, 0xb3, 0x7b, 0x3a, 0xf1, 0xc0, 0xd9, 0xc4, 0x03, 0x3f, 0x26,
|
||||
0x1e, 0x78, 0x37, 0xf5, 0x9c, 0xb3, 0xa9, 0xe7, 0x7c, 0x9b, 0x7a, 0xce, 0xf3, 0xad, 0xbf, 0xb1,
|
||||
0xd1, 0xcc, 0xa3, 0x57, 0x31, 0x7f, 0x8e, 0xbb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe2, 0x72,
|
||||
0xf6, 0xc6, 0xc1, 0x04, 0x00, 0x00,
|
||||
// 588 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xbf, 0x6f, 0xd3, 0x4e,
|
||||
0x14, 0xf7, 0x35, 0x8d, 0xbf, 0xe9, 0xe5, 0xcb, 0x72, 0x54, 0xc8, 0xad, 0x84, 0x6d, 0x2c, 0x21,
|
||||
0xa5, 0x88, 0x3a, 0x14, 0xc4, 0x92, 0x05, 0x29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0xd7, 0x7a, 0xb6, 0xf5, 0x27, 0x96, 0xeb, 0xdd, 0xc5, 0xb6, 0xfe, 0x97, 0xb9, 0xf3, 0x33,
|
||||
0x00, 0x00, 0xff, 0xff, 0xa8, 0xf5, 0xda, 0x82, 0xed, 0x04, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *SendEnabled) Equal(that interface{}) bool {
|
||||
@ -774,6 +794,20 @@ func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Symbol) > 0 {
|
||||
i -= len(m.Symbol)
|
||||
copy(dAtA[i:], m.Symbol)
|
||||
i = encodeVarintBank(dAtA, i, uint64(len(m.Symbol)))
|
||||
i--
|
||||
dAtA[i] = 0x32
|
||||
}
|
||||
if len(m.Name) > 0 {
|
||||
i -= len(m.Name)
|
||||
copy(dAtA[i:], m.Name)
|
||||
i = encodeVarintBank(dAtA, i, uint64(len(m.Name)))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
}
|
||||
if len(m.Display) > 0 {
|
||||
i -= len(m.Display)
|
||||
copy(dAtA[i:], m.Display)
|
||||
@ -956,6 +990,14 @@ func (m *Metadata) Size() (n int) {
|
||||
if l > 0 {
|
||||
n += 1 + l + sovBank(uint64(l))
|
||||
}
|
||||
l = len(m.Name)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovBank(uint64(l))
|
||||
}
|
||||
l = len(m.Symbol)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovBank(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@ -1779,6 +1821,70 @@ func (m *Metadata) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
m.Display = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBank
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthBank
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBank
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Name = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 6:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Symbol", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBank
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthBank
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBank
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Symbol = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipBank(dAtA[iNdEx:])
|
||||
|
||||
@ -28,6 +28,8 @@ func TestGenesisStateValidate(t *testing.T) {
|
||||
Supply: sdk.Coins{sdk.NewInt64Coin("uatom", 1)},
|
||||
DenomMetadata: []Metadata{
|
||||
{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
@ -85,6 +87,8 @@ func TestGenesisStateValidate(t *testing.T) {
|
||||
GenesisState{
|
||||
DenomMetadata: []Metadata{
|
||||
{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
@ -95,6 +99,8 @@ func TestGenesisStateValidate(t *testing.T) {
|
||||
Display: "atom",
|
||||
},
|
||||
{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
@ -113,6 +119,8 @@ func TestGenesisStateValidate(t *testing.T) {
|
||||
GenesisState{
|
||||
DenomMetadata: []Metadata{
|
||||
{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
|
||||
@ -9,12 +9,21 @@ import (
|
||||
)
|
||||
|
||||
// Validate performs a basic validation of the coin metadata fields. It checks:
|
||||
// - Name and Symbol are not blank
|
||||
// - Base and Display denominations are valid coin denominations
|
||||
// - Base and Display denominations are present in the DenomUnit slice
|
||||
// - Base denomination has exponent 0
|
||||
// - Denomination units are sorted in ascending order
|
||||
// - Denomination units not duplicated
|
||||
func (m Metadata) Validate() error {
|
||||
if strings.TrimSpace(m.Name) == "" {
|
||||
return errors.New("name field cannot be blank")
|
||||
}
|
||||
|
||||
if strings.TrimSpace(m.Symbol) == "" {
|
||||
return errors.New("symbol field cannot be blank")
|
||||
}
|
||||
|
||||
if err := sdk.ValidateDenom(m.Base); err != nil {
|
||||
return fmt.Errorf("invalid metadata base denom: %w", err)
|
||||
}
|
||||
|
||||
@ -18,6 +18,8 @@ func TestMetadataValidate(t *testing.T) {
|
||||
{
|
||||
"non-empty coins",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
@ -32,6 +34,8 @@ func TestMetadataValidate(t *testing.T) {
|
||||
{
|
||||
"base coin is display coin",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"atom", uint32(0), []string{"ATOM"}},
|
||||
@ -42,16 +46,35 @@ func TestMetadataValidate(t *testing.T) {
|
||||
false,
|
||||
},
|
||||
{"empty metadata", types.Metadata{}, true},
|
||||
{
|
||||
"blank name",
|
||||
types.Metadata{
|
||||
Name: "",
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"blank symbol",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "",
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"invalid base denom",
|
||||
types.Metadata{
|
||||
Base: "",
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Base: "",
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"invalid display denom",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Base: "uatom",
|
||||
Display: "",
|
||||
},
|
||||
@ -60,6 +83,8 @@ func TestMetadataValidate(t *testing.T) {
|
||||
{
|
||||
"duplicate denom unit",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
@ -73,6 +98,8 @@ func TestMetadataValidate(t *testing.T) {
|
||||
{
|
||||
"invalid denom unit",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"", uint32(0), []string{"microatom"}},
|
||||
@ -85,6 +112,8 @@ func TestMetadataValidate(t *testing.T) {
|
||||
{
|
||||
"invalid denom unit alias",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"uatom", uint32(0), []string{""}},
|
||||
@ -97,6 +126,8 @@ func TestMetadataValidate(t *testing.T) {
|
||||
{
|
||||
"duplicate denom unit alias",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom", "microatom"}},
|
||||
@ -109,6 +140,8 @@ func TestMetadataValidate(t *testing.T) {
|
||||
{
|
||||
"no base denom unit",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"matom", uint32(3), []string{"milliatom"}},
|
||||
@ -122,6 +155,8 @@ func TestMetadataValidate(t *testing.T) {
|
||||
{
|
||||
"base denom exponent not zero",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"uatom", uint32(1), []string{"microatom"}},
|
||||
@ -133,9 +168,26 @@ func TestMetadataValidate(t *testing.T) {
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"invalid denom unit",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
{"", uint32(3), []string{"milliatom"}},
|
||||
},
|
||||
Base: "uatom",
|
||||
Display: "uatom",
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"no display denom unit",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
@ -148,6 +200,8 @@ func TestMetadataValidate(t *testing.T) {
|
||||
{
|
||||
"denom units not sorted",
|
||||
types.Metadata{
|
||||
Name: "Cosmos Hub Atom",
|
||||
Symbol: "ATOM",
|
||||
Description: "The native staking token of the Cosmos Hub.",
|
||||
DenomUnits: []*types.DenomUnit{
|
||||
{"uatom", uint32(0), []string{"microatom"}},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user