Documentation ¶
Overview ¶
Package signer implements the ChainSigner interface for EVM chains
Package signer implements the ChainSigner interface for EVM chains
Index ¶
- func ErrorMsg(cctx *crosschaintypes.CrossChainTx) string
- func IsSenderZetaChain(cctx *crosschaintypes.CrossChainTx, zetacoreClient interfaces.ZetacoreClient) bool
- type Gas
- type OutboundData
- type Signer
- func (signer *Signer) BroadcastOutbound(ctx context.Context, tx *ethtypes.Transaction, ...)
- func (signer *Signer) EvmClient() interfaces.EVMRPCClient
- func (signer *Signer) EvmSigner() ethtypes.Signer
- func (signer *Signer) GetERC20CustodyAddress() ethcommon.Address
- func (signer *Signer) GetGatewayAddress() string
- func (signer *Signer) GetZetaConnectorAddress() ethcommon.Address
- func (signer *Signer) SetERC20CustodyAddress(addr ethcommon.Address)
- func (signer *Signer) SetGatewayAddress(addr string)
- func (signer *Signer) SetZetaConnectorAddress(addr ethcommon.Address)
- func (signer *Signer) Sign(ctx context.Context, data []byte, to ethcommon.Address, amount *big.Int, ...) (*ethtypes.Transaction, []byte, []byte, error)
- func (signer *Signer) SignAdminTx(ctx context.Context, txData *OutboundData, cmd string, params string) (*ethtypes.Transaction, error)
- func (signer *Signer) SignCancel(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
- func (signer *Signer) SignConnectorOnReceive(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
- func (signer *Signer) SignConnectorOnRevert(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
- func (signer *Signer) SignERC20Withdraw(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
- func (signer *Signer) SignGasWithdraw(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
- func (signer *Signer) SignMigrateTssFundsCmd(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
- func (signer *Signer) SignOutboundFromCCTX(ctx context.Context, logger zerolog.Logger, cctx *crosschaintypes.CrossChainTx, ...) (*ethtypes.Transaction, error)
- func (signer *Signer) SignOutboundFromCCTXV2(ctx context.Context, cctx *types.CrossChainTx, outboundData *OutboundData) (*ethtypes.Transaction, error)
- func (signer *Signer) SignWhitelistERC20Cmd(ctx context.Context, txData *OutboundData, params string) (*ethtypes.Transaction, error)
- func (signer *Signer) TryProcessOutbound(ctx context.Context, cctx *crosschaintypes.CrossChainTx, ...)
- func (signer *Signer) WithEvmClient(client interfaces.EVMRPCClient)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorMsg ¶
func ErrorMsg(cctx *crosschaintypes.CrossChainTx) string
ErrorMsg returns a error message for SignConnectorOnReceive failure with cctx data
func IsSenderZetaChain ¶
func IsSenderZetaChain( cctx *crosschaintypes.CrossChainTx, zetacoreClient interfaces.ZetacoreClient, ) bool
IsSenderZetaChain checks if the sender chain is ZetaChain TODO(revamp): move to another package more general for cctx functions
Types ¶
type Gas ¶
type Gas struct { Limit uint64 // This is a "total" gasPrice per 1 unit of gas. // GasPrice for pre EIP-1559 transactions or maxFeePerGas for EIP-1559. Price *big.Int // PriorityFee a fee paid directly to validators for EIP-1559. PriorityFee *big.Int }
Gas represents gas parameters for EVM transactions.
This is pretty interesting because all EVM chains now support EIP-1559, but some chains do it in a specific way https://eips.ethereum.org/EIPS/eip-1559 https://www.blocknative.com/blog/eip-1559-fees https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP226.md (tl;dr: baseFee is always zero)
However, this doesn't affect tx creation nor broadcasting
type OutboundData ¶
type OutboundData struct {
// contains filtered or unexported fields
}
OutboundData is a data structure containing input fields used to construct each type of transaction. This is populated using cctx and other input parameters passed to TryProcessOutbound
func NewOutboundData ¶
func NewOutboundData( ctx context.Context, cctx *types.CrossChainTx, height uint64, logger zerolog.Logger, ) (*OutboundData, bool, error)
NewOutboundData creates OutboundData from the given CCTX. returns `bool true` when transaction should be skipped.
func (OutboundData) MessageContext ¶
func (o OutboundData) MessageContext() (gatewayevm.MessageContext, error)
type Signer ¶
Signer deals with the signing EVM transactions and implements the ChainSigner interface
func NewSigner ¶
func NewSigner( ctx context.Context, chain chains.Chain, tss interfaces.TSSSigner, ts *metrics.TelemetryServer, logger base.Logger, endpoint string, zetaConnectorAddress ethcommon.Address, erc20CustodyAddress ethcommon.Address, gatewayAddress ethcommon.Address, ) (*Signer, error)
NewSigner creates a new EVM signer
func (*Signer) BroadcastOutbound ¶
func (signer *Signer) BroadcastOutbound( ctx context.Context, tx *ethtypes.Transaction, cctx *crosschaintypes.CrossChainTx, logger zerolog.Logger, myID sdk.AccAddress, zetacoreClient interfaces.ZetacoreClient, txData *OutboundData, )
BroadcastOutbound signed transaction through evm rpc client
func (*Signer) EvmClient ¶
func (signer *Signer) EvmClient() interfaces.EVMRPCClient
EvmClient returns the EVM RPC client
func (*Signer) GetERC20CustodyAddress ¶
GetERC20CustodyAddress returns the erc20 custody address
func (*Signer) GetGatewayAddress ¶
GetGatewayAddress returns the gateway address
func (*Signer) GetZetaConnectorAddress ¶
GetZetaConnectorAddress returns the zeta connector address
func (*Signer) SetERC20CustodyAddress ¶
SetERC20CustodyAddress sets the erc20 custody address
func (*Signer) SetGatewayAddress ¶
SetGatewayAddress sets the gateway address
func (*Signer) SetZetaConnectorAddress ¶
SetZetaConnectorAddress sets the zeta connector address
func (*Signer) Sign ¶
func (signer *Signer) Sign( ctx context.Context, data []byte, to ethcommon.Address, amount *big.Int, gas Gas, nonce uint64, height uint64, ) (*ethtypes.Transaction, []byte, []byte, error)
Sign given data, and metadata (gas, nonce, etc) returns a signed transaction, sig bytes, hash bytes, and error
func (*Signer) SignAdminTx ¶
func (signer *Signer) SignAdminTx( ctx context.Context, txData *OutboundData, cmd string, params string, ) (*ethtypes.Transaction, error)
SignAdminTx signs a admin cmd transaction based on the given command
func (*Signer) SignCancel ¶
func (signer *Signer) SignCancel(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
SignCancel signs a transaction from TSS address to itself with a zero amount in order to increment the nonce
func (*Signer) SignConnectorOnReceive ¶
func (signer *Signer) SignConnectorOnReceive(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
SignConnectorOnReceive function onReceive(
bytes calldata originSenderAddress, uint256 originChainId, address destinationAddress, uint zetaAmount, bytes calldata message, bytes32 internalSendHash
) external virtual {}
func (*Signer) SignConnectorOnRevert ¶
func (signer *Signer) SignConnectorOnRevert(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
SignConnectorOnRevert function onRevert( address originSenderAddress, uint256 originChainId, bytes calldata destinationAddress, uint256 destinationChainId, uint256 zetaAmount, bytes calldata message, bytes32 internalSendHash ) external override whenNotPaused onlyTssAddress
func (*Signer) SignERC20Withdraw ¶
func (signer *Signer) SignERC20Withdraw(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
SignERC20Withdraw function withdraw( address recipient, address asset, uint256 amount, ) external onlyTssAddress
func (*Signer) SignGasWithdraw ¶
func (signer *Signer) SignGasWithdraw(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
SignGasWithdraw signs a withdrawal transaction sent from the TSS address to the destination
func (*Signer) SignMigrateTssFundsCmd ¶
func (signer *Signer) SignMigrateTssFundsCmd(ctx context.Context, txData *OutboundData) (*ethtypes.Transaction, error)
SignMigrateTssFundsCmd signs a migrate TSS funds command
func (*Signer) SignOutboundFromCCTX ¶
func (signer *Signer) SignOutboundFromCCTX( ctx context.Context, logger zerolog.Logger, cctx *crosschaintypes.CrossChainTx, outboundData *OutboundData, zetacoreClient interfaces.ZetacoreClient, toChain zctx.Chain, ) (*ethtypes.Transaction, error)
SignOutboundFromCCTX signs an outbound transaction from a given cctx TODO: simplify logic with all if else https://github.com/zeta-chain/node/issues/2050
func (*Signer) SignOutboundFromCCTXV2 ¶
func (signer *Signer) SignOutboundFromCCTXV2( ctx context.Context, cctx *types.CrossChainTx, outboundData *OutboundData, ) (*ethtypes.Transaction, error)
SignOutboundFromCCTXV2 signs an outbound transaction from a CCTX with protocol contract v2
func (*Signer) SignWhitelistERC20Cmd ¶
func (signer *Signer) SignWhitelistERC20Cmd( ctx context.Context, txData *OutboundData, params string, ) (*ethtypes.Transaction, error)
SignWhitelistERC20Cmd signs a whitelist command for ERC20 token
func (*Signer) TryProcessOutbound ¶
func (signer *Signer) TryProcessOutbound( ctx context.Context, cctx *crosschaintypes.CrossChainTx, outboundProc *outboundprocessor.Processor, outboundID string, _ interfaces.ChainObserver, zetacoreClient interfaces.ZetacoreClient, height uint64, )
TryProcessOutbound - signer interface implementation This function will attempt to build and sign an evm transaction using the TSS signer. It will then broadcast the signed transaction to the outbound chain. TODO(revamp): simplify function
func (*Signer) WithEvmClient ¶
func (signer *Signer) WithEvmClient(client interfaces.EVMRPCClient)
WithEvmClient attaches a new client to the signer