Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
555c8f3
I init /api/song/market.
sweetmantech Aug 30, 2024
c3e4eb5
I init useTotalNotes for front end to use the new API.
sweetmantech Aug 30, 2024
eed2e52
I cleanup the API route.
sweetmantech Aug 30, 2024
fc7d7b8
I document /api/song/market
sweetmantech Aug 30, 2024
40659b0
Merge pull request #405 from Coop-Records/sweets/api-song-market
sweetmantech Aug 30, 2024
6986d33
I init fetchSongMarketForPost lib.
sweetmantech Aug 30, 2024
dbef928
I remove unused imports to fix build errors.
sweetmantech Aug 30, 2024
ca274c9
I remove dev logging.
sweetmantech Aug 30, 2024
e29f544
Merge pull request #406 from Coop-Records/sweets/tip-hook
sweetmantech Aug 30, 2024
e06b847
I init zora sdk.
sweetmantech Aug 31, 2024
e3bb3c0
I fix build errors by removing unused imports.
sweetmantech Aug 31, 2024
7eea1fc
I document new ENV variable in env example file.
sweetmantech Aug 31, 2024
5c05739
Merge pull request #407 from Coop-Records/sweets/zora
sweetmantech Aug 31, 2024
90e842e
I create collection on zora onTip.
sweetmantech Aug 31, 2024
3a2da15
I refactor ENV variable name to PRIVATE_KEY
sweetmantech Aug 31, 2024
64f4411
I init zora/createSongToken lib.
sweetmantech Aug 31, 2024
3e1380c
Merge pull request #408 from Coop-Records/sweets/pre-market
sweetmantech Aug 31, 2024
b4f305d
I update stack.so to latest package version.
sweetmantech Aug 31, 2024
b9e3514
I add SONG_MARKET_POINT_SYSTEM_ID for tracking song markets without m…
sweetmantech Aug 31, 2024
5d090ce
I update usage of stack.getEvents to use new query format.
sweetmantech Aug 31, 2024
e87e036
I rollback changes to lib/sonata/tip/marketHook.tsx
sweetmantech Aug 31, 2024
3c99dc1
I rollback changes to lib/stack/client.ts
sweetmantech Aug 31, 2024
2f118a6
I rollback changes to lib/stack/getDaysChannelTotalTips.ts
sweetmantech Aug 31, 2024
6521c6c
I remove unused Stack type. Replaces with official type definitions f…
sweetmantech Aug 31, 2024
6137632
I fix build errors.
sweetmantech Aug 31, 2024
b7b4bf0
I update /api/jobs/channels to fix build error.
sweetmantech Aug 31, 2024
24cc908
I fix same build error in lib/sonata/channelWeeklyAirdrop/distributeC…
sweetmantech Aug 31, 2024
2ae14d2
I fix build errors resulting from update of stack SDK.
sweetmantech Aug 31, 2024
eadca7d
Merge pull request #409 from Coop-Records/sweets/new-points-song-markets
sweetmantech Aug 31, 2024
339b75b
I init getStackClient lib.
sweetmantech Aug 31, 2024
ee4f650
I init new libs for generateTokenAddress & trackSetupNewToken
sweetmantech Aug 31, 2024
c8eb5fb
I set identity for the generated address.
sweetmantech Aug 31, 2024
232847e
I update /api/song/market to return the songLinks for any song.
sweetmantech Aug 31, 2024
d9fb1e8
I update leaderboard scores to include token metadata. I also include…
sweetmantech Aug 31, 2024
5dc3517
I remove dev logging.
sweetmantech Aug 31, 2024
8f26c66
I update stack client export to use new getStackClient lib.
sweetmantech Aug 31, 2024
a4a7bc2
I cleanup code with modular libs.
sweetmantech Aug 31, 2024
4e756fa
Merge pull request #410 from Coop-Records/sweets/track-tokens
sweetmantech Aug 31, 2024
fc668a2
I add ability to get points from newly created collections.
sweetmantech Sep 1, 2024
d1e21e2
I add logic to return contract / token information when querying for …
sweetmantech Sep 1, 2024
a68aa36
I fix collection.address param.
sweetmantech Sep 1, 2024
339b54f
I add collection.zora param.
sweetmantech Sep 1, 2024
3c72042
I rollback changes to lib/sonata/handleSongMarketCreated
sweetmantech Sep 1, 2024
196a69a
I rollback changes to lib/stack/trackSetupNewToken.
sweetmantech Sep 1, 2024
5e479f9
I init lib getSongMarketCollection
sweetmantech Sep 1, 2024
b8f0914
I create smallest libs possible for cleanest code.
sweetmantech Sep 1, 2024
29552f4
I fix build errors.
sweetmantech Sep 1, 2024
2a057c8
I fix error for false positives on youtube links.
sweetmantech Sep 1, 2024
16223ce
I simplify function logic.
sweetmantech Sep 1, 2024
3571064
Merge pull request #411 from Coop-Records/sweets/api-collection
sweetmantech Sep 1, 2024
7f1937e
I add progress bar on song page.
sweetmantech Sep 1, 2024
eb1d968
I remove dev logging.
sweetmantech Sep 1, 2024
6c1b24c
Merge pull request #412 from Coop-Records/sweets/progress
sweetmantech Sep 1, 2024
03e76b1
I add Buy on Zora button for live pre-markets.
sweetmantech Sep 1, 2024
1f929ed
I rollback changes to /api/song/market.
sweetmantech Sep 1, 2024
b9904cb
I remove dev logging.
sweetmantech Sep 1, 2024
91f16aa
I refactor useTotalNotes => useSongMarket.
sweetmantech Sep 1, 2024
2b9df61
I remove dev logging.
sweetmantech Sep 1, 2024
0967754
I rollback changes to lib/sonata/song/getSongMarketCollection.
sweetmantech Sep 1, 2024
a42e133
I rollback changes to lib/sonata/tip/marketHook.
sweetmantech Sep 1, 2024
91ee862
I rollback changes to lib/consts.tsx
sweetmantech Sep 1, 2024
92d4ff6
I fix calculation of totalNotes with valid array of embeds.
sweetmantech Sep 1, 2024
d147786
Merge pull request #413 from Coop-Records/sweets/zora-view
sweetmantech Sep 1, 2024
c4e6d5c
I fix markets so they are now showing up on leaderboard for spotify l…
sweetmantech Sep 1, 2024
f4f1c95
I rollback files with only dev logging
sweetmantech Sep 1, 2024
8924a26
I rollback unintended file change.
sweetmantech Sep 1, 2024
8d8a055
I cleanup useSongCasts.
sweetmantech Sep 1, 2024
5286aaa
I remove dev logging.{
sweetmantech Sep 1, 2024
ed6923b
I update trackSetupNewToken metadata to include more alternative link…
sweetmantech Sep 1, 2024
0da193c
I init filterStackSongLinks lib.
sweetmantech Sep 1, 2024
46ad278
I remove allowedDomains in favor of shared CONTENT_PLATFORMS for easi…
sweetmantech Sep 1, 2024
e2f96ac
implicit return.
sweetmantech Sep 1, 2024
ee51122
I fix broken tipping on a few posts missing authorFid.
sweetmantech Sep 1, 2024
1418c51
I remove dev logging.
sweetmantech Sep 1, 2024
ab1b917
I increase pre-req for collection creation to 1111 NOTES.
sweetmantech Sep 1, 2024
13152ed
Merge pull request #415 from Coop-Records/sweets/song-market-spotify
sweetmantech Sep 1, 2024
2853f29
I init /api/metadata endpoint.
sweetmantech Sep 2, 2024
a00c456
I document new metadata API.
sweetmantech Sep 2, 2024
a2cd40b
Merge pull request #416 from Coop-Records/sweets/metadata
sweetmantech Sep 2, 2024
30a439b
I update metadata to include animation_url and assign api endpoint fo…
sweetmantech Sep 2, 2024
a6c77da
I remove dev logging.
sweetmantech Sep 2, 2024
3363556
I remove dev logging.
sweetmantech Sep 2, 2024
96a63a5
Merge pull request #417 from Coop-Records/sweets/token-metadata
sweetmantech Sep 2, 2024
87f71c8
I simplify metadata.
sweetmantech Sep 2, 2024
66ca891
Merge pull request #418 from Coop-Records/sweets/metada-reduction
sweetmantech Sep 2, 2024
9414738
I prevent duplicate tokens.
sweetmantech Sep 2, 2024
23046a1
Merge pull request #419 from Coop-Records/sweets/duplicates
sweetmantech Sep 2, 2024
866d6b6
I update description to expected:
sweetmantech Sep 2, 2024
f307bbe
Merge pull request #420 from Coop-Records/sweets/description
sweetmantech Sep 2, 2024
0bfbaa3
I add <PrivyProvider /> with <ConnectButton /> and <CollectButton />
sweetmantech Sep 2, 2024
9d62c17
I create file with name SongPage for easier maintainability.
sweetmantech Sep 2, 2024
a51578a
I init <SongMarketSection /> component.
sweetmantech Sep 2, 2024
977947d
I refactor <ConnectButton /> label.
sweetmantech Sep 2, 2024
ec77627
Merge pull request #421 from Coop-Records/sweets/privy
sweetmantech Sep 2, 2024
1349b20
Hide progress on song page if token generated
arpitgupta1214 Sep 5, 2024
dddd2c3
Merge pull request #422 from Coop-Records/arpit/hide-progress-on-thre…
arpitgupta1214 Sep 5, 2024
590e7a2
update token sale strategy
arpitgupta1214 Sep 5, 2024
1c4cc8f
referral address added
arpitgupta1214 Sep 5, 2024
610a66c
add payout recipient
arpitgupta1214 Sep 6, 2024
7aa5145
Merge pull request #423 from Coop-Records/arpit/update-token-sale-str…
arpitgupta1214 Sep 6, 2024
ffb66a9
git push add buy button on song market
arpitgupta1214 Sep 10, 2024
bbacc7a
added new zora hooks for minting
arpitgupta1214 Sep 11, 2024
b43f7ac
use viem address type
arpitgupta1214 Sep 11, 2024
8093cc7
Merge pull request #425 from Coop-Records/arpit/add-buy-button
arpitgupta1214 Sep 11, 2024
0cde26b
reduce secondary market threshold for test
arpitgupta1214 Sep 12, 2024
d4a9e79
use default chain in viem public client
arpitgupta1214 Sep 13, 2024
cab969a
Merge branch 'main' into test
techeng322 Sep 13, 2024
5d43cec
I update test with main
techeng322 Sep 13, 2024
1334339
Merge pull request #427 from Coop-Records/arpit/reduce-test-mkt-thres…
arpitgupta1214 Sep 13, 2024
08a23aa
sell button ui added
arpitgupta1214 Sep 13, 2024
94803f2
Merge branch 'main' of github.com:SweetmanTech/sonata into test
arpitgupta1214 Sep 13, 2024
975d091
reduce test market countdown
arpitgupta1214 Sep 13, 2024
3f620f2
Merge pull request #430 from Coop-Records/arpit/reduce-test-countdown
arpitgupta1214 Sep 13, 2024
0aeb2f7
I complete home ui
techeng322 Sep 13, 2024
dd373ac
I fix lint error
techeng322 Sep 13, 2024
47bd628
I fix lint error
techeng322 Sep 13, 2024
0ec70b0
I fix lint error
techeng322 Sep 13, 2024
78527ca
I fix lint error
techeng322 Sep 13, 2024
15019b5
WIP
techeng322 Sep 13, 2024
b0e3a46
I trigger menu open on avatar
techeng322 Sep 13, 2024
eea25c7
I update sidebar
techeng322 Sep 13, 2024
ae05856
Merge pull request #426 from Coop-Records/arpit/sale-button-added
arpitgupta1214 Sep 13, 2024
ffd16c8
I fix feedback
techeng322 Sep 13, 2024
160afa3
I remove unused code
techeng322 Sep 13, 2024
7d73d16
I fix padding size
techeng322 Sep 13, 2024
eb0fede
I remove dev log
techeng322 Sep 13, 2024
26ca9d8
I fix home ui
techeng322 Sep 16, 2024
0a4f03e
Merge branch 'tech322/home-ui' into tech322/navbar
techeng322 Sep 16, 2024
bbf7981
I complete cast song ui
techeng322 Sep 16, 2024
30b1253
I complete cast song ui
techeng322 Sep 16, 2024
2b696b5
WIP
techeng322 Sep 16, 2024
4ccc4d9
I complete initial song page
techeng322 Sep 16, 2024
a558622
Revert "I complete initial song page"
techeng322 Sep 16, 2024
de84c49
Revert "WIP"
techeng322 Sep 16, 2024
c4e5e38
Reapply "WIP"
techeng322 Sep 16, 2024
c478509
Reapply "I complete initial song page"
techeng322 Sep 16, 2024
d60fb54
I add comment
techeng322 Sep 16, 2024
a179a2a
Merge branch 'test' of github.com:SweetmanTech/sonata into arpit/viem…
arpitgupta1214 Sep 16, 2024
aea4ff3
fix build
arpitgupta1214 Sep 16, 2024
5a5675c
Merge pull request #428 from Coop-Records/arpit/viem-client-chain
arpitgupta1214 Sep 16, 2024
4027fba
I fix feedback
techeng322 Sep 16, 2024
6f5becf
Merge pull request #431 from Coop-Records/tech322/home-ui
techeng322 Sep 17, 2024
3c6576c
Merge branch 'test' into tech322/navbar
techeng322 Sep 17, 2024
ea0512e
I fix build error
techeng322 Sep 17, 2024
3a8ebf3
Merge branch 'tech322/navbar' into tech322/cast-post
techeng322 Sep 17, 2024
d171605
Merge branch 'tech322/cast-post' into tech322/song-page
techeng322 Sep 17, 2024
0294c62
I fix text align
techeng322 Sep 17, 2024
d582364
WIP
techeng322 Sep 17, 2024
c80c07e
I complete channel ui
techeng322 Sep 17, 2024
72da460
I update profile page
techeng322 Sep 17, 2024
ffb9565
I fix feedback
techeng322 Sep 17, 2024
a6684e1
I fix feedback
techeng322 Sep 17, 2024
42e4ddc
Update Sidebar.tsx
techeng322 Sep 17, 2024
2ede213
I fix feedback
techeng322 Sep 17, 2024
7b92d3b
Merge branch 'tech322/navbar' into tech322/cast-post
techeng322 Sep 18, 2024
0908c92
Merge branch 'tech322/cast-post' into tech322/song-page
techeng322 Sep 18, 2024
966a030
Merge branch 'tech322/song-page' into tech322/channel-ui
techeng322 Sep 18, 2024
536e981
Merge branch 'tech322/channel-ui' into tech322/user-profile
techeng322 Sep 18, 2024
8d790d8
I remove background
techeng322 Sep 18, 2024
00338fd
I fix feedback
techeng322 Sep 18, 2024
217349a
I fix feedback
techeng322 Sep 18, 2024
369f0ad
I revert balance
techeng322 Sep 18, 2024
6b06fde
I fix lint error
techeng322 Sep 18, 2024
6ef258e
Merge branch 'test' of https://github.com/Coop-Records/sonata into te…
techeng322 Sep 18, 2024
f165c44
Merge pull request #432 from Coop-Records/tech322/navbar
techeng322 Sep 18, 2024
1a96361
I fix scrollbar
techeng322 Sep 18, 2024
5d89bfb
I fix input text color
techeng322 Sep 18, 2024
44dd4fa
I fix feedback
techeng322 Sep 18, 2024
34ef667
I fix build error
techeng322 Sep 18, 2024
871e7d4
I fix feedback
techeng322 Sep 18, 2024
7f0e092
I fix feedback
techeng322 Sep 18, 2024
16d9ccb
I fix lint error
techeng322 Sep 18, 2024
ce9529b
I fix feedback
techeng322 Sep 18, 2024
6dbafbb
I fix feedback
techeng322 Sep 18, 2024
2828f1d
I fix feedback
techeng322 Sep 18, 2024
f94ba31
I fix feedback
techeng322 Sep 18, 2024
d519630
I fix channel list
techeng322 Sep 18, 2024
64db838
I fix feedback
techeng322 Sep 18, 2024
4b1f467
I fix feedback
techeng322 Sep 18, 2024
42eb301
I fix feedback
techeng322 Sep 18, 2024
d649804
I fix conflict
techeng322 Sep 18, 2024
36f88fe
I fix conflict
techeng322 Sep 18, 2024
eed0293
Merge pull request #433 from Coop-Records/tech322/cast-post
techeng322 Sep 18, 2024
2395b5a
I fix feedback
techeng322 Sep 18, 2024
cbf7cba
I fix feedback
techeng322 Sep 18, 2024
b3dde71
I fix build eeror
techeng322 Sep 18, 2024
db95c3d
I fix feedback
techeng322 Sep 18, 2024
3ec89e6
Merge pull request #434 from Coop-Records/tech322/song-page
techeng322 Sep 18, 2024
9b7dfa8
Merge branch 'test' of https://github.com/Coop-Records/sonata into te…
techeng322 Sep 18, 2024
6889053
I fix conflict
techeng322 Sep 18, 2024
20130ec
I fix padding bottom
techeng322 Sep 18, 2024
b110160
limiting stack query to 99 rps in weeklyAirdrop
codesagecoder Sep 19, 2024
c4c7036
I fix feedback
techeng322 Sep 23, 2024
0895585
I fix feedback
techeng322 Sep 23, 2024
c5fa050
Merge branch 'test' of https://github.com/Coop-Records/sonata into te…
techeng322 Sep 23, 2024
409bed6
Merge pull request #435 from Coop-Records/tech322/channel-ui
techeng322 Sep 23, 2024
fe7aaaf
I fix header width
techeng322 Sep 23, 2024
86b0d19
Merge pull request #437 from Coop-Records/hotfix/weekly-airdrop-empty
codesagecoder Sep 23, 2024
e469009
I fix feedback
techeng322 Sep 23, 2024
4235e9a
I fix feedback
techeng322 Sep 23, 2024
33a3d90
Merge branch 'test' of https://github.com/Coop-Records/sonata into te…
techeng322 Sep 23, 2024
9290966
Merge pull request #436 from Coop-Records/tech322/user-profile
techeng322 Sep 23, 2024
eba57dd
I fix conflict
techeng322 Sep 23, 2024
629aadb
Merge pull request #438 from Coop-Records/tech322/remove-white
techeng322 Sep 23, 2024
c5fb6bb
I remove label
techeng322 Sep 23, 2024
b22ae11
I fix build error
techeng322 Sep 23, 2024
75ae600
Merge pull request #441 from Coop-Records/tech322/remove-music-text
techeng322 Sep 23, 2024
9ba50a1
secondary market functions added
arpitgupta1214 Sep 24, 2024
44256f1
remove dev logging
arpitgupta1214 Sep 25, 2024
59559d2
Merge pull request #442 from Coop-Records/arpit/secondary-market
arpitgupta1214 Sep 25, 2024
1335214
use cast progress from points
arpitgupta1214 Sep 25, 2024
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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
NEXT_PUBLIC_TEST=true
NEXT_PUBLIC_PRIVY_APP_ID=
PRIVATE_KEY=
NEXT_PUBLIC_NEYNAR_CLIENT_ID=
NEYNAR_CLIENT_ID=
NEYNAR_API_KEY=
Expand Down
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"prettier"
"prettier",
"plugin:@tanstack/eslint-plugin-query/recommended"
],
"rules": {
"no-prototype-builtins": "off",
Expand Down
5 changes: 2 additions & 3 deletions app/(feeds)/[username]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export default function ProfileHome() {
const tab = useSearchParams().get('tab');
const { loading, userStakes } = useUserStakes(tab, profile?.fid);

if (tab === 'stakes')
return loading ? <Loader /> : <UserStakes stakes={userStakes} />;
if (tab === 'stakes') return loading ? <Loader /> : <UserStakes stakes={userStakes} />;

return <Feeds />;
}
}
4 changes: 2 additions & 2 deletions app/(feeds)/channel/[channelId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Feeds from '@/app/(feeds)/feeds';
import ChannelPage from '@/components/ChannelPage';
import { CHANNELS } from '@/lib/consts';

export async function generateStaticParams() {
Expand All @@ -8,5 +8,5 @@ export async function generateStaticParams() {
}

export default function Channel() {
return <Feeds />;
return <ChannelPage />;
}
34 changes: 14 additions & 20 deletions app/(feeds)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,19 @@ import { Sheet, SheetContent } from '@/components/ui/sheet';
import { useUi } from '@/providers/UiProvider';
import Header from '@/components/Header';
import GlobalPlayer from '@/components/GlobalPlayer';
import CreatePost from '@/components/CreatePost';
import { useNeynarProvider } from '@/providers/NeynarProvider';
import FeedProvider from '@/providers/FeedProvider';
import ProfileProvider from '@/providers/ProfileProvider';
import { useParams } from 'next/navigation';
import TipsList from '@/components/TipsList';
import StakeProvider from '@/providers/StakeProvider';
import { cn } from '@/lib/utils';
import ChannelHeader from '@/components/Header/ChannelHeader';

export default function FeedLayout({ children }: { children: ReactNode }) {
const { menuOpen, setMenuOpen } = useUi();
const { username, channelId } = useParams();
const { user } = useNeynarProvider();
const enableMaxWidth = !channelId && !username;
const { setIsCastPostOpen } = useUi();

return (
<ProfileProvider>
<FeedProvider>
<StakeProvider>
<TipsList />
<div className="flex grow">
<div className="flex h-screen">
<meta property="of:accepts:xmtp" content="2024-02-01" />
<nav className="md:hidden">
<Sheet open={menuOpen} onOpenChange={setMenuOpen}>
Expand All @@ -41,19 +32,22 @@ export default function FeedLayout({ children }: { children: ReactNode }) {
<Sidebar />
</nav>

<main className="flex grow flex-col">
{!channelId && <Header />}
<div className="h-0 grow">
<div id="feed-container" className='size-full'>
{channelId && <ChannelHeader />}
<div className={cn('mt-4 container space-y-6', { 'max-w-3xl': enableMaxWidth })}>
{user && !username && !channelId && <CreatePost />}
{children}
</div>
<main className="flex flex-col h-full flex-col overflow-hidden w-full">
<Header />
<div className="h-0 grow overflow-y-hidden">
<div id="feed-container" className="size-full px-6 mt-4 space-y-6">
{children}
</div>
</div>
</main>
</div>
<button
type="button"
className="bg-blue fixed z-40 bottom-4 right-4 text-white text-[32px] w-16 h-16 rounded-full"
onClick={() => setIsCastPostOpen(true)}
>
+
</button>
<GlobalPlayer />
</StakeProvider>
</FeedProvider>
Expand Down
12 changes: 6 additions & 6 deletions app/api/channel/details/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import supabase from "@/lib/supabase/serverClient";
import { NextRequest } from "next/server";
import supabase from '@/lib/supabase/serverClient';
import { NextRequest } from 'next/server';

export async function GET(req: NextRequest) {
const channelId = req.nextUrl.searchParams.get('channelId');
Expand All @@ -16,20 +16,20 @@ export async function GET(req: NextRequest) {
.limit(1)
.single(),
supabase.rpc('get_channel_tips_balance', {
p_channelId: channelId
p_channelId: channelId,
}),
supabase
.from('channel_stake_stats')
.select('stakers,staked')
.eq('channelId', channelId)
.single()
.single(),
]);

return Response.json({
message: 'success',
topSong: topSong.data,
staking: stakeStats.data,
balance: balance.data ?? 0
balance: balance.data ?? 0,
});
} catch (error) {
console.error(error);
Expand All @@ -40,4 +40,4 @@ export async function GET(req: NextRequest) {

export const dynamic = 'force-dynamic';
export const fetchCache = 'force-no-store';
export const revalidate = 0;
export const revalidate = 0;
7 changes: 3 additions & 4 deletions app/api/channel/stake/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ export async function GET(req: NextRequest) {

const user = await getUser(Number(fid));

const stakedAmount = Math.abs(await getStackPoints(
user.verifications,
eventStakeChannelFid(channelId, user.fid)
));
const stakedAmount = Math.abs(
await getStackPoints(user.verifications, eventStakeChannelFid(channelId, user.fid)),
);

return Response.json({ message: 'success', stakedAmount });
} catch (error) {
Expand Down
12 changes: 7 additions & 5 deletions app/api/channel/stats/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sortChannels from "@/lib/sortChannels";
import getChannelStats from "@/lib/supabase/getChannelStats";
import getFidChannelStats from "@/lib/supabase/getFidChannelStats";
import { NextRequest } from "next/server";
import sortChannels from '@/lib/sortChannels';
import getChannelStats from '@/lib/supabase/getChannelStats';
import getFidChannelStats from '@/lib/supabase/getFidChannelStats';
import { NextRequest } from 'next/server';

export async function GET(req: NextRequest) {
const applyChannelFilter = req.nextUrl.searchParams.get('apply_channel_filter');
Expand All @@ -17,7 +17,9 @@ export async function GET(req: NextRequest) {
console.log('channelStats count', channelStats.length);

const allChannelStats = sortChannels(channelStats);
const channels = onlyChannelIds ? allChannelStats.map(channel => channel.channelId) : allChannelStats;
const channels = onlyChannelIds
? allChannelStats.map((channel) => channel.channelId)
: allChannelStats;

return Response.json({ message: 'success', channels });
}
Expand Down
4 changes: 2 additions & 2 deletions app/api/channel/weeklyAirdrop/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import getChannelWeeklyAirdropData from "@/lib/sonata/channelWeeklyAirdrop/getChannelWeeklyAirdropData";
import getChannelWeeklyAirdropData from '@/lib/sonata/channelWeeklyAirdrop/getChannelWeeklyAirdropData';

export async function GET() {
try {
Expand All @@ -11,4 +11,4 @@ export async function GET() {
}
}

export const dynamic = 'force-dynamic';
export const dynamic = 'force-dynamic';
71 changes: 38 additions & 33 deletions app/api/jobs/channels/route.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import distributeChannelStakerWeeklyAirdropAndTips from "@/lib/sonata/channelWeeklyAirdrop/distributeChannelStakerWeeklyAirdropAndTips";
import distributeChannelWeeklyAirdrop from "@/lib/sonata/channelWeeklyAirdrop/distributeChannelWeeklyAirdrop";
import sortChannels from "@/lib/sortChannels";
import { stack } from "@/lib/stack/client";
import { eventTipChannel } from "@/lib/stack/events";
import getDaysChannelTotalTips from "@/lib/stack/getDaysChannelTotalTips";
import getChannelStats from "@/lib/supabase/getChannelStats";
import supabase from "@/lib/supabase/serverClient";
import { NextRequest } from "next/server";
import distributeChannelStakerWeeklyAirdropAndTips from '@/lib/sonata/channelWeeklyAirdrop/distributeChannelStakerWeeklyAirdropAndTips';
import distributeChannelWeeklyAirdrop from '@/lib/sonata/channelWeeklyAirdrop/distributeChannelWeeklyAirdrop';
import sortChannels from '@/lib/sortChannels';
import { stack } from '@/lib/stack/client';
import { eventTipChannel } from '@/lib/stack/events';
import getDaysChannelTotalTips from '@/lib/stack/getDaysChannelTotalTips';
import getChannelStats from '@/lib/supabase/getChannelStats';
import supabase from '@/lib/supabase/serverClient';
import { NextRequest } from 'next/server';

export async function GET(req: NextRequest) {
const TOP_CHANNELS = 10;
Expand All @@ -24,34 +24,39 @@ export async function GET(req: NextRequest) {
const sortedChannels = sortChannels(channelStats);
sortedChannels.splice(TOP_CHANNELS);

const results = await Promise.all(sortedChannels.map(async (channel) => {
const channelId = channel.channelId;
const results = await Promise.all(
sortedChannels.map(async (channel) => {
const channelId = channel.channelId;

const balance = channel.staked ? await getDaysChannelTotalTips(channelId, 7) : 0;
const TIPS = channel.staked && (balance > 0) ? Math.floor(balance / 2) : 0;
const CHANNEL_AIRDROP = channel.staked ? Math.floor(AIRDROP_AMOUNT / 2) : AIRDROP_AMOUNT;
const STAKERS_AIRDROP = channel.staked ? TIPS + CHANNEL_AIRDROP : 0;
const balance = channel.staked ? await getDaysChannelTotalTips(channelId, 7) : 0;
const TIPS = channel.staked && balance > 0 ? Math.floor(balance / 2) : 0;
const CHANNEL_AIRDROP = channel.staked ? Math.floor(AIRDROP_AMOUNT / 2) : AIRDROP_AMOUNT;
const STAKERS_AIRDROP = channel.staked ? TIPS + CHANNEL_AIRDROP : 0;

const { account } = await distributeChannelWeeklyAirdrop(channel, CHANNEL_AIRDROP);
const { account } = await distributeChannelWeeklyAirdrop(channel, CHANNEL_AIRDROP);

if (STAKERS_AIRDROP) await distributeChannelStakerWeeklyAirdropAndTips(STAKERS_AIRDROP, channelId);
if (STAKERS_AIRDROP)
await distributeChannelStakerWeeklyAirdropAndTips(STAKERS_AIRDROP, channelId);

if (TIPS) {
const [result] = await Promise.all([
stack.track(eventTipChannel(channelId), { account, points: -TIPS }),
supabase.from('channel_tips_activity_log').insert({ amount: -TIPS, channelId, channelAddress: account })
]);
if (!result?.success) console.error(`${channelId} tip deduction failed`);
console.log('distributeChannelTip', channelId, TIPS);
}
if (TIPS) {
const [result] = await Promise.all([
stack.track(eventTipChannel(channelId), { account, points: -TIPS }),
supabase
.from('channel_tips_activity_log')
.insert({ amount: -TIPS, channelId, channelAddress: account }),
]);
if (!result?.success) console.error(`${channelId} tip deduction failed`);
console.log('distributeChannelTip', channelId, TIPS);
}

return {
channelId,
channelAirdropAmount: CHANNEL_AIRDROP,
channelTips: TIPS,
stakersAirdropAmount: STAKERS_AIRDROP
};
}));
return {
channelId,
channelAirdropAmount: CHANNEL_AIRDROP,
channelTips: TIPS,
stakersAirdropAmount: STAKERS_AIRDROP,
};
}),
);

return Response.json({ message: 'success', topChannels: results });
} catch (error) {
Expand All @@ -62,4 +67,4 @@ export async function GET(req: NextRequest) {

export const dynamic = 'force-dynamic';
export const fetchCache = 'force-no-store';
export const revalidate = 0;
export const revalidate = 0;
1 change: 0 additions & 1 deletion app/api/jobs/updateHypersub/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import processTipsBatch from '@/lib/hypersub/processTipsBatch';
import forEachTableRowsBatch from '@/lib/supabase/forEachTableRowsBatch';


export async function GET(): Promise<Response> {
try {
const res = await forEachTableRowsBatch('tips', 'fid, wallet_address', 3000, processTipsBatch);
Expand Down
25 changes: 25 additions & 0 deletions app/api/metadata/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { NextRequest, NextResponse } from 'next/server';
import fetchMetadata from '@/lib/fetchMetadata';
import { SupabasePost } from '@/types/SupabasePost';

export async function GET(req: NextRequest) {
const songLink = req.nextUrl.searchParams.get('songLink');
if (!songLink) {
return NextResponse.json({ error: 'songLink is required' }, { status: 400 });
}

try {
const metadata = await fetchMetadata(songLink, { id: 1 } as SupabasePost);
const external_url = `https://test-sonata.vercel.app/song/${songLink}`;
const response = {
external_url,
name: metadata.trackName,
image: metadata.artworkUrl,
description: `Listen to ${metadata.trackName} ${metadata.artistName && `by ${metadata.artistName} `}on Sonata - ${external_url}`,
};
return NextResponse.json(response, { status: 200 });
} catch (error) {
console.error('Error fetching song metadata:', error);
return NextResponse.json({ error: 'Failed to fetch song metadata' }, { status: 500 });
}
}
11 changes: 7 additions & 4 deletions app/api/neynar/getChannelDetails/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { NextRequest } from "next/server";
import { NextRequest } from 'next/server';

const options: any = {
method: 'GET',
headers: { accept: 'application/json', api_key: process.env.NEYNAR_API_KEY }
headers: { accept: 'application/json', api_key: process.env.NEYNAR_API_KEY },
};

export async function GET(req: NextRequest) {
Expand All @@ -13,7 +13,10 @@ export async function GET(req: NextRequest) {

const queryParams = new URLSearchParams({ id: channelId, type: 'id' });

const response = await fetch('https://api.neynar.com/v2/farcaster/channel?' + queryParams.toString(), options);
const response = await fetch(
'https://api.neynar.com/v2/farcaster/channel?' + queryParams.toString(),
options,
);

if (!response.ok) throw Error(response.statusText);

Expand All @@ -26,4 +29,4 @@ export async function GET(req: NextRequest) {
}
}

export const revalidate = 600;
export const revalidate = 600;
2 changes: 1 addition & 1 deletion app/api/neynar/getUser/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function GET(req: NextRequest): Promise<Response> {
}

try {
const users = await getBulkUsersByFid(fids)
const users = await getBulkUsersByFid(fids);
return Response.json({ users });
} catch (error) {
console.error(error);
Expand Down
22 changes: 11 additions & 11 deletions app/api/postMusicEmbed/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const getResponse = async (req: NextRequest) => {
const body = await req.json();
const { signer_uuid, url, channel_id } = body;

if (!(signer_uuid && url)) return Response
.json({ message: 'signer_uuid & url required' }, { status: 400 });
if (!(signer_uuid && url))
return Response.json({ message: 'signer_uuid & url required' }, { status: 400 });

const data = await postMusicEmbed(signer_uuid, url, channel_id);

Expand All @@ -30,18 +30,18 @@ const getResponse = async (req: NextRequest) => {
};
const { success } = await upsertCast(cast);

if (!success) return Response.json(
{ message: 'successfuly casted', data },
{ status: 200 }
);
if (!success) return Response.json({ message: 'successfuly casted', data }, { status: 200 });
sendBotCast(cast);

return Response.json({
message: 'successfuly casted and indexed',
link: `/cast/${cast.author.username}/${cast.hash.substring(0, 8)}`
}, { status: 307 });
return Response.json(
{
message: 'successfuly casted and indexed',
link: `/cast/${cast.author.username}/${cast.hash.substring(0, 8)}`,
},
{ status: 307 },
);
};

export async function POST(req: NextRequest) {
return getResponse(req);
}
}
Loading