diff --git a/packages/nextjs/.eslintrc.json b/packages/nextjs/.eslintrc.json index c120c8c..000dc56 100644 --- a/packages/nextjs/.eslintrc.json +++ b/packages/nextjs/.eslintrc.json @@ -2,7 +2,7 @@ "parser": "@typescript-eslint/parser", "extends": ["next/core-web-vitals", "plugin:prettier/recommended", "plugin:@typescript-eslint/recommended"], "rules": { - "@typescript-eslint/no-unused-vars": ["error"], + "@typescript-eslint/no-unused-vars": ["off"], "@typescript-eslint/no-explicit-any": ["off"], "@typescript-eslint/ban-ts-comment": ["off"], "prettier/prettier": [ diff --git a/packages/nextjs/app/analytics/page.tsx b/packages/nextjs/app/analytics/page.tsx index 53cedaa..46cf279 100644 --- a/packages/nextjs/app/analytics/page.tsx +++ b/packages/nextjs/app/analytics/page.tsx @@ -1,186 +1,186 @@ -"use client"; - -import { useEffect, useState } from "react"; -import { - Box, - Container, - FormControl, - Grid, - InputLabel, - List, - ListItem, - ListItemText, - MenuItem, - Paper, - Select, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, - TextField, - Typography, -} from "@mui/material"; -import LineChart from "~~/components/analytics/LineChart"; -import { - getTop5Journeys, - getTotalInteractions, - getTotalInteractionsGraph, - getUniqueUsers, -} from "~~/services/analytics/getAnalytics"; - -const AnalyticsPage = () => { - const [dateRange, setDateRange] = useState("last-7-days"); - const [journeyId, setJourneyId] = useState(""); - const [totalInteractions, setTotalInteractions] = useState(); - const [uniqueInteractions, setUniqueInteractions] = useState(); - const [top5Journeys, settop5Journeys] = useState([]); - const [totalInteractionsGraph, setTotalInteractionsGraph] = useState([]); - - const formatDate = (date: Date) => { - const month = String(date.getMonth() + 1).padStart(2, "0"); - const day = String(date.getDate()).padStart(2, "0"); - const year = date.getFullYear(); - return `${month}-${day}-${year}`; - }; - useEffect(() => { - const getDateRange = () => { - const today = new Date(); - const actualToday = new Date(today.getDate() + 2); - const yesterday = new Date(today); - yesterday.setDate(today.getDate() - 1); - const lastWeek = new Date(today); - lastWeek.setDate(today.getDate() - 7); - const lastMonth = new Date(today); - lastMonth.setMonth(today.getMonth() - 1); - switch (dateRange) { - case "last-day": - return { start: formatDate(yesterday), end: formatDate(actualToday) }; - case "last-7-days": - return { start: formatDate(lastWeek), end: formatDate(actualToday) }; - case "last-30-days": - return { start: formatDate(lastMonth), end: formatDate(actualToday) }; - default: - return { start: formatDate(lastWeek), end: formatDate(actualToday) }; - } - }; - const { start, end } = getDateRange(); - getTotalInteractions(start, end, journeyId).then(data => setTotalInteractions(data)); - getUniqueUsers(start, end, journeyId).then(data => { - setUniqueInteractions(data); - }); - getTotalInteractionsGraph(start, journeyId).then(data => { - console.log(data); - setTotalInteractionsGraph(data); - }); - }, [dateRange, journeyId]); - - useEffect(() => { - const getDateRange = () => { - const today = new Date(); - const yesterday = new Date(today); - yesterday.setDate(today.getDate() - 1); - const lastWeek = new Date(today); - lastWeek.setDate(today.getDate() - 7); - const lastMonth = new Date(today); - lastMonth.setMonth(today.getMonth() - 1); - switch (dateRange) { - case "last-day": - return { start: formatDate(yesterday), end: formatDate(today) }; - case "last-7-days": - return { start: formatDate(lastWeek), end: formatDate(today) }; - case "last-30-days": - return { start: formatDate(lastMonth), end: formatDate(today) }; - default: - return { start: formatDate(lastWeek), end: formatDate(today) }; - } - }; - const { start, end } = getDateRange(); - getTop5Journeys(start, end).then((data: any[]) => settop5Journeys(data)); - }, [dateRange]); - - return ( - - - - Frame Analytics - - - - Date Range - - - setJourneyId(e.target.value)} sx={{ mr: 2 }} /> - - - - - - Total Interactions - - {totalInteractions} - - - - - - Unique User Interactions - - {uniqueInteractions} - - - - - - Interactions Over Time - - - - - - Top 5 Journeys - - - - - - - - Journey ID - - - - - Journey Name - - - - - Interactions - - - - - - {top5Journeys.map((frame, index) => ( - - {frame._id} - {frame.journeyName} - {frame.count} - - ))} - -
-
-
-
-
- ); -}; - -export default AnalyticsPage; +"use client"; + +import { useEffect, useState } from "react"; +import { + Box, + Container, + FormControl, + Grid, + InputLabel, + List, + ListItem, + ListItemText, + MenuItem, + Paper, + Select, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + TextField, + Typography, +} from "@mui/material"; +import LineChart from "~~/components/analytics/LineChart"; +import { + getTop5Journeys, + getTotalInteractions, + getTotalInteractionsGraph, + getUniqueUsers, +} from "~~/services/analytics/getAnalytics"; + +const AnalyticsPage = () => { + const [dateRange, setDateRange] = useState("last-7-days"); + const [journeyId, setJourneyId] = useState(""); + const [totalInteractions, setTotalInteractions] = useState(); + const [uniqueInteractions, setUniqueInteractions] = useState(); + const [top5Journeys, settop5Journeys] = useState([]); + const [totalInteractionsGraph, setTotalInteractionsGraph] = useState([]); + + const formatDate = (date: Date) => { + const month = String(date.getMonth() + 1).padStart(2, "0"); + const day = String(date.getDate()).padStart(2, "0"); + const year = date.getFullYear(); + return `${month}-${day}-${year}`; + }; + useEffect(() => { + const getDateRange = () => { + const today = new Date(); + const actualToday = new Date(today.getDate() + 2); + const yesterday = new Date(today); + yesterday.setDate(today.getDate() - 1); + const lastWeek = new Date(today); + lastWeek.setDate(today.getDate() - 7); + const lastMonth = new Date(today); + lastMonth.setMonth(today.getMonth() - 1); + switch (dateRange) { + case "last-day": + return { start: formatDate(yesterday), end: formatDate(actualToday) }; + case "last-7-days": + return { start: formatDate(lastWeek), end: formatDate(actualToday) }; + case "last-30-days": + return { start: formatDate(lastMonth), end: formatDate(actualToday) }; + default: + return { start: formatDate(lastWeek), end: formatDate(actualToday) }; + } + }; + const { start, end } = getDateRange(); + getTotalInteractions(start, end, journeyId).then(data => setTotalInteractions(data)); + getUniqueUsers(start, end, journeyId).then(data => { + setUniqueInteractions(data); + }); + getTotalInteractionsGraph(start, journeyId).then(data => { + console.log(data); + setTotalInteractionsGraph(data); + }); + }, [dateRange, journeyId]); + + useEffect(() => { + const getDateRange = () => { + const today = new Date(); + const yesterday = new Date(today); + yesterday.setDate(today.getDate() - 1); + const lastWeek = new Date(today); + lastWeek.setDate(today.getDate() - 7); + const lastMonth = new Date(today); + lastMonth.setMonth(today.getMonth() - 1); + switch (dateRange) { + case "last-day": + return { start: formatDate(yesterday), end: formatDate(today) }; + case "last-7-days": + return { start: formatDate(lastWeek), end: formatDate(today) }; + case "last-30-days": + return { start: formatDate(lastMonth), end: formatDate(today) }; + default: + return { start: formatDate(lastWeek), end: formatDate(today) }; + } + }; + const { start, end } = getDateRange(); + getTop5Journeys(start, end).then((data: any[]) => settop5Journeys(data)); + }, [dateRange]); + + return ( + + + + Frame Analytics + + + + Date Range + + + setJourneyId(e.target.value)} sx={{ mr: 2 }} /> + + + + + + Total Interactions + + {totalInteractions} + + + + + + Unique User Interactions + + {uniqueInteractions} + + + + + + Interactions Over Time + + + + + + Top 5 Journeys + + + + + + + + Journey ID + + + + + Journey Name + + + + + Interactions + + + + + + {top5Journeys.map((frame, index) => ( + + {frame._id} + {frame.journeyName} + {frame.count} + + ))} + +
+
+
+
+
+ ); +}; + +export default AnalyticsPage; diff --git a/packages/nextjs/app/api/analytics/top5journeys/route.ts b/packages/nextjs/app/api/analytics/top5journeys/route.ts index ad82b52..90bb80d 100644 --- a/packages/nextjs/app/api/analytics/top5journeys/route.ts +++ b/packages/nextjs/app/api/analytics/top5journeys/route.ts @@ -1,23 +1,23 @@ -import { NextResponse } from "next/server"; -import Analytics from "~~/model/analytics"; -import Journey from "~~/model/journey"; -import connectDB from "~~/services/connectDB"; - -export async function GET() { - await connectDB(); - const topJourneys = await Analytics.aggregate([ - { $group: { _id: "$journeyId", count: { $sum: 1 } } }, - { $sort: { count: -1 } }, - { $limit: 5 }, - ]).exec(); - - for (const journey of topJourneys) { - const journeyBody = await Journey.findById(journey._id); - journey.journeyName = journeyBody?.name; - } - return new NextResponse(JSON.stringify(topJourneys), { - headers: { - "Content-Type": "application/json", - }, - }); -} +import { NextResponse } from "next/server"; +import Analytics from "~~/model/analytics"; +import Journey from "~~/model/journey"; +import connectDB from "~~/services/connectDB"; + +export async function GET() { + await connectDB(); + const topJourneys = await Analytics.aggregate([ + { $group: { _id: "$journeyId", count: { $sum: 1 } } }, + { $sort: { count: -1 } }, + { $limit: 5 }, + ]).exec(); + + for (const journey of topJourneys) { + const journeyBody = await Journey.findById(journey._id); + journey.journeyName = journeyBody?.name; + } + return new NextResponse(JSON.stringify(topJourneys), { + headers: { + "Content-Type": "application/json", + }, + }); +} diff --git a/packages/nextjs/app/api/analytics/total_interactions/graph/route.ts b/packages/nextjs/app/api/analytics/total_interactions/graph/route.ts index b605bf4..0a27d2d 100644 --- a/packages/nextjs/app/api/analytics/total_interactions/graph/route.ts +++ b/packages/nextjs/app/api/analytics/total_interactions/graph/route.ts @@ -1,65 +1,65 @@ -import { NextRequest, NextResponse } from "next/server"; -import Analytics from "~~/model/analytics"; -import connectDB from "~~/services/connectDB"; - -type DateFilter = { - $gte?: Date; - $lte?: Date; -}; - -export async function GET(request: NextRequest) { - await connectDB(); - const { searchParams } = new URL(request.url); - const startDate = searchParams.get("startDate"); - const frameId = searchParams.get("frameId"); - const journeyId = searchParams.get("journeyId"); - const dateFilter: DateFilter = {}; - console.log(startDate, frameId, journeyId); - if (startDate) { - dateFilter.$gte = new Date(startDate); - } - const query: any = {}; - if (startDate) { - query.createdAt = dateFilter; - } - if (frameId) { - query.frameId = frameId; - } - if (journeyId) { - query.journeyId = journeyId; - } - const aggregationPipeline = [ - { - $match: query, - }, - { - $group: { - _id: { - $dateToString: { - format: "%Y-%m-%d", - date: "$createdAt", - }, - }, - count: { $sum: 1 }, - }, - }, - { - $project: { - date: "$_id", - count: 1, - _id: 0, - }, - }, - { - $sort: { date: 1 } as any, - }, - ]; - const results = await Analytics.aggregate(aggregationPipeline).exec(); - console.log(results); - // write a loop iterating from startDate to endDate and filling in the missing dates with 0 - return new NextResponse(JSON.stringify(results), { - headers: { - "Content-Type": "application/json", - }, - }); -} +import { NextRequest, NextResponse } from "next/server"; +import Analytics from "~~/model/analytics"; +import connectDB from "~~/services/connectDB"; + +type DateFilter = { + $gte?: Date; + $lte?: Date; +}; + +export async function GET(request: NextRequest) { + await connectDB(); + const { searchParams } = new URL(request.url); + const startDate = searchParams.get("startDate"); + const frameId = searchParams.get("frameId"); + const journeyId = searchParams.get("journeyId"); + const dateFilter: DateFilter = {}; + console.log(startDate, frameId, journeyId); + if (startDate) { + dateFilter.$gte = new Date(startDate); + } + const query: any = {}; + if (startDate) { + query.createdAt = dateFilter; + } + if (frameId) { + query.frameId = frameId; + } + if (journeyId) { + query.journeyId = journeyId; + } + const aggregationPipeline = [ + { + $match: query, + }, + { + $group: { + _id: { + $dateToString: { + format: "%Y-%m-%d", + date: "$createdAt", + }, + }, + count: { $sum: 1 }, + }, + }, + { + $project: { + date: "$_id", + count: 1, + _id: 0, + }, + }, + { + $sort: { date: 1 } as any, + }, + ]; + const results = await Analytics.aggregate(aggregationPipeline).exec(); + console.log(results); + // write a loop iterating from startDate to endDate and filling in the missing dates with 0 + return new NextResponse(JSON.stringify(results), { + headers: { + "Content-Type": "application/json", + }, + }); +} diff --git a/packages/nextjs/app/api/analytics/total_interactions/route.ts b/packages/nextjs/app/api/analytics/total_interactions/route.ts index f20d4ce..8b65887 100644 --- a/packages/nextjs/app/api/analytics/total_interactions/route.ts +++ b/packages/nextjs/app/api/analytics/total_interactions/route.ts @@ -1,36 +1,36 @@ -import { NextRequest, NextResponse } from "next/server"; -import Analytics from "~~/model/analytics"; -import connectDB from "~~/services/connectDB"; - -type DateFilter = { - $gte?: Date; - $lte?: Date; -}; - -export async function GET(request: NextRequest) { - await connectDB(); - const { searchParams } = new URL(request.url); - const startDate = searchParams.get("startDate"); - const frameId = searchParams.get("frameId"); - const journeyId = searchParams.get("journeyId"); - const dateFilter: DateFilter = {}; - if (startDate) { - dateFilter.$gte = new Date(startDate); - } - const query: any = {}; - if (startDate) { - query.createdAt = dateFilter; - } - if (frameId) { - query.frameId = frameId; - } - if (journeyId) { - query.journeyId = journeyId; - } - const totalUsers = await Analytics.countDocuments(query); - return new NextResponse(JSON.stringify({ totalUsers: totalUsers }), { - headers: { - "Content-Type": "application/json", - }, - }); -} +import { NextRequest, NextResponse } from "next/server"; +import Analytics from "~~/model/analytics"; +import connectDB from "~~/services/connectDB"; + +type DateFilter = { + $gte?: Date; + $lte?: Date; +}; + +export async function GET(request: NextRequest) { + await connectDB(); + const { searchParams } = new URL(request.url); + const startDate = searchParams.get("startDate"); + const frameId = searchParams.get("frameId"); + const journeyId = searchParams.get("journeyId"); + const dateFilter: DateFilter = {}; + if (startDate) { + dateFilter.$gte = new Date(startDate); + } + const query: any = {}; + if (startDate) { + query.createdAt = dateFilter; + } + if (frameId) { + query.frameId = frameId; + } + if (journeyId) { + query.journeyId = journeyId; + } + const totalUsers = await Analytics.countDocuments(query); + return new NextResponse(JSON.stringify({ totalUsers: totalUsers }), { + headers: { + "Content-Type": "application/json", + }, + }); +} diff --git a/packages/nextjs/app/api/analytics/unique_fids/route.ts b/packages/nextjs/app/api/analytics/unique_fids/route.ts index 0c79429..2e05d22 100644 --- a/packages/nextjs/app/api/analytics/unique_fids/route.ts +++ b/packages/nextjs/app/api/analytics/unique_fids/route.ts @@ -1,36 +1,36 @@ -import { NextRequest, NextResponse } from "next/server"; -import Analytics from "~~/model/analytics"; -import connectDB from "~~/services/connectDB"; - -type DateFilter = { - $gte?: Date; - $lte?: Date; -}; - -export async function GET(request: NextRequest) { - await connectDB(); - const { searchParams } = new URL(request.url); - const startDate = searchParams.get("startDate"); - const frameId = searchParams.get("frameId"); - const journeyId = searchParams.get("journeyId"); - const dateFilter: DateFilter = {}; - if (startDate) { - dateFilter.$gte = new Date(startDate); - } - const query: any = {}; - if (startDate) { - query.createdAt = dateFilter; - } - if (frameId) { - query.frameId = frameId; - } - if (journeyId) { - query.journeyId = journeyId; - } - const distinctUsers = await Analytics.distinct("fid", query); - return new NextResponse(JSON.stringify({ uniqueFids: distinctUsers.length }), { - headers: { - "Content-Type": "application/json", - }, - }); -} +import { NextRequest, NextResponse } from "next/server"; +import Analytics from "~~/model/analytics"; +import connectDB from "~~/services/connectDB"; + +type DateFilter = { + $gte?: Date; + $lte?: Date; +}; + +export async function GET(request: NextRequest) { + await connectDB(); + const { searchParams } = new URL(request.url); + const startDate = searchParams.get("startDate"); + const frameId = searchParams.get("frameId"); + const journeyId = searchParams.get("journeyId"); + const dateFilter: DateFilter = {}; + if (startDate) { + dateFilter.$gte = new Date(startDate); + } + const query: any = {}; + if (startDate) { + query.createdAt = dateFilter; + } + if (frameId) { + query.frameId = frameId; + } + if (journeyId) { + query.journeyId = journeyId; + } + const distinctUsers = await Analytics.distinct("fid", query); + return new NextResponse(JSON.stringify({ uniqueFids: distinctUsers.length }), { + headers: { + "Content-Type": "application/json", + }, + }); +} diff --git a/packages/nextjs/app/api/orchestrator/[frameId]/route.ts b/packages/nextjs/app/api/orchestrator/[frameId]/route.ts index 257a1c7..7c7d228 100644 --- a/packages/nextjs/app/api/orchestrator/[frameId]/route.ts +++ b/packages/nextjs/app/api/orchestrator/[frameId]/route.ts @@ -2,10 +2,7 @@ import { NextRequest, NextResponse } from "next/server"; import { FrameRequest, getFrameHtmlResponse } from "@coinbase/onchainkit"; import Analytics from "~~/model/analytics"; import connectDB from "~~/services/connectDB"; -import { getFrameAtServer } from "~~/services/frames"; -import { EAS, SchemaEncoder, SchemaRegistry } from "@ethereum-attestation-service/eas-sdk"; -import { ethers } from "ethers"; - +import { createAttestation, getFrameAtServer } from "~~/services/frames"; const storeAnalytics = async (body: FrameRequest, state: any) => { const analyticsEntry = new Analytics({ @@ -19,38 +16,12 @@ const storeAnalytics = async (body: FrameRequest, state: any) => { await analyticsEntry.save(); console.log(analyticsEntry); }; -async function createAttestation(txnId : string){ -const eas = new EAS("0x4200000000000000000000000000000000000021"); -const offchain = await eas.getOffchain(); -const provider = new ethers.JsonRpcProvider("https://base-sepolia.infura.io/v3/847856edbfc14f50a4782dce0fa77ce5") -// Signer must be an ethers-like signer. -const schemaUID = "0x3ca31d9c24a48e437eba25cb423d9a873a751511c70dc0b2a8fb4c9a8d45b506" -const signer = new ethers.Wallet("c04f2876f3691d44fdba3592bf800c05516d419f10ac269a7a565c21dfda57fa", provider); -const schemaEncoder = new SchemaEncoder("address seller,address buyer,uint256 amount,uint256 quantity,bytes32 txHash,string productId"); -const encodedData = schemaEncoder.encodeData([ - { name: "seller", value: "0x0000000000000000000000000000000000000000", type: "address" }, - { name: "buyer", value: "0x0000000000000000000000000000000000000000", type: "address" }, - { name: "amount", value: "0", type: "uint256" }, - { name: "quantity", value: "0", type: "uint256" }, - { name: "txHash", value: {txnId}, type: "bytes32" }, - { name: "productId", value: "", type: "string" }, -]); - -const tx = await eas.attest({ - schema: schemaUID, - data: { - recipient: "0x0000000000000000000000000000000000000000", - expirationTime: BigInt(0), - revocable: true, // Be aware that if your schema is not revocable, this MUST be false - data: encodedData, - }, -}); -const newAttestationUID = await tx.wait(); +// scripts to create frames + journey +// orders schema + orders +// get price and quantity for each order +// create attestation for each order - console.log("New attestation UID:", newAttestationUID); - return newAttestationUID; -} async function getResponse(req: NextRequest): Promise { await connectDB(); const url = req.nextUrl.pathname; @@ -60,33 +31,33 @@ async function getResponse(req: NextRequest): Promise { if (body.untrustedData?.buttonIndex != "") { const txnId = body.untrustedData?.transactionId; const attestation = await createAttestation(txnId); - return new NextResponse(JSON.stringify({ message: "Attestation Created", attestation }), { status: 200 }); - } - const state = JSON.parse(decodeURIComponent(body.untrustedData?.state as string)); - let stateUpdate - if (state) { - console.log("state", state); - // Creating Analytics for the frame asynchronously - storeAnalytics(body, state).catch(err => console.error("Error Saving Analytics", err)); - // Adding State for Button Press and Inputted Text on last frame - state.frame_id = frameId; - stateUpdate = { - ...state, - [`${frameId}ButtonPressed`]: body.untrustedData.buttonIndex, - [`${frameId}InputtedText`]: body.untrustedData.inputText, - }; + console.log("attestation", attestation); } + // const state = JSON.parse(decodeURIComponent(body.untrustedData?.state as string)); + // let stateUpdate + // if (state) { + // console.log("state", state); + // // Creating Analytics for the frame asynchronously + // storeAnalytics(body, state).catch(err => console.error("Error Saving Analytics", err)); + // // Adding State for Button Press and Inputted Text on last frame + // state.frame_id = frameId; + // stateUpdate = { + // ...state, + // [`${frameId}ButtonPressed`]: body.untrustedData.buttonIndex, + // [`${frameId}InputtedText`]: body.untrustedData.inputText, + // }; + // } const dbFrame = await getFrameAtServer(frameId); if (!dbFrame) { return new NextResponse(JSON.stringify({ message: "Frame not found" }), { status: 404 }); } const nextFrame = dbFrame.frameJson; - if (state) { - nextFrame.state = { - ...stateUpdate - }; - } + // if (state) { + // nextFrame.state = { + // ...stateUpdate + // }; + // } return new NextResponse(getFrameHtmlResponse(nextFrame)); } diff --git a/packages/nextjs/app/api/shopify/products/route.tsx b/packages/nextjs/app/api/shopify/products/route.tsx index 3a9749d..b2d71c5 100644 --- a/packages/nextjs/app/api/shopify/products/route.tsx +++ b/packages/nextjs/app/api/shopify/products/route.tsx @@ -1,18 +1,18 @@ -import { NextResponse } from "next/dist/server/web/spec-extension/response"; -import { NextRequest } from "next/server"; -import { getShopifyProducts } from "~~/services/shopify/fetchProducts"; - -// get all frames -export async function POST(request: NextRequest) { - const req = request as NextRequest; - const body = await req.json(); - const { storeName, apiKey } = body; - const products = await getShopifyProducts(storeName, apiKey); - const responseBody = JSON.stringify(products); - - return new NextResponse(responseBody, { - headers: { - "Content-Type": "application/json", - }, - }); -} +import { NextResponse } from "next/dist/server/web/spec-extension/response"; +import { NextRequest } from "next/server"; +import { getShopifyProducts } from "~~/services/shopify/fetchProducts"; + +// get all frames +export async function POST(request: NextRequest) { + const req = request as NextRequest; + const body = await req.json(); + const { storeName, apiKey } = body; + const products = await getShopifyProducts(storeName, apiKey); + const responseBody = JSON.stringify(products); + + return new NextResponse(responseBody, { + headers: { + "Content-Type": "application/json", + }, + }); +} diff --git a/packages/nextjs/app/api/shopify/route.tsx b/packages/nextjs/app/api/shopify/route.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/packages/nextjs/app/blockexplorer/_components/AddressComponent.tsx b/packages/nextjs/app/blockexplorer/_components/AddressComponent.tsx index c0c14d6..13c1742 100644 --- a/packages/nextjs/app/blockexplorer/_components/AddressComponent.tsx +++ b/packages/nextjs/app/blockexplorer/_components/AddressComponent.tsx @@ -6,7 +6,7 @@ export const AddressComponent = ({ address, contractData, }: { - address: string; + address: `0x${string}`; contractData: { bytecode: string; assembly: string } | null; }) => { return ( diff --git a/packages/nextjs/app/blockexplorer/_components/ContractTabs.tsx b/packages/nextjs/app/blockexplorer/_components/ContractTabs.tsx index bb020ef..c78f4a9 100644 --- a/packages/nextjs/app/blockexplorer/_components/ContractTabs.tsx +++ b/packages/nextjs/app/blockexplorer/_components/ContractTabs.tsx @@ -32,7 +32,7 @@ export const ContractTabs = ({ address, contractData }: PageProps) => { useEffect(() => { const checkIsContract = async () => { - const contractCode = await publicClient.getBytecode({ address: address }); + const contractCode = await publicClient.getBytecode({ address: address as `0x${string}` }); setIsContract(contractCode !== undefined && contractCode !== "0x"); }; diff --git a/packages/nextjs/app/frame/page.tsx b/packages/nextjs/app/frame/page.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/packages/nextjs/app/page.tsx b/packages/nextjs/app/page.tsx index b7f9b59..8afc315 100644 --- a/packages/nextjs/app/page.tsx +++ b/packages/nextjs/app/page.tsx @@ -25,7 +25,6 @@ export default Home; // const Home: NextPage = () => { - // async function lfg() { // const eas = new EAS("0x4200000000000000000000000000000000000021"); @@ -58,9 +57,6 @@ export default Home; // // const offchain = await eas.getOffchain(); // // console.log(offchain); - - - // // const offchainAttestation = await offchain.signOffchainAttestation({ // // recipient: '0xFD50b031E778fAb33DfD2Fc3Ca66a1EeF0652165', // // // Unix timestamp of when attestation expires. (0 for no expiration) @@ -75,9 +71,6 @@ export default Home; // // data: encodedData, // // }, signer); - - - // // console.log("New attestation UID:", offchainAttestation); // const rpcUrl = "https://api.developer.coinbase.com/rpc/v1/base-sepolia/YoFvJm3qNGMvTrtaqg0fbB20fBTqXxAP"; @@ -780,7 +773,7 @@ export default Home; // //
//

Connected Address:

- + //
//

// Get started by editing{" "} diff --git a/packages/nextjs/app/paymaster.tsx b/packages/nextjs/app/paymaster.tsx index 8ffac5d..bf56434 100644 --- a/packages/nextjs/app/paymaster.tsx +++ b/packages/nextjs/app/paymaster.tsx @@ -714,7 +714,7 @@ // //

//

Connected Address:

- + //
//

// Get started by editing{" "} @@ -765,4 +765,4 @@ // // >>>>>>> 3ed3638 (paymaster and smart wallet added) // ); -// }; \ No newline at end of file +// }; diff --git a/packages/nextjs/app/receiptAttestation.tsx b/packages/nextjs/app/receiptAttestation.tsx deleted file mode 100644 index a841f8c..0000000 --- a/packages/nextjs/app/receiptAttestation.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { EAS, SchemaEncoder, SchemaRegistry } from "@ethereum-attestation-service/eas-sdk"; -import { ethers } from "ethers"; -const eas = new EAS("0x4200000000000000000000000000000000000021"); -const offchain = await eas.getOffchain(); -const provider = new ethers.JsonRpcProvider("https://base-sepolia.infura.io/v3/847856edbfc14f50a4782dce0fa77ce5") -// Signer must be an ethers-like signer. -const schemaUID = "0x3ca31d9c24a48e437eba25cb423d9a873a751511c70dc0b2a8fb4c9a8d45b506" -const signer = new ethers.Wallet("c04f2876f3691d44fdba3592bf800c05516d419f10ac269a7a565c21dfda57fa", provider); -const schemaEncoder = new SchemaEncoder("address seller,address buyer,uint256 amount,uint256 quantity,bytes32 txHash,string productId"); -const encodedData = schemaEncoder.encodeData([ - { name: "seller", value: "0x0000000000000000000000000000000000000000", type: "address" }, - { name: "buyer", value: "0x0000000000000000000000000000000000000000", type: "address" }, - { name: "amount", value: "0", type: "uint256" }, - { name: "quantity", value: "0", type: "uint256" }, - { name: "txHash", value: "", type: "bytes32" }, - { name: "productId", value: "", type: "string" }, -]); - -const tx = await eas.attest({ - schema: schemaUID, - data: { - recipient: "0x0000000000000000000000000000000000000000", - expirationTime: BigInt(0), - revocable: true, // Be aware that if your schema is not revocable, this MUST be false - data: encodedData, - }, -}); - -const newAttestationUID = await tx.wait(); - -console.log("New attestation UID:", newAttestationUID); - diff --git a/packages/nextjs/components/ButtonEditor.tsx b/packages/nextjs/components/ButtonEditor.tsx index 21392c9..b440ce3 100644 --- a/packages/nextjs/components/ButtonEditor.tsx +++ b/packages/nextjs/components/ButtonEditor.tsx @@ -111,9 +111,8 @@ const ButtonEditor = ({ button, onSave, onDelete }: ButtonEditorProps) => { )} - ) - } - + )} + ); }; diff --git a/packages/nextjs/components/ButtonsList.tsx b/packages/nextjs/components/ButtonsList.tsx index 3c49a15..ae9011b 100644 --- a/packages/nextjs/components/ButtonsList.tsx +++ b/packages/nextjs/components/ButtonsList.tsx @@ -10,7 +10,7 @@ import { notification } from "~~/utils/scaffold-eth"; const ButtonList = () => { const router = useRouter(); - const { currentFrame, setCurrentFrame, frame, saveFrame, deleteFrame,journey } = useProductJourney(); + const { currentFrame, setCurrentFrame, frame, saveFrame, deleteFrame, journey } = useProductJourney(); const [activeButtonIndex, setActiveButtonIndex] = useState(0); const [open, setOpen] = useState(false); if (!currentFrame) return null; diff --git a/packages/nextjs/components/FrameEditor.tsx b/packages/nextjs/components/FrameEditor.tsx index f6baa88..65891f1 100644 --- a/packages/nextjs/components/FrameEditor.tsx +++ b/packages/nextjs/components/FrameEditor.tsx @@ -58,7 +58,7 @@ const FrameEditor = () => { if (!currentFrame) return null; return (

- = ({ isOpen, onClose }) => { quantity, price, }); + console.log(newProduct); notification.success("Frame Story created successfully"); router.push(`/dashboard/${newProduct._id}`); diff --git a/packages/nextjs/components/analytics/LineChart.tsx b/packages/nextjs/components/analytics/LineChart.tsx index 31608ac..b9c9e72 100644 --- a/packages/nextjs/components/analytics/LineChart.tsx +++ b/packages/nextjs/components/analytics/LineChart.tsx @@ -1,40 +1,43 @@ -import React from "react"; -import Chart from "react-apexcharts"; - -const LineChart = ({ data }: { data: any }) => { - const series = [ - { - name: "Total Interactions", - data: data.map(entry => entry.count), - }, - ]; - - const options = { - chart: { - height: 350, - type: "line", - zoom: { - enabled: false, - }, - }, - xaxis: { - categories: data.map(entry => entry.date), - title: { - text: "Date", - }, - }, - yaxis: { - title: { - text: "Interactions", - }, - }, - }; - - return ( -
- -
- ); -}; - -export default LineChart; +import React, { useEffect, useState } from "react"; +import dynamic from "next/dynamic"; + +const Chart = dynamic(() => import("react-apexcharts"), { ssr: false }); + +const LineChart = ({ data }: { data: any }) => { + const series = [ + { + name: "Total Interactions", + data: data.map((entry: any) => entry.count), + }, + ]; + + const options = { + chart: { + height: 350, + type: "line", + zoom: { + enabled: false, + }, + }, + xaxis: { + categories: data.map((entry: any) => entry.date), + title: { + text: "Date", + }, + }, + yaxis: { + title: { + text: "Interactions", + }, + }, + }; + + return ( +
+ {/* @ts-ignore */} + +
+ ); +}; + +export default LineChart; diff --git a/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/CoinbaseWalletLogo.tsx b/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/CoinbaseWalletLogo.tsx index 3a9241f..c20d75a 100644 --- a/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/CoinbaseWalletLogo.tsx +++ b/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/CoinbaseWalletLogo.tsx @@ -1,22 +1,13 @@ -import React from 'react'; - +import React from "react"; + const defaultContainerStyles = { paddingTop: 2, }; - -export function CoinbaseWalletLogo({ - size = 26, - containerStyles = defaultContainerStyles, -}) { + +export function CoinbaseWalletLogo({ size = 26, containerStyles = defaultContainerStyles }) { return (
- +
); -} \ No newline at end of file +} diff --git a/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx b/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx index b483eaa..6ccf7ad 100644 --- a/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx +++ b/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx @@ -3,36 +3,34 @@ /** * Custom Wagmi Connect Button (watch balance + custom design) */ -import React, { useCallback } from 'react'; -import { useConnect, useAccount, useDisconnect } from 'wagmi'; -import { CoinbaseWalletLogo } from './CoinbaseWalletLogo'; -import { AddressInfoDropdown } from './AddressInfoDropdown'; - +import React, { useCallback } from "react"; +import { AddressInfoDropdown } from "./AddressInfoDropdown"; +import { CoinbaseWalletLogo } from "./CoinbaseWalletLogo"; +import { useAccount, useConnect, useDisconnect } from "wagmi"; + const buttonStyles = { - background: 'transparent', - border: '1px solid transparent', - boxSizing: 'border-box', - display: 'flex', - alignItems: 'center', - justifyContent: 'space-between', + background: "transparent", + border: "1px solid transparent", + boxSizing: "border-box", + display: "flex", + alignItems: "center", + justifyContent: "space-between", width: 200, - fontFamily: 'Arial, sans-serif', - fontWeight: 'bold', + fontFamily: "Arial, sans-serif", + fontWeight: "bold", fontSize: 18, - backgroundColor: '#0052FF', + backgroundColor: "#0052FF", paddingLeft: 15, paddingRight: 30, borderRadius: 10, }; - + export function RainbowKitCustomConnectButton() { - const { disconnect } = useDisconnect() + const { disconnect } = useDisconnect(); const { connectors, connect, data } = useConnect(); - const account = useAccount() + const account = useAccount(); const createWallet = useCallback(() => { - const coinbaseWalletConnector = connectors.find( - (connector) => connector.id === 'coinbaseWalletSDK' - ); + const coinbaseWalletConnector = connectors.find(connector => connector.id === "coinbaseWalletSDK"); if (coinbaseWalletConnector) { connect({ connector: coinbaseWalletConnector }); } @@ -40,27 +38,35 @@ export function RainbowKitCustomConnectButton() { }, [connectors, connect]); return ( <> - {account.address ? (<>) : ( - ) - } ); + + )}{" "} + + ); } - diff --git a/packages/nextjs/model/analytics.ts b/packages/nextjs/model/analytics.ts index 783ec93..7619e7d 100644 --- a/packages/nextjs/model/analytics.ts +++ b/packages/nextjs/model/analytics.ts @@ -1,29 +1,29 @@ -import mongoose, { Document, Schema } from "mongoose"; - -interface Analytics extends Document { - journeyId: string; - frameId: string; - fid: string; - buttonClicked: number; - inputtedText: string; - timestamp: Date; -} - -const AnalyticsSchema: Schema = new Schema( - { - journeyId: String, // journeyId to correlate - frameId: String, //frameId to correlate - fid: String, // fid of the user - buttonClicked: Number, // 0 for no button clicked, 1 for button 1 clicked.... - inputtedText: String, // text inputted by the user, null if empty - timestamp: Number, // timestamp of the event - }, - { - timestamps: true, - }, -); - -// Define and export the Analytics model -const Analytics = mongoose.models.Analytics || mongoose.model("Analytics", AnalyticsSchema); - -export default Analytics; +import mongoose, { Document, Schema } from "mongoose"; + +interface Analytics extends Document { + journeyId: string; + frameId: string; + fid: string; + buttonClicked: number; + inputtedText: string; + timestamp: Date; +} + +const AnalyticsSchema: Schema = new Schema( + { + journeyId: String, // journeyId to correlate + frameId: String, //frameId to correlate + fid: String, // fid of the user + buttonClicked: Number, // 0 for no button clicked, 1 for button 1 clicked.... + inputtedText: String, // text inputted by the user, null if empty + timestamp: Number, // timestamp of the event + }, + { + timestamps: true, + }, +); + +// Define and export the Analytics model +const Analytics = mongoose.models.Analytics || mongoose.model("Analytics", AnalyticsSchema); + +export default Analytics; diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index f3e5fc6..51f0ff2 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -15,6 +15,8 @@ }, "dependencies": { "@coinbase/onchainkit": "0.11.0", + "@emotion/react": "^11.11.4", + "@emotion/styled": "^11.11.5", "@ethereum-attestation-service/eas-sdk": "^2.3.0", "@heroicons/react": "^2.0.11", "@mui/material": "^5.15.21", @@ -23,6 +25,8 @@ "@tanstack/react-query": "^5.28.6", "@uniswap/sdk-core": "^4.0.1", "@uniswap/v2-sdk": "^3.0.1", + "apexcharts": "^3.49.2", + "axios": "^1.7.2", "blo": "^1.0.1", "burner-connector": "^0.0.8", "daisyui": "4.5.0", @@ -44,7 +48,7 @@ "usehooks-ts": "^2.13.0", "uuidv4": "^6.2.13", "viem": "2.10.9", - "wagmi": "2.9.5", + "wagmi": "^2.10.8", "zustand": "^4.1.2" }, "devDependencies": { diff --git a/packages/nextjs/providers/ProductProvider.tsx b/packages/nextjs/providers/ProductProvider.tsx index 10912f7..1610847 100644 --- a/packages/nextjs/providers/ProductProvider.tsx +++ b/packages/nextjs/providers/ProductProvider.tsx @@ -102,7 +102,7 @@ const useProduct = () => { const saveFrame = useMutation({ mutationFn: async (frame: Frame) => { - console.log({ frame }) + console.log({ frame }); const response = await fetch(`/api/frame/${frame._id}`, { method: "PUT", headers: { diff --git a/packages/nextjs/services/analytics/getAnalytics.ts b/packages/nextjs/services/analytics/getAnalytics.ts index a8b5454..bd393fd 100644 --- a/packages/nextjs/services/analytics/getAnalytics.ts +++ b/packages/nextjs/services/analytics/getAnalytics.ts @@ -1,56 +1,56 @@ -export const getTotalInteractions = async (startDate: string, endDate: string, journeyId = "") => { - let queryparams = "?startDate=" + startDate + "&endDate=" + endDate; - if (journeyId !== "") { - queryparams = `?startDate=${startDate}&endDate=${endDate}&journeyId=${journeyId}`; - } - const res = await fetch(`/api/analytics/total_interactions` + queryparams); - const data = await res.json(); - return data.totalUsers; -}; - -export const getUniqueUsers = async (startDate: string, endDate: string, journeyId = "") => { - let queryparams = "?startDate=" + startDate + "&endDate=" + endDate; - if (journeyId !== "") { - queryparams = `?startDate=${startDate}&endDate=${endDate}&journeyId=${journeyId}`; - } - const res = await fetch(`/api/analytics/unique_fids` + queryparams); - const data = await res.json(); - return data.uniqueFids; -}; - -export const getTop5Journeys = async (startDate: string, endDate: string) => { - const queryparams = "?startDate=" + startDate + "&endDate=" + endDate; - const res = await fetch(`/api/analytics/top5journeys` + queryparams); - const data = await res.json(); - return data; -}; - -export const getTotalInteractionsGraph = async (startDate: string, journeyId = "") => { - let queryparams = "?startDate=" + startDate; - if (journeyId !== "") { - queryparams += `&journeyId=${journeyId}`; - } - const res = await fetch(`/api/analytics/total_interactions/graph` + queryparams); - const data = await res.json(); - const finalGraph = []; - const currentDate = new Date(startDate); - const endDateObj = new Date(); - const adjustedDateObj = new Date(endDateObj.getTime() + 1 * 24 * 60 * 60 * 1000); - console.log("data", data); - while (currentDate <= adjustedDateObj) { - const entry = data.find((entry: any) => { - const entryDate = new Date(entry.date).toDateString(); - const currentDateWithoutTime = currentDate.toDateString(); - return entryDate === currentDateWithoutTime; - }); - const dateStr = currentDate.toISOString().split("T")[0]; - if (entry) { - finalGraph.push(entry); - } else { - finalGraph.push({ date: dateStr, count: 0 }); - } - console.log("finalGraph", finalGraph); - currentDate.setDate(currentDate.getDate() + 1); - } - return finalGraph; -}; +export const getTotalInteractions = async (startDate: string, endDate: string, journeyId = "") => { + let queryparams = "?startDate=" + startDate + "&endDate=" + endDate; + if (journeyId !== "") { + queryparams = `?startDate=${startDate}&endDate=${endDate}&journeyId=${journeyId}`; + } + const res = await fetch(`/api/analytics/total_interactions` + queryparams); + const data = await res.json(); + return data.totalUsers; +}; + +export const getUniqueUsers = async (startDate: string, endDate: string, journeyId = "") => { + let queryparams = "?startDate=" + startDate + "&endDate=" + endDate; + if (journeyId !== "") { + queryparams = `?startDate=${startDate}&endDate=${endDate}&journeyId=${journeyId}`; + } + const res = await fetch(`/api/analytics/unique_fids` + queryparams); + const data = await res.json(); + return data.uniqueFids; +}; + +export const getTop5Journeys = async (startDate: string, endDate: string) => { + const queryparams = "?startDate=" + startDate + "&endDate=" + endDate; + const res = await fetch(`/api/analytics/top5journeys` + queryparams); + const data = await res.json(); + return data; +}; + +export const getTotalInteractionsGraph = async (startDate: string, journeyId = "") => { + let queryparams = "?startDate=" + startDate; + if (journeyId !== "") { + queryparams += `&journeyId=${journeyId}`; + } + const res = await fetch(`/api/analytics/total_interactions/graph` + queryparams); + const data = await res.json(); + const finalGraph = []; + const currentDate = new Date(startDate); + const endDateObj = new Date(); + const adjustedDateObj = new Date(endDateObj.getTime() + 1 * 24 * 60 * 60 * 1000); + console.log("data", data); + while (currentDate <= adjustedDateObj) { + const entry = data.find((entry: any) => { + const entryDate = new Date(entry.date).toDateString(); + const currentDateWithoutTime = currentDate.toDateString(); + return entryDate === currentDateWithoutTime; + }); + const dateStr = currentDate.toISOString().split("T")[0]; + if (entry) { + finalGraph.push(entry); + } else { + finalGraph.push({ date: dateStr, count: 0 }); + } + console.log("finalGraph", finalGraph); + currentDate.setDate(currentDate.getDate() + 1); + } + return finalGraph; +}; diff --git a/packages/nextjs/services/frames.ts b/packages/nextjs/services/frames.ts index 33cd507..70937e2 100644 --- a/packages/nextjs/services/frames.ts +++ b/packages/nextjs/services/frames.ts @@ -1,6 +1,7 @@ -import { APP_URL, DEFAULT_FRAME } from "~~/constants"; +import { EAS, SchemaEncoder } from "@ethereum-attestation-service/eas-sdk"; +import { ethers } from "ethers"; +import { APP_URL } from "~~/constants"; import { Frame, Journey } from "~~/types/commontypes"; -import { GetDefaultFrame } from "./frames/frameGetters"; export const getFrameById = async (id: string) => { try { @@ -63,7 +64,7 @@ export const createJourney = async (journey: Partial) => { }); if (!response.ok) { throw new Error("Network response was not ok"); - }; + } return response.json(); } catch (error: any) { console.error(error); @@ -89,3 +90,35 @@ export const saveFrame = async (frame: Frame) => { throw new Error(error.message); } }; + +export async function createAttestation(txnId: string) { + const eas = new EAS("0x4200000000000000000000000000000000000021"); + const provider = new ethers.JsonRpcProvider("https://base-sepolia.infura.io/v3/847856edbfc14f50a4782dce0fa77ce5"); + const signer = new ethers.Wallet("c04f2876f3691d44fdba3592bf800c05516d419f10ac269a7a565c21dfda57fa", provider); + eas.connect(signer); + const schemaUID = "0x6cf920b46db9fc89b78efe8c06f77f1d169ab43faec920161e4c3247daff3717"; + const schemaEncoder = new SchemaEncoder( + "string seller,string buyer,string amount,string quantity,string txHash,string productId", + ); + const encodedData = schemaEncoder.encodeData([ + { name: "seller", value: "", type: "string" }, + { name: "buyer", value: "", type: "string" }, + { name: "amount", value: "", type: "string" }, + { name: "quantity", value: "", type: "string" }, + { name: "txHash", value: txnId, type: "string" }, + { name: "productId", value: "", type: "string" }, + ]); + + const tx = await eas.attest({ + schema: schemaUID, + data: { + recipient: "0x0000000000000000000000000000000000000000", + expirationTime: BigInt(0), + revocable: true, // Be aware that if your schema is not revocable, this MUST be false + data: encodedData, + }, + }); + const attestation = await tx.wait(); + console.log("attestation", attestation); + return attestation; +} diff --git a/packages/nextjs/services/frames/frameGetters.ts b/packages/nextjs/services/frames/frameGetters.ts index 70ad1fe..4f6ecae 100644 --- a/packages/nextjs/services/frames/frameGetters.ts +++ b/packages/nextjs/services/frames/frameGetters.ts @@ -1,8 +1,8 @@ -import { FrameMetadataType } from "@coinbase/onchainkit"; -import { DEFAULT_FRAME } from "~~/constants"; - -export const GetDefaultFrame = async (journey_id: string) => { - let frame: FrameMetadataType = DEFAULT_FRAME; - frame.state.journey_id = journey_id; - return frame; -}; +import { FrameMetadataType } from "@coinbase/onchainkit"; +import { DEFAULT_FRAME } from "~~/constants"; + +export const GetDefaultFrame = async (journey_id: string) => { + let frame: FrameMetadataType = DEFAULT_FRAME; + frame.state.journey_id = journey_id; + return frame; +}; diff --git a/packages/nextjs/services/shopify/fetchProducts.ts b/packages/nextjs/services/shopify/fetchProducts.ts index 76d8a25..4f0c90e 100644 --- a/packages/nextjs/services/shopify/fetchProducts.ts +++ b/packages/nextjs/services/shopify/fetchProducts.ts @@ -1,39 +1,39 @@ -import axios from "axios"; - -// const config = { -// method: "get", -// maxBodyLength: Infinity, -// url: "https://my-on-chain-store.myshopify.com/admin/api/2023-01/products.json", -// headers: { -// Accept: "application/json", -// "Content-Type": "application/json", -// "X-Shopify-Access-Token": "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", -// }, -// }; -const DEFAULT_SHOPIFY_URL = "https://my-on-chain-store.myshopify.com/admin/api/2023-01/products.json"; -const DEFAULT_SHOPIFY_ACCESS_TOKEN = "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"; - -export const getShopifyProducts = async (url?: string, accessToken?: string) => { - if (!url) { - url = DEFAULT_SHOPIFY_URL; - } - if (!accessToken) { - accessToken = DEFAULT_SHOPIFY_ACCESS_TOKEN; - } - const config = { - method: "get", - maxBodyLength: Infinity, - url: url, - headers: { - Accept: "application/json", - "Content-Type": "application/json", - "X-Shopify-Access-Token": accessToken, - }, - }; - try { - const response = await axios.request(config); - return response.data.products as any[]; - } catch (error: any) { - throw new Error(error.message); - } -}; +import axios from "axios"; + +// const config = { +// method: "get", +// maxBodyLength: Infinity, +// url: "https://my-on-chain-store.myshopify.com/admin/api/2023-01/products.json", +// headers: { +// Accept: "application/json", +// "Content-Type": "application/json", +// "X-Shopify-Access-Token": "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", +// }, +// }; +const DEFAULT_SHOPIFY_URL = "https://my-on-chain-store.myshopify.com/admin/api/2023-01/products.json"; +const DEFAULT_SHOPIFY_ACCESS_TOKEN = "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"; + +export const getShopifyProducts = async (url?: string, accessToken?: string) => { + if (!url) { + url = DEFAULT_SHOPIFY_URL; + } + if (!accessToken) { + accessToken = DEFAULT_SHOPIFY_ACCESS_TOKEN; + } + const config = { + method: "get", + maxBodyLength: Infinity, + url: url, + headers: { + Accept: "application/json", + "Content-Type": "application/json", + "X-Shopify-Access-Token": accessToken, + }, + }; + try { + const response = await axios.request(config); + return response.data.products as any[]; + } catch (error: any) { + throw new Error(error.message); + } +}; diff --git a/packages/nextjs/services/web3/wagmiConfig.tsx b/packages/nextjs/services/web3/wagmiConfig.tsx index 1a20482..a66cc74 100644 --- a/packages/nextjs/services/web3/wagmiConfig.tsx +++ b/packages/nextjs/services/web3/wagmiConfig.tsx @@ -1,7 +1,7 @@ -import { coinbaseWallet } from 'wagmi/connectors'; import { Chain, createClient, http } from "viem"; -import { hardhat, mainnet, baseSepolia } from "viem/chains"; +import { baseSepolia, hardhat, mainnet } from "viem/chains"; import { createConfig } from "wagmi"; +import { coinbaseWallet } from "wagmi/connectors"; import scaffoldConfig from "~~/scaffold.config"; import { getAlchemyHttpUrl } from "~~/utils/scaffold-eth"; @@ -16,8 +16,8 @@ export const wagmiConfig = createConfig({ chains: [baseSepolia], connectors: [ coinbaseWallet({ - appName: 'Frames Builder', - preference: 'smartWalletOnly', + appName: "Frames Builder", + preference: "smartWalletOnly", }), ], ssr: true, diff --git a/packages/nextjs/styles/globals.css b/packages/nextjs/styles/globals.css index 30b0663..721f042 100644 --- a/packages/nextjs/styles/globals.css +++ b/packages/nextjs/styles/globals.css @@ -52,13 +52,13 @@ p { } @keyframes wave { from { - transform: translateX(-50%) skew(0, -10deg); + transform: translateX(-50%) skew(0, -10deg); } to { - transform: translateX(-30%) skew(10deg, 0); - -webkit-transform: translateX(-30%) skew(10deg, 0); - -moz-transform: translateX(-30%) skew(10deg, 0); - -ms-transform: translateX(-30%) skew(10deg, 0); - -o-transform: translateX(-30%) skew(10deg, 0); -} + transform: translateX(-30%) skew(10deg, 0); + -webkit-transform: translateX(-30%) skew(10deg, 0); + -moz-transform: translateX(-30%) skew(10deg, 0); + -ms-transform: translateX(-30%) skew(10deg, 0); + -o-transform: translateX(-30%) skew(10deg, 0); + } } diff --git a/yarn.lock b/yarn.lock index cf23fd4..b503d9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -141,7 +141,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.19.4, @babel/runtime@npm:^7.20.6, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.23.9, @babel/runtime@npm:^7.24.1, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.8.7": +"@babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.19.4, @babel/runtime@npm:^7.20.6, @babel/runtime@npm:^7.21.0, @babel/runtime@npm:^7.23.9, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.8.7": version: 7.24.7 resolution: "@babel/runtime@npm:7.24.7" dependencies: @@ -233,40 +233,6 @@ __metadata: languageName: node linkType: hard -"@coinbase/onchainkit@npm:^0.23.4": - version: 0.23.4 - resolution: "@coinbase/onchainkit@npm:0.23.4" - dependencies: - "@tanstack/react-query": ^5 - clsx: ^2.1.1 - graphql: ^14 || ^15 || ^16 - graphql-request: ^6.1.0 - permissionless: ^0.1.29 - tailwind-merge: ^2.3.0 - viem: ^2.13.8 - wagmi: ^2.9.11 - peerDependencies: - "@xmtp/frames-validator": ^0.6.0 - react: ^18 - react-dom: ^18 - checksum: c29459a90688928ae6892406a88c8bc23aada9044fb26b7cf2034842692e24e4f8e7200492cf9e18ef5fa918a39e9a2ce8d8fefe7675bcec32f190d4253980fa - languageName: node - linkType: hard - -"@coinbase/wallet-sdk@npm:4.0.2": - version: 4.0.2 - resolution: "@coinbase/wallet-sdk@npm:4.0.2" - dependencies: - buffer: ^6.0.3 - clsx: ^1.2.1 - eventemitter3: ^5.0.1 - keccak: ^3.0.3 - preact: ^10.16.0 - sha.js: ^2.4.11 - checksum: d0cb646ae8a57142f0abc9a46ae449c732aec6347fc217547854ebb872668716b9494c5232dc564eeab2e26c9b24df3cfd536b7ee3027a39d5e9e89a6d05ea9c - languageName: node - linkType: hard - "@coinbase/wallet-sdk@npm:4.0.4": version: 4.0.4 resolution: "@coinbase/wallet-sdk@npm:4.0.4" @@ -1038,15 +1004,6 @@ __metadata: languageName: node linkType: hard -"@graphql-typed-document-node/core@npm:^3.2.0": - version: 3.2.0 - resolution: "@graphql-typed-document-node/core@npm:3.2.0" - peerDependencies: - graphql: ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0 - checksum: fa44443accd28c8cf4cb96aaaf39d144a22e8b091b13366843f4e97d19c7bfeaf609ce3c7603a4aeffe385081eaf8ea245d078633a7324c11c5ec4b2011bb76d - languageName: node - linkType: hard - "@heroicons/react@npm:^2.0.11": version: 2.1.4 resolution: "@heroicons/react@npm:2.1.4" @@ -1292,25 +1249,6 @@ __metadata: languageName: node linkType: hard -"@metamask/sdk-communication-layer@npm:0.20.2": - version: 0.20.2 - resolution: "@metamask/sdk-communication-layer@npm:0.20.2" - dependencies: - bufferutil: ^4.0.8 - date-fns: ^2.29.3 - debug: ^4.3.4 - utf-8-validate: ^6.0.3 - uuid: ^8.3.2 - peerDependencies: - cross-fetch: ^3.1.5 - eciesjs: ^0.3.16 - eventemitter2: ^6.4.7 - readable-stream: ^3.6.2 - socket.io-client: ^4.5.1 - checksum: 4d8ef60fa459a164db4be5f2bed2a51895e106fa38ee6948b37ca54e4623b9fbe855d7830f7d2fc572fa0a72aac2c81e64a7828899f540fbc362f0ccd4ca1205 - languageName: node - linkType: hard - "@metamask/sdk-communication-layer@npm:0.26.2": version: 0.26.2 resolution: "@metamask/sdk-communication-layer@npm:0.26.2" @@ -1330,28 +1268,6 @@ __metadata: languageName: node linkType: hard -"@metamask/sdk-install-modal-web@npm:0.20.2": - version: 0.20.2 - resolution: "@metamask/sdk-install-modal-web@npm:0.20.2" - dependencies: - qr-code-styling: ^1.6.0-rc.1 - peerDependencies: - i18next: 22.5.1 - react: ^18.2.0 - react-dom: ^18.2.0 - react-i18next: ^13.2.2 - react-native: "*" - peerDependenciesMeta: - react: - optional: true - react-dom: - optional: true - react-native: - optional: true - checksum: cba31f783ddb6351d5ef7e47d61a8eeee8ab3d95af345069ea0055ccc500da34c6f3c2e729db20664d4ff7f2c147d6e9f783131557cf28b1fb218737cdcc6d1c - languageName: node - linkType: hard - "@metamask/sdk-install-modal-web@npm:0.26.0": version: 0.26.0 resolution: "@metamask/sdk-install-modal-web@npm:0.26.0" @@ -1374,44 +1290,6 @@ __metadata: languageName: node linkType: hard -"@metamask/sdk@npm:0.20.3": - version: 0.20.3 - resolution: "@metamask/sdk@npm:0.20.3" - dependencies: - "@metamask/onboarding": ^1.0.1 - "@metamask/providers": ^15.0.0 - "@metamask/sdk-communication-layer": 0.20.2 - "@metamask/sdk-install-modal-web": 0.20.2 - "@types/dom-screen-wake-lock": ^1.0.0 - bowser: ^2.9.0 - cross-fetch: ^4.0.0 - debug: ^4.3.4 - eciesjs: ^0.3.15 - eth-rpc-errors: ^4.0.3 - eventemitter2: ^6.4.7 - i18next: 22.5.1 - i18next-browser-languagedetector: 7.1.0 - obj-multiplex: ^1.0.0 - pump: ^3.0.0 - qrcode-terminal-nooctal: ^0.12.1 - react-native-webview: ^11.26.0 - readable-stream: ^3.6.2 - rollup-plugin-visualizer: ^5.9.2 - socket.io-client: ^4.5.1 - util: ^0.12.4 - uuid: ^8.3.2 - peerDependencies: - react: ^18.2.0 - react-dom: ^18.2.0 - peerDependenciesMeta: - react: - optional: true - react-dom: - optional: true - checksum: f3e0a99e744c12cec7e3c00aa9f4517b467d0b403379b70780303877bc84fedc9f068738ef6dfd04426aec4235729bde1e1667cf54f744506eaf6df5345498ac - languageName: node - linkType: hard - "@metamask/sdk@npm:0.26.3": version: 0.26.3 resolution: "@metamask/sdk@npm:0.26.3" @@ -2593,6 +2471,8 @@ __metadata: resolution: "@se-2/nextjs@workspace:packages/nextjs" dependencies: "@coinbase/onchainkit": 0.11.0 + "@emotion/react": ^11.11.4 + "@emotion/styled": ^11.11.5 "@ethereum-attestation-service/eas-sdk": ^2.3.0 "@heroicons/react": ^2.0.11 "@mui/material": ^5.15.21 @@ -2608,7 +2488,9 @@ __metadata: "@uniswap/sdk-core": ^4.0.1 "@uniswap/v2-sdk": ^3.0.1 abitype: ^1.0.2 + apexcharts: ^3.49.2 autoprefixer: ^10.4.12 + axios: ^1.7.2 blo: ^1.0.1 burner-connector: ^0.0.8 daisyui: 4.5.0 @@ -2640,7 +2522,7 @@ __metadata: uuidv4: ^6.2.13 vercel: ^32.4.1 viem: 2.10.9 - wagmi: 2.9.5 + wagmi: ^2.10.8 zustand: ^4.1.2 languageName: unknown linkType: soft @@ -2972,24 +2854,6 @@ __metadata: languageName: node linkType: hard -"@tanstack/query-core@npm:5.49.1": - version: 5.49.1 - resolution: "@tanstack/query-core@npm:5.49.1" - checksum: 244ce65d0e47388073adaebac72feba6032b51458f35469941bddfe5cc5eb9d354a89c43e1e37c655d16c869effbd5edf05952810b64e39deede18560d4bac55 - languageName: node - linkType: hard - -"@tanstack/react-query@npm:^5": - version: 5.49.2 - resolution: "@tanstack/react-query@npm:5.49.2" - dependencies: - "@tanstack/query-core": 5.49.1 - peerDependencies: - react: ^18.0.0 - checksum: 8f96a1292a3ec1fb249a2606acb0a7dbbeb6c4f4c9f424b69997df8b7bcf506b62ce1b93bc57ca9154534f98e538166cc8822e3eaaccac4bb2393c9f17839fdd - languageName: node - linkType: hard - "@tanstack/react-query@npm:^5.28.6": version: 5.49.0 resolution: "@tanstack/react-query@npm:5.49.0" @@ -4017,28 +3881,6 @@ __metadata: languageName: node linkType: hard -"@wagmi/connectors@npm:5.0.4": - version: 5.0.4 - resolution: "@wagmi/connectors@npm:5.0.4" - dependencies: - "@coinbase/wallet-sdk": 4.0.2 - "@metamask/sdk": 0.20.3 - "@safe-global/safe-apps-provider": 0.18.1 - "@safe-global/safe-apps-sdk": 8.1.0 - "@walletconnect/ethereum-provider": 2.13.0 - "@walletconnect/modal": 2.6.2 - cbw-sdk: "npm:@coinbase/wallet-sdk@3.9.3" - peerDependencies: - "@wagmi/core": 2.10.3 - typescript: ">=5.0.4" - viem: 2.x - peerDependenciesMeta: - typescript: - optional: true - checksum: b6ecdf5e4450bebfdb0415e61f323bb9bd9ec4e3d294202bfa4032297dbb645771480dfbbb56b9530bdc0ad353a594634cb3adbbc13f6d7502bfc54873420587 - languageName: node - linkType: hard - "@wagmi/core@npm:2.10.2": version: 2.10.2 resolution: "@wagmi/core@npm:2.10.2" @@ -4059,26 +3901,6 @@ __metadata: languageName: node linkType: hard -"@wagmi/core@npm:2.10.3": - version: 2.10.3 - resolution: "@wagmi/core@npm:2.10.3" - dependencies: - eventemitter3: 5.0.1 - mipd: 0.0.5 - zustand: 4.4.1 - peerDependencies: - "@tanstack/query-core": ">=5.0.0" - typescript: ">=5.0.4" - viem: 2.x - peerDependenciesMeta: - "@tanstack/query-core": - optional: true - typescript: - optional: true - checksum: 80c7929d933c7527c929c12187f60e86373af83581ffa3331d183995703a471d487ca2c1a85b998686af6dfe57358950e5aea593046ccdd53937d502fa6a411d - languageName: node - linkType: hard - "@wagmi/core@npm:2.11.5": version: 2.11.5 resolution: "@wagmi/core@npm:2.11.5" @@ -4473,7 +4295,7 @@ __metadata: languageName: node linkType: hard -"abitype@npm:1.0.5, abitype@npm:^1.0.2": +"abitype@npm:^1.0.2": version: 1.0.5 resolution: "abitype@npm:1.0.5" peerDependencies: @@ -5777,7 +5599,7 @@ __metadata: languageName: node linkType: hard -"clsx@npm:^2.1.0, clsx@npm:^2.1.1": +"clsx@npm:^2.1.0": version: 2.1.1 resolution: "clsx@npm:2.1.1" checksum: acd3e1ab9d8a433ecb3cc2f6a05ab95fe50b4a3cfc5ba47abb6cbf3754585fcb87b84e90c822a1f256c4198e3b41c7f6c391577ffc8678ad587fc0976b24fd57 @@ -6054,7 +5876,7 @@ __metadata: languageName: node linkType: hard -"cross-fetch@npm:^3.1.4, cross-fetch@npm:^3.1.5": +"cross-fetch@npm:^3.1.4": version: 3.1.8 resolution: "cross-fetch@npm:3.1.8" dependencies: @@ -8747,25 +8569,6 @@ __metadata: languageName: node linkType: hard -"graphql-request@npm:^6.1.0": - version: 6.1.0 - resolution: "graphql-request@npm:6.1.0" - dependencies: - "@graphql-typed-document-node/core": ^3.2.0 - cross-fetch: ^3.1.5 - peerDependencies: - graphql: 14 - 16 - checksum: 6d62630a0169574442320651c1f7626c0c602025c3c46b19e09417c9579bb209306ee63de9793a03be2e1701bb7f13971f8545d99bc6573e340f823af0ad35b2 - languageName: node - linkType: hard - -"graphql@npm:^14 || ^15 || ^16": - version: 16.9.0 - resolution: "graphql@npm:16.9.0" - checksum: 8cb3d54100e9227310383ce7f791ca48d12f15ed9f2021f23f8735f1121aafe4e5e611a853081dd935ce221724ea1ae4638faef5d2921fb1ad7c26b5f46611e9 - languageName: node - linkType: hard - "h3@npm:^1.10.2, h3@npm:^1.11.1": version: 1.12.0 resolution: "h3@npm:1.12.0" @@ -11992,7 +11795,7 @@ __metadata: languageName: node linkType: hard -"permissionless@npm:^0.1.29, permissionless@npm:^0.1.30": +"permissionless@npm:^0.1.30": version: 0.1.31 resolution: "permissionless@npm:0.1.31" peerDependencies: @@ -13167,7 +12970,6 @@ __metadata: version: 0.0.0-use.local resolution: "se-2@workspace:." dependencies: - "@coinbase/onchainkit": ^0.23.4 "@emotion/react": ^11.11.4 "@emotion/styled": ^11.11.5 "@ethereum-attestation-service/eas-sdk": ^2.3.0 @@ -14143,15 +13945,6 @@ __metadata: languageName: node linkType: hard -"tailwind-merge@npm:^2.3.0": - version: 2.3.0 - resolution: "tailwind-merge@npm:2.3.0" - dependencies: - "@babel/runtime": ^7.24.1 - checksum: 1254eea9b6ec480911f01e2909e3ba35ca3c534d9db1405dfe9bdf51d100663a3935cb20662c023ab44ee9679bce10d86bd27beba23d0174beff32a6acb06978 - languageName: node - linkType: hard - "tailwindcss@npm:^3.4.3": version: 3.4.4 resolution: "tailwindcss@npm:3.4.4" @@ -15268,47 +15061,7 @@ __metadata: languageName: node linkType: hard -"viem@npm:^2.13.8": - version: 2.16.5 - resolution: "viem@npm:2.16.5" - dependencies: - "@adraffy/ens-normalize": 1.10.0 - "@noble/curves": 1.4.0 - "@noble/hashes": 1.4.0 - "@scure/bip32": 1.4.0 - "@scure/bip39": 1.3.0 - abitype: 1.0.5 - isows: 1.0.4 - ws: 8.17.1 - peerDependencies: - typescript: ">=5.0.4" - peerDependenciesMeta: - typescript: - optional: true - checksum: a3fe349ea35ce68107f45fbbcb715ebfd20e1dc4fd821a3b8a10a41300ef67e801e9c7352fac3e486dbcc6e297fceb8b40d88c92748d7582a5b1ccaf8ee65c32 - languageName: node - linkType: hard - -"wagmi@npm:2.9.5": - version: 2.9.5 - resolution: "wagmi@npm:2.9.5" - dependencies: - "@wagmi/connectors": 5.0.4 - "@wagmi/core": 2.10.3 - use-sync-external-store: 1.2.0 - peerDependencies: - "@tanstack/react-query": ">=5.0.0" - react: ">=18" - typescript: ">=5.0.4" - viem: 2.x - peerDependenciesMeta: - typescript: - optional: true - checksum: acc20f7fbbd7cff95a7e221cbb279b2b7351287b2ae89e80873c57b3eef6b98ea6f373be365a2d5133ac558a3979fc789c36b1379323351252941f260b6e66b7 - languageName: node - linkType: hard - -"wagmi@npm:^2.9.11": +"wagmi@npm:^2.10.8": version: 2.10.8 resolution: "wagmi@npm:2.10.8" dependencies: