From 2ed74765e5c4cc45e5a069e2a4be46138f0143a6 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Wed, 10 Apr 2024 15:17:34 +0900 Subject: [PATCH 01/12] add initial func --- gno.land/pkg/gnoclient/client_queries.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gno.land/pkg/gnoclient/client_queries.go b/gno.land/pkg/gnoclient/client_queries.go index 8ceb8352e34..8d50c737bf3 100644 --- a/gno.land/pkg/gnoclient/client_queries.go +++ b/gno.land/pkg/gnoclient/client_queries.go @@ -2,7 +2,6 @@ package gnoclient import ( "fmt" - "github.com/gnolang/gno/tm2/pkg/amino" rpcclient "github.com/gnolang/gno/tm2/pkg/bft/rpc/client" ctypes "github.com/gnolang/gno/tm2/pkg/bft/rpc/core/types" @@ -11,6 +10,10 @@ import ( "github.com/gnolang/gno/tm2/pkg/std" ) +var ( + ErrInvalidBlockHeight = errors.New("invalid block height provided") +) + // QueryCfg contains configuration options for performing ABCI queries. type QueryCfg struct { Path string // Query path @@ -123,3 +126,16 @@ func (c *Client) QEval(pkgPath string, expression string) (string, *ctypes.Resul return string(qres.Response.Data), qres, nil } + +func (c *Client) Block(height int64) (*ctypes.ResultBlockResults, error) { + if height <= 0 { + return nil, ErrInvalidBlockHeight + } + + blockResults, err := c.RPCClient.BlockResults(&height) + if err != nil { + return nil, fmt.Errorf("block query failed: %w", err) + } + + return blockResults, nil +} From 07c14732de2a60a921dbc18e19cb821a12583ac7 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Wed, 10 Apr 2024 15:38:09 +0900 Subject: [PATCH 02/12] add block & block number functions --- gno.land/pkg/gnoclient/client_queries.go | 24 +++++++++++++++++++- gno.land/pkg/gnoclient/integration_test.go | 26 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/gno.land/pkg/gnoclient/client_queries.go b/gno.land/pkg/gnoclient/client_queries.go index 8d50c737bf3..68a9ac71a89 100644 --- a/gno.land/pkg/gnoclient/client_queries.go +++ b/gno.land/pkg/gnoclient/client_queries.go @@ -127,7 +127,20 @@ func (c *Client) QEval(pkgPath string, expression string) (string, *ctypes.Resul return string(qres.Response.Data), qres, nil } -func (c *Client) Block(height int64) (*ctypes.ResultBlockResults, error) { +func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) { + if height <= 0 { + return nil, ErrInvalidBlockHeight + } + + blockResults, err := c.RPCClient.Block(&height) + if err != nil { + return nil, fmt.Errorf("block query failed: %w", err) + } + + return blockResults, nil +} + +func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) { if height <= 0 { return nil, ErrInvalidBlockHeight } @@ -139,3 +152,12 @@ func (c *Client) Block(height int64) (*ctypes.ResultBlockResults, error) { return blockResults, nil } + +func (c *Client) BlockNumber() (int64, error) { + status, err := c.RPCClient.Status() + if err != nil { + return 0, fmt.Errorf("block number query failed: %w", err) + } + + return status.SyncInfo.LatestBlockHeight, nil +} diff --git a/gno.land/pkg/gnoclient/integration_test.go b/gno.land/pkg/gnoclient/integration_test.go index 3244b32af3f..e3aff65871c 100644 --- a/gno.land/pkg/gnoclient/integration_test.go +++ b/gno.land/pkg/gnoclient/integration_test.go @@ -1,6 +1,7 @@ package gnoclient import ( + "fmt" "testing" "github.com/gnolang/gno/gnovm/pkg/gnolang" @@ -547,3 +548,28 @@ func newInMemorySigner(t *testing.T, chainid string) *SignerFromKeybase { ChainID: chainid, // Chain ID for transaction signing } } + +func TestBlock_Integration(t *testing.T) { + // Set up in-memory node + config, _ := integration.TestingNodeConfig(t, gnoenv.RootDir()) + node, remoteAddr := integration.TestingInMemoryNode(t, log.NewNoopLogger(), config) + defer node.Stop() + + // Init Signer & RPCClient + signer := newInMemorySigner(t, "tendermint_test") + rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket") + + // Setup Client + client := Client{ + Signer: signer, + RPCClient: rpcClient, + } + + //res, _ := client.Block(1) + + //fmt.Println(res.Height, res.Results.BeginBlock, res.Results.EndBlock, res.Results.DeliverTxs) + + status, _ := client.RPCClient.Status() + + fmt.Println(status.SyncInfo.LatestBlockHeight) +} From 60c881dee052177d237d04b17dd42db0680bada5 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Wed, 10 Apr 2024 15:48:04 +0900 Subject: [PATCH 03/12] add comments --- gno.land/pkg/gnoclient/client_queries.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gno.land/pkg/gnoclient/client_queries.go b/gno.land/pkg/gnoclient/client_queries.go index 68a9ac71a89..4ef3601449f 100644 --- a/gno.land/pkg/gnoclient/client_queries.go +++ b/gno.land/pkg/gnoclient/client_queries.go @@ -127,6 +127,8 @@ func (c *Client) QEval(pkgPath string, expression string) (string, *ctypes.Resul return string(qres.Response.Data), qres, nil } +// Block gets the latest block at height, if any +// Height must be larger than 0 func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) { if height <= 0 { return nil, ErrInvalidBlockHeight @@ -140,6 +142,8 @@ func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) { return blockResults, nil } +// BlockResult gets the latest block results at height, if any +// Height must be larger than 0 func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) { if height <= 0 { return nil, ErrInvalidBlockHeight @@ -153,6 +157,7 @@ func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) { return blockResults, nil } +// BlockNumber gets the latest block height on the chain func (c *Client) BlockNumber() (int64, error) { status, err := c.RPCClient.Status() if err != nil { From f10b33de5d6707b8b624a92a1449d5a69083332f Mon Sep 17 00:00:00 2001 From: leohhhn Date: Wed, 10 Apr 2024 15:59:28 +0900 Subject: [PATCH 04/12] remove sandbox code --- gno.land/pkg/gnoclient/integration_test.go | 26 ---------------------- 1 file changed, 26 deletions(-) diff --git a/gno.land/pkg/gnoclient/integration_test.go b/gno.land/pkg/gnoclient/integration_test.go index e3aff65871c..3244b32af3f 100644 --- a/gno.land/pkg/gnoclient/integration_test.go +++ b/gno.land/pkg/gnoclient/integration_test.go @@ -1,7 +1,6 @@ package gnoclient import ( - "fmt" "testing" "github.com/gnolang/gno/gnovm/pkg/gnolang" @@ -548,28 +547,3 @@ func newInMemorySigner(t *testing.T, chainid string) *SignerFromKeybase { ChainID: chainid, // Chain ID for transaction signing } } - -func TestBlock_Integration(t *testing.T) { - // Set up in-memory node - config, _ := integration.TestingNodeConfig(t, gnoenv.RootDir()) - node, remoteAddr := integration.TestingInMemoryNode(t, log.NewNoopLogger(), config) - defer node.Stop() - - // Init Signer & RPCClient - signer := newInMemorySigner(t, "tendermint_test") - rpcClient := rpcclient.NewHTTP(remoteAddr, "/websocket") - - // Setup Client - client := Client{ - Signer: signer, - RPCClient: rpcClient, - } - - //res, _ := client.Block(1) - - //fmt.Println(res.Height, res.Results.BeginBlock, res.Results.EndBlock, res.Results.DeliverTxs) - - status, _ := client.RPCClient.Status() - - fmt.Println(status.SyncInfo.LatestBlockHeight) -} From 12d11a6c11071dd13a05dbd164c18e60bb6f83d7 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Wed, 10 Apr 2024 16:16:08 +0900 Subject: [PATCH 05/12] add error tests for block methods --- gno.land/pkg/gnoclient/client_queries.go | 12 +++ gno.land/pkg/gnoclient/client_test.go | 113 +++++++++++++++++++++++ 2 files changed, 125 insertions(+) diff --git a/gno.land/pkg/gnoclient/client_queries.go b/gno.land/pkg/gnoclient/client_queries.go index 4ef3601449f..af4b3e037a3 100644 --- a/gno.land/pkg/gnoclient/client_queries.go +++ b/gno.land/pkg/gnoclient/client_queries.go @@ -130,6 +130,10 @@ func (c *Client) QEval(pkgPath string, expression string) (string, *ctypes.Resul // Block gets the latest block at height, if any // Height must be larger than 0 func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) { + if err := c.validateRPCClient(); err != nil { + return nil, ErrMissingRPCClient + } + if height <= 0 { return nil, ErrInvalidBlockHeight } @@ -145,6 +149,10 @@ func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) { // BlockResult gets the latest block results at height, if any // Height must be larger than 0 func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) { + if err := c.validateRPCClient(); err != nil { + return nil, ErrMissingRPCClient + } + if height <= 0 { return nil, ErrInvalidBlockHeight } @@ -159,6 +167,10 @@ func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) { // BlockNumber gets the latest block height on the chain func (c *Client) BlockNumber() (int64, error) { + if err := c.validateRPCClient(); err != nil { + return 0, ErrMissingRPCClient + } + status, err := c.RPCClient.Status() if err != nil { return 0, fmt.Errorf("block number query failed: %w", err) diff --git a/gno.land/pkg/gnoclient/client_test.go b/gno.land/pkg/gnoclient/client_test.go index d68a209dd26..2dacaed4284 100644 --- a/gno.land/pkg/gnoclient/client_test.go +++ b/gno.land/pkg/gnoclient/client_test.go @@ -1079,3 +1079,116 @@ func TestAddPackageErrors(t *testing.T) { }) } } + +// Block tests +func TestBlockErrors(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + client Client + height int64 + expectedError error + }{ + { + name: "Invalid RPCClient", + client: Client{ + &mockSigner{}, + nil, + }, + height: 1, + expectedError: ErrMissingRPCClient, + }, + { + name: "Invalid height", + client: Client{ + &mockSigner{}, + &mockRPCClient{}, + }, + height: 0, + expectedError: ErrInvalidBlockHeight, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + res, err := tc.client.Block(tc.height) + assert.Nil(t, res) + assert.ErrorIs(t, err, tc.expectedError) + }) + } +} + +func TestBlockResultErrors(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + client Client + height int64 + expectedError error + }{ + { + name: "Invalid RPCClient", + client: Client{ + &mockSigner{}, + nil, + }, + height: 1, + expectedError: ErrMissingRPCClient, + }, + { + name: "Invalid height", + client: Client{ + &mockSigner{}, + &mockRPCClient{}, + }, + height: 0, + expectedError: ErrInvalidBlockHeight, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + res, err := tc.client.BlockResult(tc.height) + assert.Nil(t, res) + assert.ErrorIs(t, err, tc.expectedError) + }) + } +} + +func TestBlockNumberErrors(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + client Client + expectedError error + }{ + { + name: "Invalid RPCClient", + client: Client{ + &mockSigner{}, + nil, + }, + expectedError: ErrMissingRPCClient, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + res, err := tc.client.BlockNumber() + assert.Equal(t, int64(0), res) + assert.ErrorIs(t, err, tc.expectedError) + }) + } +} From 421f913067f69a4b2135ac1d89338bcc414778fd Mon Sep 17 00:00:00 2001 From: leohhhn Date: Sat, 13 Apr 2024 17:42:57 +0900 Subject: [PATCH 06/12] make fmt --- gno.land/pkg/gnoclient/client_queries.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gno.land/pkg/gnoclient/client_queries.go b/gno.land/pkg/gnoclient/client_queries.go index af4b3e037a3..4b9dab381ae 100644 --- a/gno.land/pkg/gnoclient/client_queries.go +++ b/gno.land/pkg/gnoclient/client_queries.go @@ -2,6 +2,7 @@ package gnoclient import ( "fmt" + "github.com/gnolang/gno/tm2/pkg/amino" rpcclient "github.com/gnolang/gno/tm2/pkg/bft/rpc/client" ctypes "github.com/gnolang/gno/tm2/pkg/bft/rpc/core/types" @@ -10,9 +11,7 @@ import ( "github.com/gnolang/gno/tm2/pkg/std" ) -var ( - ErrInvalidBlockHeight = errors.New("invalid block height provided") -) +var ErrInvalidBlockHeight = errors.New("invalid block height provided") // QueryCfg contains configuration options for performing ABCI queries. type QueryCfg struct { From dcd67f28ee9e1fead8e381e649540a39bb3543d0 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Tue, 23 Apr 2024 21:52:05 +0200 Subject: [PATCH 07/12] add block mock --- gno.land/pkg/gnoclient/client_queries.go | 4 +-- gno.land/pkg/gnoclient/client_test.go | 31 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/gno.land/pkg/gnoclient/client_queries.go b/gno.land/pkg/gnoclient/client_queries.go index 4b9dab381ae..da66b48db95 100644 --- a/gno.land/pkg/gnoclient/client_queries.go +++ b/gno.land/pkg/gnoclient/client_queries.go @@ -137,12 +137,12 @@ func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) { return nil, ErrInvalidBlockHeight } - blockResults, err := c.RPCClient.Block(&height) + block, err := c.RPCClient.Block(&height) if err != nil { return nil, fmt.Errorf("block query failed: %w", err) } - return blockResults, nil + return block, nil } // BlockResult gets the latest block results at height, if any diff --git a/gno.land/pkg/gnoclient/client_test.go b/gno.land/pkg/gnoclient/client_test.go index 2dacaed4284..74fddd25c81 100644 --- a/gno.land/pkg/gnoclient/client_test.go +++ b/gno.land/pkg/gnoclient/client_test.go @@ -1080,6 +1080,37 @@ func TestAddPackageErrors(t *testing.T) { } } +func TestBlock(t *testing.T) { + t.Parallel() + + height := int64(5) + + client := &Client{ + Signer: &mockSigner{}, + RPCClient: &mockRPCClient{ + block: func(height *int64) (*ctypes.ResultBlock, error) { + return &ctypes.ResultBlock{ + BlockMeta: &types.BlockMeta{ + BlockID: types.BlockID{}, + Header: types.Header{}, + }, + Block: &types.Block{ + Header: types.Header{ + Height: *height, + }, + Data: types.Data{}, + LastCommit: nil, + }, + }, nil + }, + }, + } + + block, err := client.Block(height) + require.NoError(t, err) + assert.Equal(t, height, block.Block.GetHeight()) +} + // Block tests func TestBlockErrors(t *testing.T) { t.Parallel() From d428c1da3d3b98bd93996d734883f241d798eb04 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 26 Apr 2024 13:51:32 +0200 Subject: [PATCH 08/12] add mocks --- gno.land/pkg/gnoclient/client_test.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gno.land/pkg/gnoclient/client_test.go b/gno.land/pkg/gnoclient/client_test.go index 74fddd25c81..51e389109fd 100644 --- a/gno.land/pkg/gnoclient/client_test.go +++ b/gno.land/pkg/gnoclient/client_test.go @@ -1080,11 +1080,11 @@ func TestAddPackageErrors(t *testing.T) { } } +// Block tests func TestBlock(t *testing.T) { t.Parallel() height := int64(5) - client := &Client{ Signer: &mockSigner{}, RPCClient: &mockRPCClient{ @@ -1111,7 +1111,27 @@ func TestBlock(t *testing.T) { assert.Equal(t, height, block.Block.GetHeight()) } -// Block tests +func TestBlockResults(t *testing.T) { + t.Parallel() + + height := int64(5) + client := &Client{ + Signer: &mockSigner{}, + RPCClient: &mockRPCClient{ + blockResults: func(height *int64) (*ctypes.ResultBlockResults, error) { + return &ctypes.ResultBlockResults{ + Height: *height, + Results: nil, + }, nil + }, + }, + } + + blockResult, err := client.BlockResult(height) + require.NoError(t, err) + assert.Equal(t, height, blockResult.Height) +} + func TestBlockErrors(t *testing.T) { t.Parallel() From 8951210bce076b477f3d1c4bc90a9d24065c7702 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 26 Apr 2024 14:24:27 +0200 Subject: [PATCH 09/12] update head function --- gno.land/pkg/gnoclient/client_queries.go | 4 ++-- gno.land/pkg/gnoclient/client_test.go | 27 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/gno.land/pkg/gnoclient/client_queries.go b/gno.land/pkg/gnoclient/client_queries.go index da66b48db95..d2ddbcf7317 100644 --- a/gno.land/pkg/gnoclient/client_queries.go +++ b/gno.land/pkg/gnoclient/client_queries.go @@ -164,8 +164,8 @@ func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) { return blockResults, nil } -// BlockNumber gets the latest block height on the chain -func (c *Client) BlockNumber() (int64, error) { +// Head gets the head of the chain (latest block height) +func (c *Client) Head() (int64, error) { if err := c.validateRPCClient(); err != nil { return 0, ErrMissingRPCClient } diff --git a/gno.land/pkg/gnoclient/client_test.go b/gno.land/pkg/gnoclient/client_test.go index 51e389109fd..b8316c49998 100644 --- a/gno.land/pkg/gnoclient/client_test.go +++ b/gno.land/pkg/gnoclient/client_test.go @@ -1132,6 +1132,29 @@ func TestBlockResults(t *testing.T) { assert.Equal(t, height, blockResult.Height) } +func TestHead(t *testing.T) { + t.Parallel() + + latestHeight := int64(5) + + client := &Client{ + Signer: &mockSigner{}, + RPCClient: &mockRPCClient{ + status: func() (*ctypes.ResultStatus, error) { + return &ctypes.ResultStatus{ + SyncInfo: ctypes.SyncInfo{ + LatestBlockHeight: latestHeight, + }, + }, nil + }, + }, + } + + head, err := client.Head() + require.NoError(t, err) + assert.Equal(t, latestHeight, head) +} + func TestBlockErrors(t *testing.T) { t.Parallel() @@ -1214,7 +1237,7 @@ func TestBlockResultErrors(t *testing.T) { } } -func TestBlockNumberErrors(t *testing.T) { +func TestHeadErrors(t *testing.T) { t.Parallel() testCases := []struct { @@ -1237,7 +1260,7 @@ func TestBlockNumberErrors(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() - res, err := tc.client.BlockNumber() + res, err := tc.client.Head() assert.Equal(t, int64(0), res) assert.ErrorIs(t, err, tc.expectedError) }) From 2dd12904facd460e34ba8881f2b7c48d33b68e1b Mon Sep 17 00:00:00 2001 From: leohhhn Date: Fri, 26 Apr 2024 14:31:41 +0200 Subject: [PATCH 10/12] rename function --- gno.land/pkg/gnoclient/client_queries.go | 4 ++-- gno.land/pkg/gnoclient/client_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gno.land/pkg/gnoclient/client_queries.go b/gno.land/pkg/gnoclient/client_queries.go index d2ddbcf7317..b1e7e592415 100644 --- a/gno.land/pkg/gnoclient/client_queries.go +++ b/gno.land/pkg/gnoclient/client_queries.go @@ -164,8 +164,8 @@ func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) { return blockResults, nil } -// Head gets the head of the chain (latest block height) -func (c *Client) Head() (int64, error) { +// LatestBlockHeight gets the latest block height on the chain +func (c *Client) LatestBlockHeight() (int64, error) { if err := c.validateRPCClient(); err != nil { return 0, ErrMissingRPCClient } diff --git a/gno.land/pkg/gnoclient/client_test.go b/gno.land/pkg/gnoclient/client_test.go index b8316c49998..04ebb8e27b8 100644 --- a/gno.land/pkg/gnoclient/client_test.go +++ b/gno.land/pkg/gnoclient/client_test.go @@ -1132,7 +1132,7 @@ func TestBlockResults(t *testing.T) { assert.Equal(t, height, blockResult.Height) } -func TestHead(t *testing.T) { +func TestLatestBlockHeight(t *testing.T) { t.Parallel() latestHeight := int64(5) @@ -1150,7 +1150,7 @@ func TestHead(t *testing.T) { }, } - head, err := client.Head() + head, err := client.LatestBlockHeight() require.NoError(t, err) assert.Equal(t, latestHeight, head) } @@ -1237,7 +1237,7 @@ func TestBlockResultErrors(t *testing.T) { } } -func TestHeadErrors(t *testing.T) { +func TestLatestBlockHeightErrors(t *testing.T) { t.Parallel() testCases := []struct { @@ -1260,7 +1260,7 @@ func TestHeadErrors(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() - res, err := tc.client.Head() + res, err := tc.client.LatestBlockHeight() assert.Equal(t, int64(0), res) assert.ErrorIs(t, err, tc.expectedError) }) From 4cfe818a8f584d130696d24e4360df83ac696a65 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Mon, 29 Apr 2024 15:25:49 +0200 Subject: [PATCH 11/12] update ref docs --- docs/reference/gnoclient/client.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/reference/gnoclient/client.md b/docs/reference/gnoclient/client.md index 3f258fa683e..ca90a368f7f 100644 --- a/docs/reference/gnoclient/client.md +++ b/docs/reference/gnoclient/client.md @@ -25,6 +25,30 @@ func (c *Client) AddPackage(cfg BaseTxCfg, msgs ...MsgAddPackage) (*ctypes.Resul `AddPackage` executes one or more [AddPackage](#type-msgaddpackage) calls on the blockchain. +### func \(\*Client\) [Block]() + +```go +func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) +``` + +`Block` gets the latest block at height, if any. Height must be larger than 0. + +### func \(\*Client\) [BlockResult]() + +```go +func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) +``` + +`BlockResult` gets the latest block results at height, if any. Height must be larger than 0. + +### func \(\*Client\) [LatestBlockHeight]() + +```go +func (c *Client) LatestBlockHeight() (int64, error) +``` + +`LatestBlockHeight` gets the latest block height on the chain. + ### func \(\*Client\) [Call]() ```go From b491bc31713c9aba7bdb376f98161fc0df3f1689 Mon Sep 17 00:00:00 2001 From: leohhhn Date: Mon, 29 Apr 2024 15:27:01 +0200 Subject: [PATCH 12/12] update doc domment --- docs/reference/gnoclient/client.md | 2 +- gno.land/pkg/gnoclient/client_queries.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/gnoclient/client.md b/docs/reference/gnoclient/client.md index ca90a368f7f..0fbef3f5f93 100644 --- a/docs/reference/gnoclient/client.md +++ b/docs/reference/gnoclient/client.md @@ -39,7 +39,7 @@ func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) ``` -`BlockResult` gets the latest block results at height, if any. Height must be larger than 0. +`BlockResult` gets the block results at height, if any. Height must be larger than 0. ### func \(\*Client\) [LatestBlockHeight]() diff --git a/gno.land/pkg/gnoclient/client_queries.go b/gno.land/pkg/gnoclient/client_queries.go index b1e7e592415..a6c8ea60475 100644 --- a/gno.land/pkg/gnoclient/client_queries.go +++ b/gno.land/pkg/gnoclient/client_queries.go @@ -145,7 +145,7 @@ func (c *Client) Block(height int64) (*ctypes.ResultBlock, error) { return block, nil } -// BlockResult gets the latest block results at height, if any +// BlockResult gets the block results at height, if any // Height must be larger than 0 func (c *Client) BlockResult(height int64) (*ctypes.ResultBlockResults, error) { if err := c.validateRPCClient(); err != nil {