formatting improvements

This commit is contained in:
Vitor Pamplona
2023-04-23 16:10:20 -04:00
parent ed4c19ac79
commit b3f8b06fea
8 changed files with 15 additions and 39 deletions
@@ -4,13 +4,11 @@ import android.content.res.Resources
import androidx.core.os.ConfigurationCompat import androidx.core.os.ConfigurationCompat
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import com.vitorpamplona.amethyst.service.FileHeader import com.vitorpamplona.amethyst.service.FileHeader
import com.vitorpamplona.amethyst.service.NostrAccountDataSource
import com.vitorpamplona.amethyst.service.NostrLnZapPaymentResponseDataSource import com.vitorpamplona.amethyst.service.NostrLnZapPaymentResponseDataSource
import com.vitorpamplona.amethyst.service.model.* import com.vitorpamplona.amethyst.service.model.*
import com.vitorpamplona.amethyst.service.relays.Client import com.vitorpamplona.amethyst.service.relays.Client
import com.vitorpamplona.amethyst.service.relays.Constants import com.vitorpamplona.amethyst.service.relays.Constants
import com.vitorpamplona.amethyst.service.relays.FeedType 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.Relay
import com.vitorpamplona.amethyst.service.relays.RelayPool import com.vitorpamplona.amethyst.service.relays.RelayPool
import com.vitorpamplona.amethyst.ui.components.BundledUpdate import com.vitorpamplona.amethyst.ui.components.BundledUpdate
@@ -8,8 +8,8 @@ import com.vitorpamplona.amethyst.service.relays.TypedFilter
class NostrLnZapPaymentResponseDataSource( class NostrLnZapPaymentResponseDataSource(
private var fromServiceHex: String, private var fromServiceHex: String,
private var toUserHex: String, private var toUserHex: String,
private var replyingToHex: String, private var replyingToHex: String
): NostrDataSource("LnZapPaymentResponseFeed") { ) : NostrDataSource("LnZapPaymentResponseFeed") {
val feedTypes = setOf(FeedType.WALLET_CONNECT) val feedTypes = setOf(FeedType.WALLET_CONNECT)
@@ -1,7 +1,6 @@
package com.vitorpamplona.amethyst.service.model package com.vitorpamplona.amethyst.service.model
import android.util.Log import android.util.Log
import com.google.gson.annotations.SerializedName
import com.vitorpamplona.amethyst.model.HexKey import com.vitorpamplona.amethyst.model.HexKey
import com.vitorpamplona.amethyst.model.toByteArray import com.vitorpamplona.amethyst.model.toByteArray
import com.vitorpamplona.amethyst.model.toHexKey import com.vitorpamplona.amethyst.model.toHexKey
@@ -63,15 +62,8 @@ class LnZapPaymentRequestEvent(
abstract class Request(val method: String, val params: Params) abstract class Request(val method: String, val params: Params)
abstract class Params abstract class Params
// PayInvoice Call // PayInvoice Call
class PayInvoiceMethod(bolt11: String): Request("pay_invoice", PayInvoiceParams(bolt11)) { class PayInvoiceMethod(bolt11: String) : Request("pay_invoice", PayInvoiceParams(bolt11)) {
class PayInvoiceParams(val invoice: String): Params() class PayInvoiceParams(val invoice: String) : Params()
} }
@@ -2,12 +2,7 @@ package com.vitorpamplona.amethyst.service.model
import android.util.Log import android.util.Log
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName
import com.google.gson.reflect.TypeToken
import com.vitorpamplona.amethyst.model.HexKey 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( class LnZapPaymentResponseEvent(
id: HexKey, id: HexKey,
@@ -45,15 +40,13 @@ abstract class Response(
// PayInvoice Call // PayInvoice Call
class PayInvoiceSuccessResponse(val result: PayInvoiceResultParams): class PayInvoiceSuccessResponse(val result: PayInvoiceResultParams) :
Response("pay_invoice") Response("pay_invoice") {
{
class PayInvoiceResultParams(val preimage: String) class PayInvoiceResultParams(val preimage: String)
} }
class PayInvoiceErrorResponse(val error: PayInvoiceErrorParams? = null): class PayInvoiceErrorResponse(val error: PayInvoiceErrorParams? = null) :
Response("pay_invoice") Response("pay_invoice") {
{
class PayInvoiceErrorParams(val code: ErrorType?, val message: String?) class PayInvoiceErrorParams(val code: ErrorType?, val message: String?)
enum class ErrorType { enum class ErrorType {
@@ -72,12 +65,6 @@ class PayInvoiceErrorResponse(val error: PayInvoiceErrorParams? = null):
@SerializedName(value = "internal", alternate = ["INTERNAL"]) @SerializedName(value = "internal", alternate = ["INTERNAL"])
INTERNAL, // An internal error. INTERNAL, // An internal error.
@SerializedName(value = "other", alternate = ["OTHER"]) @SerializedName(value = "other", alternate = ["OTHER"])
OTHER, // Other error. OTHER // Other error.
} }
} }
@@ -1,6 +1,5 @@
package com.vitorpamplona.amethyst.service.relays 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.Event
import com.vitorpamplona.amethyst.service.model.EventInterface import com.vitorpamplona.amethyst.service.model.EventInterface
import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.DelicateCoroutinesApi
@@ -8,7 +7,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.UUID import java.util.UUID
/** /**
@@ -79,7 +77,9 @@ object Client : RelayPool.Listener {
} }
} else { } else {
/** temporary connection */ /** temporary connection */
newSporadicRelay(relay, feedTypes, newSporadicRelay(
relay,
feedTypes,
onConnected = { relay -> onConnected = { relay ->
relay.send(signedEvent) relay.send(signedEvent)
}, },
@@ -102,8 +102,9 @@ object Client : RelayPool.Listener {
relay.disconnect() relay.disconnect()
RelayPool.removeRelay(relay) RelayPool.removeRelay(relay)
if (onDone != null) if (onDone != null) {
onDone() onDone()
}
} }
} }
} }
@@ -3,7 +3,6 @@ package com.vitorpamplona.amethyst.service.relays
import android.util.Log import android.util.Log
import com.google.gson.JsonElement import com.google.gson.JsonElement
import com.vitorpamplona.amethyst.BuildConfig import com.vitorpamplona.amethyst.BuildConfig
import com.vitorpamplona.amethyst.service.NostrAccountDataSource
import com.vitorpamplona.amethyst.service.model.Event import com.vitorpamplona.amethyst.service.model.Event
import com.vitorpamplona.amethyst.service.model.EventInterface import com.vitorpamplona.amethyst.service.model.EventInterface
import com.vitorpamplona.amethyst.service.model.LnZapPaymentResponseEvent import com.vitorpamplona.amethyst.service.model.LnZapPaymentResponseEvent
@@ -95,7 +95,7 @@ class AccountViewModel(private val account: Account) : ViewModel() {
} else { } else {
// awaits for confirmation from Receiver or timeout. // awaits for confirmation from Receiver or timeout.
} }
}, }
) )
onProgress(0.8f) onProgress(0.8f)
@@ -60,7 +60,6 @@ import com.vitorpamplona.amethyst.service.NostrUserProfileDataSource
import com.vitorpamplona.amethyst.service.model.BadgeDefinitionEvent import com.vitorpamplona.amethyst.service.model.BadgeDefinitionEvent
import com.vitorpamplona.amethyst.service.model.BadgeProfilesEvent import com.vitorpamplona.amethyst.service.model.BadgeProfilesEvent
import com.vitorpamplona.amethyst.service.model.IdentityClaim 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.PayInvoiceErrorResponse
import com.vitorpamplona.amethyst.service.model.PayInvoiceSuccessResponse import com.vitorpamplona.amethyst.service.model.PayInvoiceSuccessResponse
import com.vitorpamplona.amethyst.service.model.ReportEvent import com.vitorpamplona.amethyst.service.model.ReportEvent