Skip to content

Commit

Permalink
feature(on-ramp): add development environment to onramp-sdk (#6325)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachunei authored May 4, 2023
1 parent c249e1f commit bf454e1
Showing 1 changed file with 27 additions and 24 deletions.
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

0 comments on commit bf454e1

Please sign in to comment.