Skip to content

Commit

Permalink
feat: added new mint and link Frame spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia committed Feb 7, 2024
1 parent f9f7652 commit 5b971e0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/components/FrameMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ type FrameMetadataReact = FrameMetadataType & {
* label: 'Redirect to cute dog pictures',
* action: 'post_redirect',
* },
* {
* label: 'Mint',
* action: 'mint',
* target: 'https://zizzamia.xyz/api/frame/mint',
* },
* ]}
* image="https://zizzamia.xyz/park-1.png"
* input={{
Expand All @@ -32,11 +37,11 @@ type FrameMetadataReact = FrameMetadataType & {
* ```
*
* @param {FrameMetadataReact} props - The metadata for the frame.
* @param {Array<{ label: string, action?: string }>} props.buttons - The buttons.
* @param {string} props.image - The image URL.
* @param {string} props.input - The input text.
* @param {string} props.post_url - The post URL.
* @param {number} props.refresh_period - The refresh period.
* @param {Array<{ label: string, action?: string }>} props.buttons - The buttons.
* @param {React.ComponentType<any> | undefined} props.wrapper - The wrapper component meta tags are rendered in.
* @returns {React.ReactElement} The FrameMetadata component.
*/
Expand All @@ -61,6 +66,10 @@ export function FrameMetadata({
{!!button.action && (
<meta name={`fc:frame:button:${index + 1}:action`} content={button.action} />
)}
{!!button.target && (
<meta name={`fc:frame:button:${index + 1}:target`} content={button.target} />
)
}
</>
);
})}
Expand Down
3 changes: 3 additions & 0 deletions src/core/getFrameHtmlResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ function getFrameHtmlResponse({
if (button.action) {
buttonHtml += `<meta property="fc:frame:button:${index + 1}:action" content="${button.action}" />`;
}
if (button.target) {
buttonHtml += `<meta property="fc:frame:button:${index + 1}:target" content="${button.target}" />`;
}
return buttonHtml;
})
.join('');
Expand Down
3 changes: 3 additions & 0 deletions src/core/getFrameMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export const getFrameMetadata = function ({
if (button.action) {
metadata[`fc:frame:button:${index + 1}:action`] = button.action;
}
if (button.target) {
metadata[`fc:frame:button:${index + 1}:target`] = button.target;
}
});
}
if (post_url) {
Expand Down
3 changes: 2 additions & 1 deletion src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ export function convertToFrame(json: any) {
}

export type FrameButtonMetadata = {
action?: 'link' | 'mint' | 'post' | 'post_redirect';
label: string;
action?: 'post' | 'post_redirect';
target?: string;
};

export type FrameInputMetadata = {
Expand Down

0 comments on commit 5b971e0

Please sign in to comment.