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/arnaubennassar/hermez-node/v2/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