From b3f8b06feaa05856a163db7ede8530c41bda9b60 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sun, 23 Apr 2023 16:10:20 -0400 Subject: [PATCH] formatting improvements --- .../vitorpamplona/amethyst/model/Account.kt | 2 -- .../NostrLnZapPaymentResponseDataSource.kt | 4 ++-- .../service/model/LnZapPaymentRequestEvent.kt | 12 ++-------- .../model/LnZapPaymentResponseEvent.kt | 23 ++++--------------- .../amethyst/service/relays/Client.kt | 9 ++++---- .../amethyst/service/relays/Relay.kt | 1 - .../ui/screen/loggedIn/AccountViewModel.kt | 2 +- .../ui/screen/loggedIn/ProfileScreen.kt | 1 - 8 files changed, 15 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index f548d9605..2ee90218b 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -4,13 +4,11 @@ import android.content.res.Resources import androidx.core.os.ConfigurationCompat import androidx.lifecycle.LiveData import com.vitorpamplona.amethyst.service.FileHeader -import com.vitorpamplona.amethyst.service.NostrAccountDataSource import com.vitorpamplona.amethyst.service.NostrLnZapPaymentResponseDataSource import com.vitorpamplona.amethyst.service.model.* import com.vitorpamplona.amethyst.service.relays.Client import com.vitorpamplona.amethyst.service.relays.Constants import com.vitorpamplona.amethyst.service.relays.FeedType -import com.vitorpamplona.amethyst.service.relays.JsonFilter import com.vitorpamplona.amethyst.service.relays.Relay import com.vitorpamplona.amethyst.service.relays.RelayPool import com.vitorpamplona.amethyst.ui.components.BundledUpdate diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrLnZapPaymentResponseDataSource.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrLnZapPaymentResponseDataSource.kt index faa301cce..57de8be6e 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/NostrLnZapPaymentResponseDataSource.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/NostrLnZapPaymentResponseDataSource.kt @@ -8,8 +8,8 @@ import com.vitorpamplona.amethyst.service.relays.TypedFilter class NostrLnZapPaymentResponseDataSource( private var fromServiceHex: String, private var toUserHex: String, - private var replyingToHex: String, -): NostrDataSource("LnZapPaymentResponseFeed") { + private var replyingToHex: String +) : NostrDataSource("LnZapPaymentResponseFeed") { val feedTypes = setOf(FeedType.WALLET_CONNECT) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/model/LnZapPaymentRequestEvent.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/model/LnZapPaymentRequestEvent.kt index e1d95ed87..ff21118f2 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/model/LnZapPaymentRequestEvent.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/model/LnZapPaymentRequestEvent.kt @@ -1,7 +1,6 @@ package com.vitorpamplona.amethyst.service.model import android.util.Log -import com.google.gson.annotations.SerializedName import com.vitorpamplona.amethyst.model.HexKey import com.vitorpamplona.amethyst.model.toByteArray import com.vitorpamplona.amethyst.model.toHexKey @@ -63,15 +62,8 @@ class LnZapPaymentRequestEvent( abstract class Request(val method: String, val params: Params) abstract class Params - // PayInvoice Call -class PayInvoiceMethod(bolt11: String): Request("pay_invoice", PayInvoiceParams(bolt11)) { - class PayInvoiceParams(val invoice: String): Params() +class PayInvoiceMethod(bolt11: String) : Request("pay_invoice", PayInvoiceParams(bolt11)) { + class PayInvoiceParams(val invoice: String) : Params() } - - - - - - diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/model/LnZapPaymentResponseEvent.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/model/LnZapPaymentResponseEvent.kt index 1b6889878..83718d310 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/model/LnZapPaymentResponseEvent.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/model/LnZapPaymentResponseEvent.kt @@ -2,12 +2,7 @@ package com.vitorpamplona.amethyst.service.model import android.util.Log import com.google.gson.annotations.SerializedName -import com.google.gson.reflect.TypeToken import com.vitorpamplona.amethyst.model.HexKey -import com.vitorpamplona.amethyst.model.toByteArray -import com.vitorpamplona.amethyst.model.toHexKey -import nostr.postr.Utils -import java.util.Date class LnZapPaymentResponseEvent( id: HexKey, @@ -45,15 +40,13 @@ abstract class Response( // PayInvoice Call -class PayInvoiceSuccessResponse(val result: PayInvoiceResultParams): - Response("pay_invoice") -{ +class PayInvoiceSuccessResponse(val result: PayInvoiceResultParams) : + Response("pay_invoice") { class PayInvoiceResultParams(val preimage: String) } -class PayInvoiceErrorResponse(val error: PayInvoiceErrorParams? = null): - Response("pay_invoice") -{ +class PayInvoiceErrorResponse(val error: PayInvoiceErrorParams? = null) : + Response("pay_invoice") { class PayInvoiceErrorParams(val code: ErrorType?, val message: String?) enum class ErrorType { @@ -72,12 +65,6 @@ class PayInvoiceErrorResponse(val error: PayInvoiceErrorParams? = null): @SerializedName(value = "internal", alternate = ["INTERNAL"]) INTERNAL, // An internal error. @SerializedName(value = "other", alternate = ["OTHER"]) - OTHER, // Other error. + OTHER // Other error. } } - - - - - - diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Client.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Client.kt index ddcc98db1..c3af984c3 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Client.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Client.kt @@ -1,6 +1,5 @@ package com.vitorpamplona.amethyst.service.relays -import com.vitorpamplona.amethyst.service.NostrDataSource import com.vitorpamplona.amethyst.service.model.Event import com.vitorpamplona.amethyst.service.model.EventInterface import kotlinx.coroutines.DelicateCoroutinesApi @@ -8,7 +7,6 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext import java.util.UUID /** @@ -79,7 +77,9 @@ object Client : RelayPool.Listener { } } else { /** temporary connection */ - newSporadicRelay(relay, feedTypes, + newSporadicRelay( + relay, + feedTypes, onConnected = { relay -> relay.send(signedEvent) }, @@ -102,8 +102,9 @@ object Client : RelayPool.Listener { relay.disconnect() RelayPool.removeRelay(relay) - if (onDone != null) + if (onDone != null) { onDone() + } } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Relay.kt b/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Relay.kt index 279c1bbf0..ca785f8fc 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Relay.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/service/relays/Relay.kt @@ -3,7 +3,6 @@ package com.vitorpamplona.amethyst.service.relays import android.util.Log import com.google.gson.JsonElement import com.vitorpamplona.amethyst.BuildConfig -import com.vitorpamplona.amethyst.service.NostrAccountDataSource import com.vitorpamplona.amethyst.service.model.Event import com.vitorpamplona.amethyst.service.model.EventInterface import com.vitorpamplona.amethyst.service.model.LnZapPaymentResponseEvent diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 6f3a89df8..5a2ac2cbd 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -95,7 +95,7 @@ class AccountViewModel(private val account: Account) : ViewModel() { } else { // awaits for confirmation from Receiver or timeout. } - }, + } ) onProgress(0.8f) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt index 040063733..91c6f7b4a 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt @@ -60,7 +60,6 @@ import com.vitorpamplona.amethyst.service.NostrUserProfileDataSource import com.vitorpamplona.amethyst.service.model.BadgeDefinitionEvent import com.vitorpamplona.amethyst.service.model.BadgeProfilesEvent import com.vitorpamplona.amethyst.service.model.IdentityClaim -import com.vitorpamplona.amethyst.service.model.LnZapPaymentResponseEvent import com.vitorpamplona.amethyst.service.model.PayInvoiceErrorResponse import com.vitorpamplona.amethyst.service.model.PayInvoiceSuccessResponse import com.vitorpamplona.amethyst.service.model.ReportEvent