@iexec/dataprotector
Version:
This product enables users to confidentially store data–such as mail address, documents, personal information ...
45 lines • 1.89 kB
JavaScript
import { GraphQLClient } from 'graphql-request';
import { IExec } from 'iexec';
import { DEFAULT_CONTRACT_ADDRESS, DEFAULT_DEBUG_SMS_URL, DEFAULT_IEXEC_IPFS_NODE, DEFAULT_IPFS_GATEWAY, DEFAULT_SHARING_CONTRACT_ADDRESS, DEFAULT_SUBGRAPH_URL, } from '../config/config.js';
class IExecDataProtectorModule {
dataprotectorContractAddress;
sharingContractAddress;
graphQLClient;
ipfsNode;
ipfsGateway;
iexec;
iexecDebug;
constructor(ethProvider, options) {
const ipfsGateway = options?.ipfsGateway || DEFAULT_IPFS_GATEWAY;
try {
this.iexec = new IExec({ ethProvider: ethProvider || 'bellecour' }, {
ipfsGatewayURL: ipfsGateway,
...options?.iexecOptions,
});
this.iexecDebug = new IExec({ ethProvider: ethProvider || 'bellecour' }, {
ipfsGatewayURL: ipfsGateway,
...options?.iexecOptions,
smsURL: options?.iexecOptions?.smsDebugURL || DEFAULT_DEBUG_SMS_URL,
});
}
catch (e) {
throw new Error(`Unsupported ethProvider, ${e.message}`);
}
try {
this.graphQLClient = new GraphQLClient(options?.subgraphUrl || DEFAULT_SUBGRAPH_URL);
}
catch (error) {
throw new Error(`Failed to create GraphQLClient: ${error.message}`);
}
this.dataprotectorContractAddress =
options?.dataprotectorContractAddress?.toLowerCase() ||
DEFAULT_CONTRACT_ADDRESS;
this.sharingContractAddress =
options?.sharingContractAddress?.toLowerCase() ||
DEFAULT_SHARING_CONTRACT_ADDRESS;
this.ipfsNode = options?.ipfsNode || DEFAULT_IEXEC_IPFS_NODE;
this.ipfsGateway = ipfsGateway;
}
}
export { IExecDataProtectorModule };
//# sourceMappingURL=IExecDataProtectorModule.js.map