Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:MetaMask/metamask-mobile into tr…
Browse files Browse the repository at this point in the history
…ansaction-header
  • Loading branch information
EtDu committed Apr 17, 2020
2 parents 9a4ee8d + 25e3910 commit 935177b
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`CollectibleImage should render correctly 1`] = `
style={
Array [
Object {
"borderRadius": 25,
"borderRadius": 10,
"height": 50,
"overflow": "hidden",
"width": 50,
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/CollectibleImage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const styles = StyleSheet.create({
listWrapper: {
width: 50,
height: 50,
borderRadius: 25,
borderRadius: 10,
overflow: 'hidden'
},
fullWrapper: {
Expand Down
43 changes: 32 additions & 11 deletions app/components/Views/BrowserTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ export class BrowserTab extends PureComponent {
activated: props.id === props.activeTab,
lastError: null,
showApprovalDialogHostname: undefined,
showOptions: false
showOptions: false,
lastUrlBeforeHome: null
};
}
backgroundBridges = [];
Expand All @@ -402,7 +403,6 @@ export class BrowserTab extends PureComponent {
sessionENSNames = {};
ensIgnoreList = [];
snapshotTimer = null;
lastUrlBeforeHome = null;
goingBack = false;
wizardScrollAdjusted = false;
isReloading = false;
Expand Down Expand Up @@ -1064,13 +1064,23 @@ export class BrowserTab extends PureComponent {
};

goBack = () => {
if (!this.canGoBack()) return;

this.toggleOptionsIfNeeded();
this.goingBack = true;
setTimeout(() => {
this.goingBack = false;
}, 500);

const { current } = this.webview;
current && current.goBack();
const { lastUrlBeforeHome } = this.state;

if (this.isHomepage() && lastUrlBeforeHome) {
this.go(lastUrlBeforeHome);
} else {
current && current.goBack();
}

setTimeout(() => {
this.props.navigation.setParams({
...this.props.navigation.state.params,
Expand All @@ -1083,7 +1093,7 @@ export class BrowserTab extends PureComponent {
forwardEnabled: true,
currentPageTitle: null
});
}, 500);
}, 1000);
};

goBackToHomepage = async () => {
Expand All @@ -1103,14 +1113,15 @@ export class BrowserTab extends PureComponent {
}, 100);
Analytics.trackEvent(ANALYTICS_EVENT_OPTS.DAPP_HOME);
setTimeout(() => {
this.lastUrlBeforeHome = lastUrlBeforeHome;
this.setState({ lastUrlBeforeHome });
}, 1000);
};

goForward = async () => {
const { current } = this.webview;
if (this.lastUrlBeforeHome) {
this.go(this.lastUrlBeforeHome);
const { lastUrlBeforeHome } = this.state;
if (lastUrlBeforeHome) {
this.go(lastUrlBeforeHome);
} else if (this.canGoForward()) {
this.toggleOptionsIfNeeded();
current && current.goForward && current.goForward();
Expand Down Expand Up @@ -1291,7 +1302,7 @@ export class BrowserTab extends PureComponent {
currentPageTitle: title,
forwardEnabled: false
});
this.lastUrlBeforeHome = null;
this.setState({ lastUrlBeforeHome: null });
this.props.navigation.setParams({ url: data.payload.url, silent: true, showUrlModal: false });
this.updateTabInfo(data.payload.url);
break;
Expand Down Expand Up @@ -1327,7 +1338,7 @@ export class BrowserTab extends PureComponent {
if (this.isHomepage(url)) {
this.refreshHomeScripts();
}
if (url === this.state.url) return;
if (url === this.state.url && !this.isHomepage(url)) return;
const { ipfsGateway } = this.props;
const data = {};
const urlObj = new URL(url);
Expand All @@ -1339,7 +1350,9 @@ export class BrowserTab extends PureComponent {
return;
}

this.lastUrlBeforeHome = null;
if (!this.isHomepage(url)) {
this.setState({ lastUrlBeforeHome: null });
}

if (!this.state.showPhishingModal && !this.isAllowedUrl(urlObj.hostname)) {
this.handleNotAllowedUrl(url);
Expand Down Expand Up @@ -1518,7 +1531,7 @@ export class BrowserTab extends PureComponent {
};

renderBottomBar = () => {
const canGoBack = !this.isHomepage();
const canGoBack = this.canGoBack();
const canGoForward = this.canGoForward();
return (
<BrowserBottomBar
Expand Down Expand Up @@ -1839,6 +1852,14 @@ export class BrowserTab extends PureComponent {

canGoForward = () => this.state.forwardEnabled;

canGoBack = () => {
if (this.isHomepage()) {
return !!this.state.lastUrlBeforeHome && !this.isHomepage(this.state.lastUrlBeforeHome);
}

return true;
};

isTabActive = () => {
const { activeTab, id } = this.props;
return activeTab === id;
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/SendFlow/Amount/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ class Amount extends PureComponent {
onPress={() => this.pickSelectedAsset(collectible)}
>
<View style={styles.assetElement}>
<CollectibleImage collectible={collectible} />
<CollectibleImage collectible={collectible} iconStyle={styles.tokenImage} containerStyle={styles.tokenImage} />
<View style={styles.assetInformationWrapper}>
<Text style={styles.textAssetTitle}>{name}</Text>
</View>
Expand Down
78 changes: 29 additions & 49 deletions e2e/dapp-initiated-txn.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ describe('Test Dapp Initiated Transactions', () => {
await TestHelpers.tap('confirm-txn-edit-button');
// Input Amount
await TestHelpers.replaceTextInField('amount-input', '0.000001');
// Tap on FAST for transaction fee
await TestHelpers.tapByText('FAST');
// Tap on NEXT button
await TestHelpers.tapByText('Next');
// Tap on CONFIRM button
Expand Down Expand Up @@ -181,12 +183,13 @@ describe('Test Dapp Initiated Transactions', () => {
await element(by.id('url-input')).tapReturnKey();
await TestHelpers.delay(3500);
}

// Tap on connect button to bring up connection request
if (device.getPlatform() === 'android') {
await TestHelpers.tapAtPoint('browser-screen', { x: 65, y: 114 });
await TestHelpers.tapAtPoint('browser-screen', { x: 183, y: 261 });
await TestHelpers.delay(1000);
} else {
await TestHelpers.tapAtPoint('browser-screen', { x: 65, y: 120 });
await TestHelpers.tapAtPoint('browser-screen', { x: 191, y: 267 });
}
// Give some time for connect request
await TestHelpers.delay(1000);
Expand All @@ -196,63 +199,40 @@ describe('Test Dapp Initiated Transactions', () => {
await TestHelpers.tapByText('CONNECT');
// Give some time for account to be displayed
await TestHelpers.delay(2000);
// Tap on Create Token button

// Scroll to bottom of browser view and create token then approve token
if (device.getPlatform() === 'ios') {
await TestHelpers.tapAtPoint('browser-screen', { x: 70, y: 297 });
} else {
await TestHelpers.tapAtPoint('browser-screen', { x: 65, y: 289 });
// Scroll down to bottom of page
await TestHelpers.swipe('browser-screen', 'up');
await TestHelpers.delay(1000);
await TestHelpers.tapAtPoint('browser-screen', { x: 114, y: 290 });
await TestHelpers.delay(1000);
await TestHelpers.tapAtPoint('browser-screen', { x: 70, y: 315 });
await TestHelpers.delay(1000);
}
// Tap Edit
await TestHelpers.tap('confirm-txn-edit-button');
// Tap on SLOW for transaction fee
await TestHelpers.tapByText('SLOW');
// Tap on NEXT button
await TestHelpers.tapByText('Next');
// Tap on CONFIRM button
await TestHelpers.tapByText('Confirm');
// on iOS dismiss notification and on Android, wait some time for token to be created
if (device.getPlatform() === 'android') {
await TestHelpers.delay(5000);
} else {
// Tap on Create Token button
await TestHelpers.tapAtPoint('browser-screen', { x: 225, y: 505 });
// Tap Edit
await TestHelpers.tap('confirm-txn-edit-button');
// Tap on FAST for transaction fee
await TestHelpers.tapByText('FAST');
// Tap on NEXT button
await TestHelpers.tapByText('Next');
// Tap on CONFIRM button
await TestHelpers.tapByText('Confirm');
// on iOS dismiss notification
// Check that we are on the browser screen
await TestHelpers.checkIfVisible('browser-screen');
// Wait for enable notifications alert to show up
await TestHelpers.delay(10000);
// Dismiss alert
await TestHelpers.tapAlertWithButton('No, thanks');
}
// Tap on Approve Tokens button
if (device.getPlatform() === 'android') {
await TestHelpers.tapAtPoint('browser-screen', { x: 300, y: 289 });
await TestHelpers.delay(1000);
await TestHelpers.tapAtPoint('browser-screen', { x: 341, y: 290 });
await TestHelpers.delay(1000);
await TestHelpers.tapAtPoint('browser-screen', { x: 350, y: 307 });
// Tap on Approve Tokens button
await TestHelpers.tapAtPoint('browser-screen', { x: 229, y: 553 });
// Check that we are on the approve screen
await TestHelpers.checkIfVisible('approve-screen');
// Check that title is correct
await TestHelpers.checkIfElementHasString('allow-access', DAPP_ACCESS);
// Tap on Approve button
await TestHelpers.tapAtPoint('approve-screen', { x: 330, y: 600 });
// Give enough time for notification to go away
await TestHelpers.delay(1000);
} else {
await TestHelpers.tapAtPoint('browser-screen', { x: 301, y: 298 });
}
// Check that we are on the approve screen
await TestHelpers.checkIfVisible('approve-screen');
// Check that title is correct
await TestHelpers.checkIfElementHasString('allow-access', DAPP_ACCESS);
// Tap on Approve button
if (device.getPlatform() === 'android') {
await TestHelpers.tapByText('Approve');
} else {
await TestHelpers.tapAtPoint('approve-screen', { x: 275, y: 620 });
}
// Delay
await TestHelpers.delay(1000);
// Check that we are on the success screen
await TestHelpers.checkIfVisible('approve-success-screen');
// Close Success screen
await TestHelpers.tap('approve-success-close-button');
});

it('should log out', async () => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"react-native-v8": "0.59.10-patch.4",
"react-native-vector-icons": "6.4.2",
"react-native-view-shot": "git+ssh://git@github.com/MetaMask/react-native-view-shot.git#androidx",
"react-native-webview": "git+ssh://git@github.com/MetaMask/react-native-webview.git#c756513b1f5a635cb49d0cfd01e25ca5c0887678",
"react-native-webview": "git+ssh://git@github.com/MetaMask/react-native-webview.git#aeaf987f07dbce99c5b56aaba9bdf0d8c98772df",
"react-navigation": "4.0.10",
"react-navigation-drawer": "1.4.0",
"react-navigation-stack": "1.7.3",
Expand Down Expand Up @@ -188,7 +188,7 @@
"jest": "24.5.0",
"jest-serializer": "24.4.0",
"lint-staged": "8.1.5",
"metamask-mobile-provider": "^1.0.2",
"metamask-mobile-provider": "^1.1.0",
"metro": "0.55.0",
"metro-react-native-babel-preset": "0.53.0",
"octonode": "0.9.5",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7295,10 +7295,10 @@ merkle-patricia-tree@^2.1.2, merkle-patricia-tree@^2.3.2:
rlp "^2.0.0"
semaphore ">=1.0.1"

metamask-mobile-provider@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/metamask-mobile-provider/-/metamask-mobile-provider-1.0.2.tgz#b1d8e73c7ae816e6c22140ad4fa4010a80b0902c"
integrity sha512-2u/iAPTDDXfr262G8jmUNCQWPviSfoaVQ4UzJ1Z/tO9GiaIRsXwWFHip3mWTiC4Kglss455xf2J7u/08CP3RHg==
metamask-mobile-provider@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/metamask-mobile-provider/-/metamask-mobile-provider-1.1.0.tgz#477aa8ee55d91bd79a0f4c00a5083be159a5a678"
integrity sha512-GZLiq2sCPvYlHT4xYVklrAg6hWA/RZyFoekCtQz+842LbFtajHYmSb0DW5GDgEdQ/unaABU9A6BfKpfUurOe2A==

methods@^1.1.1:
version "1.1.2"
Expand Down Expand Up @@ -9673,9 +9673,9 @@ react-native-vector-icons@6.4.2:
version "2.6.0"
resolved "git+ssh://git@github.com/MetaMask/react-native-view-shot.git#17a65dc27222a78ad8942de3d536d7171bb2eb76"

"react-native-webview@git+ssh://git@github.com/MetaMask/react-native-webview.git#c756513b1f5a635cb49d0cfd01e25ca5c0887678":
"react-native-webview@git+ssh://git@github.com/MetaMask/react-native-webview.git#aeaf987f07dbce99c5b56aaba9bdf0d8c98772df":
version "7.0.5"
resolved "git+ssh://git@github.com/MetaMask/react-native-webview.git#c756513b1f5a635cb49d0cfd01e25ca5c0887678"
resolved "git+ssh://git@github.com/MetaMask/react-native-webview.git#aeaf987f07dbce99c5b56aaba9bdf0d8c98772df"
dependencies:
escape-string-regexp "1.0.5"
invariant "2.2.4"
Expand Down

0 comments on commit 935177b

Please sign in to comment.