@requestnetwork/data-access
Version:
Main package for the Request Network data access layer.
103 lines • 3.61 kB
TypeScript
import { DataAccessTypes } from '@requestnetwork/types';
/**
* Module to manage a block in the data access-layer
* a block is a sorted list of transactions with topics
*/
declare const _default: {
createEmptyBlock: typeof createEmptyBlock;
getAllChannelIds: typeof getAllChannelIds;
getAllTopics: typeof getAllTopics;
getAllTransactions: typeof getAllTransactions;
getTransactionFromPosition: typeof getTransactionFromPosition;
getTransactionPositionFromChannelId: typeof getTransactionPositionFromChannelId;
getTransactionPositionsByChannelIds: typeof getTransactionPositionsByChannelIds;
getTransactionsByPositions: typeof getTransactionsByPositions;
parseBlock: typeof parseBlock;
pushTransaction: typeof pushTransaction;
};
export default _default;
/**
* Function to create an empty block
*
* @returns IBlock an empty block
*/
declare function createEmptyBlock(): DataAccessTypes.IBlock;
/**
* Parses a string to a block checking if the standard is followed
*
* @param data the data to parse
* @returns the block or throw en exception if the standard is not followed
*/
declare function parseBlock(data: string): DataAccessTypes.IBlock;
/**
* Function to add a transaction and topics in the block
*
* @param block previous state will not be modified
* @param transaction transaction to push
* @param channelId id of the channel to add the transaction in
* @param topics strings to topic the channel
*
* @returns the new state
*/
declare function pushTransaction(block: DataAccessTypes.IBlock, transaction: DataAccessTypes.ITransaction, channelId: string, topics?: string[]): DataAccessTypes.IBlock;
/**
* Returns a transaction from its position
*
* @param block current block state
* @param position position of the transaction in the block
*
* @returns the transaction
*/
declare function getTransactionFromPosition(block: DataAccessTypes.IBlock, position: number): DataAccessTypes.ITransaction;
/**
* Returns several transactions from their positions
*
* @param block current block state
* @param positions list of positions of the transactions
*
* @returns the transactions
*/
declare function getTransactionsByPositions(block: DataAccessTypes.IBlock, positions: number[]): DataAccessTypes.ITransaction[];
/**
* Returns all transactions of a block
*
* @param block current block state
*
* @returns all the transactions with topics
*/
declare function getAllTransactions(block: DataAccessTypes.IBlock): DataAccessTypes.ITransaction[];
/**
* Returns a list of the positions of the transactions with given channel id
*
* @param block current block state
* @param channelId the channel id
*
* @returns list of transaction positions
*/
declare function getTransactionPositionFromChannelId(block: DataAccessTypes.IBlock, channelId: string): number[];
/**
* Returns a list of transactions position from a list of channel ids
*
* @param block current block state
* @param ids the channel ids
*
* @returns list of transaction positions
*/
declare function getTransactionPositionsByChannelIds(block: DataAccessTypes.IBlock, channelIds: string[]): number[];
/**
* Returns all the topics of the block
*
* @param block current block state
*
* @returns all the topics
*/
declare function getAllTopics(block: DataAccessTypes.IBlock): DataAccessTypes.ITopics;
/**
* Returns all the channel ids of the block
*
* @param block current block state
*
* @returns all the channel ids
*/
declare function getAllChannelIds(block: DataAccessTypes.IBlock): DataAccessTypes.IChannelIds;
//# sourceMappingURL=block.d.ts.map