Skip to content

Commit

Permalink
feat: add gno.land/pkg/gnoclient (Gno.land Go client)
Browse files Browse the repository at this point in the history
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
  • Loading branch information
moul committed Sep 10, 2023
1 parent 207d66d commit 0d235f0
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gno.land/pkg/gnoclient/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Gno.land Go Client

This is a Go client library for interacting with the Gno.land RPC API.
The library provides a convenient way to make requests to the Gno.land API endpoints and process the responses.

## Installation

To use this library, you can add it to your Go project using `go get`:

go get github.com/gnolang/gno/gno.land/pkg/gnoclient

## Usage

TODO
36 changes: 36 additions & 0 deletions gno.land/pkg/gnoclient/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package gnoclient

// Client represents the Gno.land RPC API client.
type Client struct {
Remote string
ChainID string
}

// TODO: port existing code, i.e. faucet?
// TODO: create right now a tm2 generic go client and a gnovm generic go client?
// TODO: Command: Call
// TODO: Command: Send
// TODO: Command: AddPkg
// TODO: Command: Query
// TODO: Command: Eval
// TODO: Command: Exec
// TODO: Command: Package
// TODO: Command: QFile
// TODO: examples and unit tests
// TODO: Mock
// TODO: alternative configuration (pass existing websocket?)
// TODO: minimal go.mod to make it light to import

func (c *Client) ApplyDefaults() {
if c.Remote == "" {
c.Remote = "127.0.0.1:26657"
}
if c.ChainID == "" {
c.ChainID = "devnet"
}
}

// Request performs an API request and returns the response body.
func (c *Client) Request(method, endpoint string, params map[string]interface{}) ([]byte, error) {
panic("not implemented")
}
15 changes: 15 additions & 0 deletions gno.land/pkg/gnoclient/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package gnoclient

import (
"testing"
)

func TestClient_Request(t *testing.T) {
client := Client{
Remote: "localhost:12345",
ChainID: "test",
}
_ = client

// TODO: xxx
}
15 changes: 15 additions & 0 deletions gno.land/pkg/gnoclient/example_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package gnoclient_test

import (
"fmt"

"github.com/gnolang/gno/gno.land/pkg/gnoclient"
)

func Example() {
client := gnoclient.Client{}
_ = client
fmt.Println("Hello")
// Output:
// Hello
}

0 comments on commit 0d235f0

Please sign in to comment.