Commit 18dd4fc4 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

ethkey works in release mode on device

parent f870ff57
......@@ -14,11 +14,13 @@ class EthkeyBridge: NSObject {
NSLog("%@", name);
}
@objc func brainWallet(_ seed: String, callback: RCTResponseSenderBlock) -> Void {
@objc func brainWalletAddress(_ seed: String, callback: RCTResponseSenderBlock) -> Void {
var seed_ptr = seed.asPtr()
let keypair = ethkey_keypair_brainwallet(&seed_ptr)
let address_ptr = ethkey_keypair_address(keypair)
let keypair_ptr = ethkey_keypair_brainwallet(&seed_ptr)
let address_ptr = ethkey_keypair_address(keypair_ptr)
let address = String.fromStringPtr(ptr: address_ptr!.pointee)
ethkey_keypair_destroy(keypair_ptr)
ethkey_string_destroy(address_ptr)
callback([address])
}
}
......@@ -965,6 +965,7 @@
DEAD_CODE_STRIPPING = NO;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = T4ZYEBHX9P;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = NativeSigner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = ../rust/signer;
......@@ -989,6 +990,7 @@
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = T4ZYEBHX9P;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = NativeSigner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = ../rust/signer;
......
......@@ -16,10 +16,6 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
EthkeyBridge* bridge;
[bridge brainWallet:@[] callback:^(NSArray *cb) {
}];
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
......
......@@ -11,6 +11,6 @@
@interface RCT_EXTERN_MODULE(EthkeyBridge, NSObject)
RCT_EXTERN_METHOD(show:(NSString *)name)
RCT_EXTERN_METHOD(brainWallet:(NSString*)seed callback:(RCTResponseSenderBlock)callback)
RCT_EXTERN_METHOD(brainWalletAddress:(NSString*)seed callback:(RCTResponseSenderBlock)callback)
@end
......@@ -10,3 +10,7 @@ ethkey = { git = "https://github.com/ethcore/parity" }
[lib]
name = "signer"
crate-type = ["staticlib"]
# https://github.com/DaGenix/rust-crypto/issues/383
[replace]
"rust-crypto:0.2.36" = { git = "https://github.com/debris/rust-crypto" }
......@@ -5,7 +5,7 @@ all: $(LIB)
.PHONY: $(ARCHS)
$(ARCHS): %:
cargo build --target $@
cargo build --target $@ --release
$(LIB): $(ARCHS)
lipo -create -output $@ $(foreach arch,$(ARCHS),$(wildcard target/$(arch)/debug/$(LIB)))
lipo -create -output $@ $(foreach arch,$(ARCHS),$(wildcard target/$(arch)/release/$(LIB)))
......@@ -5,15 +5,15 @@ import { Actions } from 'react-native-router-flux'
import debounce from 'debounce'
import NewAccountInput from '../components/NewAccountInput'
import { words } from '../util/random'
import { keypairFromPhrase, toAddress, toAddressAsync } from '../util/crypto'
import { brainWalletAddress } from '../util/crypto'
import { selectAccount } from '../actions/accounts'
const mapDispatchToProps = (dispatch) => {
return {
addAccount: (account) => {
const address = toAddress(account.keypair)
dispatch(selectAccount({
address: address,
seed: account.seed,
address: account.address,
name: account.name,
}))
Actions.setPin()
......@@ -29,10 +29,15 @@ export class NewAccount extends Component {
this.state = {
seed: seed,
keypair: keypairFromPhrase(seed),
address: '',
name: '',
}
brainWalletAddress(seed, (address) => {
this.setState({
address: address,
})
})
}
render() {
......@@ -55,20 +60,20 @@ export class NewAccount extends Component {
<Text style={styles.hint}>brain wallet seed</Text>
<NewAccountInput seed={this.state.seed} onChangeText={
debounce((text) => {
//var keypair = keypairFromPhrase(text)
toAddressAsync(text, (address) => {
brainWalletAddress(text, (address) => {
self.setState({
//keypair:
seed: text,
address: address,
})
})
}, 100)}
/>
<Text style={styles.hint} adjustsFontSizeToFit={true}>0x{this.state.address}</Text>
<Text style={styles.address}>0x{this.state.address}</Text>
<Button
onPress={() => this.props.addAccount({
keypair: this.state.keypair,
name: this.state.name
seed: this.state.seed,
address: this.state.address,
name: this.state.name,
})}
title="Add Account"
color="green"
......@@ -89,6 +94,9 @@ const styles = StyleSheet.create({
hint: {
marginBottom: 20,
},
address: {
marginBottom: 20,
},
input: {
height: 20,
marginBottom: 20,
......
......@@ -13,8 +13,6 @@ export function keypairFromPhrase(phrase) {
export function toAddress(kp) { return keccak_256(kp.getPublic('buffer').slice(1)).substr(24); }
export function toAddressAsync(kp, callback) {
//EthkeyBridge.show("hello")
EthkeyBridge.brainWallet("" + 1, callback)
//return
export function brainWalletAddress(seed, callback) {
EthkeyBridge.brainWalletAddress(seed, callback)
}
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