Skip to content

Commit

Permalink
Remove MobileCoin payments
Browse files Browse the repository at this point in the history
  • Loading branch information
valldrac committed Dec 16, 2024
1 parent ab25f63 commit 5a8a330
Show file tree
Hide file tree
Showing 189 changed files with 41 additions and 14,908 deletions.
2 changes: 0 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ android {
"proguard/proguard-shortcutbadger.pro",
"proguard/proguard-retrofit.pro",
"proguard/proguard-klinker.pro",
"proguard/proguard-mobilecoin.pro",
"proguard/proguard-retrolambda.pro",
"proguard/proguard-okhttp.pro",
"proguard/proguard-ez-vcard.pro",
Expand Down Expand Up @@ -486,7 +485,6 @@ dependencies {
implementation(libs.conscrypt.android)
implementation(libs.signal.aesgcmprovider)
implementation(libs.libsignal.android)
implementation(libs.mobilecoin)
implementation(libs.molly.ringrtc)
implementation(libs.leolin.shortcutbadger)
implementation(libs.emilsjolander.stickylistheaders)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,6 @@ class V2ConversationItemShapeTest {

override fun onInviteToSignalClicked() = Unit

override fun onActivatePaymentsClicked() = Unit

override fun onSendPaymentClicked(recipientId: RecipientId) = Unit

override fun onScheduledIndicatorClicked(view: View, conversationMessage: ConversationMessage) = Unit

override fun onUrlClicked(url: String): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,6 @@ class InternalConversationTestFragment : Fragment(R.layout.conversation_test_fra
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}

override fun onActivatePaymentsClicked() {
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}

override fun onSendPaymentClicked(recipientId: RecipientId) {
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}

override fun onScheduledIndicatorClicked(view: View, conversationMessage: ConversationMessage) {
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}
Expand Down Expand Up @@ -300,10 +292,6 @@ class InternalConversationTestFragment : Fragment(R.layout.conversation_test_fra
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}

override fun onPaymentTombstoneClicked() {
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}

override fun onDisplayMediaNoLongerAvailableSheet() {
Toast.makeText(requireContext(), "Can't touch this.", Toast.LENGTH_SHORT).show()
}
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,6 @@
android:windowSoftInputMode="stateVisible|adjustResize"
android:exported="false"/>

<activity
android:name=".payments.preferences.PaymentsActivity"
android:theme="@style/TextSecure.LightRegistrationTheme"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:exported="false"/>

<activity
android:name=".lock.v2.CreateSvrPinActivity"
android:theme="@style/TextSecure.LightRegistrationTheme"
Expand Down Expand Up @@ -1223,10 +1217,6 @@
android:name=".service.TrimThreadsByDateManager$TrimThreadsByDateAlarm"
android:exported="false"/>

<receiver
android:name=".payments.backup.phrase.ClearClipboardAlarmReceiver"
android:exported="false"/>

<provider android:name=".providers.AvatarProvider"
android:authorities="${applicationId}.avatar"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ interface EventListener {
void onBlockJoinRequest(@NonNull Recipient recipient);
void onRecipientNameClicked(@NonNull RecipientId target);
void onInviteToSignalClicked();
void onActivatePaymentsClicked();
void onSendPaymentClicked(@NonNull RecipientId recipientId);
void onScheduledIndicatorClicked(@NonNull View view, @NonNull ConversationMessage conversationMessage);
/** @return true if handled, false if you want to let the normal url handling continue */
boolean onUrlClicked(@NonNull String url);
Expand All @@ -131,7 +129,6 @@ interface EventListener {
void onReportSpamLearnMoreClicked();
void onMessageRequestAcceptOptionsClicked();
void onItemDoubleClick(MultiselectPart multiselectPart);
void onPaymentTombstoneClicked();
void onDisplayMediaNoLongerAvailableSheet();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.util.Optional
import javax.annotation.meta.Exhaustive

/**
* Renders Avatar objects into Media objects. This can involve creating a Bitmap, depending on the
Expand All @@ -39,7 +38,6 @@ object AvatarRenderer {
}

fun renderAvatar(context: Context, avatar: Avatar, onAvatarRendered: (Media) -> Unit, onRenderFailed: (Throwable?) -> Unit) {
@Exhaustive
when (avatar) {
is Avatar.Resource -> renderResource(context, avatar, onAvatarRendered, onRenderFailed)
is Avatar.Vector -> renderVector(context, avatar, onAvatarRendered, onRenderFailed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import org.thoughtcrime.securesms.backup.v2.proto.GroupV2MigrationUpdate
import org.thoughtcrime.securesms.backup.v2.proto.IndividualCall
import org.thoughtcrime.securesms.backup.v2.proto.LearnedProfileChatUpdate
import org.thoughtcrime.securesms.backup.v2.proto.MessageAttachment
import org.thoughtcrime.securesms.backup.v2.proto.PaymentNotification
import org.thoughtcrime.securesms.backup.v2.proto.ProfileChangeChatUpdate
import org.thoughtcrime.securesms.backup.v2.proto.Quote
import org.thoughtcrime.securesms.backup.v2.proto.Reaction
Expand All @@ -58,7 +57,6 @@ import org.thoughtcrime.securesms.database.CallTable
import org.thoughtcrime.securesms.database.GroupReceiptTable
import org.thoughtcrime.securesms.database.MessageTable
import org.thoughtcrime.securesms.database.MessageTypes
import org.thoughtcrime.securesms.database.PaymentTable
import org.thoughtcrime.securesms.database.SignalDatabase
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchSet
import org.thoughtcrime.securesms.database.documents.NetworkFailureSet
Expand All @@ -76,8 +74,6 @@ import org.thoughtcrime.securesms.database.model.databaseprotos.ThreadMergeEvent
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.linkpreview.LinkPreview
import org.thoughtcrime.securesms.mms.QuoteModel
import org.thoughtcrime.securesms.payments.FailureReason
import org.thoughtcrime.securesms.payments.State
import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.util.JsonUtils
import org.thoughtcrime.securesms.util.MediaUtil
Expand Down Expand Up @@ -191,11 +187,11 @@ class ChatItemArchiveExporter(
}

MessageTypes.isPaymentsActivated(record.type) -> {
builder.updateMessage = simpleUpdate(SimpleChatUpdate.Type.PAYMENTS_ACTIVATED)
continue
}

MessageTypes.isPaymentsRequestToActivate(record.type) -> {
builder.updateMessage = simpleUpdate(SimpleChatUpdate.Type.PAYMENT_ACTIVATION_REQUEST)
continue
}

MessageTypes.isUnsupportedMessageType(record.type) -> {
Expand Down Expand Up @@ -259,7 +255,7 @@ class ChatItemArchiveExporter(
}

MessageTypes.isPaymentsNotification(record.type) -> {
builder.paymentNotification = record.toRemotePaymentNotificationUpdate(db)
builder.paymentNotification = null
}

MessageTypes.isGiftBadge(record.type) -> {
Expand Down Expand Up @@ -561,26 +557,6 @@ private fun CallTable.Call.toRemoteCallUpdate(db: SignalDatabase, messageRecord:
}
}

private fun BackupMessageRecord.toRemotePaymentNotificationUpdate(db: SignalDatabase): PaymentNotification {
val paymentUuid = UuidUtil.parseOrNull(this.body)
val payment = if (paymentUuid != null) {
db.paymentTable.getPayment(paymentUuid)
} else {
null
}

return if (payment == null) {
PaymentNotification()
} else {
PaymentNotification(
amountMob = payment.amount.serializeAmountString(),
feeMob = payment.fee.serializeAmountString(),
note = payment.note.takeUnless { it.isEmpty() },
transactionDetails = payment.toRemoteTransactionDetails()
)
}
}

private fun BackupMessageRecord.toRemoteSharedContacts(attachments: List<DatabaseAttachment>?): List<Contact> {
if (this.sharedContacts.isNullOrEmpty()) {
return emptyList()
Expand Down Expand Up @@ -890,47 +866,6 @@ private fun List<DatabaseAttachment>.toRemoteAttachments(mediaArchiveEnabled: Bo
}
}

private fun PaymentTable.PaymentTransaction.toRemoteTransactionDetails(): PaymentNotification.TransactionDetails {
if (this.failureReason != null || this.state == State.FAILED) {
return PaymentNotification.TransactionDetails(failedTransaction = PaymentNotification.TransactionDetails.FailedTransaction(reason = this.failureReason.toRemote()))
}

return PaymentNotification.TransactionDetails(
transaction = PaymentNotification.TransactionDetails.Transaction(
status = this.state.toRemote(),
timestamp = this.timestamp,
blockIndex = this.blockIndex,
blockTimestamp = this.blockTimestamp,
mobileCoinIdentification = this.paymentMetaData.mobileCoinTxoIdentification?.let {
PaymentNotification.TransactionDetails.MobileCoinTxoIdentification(
publicKey = it.publicKey.takeIf { this.direction.isReceived } ?: emptyList(),
keyImages = it.keyImages.takeIf { this.direction.isSent } ?: emptyList()
)
},
transaction = this.transaction?.toByteString(),
receipt = this.receipt?.toByteString()
)
)
}

private fun State.toRemote(): PaymentNotification.TransactionDetails.Transaction.Status {
return when (this) {
State.INITIAL -> PaymentNotification.TransactionDetails.Transaction.Status.INITIAL
State.SUBMITTED -> PaymentNotification.TransactionDetails.Transaction.Status.SUBMITTED
State.SUCCESSFUL -> PaymentNotification.TransactionDetails.Transaction.Status.SUCCESSFUL
State.FAILED -> throw IllegalArgumentException("state cannot be failed")
}
}

private fun FailureReason?.toRemote(): PaymentNotification.TransactionDetails.FailedTransaction.FailureReason {
return when (this) {
FailureReason.UNKNOWN -> PaymentNotification.TransactionDetails.FailedTransaction.FailureReason.GENERIC
FailureReason.INSUFFICIENT_FUNDS -> PaymentNotification.TransactionDetails.FailedTransaction.FailureReason.INSUFFICIENT_FUNDS
FailureReason.NETWORK -> PaymentNotification.TransactionDetails.FailedTransaction.FailureReason.NETWORK
else -> PaymentNotification.TransactionDetails.FailedTransaction.FailureReason.GENERIC
}
}

private fun List<Mention>.toRemoteBodyRanges(db: SignalDatabase): List<BackupBodyRange> {
return this.map {
BackupBodyRange(
Expand Down
Loading

0 comments on commit 5a8a330

Please sign in to comment.