Skip to content

Commit cda6190

Browse files
Merge pull request #183 from iExecBlockchainComputing/feature/dapp/add-checkEmailPreviousCheck-and-add-Callbackresult
Feature/dapp/add check email previous check and add callbackresult
2 parents cf84318 + 9f5ef52 commit cda6190

File tree

11 files changed

+427
-43
lines changed

11 files changed

+427
-43
lines changed

.drone.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ steps:
560560
- npm run check-format
561561

562562
- name: lint
563-
image: node:18.19
563+
image: node:14-alpine3.11
564564
commands:
565565
- cd dapp
566566
- npm run lint
@@ -576,6 +576,8 @@ steps:
576576
from_secret: mj_sender
577577
MAILGUN_APIKEY:
578578
from_secret: mailgun_apikey
579+
WEB3MAIL_WHITELISTED_APPS:
580+
from_secret: web3mail_whitelisted_apps
579581
commands:
580582
- cd dapp
581583
- npm run ctest
@@ -644,6 +646,8 @@ steps:
644646
from_secret: mj_sender
645647
MAILGUN_APIKEY:
646648
from_secret: mailgun_apikey
649+
WEB3MAIL_WHITELISTED_APPS:
650+
from_secret: web3mail_whitelisted_apps
647651
commands:
648652
- cd dapp
649653
- npm run ctest
@@ -714,6 +718,8 @@ steps:
714718
from_secret: mj_sender
715719
MAILGUN_APIKEY:
716720
from_secret: mailgun_apikey
721+
WEB3MAIL_WHITELISTED_APPS:
722+
from_secret: web3mail_whitelisted_apps
717723
commands:
718724
- cd dapp
719725
- npm run ctest

dapp/.eslintrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
"env": {
1212
"jest": true
1313
},
14+
"settings": {
15+
"import/resolver": {
16+
"node": {
17+
"extensions": [".js", ".json"]
18+
}
19+
}
20+
},
1421
"overrides": [
1522
{
1623
"files": ["./tests/**/*.js"],

dapp/package-lock.json

Lines changed: 146 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dapp/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"license": "ISC",
2222
"dependencies": {
2323
"@iexec/dataprotector-deserializer": "^0.1.0",
24+
"graphql": "^16.11.0",
25+
"graphql-request": "^3.7.0",
2426
"joi": "^17.9.2",
2527
"jszip": "^3.10.1",
2628
"node-fetch": "^2.7.0",
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const { request, gql } = require('graphql-request');
2+
3+
async function checkEmailPreviousValidation({ datasetAddress, dappAddresses }) {
4+
const pocoSubgraphUrl =
5+
'https://thegraph.bellecour.iex.ec/subgraphs/name/bellecour/poco-v5';
6+
7+
const query = gql`
8+
query checkSuccessfulTaskQuery($apps: [String!], $dataset: String!) {
9+
tasks(
10+
where: {
11+
resultsCallback_not: "0x"
12+
status: "COMPLETED"
13+
deal_: { dataset: $dataset, app_in: $apps }
14+
}
15+
) {
16+
resultsCallback
17+
}
18+
}
19+
`;
20+
21+
const variables = {
22+
apps: dappAddresses,
23+
dataset: datasetAddress.toLowerCase(),
24+
};
25+
26+
try {
27+
const data = await request(pocoSubgraphUrl, query, variables);
28+
const tasks = data?.tasks || [];
29+
30+
return tasks.some((task) => {
31+
const callback = task.resultsCallback?.toLowerCase();
32+
return (
33+
callback &&
34+
callback.startsWith('0x') &&
35+
callback.endsWith(
36+
'0000000000000000000000000000000000000000000000000000000000000001'
37+
)
38+
);
39+
});
40+
} catch (error) {
41+
console.error(
42+
'GraphQL error:',
43+
error.response?.errors || error.message || error
44+
);
45+
return false;
46+
}
47+
}
48+
49+
module.exports = {
50+
checkEmailPreviousValidation,
51+
};

0 commit comments

Comments
 (0)