Skip to content

Commit eed943c

Browse files
authored
Merge pull request #47 from SolanaCore/client/#45
fixed: unmerged files
2 parents 3cf6096 + ab1e833 commit eed943c

File tree

15 files changed

+2978
-2441
lines changed

15 files changed

+2978
-2441
lines changed

blinks/package-lock.json

Lines changed: 743 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blinks/package.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev --turbopack",
6+
"dev": "next dev",
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12+
"@solana/actions": "^1.6.6",
13+
"@solana/web3.js": "^1.98.2",
14+
"next": "15.3.4",
1215
"react": "^19.0.0",
13-
"react-dom": "^19.0.0",
14-
"next": "15.3.3"
16+
"react-dom": "^19.0.0"
1517
},
1618
"devDependencies": {
17-
"typescript": "^5",
19+
"@eslint/eslintrc": "^3",
20+
"@tailwindcss/postcss": "^4",
1821
"@types/node": "^20",
1922
"@types/react": "^19",
2023
"@types/react-dom": "^19",
21-
"@tailwindcss/postcss": "^4",
22-
"tailwindcss": "^4",
2324
"eslint": "^9",
24-
"eslint-config-next": "15.3.3",
25-
"@eslint/eslintrc": "^3"
25+
"eslint-config-next": "15.3.4",
26+
"tailwindcss": "^4",
27+
"typescript": "^5"
2628
}
2729
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { ACTIONS_CORS_HEADERS, ActionsJson } from "@solana/actions";
2+
3+
export const GET = async () => {
4+
const payload: ActionsJson = {
5+
rules: [
6+
// map all root level routes to an action
7+
{
8+
pathPattern: "/",
9+
apiPath: "/api/donate/",
10+
},
11+
],
12+
};
13+
14+
return Response.json(payload, {
15+
headers: ACTIONS_CORS_HEADERS,
16+
});
17+
};
18+
19+
// DO NOT FORGET TO INCLUDE THE `OPTIONS` HTTP METHOD
20+
// THIS WILL ENSURE CORS WORKS FOR BLINKS
21+
export const OPTIONS = GET;
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import {
2+
ACTIONS_CORS_HEADERS, // Importing CORS headers for actions
3+
ActionGetResponse, // Type for GET response
4+
ActionPostRequest, // Type for POST request
5+
ActionPostResponse, // Type for POST response
6+
createPostResponse, // Function to create a POST response
7+
} from "@solana/actions";
8+
9+
import {
10+
Connection, // Class for Solana network connection
11+
LAMPORTS_PER_SOL, // Constant for lamports to SOL conversion
12+
PublicKey, // Class for handling public keys
13+
SystemProgram, // System program for basic transactions
14+
Transaction, // Class for creating transactions
15+
clusterApiUrl, // Function to get cluster API URL
16+
} from "@solana/web3.js";
17+
18+
export async function GET(request: Request) {
19+
const url = new URL(request.url); // Parse the request URL
20+
const payload: ActionGetResponse = {
21+
// Define the GET response payload
22+
icon: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS7dPPWr-BRKzBy_Fig0v_snt-_onQj9Pl5xA&s", // Icon URL
23+
title: "Donate to the Rahul", // Title
24+
description: "Support rahul by donating SOL.", // Description
25+
label: "Donate", // Label for the action
26+
links: {
27+
actions: [
28+
{
29+
label: "Donate 0.1 SOL", // Action label
30+
href: `${url.href}?amount=0.1`, // Action URL with amount parameter
31+
},
32+
],
33+
},
34+
};
35+
return Response.json(payload, {
36+
headers: ACTIONS_CORS_HEADERS, // Set CORS headers
37+
});
38+
}
39+
40+
export const OPTIONS = GET; // Allow OPTIONS request to use GET handler
41+
42+
export async function POST(request: Request) {
43+
const body: ActionPostRequest = await request.json(); // Parse the request body
44+
const url = new URL(request.url); // Parse the request URL
45+
const amount = Number(url.searchParams.get("amount")) || 0.1; // Get the amount from query params or default to 0.1
46+
let sender;
47+
48+
try {
49+
sender = new PublicKey(body.account); // Parse the sender public key
50+
} catch (error) {
51+
return Response.json(
52+
{
53+
error: {
54+
message: "Invalid account", // Return error if invalid account
55+
},
56+
},
57+
{
58+
status: 400, // Bad request status
59+
headers: ACTIONS_CORS_HEADERS, // Set CORS headers
60+
}
61+
);
62+
}
63+
64+
const connection = new Connection(clusterApiUrl("mainnet-beta"), "confirmed"); // Create a connection to the mainnet-beta cluster
65+
66+
const transaction = new Transaction().add(
67+
SystemProgram.transfer({
68+
fromPubkey: sender, // Sender public key
69+
toPubkey: new PublicKey("address"), // Recipient public key
70+
lamports: amount * LAMPORTS_PER_SOL, // Amount to transfer in lamports
71+
})
72+
);
73+
transaction.feePayer = sender; // Set the fee payer
74+
transaction.recentBlockhash = (
75+
await connection.getLatestBlockhash()
76+
).blockhash; // Get the latest blockhash
77+
transaction.lastValidBlockHeight = (
78+
await connection.getLatestBlockhash()
79+
).lastValidBlockHeight; // Get the last valid block height
80+
81+
const payload: ActionPostResponse = await createPostResponse({
82+
fields: {
83+
transaction, // Add the transaction to the response payload
84+
message: "Transaction created", // Success message
85+
},
86+
});
87+
return new Response(JSON.stringify(payload), {
88+
headers: ACTIONS_CORS_HEADERS, // Set CORS headers
89+
});
90+
}

