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.

48 lines
2.0 KiB

  1. package common
  2. import (
  3. "math/big"
  4. )
  5. // TxID is the identifier of a Hermez network transaction
  6. type TxID Hash // Hash is a guess
  7. // TxType is a string that represents the type of a Hermez network transaction
  8. type TxType string
  9. const (
  10. // TxTypeExit represents L2->L1 token transfer. A leaf for this account appears in the exit tree of the block
  11. TxTypeExit TxType = "Exit"
  12. // TxTypeWithdrawn represents the balance that was moved from L2->L1 has been widthrawn from the smart contract
  13. TxTypeWithdrawn TxType = "Withdrawn"
  14. // TxTypeTransfer represents L2->L2 token transfer
  15. TxTypeTransfer TxType = "Transfer"
  16. // TxTypeDeposit represents L1->L2 transfer
  17. TxTypeDeposit TxType = "Deposit"
  18. // TxTypeCreateAccountDeposit represents creation of a new leaf in the state tree (newAcconut) + L1->L2 transfer
  19. TxTypeCreateAccountDeposit TxType = "CreateAccountDeposit"
  20. // TxTypeCreateAccountDepositTransfer represents L1->L2 transfer + L2->L2 transfer
  21. TxTypeCreateAccountDepositTransfer TxType = "CreateAccountDepositTransfer"
  22. // TxTypeDepositTransfer TBD
  23. TxTypeDepositTransfer TxType = "TxTypeDepositTransfer"
  24. // TxTypeForceTransfer TBD
  25. TxTypeForceTransfer TxType = "TxTypeForceTransfer"
  26. // TxTypeForceExit TBD
  27. TxTypeForceExit TxType = "TxTypeForceExit"
  28. // TxTypeTransferToEthAddr TBD
  29. TxTypeTransferToEthAddr TxType = "TxTypeTransferToEthAddr"
  30. // TxTypeTransferToBJJ TBD
  31. TxTypeTransferToBJJ TxType = "TxTypeTransferToBJJ"
  32. )
  33. // Tx is a struct used by the TxSelector & BatchBuilder as a generic type generated from L1Tx & PoolL2Tx
  34. type Tx struct {
  35. TxID TxID
  36. FromIdx Idx // FromIdx is used by L1Tx/Deposit to indicate the Idx receiver of the L1Tx.LoadAmount (deposit)
  37. ToIdx Idx // ToIdx is ignored in L1Tx/Deposit, but used in the L1Tx/DepositTransfer
  38. Amount *big.Int
  39. Nonce Nonce // effective 40 bits used
  40. Fee FeeSelector
  41. Type TxType // optional, descrives which kind of tx it's
  42. BatchNum BatchNum // batchNum in which this tx was forged. Presence indicates "forged" state.
  43. }