forked from thirdweb-dev/js
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
4 / 54 of 5 issues completedLabels
Ecosystem PortaldashboarddependenciesPull requests that update a dependency filePull requests that update a dependency filedocumentationImprovements or additions to documentationImprovements or additions to documentationgithub_actionsPull requests that update GitHub Actions codePull requests that update GitHub Actions codegood first issueGood for newcomersGood for newcomersjavascriptPull requests that update Javascript codePull requests that update Javascript codepackagesplaygroundportalsdk
Description
Reviewer's Guide
Adds and refactors internal helpers and tests around marketplace auctions/offers, ClaimButton, zkSync EIP-712 transactions, RPC utils, transaction encoding, currency resolution, and wallet chain RPC selection; exposes some internal helpers, tightens validation, and bumps dependencies (shiki, AWS KMS) per Snyk recommendations.
Sequence diagram for prepareCreateAuctionParams flow
sequenceDiagram
actor User
participant App as AppCode
participant CreateAuction as CreateAuctionModule
participant Helper as prepareCreateAuctionParams
participant AssetContract as AssetContract
participant RPC as RpcClient
participant ERC20 as CurrencyContract
User->>App: call createAuction(options)
App->>CreateAuction: createAuction(options)
CreateAuction->>Helper: prepareCreateAuctionParams(options)
Helper->>AssetContract: isERC721(assetContract)
Helper->>AssetContract: isERC1155(assetContract)
Helper->>RPC: eth_getBlockByNumber(latest)
RPC-->>Helper: latestBlock(timestamp)
Helper-->>Helper: validate assetIsERC721 || assetIsERC1155
Helper-->>Helper: compute startTimestamp and endTimestamp
Helper-->>Helper: adjust startTimestamp if <= latestBlock.timestamp
Helper-->>Helper: throw if startTimestamp >= endTimestamp
alt assetIsERC721
Helper-->>Helper: quantity = 1n
else assetIsERC1155
Helper-->>Helper: quantity = options.quantity ?? 1n
end
Helper-->>Helper: currencyAddress = options.currencyContractAddress ?? NATIVE_TOKEN_ADDRESS
alt buyoutBidAmount in display units
alt isNativeTokenAddress(currencyAddress)
Helper-->>Helper: buyoutBidAmount = toUnits(buyoutBidAmount, 18)
else ERC20 token
Helper->>ERC20: decimals()
ERC20-->>Helper: currencyDecimals
Helper-->>Helper: buyoutBidAmount = toUnits(buyoutBidAmount, currencyDecimals)
end
else buyoutBidAmountWei provided
Helper-->>Helper: buyoutBidAmount = BigInt(buyoutBidAmountWei)
end
alt minimumBidAmount in display units
alt isNativeTokenAddress(currencyAddress)
Helper-->>Helper: minimumBidAmount = toUnits(minimumBidAmount, 18)
else ERC20 token
Helper->>ERC20: decimals()
ERC20-->>Helper: currencyDecimals
Helper-->>Helper: minimumBidAmount = toUnits(minimumBidAmount, currencyDecimals)
end
else minimumBidAmountWei provided
Helper-->>Helper: minimumBidAmount = BigInt(minimumBidAmountWei)
end
Helper-->>CreateAuction: {params, overrides:{extraGas:50000n}}
CreateAuction-->>App: PreparedTransaction
App-->>User: transaction ready to send
Sequence diagram for prepareBidInAuctionParams flow
sequenceDiagram
actor Bidder
participant App as AppCode
participant BidInAuction as BidInAuctionModule
participant Helper as prepareBidInAuctionParams
participant AuctionRead as GetAuction
participant WinningBidRead as GetWinningBid
participant NewWinning as IsNewWinningBid
participant ERC20Util as convertErc20Amount
Bidder->>App: call bidInAuction(options)
App->>BidInAuction: bidInAuction(options)
BidInAuction->>Helper: prepareBidInAuctionParams(options)
Helper->>AuctionRead: getAuction(auctionId)
AuctionRead-->>Helper: auction
alt bidAmountWei provided
Helper-->>Helper: resolvedBidAmountWei = bidAmountWei
else bidAmount in display units
Helper->>ERC20Util: convertErc20Amount(amount, chain, auction.currencyContractAddress, client)
ERC20Util-->>Helper: resolvedBidAmountWei
end
Helper-->>Helper: validate resolvedBidAmountWei != 0n
Helper-->>Helper: validate resolvedBidAmountWei <= auction.buyoutCurrencyValue.value
Helper->>WinningBidRead: getWinningBid(auctionId)
WinningBidRead-->>Helper: existingWinningBid or undefined
alt existingWinningBid exists
Helper->>NewWinning: isNewWinningBid(auctionId, resolvedBidAmountWei)
NewWinning-->>Helper: isNewWinner
alt isNewWinner is false
Helper-->>Helper: throw "Bid amount is too low to outbid the existing winning bid"
end
else no existing winning bid
alt resolvedBidAmountWei < auction.minimumBidCurrencyValue.value
Helper-->>Helper: throw "Bid amount is below the minimum bid amount"
end
end
Helper-->>BidInAuction: {auctionId, bidAmount, overrides:{value?, extraGas:50000n}}
BidInAuction-->>App: PreparedTransaction
App-->>Bidder: transaction ready to send
Sequence diagram for zkSync EIP-712 getZkGasFees and formatTransaction
sequenceDiagram
participant App as AppCode
participant Tx as PreparedTransaction
participant ZkGas as getZkGasFees
participant Format as formatTransaction
participant RPC as RpcClient
App->>ZkGas: getZkGasFees({transaction, from})
ZkGas->>Format: formatTransaction({transaction, from})
Format->>Tx: read to, data, value, eip712
Format-->>ZkGas: formattedTx{from,to,data,value,gasPerPubdata?,eip712Meta,type}
ZkGas->>RPC: estimateGasL1(formattedTx)
RPC-->>ZkGas: gas
ZkGas->>RPC: getMaxFeePerGas()
RPC-->>ZkGas: maxFeePerGas
ZkGas->>RPC: getMaxPriorityFeePerGas()
RPC-->>ZkGas: maxPriorityFeePerGas
ZkGas-->>App: {gas,maxFeePerGas,maxPriorityFeePerGas,gasPerPubdata}
Class diagram for marketplace English auction helpers
classDiagram
class ThirdwebContract {
+address: string
+chain: Chain
+client: Client
}
class CreateAuctionModule {
+createAuction(options)
}
class BidInAuctionModule {
+bidInAuction(options)
}
class PrepareCreateAuctionParamsHelper {
+prepareCreateAuctionParams(options) Promise~PreparedAuctionParams~
-validateAssetIsERC721Or1155(assetContract)
-computeTimestamps(startTimestamp, endTimestamp, latestBlock)
-resolveQuantity(isERC721, quantity)
-resolveBidAmount(displayAmount, amountWei, currencyAddress) bigint
}
class PrepareBidInAuctionParamsHelper {
+prepareBidInAuctionParams(options) Promise~PreparedBidParams~
-resolveBidAmount(bidAmount, bidAmountWei, auction) bigint
-validateBidRange(amountWei, auction)
-ensureOutbidsExistingWinner(amountWei, auction)
}
class MapEnglishAuctionUtil {
+mapEnglishAuction(contract, rawAuction, latestBlock) Promise~MappedAuction~
}
class GeneratedGetAllAuctions {
+getAllAuctions(contract, startId, endId) Promise~RawAuction[]~
}
class GetAllInBatchesUtil {
+getAllInBatches(fetchFn, range, ) Promise~any[]~
}
class GetAuctionRead {
+getAuction(contract, auctionId) Promise~MappedAuction~
}
class GetWinningBidRead {
+getWinningBid(contract, auctionId) Promise~WinningBid?~
}
class IsNewWinningBidRead {
+isNewWinningBid(contract, auctionId, bidAmount) Promise~boolean~
}
CreateAuctionModule --> PrepareCreateAuctionParamsHelper : uses
BidInAuctionModule --> PrepareBidInAuctionParamsHelper : uses
PrepareCreateAuctionParamsHelper --> ThirdwebContract : reads
PrepareBidInAuctionParamsHelper --> GetAuctionRead : queries
PrepareBidInAuctionParamsHelper --> GetWinningBidRead : queries
PrepareBidInAuctionParamsHelper --> IsNewWinningBidRead : queries
MapEnglishAuctionUtil --> ThirdwebContract : reads
MapEnglishAuctionUtil --> GeneratedGetAllAuctions : consumes output
GeneratedGetAllAuctions --> ThirdwebContract : queries
GetAllInBatchesUtil --> GeneratedGetAllAuctions : calls
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Refactor English auctions write helpers into reusable parameter-preparation functions and expand end-to-end auction tests, including ERC20 currency flows and support-check helpers. |
|
packages/thirdweb/src/extensions/marketplace/english-auctions/english-auctions.test.tspackages/thirdweb/src/extensions/marketplace/english-auctions/write/createAuction.tspackages/thirdweb/src/extensions/marketplace/english-auctions/write/bidInAuction.ts |
| Improve marketplace offers and direct listings utilities and tests, including mapping and feature-detection helpers plus minor cleanup. |
|
packages/thirdweb/src/extensions/marketplace/offers/offers.test.tspackages/thirdweb/src/extensions/marketplace/direct-listings/direct-listings.test.tspackages/thirdweb/src/extensions/marketplace/direct-listings/write/createListing.tspackages/thirdweb/src/extensions/marketplace/direct-listings/write/updateListing.ts |
| Strengthen ClaimButton tests by reusing shared deployed contracts, reducing duplication and explicitly validating ERC20/ERC1155 claim flows and error paths. |
|
packages/thirdweb/src/react/web/ui/prebuilt/thirdweb/ClaimButton/ClaimButton.test.tsx |
| Enhance zkSync EIP-712 transaction utilities by exposing formatTransaction and adding tests for transaction formatting and zkSync gas fee estimation. |
|
packages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.tspackages/thirdweb/src/transaction/actions/zksync/send-eip712-transaction.test.ts |
| Increase coverage and robustness for low-level RPC and transaction helpers (encoding, extra calldata, RPC actions, currency resolution, promise concurrency, wallet chain RPCs). |
|
packages/thirdweb/src/transaction/actions/encode.test.tspackages/thirdweb/src/rpc/actions/eth_getBlockByHash.test.tspackages/thirdweb/src/rpc/actions/eth_getTransactionByHash.test.tspackages/thirdweb/src/utils/extensions/resolve-currency-value.test.tspackages/thirdweb/src/utils/promise/p-limit.test.tspackages/thirdweb/src/wallets/utils/chains.tspackages/thirdweb/src/wallets/utils/chains.test.ts |
| Update third-party dependencies to address Snyk advisories and keep SDK apps up to date. |
|
apps/dashboard/package.jsonapps/playground-web/package.jsonapps/portal/package.jsonpackages/react-native-adapter/package.jsonpnpm-lock.yaml |
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon 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 issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon 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 dismisson 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 reviewto trigger a new review!
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
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Originally posted by @sourcery-ai[bot] in #619 (comment)
Reactions are currently unavailable
Sub-issues
Metadata
Metadata
Assignees
Labels
Ecosystem PortaldashboarddependenciesPull requests that update a dependency filePull requests that update a dependency filedocumentationImprovements or additions to documentationImprovements or additions to documentationgithub_actionsPull requests that update GitHub Actions codePull requests that update GitHub Actions codegood first issueGood for newcomersGood for newcomersjavascriptPull requests that update Javascript codePull requests that update Javascript codepackagesplaygroundportalsdk
Projects
Status
In Review
Status
Todo