cic-client
Version:
Typescript libraries for building CIC client applications
101 lines (100 loc) • 3.4 kB
TypeScript
/**
* Provides processing of Ethereum transaction receipts relevant for the CIC network.
*
* @module helper
*/
import { Registry } from './registry';
import { EVMAddress, FungibleToken } from "./typ";
/**
* Reduced, concrete view of a transaction receipt.
*
* @todo Is there a way of importing the web3 type instead?
*/
declare class Receipt {
logs: Array<any>;
status: boolean;
}
/**
* Receipt processor within context of a given registry.
*
*/
declare class TransactionHelper {
w3: any;
registry: Registry;
ontransfer: (Transfer: any) => void;
onconversion: (Conversion: any) => void;
/**
*
* @param registry The registry context to use
*/
constructor(w3: any, registry: Registry);
/**
* Processes a single receipt to find conversion and token transfer events.
*
* If a transfer is found, ontransfer callback will be called with a Transfer instance.
* If a conversion is found, onconvsrsion callback will be called with a Conversion instance.
*
* @param r A Web3 transaction receipt.
* @todo The from-amount of convert is currently wrong, but be retrieved from the initial transfer log entry instead.
*/
processReceipt(r: Receipt): Promise<void>;
}
/**
* Token query within the context of a registry.
*/
declare class TokenDeclarationHelper {
registry: Registry;
w3: any;
/**
*
* @param w3
* @param registry The registry context to use.
*/
constructor(w3: any, registry: Registry);
/**
* Check if a token fits the ERC20 standard.
*
* @param tokenAddress The address of the token to be checked.
*/
assertERC20TokenType(tokenAddress: string): Promise<boolean>;
}
/**
* Declarator query within the context of a registry.
*/
declare class DeclaratorHelper {
registry: Registry;
trusts: EVMAddress[];
tokenHelper: TokenDeclarationHelper;
/**
*
* @param w3
* @param registry The registry context to use.
*/
constructor(w3: any, registry: Registry);
/**
* Add an address to list of declarators to trust.
*
* @param address The address to be added to the trust list
*/
addTrust(address: EVMAddress): void;
/**
* Check for trust records of a token
*
* if there are no trust records, an error will be thrown.
*
* @param tokenRegistryContractName The name of the token in the token registry.
* @param tokenAddress The address of the contract used to deploy the token.
* @param checkInterface A boolean on whether to to check the interface.
*/
getTrustedTokenDeclaration(tokenRegistryContractName: string, tokenAddress: EVMAddress, checkInterface?: boolean): Promise<FungibleToken>;
/**
* Check for trust records for a token by a declarator.
*
* @param tokenRegistryContractName The name of the token in the token registry.
* @param declarator The address of the declarator used to check for trust.
* @param tokenAddress The address of the contract used to deploy the token.
* @param checkInterface A boolean on whether to to check the interface.
*/
getTokenDeclaration(tokenRegistryContractName: string, declarator: EVMAddress, tokenAddress: EVMAddress, checkInterface?: boolean): Promise<FungibleToken>;
}
export { DeclaratorHelper, TransactionHelper, TokenDeclarationHelper };