Skip to content

Commit

Permalink
Swaps v1 (#2321)
Browse files Browse the repository at this point in the history
* REVERT

* Swaps: Add info modal when swaps is off (#2320)

* Fix info modal when enabled

* Swaps: Add clientId (#2324)

* Add a longer list of tokens (#2331)

* Swaps: Adjust Keypad size for medium and smaller devices (#2335)

* swaps: anonymous tracking (#2325)

* addtrack

* booleam

* fixanalytics

* trackanon

* devmoderevert

* track anonymously

* dont send data for non anonymized

* Revert "devmoderevert"

This reverts commit ff70e38.

Co-authored-by: Ethan Wessel <ejwessel@gmail.com>

* Swaps: Use decimal value for swaps tx (#2338)

* swaps: custom gas price (#2337)

* fix

* comment

* controller

* 588

* Swaps: Fix disabled button opacity (#2339)

* Swaps: Fix use max (#2361)

* Swaps:  Use contract balance when token is not added (#2360)

* Swaps: use destination amount when no rate is available (#2362)

* swaps: improve custom gas price and limit selection (#2358)

* onHandleGasFeeSelection

* minimumGasLimit

* fixes

* fixminimumlimit

* 590

* Swaps: transactions general view filtering (#2364)

* filtercorrectly

* improvefilters

* bumpir

* filtercorrectly

* filters

* circle

* ONLY_MAINNET

* rmtestnet

Co-authored-by: Pedro Pablo Aste Kompen <wachunei@gmail.com>
Co-authored-by: Ethan Wessel <ejwessel@gmail.com>
  • Loading branch information
3 people authored Mar 10, 2021
1 parent f891639 commit 5ee8e24
Show file tree
Hide file tree
Showing 23 changed files with 420 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ public void trackEvent(ReadableMap e) {
this.mixpanel.track(eventCategory, props);
}

@ReactMethod
public void trackEventAnonymously(ReadableMap e) {
String eventCategory = e.getString("category");
String distinctId = this.mixpanel.getDistinctId();
this.mixpanel.identify("0x0000000000000000");
JSONObject props = toJSONObject(e);
this.mixpanel.track(eventCategory, props);
this.mixpanel.identify(distinctId);
}

@ReactMethod
public void getDistinctId(Promise promise) {
String distinctId = this.mixpanel.getDistinctId();
Expand Down
2 changes: 1 addition & 1 deletion app/components/Base/Keypad/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const styles = StyleSheet.create({
},
keypadButton: {
paddingHorizontal: 20,
paddingVertical: Device.isMediumDevice() ? (Device.isIphone5() ? 5 : 10) : 12,
paddingVertical: Device.isMediumDevice() ? (Device.isIphone5() ? 4 : 8) : 12,
flex: 1,
justifyContent: 'center',
alignItems: 'center'
Expand Down
8 changes: 5 additions & 3 deletions app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,15 @@ const Main = props => {
delete newSwapsTransactions[transactionMeta.id].paramsForAnalytics;

InteractionManager.runAfterInteractions(() => {
Analytics.trackEventWithParameters(event, {
const parameters = {
...analyticsParams,
time_to_mine: timeToMine,
estimated_vs_used_gasRatio: estimatedVsUsedGasRatio,
quote_vs_executionRatio: quoteVsExecutionRatio,
token_to_amount_received: tokenToAmountReceived
});
token_to_amount_received: tokenToAmountReceived.toString()
};
Analytics.trackEventWithParameters(event, {});
Analytics.trackEventWithParameters(event, parameters, true);
});
} catch (e) {
Logger.error(e, ANALYTICS_EVENT_OPTS.SWAP_TRACKING_FAILED);
Expand Down
11 changes: 5 additions & 6 deletions app/components/UI/AccountOverview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import AssetActionButton from '../AssetActionButton';
import EthereumAddress from '../EthereumAddress';
import { colors, fontStyles, baseStyles } from '../../../styles/common';
import { allowedToBuy } from '../FiatOrders';
import AssetSwapButton from '../Swaps/components/AssetSwapButton';

const styles = StyleSheet.create({
scrollView: {
Expand Down Expand Up @@ -351,13 +352,11 @@ class AccountOverview extends PureComponent {
label={strings('asset_overview.send_button')}
/>
{AppConstants.SWAPS.ACTIVE && (
<AssetActionButton
icon="swap"
label={strings('asset_overview.swap')}
disabled={
!swapsIsLive || (AppConstants.SWAPS.ONLY_MAINNET ? !isMainNet(chainId) : false)
}
<AssetSwapButton
isFeatureLive={swapsIsLive}
isNetworkAllowed={AppConstants.SWAPS.ONLY_MAINNET ? isMainNet(chainId) : true}
onPress={this.goToSwaps}
isAssetAllowed
/>
)}
</View>
Expand Down
13 changes: 5 additions & 8 deletions app/components/UI/AssetOverview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Logger from '../../../util/Logger';
import Analytics from '../../../core/Analytics';
import { ANALYTICS_EVENT_OPTS } from '../../../util/analytics';
import { allowedToBuy } from '../FiatOrders';
import AssetSwapButton from '../Swaps/components/AssetSwapButton';

const styles = StyleSheet.create({
wrapper: {
Expand Down Expand Up @@ -297,14 +298,10 @@ class AssetOverview extends PureComponent {
label={strings('asset_overview.send_button')}
/>
{AppConstants.SWAPS.ACTIVE && (
<AssetActionButton
icon="swap"
label={strings('asset_overview.swap')}
disabled={
!swapsIsLive ||
(AppConstants.SWAPS.ONLY_MAINNET ? !isMainNet(chainId) : false) ||
(!isETH && !(address?.toLowerCase() in swapsTokens))
}
<AssetSwapButton
isFeatureLive={swapsIsLive}
isNetworkAllowed={AppConstants.SWAPS.ONLY_MAINNET ? isMainNet(chainId) : true}
isAssetAllowed={isETH || address?.toLowerCase() in swapsTokens}
onPress={this.goToSwaps}
/>
)}
Expand Down
13 changes: 10 additions & 3 deletions app/components/UI/CustomGas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ class CustomGas extends PureComponent {
* Object BN containing estimated gas limit
*/
gas: PropTypes.object,
/**
* Gas limit estimation that should be the minimum value to set
*/
minimumGasLimit: PropTypes.string,
/**
* Object BN containing gas price
*/
Expand Down Expand Up @@ -417,7 +421,10 @@ class CustomGas extends PureComponent {
else if (bnValue && !isBN(bnValue)) warningGasLimit = strings('transaction.invalid_gas');
else if (bnValue.lt(new BN(21000)) || bnValue.gt(new BN(7920028)))
warningGasLimit = strings('custom_gas.warning_gas_limit');

else if (this.props.minimumGasLimit && bnValue.lt(new BN(this.props.minimumGasLimit)))
warningGasLimit = strings('custom_gas.warning_gas_limit_estimated', {
gas: this.props.minimumGasLimit.toString(10)
});
this.setState({
customGasLimit: value,
customGasLimitBN: bnValue,
Expand Down Expand Up @@ -450,7 +457,7 @@ class CustomGas extends PureComponent {

//Handle gas fee selection when save button is pressed instead of everytime a change is made, otherwise cannot switch back to review mode if there is an error
saveCustomGasSelection = () => {
const { gasSpeedSelected, customGasLimit, customGasPrice } = this.state;
const { gasSpeedSelected, customGasLimit, customGasPriceBNWei } = this.state;
const {
review,
gas,
Expand All @@ -459,7 +466,7 @@ class CustomGas extends PureComponent {
basicGasEstimates: { fastGwei, averageGwei, safeLowGwei }
} = this.props;
if (advancedCustomGas) {
handleGasFeeSelection(new BN(customGasLimit), apiEstimateModifiedToWEI(customGasPrice), {
handleGasFeeSelection(new BN(customGasLimit), customGasPriceBNWei, {
mode: 'advanced'
});
} else {
Expand Down
Loading

0 comments on commit 5ee8e24

Please sign in to comment.