kleros-escrow-data-service
Version:
Data service for interacting with Kleros Escrow
80 lines (79 loc) • 3.03 kB
TypeScript
import { ethers } from "ethers";
import { TokenTransaction } from "../types/token";
import { KlerosEscrowConfig } from "../types/config";
import { BaseService } from "../base/BaseService";
/**
* Service for reading token transaction data from the Kleros Escrow Token contract
*/
export declare class TokenTransactionService extends BaseService {
private tokenContract;
/**
* Creates a new TokenTransactionService instance
* @param config The Kleros Escrow configuration
* @param provider Optional provider for read operations
*/
constructor(config: KlerosEscrowConfig, provider?: ethers.providers.Provider);
/**
* Gets a token transaction by its ID
* @param transactionId The ID of the transaction to fetch
* @returns The token transaction data
*/
getTokenTransaction: (transactionId: string) => Promise<TokenTransaction>;
/**
* Gets all token transactions for a specific address
* @param address The address to get transactions for
* @returns Array of token transactions where the address is sender or receiver
*/
getTransactionsByAddress: (address: string) => Promise<TokenTransaction[]>;
/**
* Gets the total number of token transactions in the contract
* @returns The count of transactions
*/
getTransactionCount: () => Promise<number>;
/**
* Checks if a token transaction can be executed (timeout has passed)
* @param transactionId The ID of the transaction to check
* @returns True if the transaction can be executed
*/
canExecuteTransaction: (transactionId: string) => Promise<boolean>;
/**
* Checks if a party can be timed out for not paying arbitration fees
* @param transactionId The ID of the transaction to check
* @returns Object indicating which party can be timed out, if any
*/
canTimeOut: (transactionId: string) => Promise<{
canSenderTimeOut: boolean;
canReceiverTimeOut: boolean;
}>;
/**
* Get basic ERC20 token information
* @param tokenAddress The ERC20 token contract address
* @returns Token information (name, symbol, decimals)
*/
getTokenInfo: (tokenAddress: string) => Promise<{
name: string;
symbol: string;
decimals: number;
}>;
/**
* Gets the fee timeout period from the token contract
* @returns The fee timeout in seconds
*/
getFeeTimeout: () => Promise<number>;
/**
* Gets the arbitrator address from the token contract
* @returns The arbitrator contract address
*/
getArbitratorAddress: () => Promise<string>;
/**
* Gets the arbitrator extra data from the token contract
* @returns The arbitrator extra data as bytes
*/
getArbitratorExtraData: () => Promise<string>;
/**
* Maps numeric status from contract to enum
* @param status The numeric status from the contract
* @returns The corresponding TokenTransactionStatus enum value
*/
private mapStatus;
}