Skip to content

Commit

Permalink
feat: added post_url optional metadata for tx Frame (#237)
Browse files Browse the repository at this point in the history
Co-authored-by: Leonardo Zizzamia <[email protected]>
  • Loading branch information
cnasc and Zizzamia authored Mar 8, 2024
1 parent 8028007 commit 292c7b0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .changeset/nine-wasps-work.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@coinbase/onchainkit': patch
---

- **feat**: added `post_url` optional metadata for `tx` Frame. By @zizzamia #235
- **feat**: added `post_url` optional metadata for `tx` Frame. By @zizzamia, @cnasc, @spennyp #237
10 changes: 10 additions & 0 deletions src/frame/getFrameHtmlResponse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ describe('getFrameHtmlResponse', () => {
const html = getFrameHtmlResponse({
buttons: [
{ label: 'Transaction', action: 'tx', target: 'https://zizzamia.xyz/api/frame/tx' },
{
label: 'Transaction 2',
action: 'tx',
target: 'https://zizzamia.xyz/api/frame/tx',
postUrl: 'https://zizzamia.xyz/api/frame/tx-success',
},
],
image: 'https://zizzamia.xyz/park-1.png',
});
Expand All @@ -160,6 +166,10 @@ describe('getFrameHtmlResponse', () => {
<meta property="fc:frame:button:1" content="Transaction" />
<meta property="fc:frame:button:1:action" content="tx" />
<meta property="fc:frame:button:1:target" content="https://zizzamia.xyz/api/frame/tx" />
<meta property="fc:frame:button:2" content="Transaction 2" />
<meta property="fc:frame:button:2:action" content="tx" />
<meta property="fc:frame:button:2:target" content="https://zizzamia.xyz/api/frame/tx" />
<meta property="fc:frame:button:2:post_url" content="https://zizzamia.xyz/api/frame/tx-success" />
<meta property="og:image" content="https://zizzamia.xyz/park-1.png" />
<meta property="fc:frame:image" content="https://zizzamia.xyz/park-1.png" />
Expand Down
3 changes: 3 additions & 0 deletions src/frame/getFrameHtmlResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ function getFrameHtmlResponse({
if (button.action && button.target) {
buttonHtml += ` <meta property="fc:frame:button:${index + 1}:target" content="${button.target}" />\n`;
}
if (button.action && button.action === 'tx' && button.postUrl) {
buttonHtml += ` <meta property="fc:frame:button:${index + 1}:post_url" content="${button.postUrl}" />\n`;
}
return buttonHtml;
})
.join('');
Expand Down

0 comments on commit 292c7b0

Please sign in to comment.