github.com/amazechain/amc@v0.1.3/internal/avm/types/transaction.go (about)

     1  package types
     2  
     3  //
     4  //// Message is a fully derived transaction and implements core.Message
     5  ////
     6  //// NOTE: In a future PR this will be removed.
     7  //type Message struct {
     8  //	to         *common.Address
     9  //	from       common.Address
    10  //	nonce      uint64
    11  //	amount     *big.Int
    12  //	gasLimit   uint64
    13  //	gasPrice   *big.Int
    14  //	gasFeeCap  *big.Int
    15  //	gasTipCap  *big.Int
    16  //	data       []byte
    17  //	accessList AccessList
    18  //	isFake     bool
    19  //}
    20  //
    21  //func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *big.Int, gasLimit uint64, gasPrice, gasFeeCap, gasTipCap *big.Int, data []byte, accessList AccessList, isFake bool) Message {
    22  //	return Message{
    23  //		from:       from,
    24  //		to:         to,
    25  //		nonce:      nonce,
    26  //		amount:     amount,
    27  //		gasLimit:   gasLimit,
    28  //		gasPrice:   gasPrice,
    29  //		gasFeeCap:  gasFeeCap,
    30  //		gasTipCap:  gasTipCap,
    31  //		data:       data,
    32  //		accessList: accessList,
    33  //		isFake:     isFake,
    34  //	}
    35  //}
    36  //
    37  //// // AsMessage returns the transaction as a core.Message.
    38  //func AsMessage(tx *transaction.Transaction, baseFee *big.Int, isFake bool) Message {
    39  //	f := tx.From()
    40  //
    41  //	from := &common.Address{}
    42  //	if tx.From() != nil {
    43  //		from = FromAmcAddress(f)
    44  //	}
    45  //
    46  //	msg := Message{
    47  //		nonce:     tx.Nonce(),
    48  //		gasLimit:  tx.Gas(),
    49  //		gasPrice:  tx.GasPrice().ToBig(),
    50  //		gasFeeCap: tx.GasFeeCap().ToBig(),
    51  //		gasTipCap: tx.GasTipCap().ToBig(),
    52  //		to:        FromAmcAddress(tx.To()),
    53  //		amount:    tx.Value().ToBig(),
    54  //		data:      tx.Data(),
    55  //		isFake:    isFake,
    56  //		from:      *from,
    57  //	}
    58  //
    59  //	if baseFee != nil {
    60  //		msg.gasPrice = math.BigMin(msg.gasPrice.Add(msg.gasTipCap, baseFee), msg.gasFeeCap)
    61  //	}
    62  //	var accessList AccessList
    63  //	if tx.AccessList() != nil {
    64  //		for _, v := range tx.AccessList() {
    65  //			var at AccessTuple
    66  //			at.Address = *FromAmcAddress(&v.Address)
    67  //			for _, h := range v.StorageKeys {
    68  //				at.StorageKeys = append(at.StorageKeys, FromAmcHash(h))
    69  //			}
    70  //			accessList = append(accessList, at)
    71  //		}
    72  //	} else {
    73  //		accessList = nil
    74  //	}
    75  //
    76  //	msg.accessList = accessList
    77  //
    78  //	//log.Infof("as message : %+V", msg)
    79  //	return msg
    80  //}
    81  //
    82  //func (m Message) From() common.Address   { return m.from }
    83  //func (m Message) To() *common.Address    { return m.to }
    84  //func (m Message) GasPrice() *big.Int     { return m.gasPrice }
    85  //func (m Message) GasFeeCap() *big.Int    { return m.gasFeeCap }
    86  //func (m Message) GasTipCap() *big.Int    { return m.gasTipCap }
    87  //func (m Message) Value() *big.Int        { return m.amount }
    88  //func (m Message) Gas() uint64            { return m.gasLimit }
    89  //func (m Message) Nonce() uint64          { return m.nonce }
    90  //func (m Message) Data() []byte           { return m.data }
    91  //func (m Message) AccessList() AccessList { return m.accessList }
    92  //func (m Message) IsFake() bool           { return m.isFake }