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 ¶
- type Client
- func (c *Client) Call(ctx context.Context, dbid string, procedure string, inputs []any) (*clientType.CallResult, error)
- func (c *Client) CallAction(ctx context.Context, dbid string, action string, inputs []any) (*clientType.Records, error)
- 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) DeployDatabase(ctx context.Context, payload *types.Schema, opts ...clientType.TxOpt) (transactions.TxHash, error)
- func (c *Client) DropDatabase(ctx context.Context, name string, opts ...clientType.TxOpt) (transactions.TxHash, error)
- func (c *Client) DropDatabaseID(ctx context.Context, dbid string, opts ...clientType.TxOpt) (transactions.TxHash, error)
- func (c *Client) Execute(ctx context.Context, dbid string, procedure string, tuples [][]any, ...) (transactions.TxHash, error)
- func (c *Client) ExecuteAction(ctx context.Context, dbid string, action string, tuples [][]any, ...) (transactions.TxHash, 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 []byte, status types.AccountStatus) (*types.Account, error)
- func (c *Client) GetSchema(ctx context.Context, dbid string) (*types.Schema, error)
- func (c *Client) Health(ctx context.Context) (*types.Health, error)
- func (c *Client) ListDatabases(ctx context.Context, owner []byte) ([]*types.DatasetIdentifier, 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) NewSignedTx(ctx context.Context, data transactions.Payload, txOpts *clientType.TxOptions) (*transactions.Transaction, error)
- func (c *Client) Ping(ctx context.Context) (string, error)
- func (c *Client) PrivateMode() bool
- func (c *Client) Query(ctx context.Context, dbid string, query string) (*clientType.Records, error)
- func (c *Client) SvcClient() user.TxSvcClient
- func (c *Client) Transfer(ctx context.Context, to []byte, amount *big.Int, opts ...clientType.TxOpt) (transactions.TxHash, error)
- func (c *Client) TxQuery(ctx context.Context, txHash []byte) (*transactions.TcTxQueryResponse, error)
- func (c *Client) WaitTx(ctx context.Context, txHash []byte, interval time.Duration) (*transactions.TcTxQueryResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
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 user.TxSvcClient, 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, dbid string, procedure string, inputs []any) (*clientType.CallResult, error)
Call calls a procedure or action. It returns the result records.
func (*Client) CallAction ¶
func (c *Client) CallAction(ctx context.Context, dbid string, action string, inputs []any) (*clientType.Records, error)
DEPRECATED: Use Call instead.
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) DeployDatabase ¶
func (c *Client) DeployDatabase(ctx context.Context, payload *types.Schema, opts ...clientType.TxOpt) (transactions.TxHash, error)
DeployDatabase deploys a database.
func (*Client) DropDatabase ¶
func (c *Client) DropDatabase(ctx context.Context, name string, opts ...clientType.TxOpt) (transactions.TxHash, error)
DropDatabase drops a database by name, using the configured signer to derive the DB ID.
func (*Client) DropDatabaseID ¶
func (c *Client) DropDatabaseID(ctx context.Context, dbid string, opts ...clientType.TxOpt) (transactions.TxHash, error)
DropDatabaseID drops a database by ID.
func (*Client) Execute ¶ added in v0.2.0
func (c *Client) Execute(ctx context.Context, dbid string, procedure string, tuples [][]any, opts ...clientType.TxOpt) (transactions.TxHash, error)
Execute executes a procedure or 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) ExecuteAction ¶
func (c *Client) ExecuteAction(ctx context.Context, dbid string, action string, tuples [][]any, opts ...clientType.TxOpt) (transactions.TxHash, error)
DEPRECATED: Use Execute instead.
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 []byte, 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) ListDatabases ¶
func (c *Client) ListDatabases(ctx context.Context, owner []byte) ([]*types.DatasetIdentifier, error)
ListDatabases lists databases belonging to an owner. If no owner is passed, it will list all databases.
func (*Client) ListMigrations ¶ added in v0.3.0
func (*Client) LoadChangeset ¶ added in v0.3.0
func (*Client) NewSignedTx ¶ added in v0.2.0
func (c *Client) NewSignedTx(ctx context.Context, data transactions.Payload, txOpts *clientType.TxOptions) (*transactions.Transaction, error)
NewSignedTx creates a signed transaction with a prepared payload. This will set the nonce to signer's latest, build the Transaction, set the Fee, and sign the transaction. It may then be broadcast on a kwil network. The TxOptions may be set to override the nonce and fee.
WARNING: This is an advanced method, and most applications should use the other Client methods to interact with a Kwil network.
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) 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 []byte, amount *big.Int, opts ...clientType.TxOpt) (transactions.TxHash, error)
Transfer transfers balance to a given address.
func (*Client) TxQuery ¶
func (c *Client) TxQuery(ctx context.Context, txHash []byte) (*transactions.TcTxQueryResponse, error)
TxQuery get transaction by hash.