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

update #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Dargon789
Copy link
Owner

@Dargon789 Dargon789 commented Feb 7, 2025


title: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

How to test

Unit tests, playground, etc.

Summary by Sourcery

Refactor the English Auction extension to improve the developer experience by adding helper functions for preparing transaction parameters and validating inputs. Add support for ERC20 tokens in English Auctions. Update tests to use the new helper functions and cover the new ERC20 support. Add a new utility function to get all valid auctions.

Enhancements:

  • Improve developer experience by adding helper functions for preparing transaction parameters and validating inputs.
  • Add support for ERC20 tokens in English Auctions.

Tests:

  • Update tests to use the new helper functions and cover the new ERC20 support.

@Dargon789 Dargon789 added documentation Improvements or additions to documentation duplicate This issue or pull request already exists good first issue Good for newcomers dependencies Pull requests that update a dependency file dashboard labels Feb 7, 2025
@Dargon789 Dargon789 self-assigned this Feb 7, 2025
Copy link

vercel bot commented Feb 7, 2025

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

Name Status Preview Comments Updated (UTC)
js-p5mk ❌ Failed (Inspect) Feb 7, 2025 1:20pm

Copy link

sourcery-ai bot commented Feb 7, 2025

Reviewer's Guide by Sourcery

This PR refactors and extends auction-related functionalities in the marketplace extension. It introduces new utility functions for preparing auction and bid transaction parameters, enhances tests across the English auctions, direct listings, ClaimButton, and ZKSync transaction flows, and adds several miscellaneous utility tests (RPC, chain utils, promise limits, etc.) to improve robustness and consistency.

Sequence diagram for the auction bid process

sequenceDiagram
    participant Tester as actor
    participant BID as bidInAuction
    participant PREP as prepareBidInAuctionParams
    participant GET as GetAuction
    participant CONV as convertErc20Amount
    participant WIN as GetWinningBid

    Tester->>BID: Initiate bid transaction
    BID->>PREP: Call prepareBidInAuctionParams(options)
    PREP->>GET: Retrieve auction details
    alt bidAmount in wei provided
      PREP-->>PREP: Use provided bidAmountWei
    else bidAmount conversion required
      PREP->>CONV: convertErc20Amount(options.bidAmount)
      CONV-->>PREP: resolved bid amount in wei
    end
    PREP->>PREP: Validate: bid not zero, not above buyout
    PREP->>WIN: Get existing winning bid
    alt existing winning bid exists
      PREP-->>PREP: Check if new bid outbids current winning bid
    else No winning bid
      PREP-->>PREP: Validate against minimum bid
    end
    PREP-->>BID: Return prepared bid parameters
    BID->>Tester: Transaction ready for submission
    Tester->>BID: sendAndConfirmTransaction
    BID->>WIN: Query updated winning bid
    WIN-->>BID: Return updated winning bid info
    BID-->>Tester: Bid successful, new winning bid confirmed
Loading

Class diagram for Auction Utility Functions

classDiagram
    class AuctionCreator {
      +createAuction(options)
      +prepareCreateAuctionParams(options)
      -validateAsset(assetContract): Boolean
      -toUnits(amount, decimals)
      -validateTimestamps(start, end)
    }
    class AuctionBidder {
      +bidInAuction(options)
      +prepareBidInAuctionParams(options)
      -getResolvedBidAmount(options): bigint
      -validateBidAmount(amount, auction)
    }
    class AuctionMapper {
      +mapEnglishAuction(rawAuction, latestBlock)
    }
    AuctionCreator <|-- AuctionMapper : uses
    AuctionBidder <|-- AuctionCreator : similar utilities
    note for AuctionCreator "Handles auction creation and parameter preparation"
    note for AuctionBidder "Validates and prepares bid transactions"
Loading

File-Level Changes

Change Details Files
Enhanced and refactored Marketplace English Auctions tests and functionality.
  • Reorganized the English auctions tests to use conditional execution via describe.runIf based on environment variables.
  • Expanded tests to cover various auction scenarios: minting, listing creation, approval, bid validation (zero, below minimum, above buyout, insufficient to outbid) and buyout flows.
  • Added tests for mapping auction data to ensure proper transformation of raw blockchain data.
