-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
333 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 0 additions & 105 deletions
105
wallet_app/android/app/src/main/java/com/example/walletapp/AccountBalanceActivity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...t_app/android/app/src/main/java/com/example/walletapp/data/datasource/RetrofitInstance.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.walletapp.data.datasource | ||
|
||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
|
||
object RetrofitInstance { | ||
// Replace this with the actual StarkNet RPC URL | ||
private const val BASE_URL = "https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_7/" | ||
|
||
val api: StarknetApiService by lazy { | ||
Retrofit.Builder() | ||
.baseUrl(BASE_URL) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.build() | ||
.create(StarknetApiService::class.java) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...app/android/app/src/main/java/com/example/walletapp/data/datasource/StarknetApiService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.example.walletapp.data.datasource | ||
|
||
import com.example.walletapp.data.model.StarknetResponse | ||
import com.example.walletapp.data.repository.StarknetCallRequest | ||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
interface StarknetApiService { | ||
|
||
|
||
@POST("rFAP8fkTAz9TmYw8_V5Fyzxi-WSoQdhk") // rpc end point | ||
fun getBalance( @Body request: StarknetCallRequest): Call<StarknetResponse> | ||
} |
8 changes: 8 additions & 0 deletions
8
wallet_app/android/app/src/main/java/com/example/walletapp/data/model/StarknetResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.walletapp.data.model | ||
|
||
data class StarknetResponse( | ||
val jsonrpc: String, | ||
val id: Int, | ||
val result: List<String> | ||
) | ||
|
8 changes: 8 additions & 0 deletions
8
...pp/android/app/src/main/java/com/example/walletapp/data/repository/StarknetCallRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.walletapp.data.repository | ||
|
||
data class StarknetCallRequest( | ||
val id: Int = 1, | ||
val jsonrpc: String = "2.0", | ||
val method: String = "starknet_call", | ||
val params: List<Any> | ||
) |
26 changes: 26 additions & 0 deletions
26
...app/android/app/src/main/java/com/example/walletapp/data/repository/StarknetRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.example.walletapp.data.repository | ||
|
||
import android.util.Log | ||
import com.example.walletapp.data.datasource.RetrofitInstance | ||
import com.example.walletapp.data.model.StarknetResponse | ||
import retrofit2.Call | ||
|
||
class StarknetRepository() { | ||
fun getAccountBalance( | ||
contractAddress: String, | ||
accountAddress: String | ||
): Call<StarknetResponse> { | ||
val calldata = listOf(accountAddress) | ||
val params = listOf( | ||
mapOf( | ||
"contract_address" to "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", | ||
"calldata" to listOf("0x02dc260794e4c2eeae87b1403a88385a72c18a5844d220b88117b2965a8cf3a5"), | ||
"entry_point_selector" to "0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e" | ||
), | ||
"latest" | ||
) | ||
val request = StarknetCallRequest(params = params) | ||
|
||
return RetrofitInstance.api.getBalance(request) | ||
} | ||
} |
Oops, something went wrong.