Skip to content

Commit 129d54a

Browse files
committed
feat(ocp): add server-side bill customization and social links for tokens
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent b0f8480 commit 129d54a

17 files changed

Lines changed: 253 additions & 197 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="18dp"
3+
android:height="18dp"
4+
android:viewportWidth="18"
5+
android:viewportHeight="18">
6+
<group>
7+
<clip-path
8+
android:pathData="M0,0h17.244v17.632h-17.244z"/>
9+
<path
10+
android:pathData="M1.882,8.32C6.311,6.391 9.264,5.119 10.74,4.504C14.96,2.749 15.836,2.445 16.408,2.434C16.534,2.432 16.814,2.463 16.996,2.611C17.148,2.736 17.191,2.904 17.212,3.023C17.231,3.141 17.257,3.41 17.236,3.62C17.008,6.022 16.019,11.851 15.515,14.542C15.304,15.68 14.884,16.061 14.478,16.099C13.595,16.18 12.926,15.516 12.071,14.956C10.735,14.079 9.98,13.534 8.682,12.679C7.182,11.691 8.155,11.147 9.01,10.259C9.233,10.027 13.121,6.492 13.194,6.171C13.204,6.131 13.213,5.982 13.123,5.903C13.035,5.824 12.905,5.851 12.81,5.872C12.674,5.903 10.541,7.314 6.401,10.107C5.796,10.523 5.248,10.726 4.754,10.716C4.213,10.704 3.169,10.409 2.392,10.157C1.443,9.848 0.686,9.684 0.752,9.159C0.786,8.885 1.163,8.606 1.882,8.32Z"
11+
android:strokeAlpha="0.4"
12+
android:fillColor="#ffffff"
13+
android:fillAlpha="0.4"/>
14+
</group>
15+
</vector>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="18dp"
3+
android:height="18dp"
4+
android:viewportWidth="18"
5+
android:viewportHeight="18">
6+
<path
7+
android:pathData="M8.622,15.268C12.293,15.268 15.268,12.293 15.268,8.622C15.268,4.951 12.293,1.976 8.622,1.976M8.622,15.268C4.951,15.268 1.976,12.293 1.976,8.622C1.976,4.951 4.951,1.976 8.622,1.976M8.622,15.268C6.936,15.268 5.568,12.293 5.568,8.622C5.568,4.951 6.936,1.976 8.622,1.976M8.622,15.268C10.309,15.268 11.676,12.293 11.676,8.622C11.676,4.951 10.309,1.976 8.622,1.976M15.089,8.622H2.156"
8+
android:strokeAlpha="0.5"
9+
android:strokeWidth="1.07776"
10+
android:fillColor="#00000000"
11+
android:strokeColor="#ffffff"
12+
android:fillAlpha="0.5"
13+
android:strokeLineCap="square"/>
14+
</vector>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="18dp"
3+
android:height="18dp"
4+
android:viewportWidth="18"
5+
android:viewportHeight="18">
6+
<path
7+
android:pathData="M9.881,7.776L14.809,2.047H13.642L9.363,7.021L5.945,2.047H2.003L7.171,9.569L2.003,15.576H3.171L7.69,10.323L11.299,15.576H15.241L9.881,7.776H9.881ZM8.282,9.635L7.758,8.886L3.592,2.927H5.386L8.748,7.736L9.272,8.485L13.642,14.736H11.848L8.282,9.635V9.635Z"
8+
android:strokeAlpha="0.4"
9+
android:fillColor="#ffffff"
10+
android:fillAlpha="0.4"/>
11+
</vector>

apps/flipcash/core/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,4 +415,6 @@
415415
<string name="label_sellAmount">Sell Amount</string>
416416
<string name="label_percentFee">%1$d Fee</string>
417417

