Skip to content

Commit

Permalink
Revert "65 fix all code warnings and go typescript as much as possible (
Browse files Browse the repository at this point in the history
#66)"

This reverts commit ceb6960.
  • Loading branch information
2byrds committed Jun 30, 2022
1 parent c4bd22c commit 91c4951
Show file tree
Hide file tree
Showing 65 changed files with 4,369 additions and 4,019 deletions.
Binary file removed @rootsid/rootswallet.jks
Binary file not shown.
142 changes: 142 additions & 0 deletions App.js.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import React, {
useContext,
createContext,
useEffect,
useState}
from 'react'
import {StyleSheet, Text, TouchableOpacity, View, Button, DeviceEventEmitter} from 'react-native';
import {NavigationContainer} from '@react-navigation/native'
import {createNativeStackNavigator} from '@react-navigation/native-stack'
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'
import {
HOME_SCREEN,
SETUP_SCREEN,
RELATIONSHIPS_SCREEN,
CREDENTIALS_SCREEN,
CREDENTIALDETAILS_SCREEN,
} from "./src/constants/navigationConstants";
import HomeScreen from "./src/screens/HomeScreen"
import SettingsScreen from "./src/screens/SettingsScreen";
import RelationshipsScreen from "./src/screens/RelationshipsScreen";
import CredentialsScreen from "./src/screens/CredentialsScreen";
import CredentialDetailsScreen from "./src/screens/CredentialDetailsScreen";
import SignInScreen from './src/screens/SignInScreen'
import HelpScreen from './src/screens/HelpScreen'

// import storage from "./src/utils/Storage";

const WalletNameContext = createContext('')
const useWalletName = () => useContext(WalletNameContext)

const WalletNameContextProvider = ({children}) => {
const [walletName, setWalletName] = useState('')
const getWalletName = () => walletName
const setMyWalletName = (wn) => setWalletName(wn)

return (
<WalletNameContext.Provider value={{
walletName,
getWalletName,
setMyWalletName
}}>
{children}
</WalletNameContext.Provider>
)
}

function Chats1Screen() {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Text>Chats1 Screen</Text>
</View>
)
}

function Chats2Screen() {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Text>Chats2 Screen</Text>
</View>
)
}

export default function App() {
const [isLoggedIn, setIsLoggedIn] = useState(false)
const [xwalletName, setXWalletName] = useState('')

const{walletName, getWalletName, setMyWalletName} = useWalletName()
console.log(`read in WalletName: ${getWalletName}`)
DeviceEventEmitter.addListener("event.login", (eventData) => {
console.log(`walletName: ${eventData}`)
setIsLoggedIn(true)
setMyWalletName(eventData)


})

const Stack = createNativeStackNavigator()
const Tab = createBottomTabNavigator()


const Main = () => {
return (
<Tab.Navigator>
<Tab.Screen name="relationships" component={RelationshipsStack}/>
<Tab.Screen name="chats" component={ChatsStack}/>
</Tab.Navigator>
)
}

const RelationshipsStack = () => {
return (
<Stack.Navigator>
<Stack.Group>
<Stack.Screen name="Relationships"
component={RelationshipsScreen}
options={{walletName: walletName}}
/>
<Stack.Screen name="Credentials" component={CredentialsScreen}/>
<Stack.Screen name="CredentialDetails" component={CredentialDetailsScreen}/>
</Stack.Group>
</Stack.Navigator>
)
}
const ChatsStack = () => {
return (
<Stack.Group>
<Stack.Screen name="Chats1" component={Chats1Screen}/>
<Stack.Screen name="Chats2" component={Chats2Screen}/>
</Stack.Group>
)
}


return (
<NavigationContainer>
<Stack.Navigator>

{isLoggedIn ? (
// Screens for logged in users
<Stack.Group>
<Stack.Screen name="relationshipStack" component={Main}/>
<Stack.Screen name="Home" component={HomeScreen}/>
</Stack.Group>
) : (
// Auth screens
<Stack.Group screenOptions={{headerShown: false}}>
<Stack.Screen name="SignIn"
component={SignInScreen}
/>
<Stack.Screen name="Main" component={Main}/>
</Stack.Group>
)}
{/* Common modal screens */}
<Stack.Group screenOptions={{presentation: 'modal'}}>
<Stack.Screen name="Help" component={HelpScreen}/>
</Stack.Group>
</Stack.Navigator>

</NavigationContainer>
)

}
14 changes: 11 additions & 3 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import 'react-native-gesture-handler';
import React from 'react';
//import * as SplashScreen from 'expo-splash-screen';

import Providers from './src/navigation';

export default function App() {
//SplashScreen.hideAsync();
return (
<Providers />
);
}
}

// const styles = StyleSheet.create({
// container: {
// flex: 1,
// backgroundColor: '#fff',
// alignItems: 'center',
// justifyContent: 'center',
// },
// });
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.android.build.OutputFile
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation. If none specified and
* // "index.android.js" exists, it will be used. Otherwise "index.ts" is
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
* // default. Can be overridden with ENTRY_FILE environment variable.
* entryFile: "index.android.js",
*
Expand Down
4 changes: 2 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="44.0.0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="10000"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@rootsid/rootswallet"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@anonymous/rootswallet"/>
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:screenOrientation="unspecified">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
64 changes: 38 additions & 26 deletions android/app/src/main/java/com/rootswallet/PrismModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,25 @@ class PrismModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
return "PrismModule"
}

