keeper

package
v0.0.0-...-8cb8a38 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllInvariants

func AllInvariants(k Keeper) sdk.Invariant

AllInvariants runs all invariants of the bridge module

func BackedCoinsInvariant

func BackedCoinsInvariant(k Keeper) sdk.Invariant

BackedCoinsInvariant iterates all conversion pairs and asserts that the sdk.Coin balances are less than the module ERC20 balance. **Note:** This compares <= and not == as anyone can send tokens to the ERC20 contract address and break the invariant if a strict equal check.

func BridgePairsIndexInvariant

func BridgePairsIndexInvariant(k Keeper) sdk.Invariant

BridgePairsIndexInvariant iterates all bridge pairs and asserts the index for querying are all valid.

func BridgePairsInvariant

func BridgePairsInvariant(k Keeper) sdk.Invariant

BridgePairsInvariant iterates all bridge pairs and asserts that they are valid

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

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

func NewQueryServerImpl

func NewQueryServerImpl(k Keeper) types.QueryServer

NewQueryServerImpl creates a new server for handling gRPC queries.

func RegisterInvariants

func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)

RegisterInvariants registers the bridge module invariants

func WrappingAddInt

func WrappingAddInt(i1 sdk.Int, i2 sdk.Int) sdk.Int

WrappingAddInt adds two sdk.Int values with intentional wrapping.

Types

type ConversionHooks

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

Hooks wrapper struct for bridge keeper

func (ConversionHooks) PostTxProcessing

func (h ConversionHooks) PostTxProcessing(
	ctx sdk.Context,
	msg core.Message,
	receipt *ethtypes.Receipt,
) error

PostTxProcessing implements EvmHooks.PostTxProcessing. This handles minting sdk.Coin when ConvertToCoin() is called on an eligible Fury ERC20 contract.

type Keeper

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

Keeper keeper for the bridge module

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeKey sdk.StoreKey,
	paramstore paramtypes.Subspace,
	bk types.BankKeeper,
	ak types.AccountKeeper,
	ek types.EvmKeeper,
) Keeper

NewKeeper creates a new keeper

func (Keeper) BridgeEthereumToFury

func (k Keeper) BridgeEthereumToFury(
	ctx sdk.Context,
	relayer sdk.AccAddress,
	externalERC20Address types.ExternalEVMAddress,
	receiver types.InternalEVMAddress,
	amount *big.Int,
	sequence sdk.Int,
) error

BridgeEthereumToFury mints the bridged amount at the corresponding bridged ERC20 contract on Fury EVM, deploying the ERC20 contract first if it doesn't already exist.

func (Keeper) BurnConversionPairCoin

func (k Keeper) BurnConversionPairCoin(
	ctx sdk.Context,
	pair types.ConversionPair,
	coin sdk.Coin,
	account sdk.AccAddress,
) error

BurnConversionPairCoin transfers the provided amount to the module account then burns it.

func (Keeper) CallEVM

func (k Keeper) CallEVM(
	ctx sdk.Context,
	abi abi.ABI,
	from common.Address,
	contract types.InternalEVMAddress,
	method string,
	args ...interface{},
) (*evmtypes.MsgEthereumTxResponse, error)

CallEVM performs a smart contract method call using given args

func (Keeper) CallEVMWithData

func (k Keeper) CallEVMWithData(
	ctx sdk.Context,
	from common.Address,
	contract *types.InternalEVMAddress,
	data []byte,
) (*evmtypes.MsgEthereumTxResponse, error)

CallEVMWithData performs a smart contract method call using contract data Derived from tharsis/evmos https://github.com/tharsis/evmos/blob/ee54f496551df937915ff6f74a94732a35abc505/x/erc20/keeper/evm.go

func (Keeper) ConversionHooks

func (k Keeper) ConversionHooks() ConversionHooks

Return the wrapper struct

func (Keeper) ConvertCoinToERC20

func (k Keeper) ConvertCoinToERC20(
	ctx sdk.Context,
	initiatorAccount sdk.AccAddress,
	receiverAccount types.InternalEVMAddress,
	coin sdk.Coin,
) error

ConvertCoinToERC20 converts an sdk.Coin from the originating account to an ERC20 to the receiver account.

