Skip to content

Commit 55681fe

Browse files
Calculate send slash function
1 parent 153e68a commit 55681fe

4 files changed

+401
-17
lines changed

packages/snaplet/.snaplet/dataModel.json

+107-14
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,6 @@
287287
"schemaName": "public",
288288
"tableName": "affiliate_stats",
289289
"fields": [
290-
{
291-
"id": "public.affiliate_stats.paymaster_tx_count",
292-
"name": "paymaster_tx_count",
293-
"columnName": "paymaster_tx_count",
294-
"type": "int8",
295-
"isRequired": true,
296-
"kind": "scalar",
297-
"isList": false,
298-
"isGenerated": false,
299-
"sequence": false,
300-
"hasDefaultValue": true,
301-
"isId": false,
302-
"maxLength": null
303-
},
304290
{
305291
"id": "public.affiliate_stats.user_id",
306292
"name": "user_id",
@@ -357,6 +343,20 @@
357343
"isId": false,
358344
"maxLength": null
359345
},
346+
{
347+
"id": "public.affiliate_stats.send_plus_minus",
348+
"name": "send_plus_minus",
349+
"columnName": "send_plus_minus",
350+
"type": "int8",
351+
"isRequired": true,
352+
"kind": "scalar",
353+
"isList": false,
354+
"isGenerated": false,
355+
"sequence": false,
356+
"hasDefaultValue": true,
357+
"isId": false,
358+
"maxLength": null
359+
},
360360
{
361361
"name": "profiles",
362362
"type": "profiles",
@@ -1631,6 +1631,20 @@
16311631
"isGenerated": false,
16321632
"sequence": false,
16331633
"hasDefaultValue": false
1634+
},
1635+
{
1636+
"name": "send_slash",
1637+
"type": "send_slash",
1638+
"isRequired": false,
1639+
"kind": "object",
1640+
"relationName": "send_slashTodistributions",
1641+
"relationFromFields": [],
1642+
"relationToFields": [],
1643+
"isList": true,
1644+
"isId": false,
1645+
"isGenerated": false,
1646+
"sequence": false,
1647+
"hasDefaultValue": false
16341648
}
16351649
],
16361650
"uniqueConstraints": [
@@ -6513,6 +6527,82 @@
65136527
}
65146528
]
65156529
},
6530+
"send_slash": {
6531+
"id": "public.send_slash",
6532+
"schemaName": "public",
6533+
"tableName": "send_slash",
6534+
"fields": [
6535+
{
6536+
"id": "public.send_slash.distribution_number",
6537+
"name": "distribution_number",
6538+
"columnName": "distribution_number",
6539+
"type": "int4",
6540+
"isRequired": true,
6541+
"kind": "scalar",
6542+
"isList": false,
6543+
"isGenerated": false,
6544+
"sequence": false,
6545+
"hasDefaultValue": false,
6546+
"isId": true,
6547+
"maxLength": null
6548+
},
6549+
{
6550+
"id": "public.send_slash.minimum_sends",
6551+
"name": "minimum_sends",
6552+
"columnName": "minimum_sends",
6553+
"type": "int2",
6554+
"isRequired": true,
6555+
"kind": "scalar",
6556+
"isList": false,
6557+
"isGenerated": false,
6558+
"sequence": false,
6559+
"hasDefaultValue": true,
6560+
"isId": false,
6561+
"maxLength": null
6562+
},
6563+
{
6564+
"id": "public.send_slash.scaling_divisor",
6565+
"name": "scaling_divisor",
6566+
"columnName": "scaling_divisor",
6567+
"type": "int2",
6568+
"isRequired": true,
6569+
"kind": "scalar",
6570+
"isList": false,
6571+
"isGenerated": false,
6572+
"sequence": false,
6573+
"hasDefaultValue": true,
6574+
"isId": false,
6575+
"maxLength": null
6576+
},
6577+
{
6578+
"name": "distributions",
6579+
"type": "distributions",
6580+
"isRequired": true,
6581+
"kind": "object",
6582+
"relationName": "send_slashTodistributions",
6583+
"relationFromFields": [
6584+
"distribution_number"
6585+
],
6586+
"relationToFields": [
6587+
"number"
6588+
],
6589+
"isList": false,
6590+
"isId": false,
6591+
"isGenerated": false,
6592+
"sequence": false,
6593+
"hasDefaultValue": false
6594+
}
6595+
],
6596+
"uniqueConstraints": [
6597+
{
6598+
"name": "send_slash_pkey",
6599+
"fields": [
6600+
"distribution_number"
6601+
],
6602+
"nullNotDistinct": false
6603+
}
6604+
]
6605+
},
65166606
"send_token_transfers": {
65176607
"id": "public.send_token_transfers",
65186608
"schemaName": "public",
@@ -9165,6 +9255,9 @@
91659255
{
91669256
"name": "create_passkey"
91679257
},
9258+
{
9259+
"name": "send_ceiling"
9260+
},
91689261
{
91699262
"name": "send_one_hundred"
91709263
},

supabase/database-generated.types.ts

+47-3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export type Database = {
137137
Row: {
138138
address: string
139139
amount: number
140+
amount_after_slash: number
140141
bonus_pool_amount: number
141142
created_at: string
142143
distribution_id: number
@@ -150,6 +151,7 @@ export type Database = {
150151
Insert: {
151152
address: string
152153
amount: number
154+
amount_after_slash: number
153155
bonus_pool_amount: number
154156
created_at?: string
155157
distribution_id: number
@@ -163,6 +165,7 @@ export type Database = {
163165
Update: {
164166
address?: string
165167
amount?: number
168+
amount_after_slash?: number
166169
bonus_pool_amount?: number
167170
created_at?: string
168171
distribution_id?: number
@@ -856,6 +859,32 @@ export type Database = {
856859
}
857860
Relationships: []
858861
}
862+
send_slash: {
863+
Row: {
864+
distribution_number: number
865+
minimum_sends: number
866+
scaling_divisor: number
867+
}
868+
Insert: {
869+
distribution_number: number
870+
minimum_sends?: number
871+
scaling_divisor?: number
872+
}
873+
Update: {
874+
distribution_number?: number
875+
minimum_sends?: number
876+
scaling_divisor?: number
877+
}
878+
Relationships: [
879+
{
880+
foreignKeyName: "send_slash_distribution_number_fkey"
881+
columns: ["distribution_number"]
882+
isOneToOne: true
883+
referencedRelation: "distributions"
884+
referencedColumns: ["number"]
885+
},
886+
]
887+
}
859888
send_token_transfers: {
860889
Row: {
861890
abi_idx: number
@@ -1138,6 +1167,12 @@ export type Database = {
11381167
}
11391168
}
11401169
Functions: {
1170+
calculate_and_insert_send_ceiling_verification: {
1171+
Args: {
1172+
distribution_number: number
1173+
}
1174+
Returns: undefined
1175+
}
11411176
citext:
11421177
| {
11431178
Args: {
@@ -1244,10 +1279,7 @@ export type Database = {
12441279
id: string
12451280
created_at: string
12461281
user_id: string
1247-
send_plus_minus: number
12481282
referral_count: number
1249-
network_plus_minus: number
1250-
affiliate_send_score: number
12511283
}[]
12521284
}
12531285
insert_challenge: {
@@ -1307,6 +1339,17 @@ export type Database = {
13071339
user_id: string
13081340
}
13091341
}
1342+
sum_qualification_sends: {
1343+
Args: {
1344+
distribution_number: number
1345+
send_ceiling: number
1346+
}
1347+
Returns: {
1348+
user_id: string
1349+
amount: number
1350+
sent_to: string[]
1351+
}[]
1352+
}
13101353
tag_search: {
13111354
Args: {
13121355
query: string
@@ -1343,6 +1386,7 @@ export type Database = {
13431386
| "send_one_hundred"
13441387
| "total_tag_referrals"
13451388
| "send_streak"
1389+
| "send_ceiling"
13461390
verification_value_mode: "individual" | "aggregate"
13471391
}
13481392
CompositeTypes: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Change the amount of the distribution to 300,000,000 SEND
2+
UPDATE
3+
public.distributions
4+
SET
5+
amount = 300000000 -- 300,000,000 SEND
6+
WHERE
7+
id = 9;
8+
9+
-- Add send_ceiling verification type
10+
ALTER TYPE public.verification_type
11+
ADD VALUE IF NOT EXISTS 'send_ceiling';
12+
13+
-- Create new table for send slash settings
14+
CREATE TABLE "public"."send_slash"(
15+
"distribution_number" integer PRIMARY KEY,
16+
"minimum_sends" smallint DEFAULT '1' ::smallint NOT NULL,
17+
"scaling_divisor" smallint DEFAULT '1' ::smallint NOT NULL,
18+
CONSTRAINT "send_slash_distribution_number_fkey" FOREIGN KEY ("distribution_number") REFERENCES "public"."distributions"("number") ON DELETE CASCADE
19+
);
20+
21+
ALTER TABLE send_slash ENABLE ROW LEVEL SECURITY;
22+
23+
-- Add amount_after_slash column to distribution_shares
24+
ALTER TABLE public.distribution_shares
25+
ADD COLUMN amount_after_slash numeric NOT NULL DEFAULT 0;
26+
27+
UPDATE
28+
public.distribution_shares
29+
SET
30+
amount_after_slash = amount;
31+
32+
-- After update, we could remove the default if desired
33+
ALTER TABLE public.distribution_shares
34+
ALTER COLUMN amount_after_slash DROP DEFAULT;
35+

0 commit comments

Comments
 (0)