forked from aldrin-labs/opensvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0feb4c0
commit b1bb734
Showing
9 changed files
with
863 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import { ImageResponse } from '@vercel/og'; | ||
import { getAccountInfo } from '@/lib/solana'; | ||
|
||
export const runtime = 'edge'; | ||
export const alt = 'Account Details'; | ||
export const size = { | ||
width: 1200, | ||
height: 630, | ||
}; | ||
export const contentType = 'image/png'; | ||
|
||
export default async function Image({ params }: { params: { address: string } }) { | ||
try { | ||
const account = await getAccountInfo(params.address); | ||
|
||
const title = 'Account Overview'; | ||
const description = account | ||
? `Balance: ${account.balance.toFixed(4)} SOL` | ||
: 'Solana Account Explorer'; | ||
|
||
return new ImageResponse( | ||
( | ||
<div | ||
style={{ | ||
height: '100%', | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: '#000', | ||
backgroundImage: 'linear-gradient(45deg, #000 0%, #111 100%)', | ||
}} | ||
> | ||
{/* Logo */} | ||
<div | ||
style={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
marginBottom: '20px', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
width: '80px', | ||
height: '80px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
borderRadius: '50%', | ||
background: 'linear-gradient(135deg, #00ffbd 0%, #00b386 100%)', | ||
marginRight: '16px', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
color: 'white', | ||
fontSize: '40px', | ||
fontWeight: 700, | ||
}} | ||
> | ||
S | ||
</div> | ||
</div> | ||
<div | ||
style={{ | ||
fontSize: '48px', | ||
fontWeight: 700, | ||
background: 'linear-gradient(135deg, #00ffbd 0%, #00b386 100%)', | ||
backgroundClip: 'text', | ||
color: 'transparent', | ||
}} | ||
> | ||
OPENSVM | ||
</div> | ||
</div> | ||
|
||
{/* Content */} | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
marginTop: '20px', | ||
padding: '0 48px', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
fontSize: '32px', | ||
fontWeight: 600, | ||
color: 'white', | ||
marginBottom: '10px', | ||
textAlign: 'center', | ||
}} | ||
> | ||
{title} | ||
</div> | ||
{account && ( | ||
<div | ||
style={{ | ||
fontSize: '24px', | ||
color: '#00ffbd', | ||
marginBottom: '20px', | ||
textAlign: 'center', | ||
}} | ||
> | ||
{account.executable ? 'Program Account' : 'User Account'} | ||
</div> | ||
)} | ||
<div | ||
style={{ | ||
fontSize: '20px', | ||
color: '#888', | ||
textAlign: 'center', | ||
maxWidth: '600px', | ||
}} | ||
> | ||
{description} | ||
</div> | ||
{account && ( | ||
<div | ||
style={{ | ||
fontSize: '16px', | ||
color: '#666', | ||
marginTop: '20px', | ||
textAlign: 'center', | ||
}} | ||
> | ||
{params.address.slice(0, 20)}...{params.address.slice(-20)} | ||
</div> | ||
)} | ||
</div> | ||
|
||
{/* Footer */} | ||
<div | ||
style={{ | ||
position: 'absolute', | ||
bottom: '32px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
fontSize: '16px', | ||
color: '#666', | ||
}} | ||
> | ||
opensvm.com | ||
</div> | ||
</div> | ||
</div> | ||
), | ||
{ | ||
width: 1200, | ||
height: 630, | ||
}, | ||
); | ||
} catch (e: any) { | ||
console.log(`${e.message}`); | ||
return new Response(`Failed to generate the image`, { | ||
status: 500, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
import { ImageResponse } from '@vercel/og'; | ||
import { NextRequest } from 'next/server'; | ||
|
||
export const runtime = 'edge'; | ||
|
||
export async function GET(req: NextRequest) { | ||
try { | ||
const { searchParams } = new URL(req.url); | ||
|
||
// Dynamic params | ||
const title = searchParams.get('title') || 'OPENSVM'; | ||
const description = searchParams.get('description') || 'Open Source Solana Virtual Machine Explorer'; | ||
const type = searchParams.get('type') || ''; | ||
|
||
return new ImageResponse( | ||
( | ||
<div | ||
style={{ | ||
height: '100%', | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
backgroundColor: '#000', | ||
backgroundImage: 'linear-gradient(45deg, #000 0%, #111 100%)', | ||
}} | ||
> | ||
{/* Logo */} | ||
<div | ||
style={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
marginBottom: '20px', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
width: '80px', | ||
height: '80px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
borderRadius: '50%', | ||
background: 'linear-gradient(135deg, #00ffbd 0%, #00b386 100%)', | ||
marginRight: '16px', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
color: 'white', | ||
fontSize: '40px', | ||
fontWeight: 700, | ||
}} | ||
> | ||
S | ||
</div> | ||
</div> | ||
<div | ||
style={{ | ||
fontSize: '48px', | ||
fontWeight: 700, | ||
background: 'linear-gradient(135deg, #00ffbd 0%, #00b386 100%)', | ||
backgroundClip: 'text', | ||
color: 'transparent', | ||
}} | ||
> | ||
OPENSVM | ||
</div> | ||
</div> | ||
|
||
{/* Content */} | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
marginTop: '20px', | ||
padding: '0 48px', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
fontSize: '32px', | ||
fontWeight: 600, | ||
color: 'white', | ||
marginBottom: '10px', | ||
textAlign: 'center', | ||
}} | ||
> | ||
{title} | ||
</div> | ||
{type && ( | ||
<div | ||
style={{ | ||
fontSize: '24px', | ||
color: '#00ffbd', | ||
marginBottom: '20px', | ||
textAlign: 'center', | ||
}} | ||
> | ||
{type} | ||
</div> | ||
)} | ||
<div | ||
style={{ | ||
fontSize: '20px', | ||
color: '#888', | ||
textAlign: 'center', | ||
maxWidth: '600px', | ||
}} | ||
> | ||
{description} | ||
</div> | ||
</div> | ||
|
||
{/* Footer */} | ||
<div | ||
style={{ | ||
position: 'absolute', | ||
bottom: '32px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
fontSize: '16px', | ||
color: '#666', | ||
}} | ||
> | ||
opensvm.com | ||
</div> | ||
</div> | ||
</div> | ||
), | ||
{ | ||
width: 1200, | ||
height: 630, | ||
}, | ||
); | ||
} catch (e: any) { | ||
console.log(`${e.message}`); | ||
return new Response(`Failed to generate the image`, { | ||
status: 500, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.