Documentation ¶
Index ¶
- Constants
- Variables
- func GetABI() abi.ABI
- func GetAddress() common.Address
- type AccountKeeper
- type BankKeeper
- type BridgeCoinAmountArgs
- type CallerRef
- type CancelSendToExternalArgs
- type Contract
- func (c *Contract) AddLog(evm *vm.EVM, event abi.Event, topics []common.Hash, args ...interface{}) error
- func (c *Contract) Address() common.Address
- func (c *Contract) BridgeCoinAmount(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, _ bool) ([]byte, error)
- func (c *Contract) CancelSendToExternal(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (c *Contract) CrossChain(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (c *Contract) FIP20CrossChain(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (c *Contract) IncreaseBridgeFee(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
- func (c *Contract) IsStateful() bool
- func (c *Contract) RequiredGas(input []byte) uint64
- func (c *Contract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) (ret []byte, err error)
- type ContractCall
- type CrossChainArgs
- type Erc20Keeper
- type EvmKeeper
- type FIP20CrossChainArgs
- type IBCTransferKeeper
- type IncreaseBridgeFeeArgs
Constants ¶
View Source
const ( FIP20CrossChainGas = 40_000 // 80000 - 160000 CrossChainGas = 40_000 // 70000 - 155000 CancelSendToExternalGas = 30_000 // 70000 - 126000 IncreaseBridgeFeeGas = 40_000 // 70000 - 140000 BridgeCoinAmountFeeGas = 10_000 // 9000 FIP20CrossChainMethodName = "fip20CrossChain" CrossChainMethodName = "crossChain" CancelSendToExternalMethodName = "cancelSendToExternal" IncreaseBridgeFeeMethodName = "increaseBridgeFee" BridgeCoinAmountMethodName = "bridgeCoinAmount" CrossChainEventName = "CrossChain" CancelSendToExternalEventName = "CancelSendToExternal" IncreaseBridgeFeeEventName = "IncreaseBridgeFee" )
View Source
const ( // EventTypeRelayTransferCrossChain // Deprecated EventTypeRelayTransferCrossChain = "relay_transfer_cross_chain" // EventTypeCrossChain new cross chain event type EventTypeCrossChain = "cross_chain" AttributeKeyDenom = "coin" AttributeKeyTokenAddress = "token_address" AttributeKeyFrom = "from" AttributeKeyRecipient = "recipient" AttributeKeyTarget = "target" AttributeKeyMemo = "memo" )
Variables ¶
View Source
var ( CancelSendToExternalEvent = abi.NewEvent( CancelSendToExternalEventName, CancelSendToExternalEventName, false, abi.Arguments{ abi.Argument{Name: "sender", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "chain", Type: types.TypeString, Indexed: false}, abi.Argument{Name: "txID", Type: types.TypeUint256, Indexed: false}, }) CrossChainEvent = abi.NewEvent( CrossChainEventName, CrossChainEventName, false, abi.Arguments{ abi.Argument{Name: "sender", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "token", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "denom", Type: types.TypeString, Indexed: false}, abi.Argument{Name: "receipt", Type: types.TypeString, Indexed: false}, abi.Argument{Name: "amount", Type: types.TypeUint256, Indexed: false}, abi.Argument{Name: "fee", Type: types.TypeUint256, Indexed: false}, abi.Argument{Name: "target", Type: types.TypeBytes32, Indexed: false}, abi.Argument{Name: "memo", Type: types.TypeString, Indexed: false}, }) IncreaseBridgeFeeEvent = abi.NewEvent( IncreaseBridgeFeeEventName, IncreaseBridgeFeeEventName, false, abi.Arguments{ abi.Argument{Name: "sender", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "token", Type: types.TypeAddress, Indexed: true}, abi.Argument{Name: "chain", Type: types.TypeString, Indexed: false}, abi.Argument{Name: "txID", Type: types.TypeUint256, Indexed: false}, abi.Argument{Name: "fee", Type: types.TypeUint256, Indexed: false}, }) )
View Source
var ( // CancelSendToExternalMethod cancel send to external tx CancelSendToExternalMethod = abi.NewMethod( CancelSendToExternalMethodName, CancelSendToExternalMethodName, abi.Function, "nonpayable", false, false, abi.Arguments{ abi.Argument{Name: "_chain", Type: types.TypeString}, abi.Argument{Name: "_txID", Type: types.TypeUint256}, }, abi.Arguments{ abi.Argument{Name: "_result", Type: types.TypeBool}, }, ) // FIP20CrossChainMethod cross chain with FIP20 token, only for FIP20 token // Deprecated: use CrossChainMethod instead FIP20CrossChainMethod = abi.NewMethod( FIP20CrossChainMethodName, FIP20CrossChainMethodName, abi.Function, "nonpayable", false, false, abi.Arguments{ abi.Argument{Name: "_sender", Type: types.TypeAddress}, abi.Argument{Name: "_receipt", Type: types.TypeString}, abi.Argument{Name: "_amount", Type: types.TypeUint256}, abi.Argument{Name: "_fee", Type: types.TypeUint256}, abi.Argument{Name: "_target", Type: types.TypeBytes32}, abi.Argument{Name: "_memo", Type: types.TypeString}, }, abi.Arguments{ abi.Argument{Name: "_result", Type: types.TypeBool}, }, ) // CrossChainMethod cross chain with FIP20 token CrossChainMethod = abi.NewMethod( CrossChainMethodName, CrossChainMethodName, abi.Function, "payable", false, false, abi.Arguments{ abi.Argument{Name: "_token", Type: types.TypeAddress}, abi.Argument{Name: "_receipt", Type: types.TypeString}, abi.Argument{Name: "_amount", Type: types.TypeUint256}, abi.Argument{Name: "_fee", Type: types.TypeUint256}, abi.Argument{Name: "_target", Type: types.TypeBytes32}, abi.Argument{Name: "_memo", Type: types.TypeString}, }, abi.Arguments{ abi.Argument{Name: "_result", Type: types.TypeBool}, }, ) // IncreaseBridgeFeeMethod increase bridge fee IncreaseBridgeFeeMethod = abi.NewMethod( IncreaseBridgeFeeMethodName, IncreaseBridgeFeeMethodName, abi.Function, "payable", false, false, abi.Arguments{ abi.Argument{Name: "_chain", Type: types.TypeString}, abi.Argument{Name: "_txID", Type: types.TypeUint256}, abi.Argument{Name: "_token", Type: types.TypeAddress}, abi.Argument{Name: "_fee", Type: types.TypeUint256}, }, abi.Arguments{ abi.Argument{Name: "_result", Type: types.TypeBool}, }, ) )
View Source
var BridgeCoinAmountMethod = abi.NewMethod( BridgeCoinAmountMethodName, BridgeCoinAmountMethodName, abi.Function, "view", false, false, abi.Arguments{ abi.Argument{Name: "_token", Type: types.TypeAddress}, abi.Argument{Name: "_target", Type: types.TypeBytes32}, }, abi.Arguments{ abi.Argument{Name: "_amount", Type: types.TypeUint256}, }, )
BridgeCoinAmountMethod query the amount of bridge coin
Functions ¶
func GetAddress ¶
Types ¶
type AccountKeeper ¶
type AccountKeeper interface {
GetModuleAddress(moduleName string) sdk.AccAddress
}
type BankKeeper ¶
type BankKeeper interface { GetSupply(ctx sdk.Context, denom string) sdk.Coin GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins MintCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error GetDenomMetaData(ctx sdk.Context, denom string) (bank.Metadata, bool) }
type BridgeCoinAmountArgs ¶
type BridgeCoinAmountArgs struct { Token common.Address `abi:"_token"` Target [32]byte `abi:"_target"` }
func (*BridgeCoinAmountArgs) Validate ¶
func (args *BridgeCoinAmountArgs) Validate() error
Validate validates the args
type CancelSendToExternalArgs ¶
func (*CancelSendToExternalArgs) Validate ¶
func (args *CancelSendToExternalArgs) Validate() error
Validate validates the args
type Contract ¶
type Contract struct {
// contains filtered or unexported fields
}
func NewPrecompiledContract ¶
func NewPrecompiledContract( ctx sdk.Context, bankKeeper BankKeeper, evmKeeper EvmKeeper, erc20Keeper Erc20Keeper, ibcTransferKeeper IBCTransferKeeper, accountKeeper AccountKeeper, router *fxtypes.Router, ) *Contract
func (*Contract) BridgeCoinAmount ¶
func (*Contract) CancelSendToExternal ¶
func (*Contract) CrossChain ¶
func (c *Contract) CrossChain(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
CrossChain called at any address(account or contract)
func (*Contract) FIP20CrossChain ¶
func (c *Contract) FIP20CrossChain(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
FIP20CrossChain only for fip20 contract transferCrossChain called
func (*Contract) IncreaseBridgeFee ¶
func (c *Contract) IncreaseBridgeFee(ctx sdk.Context, evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error)
IncreaseBridgeFee add bridge fee to unbatched tx
func (*Contract) IsStateful ¶
func (*Contract) RequiredGas ¶
type ContractCall ¶
type ContractCall struct {
// contains filtered or unexported fields
}
func NewContractCall ¶
func (*ContractCall) ERC20TotalSupply ¶
func (cc *ContractCall) ERC20TotalSupply() (*big.Int, error)
func (*ContractCall) ERC20TransferFrom ¶
type CrossChainArgs ¶
type CrossChainArgs struct { Token common.Address `abi:"_token"` Receipt string `abi:"_receipt"` Amount *big.Int `abi:"_amount"` Fee *big.Int `abi:"_fee"` Target [32]byte `abi:"_target"` Memo string `abi:"_memo"` }
func (*CrossChainArgs) Validate ¶
func (args *CrossChainArgs) Validate() error
Validate validates the args
type Erc20Keeper ¶
type Erc20Keeper interface { ModuleAddress() common.Address GetTokenPairByAddress(ctx sdk.Context, address common.Address) (types.TokenPair, bool) ConvertDenomToTarget(ctx sdk.Context, from sdk.AccAddress, coin sdk.Coin, fxTarget fxtypes.FxTarget) (sdk.Coin, error) ConvertERC20NativeCoin(ctx sdk.Context, pair types.TokenPair, sender common.Address, receiver sdk.AccAddress, amount sdkmath.Int) error GetIbcTimeout(ctx sdk.Context) time.Duration SetIBCTransferRelation(ctx sdk.Context, channel string, sequence uint64) HasOutgoingTransferRelation(ctx sdk.Context, moduleName string, txID uint64) bool ToTargetDenom(ctx sdk.Context, denom, base string, aliases []string, fxTarget fxtypes.FxTarget) string GetTokenPair(ctx sdk.Context, tokenOrDenom string) (types.TokenPair, bool) IsOriginDenom(ctx sdk.Context, denom string) bool HasDenomAlias(ctx sdk.Context, denom string) (bank.Metadata, bool) }
type FIP20CrossChainArgs ¶
type FIP20CrossChainArgs struct { Sender common.Address `abi:"_sender"` Receipt string `abi:"_receipt"` Amount *big.Int `abi:"_amount"` Fee *big.Int `abi:"_fee"` Target [32]byte `abi:"_target"` Memo string `abi:"_memo"` }
func (*FIP20CrossChainArgs) Validate ¶
func (args *FIP20CrossChainArgs) Validate() error
Validate validates the args
type IBCTransferKeeper ¶
type IBCTransferKeeper interface { Transfer(goCtx context.Context, msg *ibctransfertypes.MsgTransfer) (*ibctransfertypes.MsgTransferResponse, error) GetDenomTrace(ctx sdk.Context, denomTraceHash tmbytes.HexBytes) (ibctransfertypes.DenomTrace, bool) }
type IncreaseBridgeFeeArgs ¶
type IncreaseBridgeFeeArgs struct { Chain string `abi:"_chain"` TxID *big.Int `abi:"_txID"` Token common.Address `abi:"_token"` Fee *big.Int `abi:"_fee"` }
func (*IncreaseBridgeFeeArgs) Validate ¶
func (args *IncreaseBridgeFeeArgs) Validate() error
Validate validates the args
Click to show internal directories.
Click to hide internal directories.