Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,48 @@ fun isUserSignIn(): Boolean {
}

fun firebaseCustomLogin(token: String, onComplete: FirebaseAuthCallback) {
logd(TAG, "=== firebaseCustomLogin START ===")
val auth = Firebase.auth
if (auth.currentUser != null) {
logd(TAG, "have signed in")
val currentUser = auth.currentUser
logd(TAG, "Current Firebase user: ${currentUser?.uid ?: "null"}")

if (currentUser != null) {
logd(TAG, "User already signed in, UID: ${currentUser.uid}, isAnonymous: ${currentUser.isAnonymous}")
onComplete.invoke(true, null)
return
}

logd(TAG, "Attempting to sign in with custom token (length: ${token.length})")
auth.signInWithCustomToken(token).addOnCompleteListener { task ->
logd(TAG, "signInWithCustomToken completed - success: ${task.isSuccessful}")
if (!task.isSuccessful) {
logd(TAG, "ERROR: signInWithCustomToken failed - ${task.exception?.message}")
}

ioScope {
clearUserCache()
if (task.isSuccessful) {
auth.currentUser?.getIdToken(true)?.addOnSuccessListener { result ->
val newUser = auth.currentUser
logd(TAG, "Sign in successful, new user UID: ${newUser?.uid}")
logd(TAG, "Requesting ID token refresh")

newUser?.getIdToken(true)?.addOnSuccessListener { result ->
logd(TAG, "ID token obtained successfully")
uiScope {
onComplete.invoke(true, null)
}
getFirebaseMessagingToken()
}?.addOnFailureListener { e ->
logd(TAG, "ERROR: Failed to get ID token - ${e.message}")
uiScope { onComplete.invoke(false, e) }
}
} else {
logd(TAG, "ERROR: Task unsuccessful, calling failure callback")
val exception = task.exception
logd(TAG, "Exception type: ${exception?.javaClass?.simpleName}")
logd(TAG, "Exception message: ${exception?.message}")
uiScope {
onComplete.invoke(false, task.exception)
onComplete.invoke(false, exception)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,8 @@ interface ApiService {
@Query("chain_type") chainType: String,
@Query("network") currency: String?,
): AddTokenListResponse
}

@POST("/api/v4/onramp/coinbase")
suspend fun createCoinbaseOnRampSession(@Body params: CoinbaseOnRampRequest): CoinbaseOnRampResponse

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.flowfoundation.wallet.network.model

import com.google.gson.annotations.SerializedName


data class CoinbaseOnRampRequest(
@SerializedName("address")
val address: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.flowfoundation.wallet.network.model

import com.google.gson.annotations.SerializedName

data class CoinbaseOnRampResponse(
@SerializedName("data")
val data: CoinbaseOnRampInfo?,
@SerializedName("status")
val status: Int?
)

data class CoinbaseOnRampInfo(
val session: CoinbaseOnRampSession?
)

data class CoinbaseOnRampSession(
@SerializedName("onrampUrl")
val onRampUrl: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ class BackupDetailActivity : BaseActivity(), OnMapReadyCallback, OnTransactionSt
binding.btnRecoveryPhrase.setProgressVisible(false)
val data = intent?.getParcelableArrayListExtra<BackupItem>(EXTRA_CONTENT) ?: return
data.firstOrNull {
it.publicKey == backupKey?.info?.pubKey?.publicKey
// Normalize public keys for comparison
val itemPubKey = it.publicKey?.removePrefix("0x")?.lowercase()
val backupPubKey = backupKey?.info?.pubKey?.publicKey?.removePrefix("0x")?.lowercase()
itemPubKey == backupPubKey
}?.let {
BackupViewMnemonicActivity.launch(this@BackupDetailActivity, it.data)
} ?: run {
Expand All @@ -75,7 +78,10 @@ class BackupDetailActivity : BaseActivity(), OnMapReadyCallback, OnTransactionSt
binding.btnRecoveryPhrase.setProgressVisible(false)
val data = intent?.getParcelableArrayListExtra<BackupItem>(com.flowfoundation.wallet.manager.dropbox.EXTRA_CONTENT) ?: return
data.firstOrNull {
it.publicKey == backupKey?.info?.pubKey?.publicKey
// Normalize public keys for comparison
val itemPubKey = it.publicKey?.removePrefix("0x")?.lowercase()
val backupPubKey = backupKey?.info?.pubKey?.publicKey?.removePrefix("0x")?.lowercase()
itemPubKey == backupPubKey
}?.let {
BackupViewMnemonicActivity.launch(this@BackupDetailActivity, it.data)
} ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ class WalletBackupViewModel : ViewModel(), OnTransactionStateChange {
}

if (matchingKey != null) {
// Normalize public keys for comparison
val infoPubKey = info.pubKey.publicKey.removePrefix("0x").lowercase()
val currentKeyNormalized = currentKey?.removePrefix("0x")?.lowercase()

BackupKey(
matchingKey.index.toInt(),
info,
isRevoking = false,
isCurrentKey = info.pubKey.publicKey == currentKey
isCurrentKey = infoPubKey == currentKeyNormalized
)
} else {
logd(TAG, " ❌ NO MATCH - skipping this backup key")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ class DevicesViewModel : ViewModel() {
val deviceKey = keyDeviceList.lastOrNull { it.device?.id == device.id }
if (deviceKey != null) {
val unRevokedDevice = keys.firstOrNull {
it.publicKey ==
deviceKey.pubKey.publicKey && it.revoked.not()
// Normalize public keys for comparison
val onChainPubKey = it.publicKey.removePrefix("0x").lowercase()
val devicePubKey = deviceKey.pubKey.publicKey.removePrefix("0x").lowercase()
onChainPubKey == devicePubKey && it.revoked.not()
}
if (unRevokedDevice != null) {
val currentKey = CryptoProviderManager.getCurrentCryptoProvider()?.getPublicKey()
val keyId = if (unRevokedDevice.publicKey == currentKey) null else unRevokedDevice.index
// Normalize public keys for comparison
val unRevokedPubKey = unRevokedDevice.publicKey.removePrefix("0x").lowercase()
val currentKeyNormalized = currentKey?.removePrefix("0x")?.lowercase()
val keyId = if (unRevokedPubKey == currentKeyNormalized) null else unRevokedDevice.index
if (keyId != null) {
deviceList.add(
DeviceKeyModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ class AccountKeyViewModel : ViewModel(), OnTransactionStateChange {
val keyDeviceInfo = response.data.result ?: emptyList()
uiScope {
keyList.forEach { accountKey ->
keyDeviceInfo.find { it.pubKey.publicKey == accountKey.publicKey.publicKey }
?.let {
accountKey.deviceName = it.backupInfo?.name.takeIf { name -> !name.isNullOrEmpty() } ?: it.device?.device_name ?: ""
accountKey.deviceType = it.device?.device_type ?: -1
accountKey.backupType = it.backupInfo?.type ?: -1
}
keyDeviceInfo.find { deviceInfo ->
// Normalize public keys for comparison
val devicePubKey = deviceInfo.pubKey.publicKey.removePrefix("0x").lowercase()
val accountPubKey = accountKey.publicKey.publicKey.removePrefix("0x").lowercase()
devicePubKey == accountPubKey
}?.let {
accountKey.deviceName = it.backupInfo?.name.takeIf { name -> !name.isNullOrEmpty() } ?: it.device?.device_name ?: ""
accountKey.deviceType = it.device?.device_type ?: -1
accountKey.backupType = it.backupInfo?.type ?: -1
}
}
keyListLiveData.value = keyList
}
Expand Down
Loading
Loading