Skip to content

Commit 4fb5bed

Browse files
authored
Merge pull request #135 from pkgxdev/add-dynamic-data
add dynamic blockscout data
2 parents 8ec42ac + f9aa5ab commit 4fb5bed

2 files changed

Lines changed: 70 additions & 8 deletions

File tree

lambda/assam-api.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// AWS Lambda: assam-api
2+
/// this works around CORS issues
3+
/// Note: NO automated deployment at this time
4+
/// https://640264234305-o2elkm5e.us-east-1.console.aws.amazon.com/lambda/home?region=us-east-1#/functions/assam-api?newFunction=true&subtab=url&tab=code
5+
6+
/// https://yo2fkzmf2rh33u2b3bi3xhtqyi0toyqz.lambda-url.us-east-1.on.aws/?url={url}
7+
/// see: https://assam.tea.xyz/api-docs
8+
9+
export const handler = async (event) => {
10+
const targetUrl = event.queryStringParameters?.url;
11+
12+
const response = await fetch('https://assam.tea.xyz/api/v2' + targetUrl, {
13+
headers: {
14+
'Origin': 'https://assam.tea.xyz',
15+
'Accept': 'application/json'
16+
}
17+
});
18+
19+
const data = await response.json();
20+
21+
return {
22+
statusCode: 200,
23+
headers: {
24+
'Access-Control-Allow-Origin': 'https://pkgx.dev',
25+
'Content-Type': 'application/json'
26+
},
27+
body: JSON.stringify(data)
28+
};
29+
};

src/pkgx.dev/TeaProtocol.tsx

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ import { Container, Grid, Typography, Button, Box, Link, Stack } from "@mui/mate
33
import teaImage from "../../public/imgs/tea-icon.svg"; // Hero Image
44
import backgroundPattern from "../assets/pkgx-bg-pattern-right.svg"; // Full-Page Background Image
55

6-
// Social Proof Data
7-
const socialProofData = [
8-
{ number: "1,212,925", label: "Total Blocks" },
9-
{ number: "2.17M", label: "Daily Transactions" },
10-
{ number: "72,160,103", label: "Total Transactions" },
11-
{ number: "81,122,220", label: "Wallet Addresses" },
12-
];
13-
146
// Feature Section Data
157
const features = [
168
{ title: "A New Brew: The Journey From Homebrew to tea", description: "Homebrew changed how developers managed software. Now, tea is evolving the model for the open-source era—not just packaging software but packaging incentives. By leveraging smart contracts, tokenized rewards, and a global dependency tree, tea ensures that contributions are recognized, ranked, and rewarded across the entire open-source stack." },
@@ -19,7 +11,48 @@ const features = [
1911
{ title: "Open Source Should Be Rewarding. Now It Is.", description: "For too long, open source has been powered by passion, not paychecks. tea is changing the economics of open source, ensuring that every maintainer, contributor, and developer gets their fair share. Whether through staking, governance, or direct rewards, tea.xyz is about sustaining open source for the long run—so you can keep building, innovating, and, of course, sipping the tea." }
2012
];
2113

14+
interface TeaStats {
15+
totalBlocks: string;
16+
dailyTransactions: string;
17+
totalTransactions: string;
18+
walletAddresses: string;
19+
}
20+
2221
const TeaProtocol = () => {
22+
const [stats, setStats] = React.useState<TeaStats | null>(null);
23+
24+
React.useEffect(() => {
25+
const fetchTeaStats = async () => {
26+
// lambda proxy to bypass CORS
27+
const response = await fetch(`https://yo2fkzmf2rh33u2b3bi3xhtqyi0toyqz.lambda-url.us-east-1.on.aws/?url=/stats`);
28+
console.log(response);
29+
const data = await response.json();
30+
console.log(data);
31+
32+
setStats({
33+
totalBlocks: parseInt(data.total_blocks).toLocaleString(),
34+
dailyTransactions: `${(parseInt(data.transactions_today) / 1000000).toFixed(2)}M`,
35+
totalTransactions: parseInt(data.total_transactions).toLocaleString(),
36+
walletAddresses: parseInt(data.total_addresses).toLocaleString()
37+
});
38+
};
39+
40+
fetchTeaStats();
41+
}, []);
42+
43+
// Social Proof Data
44+
const socialProofData = stats ? [
45+
{ number: stats.totalBlocks, label: "Total Blocks" },
46+
{ number: stats.dailyTransactions, label: "Daily Transactions" },
47+
{ number: stats.totalTransactions, label: "Total Transactions" },
48+
{ number: stats.walletAddresses, label: "Wallet Addresses" },
49+
] : [
50+
{ number: "1,212,925", label: "Total Blocks" },
51+
{ number: "2.17M", label: "Daily Transactions" },
52+
{ number: "72,160,103", label: "Total Transactions" },
53+
{ number: "81,122,220", label: "Wallet Addresses" },
54+
];
55+
2356
return (
2457
<Box
2558
sx={{

0 commit comments

Comments
 (0)