Skip to content

Commit

Permalink
adding todos/structure for ODHack issues
Browse files Browse the repository at this point in the history
  • Loading branch information
trbutler4 committed Oct 22, 2024
1 parent 51ee19f commit 7109ad6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class CoinViewModel : ViewModel() {
vsCurrencies: String) {
viewModelScope.launch {
try {
// Fetch prices for starknet and bitcoin in USD
val response = repository.getTokenPrices(ids,vsCurrencies)
if (response.isSuccessful) {
response.body()?.let { priceMap ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ fun Wallet(modifier: Modifier, onNewTokenPress: () -> Unit, onReceivePress: () -
val prices by coinViewModel.prices
val errorMessage by coinViewModel.errorMessage

// TODO:
// TODO(#106): use the accounts stored tokens instead of hardcoding
LaunchedEffect(Unit) {
coinViewModel.getTokenPrices(ids = "starknet,ethereum", vsCurrencies = "usd")
}

LaunchedEffect (Unit){
// TODO(#107): fetch all token balances
try {
// Get the balance of the account
val getBalance = starknetClient.getEthBalance(accountAddress)
withContext(Dispatchers.Main) {
balance = weiToEther(getBalance).toDoubleWithTwoDecimal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import com.swmansion.starknet.data.types.Felt
import com.swmansion.starknet.data.types.Uint256
import com.swmansion.starknet.provider.rpc.JsonRpcProvider
import com.swmansion.starknet.signer.StarkCurveSigner
import com.swmansion.starknet.account.Account
import kotlinx.coroutines.future.await

import java.math.BigDecimal

const val ETH_ERC20_ADDRESS = "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
Expand Down Expand Up @@ -35,9 +37,12 @@ class StarknetClient(private val rpcUrl: String) {
cairoVersion = Felt.ONE,
)

// TODO: deploy account
// TODO(#99): add account deployment logic

}

// TODO(#107): change name to getBalance, support getting balance for any token
// follow example: https://github.com/software-mansion/starknet-jvm/blob/main/androiddemo/src/main/java/com/example/androiddemo/MainActivity.kt
suspend fun getEthBalance(accountAddress: Felt): Uint256 {
val erc20ContractAddress = Felt.fromHex(ETH_ERC20_ADDRESS)

Expand Down Expand Up @@ -66,8 +71,11 @@ class StarknetClient(private val rpcUrl: String) {
)
}

suspend fun sendERC20() {
// TODO(#24)
suspend fun transferFunds(account: Account, toAddress: Felt, amount: Uint256) {
// TODO(#102): add logic to transfer funds here
// follow the example: https://github.com/software-mansion/starknet-jvm/blob/main/androiddemo/src/main/java/com/example/androiddemo/MainActivity.kt
}



}

0 comments on commit 7109ad6

Please sign in to comment.