Documentation
¶
Index ¶
- func NewContext(params map[string]any) types.BlockchainContext
- type Context
- func (c *Context) Balance(addr core.Address) uint64
- func (c *Context) BlockHeight() uint64
- func (c *Context) BlockTime() int64
- func (c *Context) Call(caller core.Address, contract core.Address, function string, args ...any) ([]byte, error)
- func (c *Context) ContractAddress() core.Address
- func (c *Context) CreateObject(contract core.Address) (types.VMObject, error)
- func (c *Context) CreateObjectWithID(contract core.Address, id core.ObjectID) (types.VMObject, error)
- func (c *Context) DeleteObject(contract core.Address, id core.ObjectID) error
- func (c *Context) GetGas() int64
- func (c *Context) GetObject(contract core.Address, id core.ObjectID) (types.VMObject, error)
- func (c *Context) GetObjectWithOwner(contract core.Address, owner core.Address) (types.VMObject, error)
- func (c *Context) Log(contract core.Address, eventName string, keyValues ...any)
- func (c *Context) Sender() core.Address
- func (c *Context) SetBlockInfo(height uint64, time int64, hash core.Hash) error
- func (c *Context) SetGasLimit(limit int64)
- func (c *Context) SetTransactionInfo(hash core.Hash, from types.Address, to types.Address, value uint64) error
- func (c *Context) TransactionHash() core.Hash
- func (c *Context) Transfer(from, to core.Address, amount uint64) error
- func (c *Context) WithBlock(height uint64) error
- func (c *Context) WithTransaction(hash string) error
- type DBBalance
- type DBBlock
- type DBEvent
- type DBObject
- type DBObjectField
- type DBTransaction
- type Object
- func (o *Object) Contract() core.Address
- func (o *Object) Get(contract core.Address, field string) ([]byte, error)
- func (o *Object) ID() core.ObjectID
- func (o *Object) Owner() core.Address
- func (o *Object) Set(contract, sender core.Address, field string, value []byte) error
- func (o *Object) SetOwner(contract, sender, addr core.Address) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
func NewContext(params map[string]any) types.BlockchainContext
NewContext creates a new SQLite-backed blockchain context using GORM
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context implements the BlockchainContext interface using SQLite with GORM
func (*Context) BlockHeight ¶
BlockHeight implements types.BlockchainContext
func (*Context) Call ¶
func (c *Context) Call(caller core.Address, contract core.Address, function string, args ...any) ([]byte, error)
Call implements types.BlockchainContext
func (*Context) ContractAddress ¶
ContractAddress implements types.BlockchainContext
func (*Context) CreateObject ¶
CreateObject implements types.BlockchainContext
func (*Context) CreateObjectWithID ¶
func (c *Context) CreateObjectWithID(contract core.Address, id core.ObjectID) (types.VMObject, error)
CreateObjectWithID implements types.BlockchainContext
func (*Context) DeleteObject ¶
DeleteObject implements types.BlockchainContext
func (*Context) GetObjectWithOwner ¶
func (c *Context) GetObjectWithOwner(contract core.Address, owner core.Address) (types.VMObject, error)
GetObjectWithOwner implements types.BlockchainContext
func (*Context) SetBlockInfo ¶ added in v0.1.2
func (*Context) SetGasLimit ¶
func (*Context) SetTransactionInfo ¶ added in v0.1.2
func (*Context) TransactionHash ¶
TransactionHash implements types.BlockchainContext
func (*Context) WithTransaction ¶
WithTransaction sets the current transaction context
type DBBalance ¶
type DBBalance struct { Address string `gorm:"column:address;primaryKey;size:42"` Amount uint64 `gorm:"column:balance;not null;default:0"` }
DBBalance represents the balance in database
type DBBlock ¶
type DBEvent ¶
type DBEvent struct { gorm.Model BlockHeight uint64 `gorm:"column:block_height;not null;index"` TxHash string `gorm:"column:tx_hash;not null;index;size:66"` Contract string `gorm:"column:contract_address;not null;index;size:42"` EventName string `gorm:"column:event_name;not null;index;size:255"` KeyValues []byte `gorm:"column:key_values;type:blob;not null"` // JSON encoded key-value pairs }
DBEvent represents an event in the database
type DBObject ¶
type DBObject struct { gorm.Model ObjectID string `gorm:"column:object_id;not null;unique;index;size:66"` Owner string `gorm:"column:owner_address;not null;index;size:42"` Contract string `gorm:"column:contract_address;not null;index;size:42"` }
DBObject represents the object in database
type DBObjectField ¶
type DBObjectField struct { gorm.Model ObjectID string `gorm:"column:object_id;not null;index;size:66"` Key string `gorm:"column:field_key;not null;index;size:255"` Value []byte `gorm:"column:field_value;type:blob;not null"` }
DBObjectField represents a field of an object
func (DBObjectField) TableName ¶
func (DBObjectField) TableName() string
TableName specifies the table name for DBObjectField
type DBTransaction ¶
type DBTransaction struct { gorm.Model Hash string `gorm:"column:tx_hash;not null;unique;index;size:66"` BlockHeight uint64 `gorm:"column:block_height;not null;index"` FromAddress string `gorm:"column:from_address;not null;index;size:42"` ToAddress string `gorm:"column:to_address;not null;index;size:42"` Value uint64 `gorm:"column:value;not null"` Data []byte `gorm:"column:tx_data;type:blob;default:''"` }
func (DBTransaction) TableName ¶
func (DBTransaction) TableName() string