Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Send Earn #1085

Open
wants to merge 162 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
e257ea3
Added first part of dummy UI for earn
musidlo Jan 25, 2025
d952c3d
Added earning form screen
musidlo Jan 28, 2025
12a298c
Added active earnings screen
musidlo Jan 29, 2025
3183e34
Added withdraw form
musidlo Jan 29, 2025
80bca91
Added earnings and rewards balance
musidlo Jan 31, 2025
4e453a9
fix: StartEarning -> Deposit
0xBigBoss Feb 16, 2025
de88096
feat: add oliveDrab color
0xBigBoss Feb 16, 2025
e090c86
refactor: DepositForm
0xBigBoss Feb 16, 2025
4d576ff
feat(ui): add base style to Shake
0xBigBoss Feb 16, 2025
31eed4b
fix: update EarnTerms and DepositForm
0xBigBoss Feb 16, 2025
7539073
feat(wagmi): add Send Earn
0xBigBoss Feb 16, 2025
6f10544
fix: StartEarning -> Deposit
0xBigBoss Feb 16, 2025
407a89e
fix(app): update useUserOpTransferMutation
0xBigBoss Feb 16, 2025
ea66230
feat(wagmi): add Send Earn
0xBigBoss Feb 16, 2025
cd5139f
feat(app): SendEarn Deposit onchain
0xBigBoss Feb 16, 2025
51dd837
feat(app): SendEarn Deposit onchain
0xBigBoss Feb 16, 2025
103160e
fix: double render on HomeSidebar
0xBigBoss Feb 16, 2025
7e63df2
feat(playwright): deposit Send Earn spec
0xBigBoss Feb 17, 2025
6cabe17
feat(app): add link to Send Earn
0xBigBoss Feb 17, 2025
c8b410c
fix(app): do not retry not enough USDC
0xBigBoss Feb 17, 2025
19d6158
feat(app): move useSendEarnDepositUserOp to hooks
0xBigBoss Feb 17, 2025
f477099
fix(app): app crash
0xBigBoss Feb 19, 2025
bb1fde8
fix(app): improve amount sanitization
0xBigBoss Feb 19, 2025
817b125
fix(app): enforce minimum deposit amount in DepositForm
0xBigBoss Feb 19, 2025
4962c16
feat(app): show estimated earnings and APY for Send Earn
0xBigBoss Feb 21, 2025
90767ea
fix(app): update SendEarnVault type to ensure non-null data handling …
0xBigBoss Feb 22, 2025
be24184
fix(app): adjust minimum deposit to 10 USDC and update form error han…
0xBigBoss Feb 22, 2025
114a0da
shovel: upgrade to latest
0xBigBoss Feb 25, 2025
b9aa173
feat(shovel): add send_earn_new_affiliate integration
0xBigBoss Feb 25, 2025
e2fdec6
feat(wagmi): update SendEarn contracts and add revenue safe configura…
0xBigBoss Feb 25, 2025
41e4a30
feat(shovel): add send earn integrations
0xBigBoss Feb 25, 2025
5b30812
fix: send earn address
0xBigBoss Feb 26, 2025
1a0d15e
refactor: organize checkout form and utils
0xBigBoss Feb 26, 2025
1118736
fix(shovel): typo send earn integrations
0xBigBoss Feb 27, 2025
52bfe34
fix(supabase): specify bigint for id in send_earn_create and send_ear…
0xBigBoss Mar 2, 2025
d2f4035
fix: update contract addresses in config for SendEarn and SendEarnFac…
0xBigBoss Mar 2, 2025
9f5ddb5
fix(supabase): update types in send_earn_create and send_earn_new_aff…
0xBigBoss Mar 2, 2025
034419e
refactor: organize checkout form and utils
0xBigBoss Mar 2, 2025
8a9f1d1
fix(shovel): commit shovel snapshot, limit shovel resources
0xBigBoss Mar 2, 2025
060321f
fix: limit anvil resources
0xBigBoss Mar 2, 2025
e1adc73
fix(shovel): set default SHOVEL_VERSION
0xBigBoss Mar 2, 2025
bc6269c
feat(shovel): add send_earn deposits and withdraws
0xBigBoss Mar 5, 2025
5d1c4a3
feat(supabase): send earn deposit and withdraw RLS
0xBigBoss Mar 6, 2025
3ecf69f
feat(app): add more send earn hooks
0xBigBoss Mar 6, 2025
6a0b83b
fix: add more memory to anvil
0xBigBoss Mar 6, 2025
23d8be5
feat(app): add sendEarnDepositVault
0xBigBoss Mar 7, 2025
e5237a9
feat(app): add useReferrerVault hook
0xBigBoss Mar 7, 2025
dcb5a75
refactor(app): update jsdoc
0xBigBoss Mar 7, 2025
8101d6e
refactor: sendEarnUsdcFactoryAddress
0xBigBoss Mar 7, 2025
5b0be49
refactor(app): enhance referrer logic with profile type
0xBigBoss Mar 8, 2025
cb3e27c
refactor(app): wip on createAndDeposit affiliate flow
0xBigBoss Mar 8, 2025
f947f7b
fix(tilt): anvil keeps being OOM killed
0xBigBoss Mar 9, 2025
5be9783
refactor(app): fix calcualating base apy using default vault
0xBigBoss Mar 9, 2025
8070fc8
fix(app): earn summary
0xBigBoss Mar 9, 2025
3395bc6
fix(supabase): correct RLS policy for send_earn_balances
0xBigBoss Mar 9, 2025
094798c
feat(app): add asset to URL path param
0xBigBoss Mar 9, 2025
b75e8d7
fix(app): refactor coin schemas and improve send earn balance handlin…
0xBigBoss Mar 9, 2025
cf92615
feat(app): reorganize earn feature imports and implement new earnings…
0xBigBoss Mar 9, 2025
87bb15e
test(app): add unit tests for toNiceError utility with various error …
0xBigBoss Mar 9, 2025
c4ccf72
feat(app): add erc20Coins list to coins data for better coin manageme…
0xBigBoss Mar 9, 2025
fb84368
feat(app): formatCoinAmount utility
0xBigBoss Mar 10, 2025
4e64f39
feat(app): enhance ActiveEarnings screen with new balances and improv…
0xBigBoss Mar 10, 2025
8d3a9e9
feat(supabase): add send_earn_activity view
0xBigBoss Mar 10, 2025
1278b6f
feat(app): add EarningsFeed and TotalEarning components
0xBigBoss Mar 10, 2025
6f9d34f
fix: update @0xsend/send-earn-contracts
0xBigBoss Mar 12, 2025
57ffa1e
refactor(earn): optimize EarningsSummary calculations with useMemo fo…
0xBigBoss Mar 12, 2025
f21939a
fix(shovel): snapshots and config after send earn update
0xBigBoss Mar 12, 2025
7012ab3
feat(supabase): add created_at to referrals
0xBigBoss Mar 12, 2025
ff00e5b
sync snaplet
0xBigBoss Mar 12, 2025
2b986e7
feat(supabase): add created_at to referrals
0xBigBoss Mar 12, 2025
2957f90
fix(snaplet): include receipts
0xBigBoss Mar 13, 2025
f71a123
feat(app): add referrer view
0xBigBoss Mar 13, 2025
69173c5
feat(app): lookup existing referrer vault
0xBigBoss Mar 13, 2025
2382013
feat(app): add ReferredBy component for managing referral codes in ch…
0xBigBoss Mar 13, 2025
d104e06
fix(playwright): better tests, clean up on deposit flow
0xBigBoss Mar 14, 2025
16865ad
feat(app): refactor EarnScreen sections for improved rendering based …
0xBigBoss Mar 15, 2025
b9c8a0a
refactor(app): clean up earn utils and zod schemas
0xBigBoss Mar 16, 2025
07f3696
fix(earn): ensure coin symbol is consistently lowercase in deposit li…
0xBigBoss Mar 16, 2025
bcab62b
feat(app): add asset parameter validation utility for server-side pro…
0xBigBoss Mar 16, 2025
b3249ea
test(earn): streamline referral code visibility checks and enhance pa…
0xBigBoss Mar 16, 2025
20338ae
feat(wagmi): integrate MorphoView for vault info retrieval and simpli…
0xBigBoss Mar 17, 2025
ef23ee7
fix(app): ensure amount is set from earnParams
0xBigBoss Mar 17, 2025
5ee9a76
feat(app): add hooks for fetching affiliate vault and earn rewards
0xBigBoss Mar 17, 2025
1b2f649
feat(app): send earn withdraw
0xBigBoss Mar 17, 2025
20581ca
fix(app): refactor WithdrawForm for amount validation and update with…
0xBigBoss Mar 18, 2025
6d5adcf
feat(supabase): add referrals after send earn deposit
0xBigBoss Mar 18, 2025
a38ed3f
fix: delete LLM prompt due to token waste
0xBigBoss Mar 18, 2025
92909ab
feat(supabase): refactor referrals to remove tag dependency
0xBigBoss Mar 18, 2025
83dfc12
feat(earn): enhance deposit form to auto-accept terms for existing de…
0xBigBoss Mar 18, 2025
ad2c684
feat(earn): rename components and streamline rewards logic for better…
0xBigBoss Mar 18, 2025
98788dd
feat(earn): refactor rewards screen to improve claim logic and integr…
0xBigBoss Mar 18, 2025
eed8c3b
feat(earn): enhance ActiveEarnings and DepositForm with rewards logic…
0xBigBoss Mar 19, 2025
929d657
feat(earn): update ActiveEarnings and DepositForm to incorporate affi…
0xBigBoss Mar 19, 2025
7e41b35
feat(earn): add support for affiliate rewards splitting and enhance b…
0xBigBoss Mar 19, 2025
7c1ca21
feat(earn): implement Send Earn activity schema and enhance rewards s…
0xBigBoss Mar 19, 2025
ca0f08d
feat(earn): clean up earn activity
0xBigBoss Mar 19, 2025
9999ecb
feat(activity): add client-side processing for activity feed, includi…
0xBigBoss Mar 20, 2025
7a9c919
docs: send earn UI/UX design
0xBigBoss Mar 20, 2025
47acb81
docs: create todo
0xBigBoss Mar 20, 2025
58d7b97
feat(activity): enhance client-side processing with virtual events fo…
0xBigBoss Mar 20, 2025
093635d
feat(activity): create useEarnActivityFeed hook for fetching Send Ear…
0xBigBoss Mar 21, 2025
f2e68ac
feat(referrals): add trigger function for referral relationship on ne…
0xBigBoss Mar 21, 2025
fc05fad
feat(docs): add comprehensive overview of activity feed system and ba…
0xBigBoss Mar 21, 2025
a2d3de2
refactor(tests): remove duplicated tests for invalid referral codes a…
0xBigBoss Mar 21, 2025
183771e
feat(tests): implement claim rewards page functionality and tests to …
0xBigBoss Mar 21, 2025
19cb145
feat(docs): introduce solution for affiliate reward claim visibility,…
0xBigBoss Mar 22, 2025
1729838
refactor(tests): rename send_earn_deposits to send_earn_deposit for c…
0xBigBoss Mar 22, 2025
ad2a5e7
feat(deposit): add tokens query invalidation and trigger form validat…
0xBigBoss Mar 22, 2025
458a3d2
feat(activity): Send Earn database triggers
0xBigBoss Mar 23, 2025
168fb2c
feat(app): create SendEarnAmount component for formatted coin display
0xBigBoss Mar 24, 2025
f877090
fix(app): activity tests
0xBigBoss Mar 24, 2025
8884f38
fix(app): enhance DepositForm and tweak tests
0xBigBoss Mar 24, 2025
89e3a03
fixes after rebase
0xBigBoss Mar 24, 2025
05f5792
fixes after rebase
0xBigBoss Mar 24, 2025
3644671
fixes after rebase
0xBigBoss Mar 24, 2025
46b6a43
remove TODO
0xBigBoss Mar 24, 2025
c4ae493
refactor: update imports to use new Events enum instead of DatabaseEv…
0xBigBoss Mar 24, 2025
1b82738
refactor: simplify activity type exports by only exporting Events enu…
0xBigBoss Mar 24, 2025
5edb856
feat(app): useAddressBook now uses useQueries
0xBigBoss Mar 26, 2025
f97eef2
add react query docs v5.18.1
0xBigBoss Mar 26, 2025
73196a0
feat(app): invalidate useSendAccount correctly
0xBigBoss Mar 26, 2025
e697e6a
feat(app): simpler useAddressBook
0xBigBoss Mar 26, 2025
85bcb8c
fix: cleanup from merges and formatting
0xBigBoss Mar 26, 2025
204da92
feat(app): enhance activity feed fetch logic to include affiliate rew…
0xBigBoss Mar 26, 2025
d25f005
chore: remove docs
0xBigBoss Mar 26, 2025
c96c492
fix(hooks): update referrer vault query to enable on success or error…
0xBigBoss Mar 26, 2025
a963625
fix(app): update deposit hook to enable query on balance, referrer va…
0xBigBoss Mar 26, 2025
f564097
fix(app): refine deposit hook to enable query based on success/error …
0xBigBoss Mar 26, 2025
92059f9
fix(app): update hooks to enable queries based on fetched state inste…
0xBigBoss Mar 26, 2025
06306fb
fix(app): correct formatting in useUnderlyingVault docstring for impr…
0xBigBoss Mar 26, 2025
bc36815
fix(app): update useEarnActivityFeed to check for fetched state inste…
0xBigBoss Mar 26, 2025
38398cb
fix(app): enhance hooks logging and assertions for better debugging a…
0xBigBoss Mar 26, 2025
a2c3026
chore(app): clean up log
0xBigBoss Mar 26, 2025
c4ad314
fix(app): update useReferrerVault to require both referredBy and refe…
0xBigBoss Mar 26, 2025
3dab645
fix(app): improve useSendEarnWithdrawVault to only require fetched co…
0xBigBoss Mar 26, 2025
45c566e
fix(app): update useSendEarnWithdrawCalls to only enable query when v…
0xBigBoss Mar 26, 2025
9794a02
chore(app): remove unused vars
0xBigBoss Mar 26, 2025
4fe400b
fix(app): update useTokenActivityFeed to enable query when addressBoo…
0xBigBoss Mar 26, 2025
02b16ce
refactor(app): streamline activity utilities by introducing useAmount…
0xBigBoss Mar 26, 2025
e2dcacb
fix(app): enhance useReferrer to throw error if referralCode fetch fa…
0xBigBoss Mar 26, 2025
4a65e7d
test(playwright): add visibility and enablement checks for claim butt…
0xBigBoss Mar 26, 2025
ff19eff
fix(tests): remove unnecessary type assertion in activity feed matche…
0xBigBoss Mar 26, 2025
23aeb5d
refactor(tests): remove unused debug log in viem fixture for cleaner …
0xBigBoss Mar 26, 2025
84b32ae
refactor(tests): remove unused import of checkReferralCodeHidden for …
0xBigBoss Mar 26, 2025
1adf2d6
refactor(tests): streamline WithdrawForm tests by optimizing error ha…
0xBigBoss Mar 26, 2025
652a493
refactor(seed): utilize dynamic dryRun variable instead of hardcoding…
0xBigBoss Mar 26, 2025
81a1937
feat(docs): add comprehensive Send Earn protocol integration document…
0xBigBoss Mar 26, 2025
4efe474
feat(supabase): implement referral system enhancements and triggers f…
0xBigBoss Mar 26, 2025
cafbc81
fix(app): update test
0xBigBoss Mar 27, 2025
96c6e44
fix(supabase): use before insert for triggers
0xBigBoss Mar 28, 2025
8e9cbe4
fix: referrerVault query and clean up form trigger usage in DepositForm
0xBigBoss Mar 29, 2025
7e4209e
feat(shovel): add skip empty
0xBigBoss Mar 29, 2025
e09a8be
chore(supabase): clean up trigger names
0xBigBoss Mar 29, 2025
3133d20
fix(activity): move subText null check for better code clarity in Act…
0xBigBoss Mar 29, 2025
5e0f358
fix(supabase): try after insert again
0xBigBoss Mar 29, 2025
416f787
Revert "fix(supabase): try after insert again"
0xBigBoss Mar 29, 2025
3e41a80
chore(supabase): format
0xBigBoss Mar 29, 2025
88952c8
Reapply "fix(supabase): try after insert again"
0xBigBoss Mar 29, 2025
1b31661
fix(deposit): update form validation logic to check for errors in for…
0xBigBoss Mar 29, 2025
a8edd23
fix(supabase): fix migration order
0xBigBoss Mar 29, 2025
9bd29c9
feat(app): add Send Earn deposit workflow and API
0xBigBoss Mar 29, 2025
7032d86
feat: add postgrestools
0xBigBoss Mar 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,946 changes: 0 additions & 1,946 deletions .clinerules

