Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for Protocol 8 #239

Merged
merged 7 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ android {
buildConfigField("String", "URL_PROXY_BASE", "\"https://wallet-proxy.stagenet.concordium.com\"")
buildConfigField("String", "URL_EXPLORER_BASE", "\"https://stagenet.ccdscan.io/\"")
buildConfigField("String", "URL_NOTIFICATIONS_BASE", "\"https://notification-api.stagenet.concordium.com/api/\"")
buildConfigField("String", "HOSTNAME_GRPC", "\"grpc.stagenet.concordium.com\"")

buildConfigField("boolean", "SHOW_GTU_DROP", "true")

Expand Down Expand Up @@ -127,6 +128,7 @@ android {
buildConfigField("String", "URL_PROXY_BASE", "\"https://wallet-proxy.testnet.concordium.com\"")
buildConfigField("String", "URL_EXPLORER_BASE", "\"https://testnet.ccdscan.io/\"")
buildConfigField("String", "URL_NOTIFICATIONS_BASE", "\"https://notification-api.testnet.concordium.com/api/\"")
buildConfigField("String", "HOSTNAME_GRPC", "\"grpc.testnet.concordium.com\"")

buildConfigField("boolean", "SHOW_GTU_DROP", "true")

Expand Down Expand Up @@ -156,6 +158,7 @@ android {
buildConfigField("String", "URL_PROXY_BASE", "\"https://wallet-proxy.mainnet.concordium.software\"")
buildConfigField("String", "URL_EXPLORER_BASE", "\"https://ccdscan.io/\"")
buildConfigField("String", "URL_NOTIFICATIONS_BASE", "\"https://notification-api.mainnet.concordium.software/api/\"")
buildConfigField("String", "HOSTNAME_GRPC", "\"grpc.mainnet.concordium.software\"")

buildConfigField("boolean", "SHOW_GTU_DROP", "false")

Expand Down Expand Up @@ -230,7 +233,7 @@ allprojects {

dependencies {

implementation("com.concordium.sdk:concordium-android-sdk:7.2.0") {
implementation("com.concordium.sdk:concordium-android-sdk:10.0.0") {
exclude group: "org.bouncycastle"
exclude group: "net.jcip"
}
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/com/concordium/wallet/AppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ object AppConfig {

const val useOfflineMock = BuildConfig.USE_BACKEND_MOCK

val proxyBaseUrl: String
get() = BuildConfig.URL_PROXY_BASE

val appVersion: String
get() = if (!BuildConfig.ENV_NAME.equals("production")) {
BuildConfig.VERSION_NAME + (if (BuildConfig.DEBUG) " (debug)" else " (release)") +
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/com/concordium/wallet/core/AppCore.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.concordium.wallet.core

import android.os.Handler
import com.concordium.sdk.ClientV2
import com.concordium.wallet.App
import com.concordium.wallet.core.crypto.CryptoLibrary
import com.concordium.wallet.core.crypto.CryptoLibraryReal
Expand All @@ -12,6 +13,7 @@ import com.concordium.wallet.core.tracking.AppTracker
import com.concordium.wallet.core.tracking.MatomoAppTracker
import com.concordium.wallet.core.tracking.NoOpAppTracker
import com.concordium.wallet.data.AppWalletRepository
import com.concordium.wallet.data.backend.GrpcBackendConfig
import com.concordium.wallet.data.backend.ProxyBackend
import com.concordium.wallet.data.backend.ProxyBackendConfig
import com.concordium.wallet.data.backend.airdrop.AirDropBackend
Expand Down Expand Up @@ -40,6 +42,7 @@ class AppCore(val app: App) {

val gson: Gson = getGson()
val proxyBackendConfig = ProxyBackendConfig(gson)
private val grpcBackendConfig = GrpcBackendConfig()
private val tokenBackendConfig = TokensBackendConfig(gson)
private val airdropBackendConfig = AirDropBackendConfig(gson)
private val newsfeedRssBackendConfig: NewsfeedRssBackendConfig by lazy(::NewsfeedRssBackendConfig)
Expand Down Expand Up @@ -118,6 +121,10 @@ class AppCore(val app: App) {
return proxyBackendConfig.backend
}

fun getGrpcClient(): ClientV2 {
return grpcBackendConfig.client
}

suspend fun startNewSession(
activeWallet: AppWallet,
isLoggedIn: Boolean = session.isLoggedIn.value == true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.concordium.wallet.data.backend

import com.concordium.sdk.ClientV2
import com.concordium.sdk.Connection
import com.concordium.sdk.TLSConfig
import com.concordium.wallet.BuildConfig

class GrpcBackendConfig {
val client: ClientV2 by lazy {
ClientV2.from(
Connection.builder()
.host(BuildConfig.HOSTNAME_GRPC)
.port(PORT)
.useTLS(TLSConfig.auto())
.timeout(TIMEOUT_MS)
.build()
)
}

private companion object {
private const val PORT = 20000
private const val TIMEOUT_MS = 30_000
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.concordium.wallet.data.backend

import com.concordium.wallet.AppConfig
import com.concordium.wallet.BuildConfig
import com.google.gson.Gson
import com.ihsanbal.logging.Level
import com.ihsanbal.logging.LoggingInterceptor
Expand All @@ -12,17 +13,16 @@ import java.util.concurrent.TimeUnit

class ProxyBackendConfig(val gson: Gson) {

val retrofit: Retrofit
val backend: ProxyBackend

init {
retrofit = initializeRetrofit(AppConfig.proxyBaseUrl)
backend = retrofit.create(ProxyBackend::class.java)
val retrofit: Retrofit by lazy {
initializeRetrofit()
}
val backend: ProxyBackend by lazy {
retrofit.create(ProxyBackend::class.java)
}

private fun initializeRetrofit(baseUrl: String): Retrofit {
private fun initializeRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl(baseUrl)
.baseUrl(BuildConfig.URL_PROXY_BASE)
.client(initializeOkkHttp())
.addConverterFactory(GsonConverterFactory.create(gson))
.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.concordium.wallet.data.cryptolib

import com.concordium.wallet.data.model.AccountData
import com.concordium.wallet.data.model.BakerKeys
import com.concordium.wallet.data.model.DelegationTarget
import com.concordium.wallet.data.model.GlobalParams
import com.concordium.wallet.data.model.InputEncryptedAmount
import java.io.Serializable
Expand All @@ -20,13 +18,4 @@ data class CreateTransferInput(
val receiverPublicKey: String?,
val senderSecretKey: String?,
val inputEncryptedAmount: InputEncryptedAmount?,
val capital: String?,
val restakeEarnings: Boolean? = null,
val delegationTarget: DelegationTarget? = null,
val metadataUrl: String? = null,
val openStatus: String? = null,
val bakerKeys: BakerKeys? = null,
val transactionFeeCommission: Double? = null,
val bakingRewardCommission: Double? = null,
val finalizationRewardCommission: Double? = null
): Serializable
19 changes: 17 additions & 2 deletions app/src/main/java/com/concordium/wallet/data/model/AccountData.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
package com.concordium.wallet.data.model

import com.concordium.sdk.crypto.ed25519.ED25519SecretKey
import com.concordium.sdk.transactions.Index
import com.concordium.sdk.transactions.SignerEntry
import com.concordium.wallet.App
import com.concordium.wallet.core.gson.RawJsonTypeAdapter
import com.google.gson.annotations.JsonAdapter
import java.io.Serializable

data class AccountData(
@JsonAdapter(RawJsonTypeAdapter::class)
val keys: RawJson,
val threshold: Int
): Serializable
val threshold: Int,
) : Serializable {
fun getSecreteKey(): ED25519SecretKey =
App.appCore.gson.fromJson(keys.json, AccountDataKeys::class.java)
.level0
.keys
.keys
.signKey
.let(ED25519SecretKey::from)

fun getSignerEntry(): SignerEntry=
SignerEntry.from(Index.from(0), Index.from(0), getSecreteKey())
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ data class BakerDelegationData(
var type: String
) : Serializable {

var transferSubmissionStatus: TransferSubmissionStatus? = null
var submissionId: String? = null
var energy: Long? = null
var accountNonce: AccountNonce? = null
Expand Down
Loading