Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
trbutler4 committed Oct 21, 2024
1 parent a4445f6 commit 16294a8
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 21 deletions.
22 changes: 22 additions & 0 deletions wallet_app/android/.idea/other.xml

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

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.walletapp.data.datasource
package com.example.walletapp.data.coins

import retrofit2.Response
import retrofit2.http.GET
Expand All @@ -17,4 +17,4 @@ interface CoinGeckoApi {
@Query("ids") ids: String, // Comma-separated token IDs
@Query("vs_currencies") vsCurrencies: String // Comma-separated currency codes
): GetTokenPriceResponse
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.example.walletapp.data.repository
package com.example.walletapp.data.coins

import com.example.walletapp.di.RetrofitClient
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import retrofit2.Response
import com.example.walletapp.data.datasource.GetTokenPriceResponse

class CoinRepository {
suspend fun getTokenPrices(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.walletapp.di

import com.example.walletapp.data.datasource.CoinGeckoApi
import com.example.walletapp.data.coins.CoinGeckoApi

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.example.walletapp.model

class Account {
var address: String = ""
}
data class Account (
val address: String
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.walletapp.model

class Token {
var address: String = ""
var symbol: String = ""
}
class Token (
val address: String,
val symbol: String
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.example.walletapp.model

class User {
private var accounts: Array<Account> = emptyArray();
data class User (
val accounts: Array<Account>
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

fun hasAccount(): Boolean {
return accounts.isNotEmpty()
other as User

return accounts.contentEquals(other.accounts)
}

fun getAccounts(): Array<Account> {
return accounts
override fun hashCode(): Int {
return accounts.contentHashCode()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.launch
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.State
import com.example.walletapp.data.repository.CoinRepository
import com.example.walletapp.data.coins.CoinRepository

class CoinViewModel : ViewModel() {
private val repository = CoinRepository()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ fun Wallet(modifier: Modifier, onNewTokenPress: () -> Unit, onReceivePress: () -
val prices by coinViewModel.prices
val errorMessage by coinViewModel.errorMessage

// TODO:
LaunchedEffect(Unit) {
coinViewModel.getTokenPrices(ids = "starknet,ethereum", vsCurrencies = "usd") // Fetch starknet and bitcoin prices in USD
coinViewModel.getTokenPrices(ids = "starknet,ethereum", vsCurrencies = "usd")
}

LaunchedEffect (Unit){
Expand Down

0 comments on commit 16294a8

Please sign in to comment.