Skip to content

Conversation

@youngkidwarrior
Copy link
Collaborator

Why:

  • Provide storage and unique identity (user_id,token_key) for native/ERC-20 balances.
  • RLS ensures users can read only their balances; trigger updates native balances on deposits
    (exclude internal transfers). Historical backfill aggregates SEND net transfers and ETH deposits.

Test plan:

  • Apply migrations locally: table, indexes, RLS, trigger created.
  • Insert a receive (external→Send Account) → native balance increments.
  • Backfill runs without relation/lock errors; balances reflect SEND+ETH merged per address/chain.

Copy link
Collaborator Author

youngkidwarrior commented Oct 4, 2025

@youngkidwarrior youngkidwarrior changed the base branch from db_add_enum_send_token_hodler_docs_test to graphite-base/2004 October 4, 2025 09:41
@youngkidwarrior youngkidwarrior force-pushed the db_add_token_balances_rls_trigger_backfill branch from 871cfb2 to 36abf87 Compare October 4, 2025 09:43
@youngkidwarrior youngkidwarrior changed the base branch from graphite-base/2004 to db_add_enum_send_token_hodler_docs_test October 4, 2025 09:43
@youngkidwarrior youngkidwarrior force-pushed the db_add_token_balances_rls_trigger_backfill branch from 36abf87 to c509af8 Compare October 4, 2025 10:32
@youngkidwarrior youngkidwarrior force-pushed the db_add_enum_send_token_hodler_docs_test branch from 401915c to 1a13ada Compare October 4, 2025 12:08
@youngkidwarrior youngkidwarrior force-pushed the db_add_token_balances_rls_trigger_backfill branch from c509af8 to 4c24cdd Compare October 4, 2025 12:08
@github-actions
Copy link

github-actions bot commented Oct 4, 2025

Why:
- Optimize for speed and a single source of truth. The DB trigger on
  send_token_transfers already upserts token_balances and inserts/updates
  send_token_hodler DV when balance exceeds hodler_min_balance.
- Remove app-layer DV upsert path to avoid duplicate writes and race
  conditions.
- Backfill migration now uses only send_token_transfers (no native
  receives).

Test plan:
- yarn workspace @my/supabase reset
- yarn workspace @my/supabase generate
- yarn lint
- SQL: supabase/tests/distribution_send_token_hodler_test.sql
  (inserts a SEND transfer → verifies token_balances and DV updated)
@youngkidwarrior youngkidwarrior changed the base branch from db_add_enum_send_token_hodler_docs_test to graphite-base/2004 October 10, 2025 06:28
@youngkidwarrior youngkidwarrior force-pushed the db_add_token_balances_rls_trigger_backfill branch from 4c24cdd to 4644579 Compare October 10, 2025 06:28
@youngkidwarrior youngkidwarrior changed the base branch from graphite-base/2004 to docs_add_hodler_verification_plan October 10, 2025 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants