Skip to content

Commit

Permalink
Merge changes from master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
JayceLuong committed Apr 2, 2024
2 parents 906c7dc + 5b4a299 commit 863aafa
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ build:
# - ./gradlew clean assembleArm8Release --stacktrace

deploy:

only:
- master
stage: deploy
script:
- ./gradlew clean assembleArm64_v8aRelease --stacktrace
- ./gradlew publish
# python3 push_code.py upload_aar.py
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ properties.load(project.rootProject.file("local.properties").newDataInputStream(
def SUPPORTED_ARCH = properties.getProperty("arch.processor", "arm64_v8a")
def GROUP_ID = "io.nunchuk.android"
def ARTIFACT_ID = "nativesdk"
def VERSION = "1.1.69"
def VERSION = "1.1.70"

publishing {
publications {
Expand Down
31 changes: 31 additions & 0 deletions push_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
import subprocess

def merge_and_push():
# Set up paths and branch names
master_branch = 'master'
main_branch = 'main'
commit_message = 'Merge changes from master branch'

# Fetch latest changes from GitLab
subprocess.run(['git', 'fetch', 'origin'])

# Checkout the master branch
subprocess.run(['git', 'checkout', master_branch])

# Pull latest changes from GitLab
subprocess.run(['git', 'pull', 'origin', master_branch])

# Fetch latest changes from GitHub
subprocess.run(['git', 'fetch', 'origin-github'])

# Checkout the main branch
subprocess.run(['git', 'checkout', main_branch])

# Merge the master branch into the main branch
subprocess.run(['git', 'merge', '--no-ff', '-m', commit_message, 'origin/master'])

# Push changes to the main branch on GitHub
# subprocess.run(['git', 'push', 'origin-github', main_branch])

merge_and_push()
3 changes: 3 additions & 0 deletions release_note.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- BBQR support
- Added a new Setting item to use large font in home
- Bug fixes and improvements
13 changes: 9 additions & 4 deletions src/main/java/com/nunchuk/android/nativelib/LibNunchukAndroid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ internal class LibNunchukAndroid {
inputs: List<TxInput>,
feeRate: Amount,
subtractFeeFromAmount: Boolean,
replaceTxId: String
replaceTxId: String,
): Transaction

@Throws(NCNativeException::class)
Expand All @@ -197,7 +197,7 @@ internal class LibNunchukAndroid {
inputs: List<TxInput>,
feeRate: Amount,
subtractFeeFromAmount: Boolean,
replaceTxId: String
replaceTxId: String,
): Transaction

@Throws(NCNativeException::class)
Expand Down Expand Up @@ -737,7 +737,7 @@ internal class LibNunchukAndroid {
masterSignerId: String,
walletType: Int,
addressType: Int,
index: Int
index: Int,
): SingleSigner?

@Throws(NCNativeException::class)
Expand Down Expand Up @@ -1019,7 +1019,12 @@ internal class LibNunchukAndroid {
@Throws(NCNativeException::class)
external fun recoverHotWallet(
mnemonic: String,
) : Wallet?
): Wallet?

@Throws(NCNativeException::class)
external fun exportBBQRWallet(wallet: WalletBridge, density: Int): List<String>
@Throws(NCNativeException::class)
external fun exportBBQRTransaction(psbt: String, density: Int): List<String>

companion object {
init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.nfc.NdefRecord
import android.nfc.tech.IsoDep
import com.nunchuk.android.exception.NCNativeException
import com.nunchuk.android.model.*
import com.nunchuk.android.model.bridge.WalletBridge
import com.nunchuk.android.model.bridge.toBridge
import com.nunchuk.android.type.*

Expand Down Expand Up @@ -1273,4 +1274,8 @@ class NunchukNativeSdk {
fun recoverHotWallet(
mnemonic: String,
) = nunchukAndroid.recoverHotWallet(mnemonic)
@Throws(NCNativeException::class)
fun exportBBQRWallet(wallet: Wallet, density: Int) = nunchukAndroid.exportBBQRWallet(wallet.toBridge(), density)
@Throws(NCNativeException::class)
fun exportBBQRTransaction(psbt: String, density: Int) = nunchukAndroid.exportBBQRTransaction(psbt, density)
}
15 changes: 15 additions & 0 deletions src/main/native/transaction-jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,4 +1085,19 @@ Java_com_nunchuk_android_nativelib_LibNunchukAndroid_replaceTransactionId(JNIEnv
} catch (std::exception &e) {
Deserializer::convertStdException2JException(env, e);
}
}

extern "C"
JNIEXPORT jobject JNICALL
Java_com_nunchuk_android_nativelib_LibNunchukAndroid_exportBBQRTransaction(JNIEnv *env, jobject thiz,
jstring psbt,
jint density) {
try {
auto value = Utils::ExportBBQRTransaction(StringWrapper(env, psbt), 1, density);
return Deserializer::convert2JListString(env, value);
} catch (BaseException &e) {
Deserializer::convert2JException(env, e);
} catch (std::exception &e) {
Deserializer::convertStdException2JException(env, e);
}
}
17 changes: 17 additions & 0 deletions src/main/native/wallet-jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,21 @@ Java_com_nunchuk_android_nativelib_LibNunchukAndroid_recoverHotWallet(JNIEnv *en
Deserializer::convertStdException2JException(env, e);
return nullptr;
}
}

extern "C"
JNIEXPORT jobject JNICALL
Java_com_nunchuk_android_nativelib_LibNunchukAndroid_exportBBQRWallet(JNIEnv *env, jobject thiz,
jobject wallet,
jint density) {
try {
auto cWallet = Serializer::convert2CWallet(env, wallet);
auto data = Utils::ExportBBQRWallet(cWallet, ExportFormat::COLDCARD, 1, density);
return Deserializer::convert2JListString(env, data);
} catch (BaseException &e) {
Deserializer::convert2JException(env, e);
env->ExceptionOccurred();
} catch (std::exception &e) {
Deserializer::convertStdException2JException(env, e);
}
}
67 changes: 67 additions & 0 deletions upload_aar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
from github import Github, InputGitTreeElement
import base64
import configparser
import re

def read_file_content(file_path):
with open(file_path, 'r') as file:
content = file.read()
return content

def get_version_from_gradle():
with open('build.gradle', 'r') as f:
content = f.read()
match = re.search(r'def VERSION = "(.*?)"', content)
if match:
return match.group(1)
else:
return None

def get_github_token():
config = configparser.RawConfigParser()
with open('local.properties', 'r') as f:
file_content = '[DEFAULT]\n' + f.read()
config.read_string(file_content)
return config.get('DEFAULT', 'githubToken')

def upload_file_to_github(token, repo_name, file_path, commit_message):
g = Github(token)
version = get_version_from_gradle()
repo = g.get_repo(repo_name)
nunchuk_sdk_repo = g.get_repo("nunchuk-io/nunchuk-android-nativesdk")
release_note = read_file_content('release_note.md')
destination_path = "nunchuk-android-nativesdk-arm8-release.aar"
# Read the file content in binary mode
with open(file_path, 'rb') as file:
file_content = file.read()

# Encode file content to base64
file_content_base64 = base64.b64encode(file_content).decode()

# Get the existing file if it exists
existing_file = repo.get_contents(destination_path) if repo.get_contents(destination_path) else None

if existing_file:
# If the file exists, get the SHA hash
sha = existing_file.sha
# Determine commit message
commit_message = "File updated via script"
# Update the existing file
repo.update_file(destination_path, commit_message, file_content_base64, sha)
print(f"File '{file_path}' updated successfully at '{destination_path}' in '{repo_name}' repository.")
else:
# Determine commit message
commit_message = "File uploaded via script"
# Create a new file
repo.create_file(destination_path, commit_message, file_content_base64)
print(f"File '{file_path}' uploaded successfully to '{destination_path}' in '{repo_name}' repository.")

# Create a release
repo.create_git_release(version, version, release_note, draft=True)
nunchuk_sdk_repo.create_git_release(version, version, release_note, draft=True)
print(f"Release '{version}' created successfully with tag '{version}'.")

# Usage
version = get_version_from_gradle()
github_token = get_github_token()
upload_file_to_github(github_token, "nunchuk-io/nunchuk-android-nativesdk-prebuild", "build/outputs/aar/nunchuk-android-nativesdk-arm8-release.aar", "Upload aar file")

0 comments on commit 863aafa

Please sign in to comment.