blinks/src/app/page.tsx

Lines changed: 83 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,102 +2,112 @@ import Image from "next/image";
22

33
export default function Home() {
44
return (
5-
<div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
6-
<main className="flex flex-col gap-[32px] row-start-2 items-center sm:items-start">
7-
<Image
8-
className="dark:invert"
9-
src="/next.svg"
10-
alt="Next.js logo"
11-
width={180}
12-
height={38}
13-
priority
14-
/>
15-
<ol className="list-inside list-decimal text-sm/6 text-center sm:text-left font-[family-name:var(--font-geist-mono)]">
16-
<li className="mb-2 tracking-[-.01em]">
17-
Get started by editing{" "}
18-
<code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-[family-name:var(--font-geist-mono)] font-semibold">
19-
src/app/page.tsx
20-
</code>
21-
.
22-
</li>
23-
<li className="tracking-[-.01em]">
24-
Save and see your changes instantly.
25-
</li>
26-
</ol>
27-
28-
<div className="flex gap-4 items-center flex-col sm:flex-row">
5+
<main className="flex min-h-screen flex-col items-center justify-between p-24">
6+
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">
7+
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
8+
Get started by editing&nbsp;
9+
<code className="font-mono font-bold">src/app/page.tsx</code>
10+
</p>
11+
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:size-auto lg:bg-none">
2912
<a
30-
className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] font-medium text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:w-auto"
31-
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
13+
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
14+
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
3215
target="_blank"
3316
rel="noopener noreferrer"
3417
>
18+
By{" "}
3519
<Image
36-
className="dark:invert"
3720
src="/vercel.svg"
38-
alt="Vercel logomark"
39-
width={20}
40-
height={20}
21+
alt="Vercel Logo"
22+
className="dark:invert"
23+
width={100}
24+
height={24}
25+
priority
4126
/>
42-
Deploy now
43-
</a>
44-
<a
45-
className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent font-medium text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 w-full sm:w-auto md:w-[158px]"
46-
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
47-
target="_blank"
48-
rel="noopener noreferrer"
49-
>
50-
Read our docs
5127
</a>
5228
</div>
53-
</main>
54-
<footer className="row-start-3 flex gap-[24px] flex-wrap items-center justify-center">
29+
</div>
30+
31+
<div className="relative z-[-1] flex place-items-center before:absolute before:h-[300px] before:w-full before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 sm:before:w-[480px] sm:after:w-[240px] before:lg:h-[360px]">
32+
<Image
33+
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
34+
src="/next.svg"
35+
alt="Next.js Logo"
36+
width={180}
37+
height={37}
38+
priority
39+
/>
40+
</div>
41+
42+
<div className="mb-32 grid text-center lg:mb-0 lg:w-full lg:max-w-5xl lg:grid-cols-4 lg:text-left">
43+
<a
44+
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
45+
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
46+
target="_blank"
47+
rel="noopener noreferrer"
48+
>
49+
<h2 className="mb-3 text-2xl font-semibold">
50+
Docs{" "}
51+
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
52+
-&gt;
53+
</span>
54+
</h2>
55+
<p className="m-0 max-w-[30ch] text-sm opacity-50">
56+
Find in-depth information about Next.js features and API.
57+
</p>
58+
</a>
59+
5560
<a
56-
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
5761
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
62+
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
5863
target="_blank"
5964
rel="noopener noreferrer"
6065
>
61-
<Image
62-
aria-hidden
63-
src="/file.svg"
64-
alt="File icon"
65-
width={16}
66-
height={16}
67-
/>
68-
Learn
66+
<h2 className="mb-3 text-2xl font-semibold">
67+
Learn{" "}
68+
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
69+
-&gt;
70+
</span>
71+
</h2>
72+
<p className="m-0 max-w-[30ch] text-sm opacity-50">
73+
Learn about Next.js in an interactive course with&nbsp;quizzes!
74+
</p>
6975
</a>
76+
7077
<a
71-
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
72-
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
78+
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
79+
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
7380
target="_blank"
7481
rel="noopener noreferrer"
7582
>
76-
<Image
77-
aria-hidden
78-
src="/window.svg"
79-
alt="Window icon"
80-
width={16}
81-
height={16}
82-
/>
83-
Examples
83+
<h2 className="mb-3 text-2xl font-semibold">
84+
Templates{" "}
85+
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
86+
-&gt;
87+
</span>
88+
</h2>
89+
<p className="m-0 max-w-[30ch] text-sm opacity-50">
90+
Explore starter templates for Next.js.
91+
</p>
8492
</a>
93+
8594
<a
86-
className="flex items-center gap-2 hover:underline hover:underline-offset-4"
87-
href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
95+
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
96+
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
8897
target="_blank"
8998
rel="noopener noreferrer"
9099
>
91-
<Image
92-
aria-hidden
93-
src="/globe.svg"
94-
alt="Globe icon"
95-
width={16}
96-
height={16}
97-
/>
98-
Go to nextjs.org →
100+
<h2 className="mb-3 text-2xl font-semibold">
101+
Deploy{" "}
102+
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
103+
-&gt;
104+
</span>
105+
</h2>
106+
<p className="m-0 max-w-[30ch] text-balance text-sm opacity-50">
107+
Instantly deploy your Next.js site to a shareable URL with Vercel.
108+
</p>
99109
</a>
100-
</footer>
101-
</div>
110+
</div>
111+
</main>
102112
);
103-
}
113+
}

0 commit comments

Comments
 (0)