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.

49 lines
1.8 KiB

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