Snyk upgrade ba4cc0662a4f537bb4ca964e62a741c1#619
Conversation
Bumps [shiki](https://github.com/shikijs/shiki/tree/HEAD/packages/shiki) from 1.27.0 to 2.3.2. - [Release notes](https://github.com/shikijs/shiki/releases) - [Commits](https://github.com/shikijs/shiki/commits/v2.3.2/packages/shiki) --- updated-dependencies: - dependency-name: shiki dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
Create codeql.yml
….3.2 build(deps): bump shiki from 1.27.0 to 2.3.2
Snyk has created this PR to upgrade @aws-sdk/client-kms from 3.592.0 to 3.734.0. See this package in npm: @aws-sdk/client-kms See this project in Snyk: https://app.snyk.io/org/dargon789/project/e7fa878f-9d48-45bd-a72d-921183752fef?utm_source=github&utm_medium=referral&page=upgrade-pr
Reviewer's GuideAdds 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 flowsequenceDiagram
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 flowsequenceDiagram
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 formatTransactionsequenceDiagram
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 helpersclassDiagram
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
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary of ChangesHello @Dargon789, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the project's stability, security, and testability. It includes routine dependency updates for Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Hey - I've found 2 security issues, 1 other issue, and left some high level feedback:
Security issues:
- Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections. (link)
- Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections. (link)
General comments:
- In
eth_getBlockByHash.test.ts, the second test case ("should work for a block") is effectively identical to the first ("should get Ethereum genesis block"); consider removing or differentiating it to avoid redundant coverage. - The
describelabel ineth_getBlockByHash.test.tsis currently"get_getBlockByHash"; consider renaming it to something clearer like"eth_getBlockByHash"for consistency with the function under test.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `eth_getBlockByHash.test.ts`, the second test case (`"should work for a block"`) is effectively identical to the first (`"should get Ethereum genesis block"`); consider removing or differentiating it to avoid redundant coverage.
- The `describe` label in `eth_getBlockByHash.test.ts` is currently `"get_getBlockByHash"`; consider renaming it to something clearer like `"eth_getBlockByHash"` for consistency with the function under test.
## Individual Comments
### Comment 1
<location> `packages/thirdweb/src/transaction/actions/encode.test.ts:226-235` </location>
<code_context>
);
});
+
+ it("internal func: getExtraCallDataFromTx | should throw if the function does not return a hex string", async () => {
+ const tx = prepareTransaction({
+ chain: FORKED_ETHEREUM_CHAIN,
+ client: TEST_CLIENT,
+ to: TEST_WALLET_B,
+ value: toWei("0.1"),
+ data: toHex("getExtraCallDataFromTx-should-not-return-this"),
+ // @ts-ignore Intentionally for the test purpose
+ extraCallData: () => "I'm a cat",
+ });
+ await expect(() => getExtraCallDataFromTx(tx)).rejects.toThrowError(
+ "Invalid extra calldata - must be a hex string",
+ );
</code_context>
<issue_to_address>
**issue (testing):** The `getExtraCallDataFromTx` rejection test should await the promise directly.
Since `getExtraCallDataFromTx` is async, pass the promise directly to `expect` so the rejection matcher applies to the actual function call:
```ts
await expect(getExtraCallDataFromTx(tx)).rejects.toThrowError(
"Invalid extra calldata - must be a hex string",
);
```
Using a callback here means the matcher is not validating the returned promise and can give misleading results.
</issue_to_address>
### Comment 2
<location> `packages/thirdweb/src/wallets/utils/chains.test.ts:34` </location>
<code_context>
"ws://1.rpc.thirdweb.com/${THIRDWEB_API_KEY}",
</code_context>
<issue_to_address>
**security (javascript.lang.security.detect-insecure-websocket):** Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections.
*Source: opengrep*
</issue_to_address>
### Comment 3
<location> `packages/thirdweb/src/wallets/utils/chains.test.ts:63` </location>
<code_context>
).toStrictEqual(["ws://1.rpc.thirdweb.com/"]);
</code_context>
<issue_to_address>
**security (javascript.lang.security.detect-insecure-websocket):** Insecure WebSocket Detected. WebSocket Secure (wss) should be used for all WebSocket connections.
*Source: opengrep*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request, initiated as a Snyk upgrade, also introduces a significant number of valuable additions, primarily focused on enhancing test coverage and refactoring for better testability across marketplace, transaction, and utility functions. The changes are positive, improving the robustness of the codebase. I've identified a critical issue in a new test due to an incorrect import, which will cause it to fail. Additionally, I've left several medium-severity comments regarding test clarity, commented-out code, and TODOs that should be addressed to maintain code quality.
packages/thirdweb/src/extensions/marketplace/direct-listings/direct-listings.test.ts
Outdated
Show resolved
Hide resolved
packages/thirdweb/src/extensions/marketplace/direct-listings/direct-listings.test.ts
Outdated
Show resolved
Hide resolved
packages/thirdweb/src/extensions/marketplace/english-auctions/english-auctions.test.ts
Outdated
Show resolved
Hide resolved
packages/thirdweb/src/extensions/marketplace/english-auctions/english-auctions.test.ts
Show resolved
Hide resolved
packages/thirdweb/src/extensions/marketplace/english-auctions/write/createAuction.ts
Show resolved
Hide resolved
…irect-listings.test.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…irect-listings.test.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com>
…english-auctions.test.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Dargon789 <64915515+Dargon789@users.noreply.github.com>
Summary by Sourcery
Add new unit tests and internal helpers across marketplace auctions, offers, RPC, wallets, transactions, and utilities while upgrading selected dependencies.
New Features:
Enhancements:
Build:
Tests: