github.com/ChainSafe/chainbridge-core@v1.4.2/chains/evm/calls/transactor/transact.go (about)

     1  package transactor
     2  
     3  import (
     4  	"math/big"
     5  
     6  	"github.com/imdario/mergo"
     7  
     8  	"github.com/ethereum/go-ethereum/common"
     9  )
    10  
    11  var DefaultTransactionOptions = TransactOptions{
    12  	GasLimit: 2000000,
    13  	GasPrice: big.NewInt(0),
    14  	Value:    big.NewInt(0),
    15  }
    16  
    17  type TransactOptions struct {
    18  	GasLimit uint64
    19  	GasPrice *big.Int
    20  	Value    *big.Int
    21  	Nonce    *big.Int
    22  	ChainID  *big.Int
    23  	Priority uint8
    24  }
    25  
    26  // to save on data, we encode uin8 for transaction priority
    27  var TxPriorities = map[string]uint8{
    28  	"none":   0,
    29  	"slow":   1,
    30  	"medium": 2,
    31  	"fast":   3,
    32  }
    33  
    34  func MergeTransactionOptions(primary *TransactOptions, additional *TransactOptions) error {
    35  	if err := mergo.Merge(primary, additional); err != nil {
    36  		return err
    37  	}
    38  
    39  	return nil
    40  }
    41  
    42  type Transactor interface {
    43  	Transact(to *common.Address, data []byte, opts TransactOptions) (*common.Hash, error)
    44  }