Skip to content

Commit

Permalink
Merge pull request zingolabs#755 from juanky201271/dev_zingolib_comma…
Browse files Browse the repository at this point in the history
…nd_messages_adopted

New Release 1.10.1 (201) - new command messages added
  • Loading branch information
juanky201271 authored Nov 23, 2024
2 parents 1c10876 + cd19572 commit 544bef3
Show file tree
Hide file tree
Showing 22 changed files with 365 additions and 357 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android-macos-integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
run: colima status

- name: Pull regchest docker image
run: docker pull zingodevops/regchest:008
run: docker pull zingodevops/regchest:009

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-ubuntu-e2e-test-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
workspaces: rust

- name: Pull regchest docker image
run: docker pull zingodevops/regchest:008
run: docker pull zingodevops/regchest:009

- name: Setup Java
uses: actions/setup-java@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-ubuntu-integration-test-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
workspaces: rust

- name: Pull regchest docker image
run: docker pull zingodevops/regchest:008
run: docker pull zingodevops/regchest:009

- name: Setup Java
uses: actions/setup-java@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/old/android-e2e-test-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
sudo udevadm trigger --name-match=kvm
- name: Pull regchest docker image
run: docker pull zingodevops/regchest:008
run: docker pull zingodevops/regchest:009

- name: Setup Java
uses: actions/setup-java@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/old/android-e2e-test-script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:
# colima start

- name: Pull regchest docker image
run: docker pull zingodevops/regchest:008
run: docker pull zingodevops/regchest:009

- name: Rust toolchain stable
uses: actions-rust-lang/setup-rust-toolchain@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/old/android-ubuntu-integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
run: docker --version

- name: Pull regchest docker image
run: docker pull zingodevops/regchest:008
run: docker pull zingodevops/regchest:009

