-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframes.ts
More file actions
56 lines (53 loc) · 1.57 KB
/
frames.ts
File metadata and controls
56 lines (53 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* eslint-disable react/jsx-key */
import { farcasterHubContext, openframes } from "frames.js/middleware";
import { imagesWorkerMiddleware } from "frames.js/middleware/images-worker";
import { createFrames } from "frames.js/next";
import { getXmtpFrameMessage, isXmtpFrameActionPayload } from "frames.js/xmtp";
import { DEFAULT_DEBUGGER_HUB_URL } from "../debug";
import { getLensFrameMessage, isLensFrameActionPayload } from "frames.js/lens";
export const frames = createFrames({
basePath: "/frames",
initialState: {
pageIndex: 0,
},
middleware: [
imagesWorkerMiddleware({
imagesRoute: "/images",
}),
farcasterHubContext({
hubHttpUrl: DEFAULT_DEBUGGER_HUB_URL,
}),
openframes({
clientProtocol: {
id: "xmtp",
version: "2024-02-09",
},
handler: {
isValidPayload: (body: JSON) => isXmtpFrameActionPayload(body),
getFrameMessage: async (body: JSON) => {
if (!isXmtpFrameActionPayload(body)) {
return undefined;
}
const result = await getXmtpFrameMessage(body);
return { ...result };
},
},
}),
openframes({
clientProtocol: {
id: "lens",
version: "1.0.0",
},
handler: {
isValidPayload: (body: JSON) => isLensFrameActionPayload(body),
getFrameMessage: async (body: JSON) => {
if (!isLensFrameActionPayload(body)) {
return undefined;
}
const result = await getLensFrameMessage(body);
return { ...result };
},
},
}),
],
});