Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
ae3560a
added offline money app
AdiDumi Mar 8, 2023
b7ade06
revert to normal
AdiDumi Mar 10, 2023
610931b
added first basic app hello world
AdiDumi Mar 15, 2023
6b6dec7
change color and layour
AdiDumi Mar 15, 2023
5a5e524
styles added
AdiDumi Mar 15, 2023
f31b0ce
added navigation and fragments to app
AdiDumi Mar 17, 2023
eb7d06a
correct get button error
AdiDumi Mar 17, 2023
4e6e9b5
qr code scanner and add ammount to balance
Robert-ML Mar 17, 2023
79e59b0
Created QR encoder
Mar 17, 2023
fa6b163
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
Mar 17, 2023
2200400
Got QR encoding to work
Mar 17, 2023
ecbe168
add public key QR
AdiDumi Mar 18, 2023
8a7c668
initial push for request payload and promise payload
Robert-ML Mar 18, 2023
d91cf76
finished RequestPayload and Promise but not tested
Robert-ML Mar 18, 2023
c37d9a8
delete sending amount
AdiDumi Mar 18, 2023
f9cda99
Merge remote-tracking branch 'origin/adrians' into adrians
AdiDumi Mar 18, 2023
271b00c
added new page and promise
AdiDumi Mar 18, 2023
5e07c79
Changed from stand alone application to library and integrated into t…
Robert-ML Mar 19, 2023
cc74d05
Changed the defaultCryptoProvider to something global that probably i…
Robert-ML Mar 19, 2023
7df22be
clean code and added named fragments
AdiDumi Mar 19, 2023
c72d074
added navigation menu
AdiDumi Mar 19, 2023
d725b6f
added strings notations for constants
AdiDumi Mar 19, 2023
23606da
Made a logo for the offline money sub-app trial
Robert-ML Mar 19, 2023
111b290
change logic to token based app
AdiDumi Mar 22, 2023
2ea82b2
Merge remote-tracking branch 'origin/adrians' into adrians
AdiDumi Mar 22, 2023
6095d20
Token + Wallet
naklecha Mar 22, 2023
e83f935
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
naklecha Mar 22, 2023
cac3438
Added database files
Mar 22, 2023
b61a055
Merge pull request #1 from naklecha/adrians
naklecha Mar 22, 2023
9af9f39
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
Mar 22, 2023
148cc04
Revert "Merge branch 'adrians' of https://github.com/AdiDumi/trustcha…
Mar 22, 2023
57fe85b
Private Key in QR code
naklecha Mar 22, 2023
785d821
Revert "Revert "Merge branch 'adrians' of https://github.com/AdiDumi/…
AdiDumi Mar 23, 2023
7d5b6eb
Added tokens table
Mar 23, 2023
40bfaf5
adding number picker and print money page
AdiDumi Mar 26, 2023
8aa68c7
Merge remote-tracking branch 'origin/adrians' into adrians
AdiDumi Mar 26, 2023
15c0f5b
update working demo
AdiDumi Mar 29, 2023
32235be
Update
naklecha Mar 29, 2023
65edd7e
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
naklecha Mar 29, 2023
5463321
Fixing json errors
naklecha Mar 29, 2023
0df4484
Merge pull request #2 from naklecha/adrians
naklecha Mar 29, 2023
e84497f
transfer QR create
Robert-ML Mar 29, 2023
3cc0033
token in QR
Robert-ML Mar 29, 2023
88b7501
Added PrintMoney Function in PrintMoneyFragment
SingleDevOps Mar 29, 2023
5126de3
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
SingleDevOps Mar 29, 2023
22276a5
token in QR
Robert-ML Mar 29, 2023
8bf2c6c
fixed double loop
SingleDevOps Mar 29, 2023
7d41ade
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
SingleDevOps Mar 29, 2023
ef50ff9
changed string length for verifier and genesisHash
SingleDevOps Mar 29, 2023
54e16c6
transfer QR from json
Robert-ML Mar 29, 2023
975e918
Fix token
naklecha Mar 29, 2023
3f05c17
transfer QR from json
Robert-ML Mar 29, 2023
7445201
Working Database!!!! :)
Mar 29, 2023
cb8779c
Merge remote-tracking branch 'origin/adrians' into adrians
Mar 29, 2023
abfa4e2
Changed print money function and number picker max
Mar 29, 2023
d79a675
tokens are transferred along with the private wallet
Robert-ML Apr 2, 2023
33d97df
Merge branch 'Tribler:master' into adrians
Robert-ML Apr 2, 2023
c18e232
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
naklecha Apr 7, 2023
cd695b6
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
naklecha Apr 7, 2023
b5e6dce
Added delete function
Apr 7, 2023
b9aee50
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
naklecha Apr 7, 2023
176a721
Fixed token check
naklecha Apr 7, 2023
a691dbe
Merge pull request #3 from naklecha/adrians
naklecha Apr 7, 2023
e28c8ff
Updated receiving token_id to hex
Apr 7, 2023
fd79990
public authority private and public key
Robert-ML Apr 8, 2023
77f1a04
renamed from offlinemoney to offlinedigitaleuro
Robert-ML Apr 8, 2023
5afddb8
renamed packages from offlinemoney to offlinedigitaleuro
Robert-ML Apr 8, 2023
04cc032
added money icons and 10 euro
AdiDumi Apr 19, 2023
6605325
Added Web of Trust database structure
Apr 20, 2023
b595d0c
restore file i deleted ups
AdiDumi Apr 20, 2023
c560198
Updated UI token images
Apr 20, 2023
ac18a6a
added list of trust users
AdiDumi Apr 20, 2023
dfd5ba9
added title to the web of trust page
AdiDumi Apr 20, 2023
0418d5b
Merge remote-tracking branch 'origin/adrians' into adrians
AdiDumi Apr 20, 2023
485e9af
added acceptance page and changed logic to be in that
AdiDumi Apr 20, 2023
352aaed
modularized functionality out of fragments to have everything in one …
Robert-ML Apr 22, 2023
183742f
Added token check function
Apr 22, 2023
5f390ee
Refactoring database code
naklecha Apr 22, 2023
5c2e57a
Merge branch 'adrians' of https://github.com/AdiDumi/trustchain-super…
naklecha Apr 22, 2023
5d4e595
Merge pull request #4 from naklecha/adrians
naklecha Apr 22, 2023
6ce4aec
done insertion and integrated token finidng
Robert-ML Apr 22, 2023
f02fb6a
implementing web of trust and double spending mitigation
Robert-ML Apr 22, 2023
db65d41
implemented web of trust and double spender detection, TODO testing
Robert-ML Apr 23, 2023
0a3a11a
debugging and changed app name
Robert-ML Apr 23, 2023
0b95586
update in printing
Robert-ML Apr 23, 2023
fe1c3b7
added error box at printing and saving message
AdiDumi Apr 23, 2023
b058d6e
Merge remote-tracking branch 'origin/modularity_integration' into mod…
AdiDumi Apr 23, 2023
76b4740
added multiple lines error and change names of boxes
AdiDumi Apr 23, 2023
2e45209
added count function to query tokens db and clean code with comments
AdiDumi Apr 23, 2023
1f3acc8
it is working boys
Robert-ML Apr 23, 2023
cb2cec6
Merge branch 'modularity_integration' of https://github.com/AdiDumi/t…
Robert-ML Apr 23, 2023
ae5c16a
removed some debug prints
Robert-ML Apr 23, 2023
03b770c
removed "Verify Money" Button
SingleDevOps Apr 23, 2023
409d9c2
refactor send space
AdiDumi Apr 23, 2023
da7a600
Merge remote-tracking branch 'origin/modularity_integration' into mod…
AdiDumi Apr 23, 2023
39940b8
added transactions page, refactoring files with no warnings
AdiDumi Apr 23, 2023
099f189
added transactions in a list and database update
AdiDumi Apr 24, 2023
9259950
moved transactions add to utility
AdiDumi Apr 24, 2023
dc6bdbc
Renamed database files
Apr 24, 2023
a53c798
change app names inside navigation
AdiDumi Apr 24, 2023
cad08f8
Merge remote-tracking branch 'origin/modularity_integration' into mod…
AdiDumi Apr 24, 2023
01cda5f
changed db name
AdiDumi Apr 24, 2023
104f7ab
change message for accept
AdiDumi Apr 24, 2023
a5ffbd9
change message for accept
AdiDumi Apr 24, 2023
6f351ef
Added gifs and photos
Apr 24, 2023
a532f60
Create intermediate_wallet_illustration.jpeg
Apr 24, 2023
97760d5
change list
AdiDumi Apr 24, 2023
148430f
Merge remote-tracking branch 'origin/modularity_integration' into mod…
AdiDumi Apr 24, 2023
ddd4568
Update README.md
Apr 24, 2023
0e8cf40
addition to readme
Robert-ML Apr 24, 2023
bfe908d
Update README.md
Apr 24, 2023
aeab75f
Update README.md
Apr 24, 2023
ec8eaa7
Update README.md
Apr 24, 2023
a2f4945
managed to work the transaction history and web of trust
AdiDumi Apr 24, 2023
b75a42b
solved most of the PR comments
AdiDumi Apr 26, 2023
93d75b0
added bigger pictures and new layout for transaction history
AdiDumi May 17, 2023
b9a416d
solved PR comments
Robert-ML May 18, 2023
1af552a
changed info message to resamble button name
Robert-ML May 18, 2023
d63ecde
Update README.md
Robert-ML May 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
359 changes: 200 additions & 159 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ dependencies {
implementation project(':atomic-swap')
implementation project(':literaturedao')
implementation project(':detoks')
implementation project(':offlinedigitaleuro')
api(project(':common')) {
exclude group: 'net.java.dev.jna'
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@
android:parentActivityName=".ui.dashboard.DashboardActivity"
android:theme="@style/Fullscreen" />

<activity
android:name="nl.tudelft.trustchain.offlinedigitaleuro.MainActivityOfflineDigitalEuro"
android:parentActivityName=".ui.dashboard.DashboardActivity"
android:theme="@style/Theme.PeerChat" />

<activity
android:name="nl.tudelft.trustchain.valuetransfer.ValueTransferMainActivity"
android:exported="true"
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/nl/tudelft/trustchain/app/AppDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import nl.tudelft.trustchain.trader.ui.TrustChainTraderActivity
import nl.tudelft.trustchain.valuetransfer.ValueTransferMainActivity
import nl.tudelft.trustchain.voting.VotingActivity
import nl.tudelft.trustchain.detoks.DeToksActivity
import nl.tudelft.trustchain.offlinedigitaleuro.MainActivityOfflineDigitalEuro

enum class AppDefinition(
@DrawableRes val icon: Int,
Expand All @@ -36,6 +37,13 @@ enum class AppDefinition(
DeToksActivity::class.java,
true,
),
OFFLINE_MONEY(
R.drawable.ic_offline_money,
"Offline Digital Euro",
R.color.black,
MainActivityOfflineDigitalEuro::class.java,
true,
),
EIGHTEEN_PLUS(
R.drawable.ic_18_plus,
"18+",
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/nl/tudelft/trustchain/app/AppLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class AppLoader(
val PREFERRED_APPS = stringSetPreferencesKey("preferred_apps")
val DEFAULT_APPS = setOf(
AppDefinition.DETOKS.appName,
AppDefinition.OFFLINE_MONEY.appName,
AppDefinition.VALUETRANSFER.appName,
AppDefinition.MUSIC_DAO.appName,
AppDefinition.EIGHTEEN_PLUS.appName
Expand Down
36 changes: 36 additions & 0 deletions common/src/main/res/drawable/ic_offline_money.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="83dp"
android:height="83dp"
android:viewportWidth="83"
android:viewportHeight="83">
<path
android:pathData="M1.5,41.5a40,40 0,1 0,80 0a40,40 0,1 0,-80 0z"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#ffff00"/>
<path
android:pathData="M6.5,41.5a35,35 0,1 0,70 0a35,35 0,1 0,-70 0z"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#ffff00"/>
<path
android:pathData="M41.5,61.75L37.45,57.7C39.7,55.5 43.3,55.5 45.55,57.7ZM49.72,53.65C47.54,51.46 44.59,50.23 41.5,50.23C38.41,50.23 35.46,51.46 33.28,53.65L29.23,49.49C36.01,42.72 46.99,42.72 53.77,49.49ZM57.93,45.44C53.59,41.06 47.67,38.59 41.5,38.59C35.33,38.59 29.41,41.06 25.07,45.44L21.13,41.21C32.41,30.04 50.59,30.04 61.87,41.21ZM66.03,37.16C52.48,23.63 30.52,23.63 16.97,37.16L12.86,33.11C20.46,25.52 30.76,21.25 41.5,21.25C52.24,21.25 62.54,25.52 70.14,33.11Z"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#0080f0"/>
<path
android:pathData="M4,41.5a37.5,37.5 0,1 0,75 0a37.5,37.5 0,1 0,-75 0z"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#ffff00"/>
<path
android:pathData="M36.5,66.5L36.5,16.5"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#007fff"/>
<path
android:pathData="M46.5,66.5L46.5,16.5"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#007fff"/>
</vector>
1 change: 1 addition & 0 deletions offlinedigitaleuro/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
290 changes: 290 additions & 0 deletions offlinedigitaleuro/README.md

Large diffs are not rendered by default.

87 changes: 87 additions & 0 deletions offlinedigitaleuro/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdk 33

defaultConfig {
minSdkVersion 22
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

buildFeatures {
viewBinding = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
namespace 'nl.tudelft.trustchain.offlinedigitaleuro'
}

dependencies {

implementation project(':common')

implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.2.0'

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation "androidx.room:room-runtime:$room_version"

implementation "androidx.lifecycle:lifecycle-runtime:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"

implementation 'com.github.MattSkala:recyclerview-itemadapter:0.4'

// Material
implementation 'com.google.android.material:material:1.1.0'
implementation 'com.getbase:floatingactionbutton:1.10.1'

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

// Logging
implementation 'io.github.microutils:kotlin-logging:1.7.7'

testImplementation 'junit:junit:4.12'

androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'


implementation 'androidx.room:room-common:2.5.0'
implementation 'androidx.room:room-ktx:2.5.0'
kapt "androidx.room:room-compiler:2.5.0"
implementation "androidx.activity:activity-ktx:1.6.1"
implementation "androidx.fragment:fragment-ktx:1.5.5"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
implementation "androidx.room:room-runtime:2.5.0"

annotationProcessor "androidx.room:room-compiler:$room_version"

implementation 'com.github.travijuu:numberpicker:1.0.7'
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added offlinedigitaleuro/images/main_balance_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added offlinedigitaleuro/images/print_money.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added offlinedigitaleuro/images/print_money.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added offlinedigitaleuro/images/scanning_qrcode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added offlinedigitaleuro/images/send_money.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added offlinedigitaleuro/images/send_money1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added offlinedigitaleuro/images/send_money2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions offlinedigitaleuro/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package nl.tudelft.trustchain.offlinedigitaleuro

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("nl.tudelft.trustchain.offlinemoney", appContext.packageName)
}
}
8 changes: 8 additions & 0 deletions offlinedigitaleuro/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<activity android:name=".MainActivityOfflineDigitalEuro" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nl.tudelft.trustchain.offlinedigitaleuro

import nl.tudelft.trustchain.common.BaseActivity

class MainActivityOfflineDigitalEuro() : BaseActivity() {
override val navigationGraph = R.navigation.nav_graph_offlinedigitaleuro
override val bottomNavigationMenu = R.menu.offlinedigitaleuro_menu
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package nl.tudelft.trustchain.offlinedigitaleuro.db

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase

// Annotates class to be a Room Database with a table (entity) of the Word class

@Database(entities = [UserData::class, Transactions::class, Token::class, WebOfTrust::class], version = 1, exportSchema = false)
abstract class OfflineDigitalEuroRoomDatabase : RoomDatabase() {
abstract fun userDao(): UserDao
abstract fun transactionsDao(): TransactionsDao
abstract fun tokensDao(): TokensDao
abstract fun webOfTrustDao(): WebOfTrustDAO

companion object {
@Volatile
private var INSTANCE: OfflineDigitalEuroRoomDatabase? = null
fun getDatabase(context: Context): OfflineDigitalEuroRoomDatabase {
return INSTANCE ?: synchronized(this) {
val instance = Room.databaseBuilder(
context.applicationContext,
OfflineDigitalEuroRoomDatabase::class.java,
"item_database"
)
.fallbackToDestructiveMigration()
.allowMainThreadQueries()
.build()
INSTANCE = instance
return instance
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package nl.tudelft.trustchain.offlinedigitaleuro.db

import androidx.room.*


@Entity(tableName = "tokens_table")
class Token(
@PrimaryKey() var token_id: String,
@ColumnInfo(name = "token_value") var token_value: Double,
@ColumnInfo(name = "token_data") var token_data: ByteArray,
)


@Dao
interface TokensDao {
// Retrieve all tokens in database
@Query("SELECT * FROM tokens_table ORDER BY token_value")
fun getAllTokens() : Array<Token>

// Get all token_types from from database
@Query("SELECT * FROM tokens_table WHERE token_value = :token_value")
fun getAllTokensOfValue(token_value: Double) : Array<Token>

// Get an amount of token_types from from database
@Query("SELECT * FROM tokens_table WHERE token_value = :token_value LIMIT :count")
fun getCountOfTokensOfValue(token_value: Double, count: Int) : Array<Token>

// get how many tokens are of a certain value from database
@Query("SELECT COUNT(*) FROM tokens_table WHERE token_value = :token_value")
fun getCountTokensOfValue(token_value: Double) : Int

@Query("SELECT * FROM tokens_table WHERE token_id = :token_id")
fun getSpecificToken(token_id: String) : Array<Token>

// Insert transactions into the database
@Insert
suspend fun insertToken(tokens: Token)

// Delete transactions
@Query("DELETE FROM tokens_table WHERE token_id = :token_id")
fun deleteToken(token_id: String)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package nl.tudelft.trustchain.offlinedigitaleuro.db

import androidx.room.*


@Entity(tableName = "transactions_table")
class Transactions(
@PrimaryKey(autoGenerate = true) var id: Int = 0,
@ColumnInfo(name = "transaction_datetime") var transaction_datetime: String,
@ColumnInfo(name = "public_key") var public_key: String,
@ColumnInfo(name = "amount") var amount: Double,
@ColumnInfo(name = "verified") var verified: Boolean,
)


@Dao
interface TransactionsDao {
// Get all transactions from database
@Query("SELECT * FROM transactions_table")
fun getTransactionData(): List<Transactions>

// Insert transactions into the database
@Insert
suspend fun insertTransaction(transactions: Transactions)

// Delete transactions
@Delete
suspend fun deleteTransactionData(transactions: Transactions)

// @Query("DELETE FROM transactions_table")
// suspend fun deleteTransactionData()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package nl.tudelft.trustchain.offlinedigitaleuro.db

import androidx.room.*

@Entity(tableName = "userdata_table")
data class UserData(
@PrimaryKey(autoGenerate = true) val id: Int = 0,
@ColumnInfo(name = "username") val username: String,
@ColumnInfo(name = "public_key") val public_key: String,
@ColumnInfo(name = "private_key") val private_key: String,
)

@Dao
interface UserDao {

@Query("SELECT * FROM userdata_table")
fun getUserData(): List<UserData>

@Insert
suspend fun insertUser(userData: UserData)

@Update
suspend fun updateUser(userData: UserData)

@Delete
suspend fun deleteUserData(userData: UserData)
}
Loading