Skip to content

Commit 0004a9c

Browse files
authored
Merge pull request #283 from framesjs/fix/validate-message-bug
fix: validateFrameMessage bug
2 parents a0a7e8e + 8634f7d commit 0004a9c

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

.changeset/dirty-wombats-hunt.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"frames.js": patch
3+
---
4+
5+
fix: validateFrameMessage bug
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { getFrameMessage } from "./getFrameMessage";
2+
import { type ActionIndex } from "./types";
3+
4+
describe("getFrameMessage", () => {
5+
it("should correctly get frame message for a valid message", async () => {
6+
const sampleBody = {
7+
untrustedData: {
8+
fid: 1689,
9+
url: "https://bc53-102-135-243-163.ngrok-free.app",
10+
messageHash: "0xd556114225234a6832d0583a2140b1d93f9754e8",
11+
timestamp: 1712218321000,
12+
network: 1,
13+
buttonIndex: 1 as ActionIndex,
14+
inputText: "",
15+
state: JSON.stringify({ counter: 3 }),
16+
castId: {
17+
fid: 1689,
18+
hash: "0x0000000000000000000000000000000000000001",
19+
},
20+
},
21+
trustedData: {
22+
messageBytes:
23+
"0a68080d10990d18d1f5ff3020018201590a2b68747470733a2f2f626335332d3130322d3133352d3234332d3136332e6e67726f6b2d667265652e61707010011a1908990d121400000000000000000000000000000000000000012a0d7b22636f756e746572223a337d1214d556114225234a6832d0583a2140b1d93f9754e818012240cd2ad34f9a3a960759a0ef4296dab976b222568e30a21803559e54b66730cdb548b8914f85e69d92fbfc05a2bdcd5ee3702a83de399cdb48776d9669e28d0f0d28013220a5f666cac97ae9f09f78cfaaa624ea2a1f03f042aa87c955d0113275e54e9cfe",
24+
},
25+
};
26+
27+
const message = await getFrameMessage(sampleBody);
28+
29+
expect(message).toMatchObject({
30+
isValid: true,
31+
buttonIndex: 1,
32+
inputText: "",
33+
state: JSON.stringify({ counter: 3 }),
34+
});
35+
});
36+
});

packages/frames.js/src/validateFrameMessage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function isValidateMessageJson(value: unknown): value is ValidateMessageJson {
1919
return (
2020
typeof validateMessageJson.valid === "boolean" &&
2121
validateMessageJson.valid &&
22-
typeof validateMessageJson.message === "string"
22+
typeof validateMessageJson.message === "object"
2323
);
2424
}
2525

0 commit comments

Comments
 (0)