This file was deleted.

1,946 changes: 0 additions & 1,946 deletions .cursorrules

This file was deleted.

3 changes: 2 additions & 1 deletion .env.local.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ SNAPLET_HASH_KEY=sendapp
SUPABASE_DB_URL=postgresql://postgres:postgres@localhost:54322/postgres
SUPABASE_JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long
SUPABASE_SERVICE_ROLE=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
# NEXT_PUBLIC_ENABLE_QUERY_DEV_TOOLS=1
# NEXT_PUBLIC_REACT_QUERY_DEV_TOOLS=1
# NEXT_PUBLIC_REACT_SCAN_ENABLED=1
# Enables more logging for sendapp
# DEBUG="api:*,app:*,test:*,-test:fixtures:snaplet:*"
# Record your playwright tests
Expand Down
1,946 changes: 0 additions & 1,946 deletions CLAUDE.md

This file was deleted.

2 changes: 1 addition & 1 deletion apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"expo-build-properties": "~0.11.1",
"expo-clipboard": "^5.0.1",
"expo-constants": "~15.4.5",
"expo-crypto": "~12.8.0",
"expo-crypto": "~14.0.2",
"expo-dev-client": "~3.3.8",
"expo-device": "~5.9.3",
"expo-font": "~11.10.2",
Expand Down
1 change: 1 addition & 0 deletions apps/next/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export default () => {
'expo-modules-core',
'expo-device',
'expo-image-picker',
'expo-crypto',
],
experimental: {
scrollRestoration: true,
Expand Down
7 changes: 6 additions & 1 deletion apps/next/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { AppRegistry } from 'react-native'

import { config } from '@my/ui'

const DEV = process.env.NODE_ENV === 'development'

export default class Document extends NextDocument {
static async getInitialProps(ctx: DocumentContext): Promise<DocumentInitialProps> {
AppRegistry.registerComponent('Main', () => Main)
Expand All @@ -30,7 +32,7 @@ export default class Document extends NextDocument {
// biome-ignore lint/security/noDangerouslySetInnerHtml: tamagui is a trusted source
dangerouslySetInnerHTML={{
__html: config.getCSS({
exclude: process.env.NODE_ENV === 'development' ? null : 'design-system',
exclude: DEV ? null : 'design-system',
}),
}}
/>,
Expand All @@ -43,6 +45,9 @@ export default class Document extends NextDocument {
return (
<Html>
<Head>
{DEV && !!process.env.NEXT_PUBLIC_REACT_SCAN_ENABLED ? (
<script src="https://unpkg.com/react-scan/dist/auto.global.js" />
) : null}
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
</Head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Page: NextPageWithLayout = () => {
export const getServerSideProps = userProtectedGetSSP()

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Settings" backFunction={'router'} />} fullHeight>
<HomeLayout TopNav={<TopNav header="Settings" backFunction={'pop'} />} fullHeight>
<SettingsLayout>{children}</SettingsLayout>
</HomeLayout>
)
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/account/settings/backup/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const Page: NextPageWithLayout = () => {
export const getServerSideProps = userProtectedGetSSP()

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Settings" backFunction={'router'} />} fullHeight>
<HomeLayout TopNav={<TopNav header="Settings" backFunction={'pop'} />} fullHeight>
<SettingsLayout>{children}</SettingsLayout>
</HomeLayout>
)
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/account/settings/backup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Page: NextPageWithLayout = () => {
export const getServerSideProps = userProtectedGetSSP()

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Settings" backFunction={'router'} />} fullHeight>
<HomeLayout TopNav={<TopNav header="Settings" backFunction={'pop'} />} fullHeight>
<SettingsLayout>{children}</SettingsLayout>
</HomeLayout>
)
Expand Down
31 changes: 31 additions & 0 deletions apps/next/pages/earn/[asset]/balance.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { TopNav } from 'app/components/TopNav'
import { EarningsBalance } from 'app/features/earn/earnings/screen'
import { assetParam } from '../../../utils/assetParam'
import { HomeLayout } from 'app/features/home/layout.web'
import type { GetServerSideProps } from 'next'
import Head from 'next/head'
import { userProtectedGetSSP } from 'utils/userProtected'
import type { NextPageWithLayout } from '../../_app'

export const Page: NextPageWithLayout = () => {
return (
<>
<Head>
<title>Send | Earnings Balance</title>
</Head>
<EarningsBalance />
</>
)
}

export const getServerSideProps: GetServerSideProps = (context) => {
return assetParam(context, userProtectedGetSSP)
}

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Earnings Balance" backFunction="router" />} fullHeight>
{children}
</HomeLayout>
)

export default Page
31 changes: 31 additions & 0 deletions apps/next/pages/earn/[asset]/deposit.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { TopNav } from 'app/components/TopNav'
import { DepositScreen } from 'app/features/earn/deposit/screen'
import { assetParam } from '../../../utils/assetParam'
import { HomeLayout } from 'app/features/home/layout.web'
import type { GetServerSideProps } from 'next'
import Head from 'next/head'
import { userProtectedGetSSP } from 'utils/userProtected'
import type { NextPageWithLayout } from '../../_app'

export const Page: NextPageWithLayout = () => {
return (
<>
<Head>
<title>Send | Start Earning</title>
</Head>
<DepositScreen />
</>
)
}

export const getServerSideProps: GetServerSideProps = (context) => {
return assetParam(context, userProtectedGetSSP)
}

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Start Earning" backFunction="router" />}>
{children}
</HomeLayout>
)

export default Page
31 changes: 31 additions & 0 deletions apps/next/pages/earn/[asset]/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { TopNav } from 'app/components/TopNav'
import { ActiveEarningsScreen } from 'app/features/earn/active/screen'
import { assetParam } from '../../../utils/assetParam'
import { HomeLayout } from 'app/features/home/layout.web'
import type { GetServerSideProps } from 'next'
import Head from 'next/head'
import { userProtectedGetSSP } from 'utils/userProtected'
import type { NextPageWithLayout } from '../../_app'

export const Page: NextPageWithLayout = () => {
return (
<>
<Head>
<title>Send | Active Earnings</title>
</Head>
<ActiveEarningsScreen />
</>
)
}

export const getServerSideProps: GetServerSideProps = (context) => {
return assetParam(context, userProtectedGetSSP)
}

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Active Earnings" backFunction="root" />}>
{children}
</HomeLayout>
)

export default Page
31 changes: 31 additions & 0 deletions apps/next/pages/earn/[asset]/rewards.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { TopNav } from 'app/components/TopNav'
import { RewardsBalanceScreen } from 'app/features/earn/rewards/screen'
import { HomeLayout } from 'app/features/home/layout.web'
import Head from 'next/head'
import { userProtectedGetSSP } from 'utils/userProtected'
import type { NextPageWithLayout } from '../../_app'
import type { GetServerSideProps } from 'next'
import { assetParam } from '../../../utils/assetParam'

export const Page: NextPageWithLayout = () => {
return (
<>
<Head>
<title>Send | Rewards Balance</title>
</Head>
<RewardsBalanceScreen />
</>
)
}

export const getServerSideProps: GetServerSideProps = (context) => {
return assetParam(context, userProtectedGetSSP)
}

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Rewards Balance" backFunction="router" />} fullHeight>
{children}
</HomeLayout>
)

export default Page
31 changes: 31 additions & 0 deletions apps/next/pages/earn/[asset]/withdraw.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { TopNav } from 'app/components/TopNav'
import { assetParam } from '../../../utils/assetParam'
import { WithdrawForm } from 'app/features/earn/withdraw/screen'
import { HomeLayout } from 'app/features/home/layout.web'
import type { GetServerSideProps } from 'next'
import Head from 'next/head'
import { userProtectedGetSSP } from 'utils/userProtected'
import type { NextPageWithLayout } from '../../_app'

export const Page: NextPageWithLayout = () => {
return (
<>
<Head>
<title>Send | Withdraw Deposit</title>
</Head>
<WithdrawForm />
</>
)
}

export const getServerSideProps: GetServerSideProps = (context) => {
return assetParam(context, userProtectedGetSSP)
}

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Withdraw Deposit" backFunction="router" />}>
{children}
</HomeLayout>
)

export default Page
22 changes: 22 additions & 0 deletions apps/next/pages/earn/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { TopNav } from 'app/components/TopNav'
import { EarnScreen } from 'app/features/earn/screen'
import { HomeLayout } from 'app/features/home/layout.web'
import Head from 'next/head'
import type { NextPageWithLayout } from '../_app'

export const Page: NextPageWithLayout = () => {
return (
<>
<Head>
<title>Send | Earn</title>
</Head>
<EarnScreen />
</>
)
}

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Earn" backFunction="root" />}>{children}</HomeLayout>
)

