From 5adcd93b452a5274b75da8882d2b0d033371f5ae Mon Sep 17 00:00:00 2001 From: tarumi Date: Fri, 27 Oct 2023 18:42:03 +0200 Subject: [PATCH 1/8] rm set maxSubdomainRegistrations on sld registration --- x/registry/keeper/register_second_level_domain.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/x/registry/keeper/register_second_level_domain.go b/x/registry/keeper/register_second_level_domain.go index f68a7c3a..d331cd06 100644 --- a/x/registry/keeper/register_second_level_domain.go +++ b/x/registry/keeper/register_second_level_domain.go @@ -87,11 +87,6 @@ func (k Keeper) RegisterSecondLevelDomain(ctx sdk.Context, domain types.SecondLe return err } - // Set subdomain registration config - parentDomain.SubdomainConfig = &types.SubdomainConfig{ - MaxSubdomainRegistrations: 100, - } - // Increment parents subdomain SubdomainCount k.IncrementParentsSubdomainCount(ctx, domain) From df8517a31ebcae0d5a044e0fcdc5f1b742f000f0 Mon Sep 17 00:00:00 2001 From: tarumi Date: Tue, 31 Oct 2023 08:18:54 +0100 Subject: [PATCH 2/8] rm used code --- x/registry/keeper/msg_server_withdraw_registration_fee.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x/registry/keeper/msg_server_withdraw_registration_fee.go b/x/registry/keeper/msg_server_withdraw_registration_fee.go index 2d25c48a..1bce413d 100644 --- a/x/registry/keeper/msg_server_withdraw_registration_fee.go +++ b/x/registry/keeper/msg_server_withdraw_registration_fee.go @@ -11,10 +11,7 @@ import ( func (k msgServer) WithdrawRegistrationFee(goCtx context.Context, msg *types.MsgWithdrawRegistrationFee) (*types.MsgWithdrawRegistrationFeeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // TODO: Handling the message - _ = ctx - - // Get top level domain + // Get top level domain topLevelDomain, found := k.Keeper.GetTopLevelDomain(ctx, msg.Name) if !found { return nil, errorsmod.Wrapf(types.ErrDomainNotFound, "%s", msg.Name) From c2c121bfabcc87949e2937d60bd57a9e584aa280 Mon Sep 17 00:00:00 2001 From: tarumi Date: Tue, 31 Oct 2023 08:43:37 +0100 Subject: [PATCH 3/8] check module balance --- ...msg_server_withdraw_registration_fee_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/x/registry/keeper/msg_server_withdraw_registration_fee_test.go b/x/registry/keeper/msg_server_withdraw_registration_fee_test.go index 30a1ca36..7b87e2a8 100644 --- a/x/registry/keeper/msg_server_withdraw_registration_fee_test.go +++ b/x/registry/keeper/msg_server_withdraw_registration_fee_test.go @@ -5,6 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/mycel-domain/mycel/testutil" "github.com/mycel-domain/mycel/x/registry/types" @@ -54,7 +55,9 @@ func (suite *KeeperTestSuite) TestWithdrawRegistrationFee() { // Before balance withdrawerAddress, err := sdk.AccAddressFromBech32(tc.withdrawer) suite.Require().Nil(err) - beforeBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, withdrawerAddress) + beforeWithdrawerBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, withdrawerAddress) + registryAddress := authtypes.NewModuleAddress(types.ModuleName) + beforeRegistryAddress := suite.app.BankKeeper.GetAllBalances(suite.ctx, registryAddress) // Withdraw registration fee withdrawMsg := &types.MsgWithdrawRegistrationFee{ @@ -75,8 +78,16 @@ func (suite *KeeperTestSuite) TestWithdrawRegistrationFee() { } // Check balance - afterBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, withdrawerAddress) - suite.Require().Equal(beforeBalance.Add(fees.RegistrationFee...), afterBalance) + afterWithdrawerBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, withdrawerAddress) + suite.Require().Equal(beforeWithdrawerBalance.Add(fees.RegistrationFee...), afterWithdrawerBalance) + afterRegistyAddress := suite.app.BankKeeper.GetAllBalances(suite.ctx, registryAddress) + suite.Require().Equal(beforeRegistryAddress.Sub(fees.RegistrationFee...), afterRegistyAddress) + + // Check top level domain + topLevelDomain, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, tc.topLevelDomainName) + suite.Require().True(found) + suite.Require().True(topLevelDomain.RegistrationFee.IsEqual(sdk.NewCoins())) + } else { suite.Require().EqualError(err, tc.expErr.Error()) } From 3c1c598775396cd09638cb5d842bba2decaadf98 Mon Sep 17 00:00:00 2001 From: tarumi Date: Tue, 31 Oct 2023 12:05:26 +0100 Subject: [PATCH 4/8] rename to totalWithdrawalAmount and generate proto --- proto/mycel/registry/top_level_domain.proto | 2 +- x/registry/types/top_level_domain.pb.go | 97 +++++++++++---------- 2 files changed, 50 insertions(+), 49 deletions(-) diff --git a/proto/mycel/registry/top_level_domain.proto b/proto/mycel/registry/top_level_domain.proto index 1718a1dc..039d5e20 100644 --- a/proto/mycel/registry/top_level_domain.proto +++ b/proto/mycel/registry/top_level_domain.proto @@ -15,7 +15,7 @@ message TopLevelDomain { SubdomainConfig subdomainConfig = 4; uint64 subdomainCount = 5; map accessControl = 6; - repeated cosmos.base.v1beta1.Coin registrationFee = 7 [ + repeated cosmos.base.v1beta1.Coin totalWithdrawalAmount = 7 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; diff --git a/x/registry/types/top_level_domain.pb.go b/x/registry/types/top_level_domain.pb.go index ba432f96..53f7992a 100644 --- a/x/registry/types/top_level_domain.pb.go +++ b/x/registry/types/top_level_domain.pb.go @@ -26,13 +26,13 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TopLevelDomain struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - ExpirationDate int64 `protobuf:"varint,2,opt,name=expirationDate,proto3" json:"expirationDate,omitempty"` - Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - SubdomainConfig *SubdomainConfig `protobuf:"bytes,4,opt,name=subdomainConfig,proto3" json:"subdomainConfig,omitempty"` - SubdomainCount uint64 `protobuf:"varint,5,opt,name=subdomainCount,proto3" json:"subdomainCount,omitempty"` - AccessControl map[string]DomainRole `protobuf:"bytes,6,rep,name=accessControl,proto3" json:"accessControl,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=mycel.registry.DomainRole"` - RegistrationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=registrationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"registrationFee"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + ExpirationDate int64 `protobuf:"varint,2,opt,name=expirationDate,proto3" json:"expirationDate,omitempty"` + Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SubdomainConfig *SubdomainConfig `protobuf:"bytes,4,opt,name=subdomainConfig,proto3" json:"subdomainConfig,omitempty"` + SubdomainCount uint64 `protobuf:"varint,5,opt,name=subdomainCount,proto3" json:"subdomainCount,omitempty"` + AccessControl map[string]DomainRole `protobuf:"bytes,6,rep,name=accessControl,proto3" json:"accessControl,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=mycel.registry.DomainRole"` + TotalWithdrawalAmount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,7,rep,name=totalWithdrawalAmount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"totalWithdrawalAmount"` } func (m *TopLevelDomain) Reset() { *m = TopLevelDomain{} } @@ -110,9 +110,9 @@ func (m *TopLevelDomain) GetAccessControl() map[string]DomainRole { return nil } -func (m *TopLevelDomain) GetRegistrationFee() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *TopLevelDomain) GetTotalWithdrawalAmount() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { - return m.RegistrationFee + return m.TotalWithdrawalAmount } return nil } @@ -128,37 +128,38 @@ func init() { } var fileDescriptor_0136e389ac8054f7 = []byte{ - // 474 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x41, 0x6e, 0xd4, 0x30, - 0x14, 0x1d, 0x77, 0xa6, 0x85, 0xba, 0xea, 0x14, 0x59, 0x5d, 0xa4, 0x59, 0x64, 0x22, 0x24, 0x50, - 0x16, 0xd4, 0xee, 0x0c, 0x1b, 0x04, 0x2b, 0x3a, 0x05, 0x15, 0x09, 0x36, 0x01, 0x09, 0x09, 0x21, - 0x8d, 0x9c, 0x8c, 0x09, 0x51, 0x93, 0xfc, 0x28, 0x76, 0x46, 0xcd, 0x2d, 0x38, 0x07, 0x27, 0xe9, - 0xb2, 0x4b, 0x56, 0x80, 0x66, 0xae, 0xc0, 0x01, 0x50, 0xec, 0xb4, 0x4a, 0x02, 0x52, 0x57, 0xb1, - 0xbf, 0xdf, 0x7b, 0xdf, 0xef, 0x3f, 0x07, 0x3f, 0x4a, 0xab, 0x50, 0x24, 0xac, 0x10, 0x51, 0x2c, - 0x55, 0x51, 0x31, 0x05, 0xf9, 0x22, 0x11, 0x2b, 0x91, 0x2c, 0x96, 0x90, 0xf2, 0x38, 0xa3, 0x79, - 0x01, 0x0a, 0xc8, 0x58, 0xc3, 0xe8, 0x0d, 0xcc, 0x3e, 0x8c, 0x20, 0x02, 0x7d, 0xc4, 0xea, 0x95, - 0x41, 0xd9, 0x4e, 0x08, 0x32, 0x05, 0xc9, 0x02, 0x2e, 0x05, 0x5b, 0x4d, 0x03, 0xa1, 0xf8, 0x94, - 0x85, 0x70, 0xa3, 0x62, 0xf7, 0x9b, 0xc9, 0x32, 0x30, 0x5d, 0x16, 0x21, 0x64, 0x5f, 0xe2, 0xa8, - 0x81, 0x1d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, 0x40, 0x43, 0x48, 0x59, 0xf3, 0x1a, 0xcc, 0xe7, - 0x58, 0x2e, 0x2f, 0x98, 0xaa, 0x72, 0x21, 0x35, 0x41, 0xfa, 0xfd, 0x1e, 0xf6, 0x0b, 0xbc, 0xdf, - 0x99, 0x2e, 0x79, 0x80, 0x87, 0x17, 0xa2, 0x6a, 0x82, 0xad, 0x97, 0xe4, 0x10, 0x6f, 0xaf, 0x78, - 0x52, 0x9a, 0x38, 0x77, 0x7d, 0xb3, 0x79, 0xbe, 0xf5, 0x0c, 0xd9, 0x9f, 0x31, 0xf9, 0xd7, 0xd8, - 0x7f, 0x14, 0x4e, 0xda, 0x0a, 0xe3, 0x99, 0xdd, 0x1f, 0x96, 0x19, 0x92, 0x0f, 0x89, 0x68, 0xa9, - 0x9f, 0x9e, 0x5f, 0xad, 0x1d, 0x74, 0xbd, 0x76, 0xd0, 0xef, 0xb5, 0x83, 0xbe, 0x6d, 0x9c, 0xc1, - 0xf5, 0xc6, 0x19, 0xfc, 0xd8, 0x38, 0x83, 0x4f, 0xb4, 0xe5, 0x57, 0x4b, 0x1d, 0x9b, 0x88, 0xcc, - 0x86, 0x5d, 0xb6, 0xfe, 0xac, 0xda, 0x7b, 0xb0, 0xa3, 0xdf, 0xf1, 0xd3, 0xbf, 0x01, 0x00, 0x00, - 0xff, 0xff, 0xbf, 0x82, 0x97, 0x52, 0x78, 0x03, 0x00, 0x00, + // 484 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x41, 0x6b, 0xd4, 0x40, + 0x14, 0xde, 0xe9, 0x76, 0xab, 0x9d, 0xd2, 0x55, 0x86, 0x0a, 0x69, 0x0e, 0xd9, 0x20, 0x28, 0x39, + 0xd8, 0x49, 0x77, 0xbd, 0x88, 0x9e, 0xda, 0xad, 0x50, 0x41, 0x2f, 0x51, 0x28, 0x88, 0xb0, 0x4c, + 0xb2, 0x63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 0x19, 0x86, + 0x13, 0xbb, 0xbb, 0x39, 0xb3, 0xb1, 0x00, 0x04, 0x6f, 0xb0, 0x1f, 0x9f, 0x5e, 0xaf, 0x1c, 0x74, + 0xb3, 0x72, 0xd0, 0x9f, 0x95, 0x83, 0xbe, 0xaf, 0x9d, 0xde, 0xcd, 0xda, 0xe9, 0xfd, 0x5c, 0x3b, + 0xbd, 0xcf, 0xb4, 0xa1, 0x5a, 0x53, 0x1d, 0x18, 0xbf, 0xcc, 0xc1, 0xbf, 0x6c, 0xfc, 0x66, 0xd5, + 0x06, 0xc2, 0x2d, 0xfd, 0xa8, 0x5f, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x08, 0xbd, 0xcb, 0x4f, + 0x85, 0x03, 0x00, 0x00, } func (m *TopLevelDomain) Marshal() (dAtA []byte, err error) { @@ -181,10 +182,10 @@ func (m *TopLevelDomain) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.RegistrationFee) > 0 { - for iNdEx := len(m.RegistrationFee) - 1; iNdEx >= 0; iNdEx-- { + if len(m.TotalWithdrawalAmount) > 0 { + for iNdEx := len(m.TotalWithdrawalAmount) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.RegistrationFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.TotalWithdrawalAmount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -310,8 +311,8 @@ func (m *TopLevelDomain) Size() (n int) { n += mapEntrySize + 1 + sovTopLevelDomain(uint64(mapEntrySize)) } } - if len(m.RegistrationFee) > 0 { - for _, e := range m.RegistrationFee { + if len(m.TotalWithdrawalAmount) > 0 { + for _, e := range m.TotalWithdrawalAmount { l = e.Size() n += 1 + l + sovTopLevelDomain(uint64(l)) } @@ -702,7 +703,7 @@ func (m *TopLevelDomain) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RegistrationFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalWithdrawalAmount", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -729,8 +730,8 @@ func (m *TopLevelDomain) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RegistrationFee = append(m.RegistrationFee, types.Coin{}) - if err := m.RegistrationFee[len(m.RegistrationFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.TotalWithdrawalAmount = append(m.TotalWithdrawalAmount, types.Coin{}) + if err := m.TotalWithdrawalAmount[len(m.TotalWithdrawalAmount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From 4a191ae6eadacab672108e6d8ae9f4bdcc0ae170 Mon Sep 17 00:00:00 2001 From: tarumi Date: Tue, 31 Oct 2023 12:13:21 +0100 Subject: [PATCH 5/8] fix compilation err --- docs/static/openapi.yml | 10 ++--- ...erver_register_second_level_domain_test.go | 2 +- .../msg_server_register_top_level_domain.go | 2 +- .../msg_server_withdraw_registration_fee.go | 10 ++--- ...g_server_withdraw_registration_fee_test.go | 2 +- .../keeper/register_second_level_domain.go | 2 +- x/registry/types/errors.go | 40 +++++++++---------- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 52bb3f14..37ec88c8 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -50393,7 +50393,7 @@ paths: - OWNER - EDITOR default: NO_ROLE - registrationFee: + totalWithdrawalAmount: type: array items: type: object @@ -50621,7 +50621,7 @@ paths: - OWNER - EDITOR default: NO_ROLE - registrationFee: + totalWithdrawalAmount: type: array items: type: object @@ -81412,7 +81412,7 @@ definitions: - OWNER - EDITOR default: NO_ROLE - registrationFee: + totalWithdrawalAmount: type: array items: type: object @@ -81597,7 +81597,7 @@ definitions: - OWNER - EDITOR default: NO_ROLE - registrationFee: + totalWithdrawalAmount: type: array items: type: object @@ -81864,7 +81864,7 @@ definitions: - OWNER - EDITOR default: NO_ROLE - registrationFee: + totalWithdrawalAmount: type: array items: type: object diff --git a/x/registry/keeper/msg_server_register_second_level_domain_test.go b/x/registry/keeper/msg_server_register_second_level_domain_test.go index c5741871..134cc03c 100644 --- a/x/registry/keeper/msg_server_register_second_level_domain_test.go +++ b/x/registry/keeper/msg_server_register_second_level_domain_test.go @@ -121,7 +121,7 @@ func (suite *KeeperTestSuite) TestRegisterSecondLevelDomain() { afterModuleBalance := suite.app.BankKeeper.GetBalance(suite.ctx, moduleAddress, types.MycelDenom) suite.Require().Equal(beforeModuleBalance.Add(*fee), afterModuleBalance) - suite.Require().Equal(beforeParent.RegistrationFee.Add(*fee), afterParent.RegistrationFee) + suite.Require().Equal(beforeParent.TotalWithdrawalAmount.Add(*fee), afterParent.TotalWithdrawalAmount) // Evalute events events, found := testutil.FindEventsByType(suite.ctx.EventManager().Events(), types.EventTypeRegisterSecondLevelDomain) diff --git a/x/registry/keeper/msg_server_register_top_level_domain.go b/x/registry/keeper/msg_server_register_top_level_domain.go index fc4d627d..26835803 100644 --- a/x/registry/keeper/msg_server_register_top_level_domain.go +++ b/x/registry/keeper/msg_server_register_top_level_domain.go @@ -35,7 +35,7 @@ func (k msgServer) RegisterTopLevelDomain(goCtx context.Context, msg *types.MsgR Metadata: nil, SubdomainConfig: &defaultRegistrationConfig, AccessControl: accessControl, - RegistrationFee: sdk.NewCoins(), + TotalWithdrawalAmount: sdk.NewCoins(), } err = k.Keeper.RegisterTopLevelDomain(ctx, domain, creatorAddress, msg.RegistrationPeriodInYear) diff --git a/x/registry/keeper/msg_server_withdraw_registration_fee.go b/x/registry/keeper/msg_server_withdraw_registration_fee.go index 1bce413d..b9fc87a0 100644 --- a/x/registry/keeper/msg_server_withdraw_registration_fee.go +++ b/x/registry/keeper/msg_server_withdraw_registration_fee.go @@ -17,14 +17,14 @@ func (k msgServer) WithdrawRegistrationFee(goCtx context.Context, msg *types.Msg return nil, errorsmod.Wrapf(types.ErrDomainNotFound, "%s", msg.Name) } - if topLevelDomain.RegistrationFee.IsZero() { - return nil, errorsmod.Wrapf(types.ErrNoRegistrationFeeToWithdraw, "%s", msg.Name) + if topLevelDomain.TotalWithdrawalAmount.IsZero() { + return nil, errorsmod.Wrapf(types.ErrNoWithdrawalAmountToWithdraw, "%s", msg.Name) } // Check if the creator is the owner of the domain role, ok := topLevelDomain.AccessControl[msg.Creator] if !ok || role != types.DomainRole_OWNER { - return nil, errorsmod.Wrapf(types.ErrNoPermissionToWithdrawFee, "%s", msg.Creator) + return nil, errorsmod.Wrapf(types.ErrNoPermissionToWithdraw, "%s", msg.Creator) } // Send coins from module account to Creator @@ -33,12 +33,12 @@ func (k msgServer) WithdrawRegistrationFee(goCtx context.Context, msg *types.Msg return nil, err } - registrationFee := topLevelDomain.RegistrationFee + registrationFee := topLevelDomain.TotalWithdrawalAmount err = k.Keeper.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, creatorAddress, registrationFee) if err != nil { return nil, err } - topLevelDomain.RegistrationFee = sdk.NewCoins() + topLevelDomain.TotalWithdrawalAmount = sdk.NewCoins() k.Keeper.SetTopLevelDomain(ctx, topLevelDomain) // Emit event diff --git a/x/registry/keeper/msg_server_withdraw_registration_fee_test.go b/x/registry/keeper/msg_server_withdraw_registration_fee_test.go index 30a1ca36..32ee63a6 100644 --- a/x/registry/keeper/msg_server_withdraw_registration_fee_test.go +++ b/x/registry/keeper/msg_server_withdraw_registration_fee_test.go @@ -24,7 +24,7 @@ func (suite *KeeperTestSuite) TestWithdrawRegistrationFee() { { withdrawer: testutil.Bob, topLevelDomainName: "bar", - expErr: errorsmod.Wrapf(types.ErrNoPermissionToWithdrawFee, "%s", testutil.Bob), + expErr: errorsmod.Wrapf(types.ErrNoPermissionToWithdraw, "%s", testutil.Bob), }, } diff --git a/x/registry/keeper/register_second_level_domain.go b/x/registry/keeper/register_second_level_domain.go index d331cd06..beef2d26 100644 --- a/x/registry/keeper/register_second_level_domain.go +++ b/x/registry/keeper/register_second_level_domain.go @@ -40,7 +40,7 @@ func (k Keeper) PaySLDRegstrationFee(ctx sdk.Context, payer sdk.AccAddress, doma if !found { panic("parent not found") } - parent.RegistrationFee = parent.RegistrationFee.Add(*fee) + parent.TotalWithdrawalAmount = parent.TotalWithdrawalAmount.Add(*fee) k.SetTopLevelDomain(ctx, parent) return fee, err diff --git a/x/registry/types/errors.go b/x/registry/types/errors.go index 5c5dc7d2..31151e09 100644 --- a/x/registry/types/errors.go +++ b/x/registry/types/errors.go @@ -8,24 +8,24 @@ import ( // x/mycel module sentinel errors var ( - ErrSample = errorsmod.Register(ModuleName, 1100, "sample error") - ErrDomainIsAlreadyTaken = errorsmod.Register(ModuleName, 1101, "domain is already taken") - ErrInvalidDomainName = errorsmod.Register(ModuleName, 1102, "invalid name") - ErrInvalidDomainParent = errorsmod.Register(ModuleName, 1103, "invalid parent") - ErrDomainNotFound = errorsmod.Register(ModuleName, 1104, "domain not found") - ErrInvalidWalletAddress = errorsmod.Register(ModuleName, 1105, "invalid wallet address") - ErrInvalidWalletRecordType = errorsmod.Register(ModuleName, 1106, "invalid wallet record type") - ErrInvalidDnsRecordValue = errorsmod.Register(ModuleName, 1107, "invalid dns record value") - ErrInvalidDnsRecordType = errorsmod.Register(ModuleName, 1108, "invalid dns record type") - ErrDomainNotEditable = errorsmod.Register(ModuleName, 1109, "role not pemitted to edit the domain") - ErrParentDomainDoesNotExist = errorsmod.Register(ModuleName, 1110, "parent domain does not exist") - ErrParentDomainMustBeEmpty = errorsmod.Register(ModuleName, 1111, "parent domain must be empty") - ErrDomainNotRegistrable = errorsmod.Register(ModuleName, 1112, "domain is not registrable") - ErrMaxSubdomainCountReached = errorsmod.Register(ModuleName, 1113, "max subdomain count reached") - ErrInvalidRegistrationPeriod = errorsmod.Register(ModuleName, 1114, "invalid registration period") - ErrDomainExpired = errorsmod.Register(ModuleName, 1115, "domain expired") - ErrNoEnoughBalance = errorsmod.Register(ModuleName, 1116, "no enough balance") - ErrNoPermissionToWithdrawFee = errorsmod.Register(ModuleName, 1117, "no permission to withdraw fee") - ErrNoRegistrationFeeToWithdraw = errorsmod.Register(ModuleName, 1118, "no registration fee to withdraw") - ErrInvalidDenom = errorsmod.Register(ModuleName, 1119, "invalid denom") + ErrSample = errorsmod.Register(ModuleName, 1100, "sample error") + ErrDomainIsAlreadyTaken = errorsmod.Register(ModuleName, 1101, "domain is already taken") + ErrInvalidDomainName = errorsmod.Register(ModuleName, 1102, "invalid name") + ErrInvalidDomainParent = errorsmod.Register(ModuleName, 1103, "invalid parent") + ErrDomainNotFound = errorsmod.Register(ModuleName, 1104, "domain not found") + ErrInvalidWalletAddress = errorsmod.Register(ModuleName, 1105, "invalid wallet address") + ErrInvalidWalletRecordType = errorsmod.Register(ModuleName, 1106, "invalid wallet record type") + ErrInvalidDnsRecordValue = errorsmod.Register(ModuleName, 1107, "invalid dns record value") + ErrInvalidDnsRecordType = errorsmod.Register(ModuleName, 1108, "invalid dns record type") + ErrDomainNotEditable = errorsmod.Register(ModuleName, 1109, "role not pemitted to edit the domain") + ErrParentDomainDoesNotExist = errorsmod.Register(ModuleName, 1110, "parent domain does not exist") + ErrParentDomainMustBeEmpty = errorsmod.Register(ModuleName, 1111, "parent domain must be empty") + ErrDomainNotRegistrable = errorsmod.Register(ModuleName, 1112, "domain is not registrable") + ErrMaxSubdomainCountReached = errorsmod.Register(ModuleName, 1113, "max subdomain count reached") + ErrInvalidRegistrationPeriod = errorsmod.Register(ModuleName, 1114, "invalid registration period") + ErrDomainExpired = errorsmod.Register(ModuleName, 1115, "domain expired") + ErrNoEnoughBalance = errorsmod.Register(ModuleName, 1116, "no enough balance") + ErrNoPermissionToWithdraw = errorsmod.Register(ModuleName, 1117, "no permission to withdraw") + ErrNoWithdrawalAmountToWithdraw = errorsmod.Register(ModuleName, 1118, "no registration fee to withdraw") + ErrInvalidDenom = errorsmod.Register(ModuleName, 1119, "invalid denom") ) From b656d37f7d5ef555435d9ef41e3e6994d0790ed4 Mon Sep 17 00:00:00 2001 From: tarumi Date: Tue, 31 Oct 2023 12:16:20 +0100 Subject: [PATCH 6/8] small fix --- x/registry/keeper/msg_server_withdraw_registration_fee.go | 4 +--- .../keeper/msg_server_withdraw_registration_fee_test.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/x/registry/keeper/msg_server_withdraw_registration_fee.go b/x/registry/keeper/msg_server_withdraw_registration_fee.go index b9fc87a0..c9881e25 100644 --- a/x/registry/keeper/msg_server_withdraw_registration_fee.go +++ b/x/registry/keeper/msg_server_withdraw_registration_fee.go @@ -10,8 +10,7 @@ import ( func (k msgServer) WithdrawRegistrationFee(goCtx context.Context, msg *types.MsgWithdrawRegistrationFee) (*types.MsgWithdrawRegistrationFeeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - - // Get top level domain + // Get top level domain topLevelDomain, found := k.Keeper.GetTopLevelDomain(ctx, msg.Name) if !found { return nil, errorsmod.Wrapf(types.ErrDomainNotFound, "%s", msg.Name) @@ -44,6 +43,5 @@ func (k msgServer) WithdrawRegistrationFee(goCtx context.Context, msg *types.Msg // Emit event EmitWithdrawRegistrationFeeEvent(ctx, *msg, registrationFee) - return &types.MsgWithdrawRegistrationFeeResponse{RegistrationFee: registrationFee}, nil } diff --git a/x/registry/keeper/msg_server_withdraw_registration_fee_test.go b/x/registry/keeper/msg_server_withdraw_registration_fee_test.go index 17d9476a..c71f2f95 100644 --- a/x/registry/keeper/msg_server_withdraw_registration_fee_test.go +++ b/x/registry/keeper/msg_server_withdraw_registration_fee_test.go @@ -86,7 +86,7 @@ func (suite *KeeperTestSuite) TestWithdrawRegistrationFee() { // Check top level domain topLevelDomain, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, tc.topLevelDomainName) suite.Require().True(found) - suite.Require().True(topLevelDomain.RegistrationFee.IsEqual(sdk.NewCoins())) + suite.Require().True(topLevelDomain.TotalWithdrawalAmount.IsEqual(sdk.NewCoins())) } else { suite.Require().EqualError(err, tc.expErr.Error()) From 196b70cf8144a2cd92fc7ec4a2c0fea278c0198f Mon Sep 17 00:00:00 2001 From: tarumi Date: Wed, 1 Nov 2023 20:02:35 +0900 Subject: [PATCH 7/8] Format proto/mycel/registry/params.proto Co-authored-by: foxytanuki <45069709+foxytanuki@users.noreply.github.com> --- proto/mycel/registry/params.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/mycel/registry/params.proto b/proto/mycel/registry/params.proto index cd3bfd02..54cbd76e 100644 --- a/proto/mycel/registry/params.proto +++ b/proto/mycel/registry/params.proto @@ -8,6 +8,6 @@ option go_package = "github.com/mycel-domain/mycel/x/registry/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - float stakingInflationRatio = 1; + float stakingInflationRatio = 1; int64 topLevelDomainBaseFeeInUsd = 2; } From ff2b07e81cd5a0a5b5f2d74504ca9746bc0b9be3 Mon Sep 17 00:00:00 2001 From: tarumi Date: Wed, 1 Nov 2023 12:08:08 +0100 Subject: [PATCH 8/8] fix typos --- x/registry/keeper/events.go | 2 +- x/registry/keeper/register_top_level_domain.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/registry/keeper/events.go b/x/registry/keeper/events.go index daea9410..54b99ada 100644 --- a/x/registry/keeper/events.go +++ b/x/registry/keeper/events.go @@ -40,7 +40,7 @@ func EmitUpdateWalletRecordEvent(ctx sdk.Context, msg types.MsgUpdateWalletRecor ctx.EventManager().EmitEvent( sdk.NewEvent(types.EventTypeUpdateWalletRecord, sdk.NewAttribute(types.AttributeUpdateWalletRecordEventDomainName, msg.Name), - sdk.NewAttribute(types.AttributeUpdateDnsRecordEventDomainParent, msg.Parent), + sdk.NewAttribute(types.AttributeUpdateWalletRecordEventDomainParent, msg.Parent), sdk.NewAttribute(types.AttributeUpdateWalletRecordEventWalletRecordType, msg.WalletRecordType), sdk.NewAttribute(types.AttributeUpdateWalletRecordEventValue, msg.Value), ), diff --git a/x/registry/keeper/register_top_level_domain.go b/x/registry/keeper/register_top_level_domain.go index ecbbb15c..2b42b6b3 100644 --- a/x/registry/keeper/register_top_level_domain.go +++ b/x/registry/keeper/register_top_level_domain.go @@ -12,13 +12,13 @@ import ( func (k Keeper) GetBurnWeight(ctx sdk.Context) (weight math.LegacyDec, err error) { inflation := k.mintKeeper.GetMinter(ctx).Inflation - boundedRatio := k.mintKeeper.BondedRatio(ctx) + bondedRatio := k.mintKeeper.BondedRatio(ctx) // TODO: Get alpha from params stakingInflationRatio := k.GetParams(ctx).StakingInflationRatio alpha := math.LegacyMustNewDecFromStr(fmt.Sprintf("%f", stakingInflationRatio)) - w1 := alpha.Mul(boundedRatio) + w1 := alpha.Mul(bondedRatio) w2 := inflation.Mul(math.LegacyMustNewDecFromStr("1").Sub(alpha)) weight = w1.Add(w2) return weight, nil