diff --git a/README.md b/README.md index 74d903a1..8d293b46 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# mycel -**mycel** is a blockchain built using Cosmos SDK and Tendermint and created with [Ignite CLI](https://ignite.com/cli). +# Mycel +**Mycel** is a Decentralized ID Infrastructure solution that resolves addresses such as websites, crypto wallets, IPFS, among many more accessible through a single domain with name resolution support in DNS, IBC and smart contracts. ## Dependencies - Go `1.20.2` @@ -152,9 +152,7 @@ curl https://get.ignite.com/mycel-domain/mycel@latest! | sudo bash ``` ## Learn more - -- [Ignite CLI](https://ignite.com/cli) -- [Tutorials](https://docs.ignite.com/guide) -- [Ignite CLI docs](https://docs.ignite.com) -- [Cosmos SDK docs](https://docs.cosmos.network) -- [Developer Chat](https://discord.gg/ignite) +- [Website](https://mycel.domains) +- [Mycel Docs](https://docs.mycel.domains) +- [Discord](https://discord.gg/h2jSkBETan) +- [X](https://twitter.com/myceldomain) diff --git a/app/app.go b/app/app.go index 22810763..36eec513 100644 --- a/app/app.go +++ b/app/app.go @@ -126,6 +126,9 @@ import ( epochsmodulekeeper "github.com/mycel-domain/mycel/x/epochs/keeper" epochsmoduletypes "github.com/mycel-domain/mycel/x/epochs/types" + resolvermodule "github.com/mycel-domain/mycel/x/resolver" + resolvermodulekeeper "github.com/mycel-domain/mycel/x/resolver/keeper" + resolvermoduletypes "github.com/mycel-domain/mycel/x/resolver/types" // this line is used by starport scaffolding # stargate/app/moduleImport appparams "github.com/mycel-domain/mycel/app/params" @@ -232,6 +235,7 @@ var ( // my modules registrymodule.AppModuleBasic{}, epochsmodule.AppModuleBasic{}, + resolvermodule.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -317,6 +321,8 @@ type App struct { // my mnodules RegistryKeeper registrymodulekeeper.Keeper EpochsKeeper epochsmodulekeeper.Keeper + + ResolverKeeper resolvermodulekeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // mm is the module manager @@ -403,6 +409,7 @@ func NewApp( // my modules registrymoduletypes.StoreKey, epochsmoduletypes.StoreKey, + resolvermoduletypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -683,6 +690,16 @@ func NewApp( ) registryModule := registrymodule.NewAppModule(appCodec, app.RegistryKeeper, app.AccountKeeper, app.BankKeeper) + app.ResolverKeeper = *resolvermodulekeeper.NewKeeper( + appCodec, + keys[resolvermoduletypes.StoreKey], + keys[resolvermoduletypes.MemStoreKey], + app.GetSubspace(resolvermoduletypes.ModuleName), + + app.RegistryKeeper, + ) + resolverModule := resolvermodule.NewAppModule(appCodec, app.ResolverKeeper, app.AccountKeeper, app.BankKeeper) + // this line is used by starport scaffolding # stargate/app/keeperDefinition /**** IBC Routing ****/ @@ -754,6 +771,7 @@ func NewApp( // my modules registryModule, epochsModule, + resolverModule, // this line is used by starport scaffolding # stargate/app/appModule crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them @@ -791,6 +809,7 @@ func NewApp( // my modules registrymoduletypes.ModuleName, epochsmoduletypes.ModuleName, + resolvermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/beginBlockers ) @@ -821,6 +840,7 @@ func NewApp( // my modules registrymoduletypes.ModuleName, epochsmoduletypes.ModuleName, + resolvermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/endBlockers ) @@ -857,6 +877,7 @@ func NewApp( // my modules registrymoduletypes.ModuleName, epochsmoduletypes.ModuleName, + resolvermoduletypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis } app.mm.SetOrderInitGenesis(genesisModuleOrder...) @@ -1119,6 +1140,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino // my modules paramsKeeper.Subspace(registrymoduletypes.ModuleName) paramsKeeper.Subspace(epochsmoduletypes.ModuleName) + paramsKeeper.Subspace(resolvermoduletypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/app/simulation_test.go b/app/simulation_test.go index ad9944bc..fa28474d 100644 --- a/app/simulation_test.go +++ b/app/simulation_test.go @@ -89,7 +89,6 @@ func BenchmarkSimulation(b *testing.B) { appOptions[flags.FlagHome] = app.DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = simcli.FlagPeriodValue - wasmOpt := []wasmkeeper.Option{} bApp := app.New( diff --git a/cmd/myceld/cmd/root.go b/cmd/myceld/cmd/root.go index de3d1bff..83109891 100644 --- a/cmd/myceld/cmd/root.go +++ b/cmd/myceld/cmd/root.go @@ -37,6 +37,7 @@ import ( "github.com/spf13/cast" "github.com/spf13/cobra" "github.com/spf13/pflag" + // this line is used by starport scaffolding # root/moduleImport // CosmWasm @@ -45,6 +46,7 @@ import ( "github.com/mycel-domain/mycel/app" appparams "github.com/mycel-domain/mycel/app/params" + "github.com/mycel-domain/mycel/cmd/myceld/dns" ) // NewRootCmd creates a new root command for a Cosmos SDK application @@ -154,6 +156,11 @@ func initRootCmd( txCommand(), keys.Commands(app.DefaultNodeHome), ) + + // add DNS command + rootCmd.AddCommand( + dns.DnsCommand(), + ) } // queryCommand returns the sub-command to send queries to the app @@ -208,6 +215,7 @@ func txCommand() *cobra.Command { return cmd } + func addModuleInitFlags(startCmd *cobra.Command) { crisis.AddModuleInitFlags(startCmd) // this line is used by starport scaffolding # root/arguments diff --git a/cmd/myceld/dns/dns.go b/cmd/myceld/dns/dns.go new file mode 100644 index 00000000..1b123d05 --- /dev/null +++ b/cmd/myceld/dns/dns.go @@ -0,0 +1,234 @@ +package dns + +import ( + "context" + "fmt" + "log" + "net" + "strings" + + "github.com/miekg/dns" + resolver "github.com/mycel-domain/mycel/x/resolver/types" + "google.golang.org/grpc" + + "github.com/spf13/cobra" +) + +type grpcService struct { + grpcConn *grpc.ClientConn +} + +type DnsRecord interface{} + +func (s *grpcService) QueryDnsToMycelResolver(domain string, recordType string) (dnsRecord DnsRecord) { + + domain = strings.Trim(domain, ".") + division := strings.Index(domain, ".") + + argName := domain[:division] + argParent := domain[division+1:] + + queryClient := resolver.NewQueryClient(s.grpcConn) + + params := &resolver.QueryDnsRecordRequest{ + DomainName: argName, + DomainParent: argParent, + DnsRecordType: recordType, + } + + ctx := context.Background() + + res, err := queryClient.DnsRecord(ctx, params) + if err != nil { + log.Printf("QueryDnsToMycelResolver: %v", err) + return nil + } + + if found := res.Value != nil; found { + value := res.Value.Value + switch recordType { + case "A", "AAAA": + dnsRecord = net.ParseIP(value) + case "CNAME", "MX", "NS": + dnsRecord = value + case "TXT": + dnsRecord = []string{value} + default: + dnsRecord = nil + } + } + return dnsRecord +} + +func (s *grpcService) QueryDnsToDefaultResolver(domain string, recordType string) DnsRecord { + switch recordType { + case "A": + ips, err := net.LookupIP(domain) + if err != nil { + return nil + } + for _, ip := range ips { + if ipv4 := ip.To4(); ipv4 != nil { + return ipv4 + } + } + case "AAAA": + ips, err := net.LookupIP(domain) + if err != nil { + return nil + } + for _, ip := range ips { + if ipv4 := ip.To4(); ipv4 == nil { + return ip + } + } + case "CNAME": + cname, err := net.LookupCNAME(domain) + if err != nil { + return nil + } + return cname + case "MX": + mxs, err := net.LookupMX(domain) + if err != nil || len(mxs) == 0 { + return nil + } + return mxs[0].Host + case "NS": + nss, err := net.LookupNS(domain) + if err != nil || len(nss) == 0 { + return nil + } + return nss[0].Host + case "TXT": + txts, err := net.LookupTXT(domain) + if err != nil { + return nil + } + return txts + default: + return nil + } + return nil +} + +func (s *grpcService) QueryDns(domain string, recordType string) (dnsRecord DnsRecord) { + dnsRecord = s.QueryDnsToMycelResolver(domain, recordType) + log.Printf("MycelResolver: %s %s %v", domain, recordType, dnsRecord) + if dnsRecord == nil { + dnsRecord = s.QueryDnsToDefaultResolver(domain, recordType) + log.Printf("DefaultResolver: %s %s %v", domain, recordType, dnsRecord) + } + return dnsRecord +} + +func (s *grpcService) HandleDNSRequest(w dns.ResponseWriter, r *dns.Msg) { + msg := dns.Msg{} + msg.SetReply(r) + + domain := msg.Question[0].Name + found := false + + switch r.Question[0].Qtype { + case dns.TypeA: + msg.Authoritative = true + record := s.QueryDns(domain, "A") + if ip, ok := record.(net.IP); ok && ip != nil { + msg.Answer = append(msg.Answer, &dns.A{ + Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 600}, + A: ip, + }) + found = true + } + case dns.TypeAAAA: + record := s.QueryDns(domain, "AAAA") + if ip, ok := record.(net.IP); ok && ip != nil { + msg.Answer = append(msg.Answer, &dns.AAAA{ + Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: 600}, + AAAA: ip, + }) + found = true + } + case dns.TypeCNAME: + record := s.QueryDns(domain, "CNAME") + if cname, ok := record.(string); ok && cname != "" { + msg.Answer = append(msg.Answer, &dns.CNAME{ + Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeCNAME, Class: dns.ClassINET, Ttl: 600}, + Target: cname, + }) + found = true + } + case dns.TypeMX: + record := s.QueryDns(domain, "MX") + if mx, ok := record.(string); ok && mx != "" { + msg.Answer = append(msg.Answer, &dns.MX{ + Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeMX, Class: dns.ClassINET, Ttl: 600}, + Mx: mx, + }) + found = true + } + case dns.TypeNS: + record := s.QueryDns(domain, "NS") + if ns, ok := record.(string); ok && ns != "" { + msg.Answer = append(msg.Answer, &dns.NS{ + Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeNS, Class: dns.ClassINET, Ttl: 600}, + Ns: ns, + }) + found = true + } + case dns.TypeTXT: + record := s.QueryDns(domain, "TXT") + if txt, ok := record.([]string); ok && len(txt) > 0 { + msg.Answer = append(msg.Answer, &dns.TXT{ + Hdr: dns.RR_Header{Name: domain, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 600}, + Txt: txt, + }) + found = true + } + default: + break + } + + if !found { + msg.SetRcode(r, dns.RcodeNameError) + } + + w.WriteMsg(&msg) +} + +func RunDnsServer(nodeAddress string, listenPort int) error { + grpcConn, err := grpc.Dial(nodeAddress, + grpc.WithInsecure(), + ) + if err != nil { + log.Fatalf("Failed to connect to node: %v", err) + } + defer grpcConn.Close() + + grpc := grpcService{ + grpcConn: grpcConn, + } + + dns.HandleFunc(".", grpc.HandleDNSRequest) + server := &dns.Server{Addr: fmt.Sprintf(":%d", listenPort), Net: "udp"} + fmt.Printf("Starting DNS server at %s\n", server.Addr) + err = server.ListenAndServe() + return err +} + +// DnsCommand returns command to start DNS server +func DnsCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "dns", + Short: "Run DNS server", + RunE: func(cmd *cobra.Command, _ []string) (err error) { + listenPort, _ := cmd.Flags().GetInt("port") + nodeAddress, _ := cmd.Flags().GetString("nodeAddress") + err = RunDnsServer(nodeAddress, listenPort) + return err + }, + } + cmd.PersistentFlags().Int("port", 53, "Port to listen on") + cmd.PersistentFlags().String("nodeAddress", "localhost:9090", "Mycel node address") + return cmd +} diff --git a/cmd/myceld/main.go b/cmd/myceld/main.go index c00225d4..9fcae419 100644 --- a/cmd/myceld/main.go +++ b/cmd/myceld/main.go @@ -12,6 +12,7 @@ import ( func main() { rootCmd, _ := cmd.NewRootCmd() + if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil { switch e := err.(type) { case server.ErrorCode: diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 40cf95db..afda1489 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -50705,6 +50705,202 @@ paths: type: string tags: - Query + /mycel-domain/mycel/resolver/dns_record/{domainName}/{domainParent}/{dnsRecordType}: + get: + summary: Queries a list of DnsRecord items. + operationId: MycelResolverDnsRecord + responses: + '200': + description: A successful response. + schema: + type: object + properties: + value: + type: object + properties: + dnsRecordType: + type: string + enum: + - NO_RECORD_TYPE + - A + - AAAA + - CNAME + - NS + - MX + - PTR + - SOA + - SRV + - TXT + default: NO_RECORD_TYPE + 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: dnsRecordType + in: path + required: true + type: string + tags: + - Query + /mycel-domain/mycel/resolver/params: + get: + summary: Parameters queries the parameters of the module. + operationId: MycelResolverParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: >- + QueryParamsResponse is response type for the Query/Params RPC + method. + 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: {} + tags: + - Query + /mycel-domain/mycel/resolver/wallet_record/{domainName}/{domainParent}/{walletRecordType}: + get: + summary: Queries a list of QueryWalletRecord items. + operationId: MycelResolverWalletRecord + responses: + '200': + description: A successful response. + schema: + type: object + properties: + value: + type: object + properties: + walletRecordType: + type: string + enum: + - NO_NETWORK + - BITCOIN_MAINNET_MAINNET + - BITCOIN_TESTNET_TESTNET + - ETHEREUM_MAINNET_MAINNET + - ETHEREUM_TESTNET_GOERLI + - ETHEREUM_TESTNET_SEPOLIA + - POLYGON_MAINNET_MAINNET + - POLYGON_TESTNET_MUMBAI + - BNB_MAINNET_MAINNET + - BNB_TESTNET_TESTNET + - AVALANCHE_MAINNET_CCHAIN + - AVALANCHE_TESTNET_FUJI + - GNOSIS_MAINNET_MAINNET + - GNOSIS_TESTNET_CHIADO + - OPTIMISM_MAINNET_MAINNET + - OPTIMISM_TESTNET_GOERLI + - ARBITRUM_MAINNET_MAINNET + - ARBITRUM_TESTNET_GOERLI + - SHARDEUM_BETANET_SPHINX + - ZETA_TESTNET_ATHENS + - APTOS_MAINNET_MAINNET + - APTOS_TESTNET_TESTNET + - SUI_MAINNET_MAINNET + - SUI_TESTNET_TESTNET + - SOLANA_MAINNET_MAINNET + - SOLANA_TESTNET_TESTNET + default: NO_NETWORK + description: |- + - BITCOIN_MAINNET_MAINNET: BTC 1xxx + - ETHEREUM_MAINNET_MAINNET: EVM 2xxxx + Etheruem + - POLYGON_MAINNET_MAINNET: Polygon + - BNB_MAINNET_MAINNET: BNB Chain + - AVALANCHE_MAINNET_CCHAIN: Avalanche + - GNOSIS_MAINNET_MAINNET: Gnosis + - OPTIMISM_MAINNET_MAINNET: Optimism + - ARBITRUM_MAINNET_MAINNET: Arbitrum + - SHARDEUM_BETANET_SPHINX: Shardeum + SHARDEUM_MAINNET_ = 20015; + SHARDEUM_TESTNET_ = 20016; + - ZETA_TESTNET_ATHENS: Zetachain + ZETA_MAINNET_MAINNET = 20018; + - APTOS_MAINNET_MAINNET: MOVE 3xxxx + Aptos + - SUI_MAINNET_MAINNET: Sui + - SOLANA_MAINNET_MAINNET: SOLANA 4xxxx + title: 'Rule: CHAINNAME_ENVIROMENT_NETWORK' + 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: walletRecordType + in: path + required: true + type: string + tags: + - Query definitions: cosmos.auth.v1beta1.AddressBytesToStringResponse: type: object @@ -81518,3 +81714,93 @@ definitions: title: 'Rule: CHAINNAME_ENVIROMENT_NETWORK' value: type: string + mycel.resolver.Params: + type: object + description: Params defines the parameters for the module. + mycel.resolver.QueryDnsRecordResponse: + type: object + properties: + value: + type: object + properties: + dnsRecordType: + type: string + enum: + - NO_RECORD_TYPE + - A + - AAAA + - CNAME + - NS + - MX + - PTR + - SOA + - SRV + - TXT + default: NO_RECORD_TYPE + value: + type: string + mycel.resolver.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + description: QueryParamsResponse is response type for the Query/Params RPC method. + mycel.resolver.QueryWalletRecordResponse: + type: object + properties: + value: + type: object + properties: + walletRecordType: + type: string + enum: + - NO_NETWORK + - BITCOIN_MAINNET_MAINNET + - BITCOIN_TESTNET_TESTNET + - ETHEREUM_MAINNET_MAINNET + - ETHEREUM_TESTNET_GOERLI + - ETHEREUM_TESTNET_SEPOLIA + - POLYGON_MAINNET_MAINNET + - POLYGON_TESTNET_MUMBAI + - BNB_MAINNET_MAINNET + - BNB_TESTNET_TESTNET + - AVALANCHE_MAINNET_CCHAIN + - AVALANCHE_TESTNET_FUJI + - GNOSIS_MAINNET_MAINNET + - GNOSIS_TESTNET_CHIADO + - OPTIMISM_MAINNET_MAINNET + - OPTIMISM_TESTNET_GOERLI + - ARBITRUM_MAINNET_MAINNET + - ARBITRUM_TESTNET_GOERLI + - SHARDEUM_BETANET_SPHINX + - ZETA_TESTNET_ATHENS + - APTOS_MAINNET_MAINNET + - APTOS_TESTNET_TESTNET + - SUI_MAINNET_MAINNET + - SUI_TESTNET_TESTNET + - SOLANA_MAINNET_MAINNET + - SOLANA_TESTNET_TESTNET + default: NO_NETWORK + description: |- + - BITCOIN_MAINNET_MAINNET: BTC 1xxx + - ETHEREUM_MAINNET_MAINNET: EVM 2xxxx + Etheruem + - POLYGON_MAINNET_MAINNET: Polygon + - BNB_MAINNET_MAINNET: BNB Chain + - AVALANCHE_MAINNET_CCHAIN: Avalanche + - GNOSIS_MAINNET_MAINNET: Gnosis + - OPTIMISM_MAINNET_MAINNET: Optimism + - ARBITRUM_MAINNET_MAINNET: Arbitrum + - SHARDEUM_BETANET_SPHINX: Shardeum + SHARDEUM_MAINNET_ = 20015; + SHARDEUM_TESTNET_ = 20016; + - ZETA_TESTNET_ATHENS: Zetachain + ZETA_MAINNET_MAINNET = 20018; + - APTOS_MAINNET_MAINNET: MOVE 3xxxx + Aptos + - SUI_MAINNET_MAINNET: Sui + - SOLANA_MAINNET_MAINNET: SOLANA 4xxxx + title: 'Rule: CHAINNAME_ENVIROMENT_NETWORK' + value: + type: string diff --git a/go.mod b/go.mod index 1897f091..b6c0f5e9 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 + github.com/miekg/dns v1.1.56 github.com/prometheus/client_golang v1.16.0 github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 @@ -158,13 +159,15 @@ require ( github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/crypto v0.11.0 // indirect + golang.org/x/crypto v0.13.0 // indirect golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect - golang.org/x/net v0.12.0 // indirect + golang.org/x/mod v0.12.0 // indirect + golang.org/x/net v0.15.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sys v0.10.0 // indirect - golang.org/x/term v0.10.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/term v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect + golang.org/x/tools v0.13.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index ef3336f8..cc05b6a0 100644 --- a/go.sum +++ b/go.sum @@ -894,6 +894,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5 github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= +github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= @@ -1225,8 +1227,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1270,7 +1272,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1337,8 +1340,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1380,7 +1383,7 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1489,14 +1492,14 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1508,8 +1511,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1581,7 +1584,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/proto/mycel/resolver/genesis.proto b/proto/mycel/resolver/genesis.proto new file mode 100644 index 00000000..1671854f --- /dev/null +++ b/proto/mycel/resolver/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package mycel.resolver; + +import "gogoproto/gogo.proto"; +import "mycel/resolver/params.proto"; + +option go_package = "github.com/mycel-domain/mycel/x/resolver/types"; + +// GenesisState defines the resolver module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/mycel/resolver/params.proto b/proto/mycel/resolver/params.proto new file mode 100644 index 00000000..62761a99 --- /dev/null +++ b/proto/mycel/resolver/params.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package mycel.resolver; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/mycel-domain/mycel/x/resolver/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + +} diff --git a/proto/mycel/resolver/query.proto b/proto/mycel/resolver/query.proto new file mode 100644 index 00000000..15ede785 --- /dev/null +++ b/proto/mycel/resolver/query.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; + +package mycel.resolver; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "mycel/resolver/params.proto"; +import "mycel/registry/second_level_domain.proto"; + +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) { + option (google.api.http).get = "/mycel-domain/mycel/resolver/params"; + + } + + // Queries a list of QueryWalletRecord items. + 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) { + option (google.api.http).get = "/mycel-domain/mycel/resolver/dns_record/{domainName}/{domainParent}/{dnsRecordType}"; + + } +} +// 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 walletRecordType = 3; +} + +message QueryWalletRecordResponse { + mycel.registry.WalletRecord value = 1; +} + +message QueryDnsRecordRequest { + string domainName = 1; + string domainParent = 2; + string dnsRecordType = 3; +} + +message QueryDnsRecordResponse { + mycel.registry.DnsRecord value = 1; +} + diff --git a/proto/mycel/resolver/tx.proto b/proto/mycel/resolver/tx.proto new file mode 100644 index 00000000..2cbf8307 --- /dev/null +++ b/proto/mycel/resolver/tx.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; +package mycel.resolver; + +option go_package = "github.com/mycel-domain/mycel/x/resolver/types"; + +// Msg defines the Msg service. +service Msg {} \ No newline at end of file diff --git a/testutil/keeper/resolver.go b/testutil/keeper/resolver.go new file mode 100644 index 00000000..8f4f9c2a --- /dev/null +++ b/testutil/keeper/resolver.go @@ -0,0 +1,53 @@ +package keeper + +import ( + "testing" + + tmdb "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/mycel-domain/mycel/x/resolver/keeper" + "github.com/mycel-domain/mycel/x/resolver/types" + "github.com/stretchr/testify/require" +) + +func ResolverKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "ResolverParams", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + nil, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/x/registry/keeper/second_level_domain.go b/x/registry/keeper/second_level_domain.go index a3f165ff..6ac26448 100644 --- a/x/registry/keeper/second_level_domain.go +++ b/x/registry/keeper/second_level_domain.go @@ -1,10 +1,14 @@ package keeper import ( + "errors" + "fmt" "github.com/mycel-domain/mycel/x/registry/types" + "time" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + errosmod "github.com/cosmos/cosmos-sdk/types/errors" ) // SetSecondLevelDomain set a specific second-level-domain in the store from its index @@ -67,3 +71,29 @@ func (k Keeper) GetAllSecondLevelDomain(ctx sdk.Context) (list []types.SecondLev return } + +// Get valid second level domain +func (k Keeper) GetValidSecondLevelDomain(ctx sdk.Context, name string, parent string) (secondLevelDomain types.SecondLevelDomain, err error) { + // Regex validation + err = types.ValidateSecondLevelDomainName(name) + if err != nil { + return secondLevelDomain, err + } + err = types.ValidateSecondLevelDomainParent(parent) + if err != nil { + return secondLevelDomain, err + } + // Get second level domain + secondLevelDomain, isFound := k.GetSecondLevelDomain(ctx, name, parent) + if !isFound { + return secondLevelDomain, errosmod.Wrapf(errors.New(fmt.Sprintf("%s.%s", name, parent)), types.ErrDomainNotFound.Error()) + } + + // Check if domain is not expired + expirationDate := time.Unix(0, secondLevelDomain.ExpirationDate) + if ctx.BlockTime().After(expirationDate) && secondLevelDomain.ExpirationDate != 0 { + return secondLevelDomain, errosmod.Wrapf(errors.New(fmt.Sprintf("%s", name)), types.ErrDomainExpired.Error()) + } + + return secondLevelDomain, nil +} diff --git a/x/registry/keeper/second_level_domain_test.go b/x/registry/keeper/second_level_domain_test.go index be4703d1..351d6b49 100644 --- a/x/registry/keeper/second_level_domain_test.go +++ b/x/registry/keeper/second_level_domain_test.go @@ -1,6 +1,8 @@ package keeper_test import ( + "errors" + "fmt" "strconv" "testing" @@ -10,6 +12,7 @@ import ( "github.com/mycel-domain/mycel/x/registry/types" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" ) @@ -66,3 +69,54 @@ func TestDomainGetAll(t *testing.T) { nullify.Fill(keeper.GetAllSecondLevelDomain(ctx)), ) } + +func (suite *KeeperTestSuite) TestGetValidSecondLevelDomain() { + testCases := []struct { + secondLevelDomain types.SecondLevelDomain + expErr error + }{ + { + secondLevelDomain: types.SecondLevelDomain{ + Name: "test", + Parent: "test", + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, 20).UnixNano(), + }, + expErr: nil, + }, + { + secondLevelDomain: types.SecondLevelDomain{ + Name: "test", + Parent: "test", + ExpirationDate: 0, + }, + expErr: nil, + }, + { + secondLevelDomain: types.SecondLevelDomain{ + Name: "test", + Parent: "test", + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, -20).UnixNano(), + }, + expErr: sdkerrors.Wrapf(errors.New(fmt.Sprintf("test")), types.ErrDomainExpired.Error()), + }, + } + for i, tc := range testCases { + suite.Run(fmt.Sprintf("Case %d", i), func() { + suite.SetupTest() + + // Set domain + suite.app.RegistryKeeper.SetSecondLevelDomain(suite.ctx, tc.secondLevelDomain) + + // Get valid domain + secondLevelDomain, err := suite.app.RegistryKeeper.GetValidSecondLevelDomain(suite.ctx, tc.secondLevelDomain.Name, tc.secondLevelDomain.Parent) + if tc.expErr == nil { + suite.Require().Nil(err) + suite.Require().Equal(tc.secondLevelDomain, secondLevelDomain) + } else { + suite.Require().NotNil(err) + suite.Require().Equal(tc.expErr.Error(), err.Error()) + } + }) + } + +} diff --git a/x/registry/keeper/top_level_domain.go b/x/registry/keeper/top_level_domain.go index 7544f22b..a4d5ada3 100644 --- a/x/registry/keeper/top_level_domain.go +++ b/x/registry/keeper/top_level_domain.go @@ -1,8 +1,13 @@ package keeper import ( + "errors" + "fmt" + "time" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mycel-domain/mycel/x/registry/types" ) @@ -61,3 +66,27 @@ func (k Keeper) GetAllTopLevelDomain(ctx sdk.Context) (list []types.TopLevelDoma return } + +// Get valid top level domain + +func (k Keeper) GetValidTopLevelDomain(ctx sdk.Context, name string) (topLevelDomain types.TopLevelDomain, err error) { + // Regex validation + err = types.ValidateTopLevelDomainName(name) + if err != nil { + return topLevelDomain, err + } + + // Get top level domain + topLevelDomain, isFound := k.GetTopLevelDomain(ctx, name) + if !isFound { + return topLevelDomain, sdkerrors.Wrapf(errors.New(fmt.Sprintf("%s", name)), types.ErrDomainNotFound.Error()) + } + + // Check if domain is not expired + expirationDate := time.Unix(0, topLevelDomain.ExpirationDate) + if ctx.BlockTime().After(expirationDate) && topLevelDomain.ExpirationDate != 0 { + return topLevelDomain, sdkerrors.Wrapf(errors.New(fmt.Sprintf("%s", name)), types.ErrDomainExpired.Error()) + } + + return topLevelDomain, nil +} diff --git a/x/registry/keeper/top_level_domain_test.go b/x/registry/keeper/top_level_domain_test.go index 728a02a6..a9cce66e 100644 --- a/x/registry/keeper/top_level_domain_test.go +++ b/x/registry/keeper/top_level_domain_test.go @@ -1,10 +1,14 @@ package keeper_test import ( + "errors" + "fmt" + "strconv" "testing" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/registry/keeper" @@ -61,3 +65,51 @@ func TestTopLevelDomainGetAll(t *testing.T) { nullify.Fill(keeper.GetAllTopLevelDomain(ctx)), ) } + +func (suite *KeeperTestSuite) TestGetValidTopLevelDomain() { + testCases := []struct { + topLevelDomain types.TopLevelDomain + expErr error + }{ + { + topLevelDomain: types.TopLevelDomain{ + Name: "test", + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, 20).UnixNano(), + }, + expErr: nil, + }, + { + topLevelDomain: types.TopLevelDomain{ + Name: "test", + ExpirationDate: 0, + }, + expErr: nil, + }, + { + topLevelDomain: types.TopLevelDomain{ + Name: "test", + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, -20).UnixNano(), + }, + expErr: sdkerrors.Wrapf(errors.New(fmt.Sprintf("test")), types.ErrDomainExpired.Error()), + }, + } + for i, tc := range testCases { + suite.Run(fmt.Sprintf("Case %d", i), func() { + suite.SetupTest() + + // Set domain + suite.app.RegistryKeeper.SetTopLevelDomain(suite.ctx, tc.topLevelDomain) + + // Get valid domain + topLevelDomain, err := suite.app.RegistryKeeper.GetValidTopLevelDomain(suite.ctx, tc.topLevelDomain.Name) + if tc.expErr == nil { + suite.Require().Nil(err) + suite.Require().Equal(tc.topLevelDomain, topLevelDomain) + } else { + suite.Require().NotNil(err) + suite.Require().Equal(tc.expErr.Error(), err.Error()) + } + }) + } + +} diff --git a/x/registry/types/errors.go b/x/registry/types/errors.go index 0a4f6459..c68fb0a3 100644 --- a/x/registry/types/errors.go +++ b/x/registry/types/errors.go @@ -23,4 +23,5 @@ var ( 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") ) diff --git a/x/registry/types/valdiate_second_level_domain.go b/x/registry/types/validate_second_level_domain.go similarity index 79% rename from x/registry/types/valdiate_second_level_domain.go rename to x/registry/types/validate_second_level_domain.go index e90ebc5c..21e23e2a 100644 --- a/x/registry/types/valdiate_second_level_domain.go +++ b/x/registry/types/validate_second_level_domain.go @@ -12,28 +12,31 @@ const ( NamePattern = `-a-z0-9\p{So}\p{Sk}` ) -func (secondLevelDomain SecondLevelDomain) IsRecordEditable(sender string) (isEditable bool, err error) { - if secondLevelDomain.AccessControl[sender] == DomainRole_NO_ROLE { - err = errorsmod.Wrapf(errors.New(fmt.Sprintf("%s", sender)), ErrDomainNotEditable.Error()) +func ValidateSecondLevelDomainName(name string) (err error) { + regex := regexp.MustCompile(fmt.Sprintf(`(^[%s]+$)`, NamePattern)) + if !regex.MatchString(name) { + err = errorsmod.Wrapf(errors.New(fmt.Sprintf("%s", name)), ErrInvalidDomainName.Error()) } - isEditable = secondLevelDomain.AccessControl[sender] == DomainRole_EDITOR || secondLevelDomain.AccessControl[sender] == DomainRole_OWNER - return isEditable, err + return err } func (secondLevelDomain SecondLevelDomain) ValidateName() (err error) { - regex := regexp.MustCompile(fmt.Sprintf(`(^[%s]+$)`, NamePattern)) - if !regex.MatchString(secondLevelDomain.Name) { - err = errorsmod.Wrapf(errors.New(fmt.Sprintf("%s", secondLevelDomain.Name)), ErrInvalidDomainName.Error()) - } + err = ValidateSecondLevelDomainName(secondLevelDomain.Name) return err } -func (secondLevelDomain SecondLevelDomain) ValidateParent() (err error) { +func ValidateSecondLevelDomainParent(parent string) (err error) { regex := regexp.MustCompile(fmt.Sprintf(`(^[%s]+[%[1]s\.]*[%[1]s]$)|^$`, NamePattern)) - if !regex.MatchString(secondLevelDomain.Parent) { - err = errorsmod.Wrapf(errors.New(fmt.Sprintf("%s", secondLevelDomain.Parent)), ErrInvalidDomainParent.Error()) + if !regex.MatchString(parent) { + err = errorsmod.Wrapf(errors.New(fmt.Sprintf("%s", parent)), ErrInvalidDomainParent.Error()) } return err + +} + +func (secondLevelDomain SecondLevelDomain) ValidateParent() (err error) { + err = ValidateSecondLevelDomainParent(secondLevelDomain.Parent) + return err } func (secondLevelDomain SecondLevelDomain) Validate() (err error) { @@ -75,3 +78,13 @@ func ValidateDnsRecordType(dnsRecordType string) (err error) { } return err } + +func (secondLevelDomain SecondLevelDomain) IsRecordEditable(sender string) (isEditable bool, err error) { + if secondLevelDomain.AccessControl[sender] == DomainRole_NO_ROLE { + err = errorsmod.Wrapf(errors.New(fmt.Sprintf("%s", sender)), ErrDomainNotEditable.Error()) + } + isEditable = secondLevelDomain.AccessControl[sender] == DomainRole_EDITOR || secondLevelDomain.AccessControl[sender] == DomainRole_OWNER + return isEditable, err +} + + diff --git a/x/registry/types/valdiate_top_level_domain.go b/x/registry/types/validate_top_level_domain.go similarity index 63% rename from x/registry/types/valdiate_top_level_domain.go rename to x/registry/types/validate_top_level_domain.go index f9c984ff..d0a546c1 100644 --- a/x/registry/types/valdiate_top_level_domain.go +++ b/x/registry/types/validate_top_level_domain.go @@ -12,12 +12,18 @@ const ( TLDNamePattern = `-a-z0-9\p{So}\p{Sk}` ) -func (topLevelDomain TopLevelDomain) ValidateName() (err error) { +func ValidateTopLevelDomainName(name string) (err error) { regex := regexp.MustCompile(fmt.Sprintf(`(^[%s]+$)`, TLDNamePattern)) - if !regex.MatchString(topLevelDomain.Name) { - err = errorsmod.Wrapf(errors.New(fmt.Sprintf("%s", topLevelDomain.Name)), ErrInvalidDomainName.Error()) + if !regex.MatchString(name) { + err = errorsmod.Wrapf(errors.New(fmt.Sprintf("%s", name)), ErrInvalidDomainName.Error()) } return err + +} + +func (topLevelDomain TopLevelDomain) ValidateName() (err error) { + err = ValidateTopLevelDomainName(topLevelDomain.Name) + return err } func (topLevelDomain TopLevelDomain) Validate() (err error) { diff --git a/x/resolver/client/cli/query.go b/x/resolver/client/cli/query.go new file mode 100644 index 00000000..65369fb6 --- /dev/null +++ b/x/resolver/client/cli/query.go @@ -0,0 +1,35 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/x/resolver/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group resolver queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdQueryWalletRecord()) + + cmd.AddCommand(CmdDnsRecord()) + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/resolver/client/cli/query_dns_record.go b/x/resolver/client/cli/query_dns_record.go new file mode 100644 index 00000000..e134ac2d --- /dev/null +++ b/x/resolver/client/cli/query_dns_record.go @@ -0,0 +1,50 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/mycel-domain/mycel/x/resolver/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdDnsRecord() *cobra.Command { + cmd := &cobra.Command{ + Use: "dns-record [domainName] [domainParent] [dns-record-type]", + Short: "Query DNS record", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqDomainName := args[0] + reqDomainParent := args[1] + reqDnsRecordType := args[2] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryDnsRecordRequest{ + + DomainName: reqDomainName, + DomainParent: reqDomainParent, + DnsRecordType: reqDnsRecordType, + } + + res, err := queryClient.DnsRecord(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/resolver/client/cli/query_params.go b/x/resolver/client/cli/query_params.go new file mode 100644 index 00000000..7f4a05b4 --- /dev/null +++ b/x/resolver/client/cli/query_params.go @@ -0,0 +1,36 @@ +package cli + +import ( + "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" +) + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/resolver/client/cli/query_wallet_record.go b/x/resolver/client/cli/query_wallet_record.go new file mode 100644 index 00000000..2197759d --- /dev/null +++ b/x/resolver/client/cli/query_wallet_record.go @@ -0,0 +1,50 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/mycel-domain/mycel/x/resolver/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdQueryWalletRecord() *cobra.Command { + cmd := &cobra.Command{ + Use: "wallet-record [domain-name] [domain-parent] [wallet-record-type]", + Short: "Query wallet record", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqDomainName := args[0] + reqDomainParent := args[1] + reqWalletRecordType := args[2] + + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryWalletRecordRequest{ + + DomainName: reqDomainName, + DomainParent: reqDomainParent, + WalletRecordType: reqWalletRecordType, + } + + res, err := queryClient.WalletRecord(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/resolver/client/cli/tx.go b/x/resolver/client/cli/tx.go new file mode 100644 index 00000000..d288ff80 --- /dev/null +++ b/x/resolver/client/cli/tx.go @@ -0,0 +1,36 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/mycel-domain/mycel/x/resolver/types" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + listSeparator = "," +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + // this line is used by starport scaffolding # 1 + + return cmd +} diff --git a/x/resolver/genesis.go b/x/resolver/genesis.go new file mode 100644 index 00000000..cb2111c4 --- /dev/null +++ b/x/resolver/genesis.go @@ -0,0 +1,23 @@ +package resolver + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/resolver/keeper" + "github.com/mycel-domain/mycel/x/resolver/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/resolver/genesis_test.go b/x/resolver/genesis_test.go new file mode 100644 index 00000000..49b01882 --- /dev/null +++ b/x/resolver/genesis_test.go @@ -0,0 +1,29 @@ +package resolver_test + +import ( + "testing" + + keepertest "github.com/mycel-domain/mycel/testutil/keeper" + "github.com/mycel-domain/mycel/testutil/nullify" + "github.com/mycel-domain/mycel/x/resolver" + "github.com/mycel-domain/mycel/x/resolver/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.ResolverKeeper(t) + resolver.InitGenesis(ctx, *k, genesisState) + got := resolver.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/resolver/keeper/keeper.go b/x/resolver/keeper/keeper.go new file mode 100644 index 00000000..9128c98a --- /dev/null +++ b/x/resolver/keeper/keeper.go @@ -0,0 +1,51 @@ +package keeper + +import ( + "fmt" + + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/mycel-domain/mycel/x/resolver/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + + registryKeeper types.RegistryKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, + ps paramtypes.Subspace, + + registryKeeper types.RegistryKeeper, +) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + + registryKeeper: registryKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/resolver/keeper/msg_server.go b/x/resolver/keeper/msg_server.go new file mode 100644 index 00000000..899672c4 --- /dev/null +++ b/x/resolver/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/mycel-domain/mycel/x/resolver/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/resolver/keeper/msg_server_test.go b/x/resolver/keeper/msg_server_test.go new file mode 100644 index 00000000..9207633a --- /dev/null +++ b/x/resolver/keeper/msg_server_test.go @@ -0,0 +1,23 @@ +package keeper_test + +import ( + "context" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" + "github.com/mycel-domain/mycel/x/resolver/keeper" + "github.com/mycel-domain/mycel/x/resolver/types" + "github.com/stretchr/testify/require" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { + k, ctx := keepertest.ResolverKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +} + +func TestMsgServer(t *testing.T) { + ms, ctx := setupMsgServer(t) + require.NotNil(t, ms) + require.NotNil(t, ctx) +} diff --git a/x/resolver/keeper/params.go b/x/resolver/keeper/params.go new file mode 100644 index 00000000..7b61958a --- /dev/null +++ b/x/resolver/keeper/params.go @@ -0,0 +1,16 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/resolver/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams() +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} diff --git a/x/resolver/keeper/params_test.go b/x/resolver/keeper/params_test.go new file mode 100644 index 00000000..0481cd91 --- /dev/null +++ b/x/resolver/keeper/params_test.go @@ -0,0 +1,18 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" + "github.com/mycel-domain/mycel/x/resolver/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.ResolverKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) +} diff --git a/x/resolver/keeper/query.go b/x/resolver/keeper/query.go new file mode 100644 index 00000000..c7bf1a90 --- /dev/null +++ b/x/resolver/keeper/query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/mycel-domain/mycel/x/resolver/types" +) + +var _ types.QueryServer= Keeper{} diff --git a/x/resolver/keeper/query_dns_record.go b/x/resolver/keeper/query_dns_record.go new file mode 100644 index 00000000..2f13560f --- /dev/null +++ b/x/resolver/keeper/query_dns_record.go @@ -0,0 +1,38 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/resolver/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + registrytypes "github.com/mycel-domain/mycel/x/registry/types" +) + +func (k Keeper) DnsRecord(goCtx context.Context, req *types.QueryDnsRecordRequest) (*types.QueryDnsRecordResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + // Validate request parameters + err := registrytypes.ValidateDnsRecordType(req.DnsRecordType) + 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 + } + + return &types.QueryDnsRecordResponse{Value: secondLevelDomain.DnsRecords[req.DnsRecordType]}, nil +} diff --git a/x/resolver/keeper/query_params.go b/x/resolver/keeper/query_params.go new file mode 100644 index 00000000..650bddf6 --- /dev/null +++ b/x/resolver/keeper/query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/resolver/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/resolver/keeper/query_params_test.go b/x/resolver/keeper/query_params_test.go new file mode 100644 index 00000000..acc057e4 --- /dev/null +++ b/x/resolver/keeper/query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" + "github.com/mycel-domain/mycel/x/resolver/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.ResolverKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/resolver/keeper/query_wallet_record.go b/x/resolver/keeper/query_wallet_record.go new file mode 100644 index 00000000..0374f95a --- /dev/null +++ b/x/resolver/keeper/query_wallet_record.go @@ -0,0 +1,38 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/resolver/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + registrytypes "github.com/mycel-domain/mycel/x/registry/types" +) + +func (k Keeper) WalletRecord(goCtx context.Context, req *types.QueryWalletRecordRequest) (*types.QueryWalletRecordResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + // Validate request parameters + _, err := registrytypes.GetWalletAddressFormat(req.WalletRecordType) + 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 + } + + return &types.QueryWalletRecordResponse{Value: secondLevelDomain.WalletRecords[req.WalletRecordType]}, nil +} diff --git a/x/resolver/keeper/setup_test.go b/x/resolver/keeper/setup_test.go new file mode 100644 index 00000000..b47e1877 --- /dev/null +++ b/x/resolver/keeper/setup_test.go @@ -0,0 +1,104 @@ +package keeper_test + +import ( + mycelapp "github.com/mycel-domain/mycel/app" + "github.com/mycel-domain/mycel/x/registry/keeper" + "github.com/mycel-domain/mycel/x/registry/types" + "testing" + "time" + + "github.com/mycel-domain/mycel/testutil" + epochstypes "github.com/mycel-domain/mycel/x/epochs/types" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/stretchr/testify/suite" +) + +type KeeperTestSuite struct { + suite.Suite + + ctx sdk.Context + app *mycelapp.App + msgServer types.MsgServer + queryClient types.QueryClient + consAddress sdk.ConsAddress +} + +var s *KeeperTestSuite + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} + +func (suite *KeeperTestSuite) SetupTest() { + // init app + app := mycelapp.Setup(suite.T(), false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now().UTC()}) + + suite.app = app + suite.ctx = ctx + + queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, suite.app.RegistryKeeper) + suite.queryClient = types.NewQueryClient(queryHelper) + + suite.msgServer = keeper.NewMsgServerImpl(suite.app.RegistryKeeper) + + // Init bank keeper + suite.app.BankKeeper.InitGenesis(suite.ctx, getBankGenesis()) + + // Setup epochs + identifiers := []string{epochstypes.IncentiveEpochId} + for _, identifier := range identifiers { + epoch, found := suite.app.EpochsKeeper.GetEpochInfo(suite.ctx, identifier) + suite.Require().True(found) + epoch.StartTime = suite.ctx.BlockTime() + epoch.CurrentEpochStartHeight = suite.ctx.BlockHeight() + suite.app.EpochsKeeper.SetEpochInfo(suite.ctx, epoch) + } + +} + +func makeBalance(address string, balance int64) banktypes.Balance { + return banktypes.Balance{ + Address: address, + Coins: sdk.Coins{ + sdk.Coin{ + Denom: types.MycelDenom, + Amount: sdk.NewInt(balance), + }, + }, + } +} + +func getBankGenesis() *banktypes.GenesisState { + coins := []banktypes.Balance{ + makeBalance(testutil.Alice, testutil.BalAlice), + makeBalance(testutil.Bob, testutil.BalBob), + makeBalance(testutil.Carol, testutil.BalCarol), + } + supply := banktypes.Supply{ + Total: coins[0].Coins.Add(coins[1].Coins...).Add(coins[2].Coins...), + } + + state := banktypes.NewGenesisState( + banktypes.DefaultParams(), + coins, + supply.Total, + []banktypes.Metadata{}, + []banktypes.SendEnabled{}, + ) + + return state +} + +func (suite *KeeperTestSuite) RequireBankBalance(expected int, atAddress string) { + sdkAdd, err := sdk.AccAddressFromBech32(atAddress) + suite.Require().Nil(err, "Failed to parse address: %s", atAddress) + suite.Require().Equal( + int64(expected), + suite.app.BankKeeper.GetBalance(suite.ctx, sdkAdd, sdk.DefaultBondDenom).Amount.Int64()) +} diff --git a/x/resolver/module.go b/x/resolver/module.go new file mode 100644 index 00000000..9d8f7310 --- /dev/null +++ b/x/resolver/module.go @@ -0,0 +1,148 @@ +package resolver + +import ( + "context" + "encoding/json" + "fmt" + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/mycel-domain/mycel/x/resolver/client/cli" + "github.com/mycel-domain/mycel/x/resolver/keeper" + "github.com/mycel-domain/mycel/x/resolver/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshalled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/resolver/module_simulation.go b/x/resolver/module_simulation.go new file mode 100644 index 00000000..a04c3cbd --- /dev/null +++ b/x/resolver/module_simulation.go @@ -0,0 +1,64 @@ +package resolver + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/mycel-domain/mycel/testutil/sample" + resolversimulation "github.com/mycel-domain/mycel/x/resolver/simulation" + "github.com/mycel-domain/mycel/x/resolver/types" +) + +// avoid unused import issue +var ( + _ = sample.AccAddress + _ = resolversimulation.FindAccount + _ = simulation.MsgEntryKind + _ = baseapp.Paramspace + _ = rand.Rand{} +) + +const ( +// this line is used by starport scaffolding # simapp/module/const +) + +// GenerateGenesisState creates a randomized GenState of the module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + accs := make([]string, len(simState.Accounts)) + for i, acc := range simState.Accounts { + accs[i] = acc.Address.String() + } + resolverGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&resolverGenesis) +} + +// RegisterStoreDecoder registers a decoder. +func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// WeightedOperations returns the all the gov module operations with their respective weights. +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + operations := make([]simtypes.WeightedOperation, 0) + + // this line is used by starport scaffolding # simapp/module/operation + + return operations +} + +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{ + // this line is used by starport scaffolding # simapp/module/OpMsg + } +} diff --git a/x/resolver/simulation/helpers.go b/x/resolver/simulation/helpers.go new file mode 100644 index 00000000..92c437c0 --- /dev/null +++ b/x/resolver/simulation/helpers.go @@ -0,0 +1,15 @@ +package simulation + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +// FindAccount find a specific address from an account list +func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) { + creator, err := sdk.AccAddressFromBech32(address) + if err != nil { + panic(err) + } + return simtypes.FindAccount(accs, creator) +} diff --git a/x/resolver/types/codec.go b/x/resolver/types/codec.go new file mode 100644 index 00000000..844157a8 --- /dev/null +++ b/x/resolver/types/codec.go @@ -0,0 +1,23 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + // this line is used by starport scaffolding # 1 + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/resolver/types/errors.go b/x/resolver/types/errors.go new file mode 100644 index 00000000..639cb6d4 --- /dev/null +++ b/x/resolver/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/resolver module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") +) diff --git a/x/resolver/types/expected_keepers.go b/x/resolver/types/expected_keepers.go new file mode 100644 index 00000000..9b1dbaf9 --- /dev/null +++ b/x/resolver/types/expected_keepers.go @@ -0,0 +1,27 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" + registrytypes "github.com/mycel-domain/mycel/x/registry/types" +) + +type RegistryKeeper interface { + // Methods imported from registry should be defined here + GetSecondLevelDomain(ctx sdk.Context, name string, parent string) (val registrytypes.SecondLevelDomain, found bool) + GetTopLevelDomain(ctx sdk.Context, name string) (val registrytypes.TopLevelDomain, found bool) + GetValidSecondLevelDomain(ctx sdk.Context, name string, parent string) (secondLevelDomain registrytypes.SecondLevelDomain, err error) + GetValidTopLevelDomain(ctx sdk.Context, name string) (topLevelDomain registrytypes.TopLevelDomain, err error) +} + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} diff --git a/x/resolver/types/genesis.go b/x/resolver/types/genesis.go new file mode 100644 index 00000000..0af9b441 --- /dev/null +++ b/x/resolver/types/genesis.go @@ -0,0 +1,24 @@ +package types + +import ( +// this line is used by starport scaffolding # genesis/types/import +) + +// DefaultIndex is the default global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/resolver/types/genesis.pb.go b/x/resolver/types/genesis.pb.go new file mode 100644 index 00000000..1a619f01 --- /dev/null +++ b/x/resolver/types/genesis.pb.go @@ -0,0 +1,321 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: mycel/resolver/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the resolver module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_111508fefa25dfc0, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "mycel.resolver.GenesisState") +} + +func init() { proto.RegisterFile("mycel/resolver/genesis.proto", fileDescriptor_111508fefa25dfc0) } + +var fileDescriptor_111508fefa25dfc0 = []byte{ + // 193 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0xad, 0x4c, 0x4e, + 0xcd, 0xd1, 0x2f, 0x4a, 0x2d, 0xce, 0xcf, 0x29, 0x4b, 0x2d, 0xd2, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, + 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0xcb, 0xea, 0xc1, 0x64, 0xa5, + 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x34, 0x9a, 0x19, + 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0x23, 0x94, 0x5c, 0xb8, 0x78, 0xdc, 0x21, 0x66, 0x06, 0x97, + 0x24, 0x96, 0xa4, 0x0a, 0x99, 0x70, 0xb1, 0x41, 0xe4, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, + 0xc4, 0xf4, 0x50, 0xed, 0xd0, 0x0b, 0x00, 0xcb, 0x3a, 0xb1, 0x9c, 0xb8, 0x27, 0xcf, 0x10, 0x04, + 0x55, 0xeb, 0xe4, 0x71, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, + 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x7a, 0xe9, + 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x60, 0x93, 0x74, 0x53, 0xf2, 0x73, + 0x13, 0x33, 0xf3, 0x20, 0x1c, 0xfd, 0x0a, 0x84, 0xb3, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, + 0xc0, 0xce, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x59, 0xdd, 0x4b, 0xac, 0xf9, 0x00, 0x00, + 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/resolver/types/genesis_test.go b/x/resolver/types/genesis_test.go new file mode 100644 index 00000000..3f2d0479 --- /dev/null +++ b/x/resolver/types/genesis_test.go @@ -0,0 +1,41 @@ +package types_test + +import ( + "testing" + + "github.com/mycel-domain/mycel/x/resolver/types" + "github.com/stretchr/testify/require" +) + +func TestGenesisState_Validate(t *testing.T) { + tests := []struct { + desc string + genState *types.GenesisState + valid bool + }{ + { + desc: "default is valid", + genState: types.DefaultGenesis(), + valid: true, + }, + { + desc: "valid genesis state", + genState: &types.GenesisState{ + + // this line is used by starport scaffolding # types/genesis/validField + }, + valid: true, + }, + // this line is used by starport scaffolding # types/genesis/testcase + } + for _, tc := range tests { + t.Run(tc.desc, func(t *testing.T) { + err := tc.genState.Validate() + if tc.valid { + require.NoError(t, err) + } else { + require.Error(t, err) + } + }) + } +} diff --git a/x/resolver/types/keys.go b/x/resolver/types/keys.go new file mode 100644 index 00000000..7f59a765 --- /dev/null +++ b/x/resolver/types/keys.go @@ -0,0 +1,19 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "resolver" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_resolver" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/resolver/types/params.go b/x/resolver/types/params.go new file mode 100644 index 00000000..357196ad --- /dev/null +++ b/x/resolver/types/params.go @@ -0,0 +1,39 @@ +package types + +import ( + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +// ParamKeyTable the param key table for launch module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// NewParams creates a new Params instance +func NewParams() Params { + return Params{} +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams() +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{} +} + +// Validate validates the set of params +func (p Params) Validate() error { + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} diff --git a/x/resolver/types/params.pb.go b/x/resolver/types/params.pb.go new file mode 100644 index 00000000..45b952f0 --- /dev/null +++ b/x/resolver/types/params.pb.go @@ -0,0 +1,264 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: mycel/resolver/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_3b8c793180d31be1, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "mycel.resolver.Params") +} + +func init() { proto.RegisterFile("mycel/resolver/params.proto", fileDescriptor_3b8c793180d31be1) } + +var fileDescriptor_3b8c793180d31be1 = []byte{ + // 151 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xce, 0xad, 0x4c, 0x4e, + 0xcd, 0xd1, 0x2f, 0x4a, 0x2d, 0xce, 0xcf, 0x29, 0x4b, 0x2d, 0xd2, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, + 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0x4b, 0xea, 0xc1, 0x24, 0xa5, 0x44, + 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x12, 0x1f, 0x17, 0x5b, 0x00, + 0x58, 0x97, 0x15, 0xcb, 0x8c, 0x05, 0xf2, 0x0c, 0x4e, 0x1e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, + 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, + 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x97, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, + 0x0f, 0x36, 0x5a, 0x37, 0x25, 0x3f, 0x37, 0x31, 0x33, 0x0f, 0xc2, 0xd1, 0xaf, 0x40, 0x38, 0xa3, + 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x6c, 0x81, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x44, + 0x7b, 0x43, 0x93, 0xa5, 0x00, 0x00, 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/resolver/types/query.pb.go b/x/resolver/types/query.pb.go new file mode 100644 index 00000000..37c3230b --- /dev/null +++ b/x/resolver/types/query.pb.go @@ -0,0 +1,1532 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: mycel/resolver/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + types "github.com/mycel-domain/mycel/x/registry/types" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b8c2c421969ccc6b, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b8c2c421969ccc6b, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +type QueryWalletRecordRequest 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"` + WalletRecordType string `protobuf:"bytes,3,opt,name=walletRecordType,proto3" json:"walletRecordType,omitempty"` +} + +func (m *QueryWalletRecordRequest) Reset() { *m = QueryWalletRecordRequest{} } +func (m *QueryWalletRecordRequest) String() string { return proto.CompactTextString(m) } +func (*QueryWalletRecordRequest) ProtoMessage() {} +func (*QueryWalletRecordRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b8c2c421969ccc6b, []int{2} +} +func (m *QueryWalletRecordRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryWalletRecordRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryWalletRecordRequest.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 *QueryWalletRecordRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryWalletRecordRequest.Merge(m, src) +} +func (m *QueryWalletRecordRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryWalletRecordRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryWalletRecordRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryWalletRecordRequest proto.InternalMessageInfo + +func (m *QueryWalletRecordRequest) GetDomainName() string { + if m != nil { + return m.DomainName + } + return "" +} + +func (m *QueryWalletRecordRequest) GetDomainParent() string { + if m != nil { + return m.DomainParent + } + return "" +} + +func (m *QueryWalletRecordRequest) GetWalletRecordType() string { + if m != nil { + return m.WalletRecordType + } + return "" +} + +type QueryWalletRecordResponse struct { + Value *types.WalletRecord `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *QueryWalletRecordResponse) Reset() { *m = QueryWalletRecordResponse{} } +func (m *QueryWalletRecordResponse) String() string { return proto.CompactTextString(m) } +func (*QueryWalletRecordResponse) ProtoMessage() {} +func (*QueryWalletRecordResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b8c2c421969ccc6b, []int{3} +} +func (m *QueryWalletRecordResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryWalletRecordResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryWalletRecordResponse.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 *QueryWalletRecordResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryWalletRecordResponse.Merge(m, src) +} +func (m *QueryWalletRecordResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryWalletRecordResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryWalletRecordResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryWalletRecordResponse proto.InternalMessageInfo + +func (m *QueryWalletRecordResponse) GetValue() *types.WalletRecord { + if m != nil { + return m.Value + } + return nil +} + +type QueryDnsRecordRequest 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"` + DnsRecordType string `protobuf:"bytes,3,opt,name=dnsRecordType,proto3" json:"dnsRecordType,omitempty"` +} + +func (m *QueryDnsRecordRequest) Reset() { *m = QueryDnsRecordRequest{} } +func (m *QueryDnsRecordRequest) String() string { return proto.CompactTextString(m) } +func (*QueryDnsRecordRequest) ProtoMessage() {} +func (*QueryDnsRecordRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b8c2c421969ccc6b, []int{4} +} +func (m *QueryDnsRecordRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDnsRecordRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDnsRecordRequest.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 *QueryDnsRecordRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDnsRecordRequest.Merge(m, src) +} +func (m *QueryDnsRecordRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryDnsRecordRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDnsRecordRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDnsRecordRequest proto.InternalMessageInfo + +func (m *QueryDnsRecordRequest) GetDomainName() string { + if m != nil { + return m.DomainName + } + return "" +} + +func (m *QueryDnsRecordRequest) GetDomainParent() string { + if m != nil { + return m.DomainParent + } + return "" +} + +func (m *QueryDnsRecordRequest) GetDnsRecordType() string { + if m != nil { + return m.DnsRecordType + } + return "" +} + +type QueryDnsRecordResponse struct { + Value *types.DnsRecord `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *QueryDnsRecordResponse) Reset() { *m = QueryDnsRecordResponse{} } +func (m *QueryDnsRecordResponse) String() string { return proto.CompactTextString(m) } +func (*QueryDnsRecordResponse) ProtoMessage() {} +func (*QueryDnsRecordResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b8c2c421969ccc6b, []int{5} +} +func (m *QueryDnsRecordResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryDnsRecordResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryDnsRecordResponse.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 *QueryDnsRecordResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryDnsRecordResponse.Merge(m, src) +} +func (m *QueryDnsRecordResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryDnsRecordResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryDnsRecordResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryDnsRecordResponse proto.InternalMessageInfo + +func (m *QueryDnsRecordResponse) GetValue() *types.DnsRecord { + if m != nil { + return m.Value + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "mycel.resolver.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "mycel.resolver.QueryParamsResponse") + proto.RegisterType((*QueryWalletRecordRequest)(nil), "mycel.resolver.QueryWalletRecordRequest") + proto.RegisterType((*QueryWalletRecordResponse)(nil), "mycel.resolver.QueryWalletRecordResponse") + proto.RegisterType((*QueryDnsRecordRequest)(nil), "mycel.resolver.QueryDnsRecordRequest") + proto.RegisterType((*QueryDnsRecordResponse)(nil), "mycel.resolver.QueryDnsRecordResponse") +} + +func init() { proto.RegisterFile("mycel/resolver/query.proto", fileDescriptor_b8c2c421969ccc6b) } + +var fileDescriptor_b8c2c421969ccc6b = []byte{ + // 546 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x6b, 0xd4, 0x40, + 0x14, 0xde, 0xd4, 0xb6, 0xd0, 0xb1, 0x8a, 0x8c, 0xb5, 0x6c, 0x63, 0x89, 0x92, 0x5a, 0x59, 0x2b, + 0x66, 0xe8, 0xea, 0x2f, 0x28, 0x1e, 0x14, 0x41, 0xeb, 0xaa, 0x88, 0xf6, 0xb0, 0xcc, 0x26, 0x8f, + 0x18, 0x48, 0x32, 0xe9, 0xcc, 0xec, 0x6a, 0x28, 0x2b, 0xe8, 0xb1, 0x27, 0xc1, 0x1f, 0xe3, 0x3f, + 0x90, 0x1e, 0x0b, 0x5e, 0x3c, 0x89, 0xec, 0xfa, 0x43, 0xa4, 0x33, 0x93, 0xee, 0x26, 0x0d, 0x6b, + 0x0f, 0xde, 0x36, 0xef, 0x7d, 0xef, 0x7b, 0xdf, 0x37, 0xef, 0x63, 0x91, 0x9d, 0xe4, 0x3e, 0xc4, + 0x84, 0x83, 0x60, 0xf1, 0x00, 0x38, 0xd9, 0xef, 0x03, 0xcf, 0xbd, 0x8c, 0x33, 0xc9, 0xf0, 0x65, + 0xd5, 0xf3, 0x8a, 0x9e, 0xbd, 0x12, 0xb2, 0x90, 0xa9, 0x16, 0x39, 0xf9, 0xa5, 0x51, 0xf6, 0x7a, + 0xc8, 0x58, 0x18, 0x03, 0xa1, 0x59, 0x44, 0x68, 0x9a, 0x32, 0x49, 0x65, 0xc4, 0x52, 0x61, 0xba, + 0x5b, 0x3e, 0x13, 0x09, 0x13, 0xa4, 0x47, 0x05, 0x68, 0x72, 0x32, 0xd8, 0xee, 0x81, 0xa4, 0xdb, + 0x24, 0xa3, 0x61, 0x94, 0x2a, 0xb0, 0xc1, 0x5e, 0xaf, 0x68, 0xc9, 0x28, 0xa7, 0x49, 0x41, 0xd4, + 0x2a, 0x9a, 0x61, 0x24, 0x24, 0xcf, 0x89, 0x00, 0x9f, 0xa5, 0x41, 0x37, 0x86, 0x01, 0xc4, 0xdd, + 0x80, 0x25, 0x34, 0x32, 0x34, 0xee, 0x0a, 0xc2, 0xcf, 0x4f, 0x16, 0xed, 0xaa, 0xf1, 0x0e, 0xec, + 0xf7, 0x41, 0x48, 0xf7, 0x09, 0xba, 0x5a, 0xaa, 0x8a, 0x8c, 0xa5, 0x02, 0xf0, 0x03, 0xb4, 0xa8, + 0xd7, 0x34, 0xad, 0x9b, 0x56, 0xeb, 0x62, 0x7b, 0xd5, 0x2b, 0x9b, 0xf6, 0x34, 0x7e, 0x67, 0xfe, + 0xe8, 0xd7, 0x8d, 0x46, 0xc7, 0x60, 0xdd, 0x43, 0x0b, 0x35, 0x15, 0xdb, 0x6b, 0x1a, 0xc7, 0x20, + 0x3b, 0xe0, 0x33, 0x1e, 0x98, 0x4d, 0xd8, 0x41, 0x48, 0xeb, 0x79, 0x4a, 0x13, 0x50, 0xb4, 0x4b, + 0x9d, 0xa9, 0x0a, 0x76, 0xd1, 0xb2, 0xfe, 0xda, 0xa5, 0x1c, 0x52, 0xd9, 0x9c, 0x53, 0x88, 0x52, + 0x0d, 0x6f, 0xa1, 0x2b, 0xef, 0xa7, 0xa8, 0x5f, 0xe6, 0x19, 0x34, 0x2f, 0x28, 0xdc, 0x99, 0xba, + 0xfb, 0x0c, 0xad, 0xd5, 0x68, 0x31, 0xfe, 0xda, 0x68, 0x61, 0x40, 0xe3, 0x3e, 0x18, 0x7b, 0xeb, + 0xa7, 0xf6, 0xf4, 0x33, 0x7a, 0xa5, 0x21, 0x0d, 0x75, 0x3f, 0x59, 0xe8, 0x9a, 0x62, 0x7c, 0x98, + 0x8a, 0xff, 0x6f, 0xed, 0x16, 0xba, 0x14, 0x14, 0xbc, 0x53, 0xbe, 0xca, 0x45, 0xf7, 0x31, 0x5a, + 0xad, 0x4a, 0x30, 0x8e, 0x48, 0xd9, 0xd1, 0x5a, 0xd5, 0xd1, 0x64, 0x42, 0xe3, 0xda, 0x87, 0xf3, + 0x68, 0x41, 0x71, 0xe1, 0x8f, 0x68, 0x51, 0x9f, 0x13, 0xbb, 0xd5, 0x33, 0x9f, 0x4d, 0x8c, 0xbd, + 0x31, 0x13, 0xa3, 0xd5, 0xb8, 0x77, 0x3f, 0xff, 0xf8, 0xf3, 0x75, 0x6e, 0x13, 0x6f, 0x10, 0x05, + 0xbe, 0xa7, 0xad, 0x92, 0xda, 0x24, 0xe3, 0xef, 0x16, 0x5a, 0x9e, 0x7e, 0x70, 0xdc, 0xaa, 0x5d, + 0x51, 0x13, 0x2a, 0xfb, 0xce, 0x39, 0x90, 0x46, 0x12, 0x55, 0x92, 0xf6, 0xf0, 0x9b, 0x99, 0x92, + 0x74, 0x8c, 0xba, 0x5c, 0xcd, 0x92, 0x83, 0xc9, 0x11, 0x87, 0xc5, 0x87, 0xbe, 0xd7, 0x90, 0x1c, + 0x54, 0x13, 0x37, 0xc4, 0xdf, 0x2c, 0xb4, 0x74, 0xfa, 0xce, 0x78, 0xb3, 0x56, 0x5b, 0x35, 0x3c, + 0xf6, 0xed, 0x7f, 0xc1, 0x8c, 0xfe, 0x3d, 0xa5, 0xff, 0x15, 0x7e, 0x31, 0x53, 0x7f, 0x90, 0x8a, + 0x73, 0x89, 0x2f, 0xc5, 0x6a, 0xb8, 0xf3, 0xe8, 0x68, 0xe4, 0x58, 0xc7, 0x23, 0xc7, 0xfa, 0x3d, + 0x72, 0xac, 0x2f, 0x63, 0xa7, 0x71, 0x3c, 0x76, 0x1a, 0x3f, 0xc7, 0x4e, 0xe3, 0xad, 0x17, 0x46, + 0xf2, 0x5d, 0xbf, 0xe7, 0xf9, 0x2c, 0xa9, 0x5b, 0xfc, 0x61, 0xb2, 0x5a, 0xe6, 0x19, 0x88, 0xde, + 0xa2, 0xfa, 0xb7, 0xb9, 0xff, 0x37, 0x00, 0x00, 0xff, 0xff, 0x32, 0x49, 0xed, 0xcf, 0x42, 0x05, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a list of QueryWalletRecord items. + WalletRecord(ctx context.Context, in *QueryWalletRecordRequest, opts ...grpc.CallOption) (*QueryWalletRecordResponse, error) + // Queries a list of DnsRecord items. + DnsRecord(ctx context.Context, in *QueryDnsRecordRequest, opts ...grpc.CallOption) (*QueryDnsRecordResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/mycel.resolver.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) WalletRecord(ctx context.Context, in *QueryWalletRecordRequest, opts ...grpc.CallOption) (*QueryWalletRecordResponse, error) { + out := new(QueryWalletRecordResponse) + err := c.cc.Invoke(ctx, "/mycel.resolver.Query/WalletRecord", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) DnsRecord(ctx context.Context, in *QueryDnsRecordRequest, opts ...grpc.CallOption) (*QueryDnsRecordResponse, error) { + out := new(QueryDnsRecordResponse) + err := c.cc.Invoke(ctx, "/mycel.resolver.Query/DnsRecord", 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. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Queries a list of QueryWalletRecord items. + WalletRecord(context.Context, *QueryWalletRecordRequest) (*QueryWalletRecordResponse, error) + // Queries a list of DnsRecord items. + DnsRecord(context.Context, *QueryDnsRecordRequest) (*QueryDnsRecordResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) WalletRecord(ctx context.Context, req *QueryWalletRecordRequest) (*QueryWalletRecordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WalletRecord not implemented") +} +func (*UnimplementedQueryServer) DnsRecord(ctx context.Context, req *QueryDnsRecordRequest) (*QueryDnsRecordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DnsRecord not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mycel.resolver.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_WalletRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryWalletRecordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).WalletRecord(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mycel.resolver.Query/WalletRecord", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).WalletRecord(ctx, req.(*QueryWalletRecordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_DnsRecord_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryDnsRecordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DnsRecord(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mycel.resolver.Query/DnsRecord", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DnsRecord(ctx, req.(*QueryDnsRecordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "mycel.resolver.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "WalletRecord", + Handler: _Query_WalletRecord_Handler, + }, + { + MethodName: "DnsRecord", + Handler: _Query_DnsRecord_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "mycel/resolver/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.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 (m *QueryWalletRecordRequest) 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 *QueryWalletRecordRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryWalletRecordRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WalletRecordType) > 0 { + i -= len(m.WalletRecordType) + copy(dAtA[i:], m.WalletRecordType) + i = encodeVarintQuery(dAtA, i, uint64(len(m.WalletRecordType))) + 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 *QueryWalletRecordResponse) 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 *QueryWalletRecordResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryWalletRecordResponse) 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 (m *QueryDnsRecordRequest) 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 *QueryDnsRecordRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDnsRecordRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DnsRecordType) > 0 { + i -= len(m.DnsRecordType) + copy(dAtA[i:], m.DnsRecordType) + i = encodeVarintQuery(dAtA, i, uint64(len(m.DnsRecordType))) + 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 *QueryDnsRecordResponse) 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 *QueryDnsRecordResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryDnsRecordResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryWalletRecordRequest) 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.WalletRecordType) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryWalletRecordResponse) 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 (m *QueryDnsRecordRequest) 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.DnsRecordType) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryDnsRecordResponse) 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 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 err := m.Params.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 (m *QueryWalletRecordRequest) 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: QueryWalletRecordRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryWalletRecordRequest: 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 WalletRecordType", 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.WalletRecordType = 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 *QueryWalletRecordResponse) 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: QueryWalletRecordResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryWalletRecordResponse: 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.WalletRecord{} + } + 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 (m *QueryDnsRecordRequest) 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: QueryDnsRecordRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDnsRecordRequest: 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 DnsRecordType", 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.DnsRecordType = 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 *QueryDnsRecordResponse) 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: QueryDnsRecordResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryDnsRecordResponse: 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.DnsRecord{} + } + 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/resolver/types/query.pb.gw.go b/x/resolver/types/query.pb.gw.go new file mode 100644 index 00000000..5aee3d9b --- /dev/null +++ b/x/resolver/types/query.pb.gw.go @@ -0,0 +1,443 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: mycel/resolver/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_WalletRecord_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryWalletRecordRequest + 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["walletRecordType"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "walletRecordType") + } + + protoReq.WalletRecordType, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "walletRecordType", err) + } + + msg, err := client.WalletRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_WalletRecord_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryWalletRecordRequest + 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["walletRecordType"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "walletRecordType") + } + + protoReq.WalletRecordType, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "walletRecordType", err) + } + + msg, err := server.WalletRecord(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_DnsRecord_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDnsRecordRequest + 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["dnsRecordType"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "dnsRecordType") + } + + protoReq.DnsRecordType, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "dnsRecordType", err) + } + + msg, err := client.DnsRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DnsRecord_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDnsRecordRequest + 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["dnsRecordType"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "dnsRecordType") + } + + protoReq.DnsRecordType, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "dnsRecordType", err) + } + + msg, err := server.DnsRecord(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. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_WalletRecord_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_WalletRecord_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_WalletRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DnsRecord_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_DnsRecord_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_DnsRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_WalletRecord_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_WalletRecord_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_WalletRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_DnsRecord_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_DnsRecord_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_DnsRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mycel-domain", "mycel", "resolver", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_WalletRecord_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", "wallet_record", "domainName", "domainParent", "walletRecordType"}, "", runtime.AssumeColonVerbOpt(true))) + + 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))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_WalletRecord_0 = runtime.ForwardResponseMessage + + forward_Query_DnsRecord_0 = runtime.ForwardResponseMessage +) diff --git a/x/resolver/types/tx.pb.go b/x/resolver/types/tx.pb.go new file mode 100644 index 00000000..a9c76498 --- /dev/null +++ b/x/resolver/types/tx.pb.go @@ -0,0 +1,80 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: mycel/resolver/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("mycel/resolver/tx.proto", fileDescriptor_c16c379c28c13e9c) } + +var fileDescriptor_c16c379c28c13e9c = []byte{ + // 127 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcf, 0xad, 0x4c, 0x4e, + 0xcd, 0xd1, 0x2f, 0x4a, 0x2d, 0xce, 0xcf, 0x29, 0x4b, 0x2d, 0xd2, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, + 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0x4b, 0xe8, 0xc1, 0x24, 0x8c, 0x58, 0xb9, 0x98, 0x7d, 0x8b, + 0xd3, 0x9d, 0x3c, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, + 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x2f, 0x3d, + 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xac, 0x57, 0x37, 0x25, 0x3f, 0x37, + 0x31, 0x33, 0x0f, 0xc2, 0xd1, 0xaf, 0x40, 0xb2, 0xa3, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x6c, + 0x8f, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xee, 0x1b, 0x68, 0x52, 0x82, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "mycel.resolver.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "mycel/resolver/tx.proto", +} diff --git a/x/resolver/types/types.go b/x/resolver/types/types.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/resolver/types/types.go @@ -0,0 +1 @@ +package types