keeper

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const BasisPointDivisor uint64 = 10000

BasisPointDivisor used in calculating the MsgMicrotx fee amount to deduct

Variables

View Source
var AccountId *big.Int = big.NewInt(1)

The ID for the Account token, the only token controlled by a LiquidInfrastructureNFT Note when using this value as an argument, the EVM requires it to be a *big.Int, the non-pointer type will cause execution failure

View Source
var CurrentNFTVersion *big.Int = big.NewInt(1)
View Source
var DefaultGasLimit uint64 = 30000000

Default gas limit for eth txs from the module account

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants collects any defined invariants below

func EVMToSDKAddress

func EVMToSDKAddress(addr common.Address) sdk.AccAddress

func ExampleInvariant

func ExampleInvariant(k Keeper) sdk.Invariant

ExampleInvariant checks for incorrect things

func ExportGenesis

func ExportGenesis(ctx sdk.Context, k Keeper) microtxtypes.GenesisState

ExportGenesis exports all the state needed to restart the chain from the current state of the chain

func InitGenesis

func InitGenesis(ctx sdk.Context, k Keeper, data microtxtypes.GenesisState)

InitGenesis starts a chain from a genesis state

func IsEthermintAccount

func IsEthermintAccount(account authtypes.AccountI) bool

IsEthermintAccount indicates the given account has a registered Ethermint public key

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the gov MsgServer interface for the provided Keeper.

func SDKToEVMAddress

func SDKToEVMAddress(addr sdk.AccAddress) common.Address

SDKToEVMAddress converts `addr` to its EVM equivalent

func ToMethodArgs

func ToMethodArgs(args ...interface{}) []interface{}

ToMethodArgs conveniently converts EVM method call args to an array

Types

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper maintains the link to storage and exposes getter/setter methods for the various parts of the state machine

func NewKeeper

func NewKeeper(
	storeKey sdk.StoreKey,
	paramSpace paramtypes.Subspace,
	cdc codec.BinaryCodec,
	bankKeeper *bankkeeper.BaseKeeper,
	accKeeper *authkeeper.AccountKeeper,
	evmKeeper *evmkeeper.Keeper,
	erc20Keeper *erc20keeper.Keeper,
	gasfreeKeeper *gasfreekeeper.Keeper,
) Keeper

NewKeeper returns a new instance of the microtx keeper

func (Keeper) CallEVM

func (k Keeper) CallEVM(
	ctx sdk.Context,
	from common.Address,
	to *common.Address,
	amount *big.Int,
	data []byte,
	commit bool,
) (*evmtypes.MsgEthereumTxResponse, error)

CallEVM performs a EVM transaction given the from address, the to address, amount to be sent, data and whether to commit the tx in the EVM keeper.

func (Keeper) CallMethod

func (k Keeper) CallMethod(
	ctx sdk.Context,
	method string,
	contract evmtypes.CompiledContract,
	from common.Address,
	contractAddr *common.Address,
	amount *big.Int,
	args ...interface{},
) (*evmtypes.MsgEthereumTxResponse, error)

CallMethod is a function to interact with a contract once it is deployed. It inputs the method name on the smart contract, the compiled smart contract, the address from which the tx will be made, the contract address, the amount to be supplied in msg.value, and finally an arbitrary number of arguments that should be supplied to the function method.

func (Keeper) CollectLiquidAccounts

func (k Keeper) CollectLiquidAccounts(ctx sdk.Context) ([]*types.LiquidInfrastructureAccount, error)

GetLiquidAccountByNFTAddress fetches info about a Liquid Infrastructure Account given the address of the LiquidInfrastructureNFT in the EVM

func (Keeper) DeductMicrotxFee

func (k Keeper) DeductMicrotxFee(ctx sdk.Context, sender sdk.AccAddress, sendAmount sdk.Coin) (feeCollected *sdk.Coin, err error)

DeductMicrotxFee will check and deduct the MsgMicrotx fee for the given sendAmount, based on the MicrotxFeeBasisPoints param value

func (Keeper) DeductMsgMicrotxFee added in v1.1.0

func (k Keeper) DeductMsgMicrotxFee(ctx sdk.Context, msg *types.MsgMicrotx) (feeCollected *sdk.Coin, err error)

DeductMsgMicrotxFee is expected to be called from the AnteHandler to deduct the fee for the Msg It is possible for MsgMicrotx to not be a gasfree message type, since governance controls the list, in that case the fee should be deducted in the Msg handler

WARNING: Do **NOT** call this from the MsgMicrotx handler, as it will result in bad event logs, call DeductMicrotxFee instead

func (Keeper) DeployContract

func (k Keeper) DeployContract(
	ctx sdk.Context,
	deployer sdk.AccAddress,
	contract evmtypes.CompiledContract,
	args ...interface{},
) (common.Address, error)

DeployContract will deploy an arbitrary smart-contract. It takes the compiled contract object as well as an arbitrary number of arguments which will be supplied to the contructor. All contracts deployed are deployed by the deployer account.

func (Keeper) DoLiquify

func (k Keeper) DoLiquify(
	ctx sdk.Context,
	account sdk.AccAddress,
) (common.Address, error)

DoLiquify will deploy a LiquidInfrastructureNFT smart contract for the given account. The token will then be transferred to the given account and live under its control. Transfer to another owner requires interacting with the EVM

func (Keeper) GetLiquidAccount

func (k Keeper) GetLiquidAccount(ctx sdk.Context, accAddress sdk.AccAddress) (*types.LiquidInfrastructureAccount, error)

GetLiquidAccount fetches info about a Liquid Infrastructure Account returns nil, ErrNoLiquidAccount if `accAddress` has not been liquified (no record found)

func (Keeper) GetLiquidAccountByNFTAddress

