Giter VIP home page Giter VIP logo

Comments (2)

harish551 avatar harish551 commented on July 25, 2024 1

Hey @taramakage

If you got result with cli you should get with gRPC also because cli using same gRPC method for querying Denom
https://github.com/OmniFlix/onft/blob/onft-gon/client/cli/query.go#L218
https://github.com/OmniFlix/onft/blob/onft-gon/keeper/grpc_query.go#L146

Here I've updated above code snippet & it's working

package main

import (
	"context"
        "fmt"

	nfttypes "github.com/OmniFlix/onft/types"
	"google.golang.org/grpc"
)

type Omniflix struct {
	conn      *grpc.ClientConn
	nftClient nfttypes.QueryClient
}

func NewOmniflix() *Omniflix {
	conn, err := grpc.Dial(
		"grpc.gon-flixnet.omniflix.io:9090",
		grpc.WithInsecure(),
		grpc.WithDefaultCallOptions(),
	)
	if err != nil {
		panic(err)
	}

	return &Omniflix{
		conn:      conn,
		nftClient: nfttypes.NewQueryClient(conn),
	}
}

// Basiclly this method dosen't work as expection.
func (o *Omniflix) GetClass(classID string) (*nfttypes.Denom, error) {
	req := &nfttypes.QueryDenomRequest{
		DenomId: classID,
	}

	// Here i get the error: rpc error: code = Unimplemented desc = unknown service OmniFlix.onft.v1beta1.Query
	res, err :=  o.nftClient.Denom(context.Background(), req)
	if err != nil {
		return nil, err
        }
	// res, ok := resi.(*nfttypes.QueryDenomResponse)
	// if !ok {
	//	return nil, err
	//}

	return &nfttypes.Denom{
		Id:      res.Denom.Id,
		Name:    res.Denom.Name,
		Schema:  res.Denom.Schema,
		Creator: res.Denom.Creator,
		Uri:     res.Denom.Uri,
		UriHash: res.Denom.UriHash,
		Data:    res.Denom.Data,
	}, nil
}


func main() {
    omniflix := NewOmniflix()
    class, err := omniflix.GetClass("ibc/B9C0497B80973FB67A3000836186317DA046574DEE98D938848C8620AEFE99DA")
    if err != nil {
        panic(err)
    }
    fmt.Println(class)
}

from omniflixhub.

taramakage avatar taramakage commented on July 25, 2024

Hey @harish551, thank you very much. I just compared two snippets and found that I accidentally used the Iris gRPC address. My God...

from omniflixhub.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.