Commit 6233df97 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

accounts db working

parent 731fa479
......@@ -126,6 +126,7 @@ android {
}
dependencies {
compile project(':react-native-secure-storage')
compile project(':react-native-camera')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
......
......@@ -4,6 +4,7 @@ import android.app.Application;
import android.util.Log;
import com.facebook.react.ReactApplication;
import com.reactlibrary.RNSecureStoragePackage;
import com.lwansbrough.RCTCamera.RCTCameraPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
......@@ -26,6 +27,7 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNSecureStoragePackage(),
new RCTCameraPackage(),
new EthkeyBridgePackage()
);
......
rootProject.name = 'NativeSigner'
include ':react-native-secure-storage'
project(':react-native-secure-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-secure-storage/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
......
......@@ -25,6 +25,7 @@
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
8E82ABE6A351418899C5974A /* libRCTCamera.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0462DF64F1D24C8E8B6E90B1 /* libRCTCamera.a */; };
A2CFCBD9D98F499CAA93C611 /* libRNSecureStorage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 396EC22E554C4FD282742D3C /* libRNSecureStorage.a */; };
EA529FD21E5A00B2004DF471 /* EthkeyBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = EA529FD11E5A00B2004DF471 /* EthkeyBridge.m */; };
EA529FF31E5A4261004DF471 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA529FF21E5A4261004DF471 /* String.swift */; };
EA529FF51E5A4EF2004DF471 /* EthkeyBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA529FF41E5A4EF2004DF471 /* EthkeyBridge.swift */; };
......@@ -214,6 +215,13 @@
remoteGlobalIDString = 58B5119B1A9E6C1200147676;
remoteInfo = RCTText;
};
EA612A0E1E64A6C50066FDB7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = B4B870E03B914F399A87AC44 /* RNSecureStorage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RNSecureStorage;
};
EA75C3411E3F45880098CCC9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 821AED75338B40468A2A8B7A /* RCTCamera.xcodeproj */;
......@@ -244,10 +252,13 @@
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = NativeSigner/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = NativeSigner/main.m; sourceTree = "<group>"; };
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
396EC22E554C4FD282742D3C /* libRNSecureStorage.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNSecureStorage.a; sourceTree = "<group>"; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
821AED75338B40468A2A8B7A /* RCTCamera.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RCTCamera.xcodeproj; path = "../node_modules/react-native-camera/ios/RCTCamera.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
B4B870E03B914F399A87AC44 /* RNSecureStorage.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNSecureStorage.xcodeproj; path = "../node_modules/react-native-secure-storage/ios/RNSecureStorage.xcodeproj"; sourceTree = "<group>"; };
EA1D158C1E6362E10058EE86 /* NativeSigner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = NativeSigner.entitlements; path = NativeSigner/NativeSigner.entitlements; sourceTree = "<group>"; };
EA529FD11E5A00B2004DF471 /* EthkeyBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EthkeyBridge.m; path = NativeSigner/EthkeyBridge.m; sourceTree = "<group>"; };
EA529FF11E5A4260004DF471 /* NativeSigner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NativeSigner-Bridging-Header.h"; sourceTree = "<group>"; };
EA529FF21E5A4261004DF471 /* String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = String.swift; path = NativeSigner/String.swift; sourceTree = "<group>"; };
......@@ -283,6 +294,7 @@
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
8E82ABE6A351418899C5974A /* libRCTCamera.a in Frameworks */,
A2CFCBD9D98F499CAA93C611 /* libRNSecureStorage.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -369,6 +381,7 @@
13B07FAE1A68108700A75B9A /* NativeSigner */ = {
isa = PBXGroup;
children = (
EA1D158C1E6362E10058EE86 /* NativeSigner.entitlements */,
EA529FF91E5A52AD004DF471 /* libsigner.a */,
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
......@@ -434,6 +447,7 @@
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
821AED75338B40468A2A8B7A /* RCTCamera.xcodeproj */,
B4B870E03B914F399A87AC44 /* RNSecureStorage.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
......@@ -477,6 +491,14 @@
name = Frameworks;
sourceTree = "<group>";
};
EA6129F11E64A6C50066FDB7 /* Products */ = {
isa = PBXGroup;
children = (
EA612A0F1E64A6C50066FDB7 /* libRNSecureStorage.a */,
);
name = Products;
sourceTree = "<group>";
};
EA75C33B1E3F45880098CCC9 /* Products */ = {
isa = PBXGroup;
children = (
......@@ -540,7 +562,12 @@
};
13B07F861A680F5B00A75B9A = {
DevelopmentTeam = T4ZYEBHX9P;
LastSwiftMigration = 0810;
LastSwiftMigration = 810;
SystemCapabilities = {
com.apple.Keychain = {
enabled = 1;
};
};
};
};
};
......@@ -604,6 +631,10 @@
ProductGroup = 146834001AC3E56700842450 /* Products */;
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
},
{
ProductGroup = EA6129F11E64A6C50066FDB7 /* Products */;
ProjectRef = B4B870E03B914F399A87AC44 /* RNSecureStorage.xcodeproj */;
},
);
projectRoot = "";
targets = (
......@@ -789,6 +820,13 @@
remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
EA612A0F1E64A6C50066FDB7 /* libRNSecureStorage.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRNSecureStorage.a;
remoteRef = EA612A0E1E64A6C50066FDB7 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
EA75C3421E3F45880098CCC9 /* libRCTCamera.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
......@@ -895,6 +933,8 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = "-lc++";
PRODUCT_NAME = "$(TARGET_NAME)";
......@@ -916,6 +956,8 @@
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
OTHER_LDFLAGS = "-lc++";
PRODUCT_NAME = "$(TARGET_NAME)";
......@@ -928,6 +970,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = NativeSigner/NativeSigner.entitlements;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
DEFINES_MODULE = YES;
......@@ -954,6 +997,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = NativeSigner/NativeSigner.entitlements;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = T4ZYEBHX9P;
......
......@@ -80,7 +80,7 @@
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
......
<?xml version="1.0" encoding="UTF-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>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)org.reactjs.native.example.NativeSigner</string>
</array>
</dict>
</plist>
......@@ -3,7 +3,7 @@
"version": "0.0.1",
"private": true,
"scripts": {
"install": "cd rust/signer && ./setup.sh",
"installX": "cd rust/signer && ./setup.sh",
"build-rust": "cd rust/signer && make",
"start": "npm run build-rust && node node_modules/react-native/local-cli/cli.js run-ios",
"test": "jest"
......@@ -16,6 +16,7 @@
"react-native-camera": "^0.5.1",
"react-native-qrcode": "^0.2.3",
"react-native-router-flux": "^3.37.0",
"react-native-secure-storage": "https://github.com/debris/react-native-secure-storage",
"react-native-tabs": "^1.0.9",
"react-redux": "^5.0.2",
"redux": "^3.6.0"
......
'use strict'
import { ADD_ACCOUNT, SELECT_ACCOUNT, DELETE_ACCOUNT, SET_PIN, CONFIRM_PIN } from '../constants/AccountActions'
import { ADD_ACCOUNT, SELECT_ACCOUNT, DELETE_ACCOUNT, SET_PIN, CONFIRM_PIN, SET_ACCOUNTS } from '../constants/AccountActions'
export function addAccount(account) {
return {
......@@ -29,3 +29,10 @@ export function setPin(pin) {
pin,
}
}
export function setAccounts(accounts) {
return {
type: SET_ACCOUNTS,
accounts,
}
}
'use strict'
import React, { Component } from 'react'
import { View, Text, StyleSheet } from 'react-native'
import { View, Text, StyleSheet, AppState } from 'react-native'
import { Provider, connect } from 'react-redux'
import { createStore } from 'redux'
import { Actions, ActionConst, Router, Scene } from 'react-native-router-flux'
......@@ -15,11 +15,17 @@ import Send from '../components/Send'
import Account from '../containers/Account'
import ConfirmTransaction from '../containers/ConfirmTransaction'
import { EnterPin, SetPin, ConfirmPin } from '../containers/Pin'
import { QrViewTransaction, QrViewAddress }from '../containers/QrView'
import { QrViewTransaction, QrViewAddress } from '../containers/QrView'
import { loadAccounts, saveAccounts } from '../util/db'
import { setAccounts } from '../actions/accounts'
const ConnectedRouter = connect()(Router)
const store = createStore(reducers)
loadAccounts().then(accounts => {
store.dispatch(setAccounts(accounts))
})
const styles = StyleSheet.create({
tabbar: {
backgroundColor: '#343E48',
......@@ -115,5 +121,25 @@ export default class App extends Component {
</Provider>
)
}
componentDidMount() {
AppState.addEventListener('change', this._handleAppStateChange);
}
componentWillUnmount() {
AppState.removeEventListener('change', this._handleAppStateChange);
}
_handleAppStateChange = (appState) => {
switch (appState) {
case 'inactive':
saveAccounts(store.getState().accounts.all)
break
case 'background':
break
case 'active':
break
}
}
}
......@@ -4,3 +4,4 @@ export const ADD_ACCOUNT = 'ACCOUNT_ACTION_ADD_ACCOUNT'
export const SELECT_ACCOUNT = 'ACCOUNT_ACTION_SELECT_ACCOUNT'
export const DELETE_ACCOUNT = 'ACCOUNT_ACTION_DELETE_ACCOUNT'
export const SET_PIN = 'ACCOUNT_ACTION_SET_PIN'
export const SET_ACCOUNTS = 'ACCOUNT_ACTION_SET_ACCOUNTS'
'use strict'
import { ADD_ACCOUNT, SELECT_ACCOUNT, DELETE_ACCOUNT, SET_PIN } from '../constants/AccountActions'
import { ADD_ACCOUNT, SELECT_ACCOUNT, DELETE_ACCOUNT, SET_PIN, SET_ACCOUNTS } from '../constants/AccountActions'
// format of the account
// {
// address: 'bF35fAA9C265bAf50C9CFF8c389C363B05753275',
// name: 'Test: Wallet',
// seed: '123',
// pin: ''
// }
// all accounts are loaded on init from db
const initialAccounts = {
all: [{
address: 'bF35fAA9C265bAf50C9CFF8c389C363B05753275',
name: 'Test: Wallet',
seed: '123',
pin: '',
}, {
address: '4EECf99D543B278106ac0c0e8ffe616F2137f10a',
name: 'Test: LockMyEther',
seed: '123',
pin: '',
}],
all: [],
selected: {},
}
......@@ -44,6 +43,11 @@ export default function accounts(state = initialAccounts, action) {
})
})
case SET_ACCOUNTS:
return Object.assign({}, state, {
all: action.accounts,
})
default:
return state
}
......
'use strict'
import SecureStorage from 'react-native-secure-storage'
const accountsStore = {
keychainService: 'accounts',
sharedPreferencesName: 'accounts',
}
export const deleteAccount = (account) => SecureStorage.deleteItem(account.address, accountsStore)
export const saveAccount = (account) =>
SecureStorage.setItem(account.address, JSON.stringify(account, null, 0), accountsStore)
export const saveAccounts = (accounts) => accounts.forEach(saveAccount)
export const loadAccounts = () => SecureStorage.getAllItems(accountsStore).then(
accounts => Object.values(accounts).map(account => JSON.parse(account))
)
import { EthkeyBridge } from 'NativeModules'
export const brainWalletAddress = EthkeyBridge.brainWalletAddress
export const brainWalletSecret = EthkeyBridge.brainWalletSecret
export const brainWalletSign = EthkeyBridge.brainWalletSign
export const rlpItem = EthkeyBridge.rlpItem
export const keccak = EthkeyBridge.keccak
export const brainWalletAddress = (seed) => EthkeyBridge.brainWalletAddress(seed)
export const brainWalletSecret = (seed) => EthkeyBridge.brainWalletSecret(seed)
export const brainWalletSign = (seed, message) => EthkeyBridge.brainWalletSign(seed, message)
export const rlpItem = (rlp, position) => EthkeyBridge.rlpItem(rlp, position)
export const keccak = (data) => EthkeyBridge.keccak(data)
'use strict'
import { fromWei } from './units'
describe('units', () => {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment