diff --git a/app/build.gradle b/app/build.gradle index dd3ec8a535..6229998b0e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,13 +25,15 @@ android { defaultConfig { buildConfigField "String", "BLOCKCHAIN_NET_URL", '"https://mainnet.infura.io"' buildConfigField "String", "INFURA_API_KEY", getKey("INFURA_API_KEY") + buildConfigField "boolean", "PRIVATE_TEST_NET", "false" } buildTypes { - otherChain { + chainTest { signingConfig signingConfigs.debug minifyEnabled false buildConfigField "String", "BLOCKCHAIN_NET_URL", getKey("BLOCKCHAIN_NET_URL") + buildConfigField "boolean", "PRIVATE_TEST_NET", getKey("PRIVATE_TEST_NET", "false") } debug { @@ -41,7 +43,6 @@ android { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - buildConfigField "String", "INFURA_API_KEY", getKey("INFURA_API_KEY") } } @@ -55,11 +56,11 @@ android { } } -static def getKey(String property) { +static def getKey(String property, String defaultValue = "") { Properties properties = new Properties() properties.load(new FileInputStream("project_keys")) String value = properties.getProperty(property) - return value != null ? value : "" + return value != null ? value : defaultValue } diff --git a/app/src/main/java/pm/gnosis/android/app/authenticator/data/geth/GethAccountManager.kt b/app/src/main/java/pm/gnosis/android/app/authenticator/data/geth/GethAccountManager.kt index 396070c1e7..cf5fc98767 100644 --- a/app/src/main/java/pm/gnosis/android/app/authenticator/data/geth/GethAccountManager.kt +++ b/app/src/main/java/pm/gnosis/android/app/authenticator/data/geth/GethAccountManager.kt @@ -16,7 +16,8 @@ class GethAccountManager @Inject constructor(private val preferencesManager: Pre private val keyStore: KeyStore) { init { if (keyStore.accounts.size() == 0L) { - if (BuildConfig.DEBUG) { + @Suppress("ConstantConditionIf") + if (BuildConfig.PRIVATE_TEST_NET) { TestRPC.accounts.iterator().forEach({ val privateKey = it.value.first val passphrase = it.value.second @@ -33,7 +34,7 @@ class GethAccountManager @Inject constructor(private val preferencesManager: Pre fun getAccounts(): List { val accounts = ArrayList() - for (i in 0..keyStore.accounts.size() - 1) { + for (i in 0 until keyStore.accounts.size()) { accounts += keyStore.accounts[i] } return accounts @@ -52,8 +53,9 @@ class GethAccountManager @Inject constructor(private val preferencesManager: Pre fun getAccountPassphrase(): String { - if (BuildConfig.DEBUG) { - return TestRPC.accounts[getActiveAccount().address.hex]?.second!! + @Suppress("ConstantConditionIf") + (return if (BuildConfig.PRIVATE_TEST_NET) { + TestRPC.accounts[getActiveAccount().address.hex]?.second!! } else { var passphrase = preferencesManager.prefs.getString(PreferencesManager.PASSPHRASE_KEY, "") if (passphrase.isEmpty()) { @@ -62,7 +64,7 @@ class GethAccountManager @Inject constructor(private val preferencesManager: Pre putString(PreferencesManager.PASSPHRASE_KEY, passphrase) } } - return passphrase - } + passphrase + }) } }