From d269f4926eb5132959f9bf3d47830322abf10751 Mon Sep 17 00:00:00 2001 From: Overtorment Date: Sat, 12 Jan 2019 00:23:32 +0000 Subject: [PATCH 1/2] ADD: lapp-browser --- MainBottomTabs.js | 5 + android/app/build.gradle | 1 + .../java/com/bluewallet/MainApplication.java | 2 + .../bluewallet/MainApplication.java | 1 + android/settings.gradle | 2 + ios/BlueWallet.xcodeproj/project.pbxproj | 14 +- package-lock.json | 30 +++ package.json | 3 +- screen/lnd/browser.js | 175 ++++++++++++++++++ screen/wallets/transactions.js | 54 ++++-- 10 files changed, 268 insertions(+), 19 deletions(-) create mode 120000 android/app/src/main/java/io/bluewallet/bluewallet/MainApplication.java create mode 100644 screen/lnd/browser.js diff --git a/MainBottomTabs.js b/MainBottomTabs.js index 0d9bfca22..bdf09736f 100644 --- a/MainBottomTabs.js +++ b/MainBottomTabs.js @@ -35,6 +35,7 @@ import Success from './screen/send/success'; import ManageFunds from './screen/lnd/manageFunds'; import ScanLndInvoice from './screen/lnd/scanLndInvoice'; +import LappBrowser from './screen/lnd/browser'; import LNDCreateInvoice from './screen/lnd/lndCreateInvoice'; import LNDViewInvoice from './screen/lnd/lndViewInvoice'; import LNDViewAdditionalInvoiceInformation from './screen/lnd/lndViewAdditionalInvoiceInformation'; @@ -243,6 +244,10 @@ const MainBottomTabs = createStackNavigator( ScanQrAddress: { screen: sendScanQrAddress, }, + LappBrowser: { + screen: LappBrowser, + }, + ReorderWallets: { screen: ReorderWalletsStackNavigator, navigationOptions: { diff --git a/android/app/build.gradle b/android/app/build.gradle index a497ca33e..0d37d143c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -147,6 +147,7 @@ android { } dependencies { + compile project(':react-native-webview') compile project(':react-native-camera') compile project(':react-native-fs') compile project(':react-native-gesture-handler') diff --git a/android/app/src/main/java/com/bluewallet/MainApplication.java b/android/app/src/main/java/com/bluewallet/MainApplication.java index f23a9d761..667c0f131 100644 --- a/android/app/src/main/java/com/bluewallet/MainApplication.java +++ b/android/app/src/main/java/com/bluewallet/MainApplication.java @@ -3,6 +3,7 @@ package io.bluewallet.bluewallet; import android.app.Application; import com.facebook.react.ReactApplication; +import com.reactnativecommunity.webview.RNCWebViewPackage; import com.oblador.vectoricons.VectorIconsPackage; import com.horcrux.svg.SvgPackage; import io.sentry.RNSentryPackage; @@ -35,6 +36,7 @@ public class MainApplication extends Application implements ReactApplication { protected List getPackages() { return Arrays.asList( new MainReactPackage(), + new RNCWebViewPackage(), new RNFSPackage() , new VectorIconsPackage(), new SvgPackage(), diff --git a/android/app/src/main/java/io/bluewallet/bluewallet/MainApplication.java b/android/app/src/main/java/io/bluewallet/bluewallet/MainApplication.java new file mode 120000 index 000000000..93dacb59d --- /dev/null +++ b/android/app/src/main/java/io/bluewallet/bluewallet/MainApplication.java @@ -0,0 +1 @@ +../../../../../../../.././android/app/src/main/java/com/bluewallet/MainApplication.java \ No newline at end of file diff --git a/android/settings.gradle b/android/settings.gradle index ebf3a38a9..11636f24e 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,4 +1,6 @@ rootProject.name = 'BlueWallet' +include ':react-native-webview' +project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android') include ':react-native-camera' project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android') include ':react-native-fs' diff --git a/ios/BlueWallet.xcodeproj/project.pbxproj b/ios/BlueWallet.xcodeproj/project.pbxproj index acc718bf8..1e1392563 100644 --- a/ios/BlueWallet.xcodeproj/project.pbxproj +++ b/ios/BlueWallet.xcodeproj/project.pbxproj @@ -5,7 +5,6 @@ }; objectVersion = 46; objects = { - /* Begin PBXBuildFile section */ 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; @@ -74,6 +73,7 @@ F6AA297664414342AC23B529 /* libRNFS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F9F01E9C22C243A9AB48A90A /* libRNFS.a */; }; F97F051969164CCBA5336FC2 /* libRNRandomBytes.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 907C87020BD04956A5253DEB /* libRNRandomBytes.a */; }; FDE69393B0DE46149DDB7E3C /* FontAwesome5_Solid.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C0708F2D346B415C84383510 /* FontAwesome5_Solid.ttf */; }; + A2C00245B747440ABEB7D316 /* libRNCWebView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 81EDDF247D484BC38EBCE565 /* libRNCWebView.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -564,6 +564,8 @@ F9F01E9C22C243A9AB48A90A /* libRNFS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFS.a; sourceTree = ""; }; F9FC88F4A85F40E9ABACACB9 /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Octicons.ttf"; sourceTree = ""; }; FDDDD64DF1014CDE82A5D7D9 /* ReactNativePermissions.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = ReactNativePermissions.xcodeproj; path = "../node_modules/react-native-permissions/ios/ReactNativePermissions.xcodeproj"; sourceTree = ""; }; + 642C144246BF4C3EB350442F /* RNCWebView.xcodeproj */ = {isa = PBXFileReference; name = "RNCWebView.xcodeproj"; path = "../node_modules/react-native-webview/ios/RNCWebView.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; }; + 81EDDF247D484BC38EBCE565 /* libRNCWebView.a */ = {isa = PBXFileReference; name = "libRNCWebView.a"; path = "libRNCWebView.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -608,6 +610,7 @@ 6FEBC8E7AA7D4744A2EEE87B /* libRNGestureHandler.a in Frameworks */, F439E4EEAE42446B8AE33E3F /* libRNCamera.a in Frameworks */, F6AA297664414342AC23B529 /* libRNFS.a in Frameworks */, + A2C00245B747440ABEB7D316 /* libRNCWebView.a in Frameworks */, 228DCD6BAF1B4DF181C5A307 /* libRNRate.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -837,6 +840,7 @@ DAC908621D184867839621FE /* RNGestureHandler.xcodeproj */, 7F7225A9F01C4785B27FF490 /* RNCamera.xcodeproj */, C0B6F9440F69425886845061 /* RNFS.xcodeproj */, + 642C144246BF4C3EB350442F /* RNCWebView.xcodeproj */, D6051C6440444360BD29AFE4 /* RNRate.xcodeproj */, ); name = Libraries; @@ -1827,6 +1831,7 @@ "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-camera/ios/**", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-webview/ios", "$(SRCROOT)/../node_modules/react-native-rate/ios", ); INFOPLIST_FILE = BlueWalletTests/Info.plist; @@ -1866,6 +1871,7 @@ "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-camera/ios/**", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-webview/ios", "$(SRCROOT)/../node_modules/react-native-rate/ios", ); INFOPLIST_FILE = BlueWalletTests/Info.plist; @@ -1906,6 +1912,7 @@ "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-camera/ios/**", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-webview/ios", "$(SRCROOT)/../node_modules/react-native-rate/ios", ); INFOPLIST_FILE = BlueWallet/Info.plist; @@ -1944,6 +1951,7 @@ "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-camera/ios/**", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-webview/ios", "$(SRCROOT)/../node_modules/react-native-rate/ios", ); INFOPLIST_FILE = BlueWallet/Info.plist; @@ -1988,6 +1996,7 @@ "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-camera/ios/**", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-webview/ios", "$(SRCROOT)/../node_modules/react-native-rate/ios", ); INFOPLIST_FILE = "BlueWallet-tvOS/Info.plist"; @@ -2035,6 +2044,7 @@ "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-camera/ios/**", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-webview/ios", "$(SRCROOT)/../node_modules/react-native-rate/ios", ); INFOPLIST_FILE = "BlueWallet-tvOS/Info.plist"; @@ -2081,6 +2091,7 @@ "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-camera/ios/**", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-webview/ios", "$(SRCROOT)/../node_modules/react-native-rate/ios", ); INFOPLIST_FILE = "BlueWallet-tvOSTests/Info.plist"; @@ -2127,6 +2138,7 @@ "$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**", "$(SRCROOT)/../node_modules/react-native-camera/ios/**", "$(SRCROOT)/../node_modules/react-native-fs/**", + "$(SRCROOT)/../node_modules/react-native-webview/ios", "$(SRCROOT)/../node_modules/react-native-rate/ios", ); INFOPLIST_FILE = "BlueWallet-tvOSTests/Info.plist"; diff --git a/package-lock.json b/package-lock.json index c83f77648..8e6315caa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9546,6 +9546,36 @@ } } }, + "react-native-webview": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/react-native-webview/-/react-native-webview-2.8.0.tgz", + "integrity": "sha512-JNpAm4vOJ17xBWeZdNTlFdmDHz3E0n8VILahISSyN6Flzlv1Cmw/i/H/no7HWE990ipZNTuG4VaDxCPeJ5vJlg==", + "requires": { + "escape-string-regexp": "^1.0.5", + "fbjs": "^0.8.17" + }, + "dependencies": { + "core-js": { + "version": "1.2.7", + "resolved": "http://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" + }, + "fbjs": { + "version": "0.8.17", + "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.17.tgz", + "integrity": "sha1-xNWY6taUkRJlPWWIsBpc3Nn5D90=", + "requires": { + "core-js": "^1.0.0", + "isomorphic-fetch": "^2.1.1", + "loose-envify": "^1.0.0", + "object-assign": "^4.1.0", + "promise": "^7.1.1", + "setimmediate": "^1.0.5", + "ua-parser-js": "^0.7.18" + } + } + } + }, "react-navigation": { "version": "3.0.9", "resolved": "https://registry.npmjs.org/react-navigation/-/react-navigation-3.0.9.tgz", diff --git a/package.json b/package.json index d61aeda4d..a1be1368d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "BlueWallet", - "version": "3.5.6", + "version": "3.6.0", "devDependencies": { "babel-eslint": "^8.2.6", "babel-jest": "23.6.0", @@ -82,6 +82,7 @@ "react-native-sortable-list": "0.0.22", "react-native-svg": "^8.0.10", "react-native-vector-icons": "^6.0.2", + "react-native-webview": "2.8.0", "react-navigation": "^3.0.9", "react-test-render": "^1.1.1", "readable-stream": "^1.1.14", diff --git a/screen/lnd/browser.js b/screen/lnd/browser.js new file mode 100644 index 000000000..c8d1ea1a8 --- /dev/null +++ b/screen/lnd/browser.js @@ -0,0 +1,175 @@ +import React, { Component } from 'react'; +import { View, Alert } from 'react-native'; +import { WebView } from 'react-native-webview'; +import { BlueNavigationStyle } from '../../BlueComponents'; +import { FormInput } from 'react-native-elements'; +import Ionicons from 'react-native-vector-icons/Ionicons'; +import PropTypes from 'prop-types'; + +export default class Browser extends Component { + static navigationOptions = ({ navigation }) => ({ + ...BlueNavigationStyle(navigation, true), + title: 'Lapp Browser', + headerLeft: null, + }); + + constructor(props) { + super(props); + this.state = { url: '' }; + } + + render() { + return ( + + + { + this.webview.goBack(); + }} + name={'ios-arrow-round-back'} + size={26} + style={{ + color: 'red', + backgroundColor: 'transparent', + minWidth:36, + paddingLeft:10, + left: 8, + top: 1, + }} + /> + + + + { + this.webview.reload(); + }} + name={'ios-sync'} + size={26} + style={{ + color: 'red', + backgroundColor: 'transparent', + left: 8, + top: 1, + }} + /> + + + (this.webview = ref)} + source={{ uri: 'https://bluewallet.io/marketplace/' }} + onMessage={e => { + // this is a handler which receives messages sent from within the browser + let json = false; + try { + json = JSON.parse(e.nativeEvent.data); + } catch (_) {} + // message from browser has ln invoice + if (json && json.pay) { + Alert.alert( + 'Page', + 'This page asks for permission to pay this invoice', + [ + { text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel' }, + { + text: 'Pay', + onPress: () => { + console.log('OK Pressed'); + this.props.navigation.navigate({ + routeName: 'ScanLndInvoice', + params: { + uri: json.pay, + }, + }); + }, + }, + ], + { cancelable: false }, + ); + } + }} + onLoadEnd={e => { + this.setState({ url: e.nativeEvent.url }); + + this.webview.injectJavaScript(` + + lastTimeTriedToPay = 0; + function tryToPay(invoice) { + if (+new Date() - lastTimeTriedToPay >= 3000) { + window.postMessage(JSON.stringify({pay:invoice})); + lastTimeTriedToPay = +new Date(); + } + } + + + + setInterval(function(){ + + var searchText = "lnbc"; + + var aTags = document.getElementsByTagName("span"); + for (var i = 0; i < aTags.length; i++) { + if (aTags[i].textContent.indexOf(searchText) === 0) { + tryToPay(aTags[i].textContent); + aTags[i].replaceWith('Invoice intercepted by BlueWallet'); + break; + } + } + + + ////////////////////////////////// + ////////////////////////////////// + ////////////////////////////////// + + + var aTags = document.getElementsByTagName("input"); + + for (var i = 0; i < aTags.length; i++) { + if (aTags[i].value.indexOf(searchText) === 0) { + tryToPay(aTags[i].value); + aTags[i].replaceWith('Invoice intercepted by BlueWallet'); + break; + } + } + + + + ////////////////////////////////// + ////////////////////////////////// + ////////////////////////////////// + + + var aTags = document.getElementsByTagName("a"); + var searchText = "lightning:lnbc"; + + for (var i = 0; i < aTags.length; i++) { + let href = aTags[i].getAttribute('href') + ''; + if (href.indexOf(searchText) === 0) { + tryToPay(href.replace('lightning:', '')); + aTags[i].replaceWith('Invoice intercepted by BlueWallet'); + break; + } + } + + }, 1000); + `); + }} + /> + + ); + } +} + +Browser.propTypes = { + navigation: PropTypes.shape({ + navigate: PropTypes.func, + }), +}; diff --git a/screen/wallets/transactions.js b/screen/wallets/transactions.js index ab39987b4..adbec1db1 100644 --- a/screen/wallets/transactions.js +++ b/screen/wallets/transactions.js @@ -367,23 +367,43 @@ export default class WalletTransactions extends Component { {(() => { if (this.state.showManageFundsSmallButton) { return ( - { - console.log('navigating to', this.state.wallet.getLabel()); - navigate('ManageFunds', { fromWallet: this.state.wallet }); - }} - > - {loc.lnd.title} - - + + { + console.log('navigating to LappBrowser'); + navigate('LappBrowser', { fromSecret: this.state.wallet.getSecret() }); + }} + > + {'marketplace'} + + + + { + console.log('navigating to', this.state.wallet.getLabel()); + navigate('ManageFunds', { fromSecret: this.state.wallet.getSecret() }); + }} + > + {loc.lnd.title} + + + ); } })()} From f518c5b55493b71c8194df5b66804cb54b5da5dc Mon Sep 17 00:00:00 2001 From: felixdragon <32230902+felixdragon@users.noreply.github.com> Date: Sat, 12 Jan 2019 09:35:28 +0900 Subject: [PATCH 2/2] Update jp_JP.js on new strings. --- loc/jp_JP.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/loc/jp_JP.js b/loc/jp_JP.js index f816ee455..12a4f51cf 100644 --- a/loc/jp_JP.js +++ b/loc/jp_JP.js @@ -179,12 +179,12 @@ module.exports = { retype_password: 'パスワードの再入力', passwords_do_not_match: 'パスワードが一致しません', encrypt_storage: 'ストレージの暗号化', - lightning_settings: 'Lightning settings', + lightning_settings: 'Lightning 設定', lightning_settings_explain: - 'To connect to your own LND node please install LndHub' + - ' and put its URL here in settings. Leave blank to use default ' + + '他の LND ノードへ接続するには LndHub をインストール後、' + + 'URL を入力してください。既定の設定を使用するには空欄にします' + 'ndHub\n (lndhub.io)', - save: 'save', + save: '保存', about: 'BlueWallet について', language: '言語', currency: '通貨',