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

Upgrading to WalletConnect v1.0.0-beta #3

Merged
merged 62 commits into from May 9, 2019
Merged
Changes from 55 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f3711cf
pedrouid: getting the dev environment up and running locally
pedrouid Feb 1, 2019
fa68654
uninstall rn-walletconnect-wallet
pedrouid Feb 1, 2019
18d1942
install @walletconnect/react-native
pedrouid Feb 1, 2019
206a2d8
first draft
pedrouid Feb 1, 2019
36fcc5f
bignumber, prettier, etc
pedrouid Feb 6, 2019
360c91a
create new firebase model, replace withAddWalletConnector with withIn…
pedrouid Feb 6, 2019
3dd4ce3
refactor walletConnectInitAllConnectors and walletConnectDisconnectAll
pedrouid Feb 6, 2019
b5f73a8
manually revert prettier changes
pedrouid Feb 6, 2019
f291c35
manually revert MORE prettier changes
pedrouid Feb 6, 2019
2abd172
resolve merge conflicts
pedrouid Feb 6, 2019
dfb2fac
reverting more prettier changes
pedrouid Feb 6, 2019
3ed7434
Merge pull request #405 from balance-io/pedrouid-refactor-walletconne…
pedrouid Feb 6, 2019
9b7f4d0
delete walletconnect model, delete addTransactionsToApprove, delete w…
pedrouid Feb 6, 2019
2969154
refactor walletConnectSendStatus
pedrouid Feb 6, 2019
900c14a
refactor push notifications, rename callData to payload, rename sessi…
pedrouid Feb 6, 2019
8007e23
rename callId to requestId
pedrouid Feb 6, 2019
86e4af6
refactor walletConnectInitNewSession and get chainId from settings re…
pedrouid Feb 7, 2019
c01d127
refactor Navigation.handleAction, add setTopLevelNavigator, add subcr…
pedrouid Feb 7, 2019
f92547e
differentiate payload from callData
pedrouid Feb 7, 2019
c9b6435
remove unused check
pedrouid Feb 7, 2019
d8ebce2
deleted connections model file (not used anywhere)
pedrouid Feb 7, 2019
c828b91
deleted personalData model file (not used anywhere)
pedrouid Feb 7, 2019
5b10304
refactor src/redux/walletconnect.js
pedrouid Feb 7, 2019
f6f08e4
typo
pedrouid Feb 7, 2019
2475db0
first draft walletconfirmation modal
pedrouid Feb 7, 2019
5ef52fb
change bundle identifier for testing
pedrouid Feb 7, 2019
3dc0153
install balance-common from pedrouid-walletconnect branch
pedrouid Feb 7, 2019
8fb54c6
refactor walletconnect reducer
pedrouid Feb 7, 2019
792bd92
rename callData to paylaod
pedrouid Feb 7, 2019
21db9b5
debug example.walletconnect.org connection
pedrouid Feb 8, 2019
c5fa16b
some more changes
pedrouid Feb 27, 2019
c1c8528
catching up with dev
jinchung Apr 23, 2019
73ee76a
bumping up common version
jinchung Apr 23, 2019
9bd243e
reverting some workspace specific settings
jinchung Apr 23, 2019
a51ebc9
cleanup
jinchung Apr 23, 2019
a7272d3
cleanup
jinchung Apr 23, 2019
36fdc72
cleanup
jinchung Apr 23, 2019
f7b9a29
cleanup
jinchung Apr 23, 2019
a86815a
updates for permissions checks
jinchung Apr 24, 2019
d9afb2f
TEMP STATE
jinchung Apr 24, 2019
cb1d0b6
connecting to walletconnect dapp
jinchung Apr 24, 2019
3c4a1ce
catching up with dev
jinchung Apr 26, 2019
274e788
bugfix for sending txn and status via walletconnect
jinchung Apr 26, 2019
b81cc04
store wc sessions
jinchung Apr 27, 2019
96f386b
logo to show up on confirmation page
jinchung Apr 27, 2019
7bfdcad
retrieving timestamp from json rpc from wc
jinchung Apr 27, 2019
aaafdf6
fix for rejecting call request
jinchung Apr 27, 2019
4f01342
fix for disabled button on coin request row while rest of row worked
jinchung Apr 27, 2019
a5f167d
loading saved requests from wc
jinchung Apr 27, 2019
efb96b0
clean up
jinchung Apr 27, 2019
5c791aa
relisten to socket when re-initialized on app open
jinchung Apr 28, 2019
e76b449
fixes for requests ordering
jinchung May 9, 2019
827ef41
catching up with dev
jinchung May 9, 2019
7440b65
clean
jinchung May 9, 2019
c56092a
bumping up version
jinchung May 9, 2019
4075af3
clean
jinchung May 9, 2019
731a183
cleanup
jinchung May 9, 2019
9925fed
cleanup
jinchung May 9, 2019
e03aeac
more cleanup
jinchung May 9, 2019
7ca2941
clean
jinchung May 9, 2019
371600b
cleanup
jinchung May 9, 2019
18c73b9
version update and changelog
jinchung May 9, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -254,11 +254,11 @@ SPEC CHECKSUMS:
Crashlytics: 55e24fc23989680285a21cb1146578d9d18e432c
DoubleConversion: bb338842f62ab1d708ceb63ec3d999f0f3d98ecd
Fabric: 25d0963b691fc97be566392243ff0ecef5a68338
Firebase: 68afeeb05461db02d7c9e3215cda28068670f4aa
FirebaseAnalytics: b3628aea54c50464c32c393fb2ea032566e7ecc2
FirebaseCore: 62f1b792a49bb9e8b4073f24606d2c93ffc352f0
FirebaseInstanceID: f3f0657372592ecdfdfe2cac604a5a75758376a6
FirebaseMessaging: 6894b8fe0a0cf26c3b13dad729f1131654ae0bdb
Firebase: 76ec2a7cde90fb4037793f83aeeca48451543487
FirebaseAnalytics: b8bce8d5c40173328b8a4300da18c5c7e0a1908d
FirebaseCore: 31d258ec80ea97e1e8e40ce00a7ba7297afb45c2
FirebaseInstanceID: 4f7768a98c5c3c5bd9a4c9e431ea98dccc0a51f9
FirebaseMessaging: 94579ae655d817287f029ebfebd5b0811fbb3a51
FLAnimatedImage: 4a0b56255d9b05f18b6dd7ee06871be5d3b89e31
Folly: de497beb10f102453a1afa9edbf8cf8a251890de
glog: aefd1eb5dda2ab95ba0938556f34b98e2da3a60d
@@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>10</string>
<string>11</string>
<key>CodePushDeploymentKey</key>
<string>$(CODEPUSH_KEY)</string>
<key>ITSAppUsesNonExemptEncryption</key>
@@ -2,7 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>aps-environment</key>
<string>development</string>
</dict>
<dict/>
</plist>
@@ -1,8 +1,9 @@
{
"name": "Rainbow",
"version": "0.4.0-10",
"version": "0.4.0-11",
"private": true,
"scripts": {
"clean:cache": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean --force && npm cache verify",
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"install-pods": "cd ios && pod install && cd ..",
@@ -15,6 +16,7 @@
"@hocs/omit-props": "^0.4.0",
"@hocs/safe-timers": "^0.4.0",
"@hocs/with-view-layout-props": "^0.2.0",
"@walletconnect/react-native": "^1.0.0-beta.18",
"@rainbow-me/rainbow-common": "^0.8.1",
"@react-native-community/async-storage": "1.3.3",
"@react-native-community/blur": "^3.3.1",
@@ -102,7 +104,6 @@
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"rn-nodeify": "^10.0.1",
"rn-walletconnect-wallet": "^0.7.24",
"stream-browserify": "^1.0.0",
"string_decoder": "^0.10.31",
"styled-components": "4.1.2",
@@ -2,14 +2,13 @@ import { get, isEmpty } from 'lodash';
import PropTypes from 'prop-types';
import {
accountLoadState,
commonStorage,
settingsInitializeState,
settingsUpdateAccountAddress,
} from '@rainbow-me/rainbow-common';
import React, { Component } from 'react';
import { Alert, AppRegistry, AppState } from 'react-native';
import { StackActions } from 'react-navigation';
import CodePush from 'react-native-code-push';
import { StackActions } from 'react-navigation';
import firebase from 'react-native-firebase';
import { useScreens } from 'react-native-screens';
import { connect, Provider } from 'react-redux';
@@ -19,21 +18,17 @@ import OfflineBadge from './components/OfflineBadge';
import {
withAccountRefresh,
withHideSplashScreen,
withRequestsInit,
withWalletConnectConnections,
} from './hoc';
import {
addTransactionToApprove,
addTransactionsToApprove,
transactionIfExists,
transactionsToApproveInit,
} from './redux/transactionsToApprove';
import {
walletConnectInitAllConnectors,
walletConnectGetAllRequests,
walletConnectGetRequest,
} from './model/walletconnect';
import store from './redux/store';
import { walletInit } from './model/wallet';
import {
saveFCMToken,
registerTokenRefreshListener,
registerNotificationListener,
registerNotificationOpenedListener,
} from './model/firebase';
import Routes from './screens/Routes';
import Navigation from './navigation';

@@ -46,16 +41,13 @@ useScreens();
class App extends Component {
static propTypes = {
accountLoadState: PropTypes.func,
addTransactionsToApprove: PropTypes.func,
addTransactionToApprove: PropTypes.func,
getValidWalletConnectors: PropTypes.func,
onHideSplashScreen: PropTypes.func,
refreshAccount: PropTypes.func,
settingsInitializeState: PropTypes.func,
settingsUpdateAccountAddress: PropTypes.func,
setWalletConnectors: PropTypes.func,
walletConnectInitAllConnectors: PropTypes.func,
sortedWalletConnectors: PropTypes.arrayOf(PropTypes.object),
transactionIfExists: PropTypes.func,
transactionsToApproveInit: PropTypes.func,
}

@@ -67,20 +59,13 @@ class App extends Component {
await this.handleWalletConfig();
this.props.onHideSplashScreen();
await this.props.refreshAccount();
AppState.addEventListener('change', this.handleAppStateChange);
firebase.messaging().getToken()
.then(fcmToken => {
if (fcmToken) {
commonStorage.saveLocal('rainbowFcmToken', { data: fcmToken });
}
})
.catch(error => {
console.log('error getting fcm token', error);
});

this.onTokenRefreshListener = firebase.messaging().onTokenRefresh(fcmToken => {
commonStorage.saveLocal('rainbowFcmToken', { data: fcmToken });
});

saveFCMToken();
this.onTokenRefreshListener = registerTokenRefreshListener();

//this.notificationListener = registerNotificationListener();

//this.notificationOpenedListener = registerNotificationOpenedListener();

this.notificationListener = firebase.notifications().onNotification(notification => {
const navState = get(this.navigatorRef, 'state.nav');
@@ -116,43 +101,29 @@ class App extends Component {
}
this.props.settingsInitializeState();
this.props.accountLoadState();
this.props.walletConnectInitAllConnectors();
this.props.transactionsToApproveInit();
try {
const allConnectors = await walletConnectInitAllConnectors();
if (allConnectors) {
this.props.setWalletConnectors(allConnectors);
}
} catch (error) {
console.log('Unable to init all WalletConnect sessions');
}
/*
const notificationOpen = await firebase.notifications().getInitialNotification();
if (notificationOpen) {
const { callId, sessionId } = notificationOpen.notification.data;
this.onPushNotificationOpened(callId, sessionId, false);
}
this.fetchAllRequestsFromWalletConnectSessions();
*/
return walletAddress;
} catch (error) {
Alert.alert('Error: Failed to initialize wallet.');
return null;
}
};

handleAppStateChange = async (nextAppState) => {
if (this.state.appState.match(/unknown|background/) && nextAppState === 'active') {
this.fetchAllRequestsFromWalletConnectSessions();
}
this.setState({ appState: nextAppState });
}

componentWillUnmount() {
AppState.removeEventListener('change', this.handleAppStateChange);
this.notificationListener();
this.notificationOpenedListener();
this.onTokenRefreshListener();
}

handleNavigatorRef = (navigatorRef) => { this.navigatorRef = navigatorRef; }
handleNavigatorRef = (navigatorRef) => Navigation.setTopLevelNavigator(navigatorRef)

handleOpenConfirmTransactionModal = (transactionDetails, autoOpened) => {
if (!this.navigatorRef) return;
@@ -163,54 +134,20 @@ class App extends Component {
Navigation.handleAction(this.navigatorRef, action);
}

fetchAllRequestsFromWalletConnectSessions = async () => {
try {
const allConnectors = this.props.getValidWalletConnectors();
if (!isEmpty(allConnectors)) {
const allRequests = await walletConnectGetAllRequests(allConnectors);
if (!isEmpty(allRequests)) {
this.props.addTransactionsToApprove(allRequests);
await firebase.notifications().removeAllDeliveredNotifications();
}
}
} catch (error) {
console.log('error fetching all requests from wallet connect', error);
}
}

onPushNotificationOpened = async (callId, sessionId, autoOpened) => {
const existingTransaction = this.props.transactionIfExists(callId);
if (existingTransaction) {
this.handleOpenConfirmTransactionModal(existingTransaction, autoOpened);
const transaction = await this.fetchAndAddWalletConnectRequest(callId, sessionId);
if (transaction) {
this.handleOpenConfirmTransactionModal(transaction, autoOpened);
} else {
const transaction = await this.fetchAndAddWalletConnectRequest(callId, sessionId);
if (transaction) {
this.handleOpenConfirmTransactionModal(transaction, autoOpened);
const fetchedTransaction = null; //this.props.transactionIfExists(callId);
if (fetchedTransaction) {
this.handleOpenConfirmTransactionModal(fetchedTransaction, autoOpened);
} else {
const fetchedTransaction = this.props.transactionIfExists(callId);
if (fetchedTransaction) {
this.handleOpenConfirmTransactionModal(fetchedTransaction, autoOpened);
} else {
Alert.alert('This request has expired.');
}
Alert.alert('This request has expired.');
}
}
}

fetchAndAddWalletConnectRequest = async (callId, sessionId) => {
try {
const walletConnector = this.props.sortedWalletConnectors.find(({ _sessionId }) => (_sessionId === sessionId));
const callData = await walletConnectGetRequest(callId, walletConnector);
if (!callData) return null;

const { dappName } = walletConnector;
return this.props.addTransactionToApprove(sessionId, callId, callData, dappName);
} catch (error) {
console.log('error fetching wallet connect request');
return null;
}
}

render = () => (
<Provider store={store}>
<FlexItem>
@@ -227,18 +164,15 @@ class App extends Component {
const AppWithRedux = compose(
withProps({ store }),
withAccountRefresh,
withRequestsInit,
withHideSplashScreen,
withWalletConnectConnections,
connect(
null,
{
accountLoadState,
addTransactionsToApprove,
addTransactionToApprove,
settingsInitializeState,
settingsUpdateAccountAddress,
transactionIfExists,
transactionsToApproveInit,
},
),
)(App);
@@ -63,6 +63,7 @@ const RequestCoinRow = ({
padding-right: 12;
`}
onPress={onPressOpen}
disabled={false}
size="small"
textProps={{ size: 'smedium' }}
>
@@ -0,0 +1,4 @@
import { withProps } from 'recompact';
import Text from './Text';

export default withProps({ weight: 'bold' })(Text);
@@ -1,3 +1,4 @@
export { default as Bold } from './Bold';
export { default as Br } from './Br';
export { default as Emoji } from './Emoji';
export { default as ErrorText } from './ErrorText';
@@ -1,11 +1,9 @@
import { distanceInWordsStrict } from 'date-fns';
import { pickBy, values } from 'lodash';
import lang from 'i18n-js';
import PropTypes from 'prop-types';
import React from 'react';
import { compose, onlyUpdateForKeys, withHandlers } from 'recompact';
import lang from 'i18n-js';
import { compose, withHandlers } from 'recompact';
import { withWalletConnectConnections } from '../../hoc';
import { walletConnectDisconnectAll } from '../../model/walletconnect';
import { padding } from '../../styles';
import { RequestVendorLogoIcon } from '../coin-icon';
import ContextMenu from '../ContextMenu';
@@ -26,25 +24,19 @@ const enhance = compose(
withHandlers({
onPressActionSheet: ({
dappName,
getValidWalletConnectors,
removeWalletConnectorByDapp,
walletConnectDisconnectAllByDappName,
}) => (buttonIndex) => {
if (buttonIndex === 0) {
const validSessions = getValidWalletConnectors();
const dappSessions = values(pickBy(validSessions, (session) => session.dappName === dappName));

walletConnectDisconnectAll(dappSessions).then(() => {
removeWalletConnectorByDapp(dappName);
});
walletConnectDisconnectAllByDappName(dappName);
}
},
}),
onlyUpdateForKeys(['expires']),
);

const WalletConnectListItem = enhance(({
dappName,
expires,
dappIcon,
dappUrl,
onPressActionSheet,
}) => (
<Row align="center" height={WalletConnectListItemHeight}>
@@ -56,6 +48,7 @@ const WalletConnectListItem = enhance(({
>
<RequestVendorLogoIcon
dappName={dappName}
imageUrl={dappIcon}
size={VendorLogoIconSize}
/>
<ColumnWithMargins
@@ -66,9 +59,6 @@ const WalletConnectListItem = enhance(({
<TruncatedText letterSpacing="tight" size="lmedium" weight="medium">
{dappName || 'Unknown connection'}
</TruncatedText>
<Text color="blueGreyLightest" size="medium">
Expires in {distanceInWordsStrict(Date.now(), expires)}
</Text>
</ColumnWithMargins>
</Row>
<Centered>
@@ -88,7 +78,8 @@ const WalletConnectListItem = enhance(({

WalletConnectListItem.propTypes = {
dappName: PropTypes.string.isRequired,
expires: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
dappIcon: PropTypes.string.isRequired,
dappUrl: PropTypes.string.isRequired,
onPressActionSheet: PropTypes.func.isRequired,
};

@@ -0,0 +1,3 @@
import { Platform, NativeModules } from 'react-native';

export const DEVICE_LANGUAGE = Platform.OS === 'ios' ? NativeModules.SettingsManager.settings.AppleLocale : NativeModules.I18nManager.localeIdentifier;
@@ -4,7 +4,6 @@ export { default as withAccountReset } from './withAccountReset';
export { default as withAccountSettings } from './withAccountSettings';
export { default as withAccountTransactions } from './withAccountTransactions';
export { default as withActionSheetManager } from './withActionSheetManager';
export { default as withAddWalletConnector } from './withAddWalletConnector';
export { default as withAppState } from './withAppState';
export { default as withBlurTransitionProps } from './withBlurTransitionProps';
export { default as withFetchingPrices } from './withFetchingPrices';
@@ -21,4 +20,6 @@ export { default as withSafeAreaViewInsetValues } from './withSafeAreaViewInsetV
export { default as withSendFeedback } from './withSendFeedback';
export { default as withTransactionConfirmationScreen } from './withTransactionConfirmationScreen';
export { default as withTransitionProps } from './withTransitionProps';
export { default as withWalletConnectConfirmationModal } from './withWalletConnectConfirmationModal';
export { default as withWalletConnectConnections } from './withWalletConnectConnections';
export { default as withWalletConnectOnSessionRequest } from './withWalletConnectOnSessionRequest';

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.