@iexec/web3mail 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config.d.ts +3 -1
- package/dist/config/config.js +3 -1
- package/dist/config/config.js.map +1 -1
- package/dist/utils/errors.d.ts +1 -2
- package/dist/utils/errors.js +1 -2
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/ipfs-service.d.ts +7 -5
- package/dist/utils/ipfs-service.js +3 -3
- package/dist/utils/ipfs-service.js.map +1 -1
- package/dist/utils/subgraphQuery.js +2 -3
- package/dist/utils/subgraphQuery.js.map +1 -1
- package/dist/utils/validators.d.ts +4 -0
- package/dist/utils/validators.js +9 -4
- package/dist/utils/validators.js.map +1 -1
- package/dist/web3mail/IExecWeb3mail.d.ts +13 -8
- package/dist/web3mail/IExecWeb3mail.js +21 -8
- package/dist/web3mail/IExecWeb3mail.js.map +1 -1
- package/dist/web3mail/fetchMyContacts.d.ts +2 -2
- package/dist/web3mail/fetchMyContacts.js +8 -39
- package/dist/web3mail/fetchMyContacts.js.map +1 -1
- package/dist/web3mail/fetchUserContacts.d.ts +2 -0
- package/dist/web3mail/fetchUserContacts.js +82 -0
- package/dist/web3mail/fetchUserContacts.js.map +1 -0
- package/dist/web3mail/sendEmail.d.ts +2 -2
- package/dist/web3mail/sendEmail.js +103 -54
- package/dist/web3mail/sendEmail.js.map +1 -1
- package/dist/web3mail/types.d.ts +58 -7
- package/package.json +17 -16
- package/src/config/config.ts +3 -1
- package/src/utils/errors.ts +2 -3
- package/src/utils/ipfs-service.ts +20 -4
- package/src/utils/subgraphQuery.ts +2 -4
- package/src/utils/validators.ts +20 -6
- package/src/web3mail/IExecWeb3mail.ts +65 -23
- package/src/web3mail/fetchMyContacts.ts +15 -58
- package/src/web3mail/fetchUserContacts.ts +105 -0
- package/src/web3mail/sendEmail.ts +138 -73
- package/src/web3mail/types.ts +72 -7
package/dist/config/config.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export declare const WEB3_MAIL_DAPP_ADDRESS = "web3mail.apps.iexec.eth";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const PROD_WORKERPOOL_ADDRESS = "prod-v8-bellecour.main.pools.iexec.eth";
|
|
3
3
|
export declare const DATAPROTECTOR_SUBGRAPH_ENDPOINT = "https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector";
|
|
4
|
+
export declare const MAX_DESIRED_DATA_ORDER_PRICE = 0;
|
|
4
5
|
export declare const MAX_DESIRED_APP_ORDER_PRICE = 0;
|
|
5
6
|
export declare const MAX_DESIRED_WORKERPOOL_ORDER_PRICE = 0;
|
|
6
7
|
export declare const DEFAULT_CONTENT_TYPE = "text/plain";
|
|
7
8
|
export declare const IPFS_UPLOAD_URL = "/dns4/ipfs-upload.v8-bellecour.iex.ec/https";
|
|
8
9
|
export declare const DEFAULT_IPFS_GATEWAY = "https://ipfs-gateway.v8-bellecour.iex.ec";
|
|
9
10
|
export declare const WHITELIST_SMART_CONTRACT_ADDRESS = "0x781482C39CcE25546583EaC4957Fb7Bf04C277D2";
|
|
11
|
+
export declare const ANY_DATASET_ADDRESS = "any";
|
package/dist/config/config.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export const WEB3_MAIL_DAPP_ADDRESS = 'web3mail.apps.iexec.eth';
|
|
2
|
-
export const
|
|
2
|
+
export const PROD_WORKERPOOL_ADDRESS = 'prod-v8-bellecour.main.pools.iexec.eth';
|
|
3
3
|
export const DATAPROTECTOR_SUBGRAPH_ENDPOINT = 'https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector';
|
|
4
|
+
export const MAX_DESIRED_DATA_ORDER_PRICE = 0;
|
|
4
5
|
export const MAX_DESIRED_APP_ORDER_PRICE = 0;
|
|
5
6
|
export const MAX_DESIRED_WORKERPOOL_ORDER_PRICE = 0;
|
|
6
7
|
export const DEFAULT_CONTENT_TYPE = 'text/plain';
|
|
7
8
|
export const IPFS_UPLOAD_URL = '/dns4/ipfs-upload.v8-bellecour.iex.ec/https';
|
|
8
9
|
export const DEFAULT_IPFS_GATEWAY = 'https://ipfs-gateway.v8-bellecour.iex.ec';
|
|
9
10
|
export const WHITELIST_SMART_CONTRACT_ADDRESS = '0x781482C39CcE25546583EaC4957Fb7Bf04C277D2';
|
|
11
|
+
export const ANY_DATASET_ADDRESS = 'any';
|
|
10
12
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAChE,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAChE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wCAAwC,CAAC;AAChF,MAAM,CAAC,MAAM,+BAA+B,GAC1C,wEAAwE,CAAC;AAC3E,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AACjD,MAAM,CAAC,MAAM,eAAe,GAAG,6CAA6C,CAAC;AAC7E,MAAM,CAAC,MAAM,oBAAoB,GAAG,0CAA0C,CAAC;AAC/E,MAAM,CAAC,MAAM,gCAAgC,GAC3C,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC"}
|
package/dist/utils/errors.d.ts
CHANGED
package/dist/utils/errors.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ValidationError } from 'yup';
|
|
2
1
|
class WorkflowError extends Error {
|
|
3
2
|
constructor(message, originalError) {
|
|
4
3
|
super(message);
|
|
@@ -6,5 +5,5 @@ class WorkflowError extends Error {
|
|
|
6
5
|
this.originalError = originalError;
|
|
7
6
|
}
|
|
8
7
|
}
|
|
9
|
-
export { WorkflowError
|
|
8
|
+
export { WorkflowError };
|
|
10
9
|
//# sourceMappingURL=errors.js.map
|
package/dist/utils/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,MAAM,aAAc,SAAQ,KAAK;IAG/B,YAAY,OAAe,EAAE,aAAoB;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
interface GetOptions {
|
|
2
2
|
ipfsGateway?: string;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
3
|
+
}
|
|
4
|
+
interface AddOptions extends GetOptions {
|
|
5
|
+
ipfsNode?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const get: (cid: any, { ipfsGateway }?: GetOptions) => Promise<Uint8Array>;
|
|
8
|
+
declare const add: (content: any, { ipfsNode, ipfsGateway, }?: AddOptions) => Promise<any>;
|
|
7
9
|
export { add, get };
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { create } from 'kubo-rpc-client';
|
|
11
|
-
import {
|
|
11
|
+
import { IPFS_UPLOAD_URL, DEFAULT_IPFS_GATEWAY } from '../config/config.js';
|
|
12
12
|
const get = (cid, { ipfsGateway = DEFAULT_IPFS_GATEWAY } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
13
|
const multiaddr = `/ipfs/${cid.toString()}`;
|
|
14
14
|
const publicUrl = `${ipfsGateway}${multiaddr}`;
|
|
@@ -19,8 +19,8 @@ const get = (cid, { ipfsGateway = DEFAULT_IPFS_GATEWAY } = {}) => __awaiter(void
|
|
|
19
19
|
const arrayBuffer = yield res.arrayBuffer();
|
|
20
20
|
return new Uint8Array(arrayBuffer);
|
|
21
21
|
});
|
|
22
|
-
const add = (content, { ipfsGateway = DEFAULT_IPFS_GATEWAY } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const ipfsClient = create(
|
|
22
|
+
const add = (content, { ipfsNode = IPFS_UPLOAD_URL, ipfsGateway = DEFAULT_IPFS_GATEWAY, } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const ipfsClient = create(ipfsNode);
|
|
24
24
|
const { cid } = yield ipfsClient.add(content);
|
|
25
25
|
yield get(cid.toString(), { ipfsGateway });
|
|
26
26
|
return cid.toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs-service.js","sourceRoot":"","sources":["../../src/utils/ipfs-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ipfs-service.js","sourceRoot":"","sources":["../../src/utils/ipfs-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAS5E,MAAM,GAAG,GAAG,CACV,GAAG,EACH,EAAE,WAAW,GAAG,oBAAoB,KAAiB,EAAE,EACvD,EAAE;IACF,MAAM,SAAS,GAAG,SAAS,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC5C,MAAM,SAAS,GAAG,GAAG,WAAW,GAAG,SAAS,EAAE,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;QACX,MAAM,KAAK,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;KACzD;IACD,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC;IAC5C,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAG,CACV,OAAO,EACP,EACE,QAAQ,GAAG,eAAe,EAC1B,WAAW,GAAG,oBAAoB,MACpB,EAAE,EAClB,EAAE;IACF,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3C,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC,CAAA,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -36,7 +36,7 @@ export const getValidContact = (graphQLClient, contacts) => __awaiter(void 0, vo
|
|
|
36
36
|
// Contacts addresses
|
|
37
37
|
const contactsAddresses = contacts.map((contact) => contact.address);
|
|
38
38
|
// Pagination
|
|
39
|
-
|
|
39
|
+
const protectedDataList = [];
|
|
40
40
|
let start = 0;
|
|
41
41
|
const range = 1000;
|
|
42
42
|
let continuePagination = true;
|
|
@@ -56,7 +56,7 @@ export const getValidContact = (graphQLClient, contacts) => __awaiter(void 0, vo
|
|
|
56
56
|
// Convert contacts array into a map where the key is the contact's address
|
|
57
57
|
const contactsMap = new Map(contacts.map((contact) => [contact.address, contact]));
|
|
58
58
|
// Convert protectedData[] into Contact[] using the map for constant time lookups
|
|
59
|
-
|
|
59
|
+
return protectedDataList.map(({ id }) => {
|
|
60
60
|
const contact = contactsMap.get(id);
|
|
61
61
|
if (contact) {
|
|
62
62
|
return {
|
|
@@ -66,7 +66,6 @@ export const getValidContact = (graphQLClient, contacts) => __awaiter(void 0, vo
|
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
return validContacts;
|
|
70
69
|
}
|
|
71
70
|
catch (error) {
|
|
72
71
|
throw new WorkflowError(`Failed to fetch subgraph: ${error.message}`, error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraphQuery.js","sourceRoot":"","sources":["../../src/utils/subgraphQuery.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAiB,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,uBAAuB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;CAqBlC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,aAA4B,EAC5B,QAAmB,EACC,EAAE;IACtB,IAAI;QACF,qBAAqB;QACrB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAErE,aAAa;QACb,
|
|
1
|
+
{"version":3,"file":"subgraphQuery.js","sourceRoot":"","sources":["../../src/utils/subgraphQuery.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAiB,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,uBAAuB,GAAG,GAAG,CAAA;;;;;;;;;;;;;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AAE;oBACX,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;iBACnD,CAAC;aACH;QACH,CAAC,CAAC,CAAC;KACJ;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,aAAa,CACrB,6BAA6B,KAAK,CAAC,OAAO,EAAE,EAC5C,KAAK,CACN,CAAC;KACH;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,aAA4B,EAC5B,aAAqB,EACH,EAAE;IACpB,IAAI;QACF,MAAM,SAAS,GAAG;YAChB,cAAc,EAAE,CAAC,cAAc,CAAC;YAChC,EAAE,EAAE,CAAC,aAAa,CAAC;YACnB,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,CAAC;SACT,CAAC;QAEF,MAAM,wBAAwB,GAC5B,MAAM,aAAa,CAAC,OAAO,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC;QAElE,MAAM,EAAE,cAAc,EAAE,GAAG,wBAAwB,CAAC;QAEpD,OAAO,cAAc,CAAC,MAAM,KAAK,CAAC,CAAC;KACpC;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,aAAa,CACrB,6BAA6B,KAAK,CAAC,OAAO,EAAE,EAC5C,KAAK,CACN,CAAC;KACH;AACH,CAAC,CAAA,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare const throwIfMissing: () => never;
|
|
2
|
+
export declare const isEnsTest: (value: string) => boolean;
|
|
2
3
|
export declare const addressOrEnsSchema: () => import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
|
|
4
|
+
export declare const addressSchema: () => import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
|
|
3
5
|
export declare const emailSubjectSchema: () => import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
|
|
4
6
|
export declare const emailContentSchema: () => import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
|
|
5
7
|
export declare const contentTypeSchema: () => import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
|
|
6
8
|
export declare const senderNameSchema: () => import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
|
|
9
|
+
export declare const labelSchema: () => import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
|
|
10
|
+
export declare const positiveNumberSchema: () => import("yup").NumberSchema<number, import("yup").AnyObject, undefined, "">;
|
package/dist/utils/validators.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ValidationError, string } from 'yup';
|
|
3
|
-
const { isAddress } = utils;
|
|
1
|
+
import { isAddress } from 'ethers';
|
|
2
|
+
import { ValidationError, number, string } from 'yup';
|
|
4
3
|
export const throwIfMissing = () => {
|
|
5
4
|
throw new ValidationError('Missing parameter');
|
|
6
5
|
};
|
|
7
6
|
const isUndefined = (value) => value === undefined;
|
|
8
7
|
const isAddressTest = (value) => isAddress(value);
|
|
9
|
-
const isEnsTest = (value) => value.endsWith('.eth') && value.length > 6;
|
|
8
|
+
export const isEnsTest = (value) => value.endsWith('.eth') && value.length > 6;
|
|
10
9
|
export const addressOrEnsSchema = () => string()
|
|
11
10
|
.transform((value) => (value === null || value === void 0 ? void 0 : value.toLowerCase()) || value)
|
|
12
11
|
.test('is-address-or-ens', '${path} should be an ethereum address or a ENS name', (value) => isUndefined(value) || isAddressTest(value) || isEnsTest(value));
|
|
12
|
+
export const addressSchema = () => string()
|
|
13
|
+
.transform((value) => (value === null || value === void 0 ? void 0 : value.toLowerCase()) || value)
|
|
14
|
+
.test('is-address', '${path} should be an ethereum address', (value) => isUndefined(value) || isAddressTest(value));
|
|
13
15
|
// 78 char length for email subject (rfc2822)
|
|
14
16
|
export const emailSubjectSchema = () => string().max(78).strict();
|
|
15
17
|
// Limit of 512,000 bytes (512 kilo-bytes)
|
|
@@ -19,4 +21,7 @@ const validContentTypes = ['text/plain', 'text/html'];
|
|
|
19
21
|
export const contentTypeSchema = () => string().oneOf(validContentTypes, 'Invalid contentType').optional();
|
|
20
22
|
// Minimum of 3 characters and max of 20 to avoid sender being flagged as spam
|
|
21
23
|
export const senderNameSchema = () => string().trim().min(3).max(20).optional();
|
|
24
|
+
// Used to identify the email campaign, minimum of 3 characters and max of 10
|
|
25
|
+
export const labelSchema = () => string().trim().min(3).max(10).optional();
|
|
26
|
+
export const positiveNumberSchema = () => number().integer().min(0).typeError('${path} must be a non-negative number');
|
|
22
27
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAEtD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAU,EAAE;IACxC,MAAM,IAAI,eAAe,CAAC,mBAAmB,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC;AAC5D,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CACzC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CACrC,MAAM,EAAE;KACL,SAAS,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,EAAE,KAAI,KAAK,CA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EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAE3E,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE,CACvC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,uCAAuC,CAAC,CAAC"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Contact, FetchContactsParams, SendEmailParams, SendEmailResponse, Web3SignerProvider } from './types.js';
|
|
1
|
+
import { Eip1193Provider } from 'ethers';
|
|
2
|
+
import { Contact, FetchUserContactsParams, SendEmailParams, Web3SignerProvider, Web3MailConfigOptions } from './types.js';
|
|
4
3
|
export declare class IExecWeb3mail {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
private iexec;
|
|
5
|
+
private ipfsNode;
|
|
6
|
+
private ipfsGateway;
|
|
7
|
+
private dataProtectorSubgraph;
|
|
8
|
+
private dappAddressOrENS;
|
|
9
|
+
private dappWhitelistAddress;
|
|
10
|
+
private graphQLClient;
|
|
11
|
+
constructor(ethProvider: Eip1193Provider | Web3SignerProvider, options?: Web3MailConfigOptions);
|
|
12
|
+
fetchMyContacts: () => Promise<Contact[]>;
|
|
13
|
+
fetchUserContacts(args?: FetchUserContactsParams): Promise<Contact[]>;
|
|
14
|
+
sendEmail: (args: SendEmailParams) => Promise<import("./types.js").SendEmailResponse>;
|
|
10
15
|
}
|
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
import { IExec } from 'iexec';
|
|
2
|
+
import { fetchUserContacts } from './fetchUserContacts.js';
|
|
2
3
|
import { fetchMyContacts } from './fetchMyContacts.js';
|
|
3
4
|
import { sendEmail } from './sendEmail.js';
|
|
4
5
|
import { GraphQLClient } from 'graphql-request';
|
|
5
|
-
import { DATAPROTECTOR_SUBGRAPH_ENDPOINT } from '../config/config.js';
|
|
6
|
+
import { WEB3_MAIL_DAPP_ADDRESS, IPFS_UPLOAD_URL, DEFAULT_IPFS_GATEWAY, DATAPROTECTOR_SUBGRAPH_ENDPOINT, WHITELIST_SMART_CONTRACT_ADDRESS, } from '../config/config.js';
|
|
6
7
|
export class IExecWeb3mail {
|
|
7
8
|
constructor(ethProvider, options) {
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
this.fetchMyContacts = () => fetchMyContacts({
|
|
10
|
+
iexec: this.iexec,
|
|
11
|
+
graphQLClient: this.graphQLClient,
|
|
12
|
+
dappAddressOrENS: this.dappAddressOrENS,
|
|
13
|
+
dappWhitelistAddress: this.dappWhitelistAddress,
|
|
14
|
+
});
|
|
15
|
+
this.sendEmail = (args) => sendEmail(Object.assign(Object.assign({}, args), { iexec: this.iexec, ipfsNode: this.ipfsNode, ipfsGateway: this.ipfsGateway, dappAddressOrENS: this.dappAddressOrENS, dappWhitelistAddress: this.dappWhitelistAddress, graphQLClient: this.graphQLClient }));
|
|
10
16
|
try {
|
|
11
|
-
iexec = new IExec({ ethProvider }, options === null || options === void 0 ? void 0 : options.iexecOptions);
|
|
17
|
+
this.iexec = new IExec({ ethProvider }, options === null || options === void 0 ? void 0 : options.iexecOptions);
|
|
12
18
|
}
|
|
13
19
|
catch (e) {
|
|
14
20
|
throw Error('Unsupported ethProvider');
|
|
15
21
|
}
|
|
16
22
|
try {
|
|
17
|
-
|
|
23
|
+
this.dataProtectorSubgraph =
|
|
24
|
+
(options === null || options === void 0 ? void 0 : options.dataProtectorSubgraph) || DATAPROTECTOR_SUBGRAPH_ENDPOINT;
|
|
25
|
+
this.graphQLClient = new GraphQLClient(this.dataProtectorSubgraph);
|
|
18
26
|
}
|
|
19
27
|
catch (e) {
|
|
20
28
|
throw Error('Impossible to create GraphQLClient');
|
|
21
29
|
}
|
|
22
|
-
this.
|
|
23
|
-
this.
|
|
24
|
-
|
|
30
|
+
this.dappAddressOrENS = (options === null || options === void 0 ? void 0 : options.dappAddressOrENS) || WEB3_MAIL_DAPP_ADDRESS;
|
|
31
|
+
this.ipfsNode = (options === null || options === void 0 ? void 0 : options.ipfsNode) || IPFS_UPLOAD_URL;
|
|
32
|
+
this.ipfsGateway = (options === null || options === void 0 ? void 0 : options.ipfsGateway) || DEFAULT_IPFS_GATEWAY;
|
|
33
|
+
this.dappWhitelistAddress =
|
|
34
|
+
(options === null || options === void 0 ? void 0 : options.dappWhitelistAddress) || WHITELIST_SMART_CONTRACT_ADDRESS;
|
|
35
|
+
}
|
|
36
|
+
fetchUserContacts(args) {
|
|
37
|
+
return fetchUserContacts(Object.assign(Object.assign({}, args), { iexec: this.iexec, graphQLClient: this.graphQLClient, dappAddressOrENS: this.dappAddressOrENS, dappWhitelistAddress: this.dappWhitelistAddress }));
|
|
25
38
|
}
|
|
26
39
|
}
|
|
27
40
|
//# sourceMappingURL=IExecWeb3mail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IExecWeb3mail.js","sourceRoot":"","sources":["../../src/web3mail/IExecWeb3mail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"IExecWeb3mail.js","sourceRoot":"","sources":["../../src/web3mail/IExecWeb3mail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,GACjC,MAAM,qBAAqB,CAAC;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aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,eAAe,CAAC;QACrD,IAAI,CAAC,WAAW,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,oBAAoB,CAAC;QAChE,IAAI,CAAC,oBAAoB;YACvB,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,oBAAoB,KAAI,gCAAgC,CAAC;IACtE,CAAC;IAUD,iBAAiB,CAAC,IAA8B;QAC9C,OAAO,iBAAiB,iCACnB,IAAI,KACP,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,aAAa,EAAE,IAAI,CAAC,aAAa,EACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,EACvC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,IAC/C,CAAC;IACL,CAAC;CAYF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Contact,
|
|
2
|
-
export declare const fetchMyContacts: ({ graphQLClient, iexec,
|
|
1
|
+
import { Contact, DappAddressConsumer, DappWhitelistAddressConsumer, IExecConsumer, SubgraphConsumer } from './types.js';
|
|
2
|
+
export declare const fetchMyContacts: ({ graphQLClient, iexec, dappAddressOrENS, dappWhitelistAddress, }: IExecConsumer & SubgraphConsumer & DappAddressConsumer & DappWhitelistAddressConsumer) => Promise<Contact[]>;
|
|
@@ -7,50 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { WEB3_MAIL_DAPP_ADDRESS, WHITELIST_SMART_CONTRACT_ADDRESS, } from '../config/config.js';
|
|
11
10
|
import { WorkflowError } from '../utils/errors.js';
|
|
12
|
-
import { autoPaginateRequest } from '../utils/paginate.js';
|
|
13
|
-
import { getValidContact } from '../utils/subgraphQuery.js';
|
|
14
11
|
import { throwIfMissing } from '../utils/validators.js';
|
|
15
|
-
|
|
12
|
+
import { fetchUserContacts } from './fetchUserContacts.js';
|
|
13
|
+
export const fetchMyContacts = ({ graphQLClient = throwIfMissing(), iexec = throwIfMissing(), dappAddressOrENS = throwIfMissing(), dappWhitelistAddress = throwIfMissing(), }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
14
|
try {
|
|
17
15
|
const userAddress = yield iexec.wallet.getAddress();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
return yield fetchUserContacts({
|
|
17
|
+
iexec,
|
|
18
|
+
graphQLClient,
|
|
19
|
+
dappAddressOrENS,
|
|
20
|
+
dappWhitelistAddress,
|
|
21
|
+
userAddress,
|
|
23
22
|
});
|
|
24
|
-
const datasetOrderbookAuthorizedByENS = yield iexec.orderbook.fetchDatasetOrderbook('any', {
|
|
25
|
-
app: WEB3_MAIL_DAPP_ADDRESS,
|
|
26
|
-
requester: userAddress,
|
|
27
|
-
page,
|
|
28
|
-
pageSize,
|
|
29
|
-
});
|
|
30
|
-
const { orders: ensOrders } = yield autoPaginateRequest({
|
|
31
|
-
request: datasetOrderbookAuthorizedByENS,
|
|
32
|
-
});
|
|
33
|
-
const { orders: scOrders } = yield autoPaginateRequest({
|
|
34
|
-
request: datasetOrderbookAuthorizedBySC,
|
|
35
|
-
});
|
|
36
|
-
const orders = ensOrders.concat(scOrders);
|
|
37
|
-
const myContacts = [];
|
|
38
|
-
const web3DappResolvedAddress = yield iexec.ens.resolveName(WEB3_MAIL_DAPP_ADDRESS);
|
|
39
|
-
orders.forEach((order) => {
|
|
40
|
-
if (order.order.apprestrict.toLowerCase() ===
|
|
41
|
-
web3DappResolvedAddress.toLowerCase() ||
|
|
42
|
-
order.order.apprestrict.toLowerCase() ===
|
|
43
|
-
WHITELIST_SMART_CONTRACT_ADDRESS.toLowerCase()) {
|
|
44
|
-
const contact = {
|
|
45
|
-
address: order.order.dataset.toLowerCase(),
|
|
46
|
-
owner: order.signer.toLowerCase(),
|
|
47
|
-
accessGrantTimestamp: order.publicationTimestamp,
|
|
48
|
-
};
|
|
49
|
-
myContacts.push(contact);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const validContacts = yield getValidContact(graphQLClient, myContacts);
|
|
53
|
-
return validContacts;
|
|
54
23
|
}
|
|
55
24
|
catch (error) {
|
|
56
25
|
throw new WorkflowError(`Failed to fetch my contacts: ${error.message}`, error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchMyContacts.js","sourceRoot":"","sources":["../../src/web3mail/fetchMyContacts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"fetchMyContacts.js","sourceRoot":"","sources":["../../src/web3mail/fetchMyContacts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAS3D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAO,EACpC,aAAa,GAAG,cAAc,EAAE,EAChC,KAAK,GAAG,cAAc,EAAE,EACxB,gBAAgB,GAAG,cAAc,EAAE,EACnC,oBAAoB,GAAG,cAAc,EAAE,GAIX,EAAsB,EAAE;IACpD,IAAI;QACF,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACpD,OAAO,MAAM,iBAAiB,CAAC;YAC7B,KAAK;YACL,aAAa;YACb,gBAAgB;YAChB,oBAAoB;YACpB,WAAW;SACZ,CAAC,CAAC;KACJ;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,aAAa,CACrB,gCAAgC,KAAK,CAAC,OAAO,EAAE,EAC/C,KAAK,CACN,CAAC;KACH;AACH,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Contact, DappAddressConsumer, DappWhitelistAddressConsumer, FetchUserContactsParams, IExecConsumer, SubgraphConsumer } from './types.js';
|
|
2
|
+
export declare const fetchUserContacts: ({ graphQLClient, iexec, dappAddressOrENS, dappWhitelistAddress, userAddress, }: IExecConsumer & SubgraphConsumer & DappAddressConsumer & DappWhitelistAddressConsumer & FetchUserContactsParams) => Promise<Contact[]>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { ANY_DATASET_ADDRESS } from '../config/config.js';
|
|
11
|
+
import { WorkflowError } from '../utils/errors.js';
|
|
12
|
+
import { autoPaginateRequest } from '../utils/paginate.js';
|
|
13
|
+
import { getValidContact } from '../utils/subgraphQuery.js';
|
|
14
|
+
import { addressOrEnsSchema, addressSchema, isEnsTest, throwIfMissing, } from '../utils/validators.js';
|
|
15
|
+
export const fetchUserContacts = ({ graphQLClient = throwIfMissing(), iexec = throwIfMissing(), dappAddressOrENS = throwIfMissing(), dappWhitelistAddress = throwIfMissing(), userAddress, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
try {
|
|
17
|
+
const vDappAddressOrENS = addressOrEnsSchema()
|
|
18
|
+
.required()
|
|
19
|
+
.label('dappAddressOrENS')
|
|
20
|
+
.validateSync(dappAddressOrENS);
|
|
21
|
+
const vDappWhitelistAddress = addressSchema()
|
|
22
|
+
.required()
|
|
23
|
+
.label('dappWhitelistAddress')
|
|
24
|
+
.validateSync(dappWhitelistAddress);
|
|
25
|
+
const vUserAddress = addressOrEnsSchema()
|
|
26
|
+
.required()
|
|
27
|
+
.label('userAddress')
|
|
28
|
+
.validateSync(userAddress);
|
|
29
|
+
const [dappOrders, whitelistOrders] = yield Promise.all([
|
|
30
|
+
fetchAllOrdersByApp({
|
|
31
|
+
iexec,
|
|
32
|
+
userAddress: vUserAddress,
|
|
33
|
+
appAddress: vDappAddressOrENS,
|
|
34
|
+
}),
|
|
35
|
+
fetchAllOrdersByApp({
|
|
36
|
+
iexec,
|
|
37
|
+
userAddress: vUserAddress,
|
|
38
|
+
appAddress: vDappWhitelistAddress,
|
|
39
|
+
}),
|
|
40
|
+
]);
|
|
41
|
+
const orders = dappOrders.concat(whitelistOrders);
|
|
42
|
+
const myContacts = [];
|
|
43
|
+
let web3DappResolvedAddress = vDappAddressOrENS;
|
|
44
|
+
if (isEnsTest(vDappAddressOrENS)) {
|
|
45
|
+
web3DappResolvedAddress = yield iexec.ens.resolveName(vDappAddressOrENS);
|
|
46
|
+
}
|
|
47
|
+
orders.forEach((order) => {
|
|
48
|
+
if (order.order.apprestrict.toLowerCase() ===
|
|
49
|
+
web3DappResolvedAddress.toLowerCase() ||
|
|
50
|
+
order.order.apprestrict.toLowerCase() ===
|
|
51
|
+
vDappWhitelistAddress.toLowerCase()) {
|
|
52
|
+
const contact = {
|
|
53
|
+
address: order.order.dataset.toLowerCase(),
|
|
54
|
+
owner: order.signer.toLowerCase(),
|
|
55
|
+
accessGrantTimestamp: order.publicationTimestamp,
|
|
56
|
+
};
|
|
57
|
+
myContacts.push(contact);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
//getValidContact function remove duplicated contacts for the same protectedData address,
|
|
61
|
+
//keeping the most recent one
|
|
62
|
+
return yield getValidContact(graphQLClient, myContacts);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
throw new WorkflowError(`Failed to fetch my contacts: ${error.message}`, error);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
function fetchAllOrdersByApp({ iexec, userAddress, appAddress }) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const ordersFirstPage = iexec.orderbook.fetchDatasetOrderbook(ANY_DATASET_ADDRESS, {
|
|
71
|
+
app: appAddress,
|
|
72
|
+
requester: userAddress,
|
|
73
|
+
// Use maxPageSize here to avoid too many round-trips (we want everything anyway)
|
|
74
|
+
pageSize: 1000,
|
|
75
|
+
});
|
|
76
|
+
const { orders: allOrders } = yield autoPaginateRequest({
|
|
77
|
+
request: ordersFirstPage,
|
|
78
|
+
});
|
|
79
|
+
return allOrders;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=fetchUserContacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchUserContacts.js","sourceRoot":"","sources":["../../src/web3mail/fetchUserContacts.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,SAAS,EACT,cAAc,GACf,MAAM,wBAAwB,CAAC;AAUhC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAO,EACtC,aAAa,GAAG,cAAc,EAAE,EAChC,KAAK,GAAG,cAAc,EAAE,EACxB,gBAAgB,GAAG,cAAc,EAAE,EACnC,oBAAoB,GAAG,cAAc,EAAE,EACvC,WAAW,GAKY,EAAsB,EAAE;IAC/C,IAAI;QACF,MAAM,iBAAiB,GAAG,kBAAkB,EAAE;aAC3C,QAAQ,EAAE;aACV,KAAK,CAAC,k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AAC,MAAM,CAAC,WAAW,EAAE;oBACjC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;iBACjD,CAAC;gBACF,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aAC1B;QACH,CAAC,CAAC,CAAC;QAEH,yFAAyF;QACzF,6BAA6B;QAC7B,OAAO,MAAM,eAAe,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;KACzD;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,aAAa,CACrB,gCAAgC,KAAK,CAAC,OAAO,EAAE,EAC/C,KAAK,CACN,CAAC;KACH;AACH,CAAC,CAAA,CAAC;AAEF,SAAe,mBAAmB,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE;;QACnE,MAAM,eAAe,GAAG,KAAK,CAAC,SAAS,CAAC,qBAAqB,CAC3D,mBAAmB,EACnB;YACE,GAAG,EAAE,UAAU;YACf,SAAS,EAAE,WAAW;YACtB,iFAAiF;YACjF,QAAQ,EAAE,IAAI;SACf,CACF,CAAC;QACF,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,mBAAmB,CAAC;YACtD,OAAO,EAAE,eAAe;SACzB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;IACnB,CAAC;CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IExecConsumer, SendEmailParams, SendEmailResponse, SubgraphConsumer } from './types.js';
|
|
2
|
-
export declare const sendEmail: ({ graphQLClient, iexec, emailSubject, emailContent, contentType, senderName, protectedData, }: IExecConsumer & SubgraphConsumer & SendEmailParams) => Promise<SendEmailResponse>;
|
|
1
|
+
import { DappAddressConsumer, DappWhitelistAddressConsumer, IExecConsumer, IpfsGatewayConfigConsumer, IpfsNodeConfigConsumer, SendEmailParams, SendEmailResponse, SubgraphConsumer } from './types.js';
|
|
2
|
+
export declare const sendEmail: ({ graphQLClient, iexec, workerpoolAddressOrEns, dappAddressOrENS, dappWhitelistAddress, ipfsNode, ipfsGateway, emailSubject, emailContent, contentType, label, dataMaxPrice, appMaxPrice, workerpoolMaxPrice, senderName, protectedData, }: IExecConsumer & SubgraphConsumer & DappAddressConsumer & DappWhitelistAddressConsumer & IpfsNodeConfigConsumer & IpfsGatewayConfigConsumer & SendEmailParams) => Promise<SendEmailResponse>;
|