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

Swaps v1 #2321

Merged
merged 28 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3133b25
REVERT
estebanmino Mar 1, 2021
c13997d
Swaps: Add info modal when swaps is off (#2320)
wachunei Mar 1, 2021
0db05ae
Fix info modal when enabled
wachunei Mar 1, 2021
9d0b663
Swaps: Add clientId (#2324)
wachunei Mar 2, 2021
2e22ed3
Add a longer list of tokens (#2331)
wachunei Mar 4, 2021
1f4f104
Merge branch 'develop' into swaps-v1
wachunei Mar 4, 2021
0ebbec1
Swaps: Adjust Keypad size for medium and smaller devices (#2335)
wachunei Mar 4, 2021
08fa75e
swaps: anonymous tracking (#2325)
estebanmino Mar 4, 2021
f4065a7
Swaps: Use decimal value for swaps tx (#2338)
wachunei Mar 4, 2021
a723a42
swaps: custom gas price (#2337)
estebanmino Mar 4, 2021
32630d9
588
estebanmino Mar 4, 2021
f095d7d
Merge branch 'swaps-v1' of github.com:MetaMask/metamask-mobile into s…
estebanmino Mar 4, 2021
7162fd4
Swaps: Fix disabled button opacity (#2339)
wachunei Mar 4, 2021
761cbf3
Merge branch 'develop' into swaps-v1
estebanmino Mar 9, 2021
8bf558a
Swaps: Fix use max (#2361)
wachunei Mar 9, 2021
c37ddf7
Swaps: Use contract balance when token is not added (#2360)
wachunei Mar 9, 2021
7f41d08
Swaps: use destination amount when no rate is available (#2362)
wachunei Mar 9, 2021
69b97fa
Merge branch 'develop' into swaps-v1
estebanmino Mar 10, 2021
b20a652
swaps: improve custom gas price and limit selection (#2358)
estebanmino Mar 10, 2021
0ccfb16
590
estebanmino Mar 10, 2021
da26534
Merge branch 'swaps-v1' of github.com:MetaMask/metamask-mobile into s…
estebanmino Mar 10, 2021
fe1b505
Swaps: transactions general view filtering (#2364)
estebanmino Mar 10, 2021
0488f10
Merge branch 'develop' into swaps-v1
estebanmino Mar 10, 2021
f9b9224
filters
estebanmino Mar 10, 2021
17c320f
circle
estebanmino Mar 10, 2021
505ee03
ONLY_MAINNET
estebanmino Mar 10, 2021
525244f
rmtestnet
estebanmino Mar 10, 2021
16706f0
merge
estebanmino Mar 10, 2021
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
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