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

support feature flag #143

Merged
merged 2 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@portis/web3",
"version": "4.0.6",
"version": "4.0.7",
"description": "Portis Web3 SDK",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Portis {
scope: options.scope,
registerPageByDefault: options.registerPageByDefault,
staging: options.staging,
feature: options.feature,
};

this._getWidgetCommunication = this._getWidgetCommunication.bind(this);
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface ISDKConfig {
scope?: Scope[];
registerPageByDefault?: boolean;
staging?: boolean;
feature?: boolean;
}

export type Scope = 'email';
Expand All @@ -67,6 +68,7 @@ export interface IOptions {
registerPageByDefault?: boolean;
pocketDevId?: string;
staging?: boolean;
feature?: boolean;
}

export interface ITransactionRequest {
Expand Down
4 changes: 4 additions & 0 deletions src/widget/widgetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { validateSecureOrigin } from '../utils/secureOrigin';
// Create a .env file to override the default WIDGET_URL when running locally
const WIDGET_URL = process.env.PORTIS_WIDGET_URL || 'https://widget.portis.io';
const STAGING_WIDGET_URL = 'https://widget-staging.portis.io';
const FEATURE_WIDGET_URL = 'https://widget-feature.portis.io';
const PORTIS_IFRAME_CLASS = 'por_portis-widget-frame';
const PORTIS_CONTAINER_CLASS = 'por_portis-container';

Expand All @@ -33,6 +34,9 @@ export default class WidgetManager {
if (_widgetConfig.staging) {
console.warn('Please note: you are using the Portis STAGING environment.');
this._widgetUrl = STAGING_WIDGET_URL;
} else if (_widgetConfig.feature) {
console.warn('Please note: you are using the Portis FEATURE environment.');
this._widgetUrl = FEATURE_WIDGET_URL;
}
WidgetManager._checkIfWidgetAlreadyInitialized();
}
Expand Down