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/chainbing/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 CbBJJ ¶
type CbBJJ string
CbBJJ is used to scan/value *babyjub.PublicKeyComp directly into strings that follow the BJJ public key cb format (^cb:[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 NewCbBJJ ¶
func NewCbBJJ(pkComp babyjub.PublicKeyComp) CbBJJ
NewCbBJJ creates a CbBJJ from a *babyjub.PublicKeyComp. Calling this method with a nil bjj causes panic
type CbEthAddr ¶
type CbEthAddr string
CbEthAddr is used to scan/value Ethereum Address directly into strings that follow the Ethereum address cb format (^cb: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 NewCbEthAddr ¶
NewCbEthAddr creates a CbEthAddr from an Ethereum addr
type CbIdx ¶
type CbIdx string
CbIdx is used to value common.Idx directly into strings that follow the Idx key cb format (cb: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 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 StrBigInt ¶
StrBigInt is used to unmarshal BigIntStr directly into an alias of big.Int
func (*StrBigInt) UnmarshalText ¶
UnmarshalText unmarshals a StrBigInt
type StrCbBJJ ¶
type StrCbBJJ babyjub.PublicKeyComp
StrCbBJJ is used to unmarshal CbBJJ directly into an alias of babyjub.PublicKeyComp
func (*StrCbBJJ) UnmarshalText ¶
UnmarshalText unmarshalls a StrCbBJJ
type StrCbEthAddr ¶
StrCbEthAddr is used to unmarshal CbEthAddr directly into an alias of ethCommon.Address
func (*StrCbEthAddr) UnmarshalText ¶
func (s *StrCbEthAddr) UnmarshalText(text []byte) error
UnmarshalText unmarshals a StrCbEthAddr