Skip to content
This repository has been archived by the owner on Apr 26, 2019. It is now read-only.

add app icon and handling return from TW #16

Merged
merged 1 commit into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icons/app.png",
"splash": {
"image": "./assets/icons/splash.png",
"resizeMode": "cover",
Expand Down
Binary file added assets/icons/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/core/configureStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function configureStore(
const sagaMiddleware = createSagaMiddleware();

const navigationMiddleware = createReactNavigationReduxMiddleware(
'ScannerPreview',
'',
(state: IAppReduxState) => state.nav,
);

Expand Down
2 changes: 1 addition & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function initializeCore() {
state: state.nav,
});
const AppWithNavigationState =
connect(mapStateToProps)(reduxifyNavigator(MainNavigator, 'ScannerPreview') as any);
connect(mapStateToProps)(reduxifyNavigator(MainNavigator, '') as any);

return { store, MainNavigator: AppWithNavigationState };
}
101 changes: 37 additions & 64 deletions src/modules/Auth/view/SignTransaction/SignTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import { Input, Modal, Button } from 'shared/view/components';
import { ITransaction } from 'shared/models/types';
import { IAppReduxState } from 'shared/types/app';
import { ICommunication } from 'shared/types/redux';
import TrustWallet, { MessagePayload, TransactionPayload } from 'react-native-trust-sdk';
import TrustWallet, { TransactionPayload } from 'react-native-trust-sdk';

import { selectors } from '../../redux';
import styles from './styles';

const minGasLimit = '32000';

interface IStateProps {
transaction: ITransaction | null;
loadingTransaction: ICommunication;
Expand All @@ -21,9 +23,10 @@ interface IStateProps {
interface IState {
data: string;
address: string;
isOpenModal: boolean;
amount: string;
message: string;
isOpenErrorModal: boolean;
isOpenSuccessModal: boolean;
}

type IProps = IStateProps & NavigationScreenProps;
Expand All @@ -33,17 +36,20 @@ class SignTransaction extends Component<IProps, IState> {
title: 'Enter a data',
};

// public callbackScheme: string = 'exp://gm-qy9.varimartas.akropolisconnect.exp.direct:80/--/';

public callbackScheme: string = 'akropolisconnect://';
public wallet: TrustWallet = new TrustWallet(this.callbackScheme);

public state: IState = {
// address: '0xE47494379c1d48ee73454C251A6395FDd4F9eb43',
// data: '0x8f834227000000000000000000000000000000005224',
address: '',
data: '',
amount: '1',
message: 'hello trust',
data: '',
isOpenModal: false,
isOpenErrorModal: false,
isOpenSuccessModal: false,
};

public componentDidMount() {
Expand Down Expand Up @@ -88,84 +94,51 @@ class SignTransaction extends Component<IProps, IState> {
</View>
<View style={styles.signTransaction}>
<Button
onPress={this.openModal}
onPress={this.signTtransaction}
text="COMPLETE TRANSACTION"
/>
</View>
<View style={styles.signTransaction}>
<Button
onPress={this.signMsg}
text="test signMassage"
/>
</View>
<View style={styles.signTransaction}>
<Button
onPress={this.signTx}
text="test singTransaction"
/>
</View>
{this.renderModal({ success: false })}
<Modal
isOpen={this.state.isOpenSuccessModal}
success
descriptions="Your transaction is successful go to desktop app"
acceptText="OK, THANKS"
onAcceptClick={this.redirectToStartPage}
/>
<Modal
isOpen={this.state.isOpenErrorModal}
success={false}
descriptions="Something goes wrong. Please try again"
acceptText="TRY AGAIN"
onAcceptClick={this.redirectToCamera}
rejectText="DECIDE LATER"
onRejectClick={this.redirectToStartPage}
/>
</View >
);
}

public signTx = () => {
const payload = new TransactionPayload(this.state.address, this.state.amount, this.state.data);
public signTtransaction = () => {
const payload = new TransactionPayload(this.state.address, this.state.amount, this.state.data, '', minGasLimit);

this.wallet.signTransaction(payload)
.then((result) => {
Alert.alert('Transaction Signed', result);
.then((_result) => {
this.openModal(true);
})
.catch((error) => {
Alert.alert('Error', error.msg);
});
}

public signMsg = () => {
const payload = new MessagePayload(this.state.message);
this.wallet.signMessage(payload)
.then((result) => {
Alert.alert('Message Signed', result);
}).catch((error) => {
Alert.alert('Error', error.msg);
.catch((_error) => {
this.openModal(false);
});
}

public onChangeData = (value: string) => this.setState({ data: value });
public onChangeAddress = (value: string) => this.setState({ address: value });

public renderModal = ({ success }: { success: boolean }) => {

if (success) {
return (
<Modal
isOpen={this.state.isOpenModal}
success={success}
descriptions="Your transaction is sucsesfull go to desktop app"
acceptText="OK, THANKS"
onAcceptClick={this.closeModal}
/>
);
} else {
return (
<Modal
isOpen={this.state.isOpenModal}
success={success}
descriptions="Something goes wrong. Please try agian"
acceptText="TRY AGAIN"
onAcceptClick={this.redirectToCamera}
rejectText="DECIDE LATER"
onRejectClick={this.redirectToStartPage}
/>
);
}
}

public closeModal = () => {
this.setState({ isOpenModal: false });
this.setState({ isOpenErrorModal: false, isOpenSuccessModal: false });
}

public openModal = () => {
this.setState({ isOpenModal: true });
public openModal = (success: boolean) => {
this.setState({ isOpenSuccessModal: success, isOpenErrorModal: !success });
}

public redirectToCamera = () => {
Expand Down
4 changes: 3 additions & 1 deletion src/service/api/entities/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class Auth extends BaseApi {
// });

// const body = response.data;
return { address: 'address', data: 'data' };
return {
address: '0xE47494379c1d48ee73454C251A6395FDd4F9eb43', data: '0x8f834227000000000000000000000000000000005224',
};
// return authConverter(body.results);
}
}
Expand Down