import { Address , Hash } from "./commonTypes" ; import { ControllerService } from "./controllerService" ; import { ArcTransactionDataResult , IUniversalSchemeWrapper , StandardSchemeParams , } from "./iContractWrapperBase" ; import { SchemeWrapperBase } from "./schemeWrapperBase" ; import { TxEventContext } from "./transactionService" ; /**
 * Abstract base class for all Arc universal scheme contract wrapper classes.  A universal scheme
 * is defined as an Arc scheme (see `SchemeWrapperBase`) that follows the pattern of registering
 * operating parameters with the DAO's controller, thus enabling the contract to be reused across DAOs.
 */ export abstract class USchemeWrapperBase extends SchemeWrapperBase { param paramsHash public abstract getParameters ( paramsHash ) ; public abstract getParametersHash ( params ) ; public abstract setParameters ( params ) ; public abstract getSchemeParameters ( avatarAddress ) ; param avatarAddress public async getSchemeParametersHash ( avatarAddress ) { const controllerService = new ControllerService ( avatarAddress ) ; const controller = await controllerService . getController ( ) ; return controller . getSchemeParameters ( this . address , avatarAddress ) ; } param paramsHash public getParametersArray ( paramsHash ) { return this . contract . parameters ( paramsHash ) ; } protected async _setParameters ( functionName , txEventContext , ... params ) { const parametersHash = await this . contract . getParametersHash ( ... params ) ; const txResult = await this . wrapTransactionInvocation ( functionName , Object . assign ( params , { txEventContext } ) , this . contract . setParameters , params ) ; return new ArcTransactionDataResult < Hash > ( txResult . tx , this . contract , parametersHash ) ; } protected async _getSchemeParameters ( avatarAddress ) { const paramsHash = await this . getSchemeParametersHash ( avatarAddress ) ; return this . getParameters ( paramsHash ) ; } protected _getParametersHash ( ... params ) { return this . contract . getParametersHash ( ... params ) ; } protected validateStandardSchemeParams ( params ) { if ( ! params . voteParametersHash ) { throw new Error ( `voteParametersHash is not defined` ) ; } if ( ! params . votingMachineAddress ) { throw new Error ( `votingMachineAddress is not defined` ) ; } } }