Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // PrivInsert allows insert operations to be executed. The abbreviation is "a". PrivInsert = Privilege{ Abbreviation: "a", Bitfield: 0b001, } // PrivUpdate allows updated operations to be executed. The abbreviation is "w". PrivUpdate = Privilege{ Abbreviation: "w", Bitfield: 0b010, } // PrivDelete allows delete operations to be executed. The abbreviation is "d". PrivDelete = Privilege{ Abbreviation: "d", Bitfield: 0b100, } )
Functions ¶
This section is empty.
Types ¶
type ACL ¶
type ACL interface { // CheckPrivileges checks if an address can execute a specific operation on a table. CheckPrivileges(context.Context, *sql.Tx, common.Address, tables.TableID, Operation) (bool, error) }
ACL is the API for access control rules check.
type Column ¶
type Column struct {
Name string `json:"name"`
}
Column defines a column in table data.
type ColumnValue ¶
type ColumnValue struct {
// contains filtered or unexported fields
}
ColumnValue wraps data from the db that may be raw json or any other value.
func JSONColValue ¶
func JSONColValue(v json.RawMessage) *ColumnValue
JSONColValue creates a UserValue with the provided json.
func OtherColValue ¶
func OtherColValue(v interface{}) *ColumnValue
OtherColValue creates a UserValue with the provided other value.
func (*ColumnValue) MarshalJSON ¶
func (cv *ColumnValue) MarshalJSON() ([]byte, error)
MarshalJSON implements MarshalJSON.
func (*ColumnValue) Value ¶
func (cv *ColumnValue) Value() interface{}
Value returns the underlying value.
type EVMBlockInfo ¶
EVMBlockInfo contains information about an EVM block.
type EVMEvent ¶
type EVMEvent struct { Address common.Address Topics []byte Data []byte BlockNumber uint64 TxHash common.Hash TxIndex uint BlockHash common.Hash Index uint // Enhanced fields ChainID ChainID EventJSON []byte EventType string }
EVMEvent is a Tableland on-chain event produced by the Registry SC.
type Operation ¶
type Operation int
Operation represents the kind of operation that can by executed in Tableland.
const ( // OpSelect is represents a SELECT query. OpSelect Operation = iota // OpInsert is represents a INSERT query. OpInsert // OpUpdate is represents a UPDATE query. OpUpdate // OpDelete is represents a DELETE query. OpDelete // OpGrant is represents a GRANT query. OpGrant // OpRevoke is represents a REVOKE query. OpRevoke // OpCreate is represents a CREATE query. OpCreate )
type Policy ¶
type Policy interface { // IsInsertAllowed rejects insert statement execution. IsInsertAllowed() bool // IsUpdateAllowed rejects update statement execution. IsUpdateAllowed() bool // IsDeleteAllowed rejects delete statement execution. IsDeleteAllowed() bool // WhereClause is SQL where clauses that restricts update and delete execution. WhereClause() string // UpdatableColumns imposes restrictions on what columns can be updated. // Empty means all columns are allowed. UpdatableColumns() []string // WithCheck is a SQL where clause that restricts the execution of incoming writes. WithCheck() string }
Policy represents the kinds of restrictions that can be imposed on a statement execution.
type Privilege ¶
Privilege maps to SQL privilege and is the thing needed to execute an operation.
func NewPrivilegeFromSQLString ¶
NewPrivilegeFromSQLString converts a SQL privilege string into a Privilege.
func (Privilege) ToSQLString ¶
ToSQLString returns the SQL string representation of a Privilege.
type Privileges ¶
type Privileges []Privilege
Privileges represents a list of privileges.
func (Privileges) CanExecute ¶
func (p Privileges) CanExecute(operation Operation) (bool, Privilege)
CanExecute checks if the list of privileges can execute a given operation. In case the operation cannot be executed, it returns the privilege that would allow the execution.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a database table.
func NewTableFromName ¶
NewTableFromName creates a Table from its name.
type TableData ¶
type TableData struct { Columns []Column `json:"columns"` Rows [][]*ColumnValue `json:"rows"` }
TableData defines a tabular representation of query results.
type Tableland ¶
type Tableland interface { RunReadQuery(ctx context.Context, stmt string) (*TableData, error) ValidateCreateTable(ctx context.Context, chainID ChainID, stmt string) (string, error) ValidateWriteQuery(ctx context.Context, chainID ChainID, stmt string) (tables.TableID, error) RelayWriteQuery( ctx context.Context, chainID ChainID, caller common.Address, stmt string, ) (tables.Transaction, error) GetReceipt(ctx context.Context, chainID ChainID, txnHash string) (bool, *TxnReceipt, error) SetController( ctx context.Context, chainID ChainID, caller common.Address, controller common.Address, tableID tables.TableID, ) (tables.Transaction, error) }
Tableland defines the interface of Tableland.
type TxnReceipt ¶
type TxnReceipt struct { ChainID ChainID `json:"chain_id"` TxnHash string `json:"txn_hash"` BlockNumber int64 `json:"block_number"` TableID *string `json:"table_id,omitempty"` Error string `json:"error"` ErrorEventIdx int `json:"error_event_idx"` }
TxnReceipt is a Tableland event processing receipt.