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
2.2 KiB

  1. package historydb
  2. import (
  3. "math/big"
  4. "time"
  5. ethCommon "github.com/ethereum/go-ethereum/common"
  6. "github.com/hermeznetwork/hermez-node/common"
  7. "github.com/iden3/go-iden3-crypto/babyjub"
  8. )
  9. // HistoryTx is a representation of a generic Tx with additional information
  10. // required by the API, and extracted by joining block and token tables
  11. type HistoryTx struct {
  12. // Generic
  13. IsL1 bool `meddler:"is_l1"`
  14. TxID common.TxID `meddler:"id"`
  15. Type common.TxType `meddler:"type"`
  16. Position int `meddler:"position"`
  17. FromIdx common.Idx `meddler:"from_idx"`
  18. ToIdx common.Idx `meddler:"to_idx"`
  19. Amount *big.Int `meddler:"amount,bigint"`
  20. AmountFloat float64 `meddler:"amount_f"`
  21. TokenID common.TokenID `meddler:"token_id"`
  22. USD float64 `meddler:"amount_usd,zeroisnull"`
  23. BatchNum common.BatchNum `meddler:"batch_num,zeroisnull"` // batchNum in which this tx was forged. If the tx is L2, this must be != 0
  24. EthBlockNum int64 `meddler:"eth_block_num"` // Ethereum Block Number in which this L1Tx was added to the queue
  25. // L1
  26. ToForgeL1TxsNum int64 `meddler:"to_forge_l1_txs_num"` // toForgeL1TxsNum in which the tx was forged / will be forged
  27. 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
  28. FromEthAddr ethCommon.Address `meddler:"from_eth_addr"`
  29. FromBJJ *babyjub.PublicKey `meddler:"from_bjj"`
  30. LoadAmount *big.Int `meddler:"load_amount,bigintnull"`
  31. LoadAmountFloat float64 `meddler:"load_amount_f"`
  32. LoadAmountUSD float64 `meddler:"load_amount_usd,zeroisnull"`
  33. // L2
  34. Fee common.FeeSelector `meddler:"fee,zeroisnull"`
  35. FeeUSD float64 `meddler:"fee_usd,zeroisnull"`
  36. Nonce common.Nonce `meddler:"nonce,zeroisnull"`
  37. // API extras
  38. Timestamp time.Time `meddler:"timestamp,utctime"`
  39. TokenSymbol string `meddler:"symbol"`
  40. CurrentUSD float64 `meddler:"current_usd"`
  41. USDUpdate time.Time `meddler:"usd_update,utctime"`
  42. TotalItems int `meddler:"total_items"`
  43. }