From c4b58cf0c05d9789cbe68b5f9345b098c378ca35 Mon Sep 17 00:00:00 2001 From: Max Alekseenko Date: Tue, 30 Apr 2024 15:54:52 +0200 Subject: [PATCH] allow admin service without the account enabled --- deploy/tools/envs-validator/schema.ts | 17 +++++++++++++---- deploy/tools/envs-validator/test.sh | 5 +---- deploy/tools/envs-validator/test/.env.base | 14 +++++++++++++- deploy/tools/envs-validator/test/.env.common | 3 --- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/deploy/tools/envs-validator/schema.ts b/deploy/tools/envs-validator/schema.ts index 191eedd27d..dfad3d4f9a 100644 --- a/deploy/tools/envs-validator/schema.ts +++ b/deploy/tools/envs-validator/schema.ts @@ -349,12 +349,20 @@ const accountSchema = yup then: (schema) => schema.test(urlTest).required(), otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_LOGOUT_URL cannot not be used if NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED is not set to "true"'), }), + }); + +const adminServiceSchema = yup + .object() + .shape({ NEXT_PUBLIC_ADMIN_SERVICE_API_HOST: yup .string() - .when('NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED', { - is: (value: boolean) => value, + .when([ 'NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED', 'NEXT_PUBLIC_MARKETPLACE_ENABLED' ], { + is: (value1: boolean, value2: boolean) => value1 || value2, then: (schema) => schema.test(urlTest), - otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_ADMIN_SERVICE_API_HOST cannot not be used if NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED is not set to "true"'), + otherwise: (schema) => schema.max( + -1, + 'NEXT_PUBLIC_ADMIN_SERVICE_API_HOST cannot not be used if NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED or NEXT_PUBLIC_MARKETPLACE_ENABLED is not set to "true"', + ), }), }); @@ -629,6 +637,7 @@ const schema = yup .concat(rollupSchema) .concat(beaconChainSchema) .concat(bridgedTokensSchema) - .concat(sentrySchema); + .concat(sentrySchema) + .concat(adminServiceSchema); export default schema; diff --git a/deploy/tools/envs-validator/test.sh b/deploy/tools/envs-validator/test.sh index 179ef25bc9..7e29716658 100755 --- a/deploy/tools/envs-validator/test.sh +++ b/deploy/tools/envs-validator/test.sh @@ -1,6 +1,5 @@ #!/bin/bash -secrets_file=".env.secrets" test_folder="./test" common_file="${test_folder}/.env.common" @@ -8,7 +7,6 @@ common_file="${test_folder}/.env.common" export NEXT_PUBLIC_GIT_COMMIT_SHA=$(git rev-parse --short HEAD) export NEXT_PUBLIC_GIT_TAG=$(git describe --tags --abbrev=0) ../../scripts/collect_envs.sh ../../../docs/ENVS.md -cp ../../../.env.example ${secrets_file} # Copy test assets mkdir -p "./public/assets" @@ -26,7 +24,6 @@ validate_file() { dotenv \ -e $test_file \ -e $common_file \ - -e $secrets_file \ yarn run validate -- --silent if [ $? -eq 0 ]; then @@ -46,4 +43,4 @@ for file in "${test_files[@]}"; do if [ $? -eq 1 ]; then exit 1 fi -done \ No newline at end of file +done diff --git a/deploy/tools/envs-validator/test/.env.base b/deploy/tools/envs-validator/test/.env.base index d8ef046d25..62a5a81b6f 100644 --- a/deploy/tools/envs-validator/test/.env.base +++ b/deploy/tools/envs-validator/test/.env.base @@ -1,3 +1,15 @@ +NEXT_PUBLIC_SENTRY_DSN=https://sentry.io +NEXT_PUBLIC_AUTH_URL=https://example.com +NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED=true +NEXT_PUBLIC_LOGOUT_URL=https://example.com +NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=xxx +NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY=xxx +NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID=UA-XXXXXX-X +NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN=xxx +NEXT_PUBLIC_GROWTH_BOOK_CLIENT_KEY=xxx +NEXT_PUBLIC_AUTH0_CLIENT_ID=xxx +FAVICON_GENERATOR_API_KEY=xxx +NEXT_PUBLIC_GROWTH_BOOK_CLIENT_KEY=xxx NEXT_PUBLIC_AD_TEXT_PROVIDER=coinzilla NEXT_PUBLIC_AD_BANNER_PROVIDER=slise NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=https://example.com @@ -58,4 +70,4 @@ NEXT_PUBLIC_VISUALIZE_API_BASE_PATH=https://example.com NEXT_PUBLIC_WEB3_DISABLE_ADD_TOKEN_TO_WALLET=false NEXT_PUBLIC_WEB3_WALLETS=['coinbase','metamask','token_pocket'] NEXT_PUBLIC_SWAP_BUTTON_URL=uniswap -NEXT_PUBLIC_VALIDATORS_CHAIN_TYPE=stability \ No newline at end of file +NEXT_PUBLIC_VALIDATORS_CHAIN_TYPE=stability diff --git a/deploy/tools/envs-validator/test/.env.common b/deploy/tools/envs-validator/test/.env.common index 1f900840ff..5788f392d3 100644 --- a/deploy/tools/envs-validator/test/.env.common +++ b/deploy/tools/envs-validator/test/.env.common @@ -1,7 +1,4 @@ NEXT_PUBLIC_API_HOST=blockscout.com NEXT_PUBLIC_APP_HOST=localhost -NEXT_PUBLIC_AUTH_URL=https://example.com -NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED=true -NEXT_PUBLIC_LOGOUT_URL=https://example.com NEXT_PUBLIC_NETWORK_ID=1 NEXT_PUBLIC_NETWORK_NAME=Testnet