Skip to content

Commit

Permalink
feat: enable security alerts api
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistevam committed Oct 14, 2024
1 parent 247686d commit 32fbfce
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .js.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export SEGMENT_FLUSH_INTERVAL="1"
export SEGMENT_FLUSH_EVENT_LIMIT="1"

# URL of security alerts API used to validate dApp requests.
export SECURITY_ALERTS_API_URL="http://localhost:3000"
export SECURITY_ALERTS_API_URL="https://security-alerts.api.cx.metamask.io"

# Temporary mechanism to enable security alerts API prior to release.
export SECURITY_ALERTS_API_ENABLED="true"
Expand Down
2 changes: 1 addition & 1 deletion app/actions/onboarding/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export function clearOnboardingEvents(): ClearEventsAction {
return {
type: CLEAR_EVENTS,
};
}
}
4 changes: 4 additions & 0 deletions app/core/AppConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DEFAULT_SERVER_URL } from '@metamask/sdk-communication-layer';
const DEVELOPMENT = 'development';
const PORTFOLIO_URL =
process.env.MM_PORTFOLIO_URL || 'https://portfolio.metamask.io';
const SECURITY_ALERTS_API_URL = process.env.SECURITY_ALERTS_API_URL ?? 'https://security-alerts.api.cx.metamask.io';

export default {
IS_DEV: process.env?.NODE_ENV === DEVELOPMENT,
Expand All @@ -17,6 +18,9 @@ export default {
SWARM_DEFAULT_GATEWAY_URL: 'https://swarm-gateways.net/bzz:/',
supportedTLDs: ['eth', 'xyz', 'test'],
MAX_PUSH_NOTIFICATION_PROMPT_TIMES: 2,
SECURITY_ALERTS_API: {
URL: SECURITY_ALERTS_API_URL,
},
PORTFOLIO: {
URL: PORTFOLIO_URL,
},
Expand Down
3 changes: 2 additions & 1 deletion app/lib/ppom/security-alerts-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Hex } from '@metamask/utils';
import { SecurityAlertResponse } from '../../components/Views/confirmations/components/BlockaidBanner/BlockaidBanner.types';
import AppConstants from '../../core/AppConstants';

const ENDPOINT_VALIDATE = 'validate';
const ENDPOINT_SUPPORTED_CHAINS = 'supportedChains';
Expand Down Expand Up @@ -46,7 +47,7 @@ async function request(endpoint: string, options?: RequestInit) {
}

function getUrl(endpoint: string) {
const host = process.env.SECURITY_ALERTS_API_URL;
const host = AppConstants.SECURITY_ALERTS_API.URL;

if (!host) {
throw new Error('Security alerts API URL is not set');
Expand Down
3 changes: 3 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,9 @@ app:
- opts:
is_expand: false
MM_POOLED_STAKING_UI_ENABLED: false
- opts:
is_expand: false
MM_SECURITY_ALERTS_API_ENABLED: true
- opts:
is_expand: false
PROJECT_LOCATION: android
Expand Down
2 changes: 1 addition & 1 deletion e2e/pages/Ramps/SelectPaymentMethodView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SelectPaymentMethodView {
get continueButton() {
return Matchers.getElementByText(SelectPaymentMethodSelectors.CONTINUE_BUTTON);
}

async tapPaymentMethodOption(paymentMethod) {
const paymentMethodOption = Matchers.getElementByText(paymentMethod);
await Gestures.waitAndTap(paymentMethodOption);
Expand Down
2 changes: 1 addition & 1 deletion e2e/pages/Ramps/SelectRegionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SelectRegionView {
get selectRegionDropdown() {
return Matchers.getElementByText(SelectRegionSelectors.SELECT_REGION);
}

get continueButton() {
return Matchers.getElementByText(SelectRegionSelectors.CONTINUE_BUTTON);
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/specs/ramps/onramp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe(SmokeAssets('Buy Crypto'), () => {
await SelectRegionView.tapRegionOption('California');
await SelectRegionView.tapContinueButton();
await SelectPaymentMethodView.tapPaymentMethodOption('Debit or Credit');
await SelectPaymentMethodView.tapContinueButton();
await SelectPaymentMethodView.tapContinueButton();
await Assertions.checkIfVisible(BuildQuoteView.amountToBuyLabel);
await Assertions.checkIfVisible(BuildQuoteView.getQuotesButton);
});
Expand Down

0 comments on commit 32fbfce

Please sign in to comment.