Documentation
¶
Index ¶
- Constants
- Variables
- func BuildDomainSeparator(chainID *big.Int, name string, version string, ...) ([]byte, error)
- type AllowanceMethod
- func (am *AllowanceMethod) MethodName() string
- func (am *AllowanceMethod) MethodType() precompile.MethodType
- func (am *AllowanceMethod) Payable() bool
- func (am *AllowanceMethod) RequiredGas(_ []byte) (uint64, bool)
- func (am *AllowanceMethod) Run(context *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type ApprovalEvent
- type ApproveMethod
- func (am *ApproveMethod) MethodName() string
- func (am *ApproveMethod) MethodType() precompile.MethodType
- func (am *ApproveMethod) Payable() bool
- func (am *ApproveMethod) RequiredGas(_ []byte) (uint64, bool)
- func (am *ApproveMethod) Run(context *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type BalanceOfMethod
- func (bom *BalanceOfMethod) MethodName() string
- func (bom *BalanceOfMethod) MethodType() precompile.MethodType
- func (bom *BalanceOfMethod) Payable() bool
- func (bom *BalanceOfMethod) RequiredGas(_ []byte) (uint64, bool)
- func (bom *BalanceOfMethod) Run(context *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type DecimalsMethod
- func (dm *DecimalsMethod) MethodName() string
- func (dm *DecimalsMethod) MethodType() precompile.MethodType
- func (dm *DecimalsMethod) Payable() bool
- func (dm *DecimalsMethod) RequiredGas(_ []byte) (uint64, bool)
- func (dm *DecimalsMethod) Run(_ *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type DomainSeparatorMethod
- func (dsm *DomainSeparatorMethod) MethodName() string
- func (dsm *DomainSeparatorMethod) MethodType() precompile.MethodType
- func (dsm *DomainSeparatorMethod) Payable() bool
- func (dsm *DomainSeparatorMethod) RequiredGas(_ []byte) (uint64, bool)
- func (dsm *DomainSeparatorMethod) Run(_ *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type NameMethod
- func (nm *NameMethod) MethodName() string
- func (nm *NameMethod) MethodType() precompile.MethodType
- func (nm *NameMethod) Payable() bool
- func (nm *NameMethod) RequiredGas(_ []byte) (uint64, bool)
- func (nm *NameMethod) Run(_ *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type NonceMethod
- func (nm *NonceMethod) MethodName() string
- func (nm *NonceMethod) MethodType() precompile.MethodType
- func (nm *NonceMethod) Payable() bool
- func (nm *NonceMethod) RequiredGas(_ []byte) (uint64, bool)
- func (nm *NonceMethod) Run(context *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type PermitMethod
- func (am *PermitMethod) MethodName() string
- func (am *PermitMethod) MethodType() precompile.MethodType
- func (am *PermitMethod) Payable() bool
- func (am *PermitMethod) RequiredGas(_ []byte) (uint64, bool)
- func (am *PermitMethod) Run(context *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type PermitTypehashMethod
- func (ptm *PermitTypehashMethod) MethodName() string
- func (ptm *PermitTypehashMethod) MethodType() precompile.MethodType
- func (ptm *PermitTypehashMethod) Payable() bool
- func (ptm *PermitTypehashMethod) RequiredGas(_ []byte) (uint64, bool)
- func (ptm *PermitTypehashMethod) Run(_ *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type SymbolMethod
- func (sm *SymbolMethod) MethodName() string
- func (sm *SymbolMethod) MethodType() precompile.MethodType
- func (sm *SymbolMethod) Payable() bool
- func (sm *SymbolMethod) RequiredGas(_ []byte) (uint64, bool)
- func (sm *SymbolMethod) Run(_ *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type TotalSupplyMethod
- func (tsm *TotalSupplyMethod) MethodName() string
- func (tsm *TotalSupplyMethod) MethodType() precompile.MethodType
- func (tsm *TotalSupplyMethod) Payable() bool
- func (tsm *TotalSupplyMethod) RequiredGas(_ []byte) (uint64, bool)
- func (tsm *TotalSupplyMethod) Run(context *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type TransferEvent
- type TransferFromMethod
- func (tfm *TransferFromMethod) MethodName() string
- func (tfm *TransferFromMethod) MethodType() precompile.MethodType
- func (tfm *TransferFromMethod) Payable() bool
- func (tfm *TransferFromMethod) RequiredGas(_ []byte) (uint64, bool)
- func (tfm *TransferFromMethod) Run(context *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
- type TransferMethod
- func (tm *TransferMethod) MethodName() string
- func (tm *TransferMethod) MethodType() precompile.MethodType
- func (tm *TransferMethod) Payable() bool
- func (tm *TransferMethod) RequiredGas(_ []byte) (uint64, bool)
- func (tm *TransferMethod) Run(context *precompile.RunContext, inputs precompile.MethodInputs) (precompile.MethodOutputs, error)
Constants ¶
const ( ApproveMethodName = "approve" ApprovalExpiration = time.Hour * 24 * 365 * time.Duration(100) // 100 years )
ApproveMethodName is the name of the approve method that should match the name in the contract ABI.
const ( NameMethodName = "name" SymbolMethodName = "symbol" DecimalsMethodName = "decimals" )
const ( PermitMethodName = "permit" NonceMethodName = "nonce" DomainSeparatorMethodName = "DOMAIN_SEPARATOR" PermitTypehashMethodName = "PERMIT_TYPEHASH" PermitTypehash = "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" )
const ( TransferMethodName = "transfer" TransferFromMethodName = "transferFrom" )
const (
AllowanceMethodName = "allowance"
)
AllowanceMethodName is the name of the Allowance method that should match the name in the contract ABI.
const ApprovalEventName = "Approval"
ApprovalEventName is the name of the Approval event. It matches the name of the event in the contract ABI.
const BalanceOfMethodName = "balanceOf"
BalanceOfMethodName is the name of the balanceOf method. It matches the name of the method in the contract ABI.
const TotalSupplyMethodName = "totalSupply"
TotalSupplyMethodName is the name of the totalSupply method. It matches the name of the method in the contract ABI.
const TransferEventName = "Transfer"
TransferEventName is the name of the Transfer event. It matches the name of the event in the contract ABI.
Variables ¶
var SendMsgURL = sdk.MsgTypeURL(&banktypes.MsgSend{})
SendMsgURL defines the authorization type for MsgSend
Functions ¶
func BuildDomainSeparator ¶
func BuildDomainSeparator( chainID *big.Int, name string, version string, verifyingContract common.Address, ) ([]byte, error)
This functions implements the EIP712 domain separator for the permit function and produces the same result as the Solidity code seen e.g. in the OpenZeppelin lib https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol#L89 that is used by tBTC token https://github.com/keep-network/tbtc-v2/blob/main/solidity/contracts/token/TBTC.sol#L8
Types ¶
type AllowanceMethod ¶
type AllowanceMethod struct {
// contains filtered or unexported fields
}
AllowanceMethod is a precompile method that allows users to check how much a spender is allowed to spend on behalf of an owner.
func NewAllowanceMethod ¶
func NewAllowanceMethod( authzkeeper authzkeeper.Keeper, denom string, ) *AllowanceMethod
func (*AllowanceMethod) MethodName ¶
func (am *AllowanceMethod) MethodName() string
func (*AllowanceMethod) MethodType ¶
func (am *AllowanceMethod) MethodType() precompile.MethodType
func (*AllowanceMethod) Payable ¶
func (am *AllowanceMethod) Payable() bool
func (*AllowanceMethod) RequiredGas ¶
func (am *AllowanceMethod) RequiredGas(_ []byte) (uint64, bool)
func (*AllowanceMethod) Run ¶
func (am *AllowanceMethod) Run( context *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
Run returns the allowance of the spender for the owner.
type ApprovalEvent ¶
type ApprovalEvent struct {
// contains filtered or unexported fields
}
ApprovalEvent is the implementation of the Approval event that contains the following arguments: - owner (indexed): the address of ERC20 owner, - to (indexed): the address of spender, - amount (non-indexed): the amount of tokens approved.
func NewApprovalEvent ¶
func NewApprovalEvent(from, to common.Address, amount *big.Int) *ApprovalEvent
func (*ApprovalEvent) Arguments ¶
func (ae *ApprovalEvent) Arguments() []*precompile.EventArgument
func (*ApprovalEvent) EventName ¶
func (ae *ApprovalEvent) EventName() string
type ApproveMethod ¶
type ApproveMethod struct {
// contains filtered or unexported fields
}
Sets a `value` amount of tokens as the allowance of `spender` over the caller's tokens.
func NewApproveMethod ¶
func NewApproveMethod( bankKeeper bankkeeper.Keeper, authzkeeper authzkeeper.Keeper, denom string, ) *ApproveMethod
func (*ApproveMethod) MethodName ¶
func (am *ApproveMethod) MethodName() string
func (*ApproveMethod) MethodType ¶
func (am *ApproveMethod) MethodType() precompile.MethodType
func (*ApproveMethod) Payable ¶
func (am *ApproveMethod) Payable() bool
func (*ApproveMethod) RequiredGas ¶
func (am *ApproveMethod) RequiredGas(_ []byte) (uint64, bool)
func (*ApproveMethod) Run ¶
func (am *ApproveMethod) Run( context *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
Approve sets the given amount as the allowance of the spender address over the ERC20 token. It returns a boolean value when the operation succeeded.
The Approve method handles the following cases: 1. no authorization, amount 0 -> return error 2. no authorization, amount positive -> create a new authorization 3. authorization exists, amount 0 -> delete authorization 4. authorization exists, amount positive -> update authorization
type BalanceOfMethod ¶
type BalanceOfMethod struct {
// contains filtered or unexported fields
}
BalanceOfMethod is the implementation of the balanceOf method that returns the balance of the ERC20 token for the given account.
The method has the following input arguments: - account: the EVM address of the account for which the balance is returned.
The method returns the ERC20 balance of the account (in the token's precision) if everything goes well. Otherwise, it returns nil and an error.
func NewBalanceOfMethod ¶
func NewBalanceOfMethod( bankKeeper bankkeeper.Keeper, denom string, ) *BalanceOfMethod
func (*BalanceOfMethod) MethodName ¶
func (bom *BalanceOfMethod) MethodName() string
func (*BalanceOfMethod) MethodType ¶
func (bom *BalanceOfMethod) MethodType() precompile.MethodType
func (*BalanceOfMethod) Payable ¶
func (bom *BalanceOfMethod) Payable() bool
func (*BalanceOfMethod) RequiredGas ¶
func (bom *BalanceOfMethod) RequiredGas(_ []byte) (uint64, bool)
func (*BalanceOfMethod) Run ¶
func (bom *BalanceOfMethod) Run( context *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
type DecimalsMethod ¶
type DecimalsMethod struct {
// contains filtered or unexported fields
}
func NewDecimalsMethod ¶
func NewDecimalsMethod(decimals uint8) *DecimalsMethod
Decimals method returns the number of decimals used to represent the token.
func (*DecimalsMethod) MethodName ¶
func (dm *DecimalsMethod) MethodName() string
func (*DecimalsMethod) MethodType ¶
func (dm *DecimalsMethod) MethodType() precompile.MethodType
func (*DecimalsMethod) Payable ¶
func (dm *DecimalsMethod) Payable() bool
func (*DecimalsMethod) RequiredGas ¶
func (dm *DecimalsMethod) RequiredGas(_ []byte) (uint64, bool)
func (*DecimalsMethod) Run ¶
func (dm *DecimalsMethod) Run( _ *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
type DomainSeparatorMethod ¶
type DomainSeparatorMethod struct {
// contains filtered or unexported fields
}
func NewDomainSeparatorMethod ¶
func NewDomainSeparatorMethod( domainSeparator []byte, ) *DomainSeparatorMethod
func (*DomainSeparatorMethod) MethodName ¶
func (dsm *DomainSeparatorMethod) MethodName() string
func (*DomainSeparatorMethod) MethodType ¶
func (dsm *DomainSeparatorMethod) MethodType() precompile.MethodType
func (*DomainSeparatorMethod) Payable ¶
func (dsm *DomainSeparatorMethod) Payable() bool
func (*DomainSeparatorMethod) RequiredGas ¶
func (dsm *DomainSeparatorMethod) RequiredGas(_ []byte) (uint64, bool)
func (*DomainSeparatorMethod) Run ¶
func (dsm *DomainSeparatorMethod) Run( _ *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
Returns the domain separator.
type NameMethod ¶
type NameMethod struct {
// contains filtered or unexported fields
}
func NewNameMethod ¶
func NewNameMethod(name string) *NameMethod
Name method returns the name of the token.
func (*NameMethod) MethodName ¶
func (nm *NameMethod) MethodName() string
func (*NameMethod) MethodType ¶
func (nm *NameMethod) MethodType() precompile.MethodType
func (*NameMethod) Payable ¶
func (nm *NameMethod) Payable() bool
func (*NameMethod) RequiredGas ¶
func (nm *NameMethod) RequiredGas(_ []byte) (uint64, bool)
func (*NameMethod) Run ¶
func (nm *NameMethod) Run( _ *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
type NonceMethod ¶
type NonceMethod struct {
// contains filtered or unexported fields
}
func NewNonceMethod ¶
func NewNonceMethod( evmkeeper evmkeeper.Keeper, nonceKey []byte, ) *NonceMethod
func (*NonceMethod) MethodName ¶
func (nm *NonceMethod) MethodName() string
func (*NonceMethod) MethodType ¶
func (nm *NonceMethod) MethodType() precompile.MethodType
func (*NonceMethod) Payable ¶
func (nm *NonceMethod) Payable() bool
func (*NonceMethod) RequiredGas ¶
func (nm *NonceMethod) RequiredGas(_ []byte) (uint64, bool)
func (*NonceMethod) Run ¶
func (nm *NonceMethod) Run( context *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
Returns the nonce of the given account.
type PermitMethod ¶
type PermitMethod struct {
// contains filtered or unexported fields
}
PermitMethod is a precompile method that allows users to approve a spender to spend their tokens with a signature.
func NewPermitMethod ¶
func NewPermitMethod( bankKeeper bankkeeper.Keeper, authzkeeper authzkeeper.Keeper, evmkeeper evmkeeper.Keeper, denom string, domainSeparator []byte, nonceKey []byte, ) *PermitMethod
func (*PermitMethod) MethodName ¶
func (am *PermitMethod) MethodName() string
func (*PermitMethod) MethodType ¶
func (am *PermitMethod) MethodType() precompile.MethodType
func (*PermitMethod) Payable ¶
func (am *PermitMethod) Payable() bool
func (*PermitMethod) RequiredGas ¶
func (am *PermitMethod) RequiredGas(_ []byte) (uint64, bool)
func (*PermitMethod) Run ¶
func (am *PermitMethod) Run( context *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their tokens with a signature conforming EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, paying gas fees, and possibly performing other actions in the same transaction.
type PermitTypehashMethod ¶
type PermitTypehashMethod struct{}
func NewPermitTypehashMethod ¶
func NewPermitTypehashMethod() *PermitTypehashMethod
func (*PermitTypehashMethod) MethodName ¶
func (ptm *PermitTypehashMethod) MethodName() string
func (*PermitTypehashMethod) MethodType ¶
func (ptm *PermitTypehashMethod) MethodType() precompile.MethodType
func (*PermitTypehashMethod) Payable ¶
func (ptm *PermitTypehashMethod) Payable() bool
func (*PermitTypehashMethod) RequiredGas ¶
func (ptm *PermitTypehashMethod) RequiredGas(_ []byte) (uint64, bool)
func (*PermitTypehashMethod) Run ¶
func (ptm *PermitTypehashMethod) Run( _ *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
Returns the permit typehash.
type SymbolMethod ¶
type SymbolMethod struct {
// contains filtered or unexported fields
}
func NewSymbolMethod ¶
func NewSymbolMethod(symbol string) *SymbolMethod
Symbol method returns the symbol of the token.
func (*SymbolMethod) MethodName ¶
func (sm *SymbolMethod) MethodName() string
func (*SymbolMethod) MethodType ¶
func (sm *SymbolMethod) MethodType() precompile.MethodType
func (*SymbolMethod) Payable ¶
func (sm *SymbolMethod) Payable() bool
func (*SymbolMethod) RequiredGas ¶
func (sm *SymbolMethod) RequiredGas(_ []byte) (uint64, bool)
func (*SymbolMethod) Run ¶
func (sm *SymbolMethod) Run( _ *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
type TotalSupplyMethod ¶
type TotalSupplyMethod struct {
// contains filtered or unexported fields
}
TotalSupplyMethod is the implementation of the totalSupply method that returns the total supply of the ERC20 tokens in existence.
func NewTotalSupplyMethod ¶
func NewTotalSupplyMethod( bankKeeper bankkeeper.Keeper, denom string, ) *TotalSupplyMethod
func (*TotalSupplyMethod) MethodName ¶
func (tsm *TotalSupplyMethod) MethodName() string
func (*TotalSupplyMethod) MethodType ¶
func (tsm *TotalSupplyMethod) MethodType() precompile.MethodType
func (*TotalSupplyMethod) Payable ¶
func (tsm *TotalSupplyMethod) Payable() bool
func (*TotalSupplyMethod) RequiredGas ¶
func (tsm *TotalSupplyMethod) RequiredGas(_ []byte) (uint64, bool)
func (*TotalSupplyMethod) Run ¶
func (tsm *TotalSupplyMethod) Run( context *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
type TransferEvent ¶
type TransferEvent struct {
// contains filtered or unexported fields
}
transferEvent is the implementation of the Transfer event that contains the following arguments: - from (indexed): the address from which the tokens are transferred, - to (indexed): the address to which the tokens are transferred, - value (non-indexed): the amount of tokens transferred.
func NewTransferEvent ¶
func NewTransferEvent(from, to common.Address, value *big.Int) *TransferEvent
func (*TransferEvent) Arguments ¶
func (te *TransferEvent) Arguments() []*precompile.EventArgument
func (*TransferEvent) EventName ¶
func (te *TransferEvent) EventName() string
type TransferFromMethod ¶
type TransferFromMethod struct {
// contains filtered or unexported fields
}
TransferFromMethod is a precompile method that allows users to pull tokens from an account using the allowance mechanism.
func NewTransferFromMethod ¶
func NewTransferFromMethod( bankKeeper bankkeeper.Keeper, authzkeeper authzkeeper.Keeper, evmKeeper evmkeeper.Keeper, denom string, ) *TransferFromMethod
func (*TransferFromMethod) MethodName ¶
func (tfm *TransferFromMethod) MethodName() string
func (*TransferFromMethod) MethodType ¶
func (tfm *TransferFromMethod) MethodType() precompile.MethodType
func (*TransferFromMethod) Payable ¶
func (tfm *TransferFromMethod) Payable() bool
func (*TransferFromMethod) RequiredGas ¶
func (tfm *TransferFromMethod) RequiredGas(_ []byte) (uint64, bool)
func (*TransferFromMethod) Run ¶
func (tfm *TransferFromMethod) Run( context *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)
type TransferMethod ¶
type TransferMethod struct {
// contains filtered or unexported fields
}
TransferMethod is a precompile method that allows users to transfer tokens from their account to another account.
func NewTransferMethod ¶
func NewTransferMethod( bankKeeper bankkeeper.Keeper, authzkeeper authzkeeper.Keeper, evmKeeper evmkeeper.Keeper, denom string, ) *TransferMethod
func (*TransferMethod) MethodName ¶
func (tm *TransferMethod) MethodName() string
func (*TransferMethod) MethodType ¶
func (tm *TransferMethod) MethodType() precompile.MethodType
func (*TransferMethod) Payable ¶
func (tm *TransferMethod) Payable() bool
func (*TransferMethod) RequiredGas ¶
func (tm *TransferMethod) RequiredGas(_ []byte) (uint64, bool)
func (*TransferMethod) Run ¶
func (tm *TransferMethod) Run( context *precompile.RunContext, inputs precompile.MethodInputs, ) (precompile.MethodOutputs, error)