From ff43dcc4f489fb193b6490819c1551a787aa3e71 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Thu, 1 Nov 2018 14:50:18 -0500 Subject: [PATCH] Included a brain key model and simple DAO stub --- .../bitsybitshareswallet/daos/BitsyDatabase.kt | 7 ++++++- .../bitsybitshareswallet/daos/BrainKeyDao.kt | 16 ++++++++++++++++ .../bitsybitshareswallet/models/BrainKey.kt | 13 +++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BrainKeyDao.kt create mode 100644 app/src/main/java/cy/agorise/bitsybitshareswallet/models/BrainKey.kt diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BitsyDatabase.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BitsyDatabase.kt index b428930..d5f0613 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BitsyDatabase.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BitsyDatabase.kt @@ -11,7 +11,11 @@ import cy.agorise.bitsybitshareswallet.models.* Balance::class, UserAccount::class, Authority::class, - UserAccountAuthority::class + UserAccountAuthority::class, + BrainKey::class, + EquivalentValue::class, + Operation::class, + Transfer::class ], version = 1, exportSchema = false) abstract class BitsyDatabase : RoomDatabase() { @@ -20,6 +24,7 @@ abstract class BitsyDatabase : RoomDatabase() { abstract fun userAccountDao(): UserAccountDao abstract fun authorityDao(): AuthorityDao abstract fun userAccountAuthorityDao(): UserAccountAuthorityDao + abstract fun brainKeyDao(): BrainKeyDao companion object { diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BrainKeyDao.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BrainKeyDao.kt new file mode 100644 index 0000000..2432b68 --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BrainKeyDao.kt @@ -0,0 +1,16 @@ +package cy.agorise.bitsybitshareswallet.daos + +import androidx.lifecycle.LiveData +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.Query +import cy.agorise.bitsybitshareswallet.models.BrainKey + +@Dao +interface BrainKeyDao { + @Insert + fun insert(asset: BrainKeyDao) + + @Query("SELECT * FROM brain_keys") + fun getAllBrainKeys(): LiveData> +} \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/models/BrainKey.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/models/BrainKey.kt new file mode 100644 index 0000000..3d77398 --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/models/BrainKey.kt @@ -0,0 +1,13 @@ +package cy.agorise.bitsybitshareswallet.models + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.PrimaryKey + +@Entity(tableName="brain_keys") +data class BrainKey( + @PrimaryKey + @ColumnInfo(name = "public_key") val publicKey: String, + @ColumnInfo(name = "encrypted_brain_key") val encryptedBrainKey: String, + @ColumnInfo(name = "sequence_number") val sequenceNumber: Long +) \ No newline at end of file