Skip to content

mod: poll #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
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
11 changes: 9 additions & 2 deletions docs/pages/create-mod/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ then you can access the values of the input by chaining properties like `{{refs.

`{{embed}}` -> the embed value that triggered the `richEmbedEntrypoints`

`{{date.now.iso}}` -> the current date as 8601 ISO format

`{{user.wallet.address}}` -> if requested in permissions, is the wallet address of the current user

`{{user.farcaster.fid}}` -> if requested in permissions, is the fid of the current user

## Properties of the Manifest

```ts
Expand Down Expand Up @@ -41,7 +47,7 @@ type ModManifest = {
/** A definition map of reusable elements, using their id as the key */
elements?: Record<string, ModElement[]>;
/** Permissions requested by the Mod */
permissions?: Array<"user.wallet.address" | "web3.eth.personal.sign">;
permissions?: Array<"user.wallet.address" | "web3.eth.personal.sign" | 'farcaster.messagereply.create' | 'user.farcaster.fid'>;
};
```

Expand Down Expand Up @@ -86,7 +92,8 @@ export type ModElement =
| {
ref?: string;
type: "select";
options: Array<{ label: string; value: any }>;
options: Array<{ label: string; value: string }>;
defaultValue?: string;
placeholder?: string;
isClearable?: boolean;
onchange?: ModEvent;
Expand Down
1 change: 1 addition & 0 deletions docs/pages/integrate/creation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { CreationMod } from "@mod-protocol/react";
onExitAction={hideCurrentMod}
onSetInputAction={handleSetInput}
onAddEmbedAction={handleAddEmbed}
onAddReplyAction={handleAddReply}
/>
```

Expand Down
14 changes: 14 additions & 0 deletions docs/pages/integrate/rich-embeds.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { richEmbedMods } from "@mod-protocol/mod-registry";
mods={richEmbedMods}
resolvers={{
onSendEthTransactionAction,
onAddReplyAction
}}
/>
```
Expand Down Expand Up @@ -91,6 +92,16 @@ export function Embeds(props: { embeds: Array<Embed> }) {
[]
);

const handleAddReply = React.useCallback(
({ text, embeds }, { onSuccess }) => {
// optional: first time a user does this, ask them to confirm and tell them what is happening (casting a reply on behalf of them)
// then: you create a cast with text, embeds
// TODO: implement your handler
onSuccess();
},
[]
);

const context = useMemo<Omit<ContextType, "embed">>(() => {
return {
/* Required context */
Expand All @@ -117,6 +128,7 @@ export function Embeds(props: { embeds: Array<Embed> }) {
defaultRichEmbedMod={defaultRichEmbedMod}
mods={richEmbedMods}
resolvers={{
onAddReplyAction,
onSendEthTransactionAction,
}}
/>
Expand All @@ -142,6 +154,7 @@ You can choose to filter or select which Mods are available
defaultRichEmbedMod={defaultRichEmbedMod}
mods={richEmbedMods}
resolvers={{
onAddReplyAction,
onSendEthTransactionAction,
}}
/>
Expand All @@ -159,6 +172,7 @@ You can choose to filter or select which Mods are available
defaultRichEmbedMod={defaultRichEmbedMod}
mods={richEmbedMods}
resolvers={{
onAddReplyAction,
onSendEthTransactionAction,
}}
/>
Expand Down
12 changes: 5 additions & 7 deletions docs/pages/mod-editor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ A fully featured, performant, and open source Cast creator for your React app.
```tsx
import { useEditor, EditorContent } from "@mod-protocol/react-editor";
import { EmbedsEditor } from "@mod-protocol/react-ui-shadcn/dist/lib/embeds";
import { Embed, ModManifest, fetchUrlMetadata, handleAddEmbed, handleOpenFile, handleSetInput } from "@mod-protocol/core";
import { Channel, getFarcasterChannels, getFarcasterMentions } from "@mod-protocol/farcaster";
import { fetchUrlMetadata } from "@mod-protocol/core";
import { getFarcasterChannels, getFarcasterMentions } from "@mod-protocol/farcaster";

// use our API_URL, self host our API, or use your own API.
const getUrlMetadata = fetchUrlMetadata(API_URL);
Expand All @@ -42,9 +42,9 @@ const getChannels = getFarcasterChannels(API_URL);
return (
<>
<EditorContent
editor={editor}
autoFocus
className="w-full h-full min-h-[200px]"
editor={editor}
autoFocus
className="w-full h-full min-h-[200px]"
/>
<EmbedsEditor embeds={getEmbeds()} setEmbeds={setEmbeds} />
<ChannelPicker
Expand All @@ -57,5 +57,3 @@ const getChannels = getFarcasterChannels(API_URL);
</>
);
```

## Usage with Channels UI
1 change: 1 addition & 0 deletions examples/api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ LIVEPEER_API_SECRET="REQUIRED"
DATABASE_URL="REQUIRED"
# Must be funded with MATIC on Mumbai for Irys https://mumbaifaucet.com/
PRIVATE_KEY="REQUIRED"
GATEWAY_URL="REQUIRED"
CHATGPT_ORGANIZATION_ID="REQUIRED"
15 changes: 15 additions & 0 deletions examples/api/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
module.exports = {
reactStrictMode: true,
transpilePackages: ["@mod-protocol/react"],
experimental: {
// For create-poll image generation https://stackoverflow.com/questions/76449953/node-canvas-on-vercel-serverless-function-serverless-function-exceeds-the-maxi/76879546#76879546
outputFileTracingExcludes: {
"/api/create-poll": ["**canvas**", "**ultimate-text-to-image**"],
},
},
webpack: (config) => {
config.externals = [
...config.externals,
// For create-poll image generation https://stackoverflow.com/questions/76449953/node-canvas-on-vercel-serverless-function-serverless-function-exceeds-the-maxi/76879546#76879546
"ultimate-text-to-image",
"canvas",
];
return config;
},
};
4 changes: 2 additions & 2 deletions examples/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
"chatgpt": "^5.2.5",
"cheerio": "^1.0.0-rc.12",
"kysely": "^0.26.3",
"next": "^13.5.6",
"next": "^14.0.3",
"open-graph-scraper": "^6.3.2",
"pg": "^8.11.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"siwe": "^1.1.6",
"uint8arrays": "^3.0.0"
"ultimate-text-to-image": "^1.0.1"
},
"devDependencies": {
"@types/node": "^17.0.12",
Expand Down
Loading