Documentation ¶
Index ¶
- Variables
- type Account
- func (a *Account) Address() types.Address
- func (a *Account) Balance() types.Balance
- func (a *Account) Call(to types.Address, data types.Data, gaslimit types.GasLimit, ...) types.Data
- func (a *Account) Deploy(code types.Code, gaslimit types.GasLimit, balance types.Balance) types.Address
- func (a *Account) Deposit(v *types.FLOWTokenVault)
- func (a *Account) Transfer(to types.Address, balance types.Balance)
- func (a *Account) Withdraw(b types.Balance) *types.FLOWTokenVault
- type AddressAllocator
- type BlockStore
- type ContractHandler
- func (h *ContractHandler) AccountByAddress(addr types.Address, isAuthorized bool) types.Account
- func (h *ContractHandler) AllocateAddress() types.Address
- func (h *ContractHandler) FlowTokenAddress() common.Address
- func (h *ContractHandler) LastExecutedBlock() *types.Block
- func (h *ContractHandler) Run(rlpEncodedTx []byte, coinbase types.Address)
Constants ¶
This section is empty.
Variables ¶
var FlexLatestBlockKey = "LatestBlock"
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
func (*Account) Balance ¶
Balance returns the balance of this bridged account
TODO: we might need to meter computation for read only operations as well currently the storage limits is enforced
func (*Account) Call ¶
func (a *Account) Call(to types.Address, data types.Data, gaslimit types.GasLimit, balance types.Balance) types.Data
Call calls a smart contract function with the given data it would limit the gas used according to the limit provided given it doesn't goes beyond what Flow transaction allows. the balance would be deducted from the OFA account and would be transferred to the target address
func (*Account) Deploy ¶
func (a *Account) Deploy(code types.Code, gaslimit types.GasLimit, balance types.Balance) types.Address
Deploy deploys a contract to the EVM environment the new deployed contract would be at the returned address and the contract data is not controlled by the caller accounts
func (*Account) Deposit ¶
func (a *Account) Deposit(v *types.FLOWTokenVault)
Deposit deposits the token from the given vault into the flow evm main vault and update the account balance with the new amount
type AddressAllocator ¶
type AddressAllocator struct {
// contains filtered or unexported fields
}
func NewAddressAllocator ¶
NewAddressAllocator constructs a new statefull address allocator
func (*AddressAllocator) AllocateAddress ¶
func (aa *AddressAllocator) AllocateAddress() (types.Address, error)
AllocateAddress allocates an address
type BlockStore ¶
type BlockStore struct {
// contains filtered or unexported fields
}
func NewBlockStore ¶
NewBlockStore constructs a new block store
func (*BlockStore) BlockHash ¶
func (bs *BlockStore) BlockHash(height int) (gethCommon.Hash, error)
BlockHash returns the block hash for the last x blocks
TODO: implement this properly to keep the last 256 block hashes and connect use it inside the handler to pass as a config to the emulator
func (*BlockStore) BlockProposal ¶
func (bs *BlockStore) BlockProposal() (*types.Block, error)
BlockProposal returns the block proposal to be updated by the handler
func (*BlockStore) CommitBlockProposal ¶
func (bs *BlockStore) CommitBlockProposal() error
CommitBlockProposal commits the block proposal to the chain
func (*BlockStore) LatestBlock ¶
func (bs *BlockStore) LatestBlock() (*types.Block, error)
LatestBlock returns the latest executed block
func (*BlockStore) ResetBlockProposal ¶
func (bs *BlockStore) ResetBlockProposal() error
ResetBlockProposal resets the block proposal
type ContractHandler ¶
type ContractHandler struct {
// contains filtered or unexported fields
}
ContractHandler is responsible for triggering calls to emulator, metering, event emission and updating the block
TODO and Warning: currently database keeps a copy of roothash, and if after commiting the changes by the evm we want to revert in this code we need to reset that or we should always do all the checks and return before calling the emulator, after that should be only event emissions and computation usage updates. thats another reason we first check the computation limit before using. in the future we might benefit from a view style of access to db passed as a param to the emulator.
func NewContractHandler ¶
func NewContractHandler( flowTokenAddress common.Address, blockstore types.BlockStore, addressAllocator types.AddressAllocator, backend types.Backend, emulator types.Emulator, ) *ContractHandler
func (*ContractHandler) AccountByAddress ¶
AccountByAddress returns the account for the given address, if isAuthorized is set, account is controlled by the FVM (bridged accounts)
func (*ContractHandler) AllocateAddress ¶
func (h *ContractHandler) AllocateAddress() types.Address
AllocateAddress allocates an address to be used by the bridged accounts
func (*ContractHandler) FlowTokenAddress ¶
func (h *ContractHandler) FlowTokenAddress() common.Address
func (*ContractHandler) LastExecutedBlock ¶
func (h *ContractHandler) LastExecutedBlock() *types.Block
LastExecutedBlock returns the last executed block