Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- func NewLegacyMsgServerImpl(server v1.MsgServer, k Keeper) v1beta1.MsgServer
- func NewLegacyQueryServer(server v1.QueryServer, cdc codec.Codec) v1beta1.QueryServer
- func NewMsgServerImpl(keeper Keeper) v1.MsgServer
- type Keeper
- func (k Keeper) AddBurnCoin(ctx sdk.Context, coin sdk.Coin)
- func (k Keeper) AddToken(ctx sdk.Context, token v1.Token, saveDenomMetaData bool) error
- func (k Keeper) BalanceOf(ctx sdk.Context, contract, account common.Address) (*big.Int, error)
- func (k Keeper) Balances(c context.Context, req *v1.QueryBalancesRequest) (*v1.QueryBalancesResponse, error)
- func (k Keeper) BurnERC20(ctx sdk.Context, contract, from common.Address, amount *big.Int) error
- func (k Keeper) BurnToken(ctx sdk.Context, coinBurnt sdk.Coin, owner sdk.AccAddress) error
- func (k Keeper) CallEVM(ctx sdk.Context, contractABI abi.ABI, from, to common.Address, commit bool, ...) (*types.Result, error)
- func (k Keeper) CallEVMWithData(ctx sdk.Context, from common.Address, contract *common.Address, data []byte, ...) (*types.Result, error)
- func (k Keeper) Codec() codec.Codec
- func (k Keeper) DeductIssueTokenFee(ctx sdk.Context, owner sdk.AccAddress, symbol string) error
- func (k Keeper) DeductMintTokenFee(ctx sdk.Context, owner sdk.AccAddress, symbol string) error
- func (k Keeper) DeployERC20(ctx sdk.Context, name string, symbol string, minUnit string, scale uint8) (common.Address, error)
- func (k Keeper) ERC20Enabled(ctx sdk.Context) bool
- func (k Keeper) EditToken(ctx sdk.Context, symbol string, name string, maxSupply uint64, ...) error
- func (k Keeper) Fees(c context.Context, req *v1.QueryFeesRequest) (*v1.QueryFeesResponse, error)
- func (k Keeper) GetAllBurnCoin(ctx sdk.Context) []sdk.Coin
- func (k Keeper) GetBurnCoin(ctx sdk.Context, minUint string) (sdk.Coin, error)
- func (k Keeper) GetOwner(ctx sdk.Context, denom string) (sdk.AccAddress, error)
- func (k Keeper) GetParams(ctx sdk.Context) (params v1.Params)
- func (k Keeper) GetToken(ctx sdk.Context, denom string) (v1.TokenI, error)
- func (k Keeper) GetTokenIssueFee(ctx sdk.Context, symbol string) (sdk.Coin, error)
- func (k Keeper) GetTokenMintFee(ctx sdk.Context, symbol string) (sdk.Coin, error)
- func (k Keeper) GetTokens(ctx sdk.Context, owner sdk.AccAddress) (tokens []v1.TokenI)
- func (k Keeper) HasContract(ctx sdk.Context, contract string) bool
- func (k Keeper) HasMinUint(ctx sdk.Context, minUint string) bool
- func (k Keeper) HasSymbol(ctx sdk.Context, symbol string) bool
- func (k Keeper) HasToken(ctx sdk.Context, denom string) bool
- func (k Keeper) Hooks() types.Hook
- func (k Keeper) IssueToken(ctx sdk.Context, symbol string, name string, minUnit string, scale uint32, ...) error
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) MintERC20(ctx sdk.Context, contract, to common.Address, amount *big.Int) error
- func (k Keeper) MintToken(ctx sdk.Context, coinMinted sdk.Coin, recipient sdk.AccAddress, ...) error
- func (k Keeper) Params(c context.Context, req *v1.QueryParamsRequest) (*v1.QueryParamsResponse, error)
- func (k Keeper) SetParams(ctx sdk.Context, params v1.Params) error
- func (k Keeper) SwapFeeToken(ctx sdk.Context, feePaid sdk.Coin, sender sdk.AccAddress, ...) (sdk.Coin, sdk.Coin, error)
- func (k Keeper) SwapFromERC20(ctx sdk.Context, sender common.Address, receiver sdk.AccAddress, ...) error
- func (k Keeper) SwapToERC20(ctx sdk.Context, sender sdk.AccAddress, receiver common.Address, ...) error
- func (k Keeper) Token(c context.Context, req *v1.QueryTokenRequest) (*v1.QueryTokenResponse, error)
- func (k Keeper) Tokens(c context.Context, req *v1.QueryTokensRequest) (*v1.QueryTokensResponse, error)
- func (k Keeper) TotalBurn(c context.Context, req *v1.QueryTotalBurnRequest) (*v1.QueryTotalBurnResponse, error)
- func (k Keeper) TransferTokenOwner(ctx sdk.Context, symbol string, srcOwner sdk.AccAddress, ...) error
- func (k Keeper) UnsafeTransferTokenOwner(ctx sdk.Context, symbol string, to sdk.AccAddress) error
- func (k Keeper) UpgradeERC20(ctx sdk.Context, implementation common.Address) error
- func (k Keeper) WithSwapRegistry(registry v1.SwapRegistry) Keeper
- type Migrator
- type ValidateTokenFeeDecorator
Constants ¶
const ( FeeFactorBase = 3 FeeFactorExp = 4 )
fee factor formula: (ln(len({name}))/ln{base})^{exp}
Variables ¶
This section is empty.
Functions ¶
func NewLegacyMsgServerImpl ¶ added in v1.7.3
NewLegacyMsgServerImpl returns an implementation of the token MsgServer interface for the provided Keeper.
func NewLegacyQueryServer ¶ added in v1.7.3
func NewLegacyQueryServer(server v1.QueryServer, cdc codec.Codec) v1beta1.QueryServer
NewLegacyQueryServer returns an implementation of the token QueryServer interface for the provided Keeper.
func NewMsgServerImpl ¶ added in v1.2.0
NewMsgServerImpl returns an implementation of the token MsgServer interface for the provided Keeper.
Types ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper of the token store
func NewKeeper ¶
func NewKeeper( cdc codec.Codec, key storetypes.StoreKey, bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper, evmKeeper types.EVMKeeper, ics20Keeper types.ICS20Keeper, feeCollectorName string, authority string, ) Keeper
NewKeeper creates a new instance of Keeper.
Parameters:
cdc: codec to marshal/unmarshal binary encoding/decoding. key: store key for the module's store. bankKeeper: bank Keeper module for interacting with accounts. accountKeeper: Account Keeper for interacting with accounts. evmKeeper: EVM Keeper module for interacting with Ethereum Virtual Machine transactions. ics20Keeper: ICS20 Keeper module for interacting with ICS20 transactions. feeCollectorName: name of the fee collector. authority: authority string.
Return type: Keeper.
func (Keeper) AddBurnCoin ¶ added in v1.2.0
AddBurnCoin saves the total amount of the burned tokens
func (Keeper) BalanceOf ¶ added in v1.9.0
BalanceOf retrieves the balance of a specific account in the contract.
Parameters:
- ctx: the sdk.Context for the function
- contract: the address of the contract
- account: the address of the account to retrieve the balance for
Returns:
- *big.Int: the balance of the specified account
func (Keeper) Balances ¶ added in v1.9.0
func (k Keeper) Balances(c context.Context, req *v1.QueryBalancesRequest) (*v1.QueryBalancesResponse, error)
Balances retrieves the balances of a given address for a specific token.
Parameters: - c: the context.Context object. - req: the v1.QueryBalancesRequest object containing the address and token denomination.
Returns: - *v1.QueryBalancesResponse: the response containing the balances of the address for the specified token. - error: an error if the request is empty, the address is invalid, or the token is not found.
func (Keeper) BurnERC20 ¶ added in v1.9.0
BurnERC20 burns a specific amount of ERC20 tokens from a given contract and address.
Parameters:
- ctx: the context in which the transaction is executed
- contract: the contract address of the ERC20 token
- from: the address from which the tokens are burned
- amount: the amount of tokens to burn
Returns an error.
func (Keeper) CallEVM ¶ added in v1.9.0
func (k Keeper) CallEVM( ctx sdk.Context, contractABI abi.ABI, from, to common.Address, commit bool, method string, args ...interface{}, ) (*types.Result, error)
CallEVM calls the EVM with the provided contract ABI, sender and receiver addresses, method, and arguments.
Parameters:
- ctx: the context in which the EVM call is executed
- contractABI: the ABI of the contract
- from: the sender address
- to: the receiver address
- commit: boolean indicating whether the EVM call should be committed
- method: the name of the method to be called
- args: the arguments to be passed to the method
Returns:
- *types.Result: the result of the EVM call
- error: an error if the EVM call encounters any issues
func (Keeper) CallEVMWithData ¶ added in v1.9.0
func (k Keeper) CallEVMWithData( ctx sdk.Context, from common.Address, contract *common.Address, data []byte, commit bool, ) (*types.Result, error)
CallEVMWithData executes an Ethereum Virtual Machine (EVM) call with the provided data.
Parameters:
- ctx: the context in which the EVM call is executed
- from: the address initiating the EVM call
- contract: the address of the smart contract
- data: the data to be sent with the EVM call
- commit: boolean indicating whether the EVM call should be committed
Returns:
- *types.Result: the result of the EVM call
- error: an error if the EVM call encounters any issues
func (Keeper) DeductIssueTokenFee ¶
DeductIssueTokenFee performs fee handling for issuing token
func (Keeper) DeductMintTokenFee ¶
DeductMintTokenFee performs fee handling for minting token
func (Keeper) DeployERC20 ¶ added in v1.9.0
func (k Keeper) DeployERC20( ctx sdk.Context, name string, symbol string, minUnit string, scale uint8, ) (common.Address, error)
DeployERC20 deploys an ERC20 token contract.
Parameters:
- ctx: the context
- name: the name of the token
- symbol: the symbol of the token
- minUnit: the symbol of the minUnit
- scale: the scale of the token
Returns:
- Address: the contract address.
- error: error if any.
func (Keeper) ERC20Enabled ¶ added in v1.9.0
ERC20Enabled returns true if ERC20 is enabled
func (Keeper) EditToken ¶
func (k Keeper) EditToken( ctx sdk.Context, symbol string, name string, maxSupply uint64, mintable types.Bool, owner sdk.AccAddress, ) error
EditToken edits the specified token
func (Keeper) Fees ¶
func (k Keeper) Fees(c context.Context, req *v1.QueryFeesRequest) (*v1.QueryFeesResponse, error)
Fees retrieves the issue fee and mint fee for a specific token symbol.
Parameters: - c: Context object - req: QueryFeesRequest object containing the token symbol
Returns: - QueryFeesResponse object containing issue fee, mint fee, and token existence status - Error if any
func (Keeper) GetAllBurnCoin ¶ added in v1.2.0
GetAllBurnCoin returns the total amount of all the burned tokens
func (Keeper) GetBurnCoin ¶ added in v1.2.0
GetBurnCoin returns the total amount of the burned tokens
func (Keeper) GetTokenIssueFee ¶
GetTokenIssueFee returns the token issuance fee
func (Keeper) GetTokenMintFee ¶
GetTokenMintFee returns the token minting fee
func (Keeper) HasContract ¶ added in v1.9.0
HasContract asserts a token exists by contract
func (Keeper) HasMinUint ¶ added in v1.9.0
HasMinUint asserts a token exists by minUint
func (Keeper) IssueToken ¶
func (k Keeper) IssueToken( ctx sdk.Context, symbol string, name string, minUnit string, scale uint32, initialSupply uint64, maxSupply uint64, mintable bool, owner sdk.AccAddress, ) error
IssueToken issues a new token
func (Keeper) MintERC20 ¶ added in v1.9.0
MintERC20 mints ERC20 tokens to an account.
Parameters:
- ctx: the sdk.Context for the function
- contract: the address of the contract
- to: the address of the receiver
- amount: the amount to mint
Returns:
- err : error if any
func (Keeper) MintToken ¶
func (k Keeper) MintToken( ctx sdk.Context, coinMinted sdk.Coin, recipient sdk.AccAddress, owner sdk.AccAddress, ) error
MintToken mints the specified amount of token to the specified recipient NOTE: empty owner means that the external caller is responsible to manage the token authority
func (Keeper) Params ¶
func (k Keeper) Params(c context.Context, req *v1.QueryParamsRequest) (*v1.QueryParamsResponse, error)
Params returns all the parameters in the token module.
Parameters: - c: Context object - req: QueryParamsRequest object
Returns: - QueryParamsResponse object containing token params - Error if any
func (Keeper) SwapFeeToken ¶ added in v1.7.3
func (k Keeper) SwapFeeToken( ctx sdk.Context, feePaid sdk.Coin, sender sdk.AccAddress, recipient sdk.AccAddress, ) (sdk.Coin, sdk.Coin, error)
SwapFeeToken swap the fee token
func (Keeper) SwapFromERC20 ¶ added in v1.9.0
func (k Keeper) SwapFromERC20( ctx sdk.Context, sender common.Address, receiver sdk.AccAddress, wantedAmount sdk.Coin, ) error
SwapFromERC20 executes a swap from an ERC20 token to its native counterpart
Parameters:
ctx - the context in which the swap is executed sender - the address of the sender receiver - the address of the receiver wantedAmount - the amount of the token to be swapped out
Return type: error
func (Keeper) SwapToERC20 ¶ added in v1.9.0
func (k Keeper) SwapToERC20( ctx sdk.Context, sender sdk.AccAddress, receiver common.Address, amount sdk.Coin, ) error
SwapToERC20 executes a swap from a native token to its ERC20 token counterpart
Parameters:
- ctx: the context
- sender: the sender of the amount
- receiver: the receiver of the erc20 token
- amount: the amount to be swapped
Returns:
- error: error if any.
func (Keeper) Token ¶
func (k Keeper) Token(c context.Context, req *v1.QueryTokenRequest) (*v1.QueryTokenResponse, error)
Token queries a token by denomination.
Parameters: - c: Context object - req: QueryTokenRequest object
Returns: - QueryTokenResponse object containing token - Error if any
func (Keeper) Tokens ¶
func (k Keeper) Tokens(c context.Context, req *v1.QueryTokensRequest) (*v1.QueryTokensResponse, error)
Tokens queries a list of tokens based on the given request parameters.
Parameters: - c: Context object - req: QueryTokensRequest object
Returns: - QueryTokensResponse object containing all tokens own by the owner - Error if any
func (Keeper) TotalBurn ¶ added in v1.2.0
func (k Keeper) TotalBurn(c context.Context, req *v1.QueryTotalBurnRequest) (*v1.QueryTotalBurnResponse, error)
TotalBurn return the all burn coin
Parameters: - c: Context object - req: QueryFeesRequest object
Returns: - QueryTotalBurnResponse object containing token params - Error if any
func (Keeper) TransferTokenOwner ¶
func (k Keeper) TransferTokenOwner( ctx sdk.Context, symbol string, srcOwner sdk.AccAddress, dstOwner sdk.AccAddress, ) error
TransferTokenOwner transfers the owner of the specified token to a new one
func (Keeper) UnsafeTransferTokenOwner ¶ added in v1.7.3
UnsafeTransferTokenOwner transfer the token owner without authorization NOTE: this method should be used with caution
func (Keeper) UpgradeERC20 ¶ added in v1.9.0
UpgradeERC20 upgrades the ERC20 contract to a new implementation.
Parameters: - ctx: the SDK context. - implementation: the address of the new implementation contract.
Returns: - error: an error if the upgrade fails.
func (Keeper) WithSwapRegistry ¶ added in v1.7.3
func (k Keeper) WithSwapRegistry(registry v1.SwapRegistry) Keeper
WithSwapRegistry sets the swap registry in the Keeper and returns the updated Keeper instance.
registry: The swap registry to set. Returns the updated Keeper instance.
type Migrator ¶ added in v1.8.0
type Migrator struct {
// contains filtered or unexported fields
}
Migrator is a struct for handling in-place store migrations.
func NewMigrator ¶ added in v1.8.0
NewMigrator returns a new Migrator.
type ValidateTokenFeeDecorator ¶
type ValidateTokenFeeDecorator struct {
// contains filtered or unexported fields
}
func NewValidateTokenFeeDecorator ¶
func NewValidateTokenFeeDecorator(k Keeper, bk types.BankKeeper) ValidateTokenFeeDecorator
func (ValidateTokenFeeDecorator) AnteHandle ¶
func (dtf ValidateTokenFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error)
AnteHandle returns an AnteHandler that checks if the balance of the fee payer is sufficient for token related fee