Skip to content

Commit 395639c

Browse files
committed
chore(protos): update flipcash and opencode protobuf definitions
- Fetch latest protos for both targets - Rename opencode proto files (account/currency/messaging/transaction_service → ocp_*) - Migrate all service layer references from *Service to Ocp*Service - Update flipcash domain models for activity feed renames (GaveCrypto → DirectlySentCrypto, SentCrypto → IndirectlySentCrypto) - Add new MessageContent.Cash variant with serialization support - Add NavigationTrigger.Chat for push notification navigation - Fix proto field rename is_remote_send → is_indirect_send
1 parent 170c442 commit 395639c

82 files changed

Lines changed: 722 additions & 594 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/flipcash/core/src/main/kotlin/com/flipcash/app/core/feed/ActivityFeedMessage.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ data class ActivityFeedMessage(
2828
get() {
2929
metadata ?: return false
3030
val metadata =
31-
(metadata as? MessageMetadata.SentCrypto) ?: return false
31+
(metadata as? MessageMetadata.IndirectlySentCrypto) ?: return false
3232
return metadata.canCancel
3333
}
3434
}
@@ -53,16 +53,20 @@ sealed interface MessageMetadata {
5353
data object Unknown : MessageMetadata
5454

5555
@Serializable
56-
data object GaveCrypto : MessageMetadata
56+
data class DirectlySentCrypto(
57+
val phoneNumber: String? = null,
58+
) : MessageMetadata
5759

5860
@Serializable
59-
data class SentCrypto(
61+
data class IndirectlySentCrypto(
6062
val creator: PublicKey,
6163
val canCancel: Boolean,
6264
) : MessageMetadata
6365

6466
@Serializable
65-
data object ReceivedCrypto : MessageMetadata
67+
data class ReceivedCrypto(
68+
val phoneNumber: String? = null,
69+
) : MessageMetadata
6670

6771
@Serializable
6872
data object WithdrewCrypto : MessageMetadata

apps/flipcash/core/src/test/kotlin/com/flipcash/app/core/feed/ActivityFeedMessageTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ class ActivityFeedMessageTest {
5858
}
5959

6060
@Test
61-
fun metadataFromGaveCrypto() {
62-
val json = """{"type":"com.flipcash.app.core.feed.MessageMetadata.GaveCrypto"}"""
61+
fun metadataFromDirectlySentCrypto() {
62+
val json = """{"type":"com.flipcash.app.core.feed.MessageMetadata.DirectlySentCrypto"}"""
6363
val result = MessageMetadata.from(json)
64-
assertEquals(MessageMetadata.GaveCrypto, result)
64+
assertEquals(MessageMetadata.DirectlySentCrypto(), result)
6565
}
6666

6767
@Test

apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/screens/components/MessageBubble.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ internal fun ContentBubble(
4040
isFromSelf = item.isFromSelf,
4141
position = position,
4242
)
43+
is MessageContent.Cash -> Unit // TODO
4344
}
4445
}
4546
}

