diff --git a/.github/workflows/dapp-ci.yml b/.github/workflows/dapp-ci.yml index cf15e723..8eebac7a 100644 --- a/.github/workflows/dapp-ci.yml +++ b/.github/workflows/dapp-ci.yml @@ -38,7 +38,10 @@ jobs: test: runs-on: ubuntu-latest - environment: bellecour-dev + strategy: + matrix: + environment: ['bellecour-dev', 'arbitrum-sepolia-dev'] + environment: ${{ matrix.environment }} defaults: run: working-directory: ${{ env.WORKING_DIRECTORY }} @@ -48,6 +51,7 @@ jobs: MJ_SENDER: ${{ secrets.MAILJET_SENDER }} MAILGUN_APIKEY: ${{ secrets.MAILGUN_APIKEY }} WEB3MAIL_WHITELISTED_APPS: ${{ vars.WEB3MAIL_WHITELISTED_APPS }} + POCO_SUBGRAPH_URL: ${{ vars.POCO_SUBGRAPH_URL }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/dapp-deploy.yml b/.github/workflows/dapp-deploy.yml index aa944197..3dc60133 100644 --- a/.github/workflows/dapp-deploy.yml +++ b/.github/workflows/dapp-deploy.yml @@ -128,6 +128,7 @@ jobs: MJ_SENDER: ${{ secrets.MAILJET_SENDER }} MAILGUN_APIKEY: ${{ secrets.MAILGUN_APIKEY }} WEB3MAIL_WHITELISTED_APPS: ${{ vars.WEB3MAIL_WHITELISTED_APPS }} + POCO_SUBGRAPH_URL: ${{ vars.POCO_SUBGRAPH_URL }} RPC_URL: ${{ secrets.RPC_URL }} run: | cd deployment-dapp diff --git a/.github/workflows/sdk-ci.yml b/.github/workflows/sdk-ci.yml index 8c4561e4..f46de94b 100644 --- a/.github/workflows/sdk-ci.yml +++ b/.github/workflows/sdk-ci.yml @@ -1,6 +1,13 @@ name: web3mail-sdk-ci -on: [pull_request] +on: + pull_request: + paths-ignore: + - '.github/**' + - 'dapp/**' + - 'demo/**' + - 'deployment-dapp/**' + - 'technical-design/**' concurrency: group: ${{ github.ref }}-pr-test diff --git a/dapp/src/checkEmailPreviousValidation.js b/dapp/src/checkEmailPreviousValidation.js index fb123589..b9e0c634 100644 --- a/dapp/src/checkEmailPreviousValidation.js +++ b/dapp/src/checkEmailPreviousValidation.js @@ -1,9 +1,10 @@ const { request, gql } = require('graphql-request'); -async function checkEmailPreviousValidation({ datasetAddress, dappAddresses }) { - const pocoSubgraphUrl = - 'https://thegraph.bellecour.iex.ec/subgraphs/name/bellecour/poco-v5'; - +async function checkEmailPreviousValidation({ + datasetAddress, + dappAddresses, + pocoSubgraphUrl, +}) { const query = gql` query checkSuccessfulTaskQuery($apps: [String!], $dataset: String!) { tasks( diff --git a/dapp/src/sendEmail.js b/dapp/src/sendEmail.js index 67322071..c71f860b 100644 --- a/dapp/src/sendEmail.js +++ b/dapp/src/sendEmail.js @@ -76,6 +76,7 @@ async function start() { let isEmailValidated = await checkEmailPreviousValidation({ datasetAddress: protectedData.email, dappAddresses: appDeveloperSecret.WEB3MAIL_WHITELISTED_APPS, + pocoSubgraphUrl: appDeveloperSecret.POCO_SUBGRAPH_URL, }); // Step 2: If not, try Mailgun diff --git a/dapp/src/validation.js b/dapp/src/validation.js index afd7aa63..8c3dad6c 100644 --- a/dapp/src/validation.js +++ b/dapp/src/validation.js @@ -21,6 +21,7 @@ const appSecretSchema = Joi.object({ MJ_SENDER: Joi.string().email().required(), MAILGUN_APIKEY: Joi.string().required(), WEB3MAIL_WHITELISTED_APPS: Joi.array().items(Joi.string()).required(), + POCO_SUBGRAPH_URL: Joi.string().uri().required(), }); function validateAppSecret(obj) { diff --git a/dapp/tests/e2e/app.test.js b/dapp/tests/e2e/app.test.js index dc28d57a..9198ba64 100644 --- a/dapp/tests/e2e/app.test.js +++ b/dapp/tests/e2e/app.test.js @@ -26,6 +26,7 @@ describe('sendEmail', () => { MAILGUN_APIKEY: 'xxx', WEB3MAIL_WHITELISTED_APPS: '["0xa638bf4665ce7bd7021a4a12416ea7a0a3272b6f"]', + POCO_SUBGRAPH_URL: 'https://fake-poco.subgraph.iex.ec', }); // requester secret setup process.env.IEXEC_REQUESTER_SECRET_1 = JSON.stringify({ @@ -54,6 +55,7 @@ describe('sendEmail', () => { MAILGUN_APIKEY: 'xxx', WEB3MAIL_WHITELISTED_APPS: '["0xa638bf4665ce7bd7021a4a12416ea7a0a3272b6f"]', + POCO_SUBGRAPH_URL: 'https://fake-poco.subgraph.iex.ec', }); await expect(() => start()).rejects.toThrow( Error('App secret error: "MJ_APIKEY_PUBLIC" is required') @@ -69,6 +71,7 @@ describe('sendEmail', () => { MAILGUN_APIKEY: 'xxx', WEB3MAIL_WHITELISTED_APPS: '["0xa638bf4665ce7bd7021a4a12416ea7a0a3272b6f"]', + POCO_SUBGRAPH_URL: 'https://fake-poco.subgraph.iex.ec', }); await expect(() => start()).rejects.toThrow( Error('App secret error: "MJ_APIKEY_PRIVATE" is required') @@ -84,6 +87,7 @@ describe('sendEmail', () => { MAILGUN_APIKEY: 'xxx', WEB3MAIL_WHITELISTED_APPS: '["0xa638bf4665ce7bd7021a4a12416ea7a0a3272b6f"]', + POCO_SUBGRAPH_URL: 'https://fake-poco.subgraph.iex.ec', }); await expect(() => start()).rejects.toThrow( Error('App secret error: "MJ_SENDER" is required') @@ -99,6 +103,7 @@ describe('sendEmail', () => { MJ_SENDER: 'foo@bar.com', WEB3MAIL_WHITELISTED_APPS: '["0xa638bf4665ce7bd7021a4a12416ea7a0a3272b6f"]', + POCO_SUBGRAPH_URL: 'https://fake-poco.subgraph.iex.ec', }); await expect(() => start()).rejects.toThrow( Error('App secret error: "MAILGUN_APIKEY" is required') @@ -113,6 +118,7 @@ describe('sendEmail', () => { MJ_APIKEY_PRIVATE: 'xxx', MAILGUN_APIKEY: 'xxx', MJ_SENDER: 'foo@bar.com', + POCO_SUBGRAPH_URL: 'https://fake-poco.subgraph.iex.ec', }); await expect(() => start()).rejects.toThrow( Error('App secret error: "WEB3MAIL_WHITELISTED_APPS" is required') @@ -121,6 +127,22 @@ describe('sendEmail', () => { const out = await fsPromises.readdir(process.env.IEXEC_OUT); expect(out).toStrictEqual([]); }); + it('should fail if POCO_SUBGRAPH_URL in developer secret is missing', async () => { + process.env.IEXEC_APP_DEVELOPER_SECRET = JSON.stringify({ + MJ_APIKEY_PUBLIC: 'xxx', + MJ_APIKEY_PRIVATE: 'xxx', + MAILGUN_APIKEY: 'xxx', + MJ_SENDER: 'foo@bar.com', + WEB3MAIL_WHITELISTED_APPS: + '["0xa638bf4665ce7bd7021a4a12416ea7a0a3272b6f"]', + }); + await expect(() => start()).rejects.toThrow( + Error('App secret error: "POCO_SUBGRAPH_URL" is required') + ); + // output should be empty + const out = await fsPromises.readdir(process.env.IEXEC_OUT); + expect(out).toStrictEqual([]); + }); }); describe('with bad IEXEC_REQUESTER_SECRET_1', () => { @@ -286,6 +308,7 @@ describe('sendEmail', () => { MAILGUN_APIKEY: 'fake', WEB3MAIL_WHITELISTED_APPS: '["0xa638bf4665ce7bd7021a4a12416ea7a0a3272b6f"]', + POCO_SUBGRAPH_URL: 'https://fake-poco.subgraph.iex.ec', }); // check the error is not an email validation error (mailgun validation is skipped, mailjet rejects) await expect(() => start()).rejects.toThrow( @@ -303,6 +326,7 @@ describe('sendEmail', () => { MAILGUN_APIKEY: 'xxx', WEB3MAIL_WHITELISTED_APPS: '["0xa638bf4665ce7bd7021a4a12416ea7a0a3272b6f"]', + POCO_SUBGRAPH_URL: 'https://fake-poco.subgraph.iex.ec', }); await expect(() => start()).rejects.toThrow( Error('Failed to send email') @@ -321,7 +345,8 @@ describe('sendEmail', () => { (process.env.MJ_APIKEY_PUBLIC && process.env.MJ_APIKEY_PRIVATE && process.env.MJ_SENDER && - process.env.MAILGUN_APIKEY) + process.env.MAILGUN_APIKEY && + process.env.POCO_SUBGRAPH_URL) ) { describe('with credentials', () => { beforeEach(() => { @@ -332,6 +357,7 @@ describe('sendEmail', () => { MJ_SENDER, MAILGUN_APIKEY, WEB3MAIL_WHITELISTED_APPS, + POCO_SUBGRAPH_URL, } = process.env; process.env.IEXEC_APP_DEVELOPER_SECRET = JSON.stringify({ MJ_APIKEY_PUBLIC, @@ -339,6 +365,7 @@ describe('sendEmail', () => { MJ_SENDER, MAILGUN_APIKEY, WEB3MAIL_WHITELISTED_APPS, + POCO_SUBGRAPH_URL, }); // requester secret setup diff --git a/dapp/tests/unit/validation.test.js b/dapp/tests/unit/validation.test.js index 57562e2a..bad8b586 100644 --- a/dapp/tests/unit/validation.test.js +++ b/dapp/tests/unit/validation.test.js @@ -32,6 +32,7 @@ describe('validateAppSecret function', () => { WEB3MAIL_WHITELISTED_APPS: JSON.parse( '["0xa638bf4665ce7bd7021a4a12416ea7a0a3272b6f"]' ), + POCO_SUBGRAPH_URL: 'https://fake-poco.subgraph.iex.ec', }) ).not.toThrow(); }); @@ -94,10 +95,11 @@ describe('validateAppSecret function', () => { MJ_SENDER: 'foo', MAILGUN_APIKEY: '', WEB3MAIL_WHITELISTED_APPS: '[4]', + POCO_SUBGRAPH_URL: 'not-a-url', }) ).toThrow( Error( - 'App secret error: "MJ_APIKEY_PUBLIC" must be a string; "MJ_APIKEY_PRIVATE" is not allowed to be empty; "MJ_SENDER" must be a valid email; "MAILGUN_APIKEY" is not allowed to be empty; "WEB3MAIL_WHITELISTED_APPS" must be an array' + 'App secret error: "MJ_APIKEY_PUBLIC" must be a string; "MJ_APIKEY_PRIVATE" is not allowed to be empty; "MJ_SENDER" must be a valid email; "MAILGUN_APIKEY" is not allowed to be empty; "WEB3MAIL_WHITELISTED_APPS" must be an array; "POCO_SUBGRAPH_URL" must be a valid uri' ) ); }); diff --git a/deployment-dapp/src/pushSecretScript.ts b/deployment-dapp/src/pushSecretScript.ts index 5f4cca23..52863a32 100644 --- a/deployment-dapp/src/pushSecretScript.ts +++ b/deployment-dapp/src/pushSecretScript.ts @@ -10,6 +10,7 @@ const main = async () => { MJ_SENDER, MAILGUN_APIKEY, WEB3MAIL_WHITELISTED_APPS, + POCO_SUBGRAPH_URL, } = process.env; if (!WALLET_PRIVATE_KEY) @@ -20,6 +21,7 @@ const main = async () => { if (!MAILGUN_APIKEY) throw Error('Missing env MAILGUN_APIKEY'); if (WEB3MAIL_WHITELISTED_APPS === undefined) throw Error('Missing env WEB3MAIL_WHITELISTED_APPS'); + if (!POCO_SUBGRAPH_URL) throw Error('Missing env POCO_SUBGRAPH_URL'); if (!WALLET_PRIVATE_KEY) throw Error(`Missing WALLET_PRIVATE_KEY environment variable`); @@ -40,6 +42,7 @@ const main = async () => { MJ_SENDER, MAILGUN_APIKEY, WEB3MAIL_WHITELISTED_APPS: JSON.stringify(fullWhitelistedApps), + POCO_SUBGRAPH_URL, }); await pushSecret(iexec, appAddress, jsonSecret);