Skip to content

Commit

Permalink
bug fixeds
Browse files Browse the repository at this point in the history
  • Loading branch information
polstianka committed Oct 19, 2024
1 parent f67e194 commit 0e7b099
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 31 deletions.
12 changes: 8 additions & 4 deletions apps/wallet/api/src/main/java/com/tonapps/wallet/api/API.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@ class API(

val config: ConfigEntity
get() {
while (configRepository.configEntity == null) {
Thread.sleep(16)
}
return configRepository.configEntity!!
val timeout = System.currentTimeMillis() + 2000
do {
if (configRepository.configEntity != null) {
return configRepository.configEntity!!
}
Thread.sleep(50)
} while (System.currentTimeMillis() < timeout)
return ConfigEntity.default
}

val configFlow: Flow<ConfigEntity>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class AccountRepository(

private val scope = CoroutineScope(Dispatchers.IO + SupervisorJob())
private val database = DatabaseSource(context, scope)
private val storageSource = StorageSource(context)
private val vaultSource = VaultSource(context)
private val storageSource: StorageSource by lazy { StorageSource(context) }
private val vaultSource: VaultSource by lazy { VaultSource(context) }
private val migrationHelper = RNMigrationHelper(rnLegacy)

private val _selectedStateFlow = MutableStateFlow<SelectedState>(SelectedState.Initialization)
Expand All @@ -82,8 +82,8 @@ class AccountRepository(
init {
scope.launch(Dispatchers.IO) {
if (rnLegacy.isRequestMainMigration()) {
database.clearAccounts()
storageSource.clear()
// database.clearAccounts()
// storageSource.clear()
migrationFromRN()
rnLegacy.setWalletMigrated()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tonapps.wallet.data.account.source

import android.content.Context
import android.content.SharedPreferences
import androidx.core.content.edit
import com.tonapps.blockchain.ton.extensions.hex
import com.tonapps.extensions.prefs
Expand All @@ -19,7 +20,7 @@ internal class StorageSource(context: Context) {
}

private val prefs = context.prefs(NAME)
private val encryptedPrefs = Security.pref(context, KEY_ALIAS, NAME)
private val encryptedPrefs: SharedPreferences by lazy { Security.pref(context, KEY_ALIAS, NAME) }

fun getTonProofToken(publicKey: PublicKeyEd25519): String? {
val key = tonProofTokenKey(publicKey)
Expand Down
3 changes: 3 additions & 0 deletions apps/wallet/data/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ android {
}

dependencies {
api(platform(Dependence.Firebase.bom))
api(Dependence.Firebase.crashlytics)

implementation(Dependence.ton)
implementation(Dependence.Koin.core)
implementation(Dependence.AndroidX.biometric)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.tonapps.wallet.data.core

import android.content.Context
import androidx.biometric.BiometricManager
import com.google.firebase.crashlytics.FirebaseCrashlytics

fun accountId(accountId: String, testnet: Boolean): String {
if (testnet) {
Expand All @@ -17,3 +18,7 @@ fun isAvailableBiometric(
val authStatus = BiometricManager.from(context).canAuthenticate(authenticators)
return authStatus == BiometricManager.BIOMETRIC_SUCCESS
}

fun recordException(e: Throwable) {
FirebaseCrashlytics.getInstance().recordException(e)
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ data class RawMessageEntity(

@IgnoredOnParcel
val payload: Cell by lazy {
payloadValue.safeParseCell() ?: Cell()
payloadValue.parseCell()
}

constructor(json: JSONObject) : this(
Expand Down
1 change: 1 addition & 0 deletions apps/wallet/data/dapps/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ android {
dependencies {
implementation(Dependence.ton)
implementation(project(Dependence.Wallet.api))
implementation(project(Dependence.Wallet.Data.core))
implementation(project(Dependence.Wallet.Data.rn))
implementation(project(Dependence.Lib.blockchain))
implementation(project(Dependence.Lib.extensions))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.tonapps.blockchain.ton.extensions.toUserFriendly
import com.tonapps.extensions.map
import com.tonapps.extensions.withoutQuery
import com.tonapps.wallet.api.API
import com.tonapps.wallet.data.core.recordException
import com.tonapps.wallet.data.dapps.entities.AppConnectEntity
import com.tonapps.wallet.data.dapps.entities.AppEntity
import com.tonapps.wallet.data.dapps.entities.AppPushEntity
Expand Down Expand Up @@ -58,7 +59,6 @@ class DAppsRepository(
init {
scope.launch(Dispatchers.IO) {
if (rnLegacy.isRequestMigration()) {
database.clearConnections()
migrationFromLegacy()
}

Expand All @@ -77,6 +77,10 @@ class DAppsRepository(
}

suspend fun getPushes(tonProof: String, accountId: String): List<AppPushEntity> {
if (true) {
return emptyList()
}

val pushes = api.getPushFromApps(tonProof, accountId).map { AppPushEntity.Body(it) }
if (pushes.isEmpty()) {
return emptyList()
Expand Down Expand Up @@ -239,7 +243,9 @@ class DAppsRepository(
for (apps in tcApps.testnet) {
migrationFromLegacy(apps, true)
}
} catch (ignored: Throwable) { }
} catch (e: Throwable) {
recordException(e)
}
}

private suspend fun migrationFromLegacy(connections: RNTCApps, testnet: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ private fun RawMessageEntity.rebuildJettonTransferWithCustomPayload(
)
}


fun RawMessageEntity.getWalletTransfer(
excessesAddress: AddrStd? = null,
newStateInit: StateInit? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object BrowserHelper {
.setShowTitle(true)
.setTranslateLocale(activity.locale)
.setBookmarksButtonEnabled(false)
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)
.setShareState(CustomTabsIntent.SHARE_STATE_ON)
.setShareIdentityEnabled(false)
.setDownloadButtonEnabled(false)
.setCloseButtonPosition(CustomTabsIntent.CLOSE_BUTTON_POSITION_END)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ class EventsScreen(wallet: WalletEntity) : MainScreen.Child(R.layout.fragment_ma
}

override fun getTopBarDrawable(): BarDrawable? {
if (this::headerDrawable.isInitialized) {
/*if (this::headerDrawable.isInitialized) {
return headerDrawable
}*/
if (this::headerView.isInitialized) {
return headerView.background as BarDrawable
}
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ class MainScreen: BaseWalletScreen<ScreenContext.None>(R.layout.fragment_main, S
navigation?.add(PickerScreen.newInstance())
}
}
collectFlow(viewModel.childBottomScrolled, bottomTabsView::setDivider)
collectFlow(viewModel.childBottomScrolled) {
if (bottomTabsView.selectedItemId == R.id.browser) {
bottomTabsView.setDivider(false)
} else {
bottomTabsView.setDivider(it)
}
}

rootViewModel.eventFlow.filterIsInstance<RootEvent.OpenTab>().onEach {
val itemId = mainDeepLinks[it.link] ?: return@onEach
Expand Down Expand Up @@ -198,9 +204,18 @@ class MainScreen: BaseWalletScreen<ScreenContext.None>(R.layout.fragment_main, S
} else {
transaction.add(R.id.child_fragment, fragment)
}
transaction.runOnCommit {
checkBottomDivider(fragment)
}
transaction.commitNow()
}

private fun checkBottomDivider(fragment: Fragment) {
if (fragment is BrowserMainScreen) {
bottomTabsView.setDivider(false)
}
}

override fun onResume() {
super.onResume()
window?.setBackgroundDrawable(requireContext().constantBlackColor.drawable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SendContactsScreen(wallet: WalletEntity): WalletContextScreen(R.layout.fra
super.onViewCreated(view, savedInstanceState)
headerView = view.findViewById(R.id.header)
headerView.title = getString(Localization.contacts)
headerView.doOnActionClick = { finish() }

listView = view.findViewById(R.id.list)
listView.adapter = adapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class SendContactsViewModel(
uiItems.add(Item.Space)
}

if (savedContacts.isNotEmpty()) {
/*if (savedContacts.isNotEmpty()) {
uiItems.addAll(savedContacts)
uiItems.add(Item.Space)
}
}*/

if (latestContacts.isNotEmpty()) {
uiItems.addAll(latestContacts)
Expand Down Expand Up @@ -135,7 +135,7 @@ class SendContactsViewModel(
val recipients = actions.filter { it.isOutTransfer(wallet) }.mapNotNull { it.recipient }
return recipients.filter {
!it.address.equalsAddress(wallet.address) && !it.isWallet && !contactsRepository.isHidden(it.address.toRawAddress(), wallet.testnet)
}.distinctBy { it.address }
}.distinctBy { it.address }.take(6)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class LatestHolder(

init {
emojiView.setEmoji("\uD83D\uDD57")
iconView.setImageResource(R.drawable.ic_ellipsis_16)
// iconView.setImageResource(R.drawable.ic_ellipsis_16)
}

override fun onBind(item: Item.LatestContact) {
itemView.setOnClickListener { onClick(item) }
itemView.background = item.position.drawable(context)

nameView.text = item.name
iconView.setOnClickListener { showMenu(item) }
// iconView.setOnClickListener { showMenu(item) }
}

private fun showMenu(item: Item.LatestContact) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<FrameLayout
android:id="@+id/search_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="80dp"
android:layout_gravity="bottom"
android:paddingHorizontal="@dimen/offsetMedium"
android:paddingTop="@dimen/offsetMedium"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingHorizontal="@dimen/offsetMedium"
android:topOffset="112dp"
android:clipToPadding="false"/>

<!--android:topOffset="112dp" -->

</com.tonapps.tonkeeper.ui.component.MainSwipeRefreshLayout>

<uikit.widget.EmptyLayout
Expand All @@ -37,12 +38,13 @@
<uikit.widget.HeaderView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/filters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:paddingBottom="16dp"
android:paddingHorizontal="@dimen/offsetMedium"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:ignoreSystemOffset="true"/>
app:ignoreSystemOffset="true"
android:action="@drawable/ic_close_16"/>

<uikit.widget.SimpleRecyclerView
android:id="@+id/list"
Expand All @@ -18,7 +19,7 @@
android:layout_marginTop="@dimen/barHeight"
android:clipToPadding="false"
android:paddingHorizontal="@dimen/offsetMedium"
android:paddingBottom="@dimen/offsetMedium"/>
android:paddingBottom="72dp"/>

<Button
style="@style/Widget.App.Button"
Expand All @@ -27,6 +28,7 @@
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="16dp"
android:visibility="gone"
android:textAppearance="@style/TextAppearance.Label1"
android:text="@string/add_contact"/>

Expand Down
1 change: 1 addition & 0 deletions apps/wallet/instance/main/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@

-keep class com.tonapps.tonkeeper.manager.** { *; }


Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.tonapps.blockchain.ton
import com.tonapps.blockchain.ton.extensions.storeMaybeRef
import com.tonapps.blockchain.ton.extensions.storeOpCode
import com.tonapps.blockchain.ton.extensions.storeQueryId
import com.tonapps.blockchain.ton.extensions.storeStringTail
import org.ton.block.AddrStd
import org.ton.block.Coins
import org.ton.block.MsgAddressInt
Expand All @@ -26,7 +27,7 @@ object TonTransferHelper {

return buildCell {
storeUInt(0, 32)
storeBytes(text.toByteArray())
storeStringTail(text)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,10 @@ abstract class BaseWalletContract(
val init = Maybe.of(gift.stateInit?.let {
Either.of<StateInit, CellRef<StateInit>>(it, null)
})
val body = if (gift.body == null) {
Either.of<Cell, CellRef<Cell>>(Cell.empty(), null)
} else {
Either.of<Cell, CellRef<Cell>>(null, CellRef(gift.body!!))
}

val body = gift.body?.let {
Either.of<Cell, CellRef<Cell>>(null, CellRef(it))
} ?: Either.of<Cell, CellRef<Cell>>(Cell.empty(), null)

return MessageRelaxed(
info = info,
Expand Down
3 changes: 3 additions & 0 deletions lib/security/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-keep class com.tonapps.security.Sodium {
*;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ object KeyHelper {
private fun generateKey(parameter: KeyGenParameterSpec) {
val generator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, ANDROID_KEYSTORE)
generator.init(parameter)
generator.generateKey()
}

private fun keyExists(alias: String): Boolean {
Expand Down

0 comments on commit 0e7b099

Please sign in to comment.