UNPKG

kleros-escrow-data-service

Version:

Data service for interacting with Kleros Escrow

287 lines (286 loc) 9.35 kB
import { ethers } from "ethers"; import { TokenTransactionService, TokenEventService, DisputeService, ArbitratorService, IPFSService } from "../services"; import { KlerosEscrowConfig } from "../types"; import { TokenTransaction } from "../types/token"; import { TransactionActions, DisputeActions, EvidenceActions } from "../actions"; /** * Client for interacting with Kleros Escrow Token services * Provides read and write operations for token escrow transactions */ export declare class KlerosEscrowTokenClient { private config; /** * Services for reading token transaction data */ readonly services: { tokenTransaction: TokenTransactionService; tokenEvent: TokenEventService; dispute: DisputeService; arbitrator: ArbitratorService; ipfs: IPFSService; }; /** * Actions for writing data (only available if a signer is provided) */ readonly actions?: { transaction: TransactionActions; dispute: DisputeActions; evidence: EvidenceActions; }; /** * Creates a new KlerosEscrowTokenClient * @param config The Kleros Escrow configuration * @param signer Optional signer for write operations */ constructor(config: KlerosEscrowConfig, signer?: ethers.Signer); /** * Gets the configuration used by this client * @returns The Kleros Escrow configuration */ getConfig(): KlerosEscrowConfig; /** * Checks if this client has write capabilities * @returns True if the client can perform write operations */ canWrite(): boolean; /** * Convenience method to get a token transaction by ID * @param transactionId The ID of the transaction to fetch * @returns The token transaction data */ getTokenTransaction(transactionId: string): Promise<TokenTransaction>; /** * Convenience method to get token transactions by address * @param address The address to get transactions for * @returns Array of token transactions */ getTransactionsByAddress(address: string): Promise<TokenTransaction[]>; /** * Convenience method to get token information * @param tokenAddress The token contract address * @returns Token information (name, symbol, decimals) */ getTokenInfo(tokenAddress: string): Promise<{ name: string; symbol: string; decimals: number; }>; /** * Convenience method to get a dispute by transaction ID * @param transactionId The ID of the transaction * @returns The dispute data if it exists */ getDispute(transactionId: string): Promise<import("../types").Dispute | null>; /** * Convenience method to get the arbitrator information * @returns The arbitrator information */ getArbitrator(): Promise<import("../types").Arbitrator>; /** * Convenience method to fetch data from IPFS * @param path The IPFS path or CID * @returns The data from IPFS */ fetchFromIPFS(path: string): Promise<any>; /** * Get all token transaction details from subgraph * @param transactionId The transaction ID * @returns Combined transaction details with events */ getTokenTransactionDetails(transactionId: string): Promise<{ rulings: { _arbitrator: string; _disputeID: string; blockNumber: string; blockTimestamp: string; _ruling: string; transactionHash: string; }[]; metaEvidences: { id: string; blockTimestamp: string; transactionHash: string; _evidence: string; blockNumber: string; _metaEvidenceID: string; }[]; payments: { id: string; _transactionID: string; _amount: string; _party: string; blockNumber: string; blockTimestamp: string; transactionHash: string; }[]; evidences: { _arbitrator: string; _party: string; _evidence: string; _evidenceGroupID: string; blockNumber: string; transactionHash: string; }[]; disputes: { _arbitrator: string; _disputeID: string; blockNumber: string; blockTimestamp: string; _metaEvidenceID: string; _evidenceGroupID: string; transactionHash: string; }[]; hasToPayFees: { _transactionID: string; blockNumber: string; blockTimestamp: string; _party: string; transactionHash: string; }[]; transactionCreateds: { id: string; _transactionID: string; _sender: string; _receiver: string; _token: string; _amount: string; blockNumber: string; blockTimestamp: string; transactionHash: string; }[]; }>; /** * Get all token transactions from subgraph * @returns Array of all token transactions */ getAllTokenTransactions(): Promise<{ id: string; _transactionID: string; _sender: string; _receiver: string; _token: string; _amount: string; blockNumber: string; blockTimestamp: string; transactionHash: string; }[]>; /** * Get token transactions by address from subgraph * @param address The address to filter by * @returns Array of token transactions involving the address */ getTokenTransactionsByAddress(address: string): Promise<{ id: string; _transactionID: string; _sender: string; _receiver: string; _token: string; _amount: string; blockNumber: string; blockTimestamp: string; transactionHash: string; }[]>; /** * Get transactions by token contract address from subgraph * @param tokenAddress The token contract address * @returns Array of transactions for the specific token */ getTransactionsByToken(tokenAddress: string): Promise<{ id: string; _transactionID: string; _sender: string; _receiver: string; _token: string; _amount: string; blockNumber: string; blockTimestamp: string; transactionHash: string; }[]>; /** * Get enhanced token transaction data combining contract and subgraph data * @param transactionId The transaction ID * @returns Enhanced token transaction data with token info and events */ getEnhancedTokenTransaction(transactionId: string): Promise<{ tokenInfo: { name: string; symbol: string; decimals: number; } | undefined; events: { rulings: { _arbitrator: string; _disputeID: string; blockNumber: string; blockTimestamp: string; _ruling: string; transactionHash: string; }[]; metaEvidences: { id: string; blockTimestamp: string; transactionHash: string; _evidence: string; blockNumber: string; _metaEvidenceID: string; }[]; payments: { id: string; _transactionID: string; _amount: string; _party: string; blockNumber: string; blockTimestamp: string; transactionHash: string; }[]; evidences: { _arbitrator: string; _party: string; _evidence: string; _evidenceGroupID: string; blockNumber: string; transactionHash: string; }[]; disputes: { _arbitrator: string; _disputeID: string; blockNumber: string; blockTimestamp: string; _metaEvidenceID: string; _evidenceGroupID: string; transactionHash: string; }[]; hasToPayFees: { _transactionID: string; blockNumber: string; blockTimestamp: string; _party: string; transactionHash: string; }[]; transactionCreateds: { id: string; _transactionID: string; _sender: string; _receiver: string; _token: string; _amount: string; blockNumber: string; blockTimestamp: string; transactionHash: string; }[]; }; id: string; sender: string; receiver: string; amount: string; token: string; status: import("../types").TokenTransactionStatus; timeoutPayment: number; lastInteraction: number; createdAt: number; disputeId?: number; senderFee: string; receiverFee: string; metaEvidence?: string; }>; }