datastore

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BLOCK_SUFFIX = "block"
	PAIR_SUFFIX  = "pair"
)
View Source
const (
	TOKEN        = "token"
	NATIVE_TOKEN = "native_token"
)

Variables

This section is empty.

Functions

func GetBlockFolderPath

func GetBlockFolderPath(chainId string) []string

func GetPairFolderPath

func GetPairFolderPath(chainId string) []string

func NewLcdClient

func NewLcdClient(baseUrl string, c httpClient) lcdClient

Types

type AssetInfo

type AssetInfo struct {
	Token *struct {
		ContractAddr string `json:"contract_addr"`
	} `json:"token,omitempty"`

	NativeToken *struct {
		Denom string `json:"denom"`
	} `json:"native_token,omitempty"`
}

func (*AssetInfo) GetInfo

func (assets *AssetInfo) GetInfo() *AssetInfoWithType

type AssetInfoWithType

type AssetInfoWithType struct {
	Type           string `json:"type"`
	DenomOrAddress string `json:"denom_or_address"`
}

type BlockTxsDTO

type BlockTxsDTO struct {
	BlockId int64   `json:"block_id"`
	Txs     []TxDTO `json:"txs"`
}

func FakeBlockDto

func FakeBlockDto() BlockTxsDTO

type BlockTxsRaw

type BlockTxsRaw struct {
	BlockId int64   `json:"block_id"`
	Txs     []TxRaw `json:"txs"`
}

type DataStore

type DataStore interface {
	// testing purpose
	SetNewServiceClientFunc(func(cc grpc1.ClientConn) txtypes.ServiceClient)
	SetNewS3ClientFunc(func() (s3client.S3ClientInterface, error))
	SetNewQueryClientFunc(func(cc grpc1.ClientConn) wasm.QueryClient)

	// additional wrapper for Collector module usage
	GetNodeSyncedHeight() (int64, error)
	GetChainId() string
	GetLatestProcessedBlockNumber(...string) (int64, error)
	ChangeLatestBlock(int64, ...string) error
	UploadBlockBinary(int64, []byte, ...string) error

	// exposed to public usage in actual
	AddCustomInterfaceRegistry(...func(codectypes.InterfaceRegistry))
	GetBlockByHeight(int64) (*tendermintType.Block, error)
	GetBlockTxsFromHeight(int64) (*BlockTxsRaw, error)
	GetBlockTxsFromBlockData(*tendermintType.Block) (*BlockTxsRaw, error)
	GetCurrentPairsList(int64) (*PairListDTO, error)
	GetCurrentPoolStatusOfUnitPair(int64, string) (*PoolInfoDTO, error)
	GetCurrentPoolStatusOfAllPairs(int64) (*PoolInfoList, error)
	GetPoolStatusOfUnitPairByHeight(int64, string, ...string) (*PoolInfoDTO, error)
	GetPoolStatusOfAllPairsByHeight(int64, ...string) (*PoolInfoList, error)
	UploadPoolInfoBinary(int64, []byte, ...string) error
}

func New

func New(c configs.Config, serviceDesc grpcConn.ServiceDesc, lcd lcdClient) (DataStore, error)

type PairListDTO

type PairListDTO struct {
	Pairs map[string]UnitPairDTO `json:"pairs"`
}

type PairListResponse

type PairListResponse struct {
	Pairs []UnitPair `json:"pairs"`
}

type PoolAssetInfo

type PoolAssetInfo struct {
	Info   AssetInfo      `json:"info"`
	Amount *cosmossdk.Int `json:"amount"`
}

func (*PoolAssetInfo) GetInfo

func (pool *PoolAssetInfo) GetInfo() *PoolAssetInfoWithType

type PoolAssetInfoWithType

type PoolAssetInfoWithType struct {
	Info   *AssetInfoWithType `json:"info"`
	Amount *cosmossdk.Int     `json:"amount"`
}

type PoolInfo

type PoolInfo struct {
	Assets     [2]PoolAssetInfo `json:"assets"`
	TotalShare *cosmossdk.Int   `json:"total_share"`
}

func (*PoolInfo) Convert

func (pool *PoolInfo) Convert() *PoolInfoDTO

type PoolInfoDTO