apps/flipcash/features/transactions/src/main/kotlin/com/flipcash/app/transactions/internal/TransactionHistoryViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class TransactionHistoryViewModel @Inject constructor(
7676
.filterIsInstance<Event.OnCancelRequested>()
7777
.map { it.message }
7878
.onEach { message ->
79-
val metadata = message.metadata as? MessageMetadata.SentCrypto ?: return@onEach
79+
val metadata = message.metadata as? MessageMetadata.IndirectlySentCrypto ?: return@onEach
8080
val formattedAmount = message.amount?.formatted()
8181
val title = formattedAmount?.let {
8282
resources.getString(R.string.prompt_title_cancelTransferWithAmount, it)

apps/flipcash/features/transactions/src/main/kotlin/com/flipcash/app/transactions/internal/components/FeedItem.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private val sampleItem = ActivityFeedMessage(
100100
amount = oneDollarLocalized,
101101
timestamp = Instant.parse("2025-06-03T16:25:00-04:00"),
102102
state = MessageState.COMPLETED,
103-
metadata = MessageMetadata.GaveCrypto
103+
metadata = MessageMetadata.DirectlySentCrypto()
104104
)
105105

106106
private val sampleItemWithToken = ActivityFeedMessageWithToken(

apps/flipcash/shared/persistence/db/src/main/kotlin/com/flipcash/app/persistence/converters/ChatTypeConverters.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ sealed interface MessageContentSerialized {
7272
@Serializable
7373
@SerialName("text")
7474
data class Text(val text: String) : MessageContentSerialized
75+
76+
@Serializable
77+
@SerialName("cash")
78+
data class Cash(val intentId: String, val quarks: Long) : MessageContentSerialized
7579
}
7680

7781
@Serializable

apps/flipcash/shared/persistence/sources/src/main/kotlin/com/flipcash/app/persistence/sources/mapper/chat/ChatEntityMapper.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import com.flipcash.services.models.chat.MessagePointer
2020
import com.flipcash.services.models.chat.PointerType
2121
import com.flipcash.services.models.chat.ClientMessageId
2222
import com.getcode.opencode.model.core.ID
23+
import com.getcode.opencode.model.financial.Fiat
24+
import com.getcode.utils.base58
25+
import com.getcode.utils.base64
26+
import com.getcode.utils.decodeBase58
27+
import com.getcode.utils.decodeBase64
2328
import com.getcode.utils.hexEncodedString
2429
import javax.inject.Inject
2530
import javax.inject.Singleton
@@ -163,10 +168,18 @@ class ChatEntityMapper @Inject constructor() {
163168

164169
private fun MessageContent.toSerialized(): MessageContentSerialized = when (this) {
165170
is MessageContent.Text -> MessageContentSerialized.Text(text)
171+
is MessageContent.Cash -> MessageContentSerialized.Cash(
172+
intentId = intentId.base58,
173+
quarks = amount.quarks,
174+
)
166175
}
167176

168177
private fun MessageContentSerialized.toDomain(): MessageContent = when (this) {
169178
is MessageContentSerialized.Text -> MessageContent.Text(text)
179+
is MessageContentSerialized.Cash -> MessageContent.Cash(
180+
intentId = intentId.decodeBase58().toList(),
181+
amount = Fiat(quarks = quarks),
182+
)
170183
}
171184

172185
private fun MessagePointer.toSerialized(): MessagePointerSerialized = MessagePointerSerialized(

apps/flipcash/shared/persistence/sources/src/main/kotlin/com/flipcash/app/persistence/sources/mapper/notifications/NotificationToEntityMapper.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ class MetadataMapper @Inject constructor(): Mapper<NotificationMetadata?, Messag
5555
override fun map(from: NotificationMetadata?): MessageMetadata? {
5656
from ?: return null
5757
return when (from) {
58-
NotificationMetadata.GaveCrypto -> MessageMetadata.GaveCrypto
59-
NotificationMetadata.ReceivedCrypto -> MessageMetadata.ReceivedCrypto
60-
is NotificationMetadata.SentCrypto -> MessageMetadata.SentCrypto(from.creator, from.canCancel)
58+
is NotificationMetadata.DirectlySentCrypto -> MessageMetadata.DirectlySentCrypto(from.phoneNumber)
59+
is NotificationMetadata.ReceivedCrypto -> MessageMetadata.ReceivedCrypto(from.phoneNumber)
60+
is NotificationMetadata.IndirectlySentCrypto -> MessageMetadata.IndirectlySentCrypto(from.creator, from.canCancel)
6161
NotificationMetadata.Unknown -> MessageMetadata.Unknown
6262
NotificationMetadata.WithdrewCrypto -> MessageMetadata.WithdrewCrypto
6363
NotificationMetadata.DepositedCrypto -> MessageMetadata.DepositedCrypto

definitions/flipcash/protos/src/main/proto/activity/v1/model.proto

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ option java_package = "com.codeinc.flipcash.gen.activity.v1";
77
option objc_class_prefix = "FCPBActivityV1";
88

99
import "common/v1/common.proto";
10+
import "phone/v1/model.proto";
1011
import "google/protobuf/timestamp.proto";
1112
import "validate/validate.proto";
1213

@@ -40,29 +41,35 @@ message Notification {
4041

4142
// Additional metadata for this notification specific to the notification
4243
oneof additional_metadata {
43-
GaveCryptoNotificationMetadata gave_crypto = 7;
44-
ReceivedCryptoNotificationMetadata received_crypto = 8;
45-
WithdrewCryptoNotificationMetadata withdrew_crypto = 9;
46-
SentCryptoNotificationMetadata sent_crypto = 10;
47-
DepositedCryptoNotificationMetadata deposited_crypto = 11;
48-
BoughtCryptoNotificationMetadata bought_crypto = 12;
49-
SoldCryptoNotificationMetadata sold_crypto = 13;
44+
DirectlySentCryptoNotificationMetadata directly_sent_crypto = 7;
45+
ReceivedCryptoNotificationMetadata received_crypto = 8;
46+
WithdrewCryptoNotificationMetadata withdrew_crypto = 9;
47+
IndirectlySentCryptoNotificationMetadata indirectly_sent_crypto = 10;
48+
DepositedCryptoNotificationMetadata deposited_crypto = 11;
49+
BoughtCryptoNotificationMetadata bought_crypto = 12;
50+
SoldCryptoNotificationMetadata sold_crypto = 13;
5051
}
5152

5253
reserved 6; // Deprecated WelcomeBonusNotificationMetadata
5354
}
5455

55-
message GaveCryptoNotificationMetadata {
56+
message DirectlySentCryptoNotificationMetadata {
57+
oneof destination_identifier {
58+
phone.v1.PhoneNumber phone = 1;
59+
}
5660
}
5761

5862
message ReceivedCryptoNotificationMetadata {
63+
oneof source_identifier {
64+
phone.v1.PhoneNumber phone = 1;
65+
}
5966
}
6067

6168
message WithdrewCryptoNotificationMetadata {
6269
SwapState swap_state = 1 [(validate.rules).enum.not_in = 0];
6370
}
6471

65-
message SentCryptoNotificationMetadata {
72+
message IndirectlySentCryptoNotificationMetadata {
6673
// The vault of the gift card account that was created for the cash link
6774
common.v1.PublicKey vault = 1 [(validate.rules).message.required = true];
6875

definitions/flipcash/protos/src/main/proto/common/v1/common.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ message ChatId {
6565
}];
6666
}
6767

68+
message IntentId {
69+
bytes value = 1 [(validate.rules).bytes = {
70+
min_len: 32
71+
max_len: 32
72+
}];
73+
}
74+
6875
// AppInstallId is a unque ID tied to a client app installation. It does not
6976
// identify a device. Value should remain private and not be shared across
7077
// installs.

0 commit comments

Comments
 (0)