export default Page
47 changes: 47 additions & 0 deletions apps/next/utils/assetParam.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { paramToCoin } from 'app/features/earn/params'
import { debug } from 'debug'
import type { GetServerSidePropsContext, GetServerSidePropsResult } from 'next'
import type { ParsedUrlQuery } from 'node:querystring'

const log = debug('app:utils:assetParam')

interface AssetParams extends ParsedUrlQuery {
asset?: string
}

/**
* Helper function to validate the asset parameter for all routes under the [asset] parameterized route.
*
* @param context - The GetServerSidePropsContext from Next.js
* @param getSSP - The function to call if the asset is valid (e.g., userProtectedGetSSP())
* @returns GetServerSidePropsResult based on asset validation
*/
export function assetParam(
context: GetServerSidePropsContext,
getSSP: () => (
context: GetServerSidePropsContext
) => Promise<GetServerSidePropsResult<Record<string, unknown>>>
): Promise<GetServerSidePropsResult<Record<string, unknown>>> {
const { asset } = context.params as AssetParams

if (!asset) {
log('no asset')
return Promise.resolve({
redirect: {
destination: '/earn',
permanent: false,
},
})
}

if (!paramToCoin(asset)) {
log('coin not supported', asset)
// 404 if coin is not supported
return Promise.resolve({
notFound: true,
})
}

// Asset is valid, proceed with the provided getSSP function
return getSSP()(context)
}
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"./supabase/.temp/**",
"./packages/contracts/var/*.json",
"**/tsconfig.json",
"**/*.tsconfig.json"
"**/*.tsconfig.json",
"postgrestools.jsonc"
]
},
"organizeImports": {
Expand Down
5 changes: 5 additions & 0 deletions docs/react-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# React Query

Send app relies heavily on React Query for data fetching. If you have never used React Query, you can read the [docs](https://tanstack.com/query/v5/docs/framework/react/overview) to get started.

Or, read the reference or guides for the specific hooks you want to use.
28 changes: 14 additions & 14 deletions docs/send-app-activity-feed.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ create or replace function activity_feed()
as
$$
begin
return query
return query
select a.id,
a.created_at,
a.event_name,
Expand Down Expand Up @@ -114,7 +114,7 @@ begin
-- select send app info for from address
select user_id into _f_user_id from send_accounts where address = concat('0x', encode(NEW.f, 'hex'))::citext;
select user_id into _t_user_id from send_accounts where address = concat('0x', encode(NEW.t, 'hex'))::citext;

insert into activity (event_name, event_id, from_user_id, to_user_id, data)
values ('send_account_transfers',
NEW.id,
Expand Down Expand Up @@ -164,7 +164,7 @@ SELECT tests.create_supabase_user('test_user_to');

INSERT INTO send_accounts (user_id, address, chain_id, init_code)
VALUES (tests.get_supabase_uid('test_user_from'), '0x1234567890ABCDEF1234567890ABCDEF12345678', 1, '\\x00112233445566778899AABBCCDDEEFF'),
(tests.get_supabase_uid('test_user_to'), '0xB0B7D5E8A4B6D534B3F608E9D27871F85A4E98DA', 1, '\\x00112233445566778899AABBCCDDEEFF');
(tests.get_supabase_uid('test_user_to'), '0xB0B7D5E8A4B6D534B3F608E9D27871F85A4E98DA', 1, '\\x00112233445566778899AABBCCDDEEFF');

-- Insert a test row into send_account_transfers table
INSERT INTO send_account_transfers (f, t, v)
Expand All @@ -173,10 +173,10 @@ VALUES ('\x1234567890ABCDEF1234567890ABCDEF12345678'::bytea, '\xB0B7D5E8A4B6D534
-- Test if the trigger function populated the additional columns correctly
SELECT results_eq(
$$
SELECT
f,
t,
v,
SELECT
f,
t,
v,
tests.get_supabase_uid('test_user_from'),
tests.get_supabase_uid('test_user_to')
FROM send_account_transfers
Expand All @@ -189,19 +189,19 @@ SELECT results_eq(
'Test if the trigger function populated the additional columns correctly'
);

DELETE FROM send_account_transfers
DELETE FROM send_account_transfers
WHERE id = (
SELECT id
FROM send_account_transfers
SELECT id
FROM send_account_transfers
WHERE f = '\x1234567890ABCDEF1234567890ABCDEF12345678'::bytea AND t = '\xB0B7D5E8A4B6D534B3F608E9D27871F85A4E98DA'::bytea);

-- Test if the trigger function removes the activity row
SELECT is_empty(
$$
SELECT
f,
t,
v,
SELECT
f,
t,
v,
tests.get_supabase_uid('test_user_from'),
tests.get_supabase_uid('test_user_to')
FROM send_account_transfers
Expand Down
Loading
Loading