Skip to content

Commit 7c18fb0

Browse files
authored
feat(ramp): add activation keys to all non-prod envs (#20781)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This pull request updates the environment handling logic in the `app/components/UI/Ramp/Aggregator/sdk/index.tsx` module to more accurately distinguish between production and non-production builds. The changes improve how the application determines wether Activation Keys settings are displayed or not and which callback URL to use, refining the conditions for development and internal builds. **Environment detection improvements:** * Added the `Environment` import from the SDK and introduced a new `isProduction` flag based on the current SDK environment, making production detection more robust. * Refactored the logic for `isDevelopmentOrInternalBuild` to include cases where the environment is not production, ensuring non-production features are enabled more consistently. **Callback URL selection:** * Updated the `callbackBaseUrl` export to use the new `isProduction` flag, ensuring that the correct callback URL is chosen based on the refined environment detection. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-2711 ## **Manual testing steps** ```gherkin Feature: Buy/Sell Activation Keys Scenario: user sets activation keys Given the app is a non-prod build When user goes to Buy & Sell settings Then activation keys UI is displayed Scenario: user can't see activation keys Given the app is a prod build When user goes to Buy & Sell settings Then activation keys UI is not displayed ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> N/A, this is reflected on production builds. ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Refines prod/non-prod detection using SDK `Environment`, updates `callbackBaseUrl` selection, and aligns activation keys gating with the new logic. > > - **Ramp Aggregator SDK**: > - Refine environment detection by importing `Environment`, deriving `environment` via `getSdkEnvironment()`, adding `isProduction`, and updating `isDevelopmentOrInternalBuild` to include non-production environments. > - Switch `callbackBaseUrl` selection to use `isProduction`, choosing prod vs UAT endpoints accordingly. > - Initialize SDK with derived `environment` and existing mobile `context`; keep verbose tied to development. > - Activation keys gating now follows updated `isDevelopmentOrInternalBuild` logic. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8063a1e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent d3f922f commit 7c18fb0

File tree

1 file changed

+9
-6
lines changed
  • app/components/UI/Ramp/Aggregator/sdk

1 file changed

+9
-6
lines changed

app/components/UI/Ramp/Aggregator/sdk/index.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
RegionsService,
1414
CryptoCurrency,
1515
Payment,
16+
Environment,
1617
} from '@consensys/on-ramp-sdk';
1718
import { getSdkEnvironment } from './getSdkEnvironment';
1819
import { getCaipChainIdFromCryptoCurrency } from '../utils';
@@ -38,13 +39,15 @@ import useActivationKeys from '../hooks/useActivationKeys';
3839
import useRampAccountAddress from '../../hooks/useRampAccountAddress';
3940
import { selectNickname } from '../../../../../selectors/networkController';
4041

42+
const environment = getSdkEnvironment();
43+
4144
const isDevelopment =
4245
process.env.NODE_ENV !== 'production' ||
4346
process.env.RAMP_DEV_BUILD === 'true';
4447
const isInternalBuild = process.env.RAMP_INTERNAL_BUILD === 'true';
45-
const isDevelopmentOrInternalBuild = isDevelopment || isInternalBuild;
46-
47-
const environment = getSdkEnvironment();
48+
const isProduction = environment === Environment.Production;
49+
const isDevelopmentOrInternalBuild =
50+
isDevelopment || isInternalBuild || !isProduction;
4851

4952
let context = Context.Mobile;
5053
if (Device.isAndroid()) {
@@ -115,9 +118,9 @@ interface ProviderProps<T> {
115118
children?: React.ReactNode;
116119
}
117120

118-
export const callbackBaseUrl = isDevelopment
119-
? 'https://on-ramp-content.uat-api.cx.metamask.io/regions/fake-callback'
120-
: 'https://on-ramp-content.api.cx.metamask.io/regions/fake-callback';
121+
export const callbackBaseUrl = isProduction
122+
? 'https://on-ramp-content.api.cx.metamask.io/regions/fake-callback'
123+
: 'https://on-ramp-content.uat-api.cx.metamask.io/regions/fake-callback';
121124

122125
export const callbackBaseDeeplink = 'metamask://';
123126

0 commit comments

Comments
 (0)