@iexec/web3mail 1.0.4 → 1.1.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 +1 -1
- package/dist/config/config.js +1 -1
- package/dist/config/config.js.map +1 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/validators.js +1 -1
- package/dist/utils/validators.js.map +1 -1
- package/dist/web3mail/IExecWeb3mail.js +1 -0
- package/dist/web3mail/IExecWeb3mail.js.map +1 -1
- package/dist/web3mail/fetchMyContacts.d.ts +1 -0
- package/dist/web3mail/fetchMyContacts.js.map +1 -1
- package/dist/web3mail/fetchUserContacts.js +15 -15
- package/dist/web3mail/fetchUserContacts.js.map +1 -1
- package/dist/web3mail/sendEmail.d.ts +2 -1
- package/dist/web3mail/sendEmail.js +102 -64
- package/dist/web3mail/sendEmail.js.map +1 -1
- package/dist/web3mail/sendEmail.models.d.ts +36 -0
- package/dist/web3mail/sendEmail.models.js +37 -0
- package/dist/web3mail/sendEmail.models.js.map +1 -0
- package/dist/web3mail/types.d.ts +1 -0
- package/package.json +11 -6
- package/src/config/config.ts +1 -1
- package/src/utils/errors.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/validators.ts +2 -1
- package/src/web3mail/IExecWeb3mail.ts +1 -0
- package/src/web3mail/fetchMyContacts.ts +2 -0
- package/src/web3mail/fetchUserContacts.ts +16 -16
- package/src/web3mail/sendEmail.models.ts +90 -0
- package/src/web3mail/sendEmail.ts +121 -72
- package/src/web3mail/types.ts +1 -0
package/dist/config/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const WEB3_MAIL_DAPP_ADDRESS = "web3mail.apps.iexec.eth";
|
|
2
2
|
export declare const PROD_WORKERPOOL_ADDRESS = "prod-v8-bellecour.main.pools.iexec.eth";
|
|
3
|
-
export declare const DATAPROTECTOR_SUBGRAPH_ENDPOINT = "https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector";
|
|
3
|
+
export declare const DATAPROTECTOR_SUBGRAPH_ENDPOINT = "https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector-v2";
|
|
4
4
|
export declare const MAX_DESIRED_DATA_ORDER_PRICE = 0;
|
|
5
5
|
export declare const MAX_DESIRED_APP_ORDER_PRICE = 0;
|
|
6
6
|
export declare const MAX_DESIRED_WORKERPOOL_ORDER_PRICE = 0;
|
package/dist/config/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const WEB3_MAIL_DAPP_ADDRESS = 'web3mail.apps.iexec.eth';
|
|
2
2
|
export const PROD_WORKERPOOL_ADDRESS = 'prod-v8-bellecour.main.pools.iexec.eth';
|
|
3
|
-
export const DATAPROTECTOR_SUBGRAPH_ENDPOINT = 'https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector';
|
|
3
|
+
export const DATAPROTECTOR_SUBGRAPH_ENDPOINT = 'https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector-v2';
|
|
4
4
|
export const MAX_DESIRED_DATA_ORDER_PRICE = 0;
|
|
5
5
|
export const MAX_DESIRED_APP_ORDER_PRICE = 0;
|
|
6
6
|
export const MAX_DESIRED_WORKERPOOL_ORDER_PRICE = 0;
|
|
@@ -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,uBAAuB,GAAG,wCAAwC,CAAC;AAChF,MAAM,CAAC,MAAM,+BAA+B,GAC1C,
|
|
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,2EAA2E,CAAC;AAC9E,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.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,eAAe,CAAU;IAEzB,YAAY,EACV,OAAO,EACP,UAAU,EACV,eAAe,GAAG,KAAK,GAKxB;QACC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;CACF;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAY;IAChD,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;QAClC,MAAM,IAAI,aAAa,CAAC;YACtB,OAAO,EACL,+HAA+H;YACjI,UAAU,EAAE,KAAK;YACjB,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/utils/validators.js
CHANGED
|
@@ -30,5 +30,5 @@ export const senderNameSchema = () => string().trim().min(3).max(20).optional();
|
|
|
30
30
|
// Used to identify the email campaign, minimum of 3 characters and max of 10
|
|
31
31
|
export const labelSchema = () => string().trim().min(3).max(10).optional();
|
|
32
32
|
export const positiveNumberSchema = () => number().integer().min(0).typeError('${path} must be a non-negative number');
|
|
33
|
-
export const booleanSchema = () => boolean();
|
|
33
|
+
export const booleanSchema = () => boolean().strict().typeError('${path} should be a boolean');
|
|
34
34
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,KAAY,EAAE,EAAE;IACpD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,sBAAsB,EAAE,CAAC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,UAAU;SAC7B,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { Contact, DappAddressConsumer, DappWhitelistAddressConsumer, FetchMyContactsParams, IExecConsumer, SubgraphConsumer } from './types.js';
|
|
2
|
+
export type FetchMyContacts = typeof fetchMyContacts;
|
|
2
3
|
export declare const fetchMyContacts: ({ graphQLClient, iexec, dappAddressOrENS, dappWhitelistAddress, isUserStrict, }: IExecConsumer & SubgraphConsumer & DappAddressConsumer & DappWhitelistAddressConsumer & FetchMyContactsParams) => Promise<Contact[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchMyContacts.js","sourceRoot":"","sources":["../../src/web3mail/fetchMyContacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetchMyContacts.js","sourceRoot":"","sources":["../../src/web3mail/fetchMyContacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAY3D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,aAAa,GAAG,cAAc,EAAE,EAChC,KAAK,GAAG,cAAc,EAAE,EACxB,gBAAgB,GAAG,cAAc,EAAE,EACnC,oBAAoB,GAAG,cAAc,EAAE,EACvC,YAAY,GAAG,KAAK,GAKC,EAAsB,EAAE;IAC7C,MAAM,aAAa,GAAG,aAAa,EAAE;SAClC,KAAK,CAAC,cAAc,CAAC;SACrB,YAAY,CAAC,YAAY,CAAC,CAAC;IAE9B,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;IACpD,OAAO,iBAAiB,CAAC;QACvB,KAAK;QACL,aAAa;QACb,gBAAgB;QAChB,oBAAoB;QACpB,WAAW;QACX,YAAY,EAAE,aAAa;KAC5B,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -4,22 +4,22 @@ import { autoPaginateRequest } from '../utils/paginate.js';
|
|
|
4
4
|
import { getValidContact } from '../utils/subgraphQuery.js';
|
|
5
5
|
import { addressOrEnsSchema, addressSchema, booleanSchema, isEnsTest, throwIfMissing, } from '../utils/validators.js';
|
|
6
6
|
export const fetchUserContacts = async ({ graphQLClient = throwIfMissing(), iexec = throwIfMissing(), dappAddressOrENS = throwIfMissing(), dappWhitelistAddress = throwIfMissing(), userAddress, isUserStrict = false, }) => {
|
|
7
|
+
const vDappAddressOrENS = addressOrEnsSchema()
|
|
8
|
+
.required()
|
|
9
|
+
.label('dappAddressOrENS')
|
|
10
|
+
.validateSync(dappAddressOrENS);
|
|
11
|
+
const vDappWhitelistAddress = addressSchema()
|
|
12
|
+
.required()
|
|
13
|
+
.label('dappWhitelistAddress')
|
|
14
|
+
.validateSync(dappWhitelistAddress);
|
|
15
|
+
const vUserAddress = addressOrEnsSchema()
|
|
16
|
+
.required()
|
|
17
|
+
.label('userAddress')
|
|
18
|
+
.validateSync(userAddress);
|
|
19
|
+
const vIsUserStrict = booleanSchema()
|
|
20
|
+
.label('isUserStrict')
|
|
21
|
+
.validateSync(isUserStrict);
|
|
7
22
|
try {
|
|
8
|
-
const vDappAddressOrENS = addressOrEnsSchema()
|
|
9
|
-
.required()
|
|
10
|
-
.label('dappAddressOrENS')
|
|
11
|
-
.validateSync(dappAddressOrENS);
|
|
12
|
-
const vDappWhitelistAddress = addressSchema()
|
|
13
|
-
.required()
|
|
14
|
-
.label('dappWhitelistAddress')
|
|
15
|
-
.validateSync(dappWhitelistAddress);
|
|
16
|
-
const vUserAddress = addressOrEnsSchema()
|
|
17
|
-
.required()
|
|
18
|
-
.label('userAddress')
|
|
19
|
-
.validateSync(userAddress);
|
|
20
|
-
const vIsUserStrict = booleanSchema()
|
|
21
|
-
.label('isUserStrict')
|
|
22
|
-
.validateSync(isUserStrict);
|
|
23
23
|
const [dappOrders, whitelistOrders] = await Promise.all([
|
|
24
24
|
fetchAllOrdersByApp({
|
|
25
25
|
iexec,
|
|
@@ -1 +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,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,SAAS,EACT,cAAc,GACf,MAAM,wBAAwB,CAAC;AAUhC,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,aAAa,GAAG,cAAc,EAAE,EAChC,KAAK,GAAG,cAAc,EAAE,EACxB,gBAAgB,GAAG,cAAc,EAAE,EACnC,oBAAoB,GAAG,cAAc,EAAE,EACvC,WAAW,EACX,YAAY,GAAG,KAAK,GAKG,EAAsB,EAAE;IAC/C,
|
|
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,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,SAAS,EACT,cAAc,GACf,MAAM,wBAA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Y;QAC/B,iFAAiF;QACjF,QAAQ,EAAE,IAAI;KACf,CACF,CAAC;IACF,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,mBAAmB,CAAC;QACtD,OAAO,EAAE,eAAe;KACzB,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { DappAddressConsumer, DappWhitelistAddressConsumer, IExecConsumer, IpfsGatewayConfigConsumer, IpfsNodeConfigConsumer, SendEmailParams, SendEmailResponse, SubgraphConsumer } from './types.js';
|
|
2
|
-
export
|
|
2
|
+
export type SendEmail = typeof sendEmail;
|
|
3
|
+
export declare const sendEmail: ({ graphQLClient, iexec, workerpoolAddressOrEns, dappAddressOrENS, dappWhitelistAddress, ipfsNode, ipfsGateway, emailSubject, emailContent, contentType, label, dataMaxPrice, appMaxPrice, workerpoolMaxPrice, senderName, protectedData, useVoucher, }: IExecConsumer & SubgraphConsumer & DappAddressConsumer & DappWhitelistAddressConsumer & IpfsNodeConfigConsumer & IpfsGatewayConfigConsumer & SendEmailParams) => Promise<SendEmailResponse>;
|
|
@@ -4,56 +4,73 @@ import { handleIfProtocolError, WorkflowError } from '../utils/errors.js';
|
|
|
4
4
|
import { generateSecureUniqueId } from '../utils/generateUniqueId.js';
|
|
5
5
|
import * as ipfs from '../utils/ipfs-service.js';
|
|
6
6
|
import { checkProtectedDataValidity } from '../utils/subgraphQuery.js';
|
|
7
|
-
import { addressOrEnsSchema, addressSchema, contentTypeSchema, emailContentSchema, emailSubjectSchema, labelSchema, positiveNumberSchema, senderNameSchema, throwIfMissing, } from '../utils/validators.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
7
|
+
import { addressOrEnsSchema, addressSchema, booleanSchema, contentTypeSchema, emailContentSchema, emailSubjectSchema, labelSchema, positiveNumberSchema, senderNameSchema, throwIfMissing, } from '../utils/validators.js';
|
|
8
|
+
import { checkUserVoucher, filterWorkerpoolOrders, } from './sendEmail.models.js';
|
|
9
|
+
export const sendEmail = async ({ graphQLClient = throwIfMissing(), iexec = throwIfMissing(), workerpoolAddressOrEns = PROD_WORKERPOOL_ADDRESS, dappAddressOrENS, dappWhitelistAddress, ipfsNode, ipfsGateway, emailSubject, emailContent, contentType = DEFAULT_CONTENT_TYPE, label, dataMaxPrice = MAX_DESIRED_DATA_ORDER_PRICE, appMaxPrice = MAX_DESIRED_APP_ORDER_PRICE, workerpoolMaxPrice = MAX_DESIRED_WORKERPOOL_ORDER_PRICE, senderName, protectedData, useVoucher = false, }) => {
|
|
10
|
+
const vDatasetAddress = addressOrEnsSchema()
|
|
11
|
+
.required()
|
|
12
|
+
.label('protectedData')
|
|
13
|
+
.validateSync(protectedData);
|
|
14
|
+
const vEmailSubject = emailSubjectSchema()
|
|
15
|
+
.required()
|
|
16
|
+
.label('emailSubject')
|
|
17
|
+
.validateSync(emailSubject);
|
|
18
|
+
const vEmailContent = emailContentSchema()
|
|
19
|
+
.required()
|
|
20
|
+
.label('emailContent')
|
|
21
|
+
.validateSync(emailContent);
|
|
22
|
+
const vContentType = contentTypeSchema()
|
|
23
|
+
.required()
|
|
24
|
+
.label('contentType')
|
|
25
|
+
.validateSync(contentType);
|
|
26
|
+
const vSenderName = senderNameSchema()
|
|
27
|
+
.label('senderName')
|
|
28
|
+
.validateSync(senderName);
|
|
29
|
+
const vLabel = labelSchema().label('label').validateSync(label);
|
|
30
|
+
const vWorkerpoolAddressOrEns = addressOrEnsSchema()
|
|
31
|
+
.required()
|
|
32
|
+
.label('WorkerpoolAddressOrEns')
|
|
33
|
+
.validateSync(workerpoolAddressOrEns);
|
|
34
|
+
const vDappAddressOrENS = addressOrEnsSchema()
|
|
35
|
+
.required()
|
|
36
|
+
.label('dappAddressOrENS')
|
|
37
|
+
.validateSync(dappAddressOrENS);
|
|
38
|
+
const vDappWhitelistAddress = addressSchema()
|
|
39
|
+
.required()
|
|
40
|
+
.label('dappWhitelistAddress')
|
|
41
|
+
.validateSync(dappWhitelistAddress);
|
|
42
|
+
const vDataMaxPrice = positiveNumberSchema()
|
|
43
|
+
.label('dataMaxPrice')
|
|
44
|
+
.validateSync(dataMaxPrice);
|
|
45
|
+
const vAppMaxPrice = positiveNumberSchema()
|
|
46
|
+
.label('appMaxPrice')
|
|
47
|
+
.validateSync(appMaxPrice);
|
|
48
|
+
const vWorkerpoolMaxPrice = positiveNumberSchema()
|
|
49
|
+
.label('workerpoolMaxPrice')
|
|
50
|
+
.validateSync(workerpoolMaxPrice);
|
|
51
|
+
const vUseVoucher = booleanSchema()
|
|
52
|
+
.label('useVoucher')
|
|
53
|
+
.validateSync(useVoucher);
|
|
54
|
+
// Check protected data schema through subgraph
|
|
55
|
+
const isValidProtectedData = await checkProtectedDataValidity(graphQLClient, vDatasetAddress);
|
|
56
|
+
if (!isValidProtectedData) {
|
|
57
|
+
throw new Error('This protected data does not contain "email:string" in its schema.');
|
|
58
|
+
}
|
|
59
|
+
const requesterAddress = await iexec.wallet.getAddress();
|
|
60
|
+
let userVoucher;
|
|
61
|
+
if (vUseVoucher) {
|
|
62
|
+
try {
|
|
63
|
+
userVoucher = await iexec.voucher.showUserVoucher(requesterAddress);
|
|
64
|
+
checkUserVoucher({ userVoucher });
|
|
55
65
|
}
|
|
56
|
-
|
|
66
|
+
catch (err) {
|
|
67
|
+
if (err?.message?.startsWith('No Voucher found for address')) {
|
|
68
|
+
throw new Error('Oops, it seems your wallet is not associated with any voucher. Check on https://builder-dashboard.iex.ec/');
|
|
69
|
+
}
|
|
70
|
+
throw err;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
57
74
|
const [datasetorderForApp, datasetorderForWhitelist, apporder, workerpoolorder,] = await Promise.all([
|
|
58
75
|
// Fetch dataset order for web3mail app
|
|
59
76
|
iexec.orderbook
|
|
@@ -90,26 +107,47 @@ export const sendEmail = async ({ graphQLClient = throwIfMissing(), iexec = thro
|
|
|
90
107
|
}
|
|
91
108
|
return desiredPriceAppOrder;
|
|
92
109
|
}),
|
|
93
|
-
// Fetch workerpool order
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
// Fetch workerpool order for App or AppWhitelist
|
|
111
|
+
Promise.all([
|
|
112
|
+
// for app
|
|
113
|
+
iexec.orderbook.fetchWorkerpoolOrderbook({
|
|
114
|
+
workerpool: workerpoolAddressOrEns,
|
|
115
|
+
app: vDappAddressOrENS,
|
|
116
|
+
dataset: vDatasetAddress,
|
|
117
|
+
requester: requesterAddress, // public orders + user specific orders
|
|
118
|
+
minTag: ['tee', 'scone'],
|
|
119
|
+
maxTag: ['tee', 'scone'],
|
|
120
|
+
category: 0,
|
|
121
|
+
}),
|
|
122
|
+
// for app whitelist
|
|
123
|
+
iexec.orderbook.fetchWorkerpoolOrderbook({
|
|
124
|
+
workerpool: workerpoolAddressOrEns,
|
|
125
|
+
app: vDappWhitelistAddress,
|
|
126
|
+
dataset: vDatasetAddress,
|
|
127
|
+
requester: requesterAddress, // public orders + user specific orders
|
|
128
|
+
minTag: ['tee', 'scone'],
|
|
129
|
+
maxTag: ['tee', 'scone'],
|
|
130
|
+
category: 0,
|
|
131
|
+
}),
|
|
132
|
+
]).then(([workerpoolOrderbookForApp, workerpoolOrderbookForAppWhitelist]) => {
|
|
133
|
+
const desiredPriceWorkerpoolOrder = filterWorkerpoolOrders({
|
|
134
|
+
workerpoolOrders: [
|
|
135
|
+
...workerpoolOrderbookForApp.orders,
|
|
136
|
+
...workerpoolOrderbookForAppWhitelist.orders,
|
|
137
|
+
],
|
|
138
|
+
workerpoolMaxPrice: vWorkerpoolMaxPrice,
|
|
139
|
+
useVoucher: vUseVoucher,
|
|
140
|
+
userVoucher,
|
|
141
|
+
});
|
|
107
142
|
if (!desiredPriceWorkerpoolOrder) {
|
|
108
143
|
throw new Error('No Workerpool order found for the desired price');
|
|
109
144
|
}
|
|
110
145
|
return desiredPriceWorkerpoolOrder;
|
|
111
146
|
}),
|
|
112
147
|
]);
|
|
148
|
+
if (!workerpoolorder) {
|
|
149
|
+
throw new Error('No Workerpool order found for the desired price');
|
|
150
|
+
}
|
|
113
151
|
const datasetorder = datasetorderForApp || datasetorderForWhitelist;
|
|
114
152
|
if (!datasetorder) {
|
|
115
153
|
throw new Error('No Dataset order found for the desired price');
|
|
@@ -168,7 +206,7 @@ export const sendEmail = async ({ graphQLClient = throwIfMissing(), iexec = thro
|
|
|
168
206
|
datasetorder: datasetorder,
|
|
169
207
|
workerpoolorder: workerpoolorder,
|
|
170
208
|
requestorder: requestorder,
|
|
171
|
-
});
|
|
209
|
+
}, { useVoucher: vUseVoucher });
|
|
172
210
|
const taskId = await iexec.deal.computeTaskId(dealid, 0);
|
|
173
211
|
return {
|
|
174
212
|
taskId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendEmail.js","sourceRoot":"","sources":["../../src/web3mail/sendEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,M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E,YAAY;SAC3B,EACD,EAAE,UAAU,EAAE,WAAW,EAAE,CAC5B,CAAC;QACF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAEzD,OAAO;YACL,MAAM;SACP,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAE7B,MAAM,IAAI,aAAa,CAAC;YACtB,OAAO,EAAE,qBAAqB;YAC9B,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Address, BN } from 'iexec';
|
|
2
|
+
import { PublishedWorkerpoolorder } from 'iexec/IExecOrderbookModule';
|
|
3
|
+
type VoucherInfo = {
|
|
4
|
+
owner: Address;
|
|
5
|
+
address: Address;
|
|
6
|
+
type: BN;
|
|
7
|
+
balance: BN;
|
|
8
|
+
expirationTimestamp: BN;
|
|
9
|
+
sponsoredApps: Address[];
|
|
10
|
+
sponsoredDatasets: Address[];
|
|
11
|
+
sponsoredWorkerpools: Address[];
|
|
12
|
+
allowanceAmount: BN;
|
|
13
|
+
authorizedAccounts: Address[];
|
|
14
|
+
};
|
|
15
|
+
export declare function checkUserVoucher({ userVoucher, }: {
|
|
16
|
+
userVoucher: VoucherInfo;
|
|
17
|
+
}): void;
|
|
18
|
+
export declare function filterWorkerpoolOrders({ workerpoolOrders, workerpoolMaxPrice, useVoucher, userVoucher, }: {
|
|
19
|
+
workerpoolOrders: PublishedWorkerpoolorder[];
|
|
20
|
+
workerpoolMaxPrice: number;
|
|
21
|
+
useVoucher: boolean;
|
|
22
|
+
userVoucher?: VoucherInfo;
|
|
23
|
+
}): {
|
|
24
|
+
workerpool: Address;
|
|
25
|
+
workerpoolprice: number;
|
|
26
|
+
volume: number;
|
|
27
|
+
tag: import("iexec").Bytes32;
|
|
28
|
+
category: number;
|
|
29
|
+
trust: number;
|
|
30
|
+
apprestrict: Address;
|
|
31
|
+
datasetrestrict: Address;
|
|
32
|
+
requesterrestrict: Address;
|
|
33
|
+
salt: import("iexec").Bytes32;
|
|
34
|
+
sign: import("iexec").Bytes;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function bnToNumber(bn) {
|
|
2
|
+
return Number(bn.toString());
|
|
3
|
+
}
|
|
4
|
+
export function checkUserVoucher({ userVoucher, }) {
|
|
5
|
+
if (bnToNumber(userVoucher.expirationTimestamp) < Date.now() / 1000) {
|
|
6
|
+
throw new Error('Oops, it seems your voucher has expired. You might want to ask for a top up. Check on https://builder-dashboard.iex.ec/');
|
|
7
|
+
}
|
|
8
|
+
if (bnToNumber(userVoucher.balance) === 0) {
|
|
9
|
+
throw new Error('Oops, it seems your voucher is empty. You might want to ask for a top up. Check on https://builder-dashboard.iex.ec/');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function filterWorkerpoolOrders({ workerpoolOrders, workerpoolMaxPrice, useVoucher, userVoucher, }) {
|
|
13
|
+
if (workerpoolOrders.length === 0) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
let eligibleWorkerpoolOrders = workerpoolOrders;
|
|
17
|
+
let maxVoucherSponsoredAmount = 0; // may be safer to use bigint
|
|
18
|
+
if (useVoucher) {
|
|
19
|
+
if (!userVoucher) {
|
|
20
|
+
throw new Error('useVoucher === true but userVoucher is undefined? Hum...');
|
|
21
|
+
}
|
|
22
|
+
// only voucher sponsored workerpoolorders
|
|
23
|
+
eligibleWorkerpoolOrders = eligibleWorkerpoolOrders.filter(({ order }) => userVoucher.sponsoredWorkerpools.includes(order.workerpool));
|
|
24
|
+
if (eligibleWorkerpoolOrders.length === 0) {
|
|
25
|
+
throw new Error('Found some workerpool orders but none can be sponsored by your voucher.');
|
|
26
|
+
}
|
|
27
|
+
maxVoucherSponsoredAmount = bnToNumber(userVoucher.balance);
|
|
28
|
+
}
|
|
29
|
+
const [cheapestOrder] = eligibleWorkerpoolOrders.sort((order1, order2) => order1.order.workerpoolprice - order2.order.workerpoolprice);
|
|
30
|
+
if (!cheapestOrder ||
|
|
31
|
+
cheapestOrder.order.workerpoolprice >
|
|
32
|
+
workerpoolMaxPrice + maxVoucherSponsoredAmount) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return cheapestOrder.order;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=sendEmail.models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendEmail.models.js","sourceRoot":"","sources":["../../src/web3mail/sendEmail.models.ts"],"names":[],"mappings":"AAkBA,SAAS,UAAU,CAAC,EAAM;IACxB,OAAO,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAC/B,WAAW,GAGZ;IACC,IAAI,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CACb,yHAAyH,CAC1H,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACb,sHAAsH,CACvH,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,EACrC,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,WAAW,GAMZ;IACC,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,wBAAwB,GAAG,gBAAgB,CAAC;IAChD,IAAI,yBAAyB,GAAG,CAAC,CAAC,CAAC,6BAA6B;IAEhE,IAAI,UAAU,EAAE,CAAC;QACf,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;QACJ,CAAC;QACD,0CAA0C;QAC1C,wBAAwB,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACvE,WAAW,CAAC,oBAAoB,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAC5D,CAAC;QACF,IAAI,wBAAwB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;QACJ,CAAC;QACD,yBAAyB,GAAG,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,GAAG,wBAAwB,CAAC,IAAI,CACnD,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CACjB,MAAM,CAAC,KAAK,CAAC,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAC9D,CAAC;IAEF,IACE,CAAC,aAAa;QACd,aAAa,CAAC,KAAK,CAAC,eAAe;YACjC,kBAAkB,GAAG,yBAAyB,EAChD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,aAAa,CAAC,KAAK,CAAC;AAC7B,CAAC"}
|
package/dist/web3mail/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iexec/web3mail",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "This product enables users to confidentially store data–such as mail address, documents, personal information ...",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,13 +20,18 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "rm -rf dist && tsc --project tsconfig.build.json",
|
|
22
22
|
"check-types": "tsc --noEmit",
|
|
23
|
-
"test": "
|
|
23
|
+
"test:prepare": "node tests/scripts/prepare-bellecour-fork-for-tests.js",
|
|
24
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testMatch \"**/tests/**/*.test.ts\" --forceExit -b",
|
|
25
|
+
"test:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --testMatch \"**/tests/**/*.test.ts\" --forceExit --coverage",
|
|
26
|
+
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --testMatch \"**/tests/unit/**/*.test.ts\" -b",
|
|
27
|
+
"test:unit:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --testMatch \"**/tests/unit/**/*.unit.ts\" --coverage",
|
|
28
|
+
"test:e2e": "NODE_OPTIONS=--experimental-vm-modules jest --testMatch \"**/tests/**/*.test.ts\" --forceExit -b",
|
|
29
|
+
"test:e2e:coverage": "NODE_OPTIONS=--experimental-vm-modules jest --testMatch \"**/tests/**/*.test.ts\" --coverage",
|
|
24
30
|
"lint": "eslint .",
|
|
25
31
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
26
32
|
"check-format": "prettier --check \"src/**/*.ts\"",
|
|
27
|
-
"prepare-test-env": "cd tests && node prepare-test-env.js",
|
|
28
33
|
"stop-test-stack": "cd tests && docker compose down --volumes --remove-orphans",
|
|
29
|
-
"start-test-stack": "cd tests && npm run stop-test-stack &&
|
|
34
|
+
"start-test-stack": "cd tests && npm run stop-test-stack && node scripts/prepare-test-env.js && docker compose build && docker compose up -d && node scripts/prepare-bellecour-fork-for-tests.js"
|
|
30
35
|
},
|
|
31
36
|
"repository": {
|
|
32
37
|
"type": "git",
|
|
@@ -47,12 +52,12 @@
|
|
|
47
52
|
"buffer": "^6.0.3",
|
|
48
53
|
"ethers": "^6.13.2",
|
|
49
54
|
"graphql-request": "^6.1.0",
|
|
50
|
-
"iexec": "^8.
|
|
55
|
+
"iexec": "^8.12.0",
|
|
51
56
|
"kubo-rpc-client": "^4.1.1",
|
|
52
57
|
"yup": "^1.1.1"
|
|
53
58
|
},
|
|
54
59
|
"devDependencies": {
|
|
55
|
-
"@iexec/dataprotector": "^0.
|
|
60
|
+
"@iexec/dataprotector": "^2.0.0-beta.8",
|
|
56
61
|
"@jest/globals": "^29.7.0",
|
|
57
62
|
"@swc/core": "^1.3.96",
|
|
58
63
|
"@swc/jest": "^0.2.29",
|
package/src/config/config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const WEB3_MAIL_DAPP_ADDRESS = 'web3mail.apps.iexec.eth';
|
|
2
2
|
export const PROD_WORKERPOOL_ADDRESS = 'prod-v8-bellecour.main.pools.iexec.eth';
|
|
3
3
|
export const DATAPROTECTOR_SUBGRAPH_ENDPOINT =
|
|
4
|
-
'https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector';
|
|
4
|
+
'https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector-v2';
|
|
5
5
|
export const MAX_DESIRED_DATA_ORDER_PRICE = 0;
|
|
6
6
|
export const MAX_DESIRED_APP_ORDER_PRICE = 0;
|
|
7
7
|
export const MAX_DESIRED_WORKERPOOL_ORDER_PRICE = 0;
|
package/src/utils/errors.ts
CHANGED
package/src/utils/index.ts
CHANGED
package/src/utils/validators.ts
CHANGED
|
@@ -59,4 +59,5 @@ export const labelSchema = () => string().trim().min(3).max(10).optional();
|
|
|
59
59
|
export const positiveNumberSchema = () =>
|
|
60
60
|
number().integer().min(0).typeError('${path} must be a non-negative number');
|
|
61
61
|
|
|
62
|
-
export const booleanSchema = () =>
|
|
62
|
+
export const booleanSchema = () =>
|
|
63
|
+
boolean().strict().typeError('${path} should be a boolean');
|
|
@@ -30,23 +30,23 @@ export const fetchUserContacts = async ({
|
|
|
30
30
|
DappAddressConsumer &
|
|
31
31
|
DappWhitelistAddressConsumer &
|
|
32
32
|
FetchUserContactsParams): Promise<Contact[]> => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
.validateSync(isUserStrict);
|
|
33
|
+
const vDappAddressOrENS = addressOrEnsSchema()
|
|
34
|
+
.required()
|
|
35
|
+
.label('dappAddressOrENS')
|
|
36
|
+
.validateSync(dappAddressOrENS);
|
|
37
|
+
const vDappWhitelistAddress = addressSchema()
|
|
38
|
+
.required()
|
|
39
|
+
.label('dappWhitelistAddress')
|
|
40
|
+
.validateSync(dappWhitelistAddress);
|
|
41
|
+
const vUserAddress = addressOrEnsSchema()
|
|
42
|
+
.required()
|
|
43
|
+
.label('userAddress')
|
|
44
|
+
.validateSync(userAddress);
|
|
45
|
+
const vIsUserStrict = booleanSchema()
|
|
46
|
+
.label('isUserStrict')
|
|
47
|
+
.validateSync(isUserStrict);
|
|
49
48
|
|
|
49
|
+
try {
|
|
50
50
|
const [dappOrders, whitelistOrders] = await Promise.all([
|
|
51
51
|
fetchAllOrdersByApp({
|
|
52
52
|
iexec,
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Address, BN } from 'iexec';
|
|
2
|
+
import { PublishedWorkerpoolorder } from 'iexec/IExecOrderbookModule';
|
|
3
|
+
// import { VoucherInfo } from 'iexec/IExecVoucherModule';
|
|
4
|
+
|
|
5
|
+
// To import from 'iexec' once exported
|
|
6
|
+
type VoucherInfo = {
|
|
7
|
+
owner: Address;
|
|
8
|
+
address: Address;
|
|
9
|
+
type: BN;
|
|
10
|
+
balance: BN;
|
|
11
|
+
expirationTimestamp: BN;
|
|
12
|
+
sponsoredApps: Address[];
|
|
13
|
+
sponsoredDatasets: Address[];
|
|
14
|
+
sponsoredWorkerpools: Address[];
|
|
15
|
+
allowanceAmount: BN;
|
|
16
|
+
authorizedAccounts: Address[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function bnToNumber(bn: BN) {
|
|
20
|
+
return Number(bn.toString());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function checkUserVoucher({
|
|
24
|
+
userVoucher,
|
|
25
|
+
}: {
|
|
26
|
+
userVoucher: VoucherInfo;
|
|
27
|
+
}) {
|
|
28
|
+
if (bnToNumber(userVoucher.expirationTimestamp) < Date.now() / 1000) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
'Oops, it seems your voucher has expired. You might want to ask for a top up. Check on https://builder-dashboard.iex.ec/'
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (bnToNumber(userVoucher.balance) === 0) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
'Oops, it seems your voucher is empty. You might want to ask for a top up. Check on https://builder-dashboard.iex.ec/'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function filterWorkerpoolOrders({
|
|
42
|
+
workerpoolOrders,
|
|
43
|
+
workerpoolMaxPrice,
|
|
44
|
+
useVoucher,
|
|
45
|
+
userVoucher,
|
|
46
|
+
}: {
|
|
47
|
+
workerpoolOrders: PublishedWorkerpoolorder[];
|
|
48
|
+
workerpoolMaxPrice: number;
|
|
49
|
+
useVoucher: boolean;
|
|
50
|
+
userVoucher?: VoucherInfo;
|
|
51
|
+
}) {
|
|
52
|
+
if (workerpoolOrders.length === 0) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let eligibleWorkerpoolOrders = workerpoolOrders;
|
|
57
|
+
let maxVoucherSponsoredAmount = 0; // may be safer to use bigint
|
|
58
|
+
|
|
59
|
+
if (useVoucher) {
|
|
60
|
+
if (!userVoucher) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
'useVoucher === true but userVoucher is undefined? Hum...'
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
// only voucher sponsored workerpoolorders
|
|
66
|
+
eligibleWorkerpoolOrders = eligibleWorkerpoolOrders.filter(({ order }) =>
|
|
67
|
+
userVoucher.sponsoredWorkerpools.includes(order.workerpool)
|
|
68
|
+
);
|
|
69
|
+
if (eligibleWorkerpoolOrders.length === 0) {
|
|
70
|
+
throw new Error(
|
|
71
|
+
'Found some workerpool orders but none can be sponsored by your voucher.'
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
maxVoucherSponsoredAmount = bnToNumber(userVoucher.balance);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const [cheapestOrder] = eligibleWorkerpoolOrders.sort(
|
|
78
|
+
(order1, order2) =>
|
|
79
|
+
order1.order.workerpoolprice - order2.order.workerpoolprice
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
if (
|
|
83
|
+
!cheapestOrder ||
|
|
84
|
+
cheapestOrder.order.workerpoolprice >
|
|
85
|
+
workerpoolMaxPrice + maxVoucherSponsoredAmount
|
|
86
|
+
) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return cheapestOrder.order;
|
|
90
|
+
}
|
|
@@ -13,6 +13,7 @@ import { checkProtectedDataValidity } from '../utils/subgraphQuery.js';
|
|
|
13
13
|
import {
|
|
14
14
|
addressOrEnsSchema,
|
|
15
15
|
addressSchema,
|
|
16
|
+
booleanSchema,
|
|
16
17
|
contentTypeSchema,
|
|
17
18
|
emailContentSchema,
|
|
18
19
|
emailSubjectSchema,
|
|
@@ -21,6 +22,10 @@ import {
|
|
|
21
22
|
senderNameSchema,
|
|
22
23
|
throwIfMissing,
|
|
23
24
|
} from '../utils/validators.js';
|
|
25
|
+
import {
|
|
26
|
+
checkUserVoucher,
|
|
27
|
+
filterWorkerpoolOrders,
|
|
28
|
+
} from './sendEmail.models.js';
|
|
24
29
|
import {
|
|
25
30
|
DappAddressConsumer,
|
|
26
31
|
DappWhitelistAddressConsumer,
|
|
@@ -32,6 +37,8 @@ import {
|
|
|
32
37
|
SubgraphConsumer,
|
|
33
38
|
} from './types.js';
|
|
34
39
|
|
|
40
|
+
export type SendEmail = typeof sendEmail;
|
|
41
|
+
|
|
35
42
|
export const sendEmail = async ({
|
|
36
43
|
graphQLClient = throwIfMissing(),
|
|
37
44
|
iexec = throwIfMissing(),
|
|
@@ -49,6 +56,7 @@ export const sendEmail = async ({
|
|
|
49
56
|
workerpoolMaxPrice = MAX_DESIRED_WORKERPOOL_ORDER_PRICE,
|
|
50
57
|
senderName,
|
|
51
58
|
protectedData,
|
|
59
|
+
useVoucher = false,
|
|
52
60
|
}: IExecConsumer &
|
|
53
61
|
SubgraphConsumer &
|
|
54
62
|
DappAddressConsumer &
|
|
@@ -56,60 +64,80 @@ export const sendEmail = async ({
|
|
|
56
64
|
IpfsNodeConfigConsumer &
|
|
57
65
|
IpfsGatewayConfigConsumer &
|
|
58
66
|
SendEmailParams): Promise<SendEmailResponse> => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
67
|
+
const vDatasetAddress = addressOrEnsSchema()
|
|
68
|
+
.required()
|
|
69
|
+
.label('protectedData')
|
|
70
|
+
.validateSync(protectedData);
|
|
71
|
+
const vEmailSubject = emailSubjectSchema()
|
|
72
|
+
.required()
|
|
73
|
+
.label('emailSubject')
|
|
74
|
+
.validateSync(emailSubject);
|
|
75
|
+
const vEmailContent = emailContentSchema()
|
|
76
|
+
.required()
|
|
77
|
+
.label('emailContent')
|
|
78
|
+
.validateSync(emailContent);
|
|
79
|
+
const vContentType = contentTypeSchema()
|
|
80
|
+
.required()
|
|
81
|
+
.label('contentType')
|
|
82
|
+
.validateSync(contentType);
|
|
83
|
+
const vSenderName = senderNameSchema()
|
|
84
|
+
.label('senderName')
|
|
85
|
+
.validateSync(senderName);
|
|
86
|
+
const vLabel = labelSchema().label('label').validateSync(label);
|
|
87
|
+
const vWorkerpoolAddressOrEns = addressOrEnsSchema()
|
|
88
|
+
.required()
|
|
89
|
+
.label('WorkerpoolAddressOrEns')
|
|
90
|
+
.validateSync(workerpoolAddressOrEns);
|
|
91
|
+
const vDappAddressOrENS = addressOrEnsSchema()
|
|
92
|
+
.required()
|
|
93
|
+
.label('dappAddressOrENS')
|
|
94
|
+
.validateSync(dappAddressOrENS);
|
|
95
|
+
const vDappWhitelistAddress = addressSchema()
|
|
96
|
+
.required()
|
|
97
|
+
.label('dappWhitelistAddress')
|
|
98
|
+
.validateSync(dappWhitelistAddress);
|
|
99
|
+
const vDataMaxPrice = positiveNumberSchema()
|
|
100
|
+
.label('dataMaxPrice')
|
|
101
|
+
.validateSync(dataMaxPrice);
|
|
102
|
+
const vAppMaxPrice = positiveNumberSchema()
|
|
103
|
+
.label('appMaxPrice')
|
|
104
|
+
.validateSync(appMaxPrice);
|
|
105
|
+
const vWorkerpoolMaxPrice = positiveNumberSchema()
|
|
106
|
+
.label('workerpoolMaxPrice')
|
|
107
|
+
.validateSync(workerpoolMaxPrice);
|
|
108
|
+
const vUseVoucher = booleanSchema()
|
|
109
|
+
.label('useVoucher')
|
|
110
|
+
.validateSync(useVoucher);
|
|
101
111
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
// Check protected data schema through subgraph
|
|
113
|
+
const isValidProtectedData = await checkProtectedDataValidity(
|
|
114
|
+
graphQLClient,
|
|
115
|
+
vDatasetAddress
|
|
116
|
+
);
|
|
117
|
+
if (!isValidProtectedData) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
'This protected data does not contain "email:string" in its schema.'
|
|
106
120
|
);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const requesterAddress = await iexec.wallet.getAddress();
|
|
110
124
|
|
|
111
|
-
|
|
125
|
+
let userVoucher;
|
|
126
|
+
if (vUseVoucher) {
|
|
127
|
+
try {
|
|
128
|
+
userVoucher = await iexec.voucher.showUserVoucher(requesterAddress);
|
|
129
|
+
checkUserVoucher({ userVoucher });
|
|
130
|
+
} catch (err) {
|
|
131
|
+
if (err?.message?.startsWith('No Voucher found for address')) {
|
|
132
|
+
throw new Error(
|
|
133
|
+
'Oops, it seems your wallet is not associated with any voucher. Check on https://builder-dashboard.iex.ec/'
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
throw err;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
112
139
|
|
|
140
|
+
try {
|
|
113
141
|
const [
|
|
114
142
|
datasetorderForApp,
|
|
115
143
|
datasetorderForWhitelist,
|
|
@@ -157,33 +185,51 @@ export const sendEmail = async ({
|
|
|
157
185
|
}
|
|
158
186
|
return desiredPriceAppOrder;
|
|
159
187
|
}),
|
|
160
|
-
// Fetch workerpool order
|
|
161
|
-
|
|
162
|
-
|
|
188
|
+
// Fetch workerpool order for App or AppWhitelist
|
|
189
|
+
Promise.all([
|
|
190
|
+
// for app
|
|
191
|
+
iexec.orderbook.fetchWorkerpoolOrderbook({
|
|
163
192
|
workerpool: workerpoolAddressOrEns,
|
|
164
|
-
app:
|
|
193
|
+
app: vDappAddressOrENS,
|
|
165
194
|
dataset: vDatasetAddress,
|
|
195
|
+
requester: requesterAddress, // public orders + user specific orders
|
|
166
196
|
minTag: ['tee', 'scone'],
|
|
167
197
|
maxTag: ['tee', 'scone'],
|
|
168
198
|
category: 0,
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
199
|
+
}),
|
|
200
|
+
// for app whitelist
|
|
201
|
+
iexec.orderbook.fetchWorkerpoolOrderbook({
|
|
202
|
+
workerpool: workerpoolAddressOrEns,
|
|
203
|
+
app: vDappWhitelistAddress,
|
|
204
|
+
dataset: vDatasetAddress,
|
|
205
|
+
requester: requesterAddress, // public orders + user specific orders
|
|
206
|
+
minTag: ['tee', 'scone'],
|
|
207
|
+
maxTag: ['tee', 'scone'],
|
|
208
|
+
category: 0,
|
|
209
|
+
}),
|
|
210
|
+
]).then(
|
|
211
|
+
([workerpoolOrderbookForApp, workerpoolOrderbookForAppWhitelist]) => {
|
|
212
|
+
const desiredPriceWorkerpoolOrder = filterWorkerpoolOrders({
|
|
213
|
+
workerpoolOrders: [
|
|
214
|
+
...workerpoolOrderbookForApp.orders,
|
|
215
|
+
...workerpoolOrderbookForAppWhitelist.orders,
|
|
216
|
+
],
|
|
217
|
+
workerpoolMaxPrice: vWorkerpoolMaxPrice,
|
|
218
|
+
useVoucher: vUseVoucher,
|
|
219
|
+
userVoucher,
|
|
220
|
+
});
|
|
180
221
|
if (!desiredPriceWorkerpoolOrder) {
|
|
181
222
|
throw new Error('No Workerpool order found for the desired price');
|
|
182
223
|
}
|
|
183
224
|
return desiredPriceWorkerpoolOrder;
|
|
184
|
-
}
|
|
225
|
+
}
|
|
226
|
+
),
|
|
185
227
|
]);
|
|
186
228
|
|
|
229
|
+
if (!workerpoolorder) {
|
|
230
|
+
throw new Error('No Workerpool order found for the desired price');
|
|
231
|
+
}
|
|
232
|
+
|
|
187
233
|
const datasetorder = datasetorderForApp || datasetorderForWhitelist;
|
|
188
234
|
if (!datasetorder) {
|
|
189
235
|
throw new Error('No Dataset order found for the desired price');
|
|
@@ -244,12 +290,15 @@ export const sendEmail = async ({
|
|
|
244
290
|
const requestorder = await iexec.order.signRequestorder(requestorderToSign);
|
|
245
291
|
|
|
246
292
|
// Match orders and compute task ID
|
|
247
|
-
const { dealid } = await iexec.order.matchOrders(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
293
|
+
const { dealid } = await iexec.order.matchOrders(
|
|
294
|
+
{
|
|
295
|
+
apporder: apporder,
|
|
296
|
+
datasetorder: datasetorder,
|
|
297
|
+
workerpoolorder: workerpoolorder,
|
|
298
|
+
requestorder: requestorder,
|
|
299
|
+
},
|
|
300
|
+
{ useVoucher: vUseVoucher }
|
|
301
|
+
);
|
|
253
302
|
const taskId = await iexec.deal.computeTaskId(dealid, 0);
|
|
254
303
|
|
|
255
304
|
return {
|