Skip to content

Commit f8a177a

Browse files
committed
feat(ocp): update protos; add HolderMetrics to Token
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 3a7a118 commit f8a177a

35 files changed

Lines changed: 845 additions & 56 deletions

File tree

Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 14,
5+
"identityHash": "8341b10599a7b1c98f1faa3832d759b5",
6+
"entities": [
7+
{
8+
"tableName": "messages",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`idBase58` TEXT NOT NULL, `text` TEXT NOT NULL, `amountUsdc` INTEGER, `amountNative` INTEGER, `nativeCurrency` TEXT, `rate` REAL, `state` TEXT NOT NULL, `timestamp` INTEGER NOT NULL, `metadata` TEXT, `mintBase58` TEXT DEFAULT 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', PRIMARY KEY(`idBase58`))",
10+
"fields": [
11+
{
12+
"fieldPath": "idBase58",
13+
"columnName": "idBase58",
14+
"affinity": "TEXT",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "text",
19+
"columnName": "text",
20+
"affinity": "TEXT",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "amountUsdc",
25+
"columnName": "amountUsdc",
26+
"affinity": "INTEGER"
27+
},
28+
{
29+
"fieldPath": "amountNative",
30+
"columnName": "amountNative",
31+
"affinity": "INTEGER"
32+
},
33+
{
34+
"fieldPath": "nativeCurrency",
35+
"columnName": "nativeCurrency",
36+
"affinity": "TEXT"
37+
},
38+
{
39+
"fieldPath": "rate",
40+
"columnName": "rate",
41+
"affinity": "REAL"
42+
},
43+
{
44+
"fieldPath": "state",
45+
"columnName": "state",
46+
"affinity": "TEXT",
47+
"notNull": true
48+
},
49+
{
50+
"fieldPath": "timestamp",
51+
"columnName": "timestamp",
52+
"affinity": "INTEGER",
53+
"notNull": true
54+
},
55+
{
56+
"fieldPath": "metadata",
57+
"columnName": "metadata",
58+
"affinity": "TEXT"
59+
},
60+
{
61+
"fieldPath": "mintBase58",
62+
"columnName": "mintBase58",
63+
"affinity": "TEXT",
64+
"defaultValue": "'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'"
65+
}
66+
],
67+
"primaryKey": {
68+
"autoGenerate": false,
69+
"columnNames": [
70+
"idBase58"
71+
]
72+
}
73+
},
74+
{
75+
"tableName": "tokens",
76+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`address` TEXT NOT NULL, `decimals` INTEGER NOT NULL, `name` TEXT NOT NULL, `symbol` TEXT NOT NULL, `created_at` INTEGER, `description` TEXT NOT NULL, `image_url` TEXT NOT NULL, `social_links` TEXT, `bill_customizations` TEXT, `holder_metrics` TEXT, `vm_vm` TEXT NOT NULL, `vm_authority` TEXT NOT NULL, `vm_lock_duration_days` INTEGER NOT NULL, `lp_currency_config` TEXT, `lp_liquidity_pool` TEXT, `lp_seed` TEXT, `lp_authority` TEXT, `lp_mint_vault` TEXT, `lp_core_mint_vault` TEXT, `lp_circulating_supply_quarks` INTEGER, `lp_sell_fee_bps` INTEGER, `lp_price_amount_usd` REAL, `lp_market_cap_amount_usd` REAL, PRIMARY KEY(`address`))",
77+
"fields": [
78+
{
79+
"fieldPath": "address",
80+
"columnName": "address",
81+
"affinity": "TEXT",
82+
"notNull": true
83+
},
84+
{
85+
"fieldPath": "decimals",
86+
"columnName": "decimals",
87+
"affinity": "INTEGER",
88+
"notNull": true
89+
},
90+
{
91+
"fieldPath": "name",
92+
"columnName": "name",
93+
"affinity": "TEXT",
94+
"notNull": true
95+
},
96+
{
97+
"fieldPath": "symbol",
98+
"columnName": "symbol",
99+
"affinity": "TEXT",
100+
"notNull": true
101+
},
102+
{
103+
"fieldPath": "createdAt",
104+
"columnName": "created_at",
105+
"affinity": "INTEGER"
106+
},
107+
{
108+
"fieldPath": "description",
109+
"columnName": "description",
110+
"affinity": "TEXT",
111+
"notNull": true
112+
},
113+
{
114+
"fieldPath": "imageUrl",
115+
"columnName": "image_url",
116+
"affinity": "TEXT",
117+
"notNull": true
118+
},
119+
{
120+
"fieldPath": "socialLinks",
121+
"columnName": "social_links",
122+
"affinity": "TEXT"
123+
},
124+
{
125+
"fieldPath": "billCustomizationsJson",
126+
"columnName": "bill_customizations",
127+
"affinity": "TEXT"
128+
},
129+
{
130+
"fieldPath": "holderMetricsJson",
131+
"columnName": "holder_metrics",
132+
"affinity": "TEXT"
133+
},
134+
{
135+
"fieldPath": "vmMetadata.vm",
136+
"columnName": "vm_vm",
137+
"affinity": "TEXT",
138+
"notNull": true
139+
},
140+
{
141+
"fieldPath": "vmMetadata.authority",
142+
"columnName": "vm_authority",
143+
"affinity": "TEXT",
144+
"notNull": true
145+
},
146+
{
147+
"fieldPath": "vmMetadata.lockDurationInDays",
148+
"columnName": "vm_lock_duration_days",
149+
"affinity": "INTEGER",
150+
"notNull": true
151+
},
152+
{
153+
"fieldPath": "launchpadMetadata.currencyConfig",
154+
"columnName": "lp_currency_config",
155+
"affinity": "TEXT"
156+
},
157+
{
158+
"fieldPath": "launchpadMetadata.liquidityPool",
159+
"columnName": "lp_liquidity_pool",
160+
"affinity": "TEXT"
161+
},
162+
{
163+
"fieldPath": "launchpadMetadata.seed",
164+
"columnName": "lp_seed",
165+
"affinity": "TEXT"
166+
},
167+
{
168+
"fieldPath": "launchpadMetadata.authority",
169+
"columnName": "lp_authority",
170+
"affinity": "TEXT"
171+
},
172+
{
173+
"fieldPath": "launchpadMetadata.mintVault",
174+
"columnName": "lp_mint_vault",
175+
"affinity": "TEXT"
176+
},
177+
{
178+
"fieldPath": "launchpadMetadata.coreMintVault",
179+
"columnName": "lp_core_mint_vault",
180+
"affinity": "TEXT"
181+
},
182+
{
183+
"fieldPath": "launchpadMetadata.currentCirculatingSupplyQuarks",
184+
"columnName": "lp_circulating_supply_quarks",
185+
"affinity": "INTEGER"
186+
},
187+
{
188+
"fieldPath": "launchpadMetadata.sellFeeBps",
189+
"columnName": "lp_sell_fee_bps",
190+
"affinity": "INTEGER"
191+
},
192+
{
193+
"fieldPath": "launchpadMetadata.priceAmount",
194+
"columnName": "lp_price_amount_usd",
195+
"affinity": "REAL"
196+
},
197+
{
198+
"fieldPath": "launchpadMetadata.marketCapAmount",
199+
"columnName": "lp_market_cap_amount_usd",
200+
"affinity": "REAL"
201+
}
202+
],
203+
"primaryKey": {
204+
"autoGenerate": false,
205+
"columnNames": [
206+
"address"
207+
]
208+
}
209+
},
210+
{
211+
"tableName": "token_social_links",
212+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `token_address` TEXT NOT NULL, `type` TEXT NOT NULL, `value` TEXT NOT NULL, FOREIGN KEY(`token_address`) REFERENCES `tokens`(`address`) ON UPDATE NO ACTION ON DELETE CASCADE )",
213+
"fields": [
214+
{
215+
"fieldPath": "id",
216+
"columnName": "id",
217+
"affinity": "INTEGER",
218+
"notNull": true
219+
},
220+
{
221+
"fieldPath": "tokenAddress",
222+
"columnName": "token_address",
223+
"affinity": "TEXT",
224+
"notNull": true
225+
},
226+
{
227+
"fieldPath": "type",
228+
"columnName": "type",
229+
"affinity": "TEXT",
230+
"notNull": true
231+
},
232+
{
233+
"fieldPath": "value",
234+
"columnName": "value",
235+
"affinity": "TEXT",
236+
"notNull": true
237+
}
238+
],
239+
"primaryKey": {
240+
"autoGenerate": true,
241+
"columnNames": [
242+
"id"
243+
]
244+
},
245+
"indices": [
246+
{
247+
"name": "index_token_social_links_token_address",
248+
"unique": false,
249+
"columnNames": [
250+
"token_address"
251+
],
252+
"orders": [],
253+
"createSql": "CREATE INDEX IF NOT EXISTS `index_token_social_links_token_address` ON `${TABLE_NAME}` (`token_address`)"
254+
}
255+
],
256+
"foreignKeys": [
257+
{
258+
"table": "tokens",
259+
"onDelete": "CASCADE",
260+
"onUpdate": "NO ACTION",
261+
"columns": [
262+
"token_address"
263+
],
264+
"referencedColumns": [
265+
"address"
266+
]
267+
}
268+
]
269+
},
270+
{
271+
"tableName": "token_valuation",
272+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`token_address` TEXT NOT NULL, `balance_quarks` INTEGER NOT NULL, `cost_basis` REAL NOT NULL, PRIMARY KEY(`token_address`), FOREIGN KEY(`token_address`) REFERENCES `tokens`(`address`) ON UPDATE NO ACTION ON DELETE CASCADE )",
273+
"fields": [
274+
{
275+
"fieldPath": "tokenAddress",
276+
"columnName": "token_address",
277+
"affinity": "TEXT",
278+
"notNull": true
279+
},
280+
{
281+
"fieldPath": "balanceQuarks",
282+
"columnName": "balance_quarks",
283+
"affinity": "INTEGER",
284+
"notNull": true
285+
},
286+
{
287+
"fieldPath": "costBasis",
288+
"columnName": "cost_basis",
289+
"affinity": "REAL",
290+
"notNull": true
291+
}
292+
],
293+
"primaryKey": {
294+
"autoGenerate": false,
295+
"columnNames": [
296+
"token_address"
297+
]
298+
},
299+
"indices": [
300+
{
301+
"name": "index_token_valuation_token_address",
302+
"unique": false,
303+
"columnNames": [
304+
"token_address"
305+
],
306+
"orders": [],
307+
"createSql": "CREATE INDEX IF NOT EXISTS `index_token_valuation_token_address` ON `${TABLE_NAME}` (`token_address`)"
308+
}
309+
],
310+
"foreignKeys": [
311+
{
312+
"table": "tokens",
313+
"onDelete": "CASCADE",
314+
"onUpdate": "NO ACTION",
315+
"columns": [
316+
"token_address"
317+
],
318+
"referencedColumns": [
319+
"address"
320+
]
321+
}
322+
]
323+
}
324+
],
325+
"setupQueries": [
326+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
327+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '8341b10599a7b1c98f1faa3832d759b5')"
328+
]
329+
}
330+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ import com.getcode.utils.subByteArray
4343
AutoMigration(from = 10, to = 11, spec = FlipcashDatabase.Migration10To11::class),
4444
AutoMigration(from = 11, to = 12),
4545
AutoMigration(from = 12, to = 13, spec = FlipcashDatabase.Migration12To13::class),
46+
AutoMigration(from = 13, to = 14),
4647
],
47-
version = 13,
48+
version = 14,
4849
)
4950
@TypeConverters(TokenTypeConverters::class)
5051
abstract class FlipcashDatabase : RoomDatabase() {

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ class TokenTypeConverters {
4040
}
4141

4242
// endregion
43+
44+
// region holder metrics
45+
@TypeConverter
46+
fun fromHolderMetrics(value: String?): HolderMetricsSerialized? {
47+
return value?.let { json.decodeFromString<HolderMetricsSerialized>(it) }
48+
}
49+
50+
@TypeConverter
51+
fun toHolderMetrics(metrics: HolderMetricsSerialized?): String? {
52+
return metrics?.let { json.encodeToString(it) }
53+
}
54+
// endregion
4355
}
4456

4557
@Serializable
@@ -84,4 +96,16 @@ data class BillTextureSerialized(
8496
val index: Int,
8597
val blendMode: String,
8698
val strength: Float,
99+
)
100+
101+
@Serializable
102+
data class HolderMetricsSerialized(
103+
val currentHolders: Long,
104+
val deltas: List<HolderDeltaSerialized>,
105+
)
106+
107+
@Serializable
108+
data class HolderDeltaSerialized(
109+
val range: String, // WindowedRange enum name
110+
val delta: Long,
87111
)

apps/flipcash/shared/persistence/db/src/main/kotlin/com/flipcash/app/persistence/entities/TokenEntity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ data class TokenEntity(
4646

4747
// Serialized via TypeConverter (polymorphic sealed types)
4848
@ColumnInfo(name = "bill_customizations")
49-
val billCustomizationsJson: String?, // JSON
49+
val billCustomizationsJson: String?,
50+
51+
@ColumnInfo(name = "holder_metrics")
52+
val holderMetricsJson: String?,
5053
) {
5154
@get:Ignore
5255
val mint: Mint

0 commit comments

Comments
 (0)