type PoolInfoDTO struct {
	Assets     [2]PoolAssetInfoWithType `json:"assets"`
	TotalShare *cosmossdk.Int           `json:"total_share"`
}

type PoolInfoList

type PoolInfoList struct {
	Pairs map[string]PoolInfoDTO `json:"pairs"`
}

func FakePoolInfoList

func FakePoolInfoList() PoolInfoList

type ReadStore

type ReadStore interface {
	GetLatestHeight() (uint64, error)
	GetBlockByHeight(height uint64) (*BlockTxsDTO, error)
	GetPoolStatusOfAllPairsByHeight(uint64) (*PoolInfoList, error)
}

func NewReadStore

func NewReadStore(chainId string, s3Client s3client.S3ClientInterface) ReadStore

func NewReadStoreWithGrpc

func NewReadStoreWithGrpc(chainId string, store DataStore) ReadStore

type ReadStoreMock

type ReadStoreMock struct {
	mock.Mock
}

func (*ReadStoreMock) GetBlockByHeight

func (m *ReadStoreMock) GetBlockByHeight(height uint64) (*BlockTxsDTO, error)

GetBlockByHeight implements ReadStore

func (*ReadStoreMock) GetLatestHeight

func (m *ReadStoreMock) GetLatestHeight() (uint64, error)

GetLatestHeight implements ReadStore

func (*ReadStoreMock) GetPoolStatusOfAllPairsByHeight

func (m *ReadStoreMock) GetPoolStatusOfAllPairsByHeight(uint64) (*PoolInfoList, error)

GetPoolStatusOfAllPairsByHeight implements ReadStore

type TxDTO

type TxDTO struct {
	Height    string                    `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
	TxHash    string                    `protobuf:"bytes,2,opt,name=txhash,proto3" json:"txhash,omitempty"`
	Codespace string                    `protobuf:"bytes,3,opt,name=codespace,proto3" json:"codespace,omitempty"`
	Code      uint32                    `protobuf:"varint,4,opt,name=code,proto3" json:"code,omitempty"`
	Data      string                    `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
	RawLog    string                    `protobuf:"bytes,6,opt,name=raw_log,json=rawLog,proto3" json:"raw_log,omitempty"`
	Logs      cosmossdk.ABCIMessageLogs `protobuf:"bytes,7,rep,name=logs,proto3,castrepeated=ABCIMessageLogs" json:"logs"`
	Info      string                    `protobuf:"bytes,8,opt,name=info,proto3" json:"info,omitempty"`
	GasWanted string                    `protobuf:"varint,9,opt,name=gas_wanted,json=gasWanted,proto3" json:"gas_wanted,omitempty"`
	GasUsed   string                    `protobuf:"varint,10,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"`

	// the type of Tx will be replace when we can find the appropriate type
	Tx        *codectypes.Any   `protobuf:"bytes,11,opt,name=tx,proto3" json:"tx,omitempty"`
	Timestamp string            `protobuf:"bytes,12,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	Events    []abcitypes.Event `protobuf:"bytes,13,rep,name=events,proto3" json:"events"`
}

Copied from the type definition of Cosmos SDK and revised the stringed integer

type TxRaw

type TxRaw struct {
	TxHash    string
	TxContent *txtypes.GetTxResponse
}

func (*TxRaw) MarshalJSON

func (tx *TxRaw) MarshalJSON() ([]byte, error)

func (*TxRaw) ToString

func (tx *TxRaw) ToString() (string, error)

type UnitPair

type UnitPair struct {
	AssetInfo      [2]AssetInfo `json:"asset_infos"`
	ContractAddr   string       `json:"contract_addr"`
	LiquidityToken string       `json:"liquidity_token"`
	AssetDecimals  [2]uint      `json:"asset_decimals"`
}

func (*UnitPair) Convert

func (pair *UnitPair) Convert() *UnitPairDTO

type UnitPairDTO

type UnitPairDTO struct {
	AssetInfo      [2]AssetInfoWithType `json:"asset_infos"`
	ContractAddr   string               `json:"contract_addr"`
	LiquidityToken string               `json:"liquidity_token"`
	AssetDecimals  [2]uint              `json:"asset_decimals"`
}

Jump to

Keyboard shortcuts

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