- name: Rust toolchain stable
uses: actions-rust-lang/setup-rust-toolchain@v1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ From the `rust/android/lightwalletd_bin` directory run: <br />
Alternatively, integration tests and end-to-end tests can be run on non-linux hosts with Regchest
(https://github.com/zingolabs/zingo-regchest). Regchest manages the zcash/lightwalletd regtest
network in a docker container. Before running tests, pull the latest Regchest image from docker: <br />
`docker pull zingodevops/regchest:008`
`docker pull zingodevops/regchest:009`

### Yarn Tests
1. From the root directory, run: <br />
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ android {
applicationId 'org.ZingoLabs.Zingo' // Real
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 199 // Real
versionName "zingo-1.8.1" // Real
versionCode 202 // Real
versionName "zingo-1.10.2" // Real
missingDimensionStrategy 'react-native-camera', 'general'
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,22 +376,22 @@ class UpdateCurrentPriceAndValueTransfersFromSeed {
// 2. Sent - 110_000 - uregtest1zkuzfv5m3... (1 item)
// 3. memoToSelf - 10_000 (1 item)
assertThat(valueTranfers.value_transfers.size).isEqualTo(3)
// first item have to be a `Received`
assertThat(valueTranfers.value_transfers[0].kind).isEqualTo("received")
assertThat(valueTranfers.value_transfers[0].pool_received).isEqualTo("Orchard")
// third item have to be a `fee` from the last `Sent` with the same txid
assertThat(valueTranfers.value_transfers[0].kind).isEqualTo("memo-to-self")
assertThat(valueTranfers.value_transfers[0].status).isEqualTo("confirmed")
assertThat(valueTranfers.value_transfers[0].value).isEqualTo(1000000)
assertThat(valueTranfers.value_transfers[0].value).isEqualTo(0)
assertThat(valueTranfers.value_transfers[0].transaction_fee).isEqualTo(20000)
// second item have to be a `Sent`
assertThat(valueTranfers.value_transfers[1].kind).isEqualTo("sent")
assertThat(valueTranfers.value_transfers[1].recipient_address).isEqualTo("uregtest1zkuzfv5m3yhv2j4fmvq5rjurkxenxyq8r7h4daun2zkznrjaa8ra8asgdm8wwgwjvlwwrxx7347r8w0ee6dqyw4rufw4wg9djwcr6frzkezmdw6dud3wsm99eany5r8wgsctlxquu009nzd6hsme2tcsk0v3sgjvxa70er7h27z5epr67p5q767s2z5gt88paru56mxpm6pwz0cu35m")
assertThat(valueTranfers.value_transfers[1].status).isEqualTo("confirmed")
assertThat(valueTranfers.value_transfers[1].value).isEqualTo(100000)
assertThat(valueTranfers.value_transfers[1].transaction_fee).isEqualTo(10000)
// third item have to be a `fee` from the last `Sent` with the same txid
assertThat(valueTranfers.value_transfers[2].kind).isEqualTo("memo-to-self")
// first item have to be a `Received`
assertThat(valueTranfers.value_transfers[2].kind).isEqualTo("received")
assertThat(valueTranfers.value_transfers[2].pool_received).isEqualTo("Orchard")
assertThat(valueTranfers.value_transfers[2].status).isEqualTo("confirmed")
assertThat(valueTranfers.value_transfers[2].value).isEqualTo(0)
assertThat(valueTranfers.value_transfers[2].transaction_fee).isEqualTo(20000)
assertThat(valueTranfers.value_transfers[2].value).isEqualTo(1000000)
}
}

Expand Down
47 changes: 40 additions & 7 deletions android/app/src/main/java/org/ZingoLabs/Zingo/RPCModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.facebook.react.bridge.Promise

//import android.util.Log
import java.io.File
import java.io.FileNotFoundException
import java.io.IOException
import kotlin.concurrent.thread
import org.ZingoLabs.Zingo.Constants.*

Expand Down Expand Up @@ -90,13 +92,19 @@ class RPCModule internal constructor(private val reactContext: ReactApplicationC

private fun saveWalletBackupFile(): Boolean {
// Get the encoded wallet file
// Read the file
val fileBytes = readFile(WalletFileName.value)
// Log.i("MAIN", b64encoded)

val fileBytes: ByteArray
try {
// Log.i("MAIN", "file size${fileBytes.size}")
// Intentar leer el archivo
fileBytes = readFile(WalletFileName.value)
} catch (e: FileNotFoundException) {
Log.e("MAIN", "Error: Wallet file not found", e)
return false
} catch (e: IOException) {
Log.e("MAIN", "Error: Couldn't read the wallet file", e)
return false
}

try {
// Save file to disk
writeFile(WalletBackupFileName.value, fileBytes)
} catch (e: IllegalArgumentException) {
Expand Down Expand Up @@ -345,18 +353,42 @@ class RPCModule internal constructor(private val reactContext: ReactApplicationC

@ReactMethod
fun restoreExistingWalletBackup(promise: Promise) {
val fileBytesBackup: ByteArray
val fileBytesWallet: ByteArray

// Read the file backup
val fileBytesBackup = readFile(WalletBackupFileName.value)
try {
fileBytesBackup = readFile(WalletBackupFileName.value)
} catch (e: FileNotFoundException) {
Log.e("MAIN", "Error: Backup file not found", e)
promise.resolve(false)
return
} catch (e: IOException) {
Log.e("MAIN", "Error reading the backup file", e)
promise.resolve(false)
return
}

// Read the file wallet
val fileBytesWallet = readFile(WalletFileName.value)
try {
fileBytesWallet = readFile(WalletFileName.value)
} catch (e: FileNotFoundException) {
Log.e("MAIN", "Error: Wallet file not found", e)
promise.resolve(false)
return
} catch (e: IOException) {
Log.e("MAIN", "Error reading the wallet file", e)
promise.resolve(false)
return
}

try {
// Save file to disk wallet (with the backup)
writeFile(WalletFileName.value, fileBytesBackup)
} catch (e: IllegalArgumentException) {
Log.e("MAIN", "Couldn't save the wallet with the backup")
promise.resolve(false)
return
}

try {
Expand All @@ -365,6 +397,7 @@ class RPCModule internal constructor(private val reactContext: ReactApplicationC
} catch (e: IllegalArgumentException) {
Log.e("MAIN", "Couldn't save the backup with the wallet")
promise.resolve(false)
return
}

promise.resolve(true)
Expand Down
1 change: 1 addition & 0 deletions app/AppState/enums/CommandEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export enum CommandEnum {
shield = 'shield',
// this works for all: send, sendall & shield
confirm = 'confirm',
messages = 'messages',
}
Loading

0 comments on commit 544bef3

Please sign in to comment.