apitypes

package
v0.0.0-...-e04c47b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

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

func NewBigIntStr(bigInt *big.Int) *BigIntStr

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

func (*CbBJJ) Scan

func (b *CbBJJ) Scan(src interface{}) error

Scan implements Scanner for database/sql

func (CbBJJ) ToBJJ

func (b CbBJJ) ToBJJ() (babyjub.PublicKeyComp, error)

ToBJJ returns a babyjub.PublicKeyComp created from CbBJJ

func (CbBJJ) Value

func (b CbBJJ) Value() (driver.Value, error)

Value implements valuer for database/sql

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

func NewCbEthAddr(addr ethCommon.Address) CbEthAddr

NewCbEthAddr creates a CbEthAddr from an Ethereum addr

func (*CbEthAddr) Scan

func (a *CbEthAddr) Scan(src interface{}) error

Scan implements Scanner for database/sql

func (CbEthAddr) ToEthAddr

func (a CbEthAddr) ToEthAddr() (ethCommon.Address, error)

ToEthAddr returns an Ethereum Address created from CbEthAddr

func (CbEthAddr) Value

func (a CbEthAddr) Value() (driver.Value, error)

Value implements valuer for database/sql

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

type CollectedFeesAPI map[common.TokenID]BigIntStr

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

func (EthSignature) Value

func (e EthSignature) Value() (driver.Value, error)

Value implements valuer for database/sql

type StrBigInt

type StrBigInt big.Int

StrBigInt is used to unmarshal BigIntStr directly into an alias of big.Int

func (*StrBigInt) UnmarshalText

func (s *StrBigInt) UnmarshalText(text []byte) error

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

func (s *StrCbBJJ) UnmarshalText(text []byte) error

UnmarshalText unmarshalls a StrCbBJJ

type StrCbEthAddr

type StrCbEthAddr ethCommon.Address

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

type StrCbIdx

type StrCbIdx common.Idx

StrCbIdx is used to unmarshal CbIdx directly into an alias of common.Idx

func (*StrCbIdx) UnmarshalText

func (s *StrCbIdx) UnmarshalText(text []byte) error

UnmarshalText unmarshals a StrCbIdx

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL