Documentation ¶
Index ¶
- Variables
- type Context
- type Contract
- func (c *Contract) Address() crypto.Address
- func (c *Contract) Call(state engine.State, params engine.CallParams) (output []byte, err error)
- func (c *Contract) ContractMeta() []*acm.ContractMeta
- func (c *Contract) FullName() string
- func (c *Contract) FunctionByID(id abi.FunctionID) (*Function, errors.CodedError)
- func (c *Contract) FunctionByName(name string) *Function
- func (c *Contract) Functions() []*Function
- func (c *Contract) SetExternals(externals engine.Dispatcher)
- type Function
- func (f *Function) Abi() *abi.FunctionSpec
- func (f *Function) Address() crypto.Address
- func (f *Function) Call(state engine.State, params engine.CallParams) ([]byte, error)
- func (f *Function) ContractMeta() []*acm.ContractMeta
- func (f *Function) FullName() string
- func (f *Function) NArgs() int
- func (f *Function) Name() string
- func (f *Function) SetExternals(externals engine.Dispatcher)
- func (f *Function) Signature() string
- func (f *Function) String() string
- type Natives
- func (ns *Natives) Callables() []engine.Callable
- func (ns *Natives) Contract(name, comment string, functions ...Function) (*Natives, error)
- func (ns *Natives) Dispatch(acc *acm.Account) engine.Callable
- func (ns *Natives) Function(comment string, address crypto.Address, permFlag permission.PermFlag, ...) (*Natives, error)
- func (ns *Natives) GetByAddress(address crypto.Address) engine.Native
- func (ns *Natives) GetByName(name string) engine.Native
- func (ns *Natives) GetContract(name string) *Contract
- func (ns *Natives) GetFunction(name string) *Function
- func (ns *Natives) IsRegistered(address crypto.Address) bool
- func (ns *Natives) MustContract(name, comment string, functions ...Function) *Natives
- func (ns *Natives) MustFunction(comment string, address crypto.Address, permFlag permission.PermFlag, ...) *Natives
- func (ns *Natives) SetExternals(externals engine.Dispatcher)
- func (ns *Natives) WithLogger(logger *logging.Logger) *Natives
- type State
- func (s *State) GetAccount(address crypto.Address) (*acm.Account, error)
- func (s *State) GetStorage(address crypto.Address, key binary.Word256) ([]byte, error)
- func (s *State) RemoveAccount(address crypto.Address) error
- func (s *State) SetStorage(address crypto.Address, key binary.Word256, value []byte) error
- func (s *State) UpdateAccount(updatedAccount *acm.Account) error
Constants ¶
This section is empty.
Variables ¶
var Permissions = New().MustContract("Permissions", `* Interface for managing Secure Native authorizations. * @dev This interface describes the functions exposed by the native permissions layer in burrow. `, Function{ Comment: ` * @notice Adds a role to an account * @param _account account address * @param _role role name * @return _result whether role was added `, PermFlag: permission.AddRole, F: addRole, }, Function{ Comment: ` * @notice Removes a role from an account * @param _account account address * @param _role role name * @return _result whether role was removed `, PermFlag: permission.RemoveRole, F: removeRole, }, Function{ Comment: ` * @notice Indicates whether an account has a role * @param _account account address * @param _role role name * @return _result whether account has role `, PermFlag: permission.HasRole, F: hasRole, }, Function{ Comment: ` * @notice Sets the permission flags for an account. Makes them explicitly set (on or off). * @param _account account address * @param _permission the base permissions flags to set for the account * @param _set whether to set or unset the permissions flags at the account level * @return _result is the permission flag that was set as uint64 `, PermFlag: permission.SetBase, F: setBase, }, Function{ Comment: ` * @notice Unsets the permissions flags for an account. Causes permissions being unset to fall through to global permissions. * @param _account account address * @param _permission the permissions flags to unset for the account * @return _result is the permission flag that was unset as uint64 `, PermFlag: permission.UnsetBase, F: unsetBase, }, Function{ Comment: ` * @notice Indicates whether an account has a subset of permissions set * @param _account account address * @param _permission the permissions flags (mask) to check whether enabled against base permissions for the account * @return _result is whether account has the passed permissions flags set `, PermFlag: permission.HasBase, F: hasBase, }, Function{Comment: ` * @notice Sets the global (default) permissions flags for the entire chain * @param _permission the permissions flags to set * @param _set whether to set (or unset) the permissions flags * @return _result is the permission flag that was set as uint64 `, PermFlag: permission.SetGlobal, F: setGlobal, }, )
var Precompiles = New(). MustFunction(`Recover public key/address of account that signed the data`, leftPadAddress(1), permission.None, ecrecover). MustFunction(`Compute the sha256 hash of input`, leftPadAddress(2), permission.None, sha256). MustFunction(`Compute the ripemd160 hash of input`, leftPadAddress(3), permission.None, ripemd160Func). MustFunction(`Return an output identical to the input`, leftPadAddress(4), permission.None, identity). MustFunction(`Compute the operation base**exp % mod where the values are big ints`, leftPadAddress(5), permission.None, expMod). MustFunction(`Compute the keccak256 hash of input`, leftPadAddress(20), permission.None, keccak256Func)
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { State engine.State engine.CallParams Logger *logging.Logger // contains filtered or unexported fields }
Context is the first argument to any native function. This struct carries all the context an native needs to access e.g. state in burrow.
type Contract ¶
type Contract struct { // Comment describing purpose of native contract and reason for assembling // the particular functions Comment string // Name of the native contract Name string // contains filtered or unexported fields }
Contract is metadata for native contract. Acts as a call target from the EVM. Can be used to generate bindings in a smart contract languages.
func NewContract ¶
func NewContract(name string, comment string, logger *logging.Logger, fs ...Function) (*Contract, error)
Create a new native contract description object by passing a comment, name and a list of member functions descriptions
func (*Contract) Address ¶
We define the address of an native contact as the last 20 bytes of the sha3 hash of its name
func (*Contract) Call ¶
Dispatch is designed to be called from the EVM once a native contract has been selected.
func (*Contract) ContractMeta ¶
func (c *Contract) ContractMeta() []*acm.ContractMeta
func (*Contract) FunctionByID ¶
func (c *Contract) FunctionByID(id abi.FunctionID) (*Function, errors.CodedError)
Get function by calling identifier FunctionSelector
func (*Contract) FunctionByName ¶
Get function by name
func (*Contract) SetExternals ¶
func (c *Contract) SetExternals(externals engine.Dispatcher)
type Function ¶
type Function struct { // Comment describing function's purpose, parameters, and return value Comment string // Permissions required to call function PermFlag permission.PermFlag // Whether this function writes to state Pure bool // Native function to which calls will be dispatched when a containing F interface{} // contains filtered or unexported fields }
Function is metadata for native functions. Act as call targets for the EVM when collected into an Contract. Can be used to generate bindings in a smart contract languages.
func NewFunction ¶
func NewFunction(comment string, address crypto.Address, permFlag permission.PermFlag, f interface{}) (*Function, error)
Created a new function mounted directly at address (i.e. no Solidity contract or function selection)
func (*Function) Abi ¶
func (f *Function) Abi() *abi.FunctionSpec
Abi returns the FunctionSpec for this function
func (*Function) ContractMeta ¶
func (f *Function) ContractMeta() []*acm.ContractMeta
func (*Function) SetExternals ¶
func (f *Function) SetExternals(externals engine.Dispatcher)
type Natives ¶
type Natives struct {
// contains filtered or unexported fields
}
func DefaultNatives ¶
func MustDefaultNatives ¶
func MustDefaultNatives() *Natives
func (*Natives) GetByAddress ¶
func (*Natives) GetContract ¶
func (*Natives) GetFunction ¶
func (*Natives) MustContract ¶
func (*Natives) MustFunction ¶
func (*Natives) SetExternals ¶
func (ns *Natives) SetExternals(externals engine.Dispatcher)
type State ¶
type State struct {
// contains filtered or unexported fields
}
This wrapper provides a state that behaves 'as if' the natives were stored directly in state. TODO: we may want to actually store native account sentinel values (and their metadata) in on-disk state down the line
func NewState ¶
func NewState(natives engine.Natives, backend acmstate.ReaderWriter) *State
Get a new state that wraps the backend but intercepts any calls to natives returning appropriate errors message or an Account sentinel for the particular native