Skip to content
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

feat: counter swap for collection atomic swap #11432

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

Jarsen136
Copy link
Contributor

@Jarsen136 Jarsen136 commented Feb 19, 2025

Thank you for your contribution to the Koda - Generative Art Marketplace.

👇 __ Let's make a quick check before the contribution.

PR Type

  • Feature

Needs Design check

Needs QA check

  • @kodadot/qa-guild please review

Context

Screenshot 📸

  • My fix has changed something on UI; a screenshot is best to understand changes for others.

K

Summary by CodeRabbit

  • New Features
    • Expanded conditions for trade interactions now display additional contextual information, providing users with more timely feedback.
    • Improved swap processing enables smoother and more reliable transactions across a wider range of trade scenarios.

@Jarsen136 Jarsen136 requested a review from a team as a code owner February 19, 2025 14:08
@Jarsen136 Jarsen136 requested review from preschian and vikiival and removed request for a team February 19, 2025 14:08
Copy link

coderabbitai bot commented Feb 19, 2025

Walkthrough

This pull request updates two parts of the application. In the TradeOwnerButton.vue component, a condition in the template rendering logic has been simplified by removing the check for trade.isAnyTokenInCollectionDesired, thereby broadening the scenarios in which the tooltip appears. In the counterSwap function within utils/swap.ts, the early return triggered by a missing trade.desired is removed. Instead, the function now conditionally assigns the offered field in a constructed object based on the presence of trade.desired, resulting in a more flexible control flow.

Changes

File(s) Change Summary
components/.../TradeOwnerButton.vue Removed the !trade.isAnyTokenInCollectionDesired check, so the tooltip now renders when isTargetOfTrade, detailed, and trade.type===SWAP are true.
utils/swap.ts Eliminated the early return on missing trade.desired and updated the construction of withFields to conditionally include the offered field based on its existence.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant CounterSwap as counterSwap()
    participant Trade as Trade Object

    Caller ->> CounterSwap: call counterSwap(trade)
    alt trade.desired exists
        CounterSwap ->> CounterSwap: Include trade.desired in offered array
    else
        CounterSwap ->> CounterSwap: Skip offered assignment
    end
    CounterSwap ->> Caller: Return constructed withFields result
Loading

Poem

I'm a coding rabbit with a joyful hop,
Leaping over logic that just won't stop.
Conditions now flow in a gentle stream,
Simplified paths like a dream.
Swaps and tips dance in my code, so neat—
Bug hops away, leaving cheer on every beat!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 51d0c16 and 19e051b.

📒 Files selected for processing (2)
  • components/trade/TradeOwnerButton.vue (1 hunks)
  • utils/swap.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed
  • GitHub Check: shard (10, 10)
  • GitHub Check: shard (9, 10)
  • GitHub Check: shard (8, 10)
  • GitHub Check: shard (7, 10)
  • GitHub Check: shard (6, 10)
  • GitHub Check: shard (5, 10)
  • GitHub Check: shard (4, 10)
  • GitHub Check: shard (3, 10)
  • GitHub Check: build-cf
  • GitHub Check: build
  • GitHub Check: shard (2, 10)
  • GitHub Check: shard (1, 10)
  • GitHub Check: Cloudflare Pages: koda-art-prod
🔇 Additional comments (2)
components/trade/TradeOwnerButton.vue (1)

10-10: Counter swap functionality expanded for collection atomic swaps

The condition has been simplified by removing the !trade.isAnyTokenInCollectionDesired check, allowing the counter swap button to appear even when tokens from collections are desired. This implements the feature requested in the PR for collection atomic swaps.

utils/swap.ts (1)

88-95: Improved counterSwap function to support collection atomic swaps

The function has been restructured to handle cases where trade.desired might be undefined, which aligns with collection atomic swaps. Instead of returning early when trade.desired is missing, it now conditionally assigns the offered field only when trade.desired exists.

However, there's an important design consideration here:

Is this new behavior the intended user flow? Based on the PR comment from "hassnian", there's a question about whether a counter swap makes sense when the counterparty could accept directly. Please confirm that creating another atomic swap instead of direct acceptance is the intended behavior for collection swaps.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Jarsen136 Jarsen136 requested a review from hassnian February 19, 2025 14:08
Copy link

netlify bot commented Feb 19, 2025

Deploy Preview for koda-canary ready!

Name Link
🔨 Latest commit 19e051b
🔍 Latest deploy log https://app.netlify.com/sites/koda-canary/deploys/67c9ac31ed10aa000847c184
😎 Deploy Preview https://deploy-preview-11432--koda-canary.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hassnian
Copy link
Contributor

code wise LGTM, but now that I've tested it I'm unsure if it makes any sense to have in the first place

the counterparty can accept directly instate of creating another atomic swap

cc @exezbcz

Base automatically changed from issue-11331-0 to main March 4, 2025 15:46
Copy link

cloudflare-workers-and-pages bot commented Mar 6, 2025

Deploying koda-art-prod with  Cloudflare Pages  Cloudflare Pages

Latest commit: 19e051b
Status: ✅  Deploy successful!
Preview URL: https://52428e81.kodaart-production.pages.dev
Branch Preview URL: https://issue-11331-2.kodaart-production.pages.dev

View logs

Copy link

sonarqubecloud bot commented Mar 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants