Skip to content

Feat: Better Handling of FrameButton post actions#1053

Merged
Zizzamia merged 8 commits intocoinbase:mainfrom
brendan-defi:feat/frame-post-button-handling
Aug 15, 2024
Merged

Feat: Better Handling of FrameButton post actions#1053
Zizzamia merged 8 commits intocoinbase:mainfrom
brendan-defi:feat/frame-post-button-handling

Conversation

@brendan-defi
Copy link
Contributor

What changed? Why?

  • updated FrameButtonMetadata to allow custom postUrl property
  • updated getFrameMetadata to handle custom postUrls on Frame Buttons

Notes to reviewers

How has it been tested?

@vercel
Copy link

vercel bot commented Aug 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
onchainkit-coverage ❌ Failed (Inspect) Aug 15, 2024 10:26pm
onchainkit-playground ❌ Failed (Inspect) Aug 15, 2024 10:26pm

| {
action?: 'post' | 'post_redirect';
label: string;
postUrl?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part of the Frame Spec? And where is this writtend?

Copy link
Contributor Author

@brendan-defi brendan-defi Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Per Button Actions, we are told that a post should send an HTTP request to the button's post_url.

But as currently configured, getFrameMetadata does not set a fc:frame:button:[id]:post_url property for post actions, only tx actions:

  if (buttons) {
    buttons.forEach((button, index) => {
      metadata[`fc:frame:button:${index + 1}`] = button.label;
      if (button.action) {
        metadata[`fc:frame:button:${index + 1}:action`] = button.action;
      }
      if (button.target) {
        metadata[`fc:frame:button:${index + 1}:target`] = button.target;
      }
      if (button.action && button.action === 'tx' && button.postUrl) {
        metadata[`fc:frame:button:${index + 1}:post_url`] = button.postUrl;
      }
    });
  }

The above change to FrameButtonMetadata is required for strict type-checking of the getFrameMetadata logic.

@vercel
Copy link

vercel bot commented Aug 15, 2024

@brendan-defi is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants