Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Bugfix: remove nonconfigurable directories from kin storage path (#30)
Browse files Browse the repository at this point in the history
* removed environment separating directories

* all: version bump to 2.0.0
  • Loading branch information
samdowd authored Aug 22, 2021
1 parent 08806c5 commit e336b59
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ buildscript {
ext {
versions = [:]
versions.kin = "1.0.1"
versions.kin = "2.0.0"
}
}
dependencies {
Expand Down
2 changes: 1 addition & 1 deletion base/src/main/java/org/kin/sdk/base/models/SDKConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package org.kin.sdk.base.models

object SDKConfig {
const val platform = "JVM"
const val versionString = "1.0.1"
const val versionString = "2.0.0"
val systemUserAgent by lazy { System.getProperty("http.agent") ?: "JVM/unspecified" }
}
18 changes: 7 additions & 11 deletions base/src/main/java/org/kin/sdk/base/storage/KinFileStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ class KinFileStorage @JvmOverloads internal constructor(
}

override fun getOrCreateCID(): String {
val exisingkinConfig = getKinConfig()
return if (exisingkinConfig.isPresent) {
exisingkinConfig.get()!!.cid
val existingkinConfig = getKinConfig()
return if (existingkinConfig.isPresent) {
existingkinConfig.get()!!.cid
} else {
val newCid = UUID.randomUUID().toString()
val newKinConfig = StorageKinConfig.newBuilder()
Expand Down Expand Up @@ -525,22 +525,18 @@ class KinFileStorage @JvmOverloads internal constructor(

/**
* File Structure
* Environment Directory: <context.getFilesDir>/env/<env passcode in hex>/
* Config: <Environment Directory>/config
* Account Directory: <Environment Directory>/kin_accounts/<public key>
* Config: <Base Directory>/config
* Account Directory: <Base Directory>/kin_accounts/<account hash>
* KinAccount object: <Account Directory>/account_info
* KinTransactions: <Account Directory>/<account_id>_transactions/<account_id>_transactions
* Invoices: <Account Directory>/<account_id>_invoices/<account_id>_invoices
*/

private fun envDirectory(): String =
"$filesDir/env/${Hex.encodeHexString(networkEnvironment.networkPassphrase.toByteArray())}"

private fun directoryForConfig(): String =
"${envDirectory()}/"
"$filesDir/"

private fun directoryForAllAccounts(): String =
"${envDirectory()}/$directoryNameForAllAccounts/"
"$filesDir/$directoryNameForAllAccounts/"

private fun directoryForAccount(accountId: KinAccount.Id): String {
return directoryForAllAccounts() + accountId.hashCode() + "/"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ allprojects {
ext {
// Libraries
groupId = "org.kin.sdk.android"
libraryVersion = "1.0.1" // NOTE: ALSO CHANGE SDKConfig.versionString when updating. Should be identical.
libraryVersion = "2.0.0" // NOTE: ALSO CHANGE SDKConfig.versionString when updating. Should be identical.
siteUrl = "https://github.com/kinecosystem/kin-android"
gitUrl = "https://github.com/kinecosystem/kin-android.git"
}
Expand Down

0 comments on commit e336b59

Please sign in to comment.