Skip to content

Commit

Permalink
feat: add an option to enable manifest parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkvasnicak committed Dec 9, 2024
1 parent bb96c9a commit 37e92a6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/render/src/unstable-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ export type UseFrameOptions<
frameActionProxy: string;
/** the route used to GET the initial frame via proxy */
frameGetProxy: string;
/**
* Will request the Farcaster Frames v2 manifest.
*
* This is only valid for Frames v2 and GET requests.
*
* @defaultValue false
*/
parseFarcasterManifest?: boolean;
/**
* Called on initial frame load.
*
Expand Down Expand Up @@ -501,6 +509,14 @@ export type UseFetchFrameOptions<
* URL or path to the frame proxy handling POST requests.
*/
frameActionProxy: string;
/**
* Will request the Farcaster Frames v2 manifest.
*
* This is only valid for Frames v2 and GET requests.
*
* @defaultValue false
*/
parseFarcasterManifest?: boolean;
/**
* Extra payload to be sent with the POST request.
*/
Expand Down
10 changes: 10 additions & 0 deletions packages/render/src/unstable-use-fetch-frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function useFetchFrame<
frameActionProxy,
frameGetProxy,
extraButtonRequestPayload,
parseFarcasterManifest = false,
onTransaction,
transactionDataSuffix,
onSignature,
Expand Down Expand Up @@ -157,6 +158,7 @@ export function useFetchFrame<
proxyUrl: frameGetProxy,
fetchFn,
url: request.url,
parseFarcasterManifest,
});

const endTime = new Date();
Expand Down Expand Up @@ -800,6 +802,10 @@ function proxyUrlAndSearchParamsToUrl(
type FetchProxiedArg = {
proxyUrl: string;
fetchFn: typeof fetch;
/**
* Valid only for GET requests
*/
parseFarcasterManifest?: boolean;
} & (
| {
frameAction: SignedFrameAction;
Expand Down Expand Up @@ -836,6 +842,10 @@ async function fetchProxied(
);
}

if (params.parseFarcasterManifest) {
searchParams.set("parseFarcasterManifest", "true");
}

searchParams.set("url", params.url);

const proxyUrl = proxyUrlAndSearchParamsToUrl(params.proxyUrl, searchParams);
Expand Down
2 changes: 2 additions & 0 deletions packages/render/src/unstable-use-frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export function useFrame_unstable<
frameActionProxy,
/** Ex: /frames */
frameGetProxy,
parseFarcasterManifest = false,
extraButtonRequestPayload,
resolveSigner: resolveSpecification,
onError = onErrorFallback,
Expand Down Expand Up @@ -238,6 +239,7 @@ export function useFrame_unstable<
onTransactionProcessingSuccess,
onTransactionStart,
onTransactionSuccess,
parseFarcasterManifest,
});

const fetchFrameRef = useFreshRef(fetchFrame);
Expand Down

0 comments on commit 37e92a6

Please sign in to comment.