packages/thirdweb/src/extensions/marketplace/english-auctions/english-auctions.test.ts
Refactored auction transaction parameter preparation functions.
  • Introduced and modified prepareCreateAuctionParams function to consolidate asset validation, timestamp checks, and parameter conversion for auction creation.
  • Refactored bidInAuction to use prepareBidInAuctionParams for calculating bid amounts, validating against minimums and buyout conditions.
packages/thirdweb/src/extensions/marketplace/english-auctions/write/createAuction.ts
packages/thirdweb/src/extensions/marketplace/english-auctions/write/bidInAuction.ts
Updated ClaimButton tests with pre-deployed token contracts.
  • Integrated ERC20 and ERC1155 contracts in ClaimButton tests to improve reliability.
  • Updated contract address references in claim tests to use the pre-deployed contracts instead of deploying new ones inside each test.
packages/thirdweb/src/react/web/ui/prebuilt/thirdweb/ClaimButton/ClaimButton.test.tsx
Improved ZKSync transaction testing and helper export.
  • Added tests for formatTransaction to ensure it returns the correctly formatted transaction with expected EIP712 meta data.
  • Implemented tests for getZkGasFees to verify gas, max fee per gas, and other fee parameters.
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.ts
Updated Direct Listings functionality and tests.
  • Added support check for createListing via isCreateListingSupported in direct listings tests.
  • Performed minor fixes in parameter validations (e.g., quantity validation) in listing creation and update functions.
packages/thirdweb/src/extensions/marketplace/direct-listings/direct-listings.test.ts
packages/thirdweb/src/extensions/marketplace/direct-listings/write/createListing.ts
packages/thirdweb/src/extensions/marketplace/direct-listings/write/updateListing.ts
Updated utility functions and tests for RPC and chain configurations.
  • Changed getValidChainRPCs export to be a named export.
  • Enhanced pLimit tests to validate error handling for non-integer and negative concurrency values.
  • Added tests for fetching block data and transaction data via eth_getBlockByHash and eth_getTransactionByHash.
packages/thirdweb/src/wallets/utils/chains.ts
packages/thirdweb/src/utils/promise/p-limit.test.ts
packages/thirdweb/src/rpc/actions/eth_getBlockByHash.test.ts
packages/thirdweb/src/rpc/actions/eth_getTransactionByHash.test.ts
Introduced additional tests for currency resolution and extra calldata processing.
  • Added tests for resolveCurrencyValue to confirm correct conversion for native token as well as ERC20 tokens.
  • Augmented tests in transaction action encoding to verify extraCallData extraction and proper error handling.
packages/thirdweb/src/utils/extensions/resolve-currency-value.test.ts
packages/thirdweb/src/transaction/actions/encode.test.ts
Added new tests for wallet and chain utility functions.
  • Implemented tests for chain utility functions to ensure valid RPC URL extraction and error handling when no URLs are provided.
  • Included tests for Coinbase wallet utils (if applicable) and storage upload/transaction utils placeholders.
packages/thirdweb/src/wallets/utils/chains.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Dargon789 Dargon789 linked an issue Feb 7, 2025 that may be closed by this pull request
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Dargon789 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Extract the repeated bid and amount conversion logic into a common helper to reduce duplication in prepareCreateAuctionParams and prepareBidInAuctionParams.
  • Mock the block timestamp in auction tests for more deterministic assertions rather than relying on the latest block time.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 2 issues found
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Dargon789 Dargon789 added enhancement New feature or request help wanted Extra attention is needed invalid This doesn't seem right question Further information is requested Stale javascript Pull requests that update Javascript code playground portal Ecosystem Portal bug Something isn't working wontfix This will not be worked on labels Feb 7, 2025
@Dargon789 Dargon789 enabled auto-merge (squash) February 7, 2025 13:16
@Dargon789 Dargon789 removed bug Something isn't working enhancement New feature or request help wanted Extra attention is needed invalid This doesn't seem right labels Feb 7, 2025
@Dargon789 Dargon789 removed question Further information is requested wontfix This will not be worked on labels Feb 7, 2025
Copy link
Owner Author

@Dargon789 Dargon789 left a comment

Choose a reason for hiding this comment

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

update #19

@github-actions github-actions bot removed the Stale label Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboard dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation duplicate This issue or pull request already exists Ecosystem Portal good first issue Good for newcomers javascript Pull requests that update Javascript code packages playground portal sdk
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix code scanning alert - Hard-coded credentials #8
2 participants