diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 76ce2df9..7f4296f7 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -51019,7 +51019,7 @@ paths: title: 'Rule: CHAINNAME_ENVIRONMENT_NETWORK' value: type: string - metadata: + textRecord: type: object properties: key: @@ -51153,6 +51153,56 @@ paths: additionalProperties: {} tags: - Query + /mycel-domain/mycel/resolver/text_record/{domainName}/{domainParent}/{key}: + get: + summary: Queries a list of TextRecord items. + operationId: MycelResolverTextRecord + responses: + '200': + description: A successful response. + schema: + type: object + properties: + value: + type: object + properties: + key: + type: string + value: + type: string + default: + description: An unexpected error response. + schema: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + details: + type: array + items: + type: object + properties: + '@type': + type: string + additionalProperties: {} + parameters: + - name: domainName + in: path + required: true + type: string + - name: domainParent + in: path + required: true + type: string + - name: key + in: path + required: true + type: string + tags: + - Query /mycel-domain/mycel/resolver/wallet_record/{domainName}/{domainParent}/{walletRecordType}: get: summary: Queries a list of QueryWalletRecord items. @@ -81661,6 +81711,8 @@ definitions: signatures required by gogoproto. mycel.registry.MsgUpdateDnsRecordResponse: type: object + mycel.registry.MsgUpdateTextRecordResponse: + type: object mycel.registry.MsgUpdateWalletRecordResponse: type: object mycel.registry.MsgWithdrawRegistrationFeeResponse: @@ -82506,13 +82558,6 @@ definitions: - SRV - TXT default: NO_RECORD_TYPE - mycel.registry.Metadata: - type: object - properties: - key: - type: string - value: - type: string mycel.registry.NetworkName: type: string enum: @@ -82640,13 +82685,20 @@ definitions: title: 'Rule: CHAINNAME_ENVIRONMENT_NETWORK' value: type: string - metadata: + textRecord: type: object properties: key: type: string value: type: string + mycel.registry.TextRecord: + type: object + properties: + key: + type: string + value: + type: string mycel.registry.WalletRecord: type: object properties: @@ -82787,7 +82839,7 @@ definitions: title: 'Rule: CHAINNAME_ENVIRONMENT_NETWORK' value: type: string - metadata: + textRecord: type: object properties: key: @@ -82823,6 +82875,16 @@ definitions: description: params holds all the parameters of this module. type: object description: QueryParamsResponse is response type for the Query/Params RPC method. + mycel.resolver.QueryTextRecordResponse: + type: object + properties: + value: + type: object + properties: + key: + type: string + value: + type: string mycel.resolver.QueryWalletRecordResponse: type: object properties: diff --git a/proto/mycel/registry/second_level_domain.proto b/proto/mycel/registry/second_level_domain.proto index 796e69a1..c7e66973 100644 --- a/proto/mycel/registry/second_level_domain.proto +++ b/proto/mycel/registry/second_level_domain.proto @@ -19,7 +19,7 @@ message WalletRecord { string value = 2; } -message Metadata { +message TextRecord { string key = 1; string value = 2; } @@ -28,7 +28,7 @@ message Record { oneof record { DnsRecord dnsRecord = 1; WalletRecord walletRecord = 2; - Metadata metadata = 3; + TextRecord textRecord = 3; } } diff --git a/proto/mycel/registry/tx.proto b/proto/mycel/registry/tx.proto index da664c24..53bb8a68 100644 --- a/proto/mycel/registry/tx.proto +++ b/proto/mycel/registry/tx.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package mycel.registry; import "cosmos/base/v1beta1/coin.proto"; @@ -9,72 +10,81 @@ option go_package = "github.com/mycel-domain/mycel/x/registry/types"; // Msg defines the Msg service. service Msg { - rpc UpdateWalletRecord(MsgUpdateWalletRecord) returns (MsgUpdateWalletRecordResponse); - rpc UpdateDnsRecord(MsgUpdateDnsRecord) returns (MsgUpdateDnsRecordResponse); - rpc RegisterSecondLevelDomain(MsgRegisterSecondLevelDomain) returns (MsgRegisterSecondLevelDomainResponse); - rpc RegisterTopLevelDomain(MsgRegisterTopLevelDomain) returns (MsgRegisterTopLevelDomainResponse); - rpc WithdrawRegistrationFee(MsgWithdrawRegistrationFee) returns (MsgWithdrawRegistrationFeeResponse); - rpc ExtendTopLevelDomainExpirationDate(MsgExtendTopLevelDomainExpirationDate) returns (MsgExtendTopLevelDomainExpirationDateResponse); + rpc UpdateWalletRecord (MsgUpdateWalletRecord ) returns (MsgUpdateWalletRecordResponse ); + rpc UpdateDnsRecord (MsgUpdateDnsRecord ) returns (MsgUpdateDnsRecordResponse ); + rpc RegisterSecondLevelDomain (MsgRegisterSecondLevelDomain ) returns (MsgRegisterSecondLevelDomainResponse ); + rpc RegisterTopLevelDomain (MsgRegisterTopLevelDomain ) returns (MsgRegisterTopLevelDomainResponse ); + rpc WithdrawRegistrationFee (MsgWithdrawRegistrationFee ) returns (MsgWithdrawRegistrationFeeResponse ); + rpc ExtendTopLevelDomainExpirationDate (MsgExtendTopLevelDomainExpirationDate) returns (MsgExtendTopLevelDomainExpirationDateResponse); + rpc UpdateTextRecord (MsgUpdateTextRecord ) returns (MsgUpdateTextRecordResponse ); } message MsgUpdateWalletRecord { - string creator = 1; - string name = 2; - string parent = 3; + string creator = 1; + string name = 2; + string parent = 3; string walletRecordType = 4; - string value = 5; + string value = 5; } message MsgUpdateWalletRecordResponse {} message MsgUpdateDnsRecord { - string creator = 1; - string name = 2; - string parent = 3; + string creator = 1; + string name = 2; + string parent = 3; string dnsRecordType = 4; - string value = 5; + string value = 5; } message MsgUpdateDnsRecordResponse {} message MsgRegisterSecondLevelDomain { - string creator = 1; - string name = 2; - string parent = 3; + string creator = 1; + string name = 2; + string parent = 3; uint64 registrationPeriodInYear = 4; } message MsgRegisterSecondLevelDomainResponse {} message MsgRegisterTopLevelDomain { - string creator = 1; - string name = 2; + string creator = 1; + string name = 2; uint64 registrationPeriodInYear = 3; } message MsgRegisterTopLevelDomainResponse { - TopLevelDomain topLevelDomain = 1; - TopLevelDomainFee fee = 2; + TopLevelDomain topLevelDomain = 1; + TopLevelDomainFee fee = 2; } message MsgWithdrawRegistrationFee { string creator = 1; - string name = 2; + string name = 2; } message MsgWithdrawRegistrationFeeResponse { - repeated cosmos.base.v1beta1.Coin registrationFee = 7 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + repeated cosmos.base.v1beta1.Coin registrationFee = 7 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; } message MsgExtendTopLevelDomainExpirationDate { - string creator = 1; - string name = 2; + string creator = 1; + string name = 2; uint64 extensionPeriodInYear = 3; } message MsgExtendTopLevelDomainExpirationDateResponse { - TopLevelDomain topLevelDomain = 1; - TopLevelDomainFee fee = 2; + TopLevelDomain topLevelDomain = 1; + TopLevelDomainFee fee = 2; } + +message MsgUpdateTextRecord { + string creator = 1; + string name = 2; + string parent = 3; + string key = 4; + string value = 5; +} + +message MsgUpdateTextRecordResponse {} + diff --git a/proto/mycel/resolver/query.proto b/proto/mycel/resolver/query.proto index d997f682..c9f34ce8 100644 --- a/proto/mycel/resolver/query.proto +++ b/proto/mycel/resolver/query.proto @@ -1,4 +1,5 @@ syntax = "proto3"; + package mycel.resolver; import "cosmos/base/query/v1beta1/pagination.proto"; @@ -11,39 +12,50 @@ option go_package = "github.com/mycel-domain/mycel/x/resolver/types"; // Query defines the gRPC querier service. service Query { + // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/mycel-domain/mycel/resolver/params"; + } - + // Queries a list of QueryWalletRecord items. - rpc WalletRecord(QueryWalletRecordRequest) returns (QueryWalletRecordResponse) { + rpc WalletRecord (QueryWalletRecordRequest) returns (QueryWalletRecordResponse) { option (google.api.http).get = "/mycel-domain/mycel/resolver/wallet_record/{domainName}/{domainParent}/{walletRecordType}"; + } - + // Queries a list of DnsRecord items. - rpc DnsRecord(QueryDnsRecordRequest) returns (QueryDnsRecordResponse) { + rpc DnsRecord (QueryDnsRecordRequest) returns (QueryDnsRecordResponse) { option (google.api.http).get = "/mycel-domain/mycel/resolver/dns_record/{domainName}/{domainParent}/{dnsRecordType}"; + } - + // Queries a list of AllRecord items. - rpc AllRecords(QueryAllRecordsRequest) returns (QueryAllRecordsResponse) { + rpc AllRecords (QueryAllRecordsRequest) returns (QueryAllRecordsResponse) { option (google.api.http).get = "/mycel-domain/mycel/resolver/all_records/{domainName}/{domainParent}"; + + } + + // Queries a list of TextRecord items. + rpc TextRecord (QueryTextRecordRequest) returns (QueryTextRecordResponse) { + option (google.api.http).get = "/mycel-domain/mycel/resolver/text_record/{domainName}/{domainParent}/{key}"; + } } - // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { + // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = false]; } message QueryWalletRecordRequest { - string domainName = 1; - string domainParent = 2; + string domainName = 1; + string domainParent = 2; string walletRecordType = 3; } @@ -52,8 +64,8 @@ message QueryWalletRecordResponse { } message QueryDnsRecordRequest { - string domainName = 1; - string domainParent = 2; + string domainName = 1; + string domainParent = 2; string dnsRecordType = 3; } @@ -62,10 +74,20 @@ message QueryDnsRecordResponse { } message QueryAllRecordsRequest { - string domainName = 1; + string domainName = 1; string domainParent = 2; } message QueryAllRecordsResponse { - map values = 1; + map values = 1; +} + +message QueryTextRecordRequest { + string domainName = 1; + string domainParent = 2; + string key = 3; +} + +message QueryTextRecordResponse { + mycel.registry.TextRecord value = 1; } diff --git a/x/registry/client/cli/tx.go b/x/registry/client/cli/tx.go index 4f6baa29..55dd3a54 100644 --- a/x/registry/client/cli/tx.go +++ b/x/registry/client/cli/tx.go @@ -36,6 +36,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdRegisterTopLevelDomain()) cmd.AddCommand(CmdWithdrawRegistrationFee()) cmd.AddCommand(CmdExtendTopLevelDomainExpirationDate()) + cmd.AddCommand(CmdUpdateTextRecord()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/registry/client/cli/tx_update_text_record.go b/x/registry/client/cli/tx_update_text_record.go new file mode 100644 index 00000000..05388993 --- /dev/null +++ b/x/registry/client/cli/tx_update_text_record.go @@ -0,0 +1,49 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" +) + +var _ = strconv.Itoa(0) + +func CmdUpdateTextRecord() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-text-record [name] [parent] [key] [value]", + Short: "Broadcast message updateTextRecord", + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argName := args[0] + argParent := args[1] + argKey := args[2] + argValue := args[3] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgUpdateTextRecord( + clientCtx.GetFromAddress().String(), + argName, + argParent, + argKey, + argValue, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/registry/keeper/events.go b/x/registry/keeper/events.go index 768a461f..ec6f830f 100644 --- a/x/registry/keeper/events.go +++ b/x/registry/keeper/events.go @@ -60,6 +60,18 @@ func EmitUpdateDnsRecordEvent(ctx sdk.Context, msg types.MsgUpdateDnsRecord) { ) } +// Update dns record event +func EmitUpdateTextRecordEvent(ctx sdk.Context, msg types.MsgUpdateTextRecord) { + ctx.EventManager().EmitEvent( + sdk.NewEvent(types.EventTypeUpdateTextRecord, + sdk.NewAttribute(types.AttributeUpdateTextRecordEventDomainName, msg.Name), + sdk.NewAttribute(types.AttributeUpdateTextRecordEventDomainParent, msg.Parent), + sdk.NewAttribute(types.AttributeUpdateTextRecordEventKey, msg.Key), + sdk.NewAttribute(types.AttributeUpdateTextRecordEventValue, msg.Value), + ), + ) +} + // Withdraw fees event func EmitWithdrawRegistrationFeeEvent(ctx sdk.Context, msg types.MsgWithdrawRegistrationFee, fee sdk.Coins) { ctx.EventManager().EmitEvent( diff --git a/x/registry/keeper/msg_server_update_text_record.go b/x/registry/keeper/msg_server_update_text_record.go new file mode 100644 index 00000000..ac1a8930 --- /dev/null +++ b/x/registry/keeper/msg_server_update_text_record.go @@ -0,0 +1,37 @@ +package keeper + +import ( + "context" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/x/registry/types" +) + +func (k msgServer) UpdateTextRecord(goCtx context.Context, msg *types.MsgUpdateTextRecord) (*types.MsgUpdateTextRecordResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + _ = ctx + domain, isFound := k.Keeper.GetSecondLevelDomain(ctx, msg.Name, msg.Parent) + if !isFound { + return nil, errorsmod.Wrapf(types.ErrSecondLevelDomainNotFound, "%s.%s", msg.Name, msg.Parent) + } + + // Check if the domain is owned by the creator + isEditable, err := domain.IsRecordEditable(msg.Creator) + if !isEditable { + return nil, err + } + + err = domain.UpdateTextRecord(msg.Key, msg.Value) + if err != nil { + return nil, err + } + k.Keeper.SetSecondLevelDomain(ctx, domain) + + // Emit event + EmitUpdateTextRecordEvent(ctx, *msg) + + return &types.MsgUpdateTextRecordResponse{}, nil +} diff --git a/x/registry/keeper/msg_server_update_text_record_test.go b/x/registry/keeper/msg_server_update_text_record_test.go new file mode 100644 index 00000000..ed5183a9 --- /dev/null +++ b/x/registry/keeper/msg_server_update_text_record_test.go @@ -0,0 +1,107 @@ +package keeper_test + +import ( + "fmt" + + errorsmod "cosmossdk.io/errors" + + "github.com/mycel-domain/mycel/testutil" + "github.com/mycel-domain/mycel/x/registry/types" +) + +func (suite *KeeperTestSuite) TestUpdateTextRecord() { + testCases := []struct { + creator string + name string + parent string + key string + value string + expErr error + fn func() + }{ + { + creator: testutil.Alice, + name: "foo", + parent: "cel", + key: "com.github", + value: "mycel-domain", + expErr: nil, + fn: func() {}, + }, + { + creator: testutil.Alice, + name: "foo", + parent: "cel", + key: "ETHEREUM_MAINNET_MAINNET", + value: "mycel-domain", + expErr: errorsmod.Wrapf(types.ErrInvalidTextRecordKey, "%s", "ETHEREUM_MAINNET_MAINNET"), + fn: func() {}, + }, + { + creator: testutil.Alice, + name: "hoge", + parent: "fuga", + key: "com.github", + value: "mycel-domain", + expErr: errorsmod.Wrapf(types.ErrSecondLevelDomainNotFound, "hoge.fuga"), + fn: func() {}, + }, + { + creator: testutil.Bob, + name: "foo", + parent: "cel", + key: "com.github", + value: "mycel-domain", + expErr: errorsmod.Wrapf(types.ErrSecondLevelDomainNotEditable, "%s", testutil.Bob), + fn: func() {}, + }, + } + for i, tc := range testCases { + suite.Run(fmt.Sprintf("Case %d", i), func() { + suite.SetupTest() + + // Register domain + domain := &types.MsgRegisterSecondLevelDomain{ + Creator: testutil.Alice, + Name: "foo", + Parent: "cel", + RegistrationPeriodInYear: 1, + } + _, err := suite.msgServer.RegisterSecondLevelDomain(suite.ctx, domain) + suite.Require().Nil(err) + // Run test case function + tc.fn() + + // Update dns record + msgUpdateRecord := &types.MsgUpdateTextRecord{ + Creator: tc.creator, + Name: tc.name, + Parent: tc.parent, + Key: tc.key, + Value: tc.value, + } + _, err = suite.msgServer.UpdateTextRecord(suite.ctx, msgUpdateRecord) + + if tc.expErr == nil { + // Check if the record is updated + suite.Require().Nil(err) + res, _ := suite.app.RegistryKeeper.GetSecondLevelDomain(suite.ctx, domain.Name, domain.Parent) + suite.Require().Equal(tc.value, res.GetTextRecord(tc.key)) + // Evalute events + events, found := testutil.FindEventsByType(suite.ctx.EventManager().Events(), types.EventTypeUpdateTextRecord) + suite.Require().True(found) + + for _, event := range events { + suite.Require().Equal(tc.name, event.Attributes[0].Value) + suite.Require().Equal(tc.parent, event.Attributes[1].Value) + suite.Require().Equal(tc.key, event.Attributes[2].Value) + suite.Require().Equal(tc.value, event.Attributes[3].Value) + } + } else { + suite.Require().EqualError(err, tc.expErr.Error()) + } + + }) + } + +} diff --git a/x/registry/module_simulation.go b/x/registry/module_simulation.go index 5c227986..d620bd98 100644 --- a/x/registry/module_simulation.go +++ b/x/registry/module_simulation.go @@ -44,6 +44,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgExtendTopLevelDomainExpirationDate int = 100 + opWeightMsgUpdateTextRecord = "op_weight_msg_update_text_record" + // TODO: Determine the simulation weight value + defaultWeightMsgUpdateTextRecord int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -127,6 +131,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp registrysimulation.SimulateMsgExtendTopLevelDomainExpirationDate(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgUpdateTextRecord int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateTextRecord, &weightMsgUpdateTextRecord, nil, + func(_ *rand.Rand) { + weightMsgUpdateTextRecord = defaultWeightMsgUpdateTextRecord + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgUpdateTextRecord, + registrysimulation.SimulateMsgUpdateTextRecord(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/registry/simulation/update_text_record.go b/x/registry/simulation/update_text_record.go new file mode 100644 index 00000000..2b537f34 --- /dev/null +++ b/x/registry/simulation/update_text_record.go @@ -0,0 +1,30 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/mycel-domain/mycel/x/registry/keeper" + "github.com/mycel-domain/mycel/x/registry/types" +) + +func SimulateMsgUpdateTextRecord( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgUpdateTextRecord{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the UpdateTextRecord simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "UpdateTextRecord simulation not implemented"), nil, nil + } +} diff --git a/x/registry/types/codec.go b/x/registry/types/codec.go index 1f72106b..65fb969b 100644 --- a/x/registry/types/codec.go +++ b/x/registry/types/codec.go @@ -13,6 +13,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgRegisterTopLevelDomain{}, "registry/RegisterTopLevelDomain", nil) cdc.RegisterConcrete(&MsgWithdrawRegistrationFee{}, "registry/WithdrawRegistrationFee", nil) cdc.RegisterConcrete(&MsgExtendTopLevelDomainExpirationDate{}, "registry/ExtendTopLevelDomainExpirationDate", nil) + cdc.RegisterConcrete(&MsgUpdateTextRecord{}, "registry/UpdateTextRecord", nil) // this line is used by starport scaffolding # 2 } @@ -32,6 +33,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgExtendTopLevelDomainExpirationDate{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgUpdateTextRecord{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/registry/types/errors.go b/x/registry/types/errors.go index 216b58ac..d8f5ee9d 100644 --- a/x/registry/types/errors.go +++ b/x/registry/types/errors.go @@ -37,6 +37,7 @@ var ( ErrInvalidWalletRecordType = errorsmod.Register(ModuleName, 1201, "invalid wallet record type") ErrInvalidDnsRecordValue = errorsmod.Register(ModuleName, 1202, "invalid dns record value") ErrInvalidDnsRecordType = errorsmod.Register(ModuleName, 1203, "invalid dns record type") + ErrInvalidTextRecordKey = errorsmod.Register(ModuleName, 1204, "invalid text record key, this key is reserved") ) // withdraw sentinel errors diff --git a/x/registry/types/events.go b/x/registry/types/events.go index 946c3594..7eadb7aa 100644 --- a/x/registry/types/events.go +++ b/x/registry/types/events.go @@ -43,6 +43,16 @@ const ( AttributeUpdateDnsRecordEventValue = "value" ) +// Update text record event +const ( + EventTypeUpdateTextRecord = "update-text-record" + + AttributeUpdateTextRecordEventDomainName = "name" + AttributeUpdateTextRecordEventDomainParent = "parent" + AttributeUpdateTextRecordEventKey = "key" + AttributeUpdateTextRecordEventValue = "value" +) + // Withdraw fees event const ( EventTypeWithdrawRegistrationFee = "withdraw-registration-fees" diff --git a/x/registry/types/message_update_text_record.go b/x/registry/types/message_update_text_record.go new file mode 100644 index 00000000..0467c5ac --- /dev/null +++ b/x/registry/types/message_update_text_record.go @@ -0,0 +1,49 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgUpdateTextRecord = "update_text_record" + +var _ sdk.Msg = &MsgUpdateTextRecord{} + +func NewMsgUpdateTextRecord(creator string, name string, parent string, key string, value string) *MsgUpdateTextRecord { + return &MsgUpdateTextRecord{ + Creator: creator, + Name: name, + Parent: parent, + Key: key, + Value: value, + } +} + +func (msg *MsgUpdateTextRecord) Route() string { + return RouterKey +} + +func (msg *MsgUpdateTextRecord) Type() string { + return TypeMsgUpdateTextRecord +} + +func (msg *MsgUpdateTextRecord) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateTextRecord) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateTextRecord) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/registry/types/message_update_text_record_test.go b/x/registry/types/message_update_text_record_test.go new file mode 100644 index 00000000..2f5be020 --- /dev/null +++ b/x/registry/types/message_update_text_record_test.go @@ -0,0 +1,41 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/testutil/sample" +) + +func TestMsgUpdateTextRecord_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateTextRecord + err error + }{ + { + name: "invalid address", + msg: MsgUpdateTextRecord{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgUpdateTextRecord{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/registry/types/secend_level_domain.go b/x/registry/types/secend_level_domain.go index e9ad1c06..9b063560 100644 --- a/x/registry/types/secend_level_domain.go +++ b/x/registry/types/secend_level_domain.go @@ -37,6 +37,15 @@ func (secondLevelDomain *SecondLevelDomain) GetDnsRecord(dnsRecordType string) s return "" } +func (secondLevelDomain *SecondLevelDomain) GetTextRecord(key string) string { + for _, rec := range secondLevelDomain.Records { + if rec.GetTextRecord() != nil && rec.GetTextRecord().Key == key { + return rec.GetTextRecord().Value + } + } + return "" +} + func GetWalletAddressFormat(walletRecordType string) (walletAddressFormat string, err error) { // Validate wallet record type err = ValidateWalletRecordType(walletRecordType) @@ -137,6 +146,34 @@ func (secondLevelDomain *SecondLevelDomain) UpdateDnsRecord(dnsRecordType string return err } +func (secondLevelDomain *SecondLevelDomain) UpdateTextRecord(key string, value string) (err error) { + err = ValidateTextRecordKey(key) + if err != nil { + return err + } + textRecord := &TextRecord{ + Key: key, + Value: value, + } + + record := &Record{ + Record: &Record_TextRecord{TextRecord: textRecord}, + } + + updated := false + for i, rec := range secondLevelDomain.Records { + if rec.GetTextRecord() != nil && rec.GetTextRecord().Key == key { + secondLevelDomain.Records[i] = record + updated = true + break + } + } + if !updated { + secondLevelDomain.Records = append(secondLevelDomain.Records, record) + } + return err +} + func (secondLevelDomain SecondLevelDomain) IsRecordEditable(sender string) (isEditable bool, err error) { role := secondLevelDomain.GetRole(sender) if role == DomainRole_NO_ROLE { diff --git a/x/registry/types/second_level_domain.pb.go b/x/registry/types/second_level_domain.pb.go index 3a30f28e..10c3e2fb 100644 --- a/x/registry/types/second_level_domain.pb.go +++ b/x/registry/types/second_level_domain.pb.go @@ -131,23 +131,23 @@ func (m *WalletRecord) GetValue() string { return "" } -type Metadata struct { +type TextRecord struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` } -func (m *Metadata) Reset() { *m = Metadata{} } -func (m *Metadata) String() string { return proto.CompactTextString(m) } -func (*Metadata) ProtoMessage() {} -func (*Metadata) Descriptor() ([]byte, []int) { +func (m *TextRecord) Reset() { *m = TextRecord{} } +func (m *TextRecord) String() string { return proto.CompactTextString(m) } +func (*TextRecord) ProtoMessage() {} +func (*TextRecord) Descriptor() ([]byte, []int) { return fileDescriptor_71a2ae6361ebd509, []int{2} } -func (m *Metadata) XXX_Unmarshal(b []byte) error { +func (m *TextRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *TextRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_Metadata.Marshal(b, m, deterministic) + return xxx_messageInfo_TextRecord.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -157,26 +157,26 @@ func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *Metadata) XXX_Merge(src proto.Message) { - xxx_messageInfo_Metadata.Merge(m, src) +func (m *TextRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_TextRecord.Merge(m, src) } -func (m *Metadata) XXX_Size() int { +func (m *TextRecord) XXX_Size() int { return m.Size() } -func (m *Metadata) XXX_DiscardUnknown() { - xxx_messageInfo_Metadata.DiscardUnknown(m) +func (m *TextRecord) XXX_DiscardUnknown() { + xxx_messageInfo_TextRecord.DiscardUnknown(m) } -var xxx_messageInfo_Metadata proto.InternalMessageInfo +var xxx_messageInfo_TextRecord proto.InternalMessageInfo -func (m *Metadata) GetKey() string { +func (m *TextRecord) GetKey() string { if m != nil { return m.Key } return "" } -func (m *Metadata) GetValue() string { +func (m *TextRecord) GetValue() string { if m != nil { return m.Value } @@ -188,7 +188,7 @@ type Record struct { // // *Record_DnsRecord // *Record_WalletRecord - // *Record_Metadata + // *Record_TextRecord Record isRecord_Record `protobuf_oneof:"record"` } @@ -237,13 +237,13 @@ type Record_DnsRecord struct { type Record_WalletRecord struct { WalletRecord *WalletRecord `protobuf:"bytes,2,opt,name=walletRecord,proto3,oneof" json:"walletRecord,omitempty"` } -type Record_Metadata struct { - Metadata *Metadata `protobuf:"bytes,3,opt,name=metadata,proto3,oneof" json:"metadata,omitempty"` +type Record_TextRecord struct { + TextRecord *TextRecord `protobuf:"bytes,3,opt,name=textRecord,proto3,oneof" json:"textRecord,omitempty"` } func (*Record_DnsRecord) isRecord_Record() {} func (*Record_WalletRecord) isRecord_Record() {} -func (*Record_Metadata) isRecord_Record() {} +func (*Record_TextRecord) isRecord_Record() {} func (m *Record) GetRecord() isRecord_Record { if m != nil { @@ -266,9 +266,9 @@ func (m *Record) GetWalletRecord() *WalletRecord { return nil } -func (m *Record) GetMetadata() *Metadata { - if x, ok := m.GetRecord().(*Record_Metadata); ok { - return x.Metadata +func (m *Record) GetTextRecord() *TextRecord { + if x, ok := m.GetRecord().(*Record_TextRecord); ok { + return x.TextRecord } return nil } @@ -278,7 +278,7 @@ func (*Record) XXX_OneofWrappers() []interface{} { return []interface{}{ (*Record_DnsRecord)(nil), (*Record_WalletRecord)(nil), - (*Record_Metadata)(nil), + (*Record_TextRecord)(nil), } } @@ -369,7 +369,7 @@ func (m *SecondLevelDomain) GetAccessControl() []*AccessControl { func init() { proto.RegisterType((*DnsRecord)(nil), "mycel.registry.DnsRecord") proto.RegisterType((*WalletRecord)(nil), "mycel.registry.WalletRecord") - proto.RegisterType((*Metadata)(nil), "mycel.registry.Metadata") + proto.RegisterType((*TextRecord)(nil), "mycel.registry.TextRecord") proto.RegisterType((*Record)(nil), "mycel.registry.Record") proto.RegisterType((*SecondLevelDomain)(nil), "mycel.registry.SecondLevelDomain") } @@ -379,40 +379,40 @@ func init() { } var fileDescriptor_71a2ae6361ebd509 = []byte{ - // 526 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x3d, 0x6f, 0xd3, 0x40, - 0x1c, 0xc6, 0xed, 0xbe, 0x84, 0xe4, 0x52, 0xa2, 0x72, 0xaa, 0x2a, 0x13, 0xc0, 0x09, 0x61, 0xc9, - 0x82, 0x8d, 0x82, 0x84, 0xc4, 0x48, 0x1a, 0x89, 0x0c, 0xa5, 0xc3, 0x51, 0x09, 0x89, 0x25, 0xba, - 0xd8, 0xff, 0x1a, 0xab, 0xf6, 0x9d, 0x75, 0xbe, 0x34, 0xf5, 0xb7, 0xe8, 0xcc, 0x27, 0x2a, 0x5b, - 0x47, 0x26, 0x40, 0xc9, 0x17, 0x41, 0xbe, 0xb3, 0x5b, 0xc7, 0x55, 0xb6, 0x7b, 0xe4, 0xdf, 0xf3, - 0x7f, 0xd3, 0x63, 0x34, 0x8c, 0x33, 0x0f, 0x22, 0x57, 0x40, 0x10, 0xa6, 0x52, 0x64, 0x6e, 0x0a, - 0x1e, 0x67, 0xfe, 0x2c, 0x82, 0x2b, 0x88, 0x66, 0x3e, 0x8f, 0x69, 0xc8, 0x9c, 0x44, 0x70, 0xc9, - 0x71, 0x47, 0x91, 0x4e, 0x49, 0x76, 0x8f, 0x02, 0x1e, 0x70, 0xf5, 0xc9, 0xcd, 0x5f, 0x9a, 0xea, - 0xf6, 0x02, 0xce, 0x83, 0x08, 0x5c, 0xa5, 0xe6, 0x8b, 0x0b, 0x57, 0x86, 0x31, 0xa4, 0x92, 0xc6, - 0x49, 0x09, 0xd4, 0x1a, 0xfa, 0x2c, 0x9d, 0x09, 0xf0, 0xb8, 0xf0, 0x0b,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 0x35, 0x84, 0x91, 0x20, 0x04, 0x00, 0x00, + // 525 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0xcf, 0x6e, 0xd3, 0x40, + 0x10, 0xc6, 0xed, 0xfe, 0x09, 0xcd, 0xa4, 0x44, 0xc5, 0xaa, 0x2a, 0x13, 0xc0, 0x09, 0xe1, 0x92, + 0x0b, 0x36, 0x0a, 0x5c, 0x90, 0xb8, 0x90, 0x46, 0x22, 0x87, 0xaa, 0x87, 0x25, 0x12, 0x12, 0x97, + 0xc8, 0x71, 0xa6, 0xc6, 0xaa, 0xbd, 0x6b, 0xad, 0x37, 0x4d, 0xfc, 0x16, 0x3d, 0xf3, 0x44, 0xbd, + 0xd1, 0x23, 0x27, 0x40, 0xc9, 0x8b, 0x20, 0xef, 0xda, 0x8d, 0xe3, 0x2a, 0xb7, 0x1d, 0xf9, 0xf7, + 0xcd, 0xcc, 0x37, 0xfa, 0x0c, 0xbd, 0x28, 0xf5, 0x30, 0x74, 0x38, 0xfa, 0x41, 0x22, 0x78, 0xea, + 0x24, 0xe8, 0x31, 0x3a, 0x9b, 0x84, 0x78, 0x83, 0xe1, 0x64, 0xc6, 0x22, 0x37, 0xa0, 0x76, 0xcc, + 0x99, 0x60, 0x46, 0x53, 0x92, 0x76, 0x41, 0xb6, 0x4e, 0x7d, 0xe6, 0x33, 0xf9, 0xc9, 0xc9, 0x5e, + 0x8a, 0x6a, 0xb5, 0x7d, 0xc6, 0xfc, 0x10, 0x1d, 0x59, 0x4d, 0xe7, 0x57, 0x8e, 0x08, 0x22, 0x4c, + 0x84, 0x1b, 0xc5, 0x05, 0x50, 0x19, 0x38, 0xa3, 0xc9, 0x84, 0xa3, 0xc7, 0xf8, 0x2c, 0x07, 0x5e, + 0x57, 0x00, 0x8a, 0x62, 0xc1, 0xf8, 0xf5, 0x84, 0xba, 0x11, 0xe6, 0xc8, 0x9b, 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 0x51, 0x35, 0x0c, 0x38, 0xc8, 0x72, 0x92, 0x1f, 0x44, 0xbe, 0x8d, 0x33, 0xa8, 0xc5, + 0x2e, 0x47, 0x2a, 0xf2, 0x93, 0xe4, 0x55, 0x76, 0x29, 0xb6, 0xa0, 0xc8, 0xe5, 0x12, 0x75, 0xa2, + 0x0a, 0xe3, 0x02, 0x9a, 0xb8, 0x8c, 0x03, 0xee, 0x8a, 0x80, 0xd1, 0xa1, 0x2b, 0xd0, 0x3c, 0xc8, + 0x77, 0x54, 0xc9, 0xb6, 0x8b, 0x64, 0xdb, 0xe3, 0x22, 0xd9, 0x83, 0xa3, 0xbb, 0x3f, 0x6d, 0xed, + 0xf6, 0x6f, 0x5b, 0x27, 0x15, 0xad, 0xf1, 0x0e, 0x9e, 0xa8, 0x7d, 0x13, 0xf3, 0xb0, 0xb3, 0xdf, + 0x6b, 0xf4, 0xcf, 0xaa, 0x56, 0x95, 0x31, 0x52, 0x60, 0x59, 0x52, 0x55, 0x9c, 0xcf, 0x55, 0x9a, + 0xcd, 0x9a, 0xd4, 0x3d, 0x4a, 0xea, 0xe7, 0x32, 0x44, 0xb6, 0x35, 0x83, 0xd1, 0xdd, 0xca, 0xd2, + 0xef, 0x57, 0x96, 0xfe, 0x6f, 0x65, 0xe9, 0xb7, 0x6b, 0x4b, 0xbb, 0x5f, 0x5b, 0xda, 0xef, 0xb5, + 0xa5, 0x7d, 0xb7, 0xfd, 0x40, 0xfc, 0x98, 0x4f, 0x6d, 0x8f, 0x45, 0x8e, 0xec, 0xf8, 0x56, 0xfd, + 0xe4, 0xaa, 0x70, 0x96, 0x9b, 0x9f, 0x4a, 0xa4, 0x31, 0x26, 0xd3, 0x9a, 0xb4, 0xfb, 0xfe, 0x7f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x9d, 0xe5, 0x68, 0x82, 0x28, 0x04, 0x00, 0x00, } func (m *DnsRecord) Marshal() (dAtA []byte, err error) { @@ -485,7 +485,7 @@ func (m *WalletRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Metadata) Marshal() (dAtA []byte, err error) { +func (m *TextRecord) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -495,12 +495,12 @@ func (m *Metadata) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Metadata) MarshalTo(dAtA []byte) (int, error) { +func (m *TextRecord) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *TextRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -596,16 +596,16 @@ func (m *Record_WalletRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { } return len(dAtA) - i, nil } -func (m *Record_Metadata) MarshalTo(dAtA []byte) (int, error) { +func (m *Record_TextRecord) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Record_Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Record_TextRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - if m.Metadata != nil { + if m.TextRecord != nil { { - size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.TextRecord.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -740,7 +740,7 @@ func (m *WalletRecord) Size() (n int) { return n } -func (m *Metadata) Size() (n int) { +func (m *TextRecord) Size() (n int) { if m == nil { return 0 } @@ -793,14 +793,14 @@ func (m *Record_WalletRecord) Size() (n int) { } return n } -func (m *Record_Metadata) Size() (n int) { +func (m *Record_TextRecord) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Metadata != nil { - l = m.Metadata.Size() + if m.TextRecord != nil { + l = m.TextRecord.Size() n += 1 + l + sovSecondLevelDomain(uint64(l)) } return n @@ -1048,7 +1048,7 @@ func (m *WalletRecord) Unmarshal(dAtA []byte) error { } return nil } -func (m *Metadata) Unmarshal(dAtA []byte) error { +func (m *TextRecord) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1071,10 +1071,10 @@ func (m *Metadata) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Metadata: wiretype end group for non-group") + return fmt.Errorf("proto: TextRecord: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TextRecord: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1263,7 +1263,7 @@ func (m *Record) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TextRecord", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1290,11 +1290,11 @@ func (m *Record) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &Metadata{} + v := &TextRecord{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Record = &Record_Metadata{v} + m.Record = &Record_TextRecord{v} iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/registry/types/second_level_domain_test.go b/x/registry/types/second_level_domain_test.go index 777d34c6..02b8687b 100644 --- a/x/registry/types/second_level_domain_test.go +++ b/x/registry/types/second_level_domain_test.go @@ -201,6 +201,34 @@ func TestDomainUpdateDnsRecord(t *testing.T) { } } +func TestDomainUpdateTextRecord(t *testing.T) { + testCases := []struct { + key string + value string + expErr error + }{ + { + key: "key1", + value: "value1", + }, + { + key: "ETHEREUM_MAINNET_MAINNET", + value: "value2", + expErr: errorsmod.Wrapf(ErrInvalidTextRecordKey, "ETHEREUM_MAINNET_MAINNET"), + }, + } + for _, tc := range testCases { + domain := SecondLevelDomain{Name: "foo", Parent: "myc"} + err := domain.UpdateTextRecord(tc.key, tc.value) + if tc.expErr == nil { + require.Nil(t, err) + require.Equal(t, tc.value, domain.GetTextRecord(tc.key)) + } else { + require.EqualError(t, err, tc.expErr.Error()) + } + } +} + func TestGetRoleSLD(t *testing.T) { testCases := []struct { domain SecondLevelDomain diff --git a/x/registry/types/tx.pb.go b/x/registry/types/tx.pb.go index a4092d83..46fa76cf 100644 --- a/x/registry/types/tx.pb.go +++ b/x/registry/types/tx.pb.go @@ -682,6 +682,118 @@ func (m *MsgExtendTopLevelDomainExpirationDateResponse) GetFee() *TopLevelDomain return nil } +type MsgUpdateTextRecord struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Parent string `protobuf:"bytes,3,opt,name=parent,proto3" json:"parent,omitempty"` + Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"` + Value string `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *MsgUpdateTextRecord) Reset() { *m = MsgUpdateTextRecord{} } +func (m *MsgUpdateTextRecord) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateTextRecord) ProtoMessage() {} +func (*MsgUpdateTextRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_7a4e7619dfc6612f, []int{12} +} +func (m *MsgUpdateTextRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateTextRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateTextRecord.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateTextRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateTextRecord.Merge(m, src) +} +func (m *MsgUpdateTextRecord) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateTextRecord) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateTextRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateTextRecord proto.InternalMessageInfo + +func (m *MsgUpdateTextRecord) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateTextRecord) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgUpdateTextRecord) GetParent() string { + if m != nil { + return m.Parent + } + return "" +} + +func (m *MsgUpdateTextRecord) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *MsgUpdateTextRecord) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +type MsgUpdateTextRecordResponse struct { +} + +func (m *MsgUpdateTextRecordResponse) Reset() { *m = MsgUpdateTextRecordResponse{} } +func (m *MsgUpdateTextRecordResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateTextRecordResponse) ProtoMessage() {} +func (*MsgUpdateTextRecordResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7a4e7619dfc6612f, []int{13} +} +func (m *MsgUpdateTextRecordResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateTextRecordResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateTextRecordResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUpdateTextRecordResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateTextRecordResponse.Merge(m, src) +} +func (m *MsgUpdateTextRecordResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateTextRecordResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateTextRecordResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateTextRecordResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgUpdateWalletRecord)(nil), "mycel.registry.MsgUpdateWalletRecord") proto.RegisterType((*MsgUpdateWalletRecordResponse)(nil), "mycel.registry.MsgUpdateWalletRecordResponse") @@ -695,56 +807,61 @@ func init() { proto.RegisterType((*MsgWithdrawRegistrationFeeResponse)(nil), "mycel.registry.MsgWithdrawRegistrationFeeResponse") proto.RegisterType((*MsgExtendTopLevelDomainExpirationDate)(nil), "mycel.registry.MsgExtendTopLevelDomainExpirationDate") proto.RegisterType((*MsgExtendTopLevelDomainExpirationDateResponse)(nil), "mycel.registry.MsgExtendTopLevelDomainExpirationDateResponse") + proto.RegisterType((*MsgUpdateTextRecord)(nil), "mycel.registry.MsgUpdateTextRecord") + proto.RegisterType((*MsgUpdateTextRecordResponse)(nil), "mycel.registry.MsgUpdateTextRecordResponse") } func init() { proto.RegisterFile("mycel/registry/tx.proto", fileDescriptor_7a4e7619dfc6612f) } var fileDescriptor_7a4e7619dfc6612f = []byte{ - // 697 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcf, 0x4f, 0x13, 0x41, - 0x14, 0xee, 0x58, 0x7e, 0xc4, 0x47, 0x04, 0xb3, 0xe1, 0xc7, 0xb2, 0xc1, 0x05, 0x36, 0x60, 0x90, - 0xd8, 0x5d, 0x29, 0x78, 0x31, 0xf1, 0x82, 0x40, 0xd4, 0xd8, 0xc4, 0xac, 0x18, 0xa2, 0x17, 0x32, - 0xed, 0x3e, 0x97, 0xd5, 0x76, 0x67, 0xb3, 0x33, 0x94, 0xf6, 0xe4, 0xc9, 0x93, 0x17, 0x4f, 0x1e, - 0xf4, 0x20, 0x67, 0xe3, 0x1f, 0xc2, 0x91, 0xa3, 0x27, 0x35, 0x10, 0xff, 0x0f, 0xd3, 0xd9, 0x76, - 0xd3, 0x96, 0xdd, 0x52, 0x08, 0x07, 0x4f, 0xbb, 0x33, 0xef, 0x7b, 0xdf, 0xfb, 0xde, 0xfc, 0xf8, - 0x32, 0x30, 0x55, 0xa9, 0x97, 0xb0, 0x6c, 0x85, 0xe8, 0x7a, 0x5c, 0x84, 0x75, 0x4b, 0xd4, 0xcc, - 0x20, 0x64, 0x82, 0x29, 0xa3, 0x32, 0x60, 0xb6, 0x02, 0x9a, 0x5e, 0x62, 0xbc, 0xc2, 0xb8, 0x55, - 0xa4, 0x1c, 0xad, 0xea, 0x4a, 0x11, 0x05, 0x5d, 0xb1, 0x4a, 0xcc, 0xf3, 0x23, 0xbc, 0x36, 0xee, - 0x32, 0x97, 0xc9, 0x5f, 0xab, 0xf1, 0xd7, 0x9c, 0x5d, 0xec, 0xa6, 0x67, 0xc1, 0x6e, 0x19, 0xab, - 0x58, 0xde, 0x75, 0x58, 0x85, 0xb6, 0x92, 0x8d, 0x6f, 0x04, 0x26, 0x0a, 0xdc, 0x7d, 0x19, 0x38, - 0x54, 0xe0, 0x0e, 0x2d, 0x97, 0x51, 0xd8, 0x58, 0x62, 0xa1, 0xa3, 0xa8, 0x30, 0x5c, 0x0a, 0x91, - 0x0a, 0x16, 0xaa, 0x64, 0x8e, 0x2c, 0x5d, 0xb7, 0x5b, 0x43, 0x45, 0x81, 0x01, 0x9f, 0x56, 0x50, - 0xbd, 0x26, 0xa7, 0xe5, 0xbf, 0x32, 0x09, 0x43, 0x01, 0x0d, 0xd1, 0x17, 0x6a, 0x56, 0xce, 0x36, - 0x47, 0xca, 0x32, 0xdc, 0x3c, 0x68, 0x63, 0xdd, 0xae, 0x07, 0xa8, 0x0e, 0x48, 0xc4, 0x99, 0x79, - 0x65, 0x1c, 0x06, 0xab, 0xb4, 0xbc, 0x8f, 0xea, 0xa0, 0x04, 0x44, 0x03, 0x63, 0x16, 0x6e, 0x25, - 0x0a, 0xb4, 0x91, 0x07, 0xcc, 0xe7, 0x68, 0x7c, 0x26, 0xa0, 0xc4, 0x88, 0x0d, 0x9f, 0x5f,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b5, 0xc4, 0xad, 0x3f, 0x3e, 0x3a, - 0xd1, 0xc9, 0xf1, 0x89, 0x4e, 0xfe, 0x9c, 0xe8, 0xe4, 0xd3, 0xa9, 0x9e, 0x39, 0x3e, 0xd5, 0x33, - 0x3f, 0x4f, 0xf5, 0xcc, 0x6b, 0xb3, 0xcd, 0x79, 0x64, 0x89, 0x5c, 0xf4, 0x6e, 0x89, 0x06, 0x56, - 0xad, 0xed, 0x65, 0xd3, 0x70, 0xa1, 0xe2, 0x90, 0x7c, 0xcf, 0xac, 0xfe, 0x0b, 0x00, 0x00, 0xff, - 0xff, 0xc0, 0xa4, 0xb3, 0xef, 0x57, 0x09, 0x00, 0x00, + // 748 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcf, 0x4f, 0x13, 0x4f, + 0x14, 0xef, 0x7c, 0xcb, 0x8f, 0x7c, 0x1f, 0x11, 0xc8, 0xca, 0x8f, 0x65, 0x85, 0x05, 0x56, 0x30, + 0x88, 0x76, 0x57, 0x0a, 0x5e, 0x4c, 0xbc, 0x20, 0x10, 0x35, 0x36, 0x31, 0x2b, 0x86, 0xe8, 0x85, + 0x6c, 0xbb, 0xcf, 0x65, 0xa5, 0xdd, 0xd9, 0xec, 0x0c, 0xa5, 0x3d, 0x79, 0x30, 0x9e, 0xbc, 0x78, + 0xf2, 0xa0, 0x07, 0x39, 0x1b, 0xff, 0x10, 0x12, 0x2f, 0x1c, 0x3d, 0xa9, 0x81, 0x7f, 0xc4, 0x74, + 0xb6, 0x5d, 0xdb, 0xb2, 0x5b, 0x0a, 0xe1, 0xe0, 0xa9, 0x33, 0xf3, 0x3e, 0xef, 0x33, 0x9f, 0x37, + 0xf3, 0xf6, 0xd3, 0x81, 0xf1, 0x52, 0xb5, 0x80, 0x45, 0x23, 0x40, 0xc7, 0x65, 0x3c, 0xa8, 0x1a, + 0xbc, 0xa2, 0xfb, 0x01, 0xe5, 0x54, 0x1a, 0x14, 0x01, 0xbd, 0x11, 0x50, 0xd4, 0x02, 0x65, 0x25, + 0xca, 0x8c, 0xbc, 0xc5, 0xd0, 0x28, 0x2f, 0xe5, 0x91, 0x5b, 0x4b, 0x46, 0x81, 0xba, 0x5e, 0x88, + 0x57, 0x46, 0x1c, 0xea, 0x50, 0x31, 0x34, 0x6a, 0xa3, 0xfa, 0xea, 0x7c, 0x3b, 0x3d, 0xf5, 0xb7, + 0x8b, 0x58, 0xc6, 0xe2, 0xb6, 0x4d, 0x4b, 0x56, 0x23, 0x59, 0xfb, 0x42, 0x60, 0x34, 0xc7, 0x9c, + 0xe7, 0xbe, 0x6d, 0x71, 0xdc, 0xb2, 0x8a, 0x45, 0xe4, 0x26, 0x16, 0x68, 0x60, 0x4b, 0x32, 0xf4, + 0x17, 0x02, 0xb4, 0x38, 0x0d, 0x64, 0x32, 0x43, 0x16, 0xfe, 0x37, 0x1b, 0x53, 0x49, 0x82, 0x1e, + 0xcf, 0x2a, 0xa1, 0xfc, 0x9f, 0x58, 0x16, 0x63, 0x69, 0x0c, 0xfa, 0x7c, 0x2b, 0x40, 0x8f, 0xcb, + 0x69, 0xb1, 0x5a, 0x9f, 0x49, 0x8b, 0x30, 0xbc, 0xdf, 0xc4, 0xba, 0x59, 0xf5, 0x51, 0xee, 0x11, + 0x88, 0x53, 0xeb, 0xd2, 0x08, 0xf4, 0x96, 0xad, 0xe2, 0x1e, 0xca, 0xbd, 0x02, 0x10, 0x4e, 0xb4, + 0x69, 0x98, 0x8a, 0x15, 0x68, 0x22, 0xf3, 0xa9, 0xc7, 0x50, 0xfb, 0x48, 0x40, 0x8a, 0x10, 0x6b, + 0x1e, 0xbb, 0x54, 0xfd, 0x73, 0x70, 0xc5, 0x6e, 0x50, 0x36, 0x89, 0x6f, 0x5d, 0x4c, 0x50, 0x3e, + 0x09, 0xca, 0x69, 0x5d, 0x91, 0xec, 0x03, 0x02, 0x93, 0x39, 0xe6, 0x98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 0xfb, 0x17, 0x4a, 0x8b, 0xc4, 0xd9, 0x30, + 0x7c, 0xea, 0x43, 0xbc, 0x9e, 0xd8, 0x50, 0x7f, 0x41, 0xca, 0xad, 0x2e, 0x40, 0x8d, 0x5d, 0x56, + 0x1f, 0x1e, 0x1e, 0xab, 0xe4, 0xe8, 0x58, 0x25, 0xbf, 0x8f, 0x55, 0xf2, 0xe1, 0x44, 0x4d, 0x1d, + 0x9d, 0xa8, 0xa9, 0x1f, 0x27, 0x6a, 0xea, 0xa5, 0xde, 0x64, 0xc2, 0x82, 0x30, 0x13, 0x3e, 0xe1, + 0xc2, 0x89, 0x51, 0x69, 0x7a, 0xe4, 0xd5, 0x0c, 0x39, 0xdf, 0x27, 0x9e, 0x76, 0xcb, 0x7f, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x7a, 0x5b, 0x88, 0x2a, 0x62, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -765,6 +882,7 @@ type MsgClient interface { RegisterTopLevelDomain(ctx context.Context, in *MsgRegisterTopLevelDomain, opts ...grpc.CallOption) (*MsgRegisterTopLevelDomainResponse, error) WithdrawRegistrationFee(ctx context.Context, in *MsgWithdrawRegistrationFee, opts ...grpc.CallOption) (*MsgWithdrawRegistrationFeeResponse, error) ExtendTopLevelDomainExpirationDate(ctx context.Context, in *MsgExtendTopLevelDomainExpirationDate, opts ...grpc.CallOption) (*MsgExtendTopLevelDomainExpirationDateResponse, error) + UpdateTextRecord(ctx context.Context, in *MsgUpdateTextRecord, opts ...grpc.CallOption) (*MsgUpdateTextRecordResponse, error) } type msgClient struct { @@ -829,6 +947,15 @@ func (c *msgClient) ExtendTopLevelDomainExpirationDate(ctx context.Context, in * return out, nil } +func (c *msgClient) UpdateTextRecord(ctx context.Context, in *MsgUpdateTextRecord, opts ...grpc.CallOption) (*MsgUpdateTextRecordResponse, error) { + out := new(MsgUpdateTextRecordResponse) + err := c.cc.Invoke(ctx, "/mycel.registry.Msg/UpdateTextRecord", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { UpdateWalletRecord(context.Context, *MsgUpdateWalletRecord) (*MsgUpdateWalletRecordResponse, error) @@ -837,6 +964,7 @@ type MsgServer interface { RegisterTopLevelDomain(context.Context, *MsgRegisterTopLevelDomain) (*MsgRegisterTopLevelDomainResponse, error) WithdrawRegistrationFee(context.Context, *MsgWithdrawRegistrationFee) (*MsgWithdrawRegistrationFeeResponse, error) ExtendTopLevelDomainExpirationDate(context.Context, *MsgExtendTopLevelDomainExpirationDate) (*MsgExtendTopLevelDomainExpirationDateResponse, error) + UpdateTextRecord(context.Context, *MsgUpdateTextRecord) (*MsgUpdateTextRecordResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -861,6 +989,9 @@ func (*UnimplementedMsgServer) WithdrawRegistrationFee(ctx context.Context, req func (*UnimplementedMsgServer) ExtendTopLevelDomainExpirationDate(ctx context.Context, req *MsgExtendTopLevelDomainExpirationDate) (*MsgExtendTopLevelDomainExpirationDateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ExtendTopLevelDomainExpirationDate not implemented") } +func (*UnimplementedMsgServer) UpdateTextRecord(ctx context.Context, req *MsgUpdateTextRecord) (*MsgUpdateTextRecordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateTextRecord not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -974,6 +1105,24 @@ func _Msg_ExtendTopLevelDomainExpirationDate_Handler(srv interface{}, ctx contex return interceptor(ctx, in, info, handler) } +func _Msg_UpdateTextRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateTextRecord) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateTextRecord(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mycel.registry.Msg/UpdateTextRecord", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateTextRecord(ctx, req.(*MsgUpdateTextRecord)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "mycel.registry.Msg", HandlerType: (*MsgServer)(nil), @@ -1002,6 +1151,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ExtendTopLevelDomainExpirationDate", Handler: _Msg_ExtendTopLevelDomainExpirationDate_Handler, }, + { + MethodName: "UpdateTextRecord", + Handler: _Msg_UpdateTextRecord_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "mycel/registry/tx.proto", @@ -1493,6 +1646,87 @@ func (m *MsgExtendTopLevelDomainExpirationDateResponse) MarshalToSizedBuffer(dAt return len(dAtA) - i, nil } +func (m *MsgUpdateTextRecord) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateTextRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateTextRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintTx(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x2a + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintTx(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x22 + } + if len(m.Parent) > 0 { + i -= len(m.Parent) + copy(dAtA[i:], m.Parent) + i = encodeVarintTx(dAtA, i, uint64(len(m.Parent))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateTextRecordResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgUpdateTextRecordResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateTextRecordResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1719,6 +1953,44 @@ func (m *MsgExtendTopLevelDomainExpirationDateResponse) Size() (n int) { return n } +func (m *MsgUpdateTextRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Parent) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateTextRecordResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3168,6 +3440,266 @@ func (m *MsgExtendTopLevelDomainExpirationDateResponse) Unmarshal(dAtA []byte) e } return nil } +func (m *MsgUpdateTextRecord) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateTextRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateTextRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Parent", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Parent = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateTextRecordResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateTextRecordResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateTextRecordResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/registry/types/validate_second_level_domain.go b/x/registry/types/validate_second_level_domain.go index 0c05e2bb..33994e95 100644 --- a/x/registry/types/validate_second_level_domain.go +++ b/x/registry/types/validate_second_level_domain.go @@ -77,3 +77,15 @@ func ValidateDnsRecordType(dnsRecordType string) (err error) { } return err } + +func ValidateTextRecordKey(textRecordKey string) (err error) { + _, isFound := NetworkName_value[textRecordKey] + if isFound { + err = errorsmod.Wrapf(ErrInvalidTextRecordKey, "%s", textRecordKey) + } + _, isFound = DnsRecordType_value[textRecordKey] + if isFound { + err = errorsmod.Wrapf(ErrInvalidTextRecordKey, "%s", textRecordKey) + } + return err +} diff --git a/x/resolver/client/cli/query.go b/x/resolver/client/cli/query.go index 6c6798e0..2be00395 100644 --- a/x/resolver/client/cli/query.go +++ b/x/resolver/client/cli/query.go @@ -27,6 +27,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdAllRecord()) + cmd.AddCommand(CmdTextRecord()) + // this line is used by starport scaffolding # 1 return cmd diff --git a/x/resolver/client/cli/query_text_record.go b/x/resolver/client/cli/query_text_record.go new file mode 100644 index 00000000..97c6a665 --- /dev/null +++ b/x/resolver/client/cli/query_text_record.go @@ -0,0 +1,51 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/resolver/types" +) + +var _ = strconv.Itoa(0) + +func CmdTextRecord() *cobra.Command { + cmd := &cobra.Command{ + Use: "text-record [domain-name] [domain-parent] [key]", + Short: "Query textRecord", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqDomainName := args[0] + reqDomainParent := args[1] + reqKey := args[2] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryTextRecordRequest{ + + DomainName: reqDomainName, + DomainParent: reqDomainParent, + Key: reqKey, + } + + res, err := queryClient.TextRecord(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/resolver/keeper/query_all_records.go b/x/resolver/keeper/query_all_records.go index 06949d9b..9eeef0f6 100644 --- a/x/resolver/keeper/query_all_records.go +++ b/x/resolver/keeper/query_all_records.go @@ -45,8 +45,8 @@ func generateRecordKey(record *registrytypes.Record) string { return record.GetDnsRecord().DnsRecordType.String() case record.GetWalletRecord() != nil: return record.GetWalletRecord().WalletRecordType.String() - case record.GetMetadata() != nil: - return record.GetMetadata().Key + case record.GetTextRecord() != nil: + return record.GetTextRecord().Key default: return "" } diff --git a/x/resolver/keeper/query_text_record.go b/x/resolver/keeper/query_text_record.go new file mode 100644 index 00000000..921a069e --- /dev/null +++ b/x/resolver/keeper/query_text_record.go @@ -0,0 +1,42 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + registrytypes "github.com/mycel-domain/mycel/x/registry/types" + "github.com/mycel-domain/mycel/x/resolver/types" +) + +func (k Keeper) TextRecord(goCtx context.Context, req *types.QueryTextRecordRequest) (*types.QueryTextRecordResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + // Validate request parameters + err := registrytypes.ValidateTextRecordKey(req.Key) + if err != nil { + return nil, err + } + + // Query domain record + _, err = k.registryKeeper.GetValidTopLevelDomain(ctx, req.DomainParent) + if err != nil { + return nil, err + } + secondLevelDomain, err := k.registryKeeper.GetValidSecondLevelDomain(ctx, req.DomainName, req.DomainParent) + if err != nil { + return nil, err + } + + value := secondLevelDomain.GetTextRecord(req.Key) + + return &types.QueryTextRecordResponse{ + Value: ®istrytypes.TextRecord{Key: req.Key, Value: value}, + }, nil +} diff --git a/x/resolver/types/query.pb.go b/x/resolver/types/query.pb.go index 679f54a0..f14917fd 100644 --- a/x/resolver/types/query.pb.go +++ b/x/resolver/types/query.pb.go @@ -418,6 +418,110 @@ func (m *QueryAllRecordsResponse) GetValues() map[string]*types.Record { return nil } +type QueryTextRecordRequest struct { + DomainName string `protobuf:"bytes,1,opt,name=domainName,proto3" json:"domainName,omitempty"` + DomainParent string `protobuf:"bytes,2,opt,name=domainParent,proto3" json:"domainParent,omitempty"` + Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` +} + +func (m *QueryTextRecordRequest) Reset() { *m = QueryTextRecordRequest{} } +func (m *QueryTextRecordRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTextRecordRequest) ProtoMessage() {} +func (*QueryTextRecordRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b8c2c421969ccc6b, []int{8} +} +func (m *QueryTextRecordRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTextRecordRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTextRecordRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTextRecordRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTextRecordRequest.Merge(m, src) +} +func (m *QueryTextRecordRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTextRecordRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTextRecordRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTextRecordRequest proto.InternalMessageInfo + +func (m *QueryTextRecordRequest) GetDomainName() string { + if m != nil { + return m.DomainName + } + return "" +} + +func (m *QueryTextRecordRequest) GetDomainParent() string { + if m != nil { + return m.DomainParent + } + return "" +} + +func (m *QueryTextRecordRequest) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +type QueryTextRecordResponse struct { + Value *types.TextRecord `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *QueryTextRecordResponse) Reset() { *m = QueryTextRecordResponse{} } +func (m *QueryTextRecordResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTextRecordResponse) ProtoMessage() {} +func (*QueryTextRecordResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b8c2c421969ccc6b, []int{9} +} +func (m *QueryTextRecordResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTextRecordResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTextRecordResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTextRecordResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTextRecordResponse.Merge(m, src) +} +func (m *QueryTextRecordResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTextRecordResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTextRecordResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTextRecordResponse proto.InternalMessageInfo + +func (m *QueryTextRecordResponse) GetValue() *types.TextRecord { + if m != nil { + return m.Value + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "mycel.resolver.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "mycel.resolver.QueryParamsResponse") @@ -428,54 +532,60 @@ func init() { proto.RegisterType((*QueryAllRecordsRequest)(nil), "mycel.resolver.QueryAllRecordsRequest") proto.RegisterType((*QueryAllRecordsResponse)(nil), "mycel.resolver.QueryAllRecordsResponse") proto.RegisterMapType((map[string]*types.Record)(nil), "mycel.resolver.QueryAllRecordsResponse.ValuesEntry") + proto.RegisterType((*QueryTextRecordRequest)(nil), "mycel.resolver.QueryTextRecordRequest") + proto.RegisterType((*QueryTextRecordResponse)(nil), "mycel.resolver.QueryTextRecordResponse") } func init() { proto.RegisterFile("mycel/resolver/query.proto", fileDescriptor_b8c2c421969ccc6b) } var fileDescriptor_b8c2c421969ccc6b = []byte{ - // 661 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xdf, 0x4e, 0x13, 0x41, - 0x14, 0xc6, 0xbb, 0x45, 0x9a, 0x70, 0x40, 0x43, 0x46, 0xc4, 0xb2, 0x92, 0xd5, 0x2c, 0x82, 0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xd8, 0x2f, 0x1d, 0xd1, 0xd3, 0xf6, 0x7d, 0x09, 0x7f, 0x07, 0x2d, 0x0f, 0x84, - 0x27, 0x8c, 0x69, 0x78, 0x31, 0x88, 0x7e, 0xe9, 0xee, 0xf6, 0xae, 0x65, 0xec, 0xec, 0x5a, 0xc6, - 0x9f, 0x5d, 0xcb, 0xf8, 0xb4, 0x67, 0xe5, 0x76, 0xf6, 0xac, 0xdc, 0xaf, 0x3d, 0x2b, 0xf7, 0xc2, - 0x71, 0x1b, 0xe1, 0xab, 0x56, 0xd5, 0xa9, 0xf1, 0x66, 0xd6, 0x4b, 0x6f, 0x7b, 0x6f, 0x85, 0x91, - 0x4f, 0x45, 0xb5, 0x20, 0xff, 0x35, 0x16, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x95, 0x14, 0x55, - 0xd8, 0x0a, 0x07, 0x00, 0x00, + // 730 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0xc1, 0x4f, 0x13, 0x4f, + 0x14, 0xc7, 0xbb, 0xed, 0x8f, 0x26, 0x0c, 0xfc, 0x0c, 0x19, 0x11, 0xcb, 0x4a, 0x56, 0x33, 0x08, + 0x56, 0xd4, 0x1d, 0x29, 0x1e, 0x8c, 0x37, 0x09, 0x1a, 0x15, 0xa2, 0x50, 0x51, 0xa3, 0x98, 0x90, + 0x69, 0x3b, 0x59, 0x1b, 0xb6, 0x3b, 0xcb, 0xce, 0xb6, 0xb2, 0x21, 0x35, 0xd1, 0xa3, 0x27, 0x13, + 0xff, 0x0c, 0x4f, 0x9e, 0x8c, 0xff, 0x80, 0xe1, 0x48, 0xe2, 0xc5, 0x93, 0x31, 0xe0, 0xd1, 0x3f, + 0xc2, 0x74, 0x66, 0x4a, 0x77, 0xb7, 0xdb, 0xd2, 0x03, 0xde, 0xb6, 0x6f, 0xde, 0x7b, 0xf3, 0xf9, + 0xbe, 0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0, 0xed, 0x1a, 0xca, 0x1e, 0xb4, 0xdd, 0xc3, 0x84, 0x8a, 0x82, 0x76, + 0x05, 0x3e, 0xe8, 0x4b, 0xeb, 0xd3, 0x9d, 0xc1, 0x1a, 0x65, 0x8b, 0x06, 0xcd, 0xc5, 0x7b, 0x7b, + 0x07, 0x86, 0xb6, 0x7f, 0x60, 0x68, 0xbf, 0x0e, 0x0c, 0xed, 0xc3, 0xa1, 0x91, 0xda, 0x3f, 0x34, + 0x52, 0x3f, 0x0e, 0x8d, 0xd4, 0x0b, 0xd3, 0xaa, 0xfa, 0xaf, 0xea, 0x25, 0xb3, 0xcc, 0x6a, 0x49, + 0xf7, 0xed, 0x84, 0x6e, 0x0c, 0x5c, 0xca, 0x4b, 0x59, 0xf1, 0x37, 0xbd, 0xf0, 0x37, 0x00, 0x00, + 0xff, 0xff, 0x4d, 0xac, 0x8e, 0xb1, 0x7b, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -498,6 +608,8 @@ type QueryClient interface { DnsRecord(ctx context.Context, in *QueryDnsRecordRequest, opts ...grpc.CallOption) (*QueryDnsRecordResponse, error) // Queries a list of AllRecord items. AllRecords(ctx context.Context, in *QueryAllRecordsRequest, opts ...grpc.CallOption) (*QueryAllRecordsResponse, error) + // Queries a list of TextRecord items. + TextRecord(ctx context.Context, in *QueryTextRecordRequest, opts ...grpc.CallOption) (*QueryTextRecordResponse, error) } type queryClient struct { @@ -544,6 +656,15 @@ func (c *queryClient) AllRecords(ctx context.Context, in *QueryAllRecordsRequest return out, nil } +func (c *queryClient) TextRecord(ctx context.Context, in *QueryTextRecordRequest, opts ...grpc.CallOption) (*QueryTextRecordResponse, error) { + out := new(QueryTextRecordResponse) + err := c.cc.Invoke(ctx, "/mycel.resolver.Query/TextRecord", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -554,6 +675,8 @@ type QueryServer interface { DnsRecord(context.Context, *QueryDnsRecordRequest) (*QueryDnsRecordResponse, error) // Queries a list of AllRecord items. AllRecords(context.Context, *QueryAllRecordsRequest) (*QueryAllRecordsResponse, error) + // Queries a list of TextRecord items. + TextRecord(context.Context, *QueryTextRecordRequest) (*QueryTextRecordResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -572,6 +695,9 @@ func (*UnimplementedQueryServer) DnsRecord(ctx context.Context, req *QueryDnsRec func (*UnimplementedQueryServer) AllRecords(ctx context.Context, req *QueryAllRecordsRequest) (*QueryAllRecordsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AllRecords not implemented") } +func (*UnimplementedQueryServer) TextRecord(ctx context.Context, req *QueryTextRecordRequest) (*QueryTextRecordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TextRecord not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -649,6 +775,24 @@ func _Query_AllRecords_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Query_TextRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTextRecordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TextRecord(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mycel.resolver.Query/TextRecord", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TextRecord(ctx, req.(*QueryTextRecordRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "mycel.resolver.Query", HandlerType: (*QueryServer)(nil), @@ -669,6 +813,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "AllRecords", Handler: _Query_AllRecords_Handler, }, + { + MethodName: "TextRecord", + Handler: _Query_TextRecord_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "mycel/resolver/query.proto", @@ -974,6 +1122,85 @@ func (m *QueryAllRecordsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *QueryTextRecordRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTextRecordRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTextRecordRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x1a + } + if len(m.DomainParent) > 0 { + i -= len(m.DomainParent) + copy(dAtA[i:], m.DomainParent) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DomainParent))) + i-- + dAtA[i] = 0x12 + } + if len(m.DomainName) > 0 { + i -= len(m.DomainName) + copy(dAtA[i:], m.DomainName) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DomainName))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTextRecordResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTextRecordResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTextRecordResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != nil { + { + size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1112,6 +1339,40 @@ func (m *QueryAllRecordsResponse) Size() (n int) { return n } +func (m *QueryTextRecordRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DomainName) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.DomainParent) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTextRecordResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != nil { + l = m.Value.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2008,6 +2269,238 @@ func (m *QueryAllRecordsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryTextRecordRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTextRecordRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTextRecordRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DomainName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DomainName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DomainParent", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DomainParent = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTextRecordResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTextRecordResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTextRecordResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Value == nil { + m.Value = &types.TextRecord{} + } + if err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/resolver/types/query.pb.gw.go b/x/resolver/types/query.pb.gw.go index dd3e50f9..488cf3ea 100644 --- a/x/resolver/types/query.pb.gw.go +++ b/x/resolver/types/query.pb.gw.go @@ -323,6 +323,104 @@ func local_request_Query_AllRecords_0(ctx context.Context, marshaler runtime.Mar } +func request_Query_TextRecord_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTextRecordRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["domainName"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "domainName") + } + + protoReq.DomainName, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "domainName", err) + } + + val, ok = pathParams["domainParent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "domainParent") + } + + protoReq.DomainParent, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "domainParent", err) + } + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := client.TextRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TextRecord_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTextRecordRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["domainName"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "domainName") + } + + protoReq.DomainName, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "domainName", err) + } + + val, ok = pathParams["domainParent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "domainParent") + } + + protoReq.DomainParent, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "domainParent", err) + } + + val, ok = pathParams["key"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "key") + } + + protoReq.Key, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "key", err) + } + + msg, err := server.TextRecord(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -421,6 +519,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_TextRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TextRecord_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TextRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -542,6 +663,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_TextRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TextRecord_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TextRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -553,6 +694,8 @@ var ( pattern_Query_DnsRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 1, 0, 4, 1, 5, 6}, []string{"mycel-domain", "mycel", "resolver", "dns_record", "domainName", "domainParent", "dnsRecordType"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_AllRecords_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"mycel-domain", "mycel", "resolver", "all_records", "domainName", "domainParent"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TextRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5, 1, 0, 4, 1, 5, 6}, []string{"mycel-domain", "mycel", "resolver", "text_record", "domainName", "domainParent", "key"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -563,4 +706,6 @@ var ( forward_Query_DnsRecord_0 = runtime.ForwardResponseMessage forward_Query_AllRecords_0 = runtime.ForwardResponseMessage + + forward_Query_TextRecord_0 = runtime.ForwardResponseMessage )