Skip to content

Commit

Permalink
fix: getFrameMessage (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia authored Feb 1, 2024
1 parent b95951f commit 97c146d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-actors-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@coinbase/onchainkit': patch
---

- **fix**: missing apiKey
25 changes: 22 additions & 3 deletions src/core/getFrameMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { FrameValidationResponse } from './farcasterTypes';
import { neynarFrameValidation } from '../utils/neynar/frame/neynarFrameFunctions';
import {
NEYNAR_DEFAULT_API_KEY,
neynarFrameValidation,
} from '../utils/neynar/frame/neynarFrameFunctions';

type FrameMessageOptions =
| {
neynarApiKey?: string;
castReactionContext?: boolean;
followContext?: boolean;
}
| undefined;

/**
* Given a frame message, decode and validate it.
Expand All @@ -8,9 +19,17 @@ import { neynarFrameValidation } from '../utils/neynar/frame/neynarFrameFunction
*
* @param body The JSON received by server on frame callback
*/
async function getFrameMessage(body: any): Promise<FrameValidationResponse> {
async function getFrameMessage(
body: any,
messageOptions?: FrameMessageOptions,
): Promise<FrameValidationResponse> {
// Validate the message
const response = await neynarFrameValidation(body?.trustedData?.messageBytes);
const response = await neynarFrameValidation(
body?.trustedData?.messageBytes,
messageOptions?.neynarApiKey || NEYNAR_DEFAULT_API_KEY,
messageOptions?.castReactionContext || true,
messageOptions?.followContext || true,
);
if (response?.valid) {
return {
isValid: true,
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.4.0';
export const version = '0.4.1';

0 comments on commit 97c146d

Please sign in to comment.