Documentation ¶
Overview ¶
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. This package also defines the Client interface that should be satisfied by different implementations, such as a gateway client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { CallAction(ctx context.Context, dbid string, action string, inputs []any) (*Records, error) ChainID() string ChainInfo(ctx context.Context) (*types.ChainInfo, error) DeployDatabase(ctx context.Context, payload *transactions.Schema, opts ...TxOpt) (transactions.TxHash, error) DropDatabase(ctx context.Context, name string, opts ...TxOpt) (transactions.TxHash, error) DropDatabaseID(ctx context.Context, dbid string, opts ...TxOpt) (transactions.TxHash, error) ExecuteAction(ctx context.Context, dbid string, action string, tuples [][]any, opts ...TxOpt) (transactions.TxHash, error) GetAccount(ctx context.Context, pubKey []byte, status types.AccountStatus) (*types.Account, error) GetSchema(ctx context.Context, dbid string) (*transactions.Schema, error) ListDatabases(ctx context.Context, owner []byte) ([]*types.DatasetIdentifier, error) Ping(ctx context.Context) (string, error) Query(ctx context.Context, dbid string, query string) (*Records, error) TxQuery(ctx context.Context, txHash []byte) (*transactions.TcTxQueryResponse, error) WaitTx(ctx context.Context, txHash []byte, interval time.Duration) (*transactions.TcTxQueryResponse, error) Transfer(ctx context.Context, to []byte, amount *big.Int, opts ...TxOpt) (transactions.TxHash, error) }
Client defines methods are used to talk to a Kwil provider.
type Option ¶
type Option func(*Options)
func SilenceWarnings ¶
func SilenceWarnings() Option
SilenceWarnings silences warnings from the client.
func WithChainID ¶
WithChainID sets the chain ID to use when authoring transactions. The chain ID will be used in all transactions, which helps prevent replay attacks on different chains. On the initial connection, the remote node's chain ID is checked against ours to ensure were are on the right network. If the chain ID is empty, we will create and sign transactions for whatever network the remote node claims, which should only be done for testing or when in secure communication with a trusted node (using TLS or Unix sockets).
func WithLogger ¶
func WithSigner ¶
WithSigner sets a signer to use when authoring transactions.
type Options ¶
type Options struct { // Logger is the logger to use for the client. Logger log.Logger // Signer will be used to sign transactions and set the Sender field on call messages. Signer auth.Signer // The chain ID will be used in all transactions, which helps prevent replay attacks on // different chains. On the initial connection, the remote node's chain ID is // checked against ours to ensure were are on the right network. If the chain ID // is empty, we will create and sign transactions for whatever network the // remote node claims, which should only be done for testing or when in secure // communication with a trusted node (using TLS or Unix sockets). ChainID string // Silence silences warnings logged from the client. Silence bool }
Options are options that can be set for the client
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns the default options for the client.
type Record ¶
Record represents a single row in a set of records.
type Records ¶
type Records struct {
// contains filtered or unexported fields
}
Records providers an iterator over a set of records.
func NewRecords ¶
NewRecords constructs a Records instance for iterating over a Record slice. DEPRECATED: This is intended for internal use. If you have all the records in a slice, you don't need to construct a Records iterator.
func NewRecordsFromMaps ¶
NewRecordsFromMaps creates a Records from a slice of the maps of the same shape as an individual Record.
func (*Records) Export ¶
Export returns all of the records in a slice. The map in each slice is equivalent to a Record, which is keyed by the column name.
func (*Records) ExportString ¶
ExportString is like Export, but the values in each map are converted to strings.
func (*Records) Next ¶
Next steps to the next Record, returning false if there are no more records. Next must be used prior to accessing the first record with the Record method.
type TxOpt ¶
type TxOpt func(*TxOptions)
TxOpt sets an option used when making and broadcasting a transaction.
func WithFee ¶
WithFee sets the Fee to use on the transaction, otherwise an EstimateCode RPC will be performed for the action.
func WithSyncBroadcast ¶
WithSyncBroadcast indicates that broadcast should wait for the transaction to be included in a block, not merely accepted into mempool.