diff --git a/.changeset/tidy-icons-arrive.md b/.changeset/tidy-icons-arrive.md new file mode 100644 index 0000000000..8d2dcb5898 --- /dev/null +++ b/.changeset/tidy-icons-arrive.md @@ -0,0 +1,5 @@ +--- +"@coinbase/onchainkit": patch +--- + +**feat**: added `generateFrameNextMetadata` to help generates the metadata for a Farcaster Frame. diff --git a/package.json b/package.json index a8329bb3ba..3401980fac 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "MIT", "dependencies": { "react": "^18", - "viem": "2.4.1" + "viem": "2.5.0" }, "scripts": { "prebuild": "rimraf dist", diff --git a/src/core/generateFrameNextMetadata.ts b/src/core/generateFrameNextMetadata.ts new file mode 100644 index 0000000000..f371152516 --- /dev/null +++ b/src/core/generateFrameNextMetadata.ts @@ -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 = { + '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; +}; diff --git a/src/core/index.ts b/src/core/index.ts new file mode 100644 index 0000000000..43e8726bc4 --- /dev/null +++ b/src/core/index.ts @@ -0,0 +1 @@ +export { generateFrameNextMetadata } from './generateFrameNextMetadata'; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 5075f29e6f..3caa4f790f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,5 @@ // ☕️ -const version = '0.0.0'; \ No newline at end of file +const version = '0.1.1'; + +// TODO remove this line from here +export { generateFrameNextMetadata } from './core/generateFrameNextMetadata'; diff --git a/yarn.lock b/yarn.lock index b4d3aba126..750e71d95d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 @@ -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" @@ -2563,7 +2563,7 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 62887977a4d9a3100d9351ff80103dbcbd171d550d870b4894d4e74e122576e9f1599a15346a9bd9b71997413b9708ba9182ac0c2773d2fd65aa8924e309c706 + checksum: 1a15999dea2f4fd97d52f7436aa237d7334b41aa50a509a713ef7719437d28bdc4daa1e9f9bad56016caef72294d057c4dd47931d4f6aecfa243ba4cc60e2c51 languageName: node linkType: hard