Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On-ramp: add development environment to on-ramp-sdk #6325

Merged
merged 2 commits into from
May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions app/components/UI/FiatOnRampAggregator/sdk/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,33 @@ import I18n, { I18nEvents } from '../../../../../locales/i18n';
import Device from '../../../../util/device';
import useActivationKeys from '../hooks/useActivationKeys';

const isDevelopment = process.env.NODE_ENV !== 'production';
const isInternalBuild = process.env.ONRAMP_INTERNAL_BUILD === 'true';
const isDevelopmentOrInternalBuild = isDevelopment || isInternalBuild;

let environment = Environment.Production;
if (isInternalBuild) {
environment = Environment.Staging;
} else if (isDevelopment) {
environment = Environment.Development;
}

let context = Context.Mobile;
if (Device.isAndroid()) {
context = Context.MobileAndroid;
} else if (Device.isIos()) {
context = Context.MobileIOS;
}

export const SDK = OnRampSdk.create(environment, context, {
verbose: isDevelopment,
locale: I18n.locale,
});

I18nEvents.addListener('localeChanged', (locale) => {
SDK.setLocale(locale);
});

interface OnRampSDKConfig {
POLLING_INTERVAL: number;
POLLING_INTERVAL_HIGHLIGHT: number;
Expand Down Expand Up @@ -74,30 +101,6 @@ interface IProviderProps<T> {
children?: React.ReactNode | undefined;
}

const isDevelopment = process.env.NODE_ENV !== 'production';
const isInternalBuild = process.env.ONRAMP_INTERNAL_BUILD === 'true';
const isDevelopmentOrInternalBuild = isDevelopment || isInternalBuild;

const CONTEXT = Device.isAndroid()
? Context.MobileAndroid
: Device.isIos()
? Context.MobileIOS
: Context.Mobile;
const VERBOSE_SDK = isDevelopment;

export const SDK = OnRampSdk.create(
isDevelopmentOrInternalBuild ? Environment.Staging : Environment.Production,
CONTEXT,
{
verbose: VERBOSE_SDK,
locale: I18n.locale,
},
);

I18nEvents.addListener('localeChanged', (locale) => {
SDK.setLocale(locale);
});

export const callbackBaseUrl = isDevelopment
? 'https://on-ramp.metaswap-dev.codefi.network/regions/fake-callback'
: 'https://on-ramp-content.metaswap.codefi.network/regions/fake-callback';
Expand Down