diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 73dc7f5..c01d068 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -16,8 +16,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
- android:theme="@style/AppTheme">
-
+ android:theme="@style/Theme.AppCompat.Light.NoActionBar">
@@ -32,12 +31,19 @@
+ android:label="@string/app_name"
+ android:launchMode="singleTask"
+ android:alwaysRetainTaskState="true">
-
+
+
+
+
+
+
Unit = this::nop
private var signAction: (RecoverableSignature) -> Unit = this::nop
+ var currentAccount: String? = null
+ private set(value) {
+ field = value
+ wcListener.onAccountChanged(value)
+ }
override fun onStatus(status: Session.Status) {
- when (status) {
- is Session.Status.Error -> println("WalletConnect Error")
- is Session.Status.Approved -> println("WalletConnect Approved")
- is Session.Status.Connected -> println("WalletConnect Connected")
- is Session.Status.Disconnected -> println("WalletConnect Disconnected")
- is Session.Status.Closed -> session = null
+ when(status) {
+ Session.Status.Approved, Session.Status.Connected -> wcListener.onConnected()
+ is Session.Status.Error, Session.Status.Disconnected, Session.Status.Closed -> { wcListener.onDisconnected(); session = null; currentAccount = null }
}
}
override fun onMethodCall(call: Session.MethodCall) {
scope.launch(Dispatchers.IO) {
when (call) {
- is Session.MethodCall.SessionRequest -> Registry.scriptExecutor.runScript(scriptWithAuthentication().plus(ExportKeyCommand(Registry.walletConnect, bip32Path)))
+ is Session.MethodCall.SessionRequest -> getAccountKeys()
is Session.MethodCall.SignMessage -> signText(call.id, call.message)
is Session.MethodCall.SendTransaction -> signTransaction(call.id, toTransaction(call), true)
is Session.MethodCall.Custom -> onCustomCall(call)
@@ -77,6 +77,10 @@ class WalletConnect(var bip32Path: String, var chainID: Long) : ExportKeyCommand
}
}
+ private fun getAccountKeys() {
+ Registry.scriptExecutor.runScript(scriptWithAuthentication().plus(ExportKeyCommand(Registry.walletConnect, bip32Path)))
+ }
+
private inline fun runOnValidParam(call: Session.MethodCall.Custom, index: Int, body: (T) -> Unit) {
val param = call.params?.getOrNull(index)
@@ -94,7 +98,7 @@ class WalletConnect(var bip32Path: String, var chainID: Long) : ExportKeyCommand
private fun onCustomCall(call: Session.MethodCall.Custom) {
when(call.method) {
"personal_sign" -> runOnValidParam(call, 0) { signText(call.id, it) }
- "eth_signTypedData" -> { runOnValidParam(call, 1) { @Suppress("UNCHECKED_CAST") signTypedData(call.id, it) } }
+ "eth_signTypedData" -> { runOnValidParam(call, 1) { signTypedData(call.id, it) } }
"eth_signTransaction" -> { runOnValidParam