@@ -49,15 +49,51 @@ export default class App extends React.Component<any, State> {
4949 < SafeAreaView style = { { flex : 1 } } >
5050 {
5151 this . state . currentScreen === AppScreen . Home ? (
52- < HomeScreen onStartAuthentication = { this . onStartAuthentication } errorMessage = { this . state . errorMessage } />
52+ < HomeScreen onStartAuthentication = { this . onStartAuthentication } errorMessage = { this . state . errorMessage }
53+ />
5354 ) : (
54- < LoggedIn username = { this . state . username } onLogout = { this . onLogout } isNewlyRegistered = { this . state . isNewlyRegistered } />
55+ < LoggedIn
56+ username = { this . state . username }
57+ onStartTransaction = { this . onStartTransaction }
58+ onLogout = { this . onLogout }
59+ isNewlyRegistered = { this . state . isNewlyRegistered }
60+ />
5561 )
5662 }
5763 </ SafeAreaView >
5864 ) ;
5965 }
6066
67+ // Transaction Process Handlers
68+
69+ public onStartTransaction = async ( rawUsername : string ) : Promise < void > => {
70+ const username = rawUsername . toLowerCase ( ) ;
71+ this . setState ( { errorMessage : '' } ) ;
72+
73+ if ( localUserStore . isUserIDStored ( username ) ) {
74+ this . signTransaction ( username ) ;
75+ } else {
76+ console . log ( "User not registered" ) ;
77+ this . setState ( { errorMessage : 'User not registered' } ) ;
78+ }
79+ }
80+
81+ private signTransaction = async ( username : string ) : Promise < void > => {
82+ try {
83+ const response = await TSAuthenticationSDKModule . signTransaction ( username ) ;
84+ const accessToken = await this . mockServer . getAccessToken ( ) ;
85+ const success = await this . mockServer . completeAuthentication ( accessToken . token , response . result ) ; // should change???
86+ if ( success ) {
87+ this . setState ( { errorMessage : '' } ) ;
88+ console . log ( "Sign Transaction success" ) ;
89+ } else {
90+ this . setState ( { errorMessage : 'Sign Transaction failed' } ) ;
91+ }
92+ } catch ( error : any ) {
93+ this . setState ( { errorMessage : `${ error } ` } ) ;
94+ }
95+ }
96+
6197 // Authentication Process Handlers
6298
6399 public onStartAuthentication = async ( rawUsername : string ) : Promise < void > => {
@@ -115,10 +151,10 @@ export default class App extends React.Component<any, State> {
115151 // Navigation
116152
117153 private navigateToAuthenticatedUserScreen = ( username : string , isNewRegistration : boolean ) : void => {
118- this . setState ( {
119- currentScreen : AppScreen . AuthenticatedUser ,
120- username,
121- isNewlyRegistered : isNewRegistration
154+ this . setState ( {
155+ currentScreen : AppScreen . AuthenticatedUser ,
156+ username,
157+ isNewlyRegistered : isNewRegistration
122158 } ) ;
123159 }
124160
0 commit comments