Skip to content

Commit

Permalink
feat: added generateFrameNextMetadata to help generates the metadat…
Browse files Browse the repository at this point in the history
…a for a Farcaster Frame (#12)
  • Loading branch information
Zizzamia authored Jan 27, 2024
1 parent cd1863e commit a83b0f9
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-icons-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@coinbase/onchainkit": patch
---

**feat**: added `generateFrameNextMetadata` to help generates the metadata for a Farcaster Frame.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "MIT",
"dependencies": {
"react": "^18",
"viem": "2.4.1"
"viem": "2.5.0"
},
"scripts": {
"prebuild": "rimraf dist",
Expand Down
24 changes: 24 additions & 0 deletions src/core/generateFrameNextMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* This function generates the metadata for a Farcaster Frame.
* @param param0
* @returns
*/
export const generateFrameNextMetadata = function ({
buttons,
image,
post_url,
}: {
buttons: string[];
image: string;
post_url: string;
}) {
const metadata: Record<string, string> = {
'fc:frame': 'vNext',
};
buttons.forEach((button, index) => {
metadata[`fc:frame:button:${index + 1}`] = button;
});
metadata['fc:frame:image'] = image;
metadata['fc:frame:post_url'] = post_url;
return metadata;
};
1 change: 1 addition & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { generateFrameNextMetadata } from './generateFrameNextMetadata';
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
// ☕️
const version = '0.0.0';
const version = '0.1.1';

// TODO remove this line from here
export { generateFrameNextMetadata } from './core/generateFrameNextMetadata';
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ __metadata:
prettier: "npm:^3.1.1"
react: "npm:^18"
typescript: "npm:~5.3.3"
viem: "npm:2.4.1"
viem: "npm:2.5.0"
yarn: "npm:^1.22.21"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -2546,9 +2546,9 @@ __metadata:
languageName: node
linkType: hard

"viem@npm:2.4.1":
version: 2.4.1
resolution: "viem@npm:2.4.1"
"viem@npm:2.5.0":
version: 2.5.0
resolution: "viem@npm:2.5.0"
dependencies:
"@adraffy/ens-normalize": "npm:1.10.0"
"@noble/curves": "npm:1.2.0"
Expand All @@ -2563,7 +2563,7 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 62887977a4d9a3100d9351ff80103dbcbd171d550d870b4894d4e74e122576e9f1599a15346a9bd9b71997413b9708ba9182ac0c2773d2fd65aa8924e309c706
checksum: 1a15999dea2f4fd97d52f7436aa237d7334b41aa50a509a713ef7719437d28bdc4daa1e9f9bad56016caef72294d057c4dd47931d4f6aecfa243ba4cc60e2c51
languageName: node
linkType: hard

Expand Down

0 comments on commit a83b0f9

Please sign in to comment.