Skip to content

Commit

Permalink
update db for requestedBy author
Browse files Browse the repository at this point in the history
  • Loading branch information
bianc8 committed Nov 29, 2024
1 parent b696e44 commit ac5a734
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/app/frames/token/[address]/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { BackgroundImage } from "@/app/frames/components/background-image";
import { getTokenFromAddress } from "@/utils/db";

import { getAddress, isAddress } from "viem";
import { getUserDataForFid } from "frames.js";

function truncate(text: string, max: number) {
return text.slice(0, max - 1) + (text.length > max ? "..." : "");
Expand All @@ -32,7 +31,12 @@ const frameHandler = frames(async (ctx) => {
if (!token) {
throw new Error("Token not found");
}
const requestor = await getUserDataForFid({ fid: token.requestedBy });
const requestor = JSON.parse(token.requestedBy) as {
fid: number;
username: string;
displayName: string;
profileImage: string;
};
return {
image: (
<BackgroundImage
Expand Down Expand Up @@ -82,8 +86,7 @@ const frameHandler = frames(async (ctx) => {
<UserBanner
user={{
displayName: truncate(
`@${requestor?.username}` ||
token.requestedBy.toString(),
`@${requestor?.username}` || requestor?.fid.toString(),
15
),
pfp: requestor?.profileImage || "",
Expand Down
3 changes: 2 additions & 1 deletion src/utils/schemas/db.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const tokenTable = sqliteTable("token", {
address: text("address").unique().notNull(),
name: text("name").notNull(),
ticker: text("ticker").notNull(),
requestedBy: integer("requestedBy").notNull(), // user Farcaster FID
requestedBy: text("requestedBy").notNull(),
image: text("image").notNull(),
dateTime: text("date_time").notNull(), // date and time to allow the trading on the pool, converted to GMT time
createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`),
Expand All @@ -25,6 +25,7 @@ export const briankerRequestsTable = sqliteTable("brianker_requests", {
brianResponse: text("brian_response"),
grokResponse: text("grok_response"),
redisOperationId: text("redis_operation_id"),
tokenAddress: text("token_address").references(() => tokenTable.address),
createdAt: text("created_at").default(sql`CURRENT_TIMESTAMP`),
updatedAt: text("updated_at").default(sql`CURRENT_TIMESTAMP`),
});
Expand Down

0 comments on commit ac5a734

Please sign in to comment.