Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neynar/react",
"version": "0.8.0",
"version": "0.8.1",
"description": "Farcaster frontend component library powered by Neynar",
"main": "dist/bundle.cjs.js",
"module": "dist/bundle.es.js",
Expand Down
11 changes: 1 addition & 10 deletions src/components/molecules/FrameCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,9 @@ const InputField = styled.input({
});

function CastFrameBtn({ number, text, actionType, target, frameUrl, handleOnClick }: any) {
const handleClick = () => {
if (actionType === "link" && target) {
window.open(target, "_blank");
} else if(actionType === "mint") {
window.open(frameUrl, "_blank");
} else {
handleOnClick(number);
}
};

return (
<FrameButton onClick={handleClick}>
<FrameButton onClick={() => handleOnClick(number)}>
{text}
{(actionType === "link" || actionType === "post_redirect" || actionType === "mint") && <ExternalLinkIcon />}
</FrameButton>
Expand Down
65 changes: 35 additions & 30 deletions src/components/organisms/NeynarFrameCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,41 +93,46 @@ export const NeynarFrameCard: React.FC<NeynarFrameCardProps> = ({ url, onFrameBt
showToast(ToastType.Error, 'Signer UUID is not available');
throw new Error('Signer UUID is not available');
}

const button = localFrame.buttons.find(btn => btn.index === btnIndex);
const postUrl = button?.post_url;

try {
const response = await fetchWithTimeout(`${NEYNAR_API_URL}/v2/farcaster/frame/action?client_id=${client_id}`, {
method: "POST",
headers: {
"accept": "application/json",
"content-type": "application/json"
},
body: JSON.stringify({
"signer_uuid": signerValue,
"action": {
"button": button,
"frames_url": localFrame.frames_url,
"post_url": postUrl ? postUrl : localFrame.frames_url,
"input": {
"text": inputValue

if ((button?.action_type === "link" || button?.action_type === "post_redirect" || button?.action_type === "mint")) {
window.open(button.action_type !== 'mint' && button?.target ? button?.target : localFrame.frames_url, '_blank');
return localFrame;
} else {
try {
const response = await fetchWithTimeout(`${NEYNAR_API_URL}/v2/farcaster/frame/action?client_id=${client_id}`, {
method: "POST",
headers: {
"accept": "application/json",
"content-type": "application/json"
},
body: JSON.stringify({
"signer_uuid": signerValue,
"action": {
"button": button,
"frames_url": localFrame.frames_url,
"post_url": postUrl ? postUrl : localFrame.frames_url,
"input": {
"text": inputValue
}
}
}
})
}) as Response;
if (response.ok) {
const json = await response.json() as NeynarFrame;
return json;
} else {
showToast(ToastType.Error, `HTTP error! status: ${response.status}`);
throw new Error(`HTTP error! status: ${response.status}`);
})
}) as Response;
if (response.ok) {
const json = await response.json() as NeynarFrame;
return json;
} else {
showToast(ToastType.Error, `HTTP error! status: ${response.status}`);
throw new Error(`HTTP error! status: ${response.status}`);
}
} catch (error) {
showToast(ToastType.Error, `An error occurred while processing the button press: ${error}`);
throw error;
}
} catch (error) {
showToast(ToastType.Error, `An error occurred while processing the button press: ${error}`);
throw error;
}
};
}

const handleFrameBtnPress = async (
btnIndex: number,
Expand Down