-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add gno.land/pkg/gnoclient (Gno.land Go client)
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |