update deps

This commit is contained in:
Michele Balistreri 2020-10-09 13:55:00 +02:00
parent 9c24dc8a5f
commit feb533c549
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
6 changed files with 58 additions and 66 deletions

View File

@ -1,16 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
compileSdkVersion 30
defaultConfig {
applicationId "im.status.keycard.connect"
minSdkVersion 24
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -43,37 +40,41 @@ android {
warning 'InvalidPackage' // for bouncycastle
}
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.1.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.1.0'
implementation 'androidx.security:security-crypto:1.0.0-alpha02'
implementation 'org.bouncycastle:bcprov-jdk15on:1.64'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
implementation 'androidx.security:security-crypto:1.1.0-alpha02'
implementation 'org.bouncycastle:bcprov-jdk15on:1.65'
implementation 'com.github.status-im.status-keycard-java:android:3.0.2'
implementation 'com.github.walletconnect:kotlin-walletconnect-lib:0.9.4'
implementation 'com.github.walletconnect:kotlin-walletconnect-lib:0.9.7'
implementation 'com.journeyapps:zxing-android-embedded:4.0.0'
implementation 'com.google.zxing:core:3.4.0'
implementation 'com.squareup.moshi:moshi:1.9.1'
implementation 'com.squareup.okhttp3:okhttp:4.2.1'
implementation 'com.squareup.moshi:moshi-kotlin:1.9.1'
implementation "com.github.komputing.kethereum:extensions:$kethereum_version"
implementation 'com.google.zxing:core:3.4.1'
implementation 'com.squareup.moshi:moshi:1.11.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'com.squareup.moshi:moshi-kotlin:1.11.0'
implementation "com.github.komputing.kethereum:model:$kethereum_version"
implementation "com.github.komputing.kethereum:functions:$kethereum_version"
implementation "com.github.komputing.kethereum:rpc:$kethereum_version"
implementation "com.github.komputing.kethereum:extensions_transactions:$kethereum_version"
implementation "com.github.komputing.kethereum:extensions_kotlin:$kethereum_version"
implementation "com.github.komputing.kethereum:keccak_shortcut:$kethereum_version"
implementation 'com.github.komputing:khex:0.6'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.github.komputing:khex:1.0.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
configurations.all {
resolutionStrategy {
force 'org.bouncycastle:bcprov-jdk15on:1.65'
}
}

View File

@ -3,15 +3,15 @@ package im.status.keycard.connect.data
import android.content.Context
import android.content.SharedPreferences
import androidx.security.crypto.EncryptedSharedPreferences
import androidx.security.crypto.MasterKeys
import androidx.security.crypto.MasterKey
class SettingsManager(context: Context) {
private val sharedPreferences: SharedPreferences
init {
/** encrypted settings used for privacy **/
val masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
sharedPreferences = EncryptedSharedPreferences.create("settings", masterKeyAlias, context, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM)
val masterKey = MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build()
sharedPreferences = EncryptedSharedPreferences.create(context,"settings", masterKey, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM)
}
val rpcEndpoint

View File

@ -5,10 +5,7 @@ import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import okhttp3.OkHttpClient
import okhttp3.Request
import org.kethereum.extensions.maybeHexToBigInteger
import org.kethereum.rpc.HttpEthereumRPC
import org.kethereum.rpc.model.StringResultResponse
import java.io.IOException
import java.lang.Exception
import java.lang.reflect.Type
import java.math.BigInteger
@ -29,24 +26,16 @@ class EthereumRPC(endpointURL: String) {
endpoint = HttpEthereumRPC(endpointURL)
}
private inline fun <T> valueOrThrow(res: StringResultResponse?, body: (String) -> T) : T {
if (res != null && res.error == null) {
return body(res.result)
} else {
throw IOException("communication error")
}
}
fun ethGetTransactionCount(address: String): BigInteger {
return valueOrThrow(endpoint.getTransactionCount(address)) { it.maybeHexToBigInteger() }
return endpoint.getTransactionCount(address)!!
}
fun ethGasPrice(): BigInteger {
return valueOrThrow(endpoint.gasPrice()) { it.maybeHexToBigInteger() }
return endpoint.gasPrice()!!
}
fun ethSendRawTransaction(rawTx: String): String {
return valueOrThrow(endpoint.sendRawTransaction(rawTx)) { it }
return endpoint.sendRawTransaction(rawTx)!!
}
fun ethplorerGetTokenInfo(address: String): Map<String, Any>? {

View File

@ -19,21 +19,22 @@ import okhttp3.OkHttpClient
import org.kethereum.DEFAULT_GAS_LIMIT
import org.kethereum.extensions.maybeHexToBigInteger
import org.kethereum.extensions.toBigInteger
import org.kethereum.functions.encodeRLP
import org.kethereum.functions.getTokenTransferTo
import org.kethereum.functions.getTokenTransferValue
import org.kethereum.functions.isTokenTransfer
import org.kethereum.extensions.transactions.encodeRLP
import org.kethereum.extensions.transactions.getTokenTransferTo
import org.kethereum.extensions.transactions.getTokenTransferValue
import org.kethereum.extensions.transactions.isTokenTransfer
import org.kethereum.keccakshortcut.keccak
import org.kethereum.model.*
import org.komputing.khex.encode
import org.komputing.khex.extensions.hexToByteArray
import org.komputing.khex.extensions.toHexString
import org.komputing.khex.extensions.toNoPrefixHexString
import org.komputing.khex.model.HexString
import org.walletconnect.Session
import org.walletconnect.Session.Config.Companion.fromWCUri
import org.walletconnect.impls.*
import org.walleth.khex.hexToByteArray
import org.walleth.khex.toHexString
import org.walleth.khex.toNoPrefixHexString
import java.io.File
import java.lang.Exception
import java.math.BigInteger
class WalletConnect(var bip32Path: String, var chainID: Long) : ExportKeyCommand.Listener, SignCommand.Listener, Session.Callback {
@ -63,6 +64,7 @@ class WalletConnect(var bip32Path: String, var chainID: Long) : ExportKeyCommand
is Session.MethodCall.SignMessage -> signText(call.id, call.message)
is Session.MethodCall.SendTransaction -> signTransaction(call.id, toTransaction(call), true)
is Session.MethodCall.Custom -> onCustomCall(call)
else -> session?.rejectRequest(call.id(), 1L, "Not implemented")
}
}
}
@ -103,11 +105,11 @@ class WalletConnect(var bip32Path: String, var chainID: Long) : ExportKeyCommand
}
private fun toTransaction(tx: Session.MethodCall.SendTransaction): Transaction {
val gasLimit = tx.gasLimit?.maybeHexToBigInteger() ?: DEFAULT_GAS_LIMIT
val gasPrice = tx.gasPrice?.maybeHexToBigInteger() ?: Registry.ethereumRPC.ethGasPrice()
val nonce = tx.nonce?.maybeHexToBigInteger() ?: Registry.ethereumRPC.ethGetTransactionCount(tx.from)
return Transaction(chainID.toBigInteger(), null, Address(tx.from), gasLimit, gasPrice, tx.data.hexToByteArray(), nonce, Address(tx.to), null, tx.value.maybeHexToBigInteger())
val gasLimit = if(tx.gasLimit != null) HexString(tx.gasLimit!!).maybeHexToBigInteger() else DEFAULT_GAS_LIMIT
val gasPrice = if(tx.gasPrice != null) HexString(tx.gasPrice!!).maybeHexToBigInteger() else Registry.ethereumRPC.ethGasPrice()
val nonce = if(tx.nonce != null) HexString(tx.nonce!!).maybeHexToBigInteger() else Registry.ethereumRPC.ethGetTransactionCount(tx.from)
val to = if(tx.to != null) Address(tx.to!!) else null
return Transaction(chainID.toBigInteger(), null, Address(tx.from), gasLimit, gasPrice, HexString(tx.data).hexToByteArray(), nonce, to, null, HexString(tx.value).maybeHexToBigInteger(),null, null)
}
private fun relayTX(id: Long, signedTx: String) {
@ -115,7 +117,7 @@ class WalletConnect(var bip32Path: String, var chainID: Long) : ExportKeyCommand
}
private fun signText(id: Long, message: String) {
val msg = message.hexToByteArray()
val msg = HexString(message).hexToByteArray()
val text = String(msg)
requestId = id
@ -124,7 +126,7 @@ class WalletConnect(var bip32Path: String, var chainID: Long) : ExportKeyCommand
Registry.scriptExecutor.runScript(scriptWithAuthentication().plus(SignCommand(Registry.walletConnect, hash)))
}
signAction = { session?.approveRequest(requestId, "0x${it.r.toNoPrefixHexString()}${it.s.toNoPrefixHexString()}${(it.recId + 27).toByte().toHexString()}") }
signAction = { session?.approveRequest(requestId, "0x${it.r.toNoPrefixHexString()}${it.s.toNoPrefixHexString()}${encode((it.recId + 27).toByte())}") }
val intent = Intent(Registry.mainActivity, SignMessageActivity::class.java).apply {
putExtra(SIGN_TEXT_MESSAGE, text)
@ -198,7 +200,7 @@ class WalletConnect(var bip32Path: String, var chainID: Long) : ExportKeyCommand
session?.kill()
session = WCSession(
fromWCUri(uri),
fromWCUri(uri).toFullyQualifiedConfig(),
MoshiPayloadAdapter(moshi),
sessionStore,
OkHttpTransport.Builder(okHttpClient, moshi),

View File

@ -1,8 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.50'
ext.kethereum_version = '0.79.1'
ext.kotlin_version = '1.4.10'
ext.kethereum_version = '0.83.0'
repositories {
google()
@ -10,7 +10,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip