Skip to content

Commit

Permalink
define contstant for outbound zero amount
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Jun 3, 2024
1 parent 2e89392 commit 007020b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
3 changes: 3 additions & 0 deletions zetaclient/chains/evm/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const (
// OutboundTrackerReportTimeout is the timeout for waiting for an outbound tracker report
OutboundTrackerReportTimeout = 10 * time.Minute

// EthTransferGasLimit is the gas limit for a standard ETH transfer
EthTransferGasLimit = 21000

// TopicsZetaSent is the number of topics for a Zeta sent event
// [signature, zetaTxSenderAddress, destinationChainId]
// https://github.com/zeta-chain/protocol-contracts/blob/d65814debf17648a6c67d757ba03646415842790/contracts/evm/ZetaConnector.base.sol#L34
Expand Down
22 changes: 10 additions & 12 deletions zetaclient/chains/evm/signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ import (
"github.com/zeta-chain/zetacore/zetaclient/zetacore"
)

const (
// EthTransferGasLimit is the gas limit for a standard ETH transfer
EthTransferGasLimit = 21000
var (
zeroValue = int64(0)
_ interfaces.ChainSigner = &Signer{}
)

var _ interfaces.ChainSigner = &Signer{}

// Signer deals with the signing EVM transactions and implements the ChainSigner interface
type Signer struct {
client interfaces.EVMRPCClient
Expand Down Expand Up @@ -213,7 +211,7 @@ func (signer *Signer) SignOutbound(txData *OutboundData) (*ethtypes.Transaction,

tx, _, _, err := signer.Sign(data,
signer.zetaConnectorAddress,
big.NewInt(0),
big.NewInt(zeroValue),
txData.gasLimit,
txData.gasPrice,
txData.nonce,
Expand Down Expand Up @@ -253,7 +251,7 @@ func (signer *Signer) SignRevertTx(txData *OutboundData) (*ethtypes.Transaction,

tx, _, _, err := signer.Sign(data,
signer.zetaConnectorAddress,
big.NewInt(0),
big.NewInt(zeroValue),
txData.gasLimit,
txData.gasPrice,
txData.nonce,
Expand All @@ -270,8 +268,8 @@ func (signer *Signer) SignCancelTx(txData *OutboundData) (*ethtypes.Transaction,
tx, _, _, err := signer.Sign(
nil,
signer.tssSigner.EVMAddress(),
big.NewInt(0), // zero out the amount to cancel the tx
EthTransferGasLimit,
big.NewInt(zeroValue), // zero out the amount to cancel the tx
evm.EthTransferGasLimit,
txData.gasPrice,
txData.nonce,
txData.height,
Expand All @@ -289,7 +287,7 @@ func (signer *Signer) SignWithdrawTx(txData *OutboundData) (*ethtypes.Transactio
nil,
txData.to,
txData.amount,
EthTransferGasLimit,
evm.EthTransferGasLimit,
txData.gasPrice,
txData.nonce,
txData.height,
Expand Down Expand Up @@ -585,7 +583,7 @@ func (signer *Signer) SignERC20WithdrawTx(txData *OutboundData) (*ethtypes.Trans
tx, _, _, err := signer.Sign(
data,
signer.er20CustodyAddress,
big.NewInt(0),
big.NewInt(zeroValue),
txData.gasLimit,
txData.gasPrice,
txData.nonce,
Expand Down Expand Up @@ -649,7 +647,7 @@ func (signer *Signer) SignWhitelistERC20Cmd(txData *OutboundData, params string)
tx, _, _, err := signer.Sign(
data,
txData.to,
big.NewInt(0),
big.NewInt(zeroValue),
txData.gasLimit,
txData.gasPrice,
outboundParams.TssNonce,
Expand Down

0 comments on commit 007020b

Please sign in to comment.