import BigNumber from "bignumber.js" ; import { Address , Hash , SchemePermissions } from "./commonTypes" ; import { TransactionReceiptTruffle , TransactionService } from "./transactionService" ; import { IIntVoteInterface } from "./wrappers/iIntVoteInterface" ; export interface IContractWrapper { factory : IContractWrapperFactory < any > ; name : string ; friendlyName : string ; address : Address ; contract : any ; hydrateFromNew ( ... rest ) : Promise < any > ; hydrateFromAt ( address ) : Promise < any > ; } /**
 * The minimum requirements for a scheme that can be registered with a DAO/controller.
 */ export interface ISchemeWrapper extends IContractWrapper { getSchemePermissions ( avatarAddress ) : Promise < SchemePermissions > ; getDefaultPermissions ( ) : SchemePermissions ; } /**
 * The minimum requirements for a universal scheme.
 */ export interface IUniversalSchemeWrapper extends ISchemeWrapper { getParameters ( paramsHash ) : Promise < any > ; getParametersHash ( params ) : Promise < Hash > ; setParameters ( params ) : Promise < ArcTransactionDataResult < Hash > > ; getSchemeParameters ( avatarAddress ) : Promise < any > ; getParametersArray ( paramsHash ) : Promise < Array < any > > ; } /**
 * The minimum requirements for a voting machine wrapper.
 */ export interface IVotingMachineWrapper extends IContractWrapper { getParameters ( paramsHash ) : Promise < any > ; getParametersHash ( params ) : Promise < Hash > ; setParameters ( params ) : Promise < ArcTransactionDataResult < Hash > > ; getParametersArray ( paramsHash ) : Promise < Array < any > > ; } export interface IContractWrapperFactory < TWrapper extends IContractWrapper > { new : ( ... rest : Array < any > ) => Promise < TWrapper > ; at : ( address : string ) => Promise < TWrapper > ; deployed : ( ) => Promise < TWrapper > ; ensureSolidityContract ( ) : Promise < any > ; } export class ArcTransactionResult { constructor ( /**
     * The transaction hash
     */ public tx , /**
     *  the Truffle contract wrapper
     */ private contract ) { } /**
     * Returns a promise of the transaction if it is mined,
     * converted to a TransactionReceiptTruffle (with readable logs).
     *
     * Returns null if the transaciton is not yet mined.
     */ public async getTxMined ( ) { if ( ! this . tx ) { return null ; } return TransactionService . getMinedTransaction ( this . tx , this . contract ) as Promise < TransactionReceiptTruffle | null > ; } param requiredDepth public async getTxConfirmed ( requiredDepth ? ) { if ( ! this . tx ) { return null ; } return TransactionService . getConfirmedTransaction ( this . tx , this . contract , requiredDepth ) as Promise < TransactionReceiptTruffle | null > ; } /**
     * Returns promise of a mined transaction once it has been mined,
     * converted to a TransactionReceiptTruffle (with readable logs).
     */ public async watchForTxMined ( ) { if ( ! this . tx ) { return null ; } return TransactionService . watchForMinedTransaction ( this . tx , this . contract ) as Promise < TransactionReceiptTruffle | null > ; } param requiredDepth public async watchForTxConfirmed ( requiredDepth ? ) { if ( ! this . tx ) { return null ; } return TransactionService . watchForConfirmedTransaction ( this . tx , this . contract , requiredDepth ) as Promise < TransactionReceiptTruffle | null > ; } param valueName param eventName param index public async getValueFromMinedTx ( valueName , eventName = null , index = 0 ) { if ( ! this . tx ) { return null ; } const txMined = await this . watchForTxMined ( ) ; return TransactionService . getValueFromLogs ( txMined , valueName , eventName , index ) ; } } /**
 * Base or actual type returned by all contract wrapper methods that generate a transaction and initiate a proposal.
 */ export class ArcTransactionProposalResult extends ArcTransactionResult { constructor ( tx , contract , /**
     * The proposal's voting machine, as IntVoteInterface
     */ public votingMachine ) { super ( tx , contract ) ; this . votingMachine = votingMachine ; } /**
     * Returns promise of the proposal id from the logs of the mined transaction. Will watch for the mined tx;
     * if it hasn't yet been mined, could take a while to return.
     */ public async getProposalIdFromMinedTx ( ) { return this . getValueFromMinedTx ( "_proposalId" ) ; } } /**
 * Base or actual type returned by all contract wrapper methods that generate a transaction and any other result.
 */ export class ArcTransactionDataResult < TData > extends ArcTransactionResult { constructor ( tx , contract , /**
     * Additional data being returned.
     */ public result ) { super ( tx , contract ) ; this . result = result ; } } /**
 * Common scheme parameters for schemes that are able to create proposals.
 */ export interface StandardSchemeParams { /**
     * Hash of the voting machine parameters to use when voting on a proposal.
     */ voteParametersHash : Hash ; /**
     * Address of the voting machine to use when voting on a proposal.
     */ votingMachineAddress : Address ; } export { DecodedLogEntryEvent , TransactionReceipt } from "web3" ; /**
 * The value of the global config setting `gasPriceAdjustor`
 * This function will be invoked to obtain promise of a desired gas price
 * given the current default gas price which will be determined by the x latest blocks
 * median gas price.
 */ export type GasPriceAdjustor = ( defaultGasPrice : BigNumber ) => Promise < BigNumber | string > ;