Skip to content

Commit c319e48

Browse files
add onboarding stories button (#153)
1 parent 4367854 commit c319e48

41 files changed

Lines changed: 785 additions & 213 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/wallet/api/src/main/java/com/tonapps/wallet/api/API.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.tonapps.wallet.api
33
import android.content.Context
44
import android.net.Uri
55
import android.util.ArrayMap
6-
import android.util.Log
76
import com.squareup.moshi.JsonAdapter
87
import com.tonapps.blockchain.ton.contract.BaseWalletContract
98
import com.tonapps.blockchain.ton.contract.WalletVersion
@@ -39,7 +38,6 @@ import io.batteryapi.apis.BatteryApi.UnitsGetBalance
3938
import io.batteryapi.models.Balance
4039
import io.batteryapi.models.Config
4140
import io.batteryapi.models.RechargeMethods
42-
import io.tonapi.infrastructure.ClientError
4341
import io.tonapi.infrastructure.ClientException
4442
import io.tonapi.infrastructure.Serializer
4543
import io.tonapi.models.Account
@@ -92,6 +90,9 @@ class API(
9290
tonAPIHttpClient { config }
9391
}
9492

93+
private val bridgeUrl: String
94+
get() = "${config.tonConnectBridgeHost}/bridge"
95+
9596
@Volatile
9697
private var cachedCountry: String? = null
9798

@@ -508,7 +509,7 @@ class API(
508509
return emptyFlow()
509510
}
510511
val value = publicKeys.joinToString(",")
511-
val url = "${BRIDGE_URL}/events?client_id=$value"
512+
val url = "${bridgeUrl}/events?client_id=$value"
512513
return seeHttpClient.sse(url, lastEventId, onFailure).filter { it.type == "message" }
513514
}
514515

@@ -553,7 +554,7 @@ class API(
553554
body: String
554555
) {
555556
val mimeType = "text/plain".toMediaType()
556-
val url = "${BRIDGE_URL}/message?client_id=$publicKeyHex&to=$clientId&ttl=300"
557+
val url = "${bridgeUrl}/message?client_id=$publicKeyHex&to=$clientId&ttl=300"
557558
withRetry {
558559
tonAPIHttpClient.post(url, body.toRequestBody(mimeType))
559560
}
@@ -932,8 +933,4 @@ class API(
932933
}
933934
response.body?.string() ?: throw Exception("Empty response")
934935
}
935-
936-
companion object {
937-
const val BRIDGE_URL = "https://bridge.tonapi.io/bridge"
938-
}
939936
}

