aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website
diff options
context:
space:
mode:
authorBrandon Millman <brandon@0xproject.com>2018-07-07 04:05:27 +0800
committerGitHub <noreply@github.com>2018-07-07 04:05:27 +0800
commit4cc33d270ee62584710659b16671575ce9955e5e (patch)
treecc2452391aaf9f9d46b36ba6e77f2f9825d18a7c /packages/website
parentf767f5c12c3f17e6c5eb945f1d398f8270491f31 (diff)
parentafbc4989d512d3dcc24a7cbc29e96afaae3acdc0 (diff)
downloaddexon-sol-tools-4cc33d270ee62584710659b16671575ce9955e5e.tar
dexon-sol-tools-4cc33d270ee62584710659b16671575ce9955e5e.tar.gz
dexon-sol-tools-4cc33d270ee62584710659b16671575ce9955e5e.tar.bz2
dexon-sol-tools-4cc33d270ee62584710659b16671575ce9955e5e.tar.lz
dexon-sol-tools-4cc33d270ee62584710659b16671575ce9955e5e.tar.xz
dexon-sol-tools-4cc33d270ee62584710659b16671575ce9955e5e.tar.zst
dexon-sol-tools-4cc33d270ee62584710659b16671575ce9955e5e.zip
Merge pull request #828 from 0xProject/feature/website/portal-improvements
Fix some portal bugs, and poll for best gas price
Diffstat (limited to 'packages/website')
-rw-r--r--packages/website/ts/blockchain.ts30
-rw-r--r--packages/website/ts/components/dialogs/ledger_config_dialog.tsx5
-rw-r--r--packages/website/ts/components/onboarding/onboarding_flow.tsx4
-rw-r--r--packages/website/ts/components/onboarding/portal_onboarding_flow.tsx5
-rw-r--r--packages/website/ts/components/wallet/wallet.tsx2
-rw-r--r--packages/website/ts/types.ts3
6 files changed, 41 insertions, 8 deletions
diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts
index 8b6bbe91a..ddf2b3989 100644
--- a/packages/website/ts/blockchain.ts
+++ b/packages/website/ts/blockchain.ts
@@ -92,6 +92,7 @@ export class Blockchain {
private _userAddressIfExists: string;
private _ledgerSubprovider: LedgerSubprovider;
private _defaultGasPrice: BigNumber;
+ private _watchGasPriceIntervalId: NodeJS.Timer;
private static _getNameGivenProvider(provider: Provider): string {
const providerType = utils.getProviderType(provider);
const providerNameIfExists = providerToName[providerType];
@@ -199,13 +200,11 @@ export class Blockchain {
}
constructor(dispatcher: Dispatcher) {
this._dispatcher = dispatcher;
- const defaultGasPrice = GWEI_IN_WEI * 30;
+ const defaultGasPrice = GWEI_IN_WEI * 40;
this._defaultGasPrice = new BigNumber(defaultGasPrice);
// We need a unique reference to this function so we can use it to unsubcribe.
this._injectedProviderUpdateHandler = this._handleInjectedProviderUpdateAsync.bind(this);
// tslint:disable-next-line:no-floating-promises
- this._updateDefaultGasPriceAsync();
- // tslint:disable-next-line:no-floating-promises
this._onPageLoadInitFireAndForgetAsync();
}
public async networkIdUpdatedFireAndForgetAsync(newNetworkId: number): Promise<void> {
@@ -540,6 +539,7 @@ export class Blockchain {
this._blockchainWatcher.destroy();
this._injectedProviderObservable.unsubscribe(this._injectedProviderUpdateHandler);
this._stopWatchingExchangeLogFillEvents();
+ this._stopWatchingGasPrice();
}
public async fetchTokenInformationAsync(): Promise<void> {
utils.assert(
@@ -803,8 +803,30 @@ export class Blockchain {
this._updateProviderName(injectedWeb3IfExists);
const shouldPollUserAddress = true;
const shouldUseLedgerProvider = false;
+ this._startWatchingGasPrice();
await this._resetOrInitializeAsync(this.networkId, shouldPollUserAddress, shouldUseLedgerProvider);
}
+ private _startWatchingGasPrice(): void {
+ if (!_.isUndefined(this._watchGasPriceIntervalId)) {
+ return; // we are already watching
+ }
+ const oneMinuteInMs = 60000;
+ // tslint:disable-next-line:no-floating-promises
+ this._updateDefaultGasPriceAsync();
+ this._watchGasPriceIntervalId = intervalUtils.setAsyncExcludingInterval(
+ this._updateDefaultGasPriceAsync.bind(this),
+ oneMinuteInMs,
+ (err: Error) => {
+ logUtils.log(`Watching gas price failed: ${err.stack}`);
+ this._stopWatchingGasPrice();
+ },
+ );
+ }
+ private _stopWatchingGasPrice(): void {
+ if (!_.isUndefined(this._watchGasPriceIntervalId)) {
+ intervalUtils.clearAsyncExcludingInterval(this._watchGasPriceIntervalId);
+ }
+ }
private async _resetOrInitializeAsync(
networkId: number,
shouldPollUserAddress: boolean = false,
@@ -900,7 +922,7 @@ export class Blockchain {
private async _updateDefaultGasPriceAsync(): Promise<void> {
try {
const gasInfo = await backendClient.getGasInfoAsync();
- const gasPriceInGwei = new BigNumber(gasInfo.average / 10);
+ const gasPriceInGwei = new BigNumber(gasInfo.fast / 10);
const gasPriceInWei = gasPriceInGwei.mul(1000000000);
this._defaultGasPrice = gasPriceInWei;
} catch (err) {
diff --git a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx
index 38e4732a4..d2f373d67 100644
--- a/packages/website/ts/components/dialogs/ledger_config_dialog.tsx
+++ b/packages/website/ts/components/dialogs/ledger_config_dialog.tsx
@@ -29,7 +29,7 @@ interface LedgerConfigDialogProps {
toggleDialogFn: (isOpen: boolean) => void;
dispatcher: Dispatcher;
blockchain: Blockchain;
- networkId: number;
+ networkId?: number;
providerType: ProviderType;
}
@@ -44,6 +44,9 @@ interface LedgerConfigDialogState {
}
export class LedgerConfigDialog extends React.Component<LedgerConfigDialogProps, LedgerConfigDialogState> {
+ public static defaultProps = {
+ networkId: 1,
+ };
constructor(props: LedgerConfigDialogProps) {
super(props);
const derivationPathIfExists = props.blockchain.getLedgerDerivationPathIfExists();
diff --git a/packages/website/ts/components/onboarding/onboarding_flow.tsx b/packages/website/ts/components/onboarding/onboarding_flow.tsx
index c2b4a4ca7..46dc897bd 100644
--- a/packages/website/ts/components/onboarding/onboarding_flow.tsx
+++ b/packages/website/ts/components/onboarding/onboarding_flow.tsx
@@ -44,12 +44,14 @@ export interface OnboardingFlowProps {
updateOnboardingStep: (stepIndex: number) => void;
disableOverlay?: boolean;
isMobile: boolean;
+ disableCloseOnClickOutside?: boolean;
}
export class OnboardingFlow extends React.Component<OnboardingFlowProps> {
public static defaultProps = {
disableOverlay: false,
isMobile: false,
+ disableCloseOnClickOutside: false,
};
public render(): React.ReactNode {
if (!this.props.isRunning) {
@@ -86,7 +88,7 @@ export class OnboardingFlow extends React.Component<OnboardingFlowProps> {
}
return (
<div>
- <Overlay onClick={this.props.onClose} />
+ <Overlay onClick={this.props.disableCloseOnClickOutside ? undefined : this.props.onClose} />
{onboardingElement}
</div>
);
diff --git a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
index 1c2c92fd1..503f2163d 100644
--- a/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
+++ b/packages/website/ts/components/onboarding/portal_onboarding_flow.tsx
@@ -23,7 +23,7 @@ import {
WrapEthOnboardingStep3,
} from 'ts/components/onboarding/wrap_eth_onboarding_step';
import { AllowanceToggle } from 'ts/containers/inputs/allowance_toggle';
-import { ProviderType, ScreenWidths, Token, TokenByAddress, TokenStateByAddress } from 'ts/types';
+import { BrowserType, ProviderType, ScreenWidths, Token, TokenByAddress, TokenStateByAddress } from 'ts/types';
import { analytics } from 'ts/utils/analytics';
import { utils } from 'ts/utils/utils';
@@ -68,6 +68,7 @@ class PlainPortalOnboardingFlow extends React.Component<PortalOnboardingFlowProp
}
}
public render(): React.ReactNode {
+ const browserType = utils.getBrowserType();
return (
<OnboardingFlow
steps={this._getSteps()}
@@ -77,6 +78,8 @@ class PlainPortalOnboardingFlow extends React.Component<PortalOnboardingFlowProp
updateOnboardingStep={this._updateOnboardingStep.bind(this)}
disableOverlay={this.props.screenWidth === ScreenWidths.Sm}
isMobile={this.props.screenWidth === ScreenWidths.Sm}
+ // This is necessary to ensure onboarding stays open once the user unlocks metamask and clicks away
+ disableCloseOnClickOutside={browserType === BrowserType.Firefox || browserType === BrowserType.Opera}
/>
);
}
diff --git a/packages/website/ts/components/wallet/wallet.tsx b/packages/website/ts/components/wallet/wallet.tsx
index de3b91ad0..1c7dafca0 100644
--- a/packages/website/ts/components/wallet/wallet.tsx
+++ b/packages/website/ts/components/wallet/wallet.tsx
@@ -270,7 +270,7 @@ export class Wallet extends React.Component<WalletProps, WalletState> {
overflowY: this.state.isHoveringSidebar ? 'scroll' : 'hidden',
marginRight: this.state.isHoveringSidebar ? 0 : 4,
// TODO: make this completely responsive
- maxHeight: this.props.screenWidth !== ScreenWidths.Sm ? 475 : undefined,
+ maxHeight: !utils.isMobileWidth(this.props.screenWidth) ? 'calc(90vh - 300px)' : undefined,
};
}
private _onSidebarHover(_event: React.FormEvent<HTMLInputElement>): void {
diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts
index f7324e87a..27b219682 100644
--- a/packages/website/ts/types.ts
+++ b/packages/website/ts/types.ts
@@ -552,7 +552,10 @@ export interface WebsiteBackendTokenInfo {
}
export interface WebsiteBackendGasInfo {
+ safeSlow: number;
average: number;
+ fast: number;
+ fastest: number;
}
export interface WebsiteBackendJobInfo {