Skip to content

Commit 5099e29

Browse files
committed
remove the saved wallet stuff from the demo
1 parent 58ce184 commit 5099e29

File tree

3 files changed

+1
-42
lines changed

3 files changed

+1
-42
lines changed

example/src/main/java/org/xmtp/android/example/connect/ConnectWalletFragment.kt

-7
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ class ConnectWalletFragment : Fragment() {
6060
viewModel.generateWallet()
6161
}
6262

63-
binding.savedWalletButton.setOnClickListener {
64-
viewModel.savedWallet()
65-
}
66-
6763
val isConnectWalletAvailable = isConnectAvailable()
6864
binding.connectButton.isEnabled = isConnectWalletAvailable
6965
binding.connectError.isVisible = !isConnectWalletAvailable
@@ -119,7 +115,6 @@ class ConnectWalletFragment : Fragment() {
119115
private fun showError(message: String) {
120116
binding.progress.visibility = View.GONE
121117
binding.generateButton.visibility = View.VISIBLE
122-
binding.savedWalletButton.visibility = View.VISIBLE
123118
binding.connectButton.visibility = View.VISIBLE
124119
binding.connectError.isVisible = !isConnectAvailable()
125120
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
@@ -130,8 +125,6 @@ class ConnectWalletFragment : Fragment() {
130125
binding.generateButton.visibility = View.GONE
131126
binding.connectButton.visibility = View.GONE
132127
binding.connectError.visibility = View.GONE
133-
binding.savedWalletButton.visibility = View.GONE
134-
135128
}
136129

137130
override fun onDestroyView() {

example/src/main/java/org/xmtp/android/example/connect/ConnectWalletViewModel.kt

-23
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package org.xmtp.android.example.connect
22

33
import android.app.Application
4-
import android.content.Context
54
import android.net.Uri
65
import androidx.annotation.UiThread
76
import androidx.lifecycle.AndroidViewModel
8-
import androidx.lifecycle.ViewModel
97
import androidx.lifecycle.viewModelScope
108
import com.walletconnect.wcmodal.client.Modal
119
import kotlinx.coroutines.Dispatchers
@@ -17,7 +15,6 @@ import kotlinx.coroutines.flow.launchIn
1715
import kotlinx.coroutines.flow.onEach
1816
import kotlinx.coroutines.flow.update
1917
import kotlinx.coroutines.launch
20-
import org.web3j.utils.Numeric
2118
import org.xmtp.android.example.ClientManager
2219
import org.xmtp.android.example.account.WalletConnectV2Account
2320
import org.xmtp.android.library.Client
@@ -99,26 +96,6 @@ class ConnectWalletViewModel(application: Application) : AndroidViewModel(applic
9996
}
10097
}
10198

102-
@UiThread
103-
fun savedWallet() {
104-
viewModelScope.launch(Dispatchers.IO) {
105-
_uiState.value = ConnectUiState.Loading
106-
try {
107-
val privateKeyData = Numeric.hexStringToByteArray("0x2429cd5b39334e854cb26dfe2037293cd1ccc980e366a35fa6a09cdbef070bda")
108-
// Use hardcoded privateKey
109-
val privateKey = PrivateKeyBuilder.buildFromPrivateKeyData(privateKeyData)
110-
val wallet = PrivateKeyBuilder(privateKey)
111-
val client = Client().create(wallet, ClientManager.clientOptions(getApplication()))
112-
_uiState.value = ConnectUiState.Success(
113-
wallet.address,
114-
PrivateKeyBundleV1Builder.encodeData(client.privateKeyBundleV1)
115-
)
116-
} catch (e: XMTPException) {
117-
_uiState.value = ConnectUiState.Error(e.message.orEmpty())
118-
}
119-
}
120-
}
121-
12299
@UiThread
123100
fun connectWallet(approvedSession: Modal.Model.ApprovedSession) {
124101
viewModelScope.launch(Dispatchers.IO) {

example/src/main/res/layout/fragment_connect_wallet.xml

+1-12
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@
2828
app:layout_constraintStart_toStartOf="parent"
2929
app:layout_constraintTop_toTopOf="parent" />
3030

31-
<androidx.appcompat.widget.AppCompatButton
32-
android:id="@+id/savedWalletButton"
33-
android:layout_width="0dp"
34-
android:layout_height="wrap_content"
35-
android:layout_margin="@dimen/padding"
36-
android:text="Saved Wallet"
37-
app:layout_constraintBottom_toTopOf="@id/connectButton"
38-
app:layout_constraintEnd_toEndOf="parent"
39-
app:layout_constraintStart_toStartOf="parent"
40-
app:layout_constraintTop_toBottomOf="@id/generateButton" />
41-
4231
<com.google.android.material.button.MaterialButton
4332
android:id="@+id/connectButton"
4433
android:layout_width="match_parent"
@@ -54,7 +43,7 @@
5443
android:layout_marginEnd="@dimen/padding"
5544
app:layout_constraintEnd_toEndOf="parent"
5645
app:layout_constraintStart_toStartOf="parent"
57-
app:layout_constraintTop_toBottomOf="@id/savedWalletButton" />
46+
app:layout_constraintTop_toBottomOf="@id/generateButton" />
5847

5948
<TextView
6049
android:id="@+id/connectError"

0 commit comments

Comments
 (0)