418+
<string name="label_social_website">Website</string>
419+
<string name="label_social_x">\@%1$s</string>
418420
</resources>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.flipcash.app.tokens.internal.components.info
2+
3+
import androidx.compose.foundation.Image
4+
import androidx.compose.foundation.background
5+
import androidx.compose.foundation.layout.Arrangement
6+
import androidx.compose.foundation.layout.Row
7+
import androidx.compose.foundation.layout.padding
8+
import androidx.compose.material.Text
9+
import androidx.compose.runtime.Composable
10+
import androidx.compose.ui.Alignment
11+
import androidx.compose.ui.Modifier
12+
import androidx.compose.ui.draw.clip
13+
import androidx.compose.ui.graphics.Color
14+
import androidx.compose.ui.graphics.ColorFilter
15+
import androidx.compose.ui.platform.LocalUriHandler
16+
import androidx.compose.ui.res.painterResource
17+
import androidx.compose.ui.res.stringResource
18+
import com.flipcash.features.tokens.R
19+
import com.getcode.opencode.model.financial.SocialLink
20+
import com.getcode.theme.CodeTheme
21+
import com.getcode.theme.White50
22+
import com.getcode.theme.extraSmall
23+
import com.getcode.ui.core.rememberedClickable
24+
25+
@Composable
26+
internal fun SocialChip(
27+
socialLink: SocialLink,
28+
modifier: Modifier = Modifier,
29+
) {
30+
val uriHandler = LocalUriHandler.current
31+
32+
Row(
33+
modifier = modifier
34+
.background(CodeTheme.colors.surfaceVariant, CodeTheme.shapes.extraSmall)
35+
.clip(CodeTheme.shapes.extraSmall)
36+
.rememberedClickable {
37+
uriHandler.openUri(socialLink.uri)
38+
}.padding(
39+
horizontal = CodeTheme.dimens.grid.x3,
40+
vertical = CodeTheme.dimens.grid.x2,
41+
),
42+
horizontalArrangement = Arrangement.spacedBy(CodeTheme.dimens.grid.x2),
43+
verticalAlignment = Alignment.CenterVertically,
44+
) {
45+
Image(
46+
painter = painterResource(
47+
when (socialLink) {
48+
is SocialLink.Website -> R.drawable.ic_social_web
49+
is SocialLink.X -> R.drawable.ic_social_x
50+
}
51+
),
52+
contentDescription = null,
53+
colorFilter = ColorFilter.tint(CodeTheme.colors.textSecondary)
54+
)
55+
56+
Text(
57+
text = when (socialLink) {
58+
is SocialLink.Website -> stringResource(R.string.label_social_website)
59+
is SocialLink.X -> stringResource(R.string.label_social_x, socialLink.username)
60+
},
61+
color = CodeTheme.colors.textMain,
62+
style = CodeTheme.typography.textMedium
63+
)
64+
}
65+
}

apps/flipcash/features/tokens/src/main/kotlin/com/flipcash/app/tokens/internal/components/info/TokenDetails.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.flipcash.app.tokens.internal.components.info
22

3-
import androidx.compose.foundation.background
43
import androidx.compose.foundation.layout.Arrangement
5-
import androidx.compose.foundation.layout.Box
64
import androidx.compose.foundation.layout.Column
75
import androidx.compose.foundation.layout.PaddingValues
86
import androidx.compose.foundation.layout.Row
97
import androidx.compose.foundation.layout.fillMaxWidth
108
import androidx.compose.foundation.layout.padding
119
import androidx.compose.foundation.layout.size
10+
import androidx.compose.foundation.lazy.LazyRow
11+
import androidx.compose.foundation.lazy.items
1212
import androidx.compose.material.Divider
1313
import androidx.compose.material.Icon
1414
import androidx.compose.material.Text
@@ -89,6 +89,20 @@ internal fun TokenDetailsSection(
8989
dispatch(TokenInfoViewModel.Event.ExpandDescription(!state.descriptionExpanded))
9090
}
9191

