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.

46 lines
1.6 KiB

  1. package common
  2. import (
  3. "math/big"
  4. "time"
  5. eth "github.com/ethereum/go-ethereum/common"
  6. "github.com/iden3/go-iden3-crypto/babyjub"
  7. )
  8. // PoolL2Tx is a struct that represents a L2Tx sent by an account to the coordinator hat is waiting to be forged
  9. type PoolL2Tx struct {
  10. Tx
  11. ToBJJ babyjub.PublicKey
  12. Status PoolL2TxStatus
  13. RqTxCompressedData []byte // 253 bits, optional for atomic txs
  14. RqTx RqTx
  15. Timestamp time.Time // time when added to the tx pool
  16. Signature babyjub.Signature // tx signature
  17. ToEthAddr eth.Address
  18. AbsoluteFee float64 // TODO add methods to calculate this value from Tx.Fee tables + priceupdater tables
  19. }
  20. // RqTx Transaction Data used to indicate that a transaction depends on another transaction
  21. type RqTx struct {
  22. FromEthAddr eth.Address
  23. ToEthAddr eth.Address
  24. TokenID TokenID
  25. Amount *big.Int
  26. FeeSelector FeeSelector
  27. Nonce uint64 // effective 48 bits used
  28. }
  29. // PoolL2TxStatus is a struct that represents the status of a L2 transaction
  30. type PoolL2TxStatus string
  31. const (
  32. // PoolL2TxStatusPending represents a valid L2Tx that hasn't started the forging process
  33. PoolL2TxStatusPending PoolL2TxStatus = "Pending"
  34. // PoolL2TxStatusForging represents a valid L2Tx that has started the forging process
  35. PoolL2TxStatusForging PoolL2TxStatus = "Forging"
  36. // PoolL2TxStatusForged represents a L2Tx that has already been forged
  37. PoolL2TxStatusForged PoolL2TxStatus = "Forged"
  38. // PoolL2TxStatusInvalid represents a L2Tx that has been invalidated
  39. PoolL2TxStatusInvalid PoolL2TxStatus = "Invalid"
  40. )