func (Keeper) ConvertERC20ToCoin

func (k Keeper) ConvertERC20ToCoin(
	ctx sdk.Context,
	initiator types.InternalEVMAddress,
	receiver sdk.AccAddress,
	contractAddr types.InternalEVMAddress,
	amount sdk.Int,
) error

ConvertERC20ToCoin converts an ERC20 coin from the originating account to an sdk.Coin to the receiver account.

func (Keeper) DeployMintableERC20Contract

func (k Keeper) DeployMintableERC20Contract(
	ctx sdk.Context,
	token types.EnabledERC20Token,
) (types.InternalEVMAddress, error)

DeployMintableERC20Contract deploys an ERC20 contract on the EVM as the module account and returns the address of the contract. This contract has minting permissions for the module account. Derived from tharsis/evmos https://github.com/tharsis/evmos/blob/ee54f496551df937915ff6f74a94732a35abc505/x/erc20/keeper/evm.go

func (Keeper) GetBridgePair

func (k Keeper) GetBridgePair(
	ctx sdk.Context,
	id []byte,
) (types.ERC20BridgePair, bool)

GetBridgePair returns the ERC20 bridge pair with the provided pair ID from the store.

func (Keeper) GetBridgePairFromExternal

func (k Keeper) GetBridgePairFromExternal(
	ctx sdk.Context,
	externalAddress types.ExternalEVMAddress,
) (types.ERC20BridgePair, bool)

GetBridgePairFromExternal gets ERC20 bridge pair with the provided ExternalEVMAddress from the store.

func (Keeper) GetBridgePairFromInternal

func (k Keeper) GetBridgePairFromInternal(
	ctx sdk.Context,
	internalAddress types.InternalEVMAddress,
) (types.ERC20BridgePair, bool)

GetBridgePairFromInternal gets ERC20 bridge pair with the provided InternalEVMAddress from the store.

func (Keeper) GetEnabledConversionPairFromDenom

func (k Keeper) GetEnabledConversionPairFromDenom(
	ctx sdk.Context,
	denom string,
) (types.ConversionPair, error)

GetEnabledConversionPairFromDenom returns an ConversionPair from the sdk.Coin denom.

func (Keeper) GetEnabledConversionPairFromERC20Address

func (k Keeper) GetEnabledConversionPairFromERC20Address(
	ctx sdk.Context,
	address types.InternalEVMAddress,
) (types.ConversionPair, error)

GetEnabledConversionPairFromERC20Address returns an ConversionPair from the internal contract address.

func (Keeper) GetEnabledConversionPairs

func (k Keeper) GetEnabledConversionPairs(ctx sdk.Context) types.ConversionPairs

GetEnabledConversionPairs returns the all ConversionPairs

func (Keeper) GetEnabledERC20TokenFromExternal

func (k Keeper) GetEnabledERC20TokenFromExternal(
	ctx sdk.Context,
	address types.ExternalEVMAddress,
) (types.EnabledERC20Token, error)

GetEnabledERC20TokenFromExternal returns an EnabledERC20Token from the external Ethereum contract address.

func (Keeper) GetEnabledERC20Tokens

func (k Keeper) GetEnabledERC20Tokens(ctx sdk.Context) types.EnabledERC20Tokens

GetEnabledERC20Tokens returns the all EnabledERC20Tokens

func (Keeper) GetNextWithdrawSequence

func (k Keeper) GetNextWithdrawSequence(ctx sdk.Context) (sdk.Int, error)

GetNextWithdrawSequence reads the next available global withdraw sequence from store.

func (Keeper) GetOrDeployInternalERC20

func (k Keeper) GetOrDeployInternalERC20(
	ctx sdk.Context,
	externalAddress types.ExternalEVMAddress,
) (types.InternalEVMAddress, error)

GetOrDeployInternalERC20 returns the internal EVM address mapped to the provided ExternalEVMAddress. This will either return from the store if it is already deployed, or will first deploy the internal ERC20 contract and return the new address.

func (Keeper) GetPairIDFromExternal

func (k Keeper) GetPairIDFromExternal(
	ctx sdk.Context,
	externalAddress types.ExternalEVMAddress,
) ([]byte, bool)

GetPairIDFromExternal gets the erc20 bridge pair id from the given external address.

