import { isValidSigner } from '../../utils/validators.js'; import { IExecDataProtectorModule } from '../IExecDataProtectorModule.js'; import { GetGrantedAccessParams, GetProtectedDataParams, GrantAccessParams, GrantedAccess, GrantedAccessResponse, ProcessProtectedDataParams, ProcessProtectedDataResponse, ProcessBulkRequestParams, ProcessBulkRequestResponse, ProtectDataParams, ProtectedData, GetResultFromCompletedTaskParams, GetResultFromCompletedTaskResponse, ProtectedDataWithSecretProps, RevokeAllAccessParams, RevokedAccess, TransferParams, TransferResponse, WaitForTaskCompletionResponse, WaitForTaskCompletionParams, PrepareBulkRequestParams, PrepareBulkRequestResponse, InspectBulkRequestResponse, InspectBulkRequestParams, } from '../types/index.js'; import { getGrantedAccess } from './getGrantedAccess.js'; import { getProtectedData } from './getProtectedData.js'; import { getResultFromCompletedTask } from './getResultFromCompletedTask.js'; import { grantAccess } from './grantAccess.js'; import { inspectBulkRequest } from './inspectBulkRequest.js'; import { prepareBulkRequest } from './prepareBulkRequest.js'; import { processBulkRequest } from './processBulkRequest.js'; import { processProtectedData } from './processProtectedData.js'; import { protectData } from './protectData.js'; import { revokeAllAccess } from './revokeAllAccess.js'; import { revokeOneAccess } from './revokeOneAccess.js'; import { transferOwnership } from './transferOwnership.js'; import { waitForTaskCompletion } from './waitForTaskCompletion.js'; class IExecDataProtectorCore extends IExecDataProtectorModule { async protectData( args: ProtectDataParams ): Promise { await this.init(); await isValidSigner(this.iexec); return protectData({ ...args, networkName: this.networkName, dataprotectorContractAddress: this.dataprotectorContractAddress, ipfsNode: this.ipfsNode, ipfsGateway: this.ipfsGateway, arweaveUploadApi: this.arweaveUploadApi, iexec: this.iexec, }); } async grantAccess(args: GrantAccessParams): Promise { await this.init(); await isValidSigner(this.iexec); return grantAccess({ ...args, iexec: this.iexec }); } async revokeOneAccess(args: GrantedAccess): Promise { await this.init(); await isValidSigner(this.iexec); return revokeOneAccess({ ...args, iexec: this.iexec }); } async revokeAllAccess(args: RevokeAllAccessParams): Promise { await this.init(); await isValidSigner(this.iexec); return revokeAllAccess({ ...args, iexec: this.iexec }); } async transferOwnership(args: TransferParams): Promise { await this.init(); await isValidSigner(this.iexec); return transferOwnership({ ...args, iexec: this.iexec }); } async processProtectedData( args: Params ): Promise> { await this.init(); await isValidSigner(this.iexec); return processProtectedData({ ...args, iexec: this.iexec, defaultWorkerpool: this.defaultWorkerpool, }); } async prepareBulkRequest( args: PrepareBulkRequestParams ): Promise { await this.init(); await isValidSigner(this.iexec); return prepareBulkRequest({ ...args, iexec: this.iexec, }); } async processBulkRequest( args: Params ): Promise> { await this.init(); await isValidSigner(this.iexec); return processBulkRequest({ ...args, iexec: this.iexec, defaultWorkerpool: this.defaultWorkerpool, }); } // ----- READ METHODS ----- async getProtectedData( args?: GetProtectedDataParams ): Promise { await this.init(); return getProtectedData({ ...args, graphQLClient: this.graphQLClient, }); } async getGrantedAccess( args: GetGrantedAccessParams ): Promise { await this.init(); return getGrantedAccess({ ...args, iexec: this.iexec }); } async inspectBulkRequest( args: Params ): Promise> { await this.init(); return inspectBulkRequest({ ...args, iexec: this.iexec, pocoSubgraphClient: this.pocoSubgraphClient, defaultWorkerpool: this.defaultWorkerpool, }); } async waitForTaskCompletion( args: WaitForTaskCompletionParams ): Promise { await this.init(); return waitForTaskCompletion({ ...args, iexec: this.iexec, }); } async getResultFromCompletedTask( args: GetResultFromCompletedTaskParams ): Promise { await this.init(); return getResultFromCompletedTask({ ...args, iexec: this.iexec, }); } } export { IExecDataProtectorCore };