Skip to content

Commit

Permalink
merge upstream main
Browse files Browse the repository at this point in the history
  • Loading branch information
YosephKS committed Apr 29, 2024
2 parents b643f9c + bfb2f70 commit 5aa53bf
Show file tree
Hide file tree
Showing 25 changed files with 9,121 additions and 7,068 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-lions-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frog": patch
---

Added `gas` parameter to transaction response to specify the gas limit. [See more](https://warpcast.com/horsefacts.eth/0xd6390bb3).
9 changes: 9 additions & 0 deletions .changeset/old-buses-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"frog": minor
---

Deprecated the Cast Actions Deeplink V1 format in favor of V2. [See more](https://warpcast.notion.site/Spec-Farcaster-Actions-84d5a85d479a43139ea883f6823d8caa).

Breaking changes have affected `Button.AddCastAction` and `.castAction` handler:
- `Button.AddCastAction` now only accepts `action` property;
- `.castAction` handler now requries a third parameter (`options`) to be set. Properties that were removed from `Button.AddCastAction` have migrated here, and `aboutUrl` and `description` were added along.
30 changes: 18 additions & 12 deletions playground/src/castAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,24 @@ export const app = new Frog({
</div>
),
intents: [
<Button.AddCastAction action="/action" name="Log This!" icon="log">
Add
</Button.AddCastAction>,
<Button.AddCastAction action="/action">Add</Button.AddCastAction>,
],
}),
)
.castAction('/action', async (c) => {
console.log(
`Cast Action to ${JSON.stringify(c.actionData.castId)} from ${
c.actionData.fid
}`,
)
if (Math.random() > 0.5) return c.error({ message: 'Action failed :(' })
return c.res({ message: 'Action Succeeded' })
})
.castAction(
'/action',
async (c) => {
console.log(
`Cast Action to ${JSON.stringify(c.actionData.castId)} from ${
c.actionData.fid
}`,
)
if (Math.random() > 0.5) return c.error({ message: 'Action failed :(' })
return c.res({ message: 'Action Succeeded' })
},
{
name: 'Log This!',
icon: 'log',
description: 'This cast action will log something!',
},
)
53 changes: 43 additions & 10 deletions playground/src/routing.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
import { Frog } from '@airstack/frog'
import { Button, Frog } from '@airstack/frog'

export const app = new Frog({
apiKey: process.env.AIRSTACK_API_KEY as string,
})

app.frame('/:name?', (c) => {
const name = c.req.param('name')
return c.res({
image: (
<div style={{ color: 'white', display: 'flex', fontSize: 60 }}>
gm, {name ?? 'froggie'}
</div>
),
app
.frame('/jump-to-root', (c) => {
return c.res({
action: '~/',
image: (
<div style={{ color: 'white', display: 'flex', fontSize: 60 }}>
Press a button to jump back!
</div>
),
intents: [<Button>Jump Back</Button>],
})
})
.frame('/jump-to-clock', (c) => {
return c.res({
action: '~/clock',
image: (
<div style={{ color: 'white', display: 'flex', fontSize: 60 }}>
Press a button to jump back!
</div>
),
intents: [<Button>Jump to Clock</Button>],
})
})
.frame('/jump-to-root-from-button', (c) => {
return c.res({
image: (
<div style={{ color: 'white', display: 'flex', fontSize: 60 }}>
Press a button to jump back!
</div>
),
intents: [<Button action="~/">Jump to Root</Button>],
})
})
.frame('/:name?', (c) => {
const name = c.req.param('name')
return c.res({
image: (
<div style={{ color: 'white', display: 'flex', fontSize: 60 }}>
gm, {name ?? 'froggie'}
</div>
),
})
})
})
Loading

0 comments on commit 5aa53bf

Please sign in to comment.