import { Address } from 'set-protocol-utils' ; import { AllocatorMathLibraryMockContract , FlexibleTimingManagerLibraryMockContract , UintArrayUtilsLibraryMockContract , } from '../contracts' ; import { getContractInstance , importArtifactsFromSource , txnFrom , } from '../web3Helper' ; const AllocatorMathLibraryMock = importArtifactsFromSource ( 'AllocatorMathLibraryMock' ) ; const FlexibleTimingManagerLibraryMock = importArtifactsFromSource ( 'FlexibleTimingManagerLibraryMock' ) ; const UintArrayUtilsLibrary = importArtifactsFromSource ( 'UintArrayUtilsLibrary' ) ; const UintArrayUtilsLibraryMock = importArtifactsFromSource ( 'UintArrayUtilsLibraryMock' ) ; export class LibraryMockHelper { private _contractOwnerAddress : Address ; constructor ( contractOwnerAddress ) { this . _contractOwnerAddress = contractOwnerAddress ; } public async deployFlexibleTimingManagerLibraryMockAsync ( from = this . _contractOwnerAddress ) { const managerLibraryMockContract = await FlexibleTimingManagerLibraryMock . new ( txnFrom ( from ) ) ; return new FlexibleTimingManagerLibraryMockContract ( getContractInstance ( managerLibraryMockContract ) , txnFrom ( from ) ) ; } public async deployAllocatorMathLibraryAsync ( from = this . _contractOwnerAddress ) { const mathHelperMockContract = await AllocatorMathLibraryMock . new ( txnFrom ( from ) ) ; return new AllocatorMathLibraryMockContract ( getContractInstance ( mathHelperMockContract ) , txnFrom ( from ) ) ; } public async deployUintArrayUtilsLibraryAsync ( from = this . _contractOwnerAddress ) { await this . linkUintArrayUtilsLibraryAsync ( UintArrayUtilsLibraryMock ) ; const mathHelperMockContract = await UintArrayUtilsLibraryMock . new ( txnFrom ( from ) ) ; return new UintArrayUtilsLibraryMockContract ( getContractInstance ( mathHelperMockContract ) , txnFrom ( from ) ) ; } public async linkUintArrayUtilsLibraryAsync ( contract ) { const truffleUintArrayUtilsLibrary = await UintArrayUtilsLibrary . new ( { from : this . _contractOwnerAddress } ) ; await contract . link ( 'UintArrayUtilsLibrary' , truffleUintArrayUtilsLibrary . address ) ; } }