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.

42 lines
1.4 KiB

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