Documentation ¶
Index ¶
- Variables
- func BytesToUInt64(bz []byte) uint64
- func UInt64ToBytes(number uint64) []byte
- type Hooks
- type Keeper
- func (k Keeper) CSRByContract(c context.Context, request *types.QueryCSRByContractRequest) (*types.QueryCSRByContractResponse, error)
- func (k Keeper) CSRByNFT(c context.Context, request *types.QueryCSRByNFTRequest) (*types.QueryCSRByNFTResponse, error)
- func (k Keeper) CSRs(c context.Context, request *types.QueryCSRsRequest) (*types.QueryCSRsResponse, error)
- func (k Keeper) CallEVM(ctx sdk.Context, from common.Address, to *common.Address, amount *big.Int, ...) (*evmtypes.MsgEthereumTxResponse, error)
- func (k Keeper) CallMethod(ctx sdk.Context, method string, contract evmtypes.CompiledContract, ...) (*evmtypes.MsgEthereumTxResponse, error)
- func (k Keeper) DeployContract(ctx sdk.Context, contract evmtypes.CompiledContract, args ...interface{}) (common.Address, error)
- func (k Keeper) DeployTurnstile(ctx sdk.Context) (common.Address, error)
- func (k Keeper) GetCSR(ctx sdk.Context, nftId uint64) (*types.CSR, bool)
- func (k Keeper) GetDefaultParams() types.Params
- func (k Keeper) GetNFTByContract(ctx sdk.Context, address string) (uint64, bool)
- func (k Keeper) GetParams(ctx sdk.Context) (params types.Params)
- func (k Keeper) GetTurnstile(ctx sdk.Context) (common.Address, bool)
- func (k Keeper) Hooks() Hooks
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
- func (k Keeper) RegisterEvent(ctx sdk.Context, data []byte) error
- func (k Keeper) SetCSR(ctx sdk.Context, csr types.CSR)
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetTurnstile(ctx sdk.Context, turnstile common.Address)
- func (k Keeper) Turnstile(c context.Context, _ *types.QueryTurnstileRequest) (*types.QueryTurnstileResponse, error)
- func (k Keeper) UpdateEvent(ctx sdk.Context, data []byte) error
- func (k Keeper) ValidateContract(ctx sdk.Context, contract common.Address) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrPrevRegisteredSmartContract = sdkerrors.Register(types.ModuleName, 2000, "You cannot register a smart contract that was previously registered") ErrFeeDistribution = sdkerrors.Register(types.ModuleName, 2001, "There was an error sending fees from the fee collector to NFT") ErrContractDeployments = sdkerrors.Register(types.ModuleName, 2004, "There was an error deploying a contract from the CSR module") ErrMethodCall = sdkerrors.Register(types.ModuleName, 2005, "There was an error calling a method on a smart contract from the module account") ErrRegisterInvalidContract = sdkerrors.Register(types.ModuleName, 2007, "Register/update must have a valid smart contract address entered") ErrNonexistentAcct = sdkerrors.Register(types.ModuleName, 2008, "The recipient of a register event must be an EOA that exists") ErrNonexistentCSR = sdkerrors.Register(types.ModuleName, 2009, "The CSR that was queried does not currently exist") ErrNFTNotFound = sdkerrors.Register(types.ModuleName, 2010, "The NFT that was queried does not currently exist") ErrDuplicateNFTID = sdkerrors.Register(types.ModuleName, 2011, "There cannot be duplicate NFT IDs passed into a register event") )
x/csr module sentinel errors
var DefaultGasLimit uint64 = 30000000
Default gas limit for eth txs from the module account
var (
TurnstileContract abi.ABI = contracts.TurnstileContract.ABI
)
Functions ¶
Types ¶
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks wrapper struct for fees keeper
func (Hooks) PostTxProcessing ¶
The PostTxProcessing hook implements EvmHooks.PostTxProcessing. The EVM hook allows users to utilize the Turnstile smart contract to register and assign smart contracts to a CSR NFT + distribute transaction fees for contracts that are already registered to some NFT. After each successful EVM transaction, the PostTxProcessing hook will check if any of the events emitted in the tx originate from the Turnstile address. If some event does exist, the event handler will process and update state accordingly. At the very end of the hook, the hook will check if the To address in the tx belongs to any NFT currently in state. If so, the fees will be split and distributed to the Turnstile Address / NFT.
type Keeper ¶
type Keeper struct { FeeCollectorName string // contains filtered or unexported fields }
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, storeKey sdk.StoreKey, ps paramtypes.Subspace, accountKeeper types.AccountKeeper, evmKeeper types.EVMKeeper, bankKeeper types.BankKeeper, FeeCollectorName string, ) Keeper
func (Keeper) CSRByContract ¶
func (k Keeper) CSRByContract(c context.Context, request *types.QueryCSRByContractRequest) (*types.QueryCSRByContractResponse, error)
CSRByContract returns the CSR associated with a given smart contracted address passed into the request. This will return nil if the smart contract address does not match up to any CSR
func (Keeper) CSRByNFT ¶
func (k Keeper) CSRByNFT(c context.Context, request *types.QueryCSRByNFTRequest) (*types.QueryCSRByNFTResponse, error)
CSRByNFT returns the CSR associated with a given NFT ID passed into the request. This will return nil if the NFT does not match up to any CSR
func (Keeper) CSRs ¶
func (k Keeper) CSRs(c context.Context, request *types.QueryCSRsRequest) (*types.QueryCSRsResponse, error)
CSRs returns all of the CSRs in the CSR module with optional pagination
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) DeployContract ¶
func (k Keeper) DeployContract( ctx sdk.Context, 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 module account.
func (Keeper) DeployTurnstile ¶
DeployTurnstile will deploy the Turnstile smart contract from the csr module account. This will allow the CSR module to interact with the CSR NFTs in a permissionless way.
func (Keeper) GetCSR ¶
Returns a CSR object given an NFT ID. If the ID is invalid, i.e. it does not exist, then GetCSR will return (nil, false). Otherwise (csr, true).
func (Keeper) GetDefaultParams ¶
func (Keeper) GetNFTByContract ¶
Returns the NFT ID associated with a smart contract address. If the smart contract address entered does belong to some NFT, then it will return (id, true), otherwise (0, false).
func (Keeper) GetTurnstile ¶
Retrieves the deployed Turnstile Address from state if found.
func (Keeper) Params ¶
func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error)
Params returns the CSR module parameters
func (Keeper) RegisterEvent ¶
Register events occur in the Turnstile Contract when a user is attempting to create a new NFT with a smart contract that was just deployed. This event handler will unpack the event data, validate that the smart contract address, check that the receiver address is not null, and validate that this NFT is new. Only register can create new NFTs. Returns an error if the register event fails.
func (Keeper) SetCSR ¶
Set CSR will place a new or updated CSR into the store with the key being the NFT ID and the value being the marshalled CSR object (bytes). Additionally, every single smart contract address entered will get mapped to its NFT ID for easy reads and writes later.
func (Keeper) SetTurnstile ¶
Sets the deployed Turnstile Address to state.
func (Keeper) Turnstile ¶
func (k Keeper) Turnstile(c context.Context, _ *types.QueryTurnstileRequest) (*types.QueryTurnstileResponse, error)
Turnstile returns the turnstile address that was deployed by the module account. This function does not take in any request params.
func (Keeper) UpdateEvent ¶
Update events occur in the Turnstile contract when a user is attempting to assign their newly deployed smart contract to an existing NFT. This event handler will unpack the data, validate that the smart contract to be assigned is valid, check that NFT id exists, and append the smart contract to the NFT id entered. Update is permissionless in the sense that you do not have to be the owner of the NFT to be able to add new smart contracts to it.
func (Keeper) ValidateContract ¶
ValidateContract checks if the smart contract can be registered to a CSR. It checks if the address is a smart contract address, whether the smart contract has code, and whether the contract is already assigned to some other NFT.