func (Keeper) GetPairIDFromInternal

func (k Keeper) GetPairIDFromInternal(
	ctx sdk.Context,
	internalAddress types.InternalEVMAddress,
) ([]byte, bool)

GetPairIDFromInternal gets the erc20 bridge pair id from the given internal address.

func (Keeper) GetParams

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

GetParams returns the total set of evm parameters.

func (Keeper) GetRelayer

func (k Keeper) GetRelayer(ctx sdk.Context) sdk.AccAddress

GetRelayer returns the relayer in params

func (Keeper) IncrementNextWithdrawSequence

func (k Keeper) IncrementNextWithdrawSequence(ctx sdk.Context) error

IncrementNextWithdrawSequence increments the next withdraw sequence in the store by 1.

func (Keeper) IsSignerAuthorized

func (k Keeper) IsSignerAuthorized(ctx sdk.Context, signer sdk.AccAddress) error

IsSignerAuthorized returns an error if the provided message signer does not match the relayer set in params.

func (Keeper) IterateBridgePairs

func (k Keeper) IterateBridgePairs(
	ctx sdk.Context,
	cb func(pair types.ERC20BridgePair) (stop bool),
)

IterateBridgePairs provides an iterator over all stored ERC20 bridge pairs. For each pair, cb will be called. If cb returns true, the iterator will close and stop.

func (Keeper) LockERC20Tokens

func (k Keeper) LockERC20Tokens(
	ctx sdk.Context,
	pair types.ConversionPair,
	amount *big.Int,
	initiator types.InternalEVMAddress,
) error

LockERC20Tokens transfers the given amount of a conversion pair ERC20 token from the initiator account to the module account.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MintConversionPairCoin

func (k Keeper) MintConversionPairCoin(
	ctx sdk.Context,
	pair types.ConversionPair,
	amount *big.Int,
	recipient sdk.AccAddress,
) (sdk.Coin, error)

MintConversionPairCoin mints the given amount of a ConversionPair denom and sends it to the provided address.

func (Keeper) MintERC20

func (k Keeper) MintERC20(
	ctx sdk.Context,
	contractAddr types.InternalEVMAddress,
	receiver types.InternalEVMAddress,
	amount *big.Int,
) error

MintERC20 mints the given amount of an ERC20 token to an address. This is unchecked and should only be called after permission and enabled ERC20 checks.

func (Keeper) QueryERC20BalanceOf

func (k Keeper) QueryERC20BalanceOf(
	ctx sdk.Context,
	contractAddr types.InternalEVMAddress,
	account types.InternalEVMAddress,
) (*big.Int, error)

func (Keeper) RegisterBridgePair

func (k Keeper) RegisterBridgePair(
	ctx sdk.Context,
	pair types.ERC20BridgePair,
)

RegisterBridgePair puts the erc20 bridge pair in the store with all of its corresponding external/internal to ID mappings.

func (Keeper) SetNextWithdrawSequence

func (k Keeper) SetNextWithdrawSequence(ctx sdk.Context, sequence sdk.Int)

SetNextWithdrawSequence stores a sequence to be used for the next withdraw.

func (Keeper) SetParams

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

SetParams sets the evm parameters to the param space.

func (Keeper) SetRelayer

func (k Keeper) SetRelayer(ctx sdk.Context, relayer sdk.AccAddress)

SetRelayer sets the relayer in params

func (Keeper) UnlockERC20Tokens

func (k Keeper) UnlockERC20Tokens(
	ctx sdk.Context,
	pair types.ConversionPair,
	amount *big.Int,
	receiver types.InternalEVMAddress,
) error

UnlockERC20Tokens transfers the given amount of a conversion pair ERC20 token to the provided account.

func (Keeper) WithdrawHooks

func (k Keeper) WithdrawHooks() WithdrawHook

Return the wrapper struct

type WithdrawHook

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

Hooks wrapper struct for bridge keeper

func (WithdrawHook) PostTxProcessing

func (h WithdrawHook) PostTxProcessing(
	ctx sdk.Context,
	msg core.Message,
	receipt *ethtypes.Receipt,
) error

PostTxProcessing implements EvmHooks.PostTxProcessing

Jump to

Keyboard shortcuts

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