@ReactMethod
fun getDidDocument(did: String, promise: Promise) {
Log.d("PRISM_TAG","Getting DID doc"+did);
thread(start = true) {
try {
var didDocJson = getDidDocumentJson(did);
Log.d("PRISM_TAG","Got did document "+did+" w/ doc"+didDocJson)
promise.resolve(didDocJson);
} catch (e: Exception) {
promise.reject("Publish Error", e);
}
}
@ReactMethod(isBlockingSynchronousMethod = true)
fun setNetwork(host: String = "ppp.atalaprism.io", port: String = "50053") {
Log.d("PRISM_TAG","Setting GrpcConfig host "+host+" w/port "+port);
GrpcConfig.host = host
GrpcConfig.port = port
}

// @ReactMethod(isBlockingSynchronousMethod = true)
// fun test() {Log.d("test","test")}
//
// @ReactMethod(isBlockingSynchronousMethod = true)
// fun testNode() {
// val wal = newWallet("walletname1", "", "password1")
// val didAlias1 = "didAlias1"
// val walAfterDid = newDid(wal, didAlias1, true)
// Log.d("LANCETAG", "Testing node publish....")
// val output = publishDid(walAfterDid, didAlias1).toString()
// }

@ReactMethod(isBlockingSynchronousMethod = true)
fun newDID(walJson: String, didAlias: String): String {
var cliWal = Json.decodeFromString<Wallet>(walJson);
Expand Down Expand Up @@ -65,6 +70,25 @@ class PrismModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
}

@ReactMethod
fun importCred(walJson: String, credAlias: String, credJson: String, promise: Promise) {
Log.d("PRISM_TAG","Importing credential for "+credAlias+" from wallet "+walJson);
thread(start = true) {
try {
val importedCredential = ImportedCredential(
credAlias,
Json.decodeFromString<VerifiedCredential>(credJson)
)
var newWal = Json.decodeFromString<Wallet>(walJson);
newWal.importedCredentials.add(importedCredential)
//Log.d("PRISM_TAG","Credential imported",walJson)
promise.resolve(Json.encodeToString(newWal));
} catch (e: Exception) {
promise.reject("Publish Error", e);
}
}
}

@ReactMethod
fun issueCred(walJson: String, didAlias: String, credJson: String, promise: Promise) {
Log.d("PRISM_TAG","Issuing credential for "+didAlias+" from wallet "+walJson);
Expand Down Expand Up @@ -98,25 +122,13 @@ class PrismModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaM
}
}

@ReactMethod(isBlockingSynchronousMethod = true)
fun setNetwork(host: String = "ppp.atalaprism.io", port: String = "50053") {
Log.d("PRISM_TAG","Setting GrpcConfig host "+host+" w/port "+port);
GrpcConfig.host = host
GrpcConfig.port = port
}

@ReactMethod
fun verifyCred(walJson: String, credAlias: String, imported: Boolean, promise: Promise) {
fun verifyImportedCred(walJson: String, credAlias: String, promise: Promise) {
Log.d("PRISM_TAG","Verifying credential for "+credAlias+" from wallet "+walJson);
thread(start = true) {
try {
var cliWal = Json.decodeFromString<Wallet>(walJson);
var verResult = ""
if(imported) {
verResult = Json.encodeToString(verifyImportedCredential(cliWal, credAlias))
} else {
verResult = Json.encodeToString(verifyIssuedCredential(cliWal, credAlias))
}
var verResult = Json.encodeToString(verifyImportedCredential(cliWal, credAlias))
Log.d("PRISM_TAG","Credential "+credAlias+" is " + verResult)
promise.resolve(verResult);
} catch (e: Exception) {
Expand Down
5 changes: 5 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"platforms": ["android"],
"githubUrl": "https://github.com/roots-id/rootswallet",
"icon": "./src/assets/LogoOnly1024.png",
"splash": {
"image": "./src/assets/WhiteTextExtraGlow.png",
"resizeMode": "contain",
"backgroundColor": "#000000"
},
"updates": {
"enabled": true,
"fallbackToCacheTimeout": 10000
Expand Down
23 changes: 0 additions & 23 deletions eas.json

This file was deleted.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"resolutions": {
"@types/react": "17.0.1"
},
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
Expand All @@ -23,12 +22,12 @@
"@transmute/did-key-ed25519": "^0.3.0-unstable.8",
"@transmute/did-key-secp256k1": "^0.3.0-unstable.8",
"@transmute/did-key-x25519": "^0.3.0-unstable.8",
"base-64": "^1.0.0",
"buffer": "^6.0.3",
"emoji-utils": "^1.0.1",
"expo": "^44.0.6",
"expo-barcode-scanner": "^11.2.1",
"expo-secure-store": "~11.1.0",
"expo-splash-screen": "~0.14.1",
"expo-status-bar": "~1.2.0",
"expo-updates": "~0.11.7",
"i18next": "^21.6.4",
Expand All @@ -39,7 +38,7 @@
"react-native": "0.64.3",
"react-native-base64": "^0.2.1",
"react-native-gesture-handler": "~2.1.0",
"react-native-gifted-chat": "1.0.0",
"react-native-gifted-chat": "1.0.0-beta-3",
"react-native-hyperlink": "^0.0.19",
"react-native-localize": "^2.1.7",
"react-native-paper": "^4.12.1",
Expand Down
15 changes: 13 additions & 2 deletions src/components/FormButton.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import React from 'react';
import { Dimensions, StyleSheet } from 'react-native';
import { Button } from 'react-native-paper';
import {styles} from "../styles/styles";


const { width, height } = Dimensions.get('screen');

export default function FormButton({ title, modeValue, ...rest }) {
return (
<Button
mode={modeValue}
{...rest}
style={styles.button}
contentStyle={styles.buttonContainer}
>
{title}
</Button>
);
}

const styles = StyleSheet.create({
button: {
marginTop: 10,
},
buttonContainer: {
width: width / 2,
height: height / 15,
},
});
Loading

0 comments on commit 91c4951

Please sign in to comment.