Documentation
¶
Overview ¶
Package client defines client for interacting with the Kwil provider. It's supposed to be used as go-sdk for Kwil, currently used by the Kwil CLI.
Index ¶
- func EncodeInputs(tup []any) ([]*types.EncodedValue, error)
- func WaitForTx(ctx context.Context, ...) (*types.TxQueryResponse, error)
- type Client
- func (c *Client) Call(ctx context.Context, namespace string, action string, inputs []any) (*types.CallResult, error)
- func (c *Client) ChainClient() chainrpc.Client
- func (c *Client) ChainID() string
- func (c *Client) ChainInfo(ctx context.Context) (*types.ChainInfo, error)
- func (c *Client) ChangesetMetadata(ctx context.Context, height int64) (numChangesets int64, chunkSizes []int64, err error)
- func (c *Client) Execute(ctx context.Context, namespace string, action string, tuples [][]any, ...) (types.Hash, error)
- func (c *Client) ExecuteSQL(ctx context.Context, stmt string, params map[string]any, ...) (types.Hash, error)
- func (c *Client) GenesisSnapshotChunk(ctx context.Context, height uint64, chunkIdx uint32) ([]byte, error)
- func (c *Client) GenesisState(ctx context.Context) (*types.MigrationMetadata, error)
- func (c *Client) GetAccount(ctx context.Context, acctID *types.AccountID, status types.AccountStatus) (*types.Account, error)
- func (c *Client) GetNumAccounts(ctx context.Context) (count, height int64, err error)
- func (c *Client) Health(ctx context.Context) (*types.Health, error)
- func (c *Client) ListMigrations(ctx context.Context) ([]*types.Migration, error)
- func (c *Client) LoadChangeset(ctx context.Context, height int64, index int64) ([]byte, error)
- func (c *Client) Ping(ctx context.Context) (string, error)
- func (c *Client) PrivateMode() bool
- func (c *Client) Query(ctx context.Context, query string, params map[string]any, skipAuth bool) (*types.QueryResult, error)
- func (c *Client) Signer() auth.Signer
- func (c *Client) SvcClient() user.TxSvcClient
- func (c *Client) Transfer(ctx context.Context, to *types.AccountID, amount *big.Int, ...) (types.Hash, error)
- func (c *Client) TxQuery(ctx context.Context, txHash types.Hash) (*types.TxQueryResponse, error)
- func (c *Client) WaitTx(ctx context.Context, txHash types.Hash, interval time.Duration) (*types.TxQueryResponse, error)
- type RPCClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeInputs ¶ added in v0.4.0
func EncodeInputs(tup []any) ([]*types.EncodedValue, error)
EncodeInputs encodes input(a tuple) for usage in a transaction.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client that interacts with a public Kwil provider.
func NewClient ¶
func NewClient(ctx context.Context, target string, options *clientType.Options) (c *Client, err error)
NewClient creates a Kwil client. The target should be a URL (for an http.Client). It by default communicates with target via HTTP; chain ID of the remote host will be verified against the chain ID passed in.
func WrapClient ¶
func WrapClient(ctx context.Context, client RPCClient, options *clientType.Options) (*Client, error)
WrapClient wraps a TxSvcClient with a Kwil client. It provides a way to use a custom rpc client with the Kwil client.
func (*Client) Call ¶ added in v0.2.0
func (c *Client) Call(ctx context.Context, namespace string, action string, inputs []any) (*types.CallResult, error)
Call calls an action. It returns the result records.
func (*Client) ChainClient ¶ added in v0.4.0
ChainClient is a trapdoor to access the underlying core/rpc/client/chain.Client.
func (*Client) ChainInfo ¶
ChainInfo get the current blockchain information like chain ID and best block height/hash.
func (*Client) ChangesetMetadata ¶ added in v0.3.0
func (*Client) Execute ¶ added in v0.2.0
func (c *Client) Execute(ctx context.Context, namespace string, action string, tuples [][]any, opts ...clientType.TxOpt) (types.Hash, error)
Execute executes an action. It returns the receipt, as well as outputs which is the decoded body of the receipt. It can take any number of inputs, and if multiple tuples of inputs are passed, it will execute them in the same transaction.
func (*Client) ExecuteSQL ¶ added in v0.4.0
func (c *Client) ExecuteSQL(ctx context.Context, stmt string, params map[string]any, opts ...clientType.TxOpt) (types.Hash, error)
ExecuteSQL executes a SQL statement.
func (*Client) GenesisSnapshotChunk ¶ added in v0.3.0
func (*Client) GenesisState ¶ added in v0.3.0
func (*Client) GetAccount ¶
func (c *Client) GetAccount(ctx context.Context, acctID *types.AccountID, status types.AccountStatus) (*types.Account, error)
GetAccount gets account info by account ID. If status is AccountStatusPending, it will include the pending info.
func (*Client) GetNumAccounts ¶ added in v0.4.0
func (*Client) ListMigrations ¶ added in v0.3.0
func (*Client) LoadChangeset ¶ added in v0.3.0
func (*Client) PrivateMode ¶ added in v0.3.0
PrivateMode returns if it the client has connected to an RPC server that is running in "private" mode where call requests require authentication. In addition, queries are expected to be denied, and no verbose transaction information will returned with a transaction status query.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, query string, params map[string]any, skipAuth bool) (*types.QueryResult, error)
Query executes a query.
func (*Client) Signer ¶
Signer returns the signer used by the client. It can be nil if the client is not configured with a signer.
func (*Client) SvcClient ¶ added in v0.2.0
func (c *Client) SvcClient() user.TxSvcClient
SvcClient is a trapdoor to access the underlying core/rpc/client/user.TxSvcClient. Most applications will only use the methods of Client.
func (*Client) Transfer ¶
func (c *Client) Transfer(ctx context.Context, to *types.AccountID, amount *big.Int, opts ...clientType.TxOpt) (types.Hash, error)
Transfer transfers balance to a given address.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package client contains the shared client types, including the options used to construct a Client instance, and the records iterator used to represent the results of an action call.
|
Package client contains the shared client types, including the options used to construct a Client instance, and the records iterator used to represent the results of an action call. |