Skip to content

Commit

Permalink
dCloud 1.2.0 (BTFS Mainnet)
Browse files Browse the repository at this point in the history
  • Loading branch information
simbadMarino committed Feb 25, 2022
1 parent ecd5729 commit d1c16cd
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 58 deletions.
104 changes: 90 additions & 14 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,16 @@ try{
.then(function (depositBTT_resp) {
var str_depositMessage = depositBTT_resp.data.hash;
console.log(str_depositMessage);
Alert.alert("Deposit Hash", str_depositMessage);
Alert.alert("Deposit Success!, Hash", str_depositMessage);
})

.catch(function(error) {
console.log('There has been a problem with your fetch operation: ' + error.message);
//Alert.alert("Error", "Password already set, use cli to change it if needed");
console.log("Call response: " + JSON.stringify(depositBTT_resp));
Alert.alert("Deposit Error", "Max WBTT deposit balance exceeded, try depositing less WBTT (No more than 1000)");
});

}

catch (err) {
Expand All @@ -136,6 +143,39 @@ try{

}


function withdrawBTT(WBTTamount){

try{

var withdrawBTT_resp = axios.post('http://localhost:5001/api/v1/vault/withdraw?arg=' + WBTTamount*1000000000000000000 )
.then(function (withdrawBTT_resp) {
var str_withdrawMessage = withdrawBTT_resp.data.hash;
console.log(withdrawBTT_resp);
console.log(str_withdrawMessage);
Alert.alert("Withdrawal Success!, Hash", str_withdrawMessage);
})

.catch(function(error) {
console.log('There has been a problem with your fetch operation: ' + error.message);
//Alert.alert("Error", "Password already set, use cli to change it if needed");
console.log("Call response: " + JSON.stringify(withdrawBTT_resp.data));
Alert.alert("Withdraw Error", "Please make sure to leave at least some WBTT in vault");

});

}

catch (err) {

throw err;

}


}


function getCommands() {

var response = axios.post('http://localhost:5001/api/v1/wallet/balance?')
Expand Down Expand Up @@ -205,6 +245,33 @@ prompt(



}

function withdrawToBTTC() {

prompt(
'Withdraw WBTT',
'From Vault to BTTC Adress',
[
{text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
{text: 'OK', onPress: WBTTamount => {
console.log('OK Pressed, WBTT amount: ' + WBTTamount);
console.log(WBTTamount);
withdrawBTT(WBTTamount);
}
},
],
{
type: 'number',
cancelable: false,
defaultValue: '',
placeholder: 'Deposit Amount'
}
);




}


Expand Down Expand Up @@ -246,7 +313,7 @@ async function getTronAddress() {
.then(function (response) {
strBTTCAddress = response.data.node_addr;
strVaultAddress = response.data.vault_addr;
console.log(strBTTCAddress);
//console.log(strBTTCAddress);
})
.catch(function(error) {
console.log('There has been a problem with your fetch operation: ' + error.message);
Expand Down Expand Up @@ -292,14 +359,15 @@ async function getBalanceBTT(){
.then(function (walletBalance) {
//console.log(walletBalance.data.balance);
float_bttBalance = walletBalance.data.balance/1000000000000000000;
float_bttBalance = float_bttBalance.toFixed(2);
console.log("BTT balance: " + float_bttBalance);
})
.catch(function(error) {
console.log('There has been a problem with your fetch operation: ' + error.message);
//Alert.alert("Error", "Password already set, use cli to change it if needed");
console.log("BTFS daemon not running in background...")
// Add a Toast on screen.
Toast.show('dCloud failed to connect to BTFS...', {duration: Toast.durations.LONG,});
Toast.show('dCloud failed to connect to BTFS... Please make sure daemon is running from the terminal', {duration: Toast.durations.LONG,});
//ToastAndroid.show("dCloud failed to connect to BTFS...", ToastAndroid.SHORT);
// ADD THIS THROW error
//throw error;
Expand All @@ -314,35 +382,27 @@ async function getBalanceWBTT(){
.then(function (walletBalance) {
//console.log(walletBalance.data.balance);
float_WBTT_Balance = walletBalance.data.balance/1000000000000000000;
float_WBTT_Balance = float_WBTT_Balance.toFixed(2);
console.log("WBTT balance: " + float_WBTT_Balance);
})
.catch(function(error) {
console.log('There has been a problem with your fetch operation: ' + error.message);
//Alert.alert("Error", "Password already set, use cli to change it if needed");
//console.log("BTFS daemon not running in background...")
//ToastAndroid.show("dCloud failed to connect to BTFS...", ToastAndroid.SHORT);
// ADD THIS THROW error
//throw error;
});

}

async function getBalanceVaultWBTT(){


var walletBalance = axios.post('http://localhost:5001/api/v1/vault/wbttbalance?arg=' + strVaultAddress )
var walletBalance = axios.post('http://localhost:5001/api/v1/vault/balance')
.then(function (walletBalance) {
//console.log(walletBalance.data.balance);
float_Vault_WBTT_Balance = walletBalance.data.balance/1000000000000000000;
float_Vault_WBTT_Balance = float_Vault_WBTT_Balance.toFixed(2);
console.log("Vault WBTT balance: " + float_Vault_WBTT_Balance);
})
.catch(function(error) {
console.log('There has been a problem with your fetch operation: ' + error.message);
//Alert.alert("Error", "Password already set, use cli to change it if needed");
//console.log("BTFS daemon not running in background...")
//ToastAndroid.show("dCloud failed to connect to BTFS...", ToastAndroid.SHORT);
// ADD THIS THROW error
//throw error;
});

}
Expand Down Expand Up @@ -500,6 +560,12 @@ const onRefresh = React.useCallback(() => {
<Text style={styles.tabMenuText}>
Deposit WBTT to Vault</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.tabsButton}
onPress={withdrawToBTTC}
>
<Text style={styles.tabMenuText}>
Withdraw WBTT</Text>
</TouchableOpacity>

</ScrollView>
</SafeAreaView>
Expand Down Expand Up @@ -663,6 +729,16 @@ state = {
clearTimeout(this.intervalAddress);
this.intervalAddress = 0;
}
if (this.intervalWBTTBalance) { // Is our timer running
// Yes, clear it
clearTimeout(this.intervalWBTTBalance);
this.intervalWBTTBalance = 0;
}
if (this.intervalVaultWBTTBalance) { // Is our timer running
// Yes, clear it
clearTimeout(this.intervalVaultWBTTBalance);
this.intervalVaultWBTTBalance = 0;
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
"soFolder": "/home/simbad/Documents/Git_Repos/dCloud/android/app/build/intermediates/ndkBuild/updatedDebug/lib",
"isDebuggableEnabled": true,
"validAbiList": [
"ARMEABI_V7A",
"ARM64_V8A",
"X86",
"X86_64"
],
"buildTargetSet": [],
Expand Down Expand Up @@ -125,6 +122,7 @@
"sdkFolder": "/home/simbad/Android/Sdk",
"isNativeCompilerSettingsCacheEnabled": false,
"isBuildOnlyTargetAbiEnabled": true,
"ideBuildTargetAbi": "x86_64,x86",
"isCmakeBuildCohabitationEnabled": false,
"isPrefabEnabled": false,
"isV2NativeModelEnabled": true
Expand Down
14 changes: 7 additions & 7 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ android {
defaultConfig {
applicationId "com.justshare"
minSdkVersion project.properties.minSdkVersion.toInteger()
versionCode 12
versionName "1.1.0"
versionCode 13
versionName "1.2.0"

manifestPlaceholders.TERMUX_PACKAGE_NAME = "com.termux"
manifestPlaceholders.TERMUX_APP_NAME = "justshare"
Expand Down Expand Up @@ -394,7 +394,7 @@ def downloadBootstrap(String arch, String expectedChecksum, boolean isPackagesIn
}
}

def remoteUrl = "https://github.com/simbadMarino/dCloud/releases/download/v1.0.1_BTFS_Binaries" + "/bootstrap-" + arch + ".zip"
def remoteUrl = "https://github.com/simbadMarino/dCloud/releases/download/v1.1.0_BTFS_Binaries" + "/bootstrap-" + arch + ".zip"
logger.quiet("Downloading " + remoteUrl + " ...")

file.parentFile.mkdirs()
Expand Down Expand Up @@ -427,10 +427,10 @@ task downloadBootstraps() {
boolean isPackagesInApk = getGradle().getStartParameter().getTaskRequests().toString().contains("Updated");
doLast {
//def version = "2021.04.13-r1"
downloadBootstrap("aarch64", "5da819cdd787e505df725700a3564dc7cc791f6aa1e6f61afe0ad3d24f5c36b0", isPackagesInApk)
downloadBootstrap("arm", "d69675de52043c43affc02970564156c434878a2348d15959d50037d06be0c28", isPackagesInApk)
downloadBootstrap("i686", "4f53f6a21c4ac182a9c21f3b323e92e6d05e936fd154b7750aed06b280a1625", isPackagesInApk)
downloadBootstrap("x86_64", "4c1febd194b4c743c006cdfeb30ecde7b8105294f853b067a9634a8fd5eb1e4e", isPackagesInApk)
downloadBootstrap("aarch64", "56367005b73fd764700d690c86858621465b29b2c37076558e7781169cd076d5", isPackagesInApk)
downloadBootstrap("arm", "15a7ff99c331a59c04304062b3903b967663afe5941408474af6e043c0d57b88", isPackagesInApk)
downloadBootstrap("i686", "7e773ea94c2d9570f2d16257f85da5d1cca781cd084a7b712c0fce80539fe3d6", isPackagesInApk)
downloadBootstrap("x86_64", "9b12cc3b39f1b57f1ada7487f4869a66a87bffb9d78a1aa4c7cae1a5cad788c2", isPackagesInApk)
}
}

Expand Down
8 changes: 4 additions & 4 deletions android/app/src/main/java/com/justshare/MyBasicModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public void navigateToTerminal() {
context.startActivity(intent);


/*
Intent intentBTFS = new Intent();

/*Intent intentBTFS = new Intent();
intentBTFS.setClassName("com.justshare", "com.termux.app.RunCommandService");
intentBTFS.setAction("com.justshare.RUN_COMMAND");
intentBTFS.putExtra("com.justshare.RUN_COMMAND_PATH", "/data/data/com.justshare/files/usr/bin/btfs");
intentBTFS.putExtra("com.justshare.RUN_COMMAND_BACKGROUND", true);
intentBTFS.putExtra("com.justshare.RUN_COMMAND_ARGUMENTS", new String[]{"daemon"});
intentBTFS.putExtra("com.justshare.RUN_COMMAND_BACKGROUND", false);
intentBTFS.putExtra("com.justshare.RUN_COMMAND_ARGUMENTS", new String[]{"daemon --chain-id 199"});
context.startService(intentBTFS);*/
}

Expand Down
20 changes: 3 additions & 17 deletions android/app/src/main/res/drawable/ic_service_notification.xml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,8 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<!--
Updated notification icon compliant with system icons guidelines
https://material.io/design/iconography/system-icons.html
-->
<path
android:fillColor="#ffffff"
android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM19,18H6c-2.21,0 -4,-1.79 -4,-4s1.79,-4 4,-4h0.71C7.37,7.69 9.48,6 12,6c3.04,0 5.5,2.46 5.5,5.5v0.5H19c1.66,0 3,1.34 3,3s-1.34,3 -3,3z"/>

<group>
<clip-path
android:pathData="M0,0h24v24h-24z"/>

<path
android:pathData="M5,4H2L8,12L2,20H5L11,12L5,4Z"
android:fillColor="#ffffff"/>

<path
android:pathData="M13,18H22V20H13V18Z"
android:fillColor="#ffffff"/>

</group>
</vector>
8 changes: 6 additions & 2 deletions android/app/src/main/res/layout/activity_termux.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/action_toggle_soft_keyboard" />
android:background="#A19999"
android:text="@string/action_toggle_soft_keyboard"
android:textColor="#2C6DA6" />

<Button
android:id="@+id/new_session_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/action_new_session" />
android:background="#A19999"
android:text="@string/action_new_session"
android:textColor="#2C6DA6" />
</LinearLayout>
</LinearLayout>

Expand Down
18 changes: 13 additions & 5 deletions android/app/src/main/res/layout/drawer_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#4D5DB8"
android:choiceMode="singleChoice"
android:dividerHeight="0dp"
android:descendantFocusability="blocksDescendants"
android:dividerHeight="0dp"
android:orientation="vertical">

<ListView
Expand All @@ -46,25 +47,32 @@
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#4D5DB8"
android:orientation="horizontal">

<Button
android:id="@+id/toggle_keyboard_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:layout_weight="1"
android:text="@string/action_toggle_soft_keyboard" />
android:background="#4D5DB8"
android:text="@string/action_toggle_soft_keyboard"
android:textColor="#FFFFFF"
android:textColorHighlight="#A5A0A0"
android:textColorHint="#A5A0A0" />

<Button
android:id="@+id/new_session_button"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#FFFFFF"
android:text="@string/action_new_session" />
android:background="#4D5DB8"
android:text="@string/action_new_session"
android:textColor="#FFFFFF"
android:textColorHighlight="#A5A0A0"
android:textColorHint="#A5A0A0" />
</LinearLayout>
</LinearLayout>

Expand Down
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-mdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
"soFolder": "/home/simbad/Documents/Git_Repos/dCloud/android/terminal-emulator/build/intermediates/ndkBuild/debug/lib",
"isDebuggableEnabled": true,
"validAbiList": [
"ARMEABI_V7A",
"ARM64_V8A",
"X86",
"X86_64"
],
"buildTargetSet": [],
Expand Down Expand Up @@ -125,6 +122,7 @@
"sdkFolder": "/home/simbad/Android/Sdk",
"isNativeCompilerSettingsCacheEnabled": false,
"isBuildOnlyTargetAbiEnabled": true,
"ideBuildTargetAbi": "x86_64,x86",
"isCmakeBuildCohabitationEnabled": false,
"isPrefabEnabled": false,
"isV2NativeModelEnabled": true
Expand Down
6 changes: 3 additions & 3 deletions components/filePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const getMultiUploadStatus = async(item) => {
const openURL = async (item) => {
try {

await Linking.openURL("https://gateway-test.btfs.io/btfs/" + files_list[item].qmhash);
await Linking.openURL("https://gateway.btfs.io/btfs/" + files_list[item].qmhash);
} catch (e) {
console.log("error")
}
Expand Down Expand Up @@ -386,11 +386,11 @@ state = {
render() {

const copyToClipboard = () => {
Clipboard.setString("https://gateway-test.btfs.io/btfs/" + currentFileQMhash);
Clipboard.setString("https://gateway.btfs.io/btfs/" + currentFileQMhash);
};

const copyToClipboardLong = (i) => {
Clipboard.setString("https://gateway-test.btfs.io/btfs/" + files_list[i].qmhash);
Clipboard.setString("https://gateway.btfs.io/btfs/" + files_list[i].qmhash);
console.log("Long ṕress done on item : " + files_list[i].qmhash);
ToastAndroid.show("Link Copied to Clipboard", ToastAndroid.SHORT);
};
Expand Down

0 comments on commit d1c16cd

Please sign in to comment.