92+
state.token?.socialLinks?.let { links ->
93+
LazyRow(
94+
modifier = Modifier
95+
.fillMaxWidth()
96+
.padding(top = CodeTheme.dimens.grid.x4),
97+
horizontalArrangement = Arrangement.spacedBy(CodeTheme.dimens.grid.x2),
98+
contentPadding = PaddingValues(horizontal = CodeTheme.dimens.inset)
99+
) {
100+
items(links) { link ->
101+
SocialChip(link)
102+
}
103+
}
104+
}
105+
92106
Divider(
93107
modifier = Modifier.padding(
94108
horizontal = CodeTheme.dimens.inset,

definitions/opencode/protos/src/main/proto/currency/v1/currency_service.proto

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,13 @@ import "common/v1/model.proto";
77

88
import "google/protobuf/timestamp.proto";
99
service Currency {
10-
// GetAllRates returns the exchange rates for the core mint token against all
11-
// available currencies
12-
//
13-
// Deprecated: Use StreamLiveMintData instead
14-
rpc GetAllRates(GetAllRatesRequest) returns (GetAllRatesResponse);
1510
// GetMints gets mint account metadata by address
1611
rpc GetMints(GetMintsRequest) returns (GetMintsResponse);
1712
// GetHistoricalMintData returns historical market data for a mint
1813
rpc GetHistoricalMintData(GetHistoricalMintDataRequest) returns (GetHistoricalMintDataResponse);
1914
// StreamLiveMintData streams live mint data for a set of mints
2015
rpc StreamLiveMintData(stream StreamLiveMintDataRequest) returns (stream StreamLiveMintDataResponse);
2116
}
22-
message GetAllRatesRequest {
23-
// If timestamp is included, the returned rate will be the most recent available
24-
// exchange rate prior to the provided timestamp within the same day. Otherwise,
25-
// the latest rates will be returned.
26-
google.protobuf.Timestamp timestamp = 1;
27-
}
28-
message GetAllRatesResponse {
29-
Result result = 1;
30-
enum Result {
31-
OK = 0;
32-
// No currency data is available for the requested timestamp.
33-
MISSING_DATA = 1;
34-
}
35-
// The time the exchange rates were observed
36-
google.protobuf.Timestamp as_of = 2;
37-
// The price of 1 core mint token in different currencies, keyed on 3- or 4-
38-
// letter lowercase currency code.
39-
map<string, double> rates = 3 ;
40-
}
4117
message GetMintsRequest {
4218
repeated common.v1.SolanaAccountId addresses = 1 ;
4319
}
@@ -123,6 +99,10 @@ message Mint {
12399
LaunchpadMetadata launchpad_metadata = 8;
124100
// Timestamp the currency was created
125101
google.protobuf.Timestamp created_at = 9;
102+
// Social links for this currency
103+
repeated SocialLink social_links = 10 ;
104+
// Bill customization for this currency. Use the default if not provided
105+
BillCustomization bill_customization = 11;
126106
}
127107
message VmMetadata {
128108
// VM address
@@ -154,6 +134,10 @@ message LaunchpadMetadata {
154134
uint64 supply_from_bonding = 7;
155135
// Precent fee for sells in basis points, currently hardcoded to 1%
156136
uint32 sell_fee_bps = 8;
137+
// The current price in USD
138+
double price = 9;
139+
// The current market capitalization in USD
140+
double market_cap = 10;
157141
}
158142
message HistoricalMintData {
159143
// Timestamp for this data point
@@ -193,3 +177,23 @@ message VerifiedLaunchpadCurrencyReserveState {
193177
message VerifiedLaunchapdCurrencyReserveStateBatch {
194178
repeated VerifiedLaunchpadCurrencyReserveState reserve_states = 2 ;
195179
}
180+
message SocialLink {
181+
oneof type {
182+
Website website = 1;
183+
X x = 2;
184+
}
185+
message Website {
186+
string url = 1 ;
187+
}
188+
message X {
189+
string username = 1 ;
190+
}
191+
}
192+
message BillCustomization {
193+
// Bill background colors (from top to bottom)
194+
repeated Color colors = 1 ;
195+
}
196+
message Color {
197+
// Hex colour value (e.g. "#19191A")
198+
string hex = 1 ;
199+
}

libs/encryption/keys/src/main/kotlin/com/getcode/solana/keys/Mint.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,29 @@ class Mint(bytes: List<Byte>): PublicKey(bytes) {
1818
val usdf: Mint
1919
get() = Mint("5AMAA9JV9H97YYVxx8F6FsCMmTwXSuTTQneiup4RYAUQ")
2020

21+
private val jeffy: Mint
22+
get() = Mint("54ggcQ23uen5b9QXMAns99MQNTKn7iyzq4wvCW6e8r25")
23+
24+
private val bogey: Mint
25+
get() = Mint("3AhBb1fpDTp1F9hPkZjRPDejXBM9S5vfpVdvn66vLYnT")
26+
27+
private val marketCoin: Mint
28+
get() = Mint("311m6Sb1814PfAxkEcqq6MNdBiVZLr8VWuAWDSC72euW")
29+
30+
private val xp: Mint
31+
get() = Mint("6oZnhB1FPrUaDfhRCVZnbVWNKVx9wgj84vKGH7eMpzXL")
32+
33+
private val float: Mint
34+
get() = Mint("5APqK9YUZupKt7rRUrpYy6WV3RPuxA71ZtKJffDUMdPP")
35+
36+
private val bits: Mint
37+
get() = Mint("A3e8dzb1y4gqGP2cnCS3UU8dm5YNrFpZBpjjdoZdtfnB")
38+
39+
private val badboys: Mint
40+
get() = Mint("64dkhPKhdjc2xg3NLyDjC14wiXHLnGXHHUxJnqZVugJt")
41+
42+
private val sandbox: Mint
43+
get() = Mint("2psDP3LAvbNzfvBYNMs9ieMpsD8PVzyQsKNfZrjEKoDN")
44+
2145
}
2246
}

services/opencode/src/main/kotlin/com/getcode/opencode/RepositoryFactory.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package com.getcode.opencode
22

33
import android.content.Context
44
import com.getcode.opencode.inject.OpenCodeModule
5+
import com.getcode.opencode.internal.domain.mapping.BillCustomizationMapper
56
import com.getcode.opencode.internal.domain.mapping.HistoricalMintDataMapper
67
import com.getcode.opencode.internal.domain.mapping.LaunchpadMetadataMapper
78
import com.getcode.opencode.internal.domain.mapping.LiveMintDataMapper
89
import com.getcode.opencode.internal.domain.mapping.MintMapper
10+
import com.getcode.opencode.internal.domain.mapping.SocialLinkMapper
911
import com.getcode.opencode.internal.domain.mapping.SwapMetadataMapper
1012
import com.getcode.opencode.internal.domain.mapping.TransactionMetadataMapper
1113
import com.getcode.opencode.internal.domain.mapping.VmMetadataMapper
@@ -139,6 +141,8 @@ object RepositoryFactory {
139141
val mintMapper = MintMapper(
140142
vmMetadataMapper = VmMetadataMapper(),
141143
launchpadMetadataMapper = LaunchpadMetadataMapper(),
144+
socialLinkMapper = SocialLinkMapper(),
145+
customizationMapper = BillCustomizationMapper(),
142146
)
143147
val historicalMintDataMapper = HistoricalMintDataMapper()
144148
val liveMintDataMapper = LiveMintDataMapper()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.getcode.opencode.internal.domain.mapping
2+
3+
import com.codeinc.opencode.gen.currency.v1.CurrencyService
4+
import com.getcode.opencode.mapper.Mapper
5+
import com.getcode.opencode.model.ui.BillBackground
6+
import com.getcode.opencode.model.ui.TokenBillCustomizations
7+
import javax.inject.Inject
8+
9+
internal class BillCustomizationMapper @Inject constructor(): Mapper<CurrencyService.BillCustomization?, TokenBillCustomizations?> {
10+
override fun map(from: CurrencyService.BillCustomization?): TokenBillCustomizations? {
11+
if (from == null) return null
12+
val colors = from.colorsList.map { it.hex }
13+
return TokenBillCustomizations(
14+
background = BillBackground.Gradient(colors),
15+
texture = null,
16+
icon = null,
17+
)
18+
}
19+
}

0 commit comments

Comments
 (0)