You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.6 KiB

  1. package common
  2. import (
  3. "math/big"
  4. ethCommon "github.com/ethereum/go-ethereum/common"
  5. "github.com/iden3/go-iden3-crypto/babyjub"
  6. )
  7. // L1Tx is a struct that represents a L1 tx
  8. type L1Tx struct {
  9. // Stored in DB: mandatory fileds
  10. TxID TxID `meddler:"tx_id"`
  11. ToForgeL1TxsNum uint32 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged
  12. Position int `meddler:"position"`
  13. UserOrigin bool `meddler:"user_origin"` // true if the tx was originated by a user, false if it was aoriginated by a coordinator. Note that this differ from the spec for implementation simplification purpposes
  14. FromIdx Idx `meddler:"from_idx"` // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.LoadAmount (deposit)
  15. FromEthAddr ethCommon.Address `meddler:"from_eth_addr"`
  16. FromBJJ *babyjub.PublicKey `meddler:"from_bjj"`
  17. ToIdx Idx `meddler:"to_idx"` // ToIdx is ignored in L1Tx/Deposit, but used in the L1Tx/DepositAndTransfer
  18. TokenID TokenID `meddler:"token_id"`
  19. Amount *big.Int `meddler:"amount,bigint"`
  20. LoadAmount *big.Int `meddler:"load_amount,bigint"`
  21. EthBlockNum uint64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue
  22. Type TxType `meddler:"tx_type"`
  23. }
  24. // Tx returns a *Tx from the L1Tx
  25. func (tx *L1Tx) Tx() *Tx {
  26. return &Tx{
  27. TxID: tx.TxID,
  28. FromIdx: tx.FromIdx,
  29. ToIdx: tx.ToIdx,
  30. Amount: tx.Amount,
  31. Type: tx.Type,
  32. }
  33. }