Documentation ¶
Overview ¶
Package apitypes is used to map the common types used across the node with the format expected by the API.
This is done using different strategies: - Marshallers: they get triggered when the API marshals the response structs into JSONs - Scanners/Valuers: they get triggered when a struct is sent/received to/from the SQL database - Adhoc functions: when the already mentioned strategies are not suitable, functions are added to the structs to facilitate the conversions
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BigIntStr ¶
type BigIntStr string
BigIntStr is used to scan/value *big.Int directly into strings from/to sql DBs. It assumes that *big.Int are inserted/fetched to/from the DB using the BigIntMeddler meddler defined at github.com/hermeznetwork/hermez-node/db. Since *big.Int is stored as DECIMAL in SQL, there's no need to implement Scan()/Value() because DECIMALS are encoded/decoded as strings by the sql driver, and BigIntStr is already a string.
func NewBigIntStr ¶
NewBigIntStr creates a *BigIntStr from a *big.Int. If the provided bigInt is nil the returned *BigIntStr will also be nil
type CollectedFeesAPI ¶
CollectedFeesAPI is send common.batch.CollectedFee through the API
func NewCollectedFeesAPI ¶
func NewCollectedFeesAPI(m map[common.TokenID]*big.Int) CollectedFeesAPI
NewCollectedFeesAPI creates a new CollectedFeesAPI from a *big.Int map
type EthSignature ¶
type EthSignature string
EthSignature is used to scan/value []byte representing an Ethereum signature directly into strings from/to sql DBs.
func NewEthSignature ¶
func NewEthSignature(signature []byte) *EthSignature
NewEthSignature creates a *EthSignature from []byte If the provided signature is nil the returned *EthSignature will also be nil
func (*EthSignature) Scan ¶
func (e *EthSignature) Scan(src interface{}) error
Scan implements Scanner for database/sql
func (*EthSignature) UnmarshalText ¶
func (e *EthSignature) UnmarshalText(text []byte) error
UnmarshalText unmarshals a StrEthSignature
type HezBJJ ¶
type HezBJJ string
HezBJJ is used to scan/value *babyjub.PublicKeyComp directly into strings that follow the BJJ public key hez format (^hez:[A-Za-z0-9_-]{44}$) from/to sql DBs. It assumes that *babyjub.PublicKeyComp are inserted/fetched to/from the DB using the default Scan/Value interface
func NewHezBJJ ¶
func NewHezBJJ(pkComp babyjub.PublicKeyComp) HezBJJ
NewHezBJJ creates a HezBJJ from a *babyjub.PublicKeyComp. Calling this method with a nil bjj causes panic
type HezEthAddr ¶
type HezEthAddr string
HezEthAddr is used to scan/value Ethereum Address directly into strings that follow the Ethereum address hez format (^hez:0x[a-fA-F0-9]{40}$) from/to sql DBs. It assumes that Ethereum Address are inserted/fetched to/from the DB using the default Scan/Value interface
func NewHezEthAddr ¶
func NewHezEthAddr(addr ethCommon.Address) HezEthAddr
NewHezEthAddr creates a HezEthAddr from an Ethereum addr
func (*HezEthAddr) Scan ¶
func (a *HezEthAddr) Scan(src interface{}) error
Scan implements Scanner for database/sql
type HezIdx ¶
type HezIdx string
HezIdx is used to value common.Idx directly into strings that follow the Idx key hez format (hez:tokenSymbol:idx) to sql DBs. Note that this can only be used to insert to DB since there is no way to automatically read from the DB since it needs the tokenSymbol
type StrBigInt ¶
StrBigInt is used to unmarshal BigIntStr directly into an alias of big.Int
func (*StrBigInt) UnmarshalText ¶
UnmarshalText unmarshals a StrBigInt
type StrHezBJJ ¶
type StrHezBJJ babyjub.PublicKeyComp
StrHezBJJ is used to unmarshal HezBJJ directly into an alias of babyjub.PublicKeyComp
func (*StrHezBJJ) UnmarshalText ¶
UnmarshalText unmarshalls a StrHezBJJ
type StrHezEthAddr ¶
StrHezEthAddr is used to unmarshal HezEthAddr directly into an alias of ethCommon.Address
func (*StrHezEthAddr) UnmarshalText ¶
func (s *StrHezEthAddr) UnmarshalText(text []byte) error
UnmarshalText unmarshals a StrHezEthAddr
type StrHezIdx ¶
StrHezIdx is used to unmarshal HezIdx directly into an alias of common.Idx
func (*StrHezIdx) UnmarshalText ¶
UnmarshalText unmarshals a StrHezIdx
type TxL2 ¶
type TxL2 struct { ItemID uint64 `json:"itemId"` TxID common.TxID `json:"id"` Type common.TxType `json:"type"` FromIdx HezIdx `json:"fromAccountIndex"` EffectiveFromEthAddr *HezEthAddr `json:"fromHezEthereumAddress"` EffectiveFromBJJ *HezBJJ `json:"fromBJJ"` ToIdx *HezIdx `json:"toAccountIndex"` EffectiveToEthAddr *HezEthAddr `json:"toHezEthereumAddress"` EffectiveToBJJ *HezBJJ `json:"toBJJ"` Amount BigIntStr `json:"amount"` Fee common.FeeSelector `json:"fee"` Nonce nonce.Nonce `json:"nonce"` State common.PoolL2TxState `json:"state"` BatchNum *common.BatchNum `json:"batchNum"` MaxNumBatch uint32 `json:"maxNumBatch"` Info *string `json:"info"` ErrorCode *int `json:"errorCode"` ErrorType *string `json:"errorType"` Signature babyjub.SignatureComp `json:"signature"` Timestamp time.Time `json:"timestamp"` RqFromIdx *HezIdx `json:"requestFromAccountIndex"` RqToIdx *HezIdx `json:"requestToAccountIndex"` RqToEthAddr *HezEthAddr `json:"requestToHezEthereumAddress"` RqToBJJ *HezBJJ `json:"requestToBJJ"` RqTokenID *common.TokenID `json:"requestTokenId"` RqAmount *BigIntStr `json:"requestAmount"` RqFee *common.FeeSelector `json:"requestFee"` RqNonce *nonce.Nonce `json:"requestNonce"` Token token `json:"token"` }
TxL2 represents a L2 Tx pool with extra metadata used by the API
func (TxL2) MarshalJSON ¶
MarshalJSON is used to convert TxL2 in JSON
func (*TxL2) UnmarshalJSON ¶
UnmarshalJSON is used to create a TxL2 from JSON data