func (k Keeper) GetLiquidAccountByNFTAddress(ctx sdk.Context, nftAddress common.Address) (*types.LiquidInfrastructureAccount, error)

GetLiquidAccountByNFTAddress fetches info about a LiquidAccount given the address of the LiquidInfrastructureNFT in the EVM returns nil, ErrNoLiquidAccount if `nftAddress` is not a record for any Liquid Infrastructure Account

func (Keeper) GetLiquidAccountEntry

func (k Keeper) GetLiquidAccountEntry(ctx sdk.Context, accAddress sdk.AccAddress) (*common.Address, error)

GetLiquidAccountEntry fetches the LiquidInfrastructureNFT contract address for the given `accAddress` returns nil, ErrNoLiquidAccount if `accAddress` has not been liquified (no record found)

func (Keeper) GetLiquidAccountsByCosmosOwner

func (k Keeper) GetLiquidAccountsByCosmosOwner(ctx sdk.Context, ownerAddress sdk.AccAddress) ([]*types.LiquidInfrastructureAccount, error)

GetLiquidAccountsByCosmosOwner fetches info about a Liquid Infrastructure Account given the bech32 address of the LiquidInfrastructureNFT holder returns nil, ErrNoLiquidAccount if `ownerAddress` has no LiquidInfrastructureNFTs (no record found)

func (Keeper) GetLiquidAccountsByEVMOwner

func (k Keeper) GetLiquidAccountsByEVMOwner(ctx sdk.Context, ownerAddress common.Address) ([]*types.LiquidInfrastructureAccount, error)

GetLiquidAccountsByEVMOwner fetches info about a Liquid Infrastructure Account given the EVM address of the LiquidInfrastructureNFT holder returns nil, ErrNoLiquidAccount if `ownerAddress` has no LiquidInfrastructureNFTs (no record found)

func (Keeper) GetMicrotxFeeBasisPoints

func (k Keeper) GetMicrotxFeeBasisPoints(ctx sdk.Context) (uint64, error)

GetMicrotxFeeBasisPoints will get the MicrotxFeeBasisPoints, if the params have been set

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)

GetParams will return the current Params Note that if this function is called before the chain has been initalized, a panic will occur. Use GetParamsIfSet instead e.g. in an AnteHandler which may run for creating genesis transactions

func (Keeper) GetParamsIfSet

func (k Keeper) GetParamsIfSet(ctx sdk.Context) (params types.Params, err error)

GetParamsIfSet will return the current params, but will return an error if the chain is still initializing. By error checking this function is safe to use in handling genesis transactions.

func (Keeper) IsLiquidAccount

func (k Keeper) IsLiquidAccount(ctx sdk.Context, account sdk.AccAddress) bool

IsLiquidAccount checks if the input account is a Liquid Infrastructure Account

func (Keeper) IsLiquidAccountWithValue

func (k Keeper) IsLiquidAccountWithValue(ctx sdk.Context, account sdk.AccAddress) (bool, *common.Address)

IsLiquidAccountWithValue checks if the input account is a Liquid Infrastructure Account and returns the account's nft contract

func (Keeper) IterateLiquidAccounts

func (k Keeper) IterateLiquidAccounts(ctx sdk.Context, cb func(key []byte, accAddress sdk.AccAddress, owner common.Address, nftAddress common.Address) (stop bool))

IterateLiquidAccounts calls the provided callback `cb` on every discovered Liquid Infrastructure Account entry. Return stop=true to end iteration early.

func (Keeper) LiquidAccount

LiquidAccount implements types.QueryServer.

func (Keeper) LiquidAccounts

LiquidAccounts fetches all of the known liquid infrastructure accounts TODO: Implement pagination

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

func (Keeper) Microtx

func (k Keeper) Microtx(ctx sdk.Context, sender sdk.AccAddress, receiver sdk.AccAddress, amount sdk.Coin) error

Microtx implements the transfer of funds from sender to receiver Due to the function of Liquid Infrastructure Accounts, any Microtx must transfer only EVM compatible bank coins

func (Keeper) MicrotxFee

MicrotxFee computes the amount which will be charged in fees for a given Microtx amount

func (Keeper) Params

Params queries the params of the microtx module

func (Keeper) QueryEVM

func (k Keeper) QueryEVM(
	ctx sdk.Context,
	method string,
	contract evmtypes.CompiledContract,
	querier common.Address,
	contractAddr *common.Address,
	args ...interface{},
) (*evmtypes.MsgEthereumTxResponse, error)

func (Keeper) RedirectBalanceToToken

func (k Keeper) RedirectBalanceToToken(
	ctx sdk.Context,
	account sdk.AccAddress,
	nft common.Address,
	currBalance sdk.Coin,
	thresholdAmount big.Int,
) (*sdk.Coin, error)

RedirectBalanceToToken will funnel all excess amounts of `currBalance` (based on `thresholdAmount`) to `nft` it creates a MsgConvertCoin and uses the erc20Keeper to execute it

func (Keeper) RedirectLiquidAccountExcessBalance

func (k Keeper) RedirectLiquidAccountExcessBalance(ctx sdk.Context, account sdk.AccAddress, changedErc20 common.Address) error

RedirectLiquidAccountExcessBalance will check if this account is a Liquid Infrastructure Account, then may funnel any excess balance to the registered LiquidInfrastructureNFT depending on the set thresholds If no threshold is set for `changedErc20`, its balance WILL NOT be sent to the NFT

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error

SetParams will store the given params after validating them

func (Keeper) ValidateAndGetERC20Address added in v1.1.0

func (k Keeper) ValidateAndGetERC20Address(ctx sdk.Context, amount sdk.Coin) (common.Address, error)

func (Keeper) ValidateMembers

func (k Keeper) ValidateMembers()

Check for nil members

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL