"use strict" ; import { Address , Hash } from "../commonTypes" ; import { ContractWrapperBase } from "../contractWrapperBase" ; import { ArcTransactionDataResult , IContractWrapperFactory } from "../iContractWrapperBase" ; import BigNumber from "bignumber.js" ; import { ContractWrapperFactory } from "../contractWrapperFactory" ; import { ControllerService } from "../controllerService" ; import { TxGeneratingFunctionOptions } from "../transactionService" ; import { Web3EventService } from "../web3EventService" ; export class TokenCapGCWrapper extends ContractWrapperBase { public name : string = "TokenCapGC" ; public friendlyName : string = "Token Cap Global Constraint" ; public factory : IContractWrapperFactory < TokenCapGCWrapper > = TokenCapGCFactory ; public getParametersHash ( params ) { return this . _getParametersHash ( params . token , params . cap || 0 ) ; } public setParameters ( params ) { if ( ! params . token ) { throw new Error ( "token must be set" ) ; } const cap = new BigNumber ( params . cap ) ; if ( cap . lt ( 0 ) ) { throw new Error ( "cap must be greater than or equal to zero" ) ; } return super . _setParameters ( "TokenCapGC.setParameters" , params . txEventContext , params . token , cap ) ; } public async getParameters ( paramsHash ) { const params = await this . getParametersArray ( paramsHash ) ; return { cap : params [ 1 ] , token : params [ 0 ] , } ; } public async getRegisteredParametersHash ( avatarAddress ) { const controllerService = new ControllerService ( avatarAddress ) ; const controller = await controllerService . getController ( ) ; return controller . getGlobalConstraintParameters ( this . address , avatarAddress ) ; } public async getRegisteredParameters ( avatarAddress ) { const paramsHash = await this . getRegisteredParametersHash ( avatarAddress ) ; return this . getParameters ( paramsHash ) ; } } export const TokenCapGCFactory = new ContractWrapperFactory ( "TokenCapGC" , TokenCapGCWrapper , new Web3EventService ( ) ) ; export interface TokenCapGcParams { cap : BigNumber | string ; token : Address ; } export interface GetTokenCapGcParamsResult { cap : BigNumber ; token : Address ; }