Skip to content

Commit

Permalink
Merge pull request #579 from us3r-network/F-frameActionUrl-ttang
Browse files Browse the repository at this point in the history
fix: frame url
  • Loading branch information
Tonyce authored Feb 29, 2024
2 parents ea4a929 + f0e5634 commit 8e12db9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions apps/u3/src/components/social/Embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,11 @@ function EmbedCastFrame({
}
const trustedDataResult = await makeFrameAction(
{
url: Buffer.from(data.url),
url: Buffer.from(frameData.url || ''),
buttonIndex: index,
castId,
inputText: Buffer.from(frameText),
state: Buffer.from(''),
},
{
fid: currFid,
Expand All @@ -237,7 +238,7 @@ function EmbedCastFrame({
const trustedDataValue = trustedDataResult.value;
const untrustedData = {
fid: currFid,
url: frameData.fcFramePostUrl || frameData.url,
url: frameData.url || '',
messageHash: toHex(trustedDataValue.hash),
network: FARCASTER_NETWORK,
buttonIndex: index,
Expand All @@ -246,14 +247,15 @@ function EmbedCastFrame({
fid: castId.fid,
hash: toHex(castId.hash),
},
state: '',
};
const trustedData = {
messageBytes: Buffer.from(
Message.encode(trustedDataValue).finish()
).toString('hex'),
};
const postData = {
actionUrl: frameData.fcFramePostUrl || frameData.url,
actionUrl: frameData.fcFramePostUrl,
untrustedData,
trustedData,
};
Expand All @@ -265,14 +267,27 @@ function EmbedCastFrame({
toast.error(resp.data.msg);
return;
}
setFrameData(resp.data.data?.metadata);
setFrameData((prev) => ({
url: prev.url,
...resp.data.data?.metadata,
}));
} else if (buttonAction === 'post_redirect') {
const resp = await postFrameActionRedirectApi(postData);
if (resp.data.code !== 0) {
toast.error(resp.data.msg);
return;
}
setFrameRedirect(resp.data.data?.redirectUrl || '');
} else {
const resp = await postFrameActionApi(postData);
if (resp.data.code !== 0) {
toast.error(resp.data.msg);
return;
}
setFrameData((prev) => ({
url: prev.url,
...resp.data.data?.metadata,
}));
}
},
[frameData, currFid, encryptedSigner, castId, frameText]
Expand Down

0 comments on commit 8e12db9

Please sign in to comment.