apps/wallet/api/src/main/java/com/tonapps/wallet/api/entity/ConfigEntity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ data class ConfigEntity(
1818
val mercuryoSecret: String,
1919
val tonapiMainnetHost: String,
2020
val tonapiTestnetHost: String,
21+
val tonConnectBridgeHost: String,
2122
val stonfiUrl: String,
2223
val tonNFTsMarketplaceEndpoint: String,
2324
val directSupportUrl: String,
@@ -70,7 +71,7 @@ data class ConfigEntity(
7071

7172
@IgnoredOnParcel
7273
val domains: List<String> by lazy {
73-
listOf(tonapiMainnetHost, tonapiTestnetHost, tonapiSSEEndpoint, tonapiSSETestnetEndpoint, "https://bridge.tonapi.io/", "https://tonapi.io/")
74+
listOf(tonapiMainnetHost, tonapiTestnetHost, tonapiSSEEndpoint, tonapiSSETestnetEndpoint, tonConnectBridgeHost, "https://tonapi.io/")
7475
}
7576

7677
@IgnoredOnParcel
@@ -88,6 +89,7 @@ data class ConfigEntity(
8889
mercuryoSecret = json.getString("mercuryoSecret"),
8990
tonapiMainnetHost = json.getString("tonapiMainnetHost"),
9091
tonapiTestnetHost = json.getString("tonapiTestnetHost"),
92+
tonConnectBridgeHost = json.optString("ton_connect_bridge", "https://bridge.tonapi.io"),
9193
stonfiUrl = json.getString("stonfiUrl"),
9294
tonNFTsMarketplaceEndpoint = json.getString("tonNFTsMarketplaceEndpoint"),
9395
directSupportUrl = json.getString("directSupportUrl"),
@@ -144,6 +146,7 @@ data class ConfigEntity(
144146
mercuryoSecret = "",
145147
tonapiMainnetHost = "https://keeper.tonapi.io",
146148
tonapiTestnetHost = "https://testnet.tonapi.io",
149+
tonConnectBridgeHost = "https://bridge.tonapi.io",
147150
stonfiUrl = "https://swap-widget.tonkeeper.com",
148151
tonNFTsMarketplaceEndpoint = "https://ton.diamonds",
149152
directSupportUrl = "https://t.me/tonkeeper_supportbot",

apps/wallet/data/battery/src/main/java/com/tonapps/wallet/data/battery/BatteryRepository.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,4 @@ class BatteryRepository(
171171
localDataSource.setAppliedPromo(testnet, promo)
172172
}
173173

174-
suspend fun getPreferGasless(
175-
testnet: Boolean,
176-
): Boolean = withContext(Dispatchers.IO) {
177-
localDataSource.getPreferGasless(testnet)
178-
}
179-
180-
suspend fun setPreferGasless(
181-
testnet: Boolean,
182-
value: Boolean,
183-
) = withContext(Dispatchers.IO) {
184-
localDataSource.setPreferGasless(testnet, value)
185-
}
186-
187174
}

apps/wallet/data/battery/src/main/java/com/tonapps/wallet/data/battery/source/LocalDataSource.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,6 @@ internal class LocalDataSource(
5858
}
5959
}
6060

61-
fun getPreferGasless(testnet: Boolean): Boolean {
62-
return prefs.getBoolean(gaslessKey(testnet), false)
63-
}
64-
65-
fun setPreferGasless(testnet: Boolean, value: Boolean) {
66-
prefs.edit {
67-
putBoolean(gaslessKey(testnet), value)
68-
}
69-
}
70-
71-
private fun gaslessKey(testnet: Boolean): String {
72-
return "prefer_gasless_${if (testnet) "testnet" else "mainnet"}"
73-
}
74-
7561
private fun promoKey(testnet: Boolean): String {
7662
return "promo_${if (testnet) "testnet" else "mainnet"}"
7763
}

apps/wallet/data/settings/src/main/java/com/tonapps/wallet/data/settings/SettingsRepository.kt

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.tonapps.wallet.data.core.Theme
1616
import com.tonapps.wallet.data.core.currency.WalletCurrency
1717
import com.tonapps.wallet.data.core.isAvailableBiometric
1818
import com.tonapps.wallet.data.rn.RNLegacy
19+
import com.tonapps.wallet.data.settings.entities.PreferredFeeMethod
1920
import com.tonapps.wallet.data.settings.entities.TokenPrefsEntity
2021
import com.tonapps.wallet.data.settings.folder.TokenPrefsFolder
2122
import com.tonapps.wallet.data.settings.folder.WalletPrefsFolder
@@ -66,25 +67,30 @@ class SettingsRepository(
6667
}
6768

6869
private val _currencyFlow = MutableEffectFlow<WalletCurrency>()
69-
val currencyFlow = _currencyFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull().distinctUntilChanged()
70+
val currencyFlow = _currencyFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
71+
.distinctUntilChanged()
7072

7173
private val _languageFlow = MutableEffectFlow<Language>()
7274
val languageFlow = _languageFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
7375

7476
private val _hiddenBalancesFlow = MutableEffectFlow<Boolean>()
75-
val hiddenBalancesFlow = _hiddenBalancesFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
77+
val hiddenBalancesFlow =
78+
_hiddenBalancesFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
7679

7780
private val _countryFlow = MutableEffectFlow<String>()
78-
val countryFlow = _countryFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull().map { fixCountryCode(it) }
81+
val countryFlow = _countryFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
82+
.map { fixCountryCode(it) }
7983

8084
private val _biometricFlow = MutableStateFlow<Boolean?>(null)
8185
val biometricFlow = _biometricFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
8286

8387
private val _lockscreenFlow = MutableStateFlow<Boolean?>(null)
84-
val lockscreenFlow = _lockscreenFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
88+
val lockscreenFlow =
89+
_lockscreenFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
8590

8691
private val _searchEngineFlow = MutableEffectFlow<SearchEngine>()
87-
val searchEngineFlow = _searchEngineFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
92+
val searchEngineFlow =
93+
_searchEngineFlow.stateIn(scope, SharingStarted.Eagerly, null).filterNotNull()
8894

8995
private val _walletPush = MutableEffectFlow<Unit>()
9096
val walletPush = _walletPush.shareIn(scope, SharingStarted.Eagerly)
@@ -168,7 +174,8 @@ class SettingsRepository(
168174
}
169175
}
170176

171-
var currency: WalletCurrency = WalletCurrency.ofOrDefault(prefs.getString(CURRENCY_CODE_KEY, null))
177+
var currency: WalletCurrency =
178+
WalletCurrency.ofOrDefault(prefs.getString(CURRENCY_CODE_KEY, null))
172179
set(value) {
173180
if (field != value && value.code.isNotEmpty()) {
174181
prefs.putString(CURRENCY_CODE_KEY, value.code)
@@ -178,7 +185,8 @@ class SettingsRepository(
178185
}
179186
}
180187

181-
var language: Language = Language(prefs.getString(LANGUAGE_CODE_KEY, Language.DEFAULT) ?: Language.DEFAULT)
188+
var language: Language =
189+
Language(prefs.getString(LANGUAGE_CODE_KEY, Language.DEFAULT) ?: Language.DEFAULT)
182190
@SuppressLint("UseKtx")
183191
set(value) {
184192
if (value != field) {
@@ -209,7 +217,8 @@ class SettingsRepository(
209217
}
210218
}
211219

212-
var biometric: Boolean = if (isAvailableBiometric(context)) prefs.getBoolean(BIOMETRIC_KEY, false) else false
220+
var biometric: Boolean =
221+
if (isAvailableBiometric(context)) prefs.getBoolean(BIOMETRIC_KEY, false) else false
213222
set(value) {
214223
if (value != field) {
215224
prefs.putBoolean(BIOMETRIC_KEY, value)
@@ -270,7 +279,8 @@ class SettingsRepository(
270279
get() {
271280
if (theme.isSystem) {
272281
val uiMode = context.resources.configuration.uiMode
273-
val isDarkMode = uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
282+
val isDarkMode =
283+
uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
274284
return !isDarkMode
275285
} else {
276286
return theme.light
@@ -322,19 +332,26 @@ class SettingsRepository(
322332

323333
fun disableUSDTW5(walletId: String) = walletPrefsFolder.disableUSDTW5(walletId)
324334

325-
fun getSpamStateTransaction(walletId: String, id: String) = walletPrefsFolder.getSpamStateTransaction(walletId, id)
335+
fun getSpamStateTransaction(walletId: String, id: String) =
336+
walletPrefsFolder.getSpamStateTransaction(walletId, id)
326337

327-
fun setSpamStateTransaction(walletId: String, id: String, state: SpamTransactionState) = walletPrefsFolder.setSpamStateTransaction(walletId, id, state)
338+
fun setSpamStateTransaction(walletId: String, id: String, state: SpamTransactionState) =
339+
walletPrefsFolder.setSpamStateTransaction(walletId, id, state)
328340

329-
fun isSpamTransaction(walletId: String, id: String) = getSpamStateTransaction(walletId, id) == SpamTransactionState.SPAM
341+
fun isSpamTransaction(walletId: String, id: String) =
342+
getSpamStateTransaction(walletId, id) == SpamTransactionState.SPAM
330343

331-
fun isPurchaseOpenConfirm(walletId: String, id: String) = walletPrefsFolder.isPurchaseOpenConfirm(walletId, id)
344+
fun isPurchaseOpenConfirm(walletId: String, id: String) =
345+
walletPrefsFolder.isPurchaseOpenConfirm(walletId, id)
332346

333-
fun disablePurchaseOpenConfirm(walletId: String, id: String) = walletPrefsFolder.disablePurchaseOpenConfirm(walletId, id)
347+
fun disablePurchaseOpenConfirm(walletId: String, id: String) =
348+
walletPrefsFolder.disablePurchaseOpenConfirm(walletId, id)
334349

335-
fun isDAppOpenConfirm(walletId: String, appHost: String) = walletPrefsFolder.isDAppOpenConfirm(walletId, appHost)
350+
fun isDAppOpenConfirm(walletId: String, appHost: String) =
351+
walletPrefsFolder.isDAppOpenConfirm(walletId, appHost)
336352

337-
fun setDAppOpenConfirm(walletId: String, appHost: String, enabled: Boolean) = walletPrefsFolder.setDAppOpenConfirm(walletId, appHost, enabled)
353+
fun setDAppOpenConfirm(walletId: String, appHost: String, enabled: Boolean) =
354+
walletPrefsFolder.setDAppOpenConfirm(walletId, appHost, enabled)
338355

339356
fun getPushWallet(walletId: String): Boolean = walletPrefsFolder.isPushEnabled(walletId)
340357

@@ -451,6 +468,11 @@ class SettingsRepository(
451468
return !tokenPrefsFolder.getHidden(walletId, "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t")
452469
}
453470

471+
fun getPreferredFeeMethod(walletId: String) = walletPrefsFolder.getPreferredFeeMethod(walletId)
472+
473+
fun setPreferredFeeMethod(walletId: String, method: PreferredFeeMethod) =
474+
walletPrefsFolder.setPreferredFeeMethod(walletId, method)
475+
454476
suspend fun getTokenPrefs(
455477
walletId: String,
456478
tokenAddress: String,
@@ -544,11 +566,19 @@ class SettingsRepository(
544566

545567
val spamTransactions = rnLegacy.getSpamTransactions(walletId)
546568
for (transactionId in spamTransactions.spam) {
547-
walletPrefsFolder.setSpamStateTransaction(walletId, transactionId, SpamTransactionState.SPAM)
569+
walletPrefsFolder.setSpamStateTransaction(
570+
walletId,
571+
transactionId,
572+
SpamTransactionState.SPAM
573+
)
548574
}
549575

550576
for (transactionId in spamTransactions.nonSpam) {
551-
walletPrefsFolder.setSpamStateTransaction(walletId, transactionId, SpamTransactionState.NOT_SPAM)
577+
walletPrefsFolder.setSpamStateTransaction(
578+
walletId,
579+
transactionId,
580+
SpamTransactionState.NOT_SPAM
581+
)
552582
}
553583
}
554584
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.tonapps.wallet.data.settings.entities
2+
3+
enum class PreferredFeeMethod(val id: Int) {
4+
UNSPECIFIED(0),
5+
TON(1),
6+
GASLESS(2),
7+
BATTERY(3);
8+
9+
companion object {
10+
fun fromId(id: Int): PreferredFeeMethod {
11+
return values().find { it.id == id }
12+
?: throw IllegalArgumentException("Invalid PreferredFeeMethod id: $id")
13+
}
14+
}
15+
}

apps/wallet/data/settings/src/main/java/com/tonapps/wallet/data/settings/folder/WalletPrefsFolder.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.tonapps.wallet.data.settings.BatteryTransaction
77
import com.tonapps.wallet.data.settings.BatteryTransaction.Companion.toIntArray
88
import com.tonapps.wallet.data.settings.SettingsRepository
99
import com.tonapps.wallet.data.settings.SpamTransactionState
10+
import com.tonapps.wallet.data.settings.entities.PreferredFeeMethod
1011
import com.tonapps.wallet.data.settings.entities.WalletPrefsEntity
1112
import kotlinx.coroutines.CoroutineScope
1213

@@ -23,6 +24,7 @@ internal class WalletPrefsFolder(context: Context, scope: CoroutineScope): BaseS
2324
private const val BATTERY_TX_ENABLED_PREFIX = "batter_tx_enabled_"
2425
private const val USDT_W5_PREFIX = "usdt_w5_"
2526
private const val DAPP_CONFIRM_PREFIX = "dapp_confirm_"
27+
private const val PREFERRED_FEE_PREFIX = "preferred_fee_"
2628
}
2729

2830
fun isUSDTW5(walletId: String): Boolean {
@@ -126,6 +128,21 @@ internal class WalletPrefsFolder(context: Context, scope: CoroutineScope): BaseS
126128
}
127129
}
128130

131+
fun getPreferredFeeMethod(walletId: String): PreferredFeeMethod {
132+
val key = keyPreferredFeeMethod(walletId)
133+
val value = getInt(keyPreferredFeeMethod(walletId), PreferredFeeMethod.UNSPECIFIED.id)
134+
return PreferredFeeMethod.fromId(value)
135+
}
136+
137+
fun setPreferredFeeMethod(walletId: String, method: PreferredFeeMethod) {
138+
val key = keyPreferredFeeMethod(walletId)
139+
putInt(key, method.id)
140+
}
141+
142+
private fun keyPreferredFeeMethod(walletId: String): String {
143+
return key(PREFERRED_FEE_PREFIX, walletId)
144+
}
145+
129146
private fun keyBatteryTxEnabled(accountId: String): String {
130147
return key(BATTERY_TX_ENABLED_PREFIX, accountId)
131148
}

apps/wallet/instance/app/src/main/java/com/tonapps/tonkeeper/RemoteConfig.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ class RemoteConfig(context: Context) {
1818
IS_COUNTRY_PICKER_DISABLE("isCountryPickerDisable"),
1919
IS_TRON_DISABLED("isTronDisabled"),
2020
NATIVE_ONRAMP_ENABLED("native_onrmap_enabled"),
21-
ETHENA_ENABLED("ethena_enabled");
21+
ETHENA_ENABLED("ethena_enabled"),
22+
ONBOARDING_STORIES_ENABLED("onboarding_stories_enabled");
2223
}
2324

2425
init {
@@ -32,7 +33,8 @@ class RemoteConfig(context: Context) {
3233
FeatureFlag.IS_STAKING_DISABLE.key to true,
3334
FeatureFlag.IS_DAPPS_DISABLE.key to true,
3435
FeatureFlag.DISABLE_BATTERY_CRYPTO_RECHARGE_MODULE.key to true,
35-
FeatureFlag.IS_TRON_DISABLED.key to false
36+
FeatureFlag.IS_TRON_DISABLED.key to false,
37+
FeatureFlag.ONBOARDING_STORIES_ENABLED.key to true
3638
)
3739

3840
remoteConfig.setDefaultsAsync(defaults)
@@ -77,4 +79,7 @@ class RemoteConfig(context: Context) {
7779

7880
val isEthenaEnabled: Boolean
7981
get() = remoteConfig.getBoolean(FeatureFlag.ETHENA_ENABLED.key)
82+
83+
val isOnboardingStoriesEnabled: Boolean
84+
get() = remoteConfig.getBoolean(FeatureFlag.ONBOARDING_STORIES_ENABLED.key)
8085
}

0 commit comments

Comments
 (0)