OfflineHQ / marketplace

https://offline.live/
GNU General Public License v3.0
0 stars 0 forks source link

273 claim 00 message queue #275

Closed AlexandreG-tech closed 9 months ago

AlexandreG-tech commented 9 months ago

Type

enhancement, bug_fix


Description


Changes walkthrough

Relevant files
Enhancement
6 files
index.ts
Add Delivery Status and Minter Temporary Wallet Types       

libs/gql/shared/types/src/generated/index.ts
  • Added isDelivered field to EventPassNft and PackNftSupply types.
  • Introduced MinterTemporaryWallet type with fields for managing
    temporary wallets for minters.
  • +360/-0 
    index.ts
    Implement Minter Temporary Wallet Creation in NFT Collection

    libs/nft/thirdweb-organizer/src/index.ts
  • Added wallet creation logic in getContractWithClaimConditions.
  • Included minterTemporaryWallet in the return object of contract
    deployment functions.
  • +35/-8   
    payment-admin.ts
    Update Payment Admin to Use Redis for Order Processing     

    libs/payment/admin/src/lib/payment-admin.ts
  • Removed refundPartialPayment method.
  • Modified confirmedStripeCheckoutSession to use Redis for order
    processing.
  • +15/-33 
    index.ts
    Implement API Endpoint for Order Claim Processing               

    apps/web/pages/api/orders/claim/index.ts
  • New API endpoint for processing claimed orders.
  • Utilizes multicallClaim for efficient order processing.
  • +48/-0   
    nft-thirdweb-api.ts
    Add Multicall Claim Method for Batch NFT Processing           

    libs/nft/thirdweb-admin/src/lib/nft-thirdweb-api.ts
  • Added multicallClaim method for batch processing of NFT claims.
  • Utilizes temporary wallets for signing transactions.
  • +93/-4   
    processRedisOrders.ts
    New Cron Job for Processing Redis Orders                                 

    apps/web/app/crons/processRedisOrders.ts
  • New cron job for processing Redis orders.
  • Invokes the orders-cron handler for order processing.
  • +5/-0     
    Tests
    3 files
    index.integration.test.ts
    Integration Tests for Orders Cron Functions and Handler   

    libs/features/orders-cron/src/index.integration.test.ts
  • Integration tests for minor functions and handler in the orders-cron
    feature.
  • Tests for setOrdersToBusy, deleteOrders, and the main handler
    function.
  • +219/-0 
    nft-thirdweb-api.spec.ts
    Add Tests for Multicall Claim in NFT Claimable                     

    libs/nft/thirdweb-admin/src/lib/nft-thirdweb-api.spec.ts
  • Mocked @thirdweb-dev/sdk for NFT claim tests.
  • Added tests for multicallClaim method to ensure it updates order
    statuses correctly.
  • +40/-63 
    nftCollection.integration.test.ts
    Integration Tests for NFT Collection with Temporary Wallet Creation

    libs/nft/thirdweb-organizer/src/nftCollection.integration.test.ts
  • Mocked ethers to test wallet creation.
  • Integration tests for deploying NFT collections with temporary wallet
    creation.
  • +48/-0   

    PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    vercel[bot] commented 9 months ago

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

    Name Status Preview Comments Updated (UTC)
    back-office ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2024 4:01pm
    marketplace ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2024 4:01pm
    unlock ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 27, 2024 4:01pm
    codiumai-pr-agent-free[bot] commented 9 months ago

    PR Description updated to latest commit (https://github.com/Offline-Project/marketplace/commit/aa55c7dbc5410b1cdcdacee3a9118de93a2efd70)

    codiumai-pr-agent-free[bot] commented 9 months ago

    PR Review

         PR feedback                    
    ⏱️ Estimated effort to review [1-5] 5, because this PR introduces significant changes across multiple files, including new features, database schema updates, and integration with external services (Redis, Thirdweb SDK). The complexity of the changes, especially around the new orders processing logic and NFT claiming, requires a thorough review to ensure correctness, security, and performance. Additionally, the modifications to the database schema and the introduction of new GraphQL queries and mutations add to the review complexity. The integration tests and the changes to existing logic also need careful examination to prevent regressions.
    🧪 Relevant tests Yes
    🔍 Possible issues - The new `processRedisOrders` cron job is scheduled to run every minute. Depending on the volume of orders and the performance of the order processing logic, this frequency might lead to performance issues or unnecessary load on the server. Consider adjusting the frequency based on actual needs and monitoring. - The `minterTemporaryWallet` table includes a `privateKey` column stored in plaintext. Storing private keys in plaintext poses a significant security risk if the database is compromised. Consider implementing encryption-at-rest for this sensitive information. - The error handling in `libs/payment/admin/src/lib/payment-admin.ts` and `apps/web/pages/api/orders/claim/index.ts` could be improved. Specifically, logging the error details and ensuring that any necessary cleanup or state rollback is performed in case of failures. - The mock implementation in tests (e.g., `libs/nft/thirdweb-organizer/src/nftCollection.integration.test.ts`) might not fully capture the behavior of external dependencies like the Thirdweb SDK or Redis. Ensure that the tests are comprehensive enough to catch potential integration issues.
    🔒 Security concerns Yes, because: - The handling of private keys in the `minterTemporaryWallet` table and throughout the codebase needs careful attention to ensure that these sensitive pieces of information are securely managed, stored, and accessed. The current approach of storing them in plaintext in the database is not secure. - The new endpoints and logic introduced for processing orders and claiming NFTs should be reviewed for potential vulnerabilities, such as injection attacks or unauthorized access. Ensure that proper authentication and authorization checks are in place. - The changes to the database schema and the introduction of new GraphQL queries and mutations should be reviewed to ensure they do not inadvertently expose sensitive information or introduce vulnerabilities.

    ✨ Review tool usage guide:
    **Overview:** The `review` tool scans the PR code changes, and generates a PR review. The tool can be triggered [automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on any PR. When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L19) related to the review tool (`pr_reviewer` section), use the following template: ``` /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=... ``` With a [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), use the following template: ``` [pr_reviewer] some_config1=... some_config2=... ```
    Utilizing extra instructions
    The `review` tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project. Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize. Examples for extra instructions: ``` [pr_reviewer] # /review # extra_instructions=""" In the 'possible issues' section, emphasize the following: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? - Is the code logic efficient? ... """ ``` Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.
    How to enable\disable automation
    - When you first install PR-Agent app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the `review` tool is: ``` pr_commands = ["/review", ...] ``` meaning the `review` tool will run automatically on every PR, with the default configuration. Edit this field to enable/disable the tool, or to change the used configurations
    Auto-labels
    The `review` tool can auto-generate two specific types of labels for a PR: - a `possible security issue` label, that detects possible [security issues](https://github.com/Codium-ai/pr-agent/blob/tr/user_description/pr_agent/settings/pr_reviewer_prompts.toml#L136) (`enable_review_labels_security` flag) - a `Review effort [1-5]: x` label, where x is the estimated effort to review the PR (`enable_review_labels_effort` flag)
    Extra sub-tools
    The `review` tool provides a collection of possible feedbacks about a PR. It is recommended to review the [possible options](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md#enabledisable-features), and choose the ones relevant for your use case. Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example: `require_score_review`, `require_soc2_ticket`, and more.
    Auto-approve PRs
    By invoking: ``` /review auto_approve ``` The tool will automatically approve the PR, and add a comment with the approval. To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following: ``` [pr_reviewer] enable_auto_approval = true ``` (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository) You can also enable auto-approval only if the PR meets certain requirements, such as that the `estimated_review_effort` is equal or below a certain threshold, by adjusting the flag: ``` [pr_reviewer] maximal_review_effort = 5 ```
    More PR-Agent commands
    > To invoke the PR-Agent, add a comment using one of the following commands: > - **/review**: Request a review of your Pull Request. > - **/describe**: Update the PR title and description based on the contents of the PR. > - **/improve [--extended]**: Suggest code improvements. Extended mode provides a higher quality feedback. > - **/ask \**: Ask a question about the PR. > - **/update_changelog**: Update the changelog based on the PR's contents. > - **/add_docs** 💎: Generate docstring for new components introduced in the PR. > - **/generate_labels** 💎: Generate labels for the PR based on the PR's contents. > - **/analyze** 💎: Automatically analyzes the PR, and presents changes walkthrough for each component. >See the [tools guide](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md) for more details. >To list the possible configuration parameters, add a **/config** comment.
    See the [review usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/REVIEW.md) page for a comprehensive guide on using this tool.
    codiumai-pr-agent-free[bot] commented 9 months ago

    PR Code Suggestions

    Suggestions                                                                                                                                                     
    performance
    Improve test setup performance by executing Redis operations in parallel.     ___ **Consider using Promise.all for parallel execution of Redis hset operations in the
    beforeAll block to improve test setup performance.** [libs/features/orders-cron/src/index.integration.test.ts [21-25]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-a32ec4d9ba3df15f8969bf94e7124b6d96d4275676752bdfdc4c49fdc81213b1R21-R25) ```diff -for (const orderId of testOrdersIds) { - await cache.kv.hset(testEventPassId, { +await Promise.all(testOrdersIds.map(orderId => + cache.kv.hset(testEventPassId, { [orderId]: RedisOrderStatus.Pending, - }); -} + }) +)); ```
    Add indexes to "eventPassId" and "packId" for improved query performance.     ___ **Add indexes to "eventPassId" and "packId" columns to improve query performance. These
    columns are likely to be used in JOIN operations or as part of WHERE clauses, and indexing
    them can significantly speed up these queries.** [hasura/app/migrations/default/1707893596046_add_minter_temporary_wallet_add_is_delivered_boolean/up.sql [5-6]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-3ce2dc0b55fc676b522409470dc8808d1d429910b92be80c3e6c0573a2718294R5-R6) ```diff "eventPassId" text, "packId" text, +INDEX ("eventPassId"), +INDEX ("packId"), ```
    best practice
    Ensure tests are isolated and faster by mocking API calls.                    ___ **Use a mock function for adminSdk.GetOrdersWithClaimInfo and
    adminSdk.GetMinterTemporaryWalletByEventPassId to avoid real API calls in tests, ensuring
    tests remain fast and reliable.** [libs/nft/thirdweb-admin/src/lib/nft-thirdweb-api.spec.ts [56-62]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-3ccc4a1d46881a7ab0a2f65bb2398ef21b47c99c144f0eb6214ba97825b11b03R56-R62) ```diff -const resOrders = await adminSdk.GetOrdersWithClaimInfo({ - ids: ['1e8b9aea-1b0a-4a05-803b-c72d0b46e9a2'], -}); -orders = resOrders.order; -const resWallet = await adminSdk.GetMinterTemporaryWalletByEventPassId({ - eventPassId: 'fake-event-pass-2', -}); +jest.mock('@gql/admin/api', () => ({ + adminSdk: { + GetOrdersWithClaimInfo: jest.fn().mockResolvedValue({ order: mockOrders }), + GetMinterTemporaryWalletByEventPassId: jest.fn().mockResolvedValue({ minterTemporaryWallet: mockWallet }), + }, +})); ```
    Add error handling for insertMinterTemporaryWallet to prevent unhandled exceptions. ___ **Ensure that the insertMinterTemporaryWallet function handles errors gracefully, either by
    using try-catch blocks or ensuring the calling function does so, to prevent unhandled
    exceptions.** [libs/nft/thirdweb-organizer/src/index.ts [344]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-80b26817489489d8498897af632d05d0f4662c8d8ebdcb70de6613f0297b72d6R344-R344) ```diff -await insertMinterTemporaryWallet(minterTemporaryWallet); +try { + await insertMinterTemporaryWallet(minterTemporaryWallet); +} catch (error) { + console.error('Failed to insert minter temporary wallet:', error); + // Handle error appropriately +} ```
    Replace any type with string for id fields to improve type safety. ___ **Consider using a more specific type than any for the id field in the
    GetOrdersWithClaimInfoQuery and GetOrdersFromStripeCheckoutSessionQuery types. Using any
    can lead to bugs and type errors that are hard to debug. If the id is always a UUID, you
    can use string or a custom UUID type.** [libs/gql/admin/api/src/generated/index.ts [92-99]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-a705910118ccb32a0fbdface4f59baf2452ffd8cdb25417f4774ef2c40fc5522R92-R99) ```diff -id: any +id: string ```
    Explicitly set success response status and message for clarity.               ___ **It's a good practice to explicitly set the response status code to 200 and provide a
    meaningful response body when the operation succeeds. This makes the API's behavior
    clearer to the consumers and aids in debugging.** [apps/web/pages/api/orders/claim/index.ts [44]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-434b178851cd510d14486d3c7a66f95230121fb680f09069f7a0917dcbbb4388R44-R44) ```diff -return res.status(200); +return res.status(200).json({ success: true, message: 'Orders processed successfully.' }); ```
    Explicitly type the return value of async functions for clarity.              ___ **When defining async functions that return a promise, it's beneficial to explicitly type
    the return value. This improves code readability and helps with debugging by making the
    expected return type clear.** [libs/nft/thirdweb-organizer/src/action.ts [33-35]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-979b6ef9b050567219e1a772e5d6449136db534623283c47496e746df4235a35R33-R35) ```diff export async function createEventPassNftContract( object: EventPassNftContract_Insert_Input, -) { +): Promise { const data = await adminSdk.CreateEventPassNftContract({ object }); return data?.insert_eventPassNftContract_one; } ```
    Log errors for better debugging and error tracking.                           ___ **For better error handling, consider logging the error before returning a response. This
    can help with debugging by providing more context about the error, especially when the
    error message is generic. Use a logging library or framework's logging functionality to
    log the error details.** [libs/payment/webhooks/src/lib/payment-webhooks.ts [82-85]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-7559362a4e5d9b2a85894302f2dea2e198975c52265521daf3f39fa157b100baR82-R85) ```diff +console.error(`ConfirmedStripeCheckoutSession Error: ${err}`); return new Response( `ConfirmedStripeCheckoutSession Error: ${err.message}`, { status: 500 }, ); ```
    Add foreign key constraints to "eventPassId" and "packId" for data integrity. ___ **Add a foreign key constraint to "eventPassId" and "packId" in the "minterTemporaryWallet"
    table to ensure data integrity. This will enforce a valid reference to the respective
    tables and prevent orphaned records.** [hasura/app/migrations/default/1707893596046_add_minter_temporary_wallet_add_is_delivered_boolean/up.sql [5-6]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-3ce2dc0b55fc676b522409470dc8808d1d429910b92be80c3e6c0573a2718294R5-R6) ```diff -"eventPassId" text, -"packId" text, +"eventPassId" text REFERENCES eventPass(id), +"packId" text REFERENCES pack(id), ```
    security
    Improve security and manageability by reusing a secure wallet instead of creating new ones. ___ **Instead of creating a new Ethereum wallet for every contract, consider reusing a single
    wallet or fetching it from a secure configuration, to avoid unnecessary wallet management
    and improve security.** [libs/nft/thirdweb-organizer/src/index.ts [165-167]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-80b26817489489d8498897af632d05d0f4662c8d8ebdcb70de6613f0297b72d6R165-R167) ```diff -const wallet = ethers.Wallet.createRandom(); +const wallet = getSecureWallet(); // Implement this function to securely fetch an existing wallet const walletAddress = wallet.address; const privateKey = wallet.privateKey; ```
    Encrypt the "privateKey" column to enhance security.                          ___ **Consider encrypting the "privateKey" column to enhance security. Storing private keys in
    plaintext can pose a significant security risk. You can use PostgreSQL's built-in
    encryption functions or a third-party library to encrypt this column.** [hasura/app/migrations/default/1707893596046_add_minter_temporary_wallet_add_is_delivered_boolean/up.sql [4]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-3ce2dc0b55fc676b522409470dc8808d1d429910b92be80c3e6c0573a2718294R4-R4) ```diff -"privateKey" text NOT NULL, +"privateKey" text NOT NULL ENCRYPTED, ```
    maintainability
    Improve code organization by separating deployment and wallet creation logic. ___ **Refactor the deployment and wallet creation logic into a separate function to improve code
    readability and maintainability.** [libs/nft/thirdweb-organizer/src/index.ts [165-191]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-80b26817489489d8498897af632d05d0f4662c8d8ebdcb70de6613f0297b72d6R165-R191) ```diff -const wallet = ethers.Wallet.createRandom(); -const walletAddress = wallet.address; -const privateKey = wallet.privateKey; -await contract.erc721.claimConditions.set([...]); -return { - contract, - wallet: { - address: walletAddress, - privateKey, - }, -}; +async function deployContractAndCreateWallet() { + const wallet = ethers.Wallet.createRandom(); + const walletAddress = wallet.address; + const privateKey = wallet.privateKey; + const contract = await deployContract(); // Implement contract deployment logic + await contract.erc721.claimConditions.set([...]); + return { + contract, + wallet: { + address: walletAddress, + privateKey, + }, + }; +} ```
    Use descriptive variables for error messages in tests for better maintainability. ___ **To improve test readability and maintainability, consider using a descriptive variable for
    the error message instead of hardcoding it within the toThrow assertion. This approach
    makes it easier to update the error message and reuse it across multiple tests if needed.** [libs/payment/admin/src/lib/payment-admin.spec.ts [775]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-c5f2fb965f98bfeae0635c7bf1f112c5481a66580e880dbfe9cf9b14c1c78425R775-R775) ```diff -).rejects.toThrow('Error processing orders : Failed to claim NFTs'); +const expectedErrorMessage = 'Error processing orders : Failed to claim NFTs'; +).rejects.toThrow(expectedErrorMessage); ```
    Evaluate the necessity of the lowercase enforcement function and trigger.     ___ **Ensure that the "force_lowercase_minterTemporaryWallet" function and its trigger are
    necessary. If the addresses are always generated or inputted in lowercase, this function
    might be redundant. Evaluate if the address normalization can be handled at the
    application level to simplify the database logic.** [hasura/app/migrations/default/1707893596046_add_minter_temporary_wallet_add_is_delivered_boolean/up.sql [32-37]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-3ce2dc0b55fc676b522409470dc8808d1d429910b92be80c3e6c0573a2718294R32-R37) ```diff -CREATE OR REPLACE FUNCTION force_lowercase_minterTemporaryWallet() RETURNS TRIGGER AS $$ -BEGIN - NEW."address" := LOWER(NEW."address"); - RETURN NEW; -END; -$$ LANGUAGE plpgsql; +-- Evaluate the necessity of this function ```
    enhancement
    Use a logging library for better error handling and logging.                  ___ **Instead of using console.error for logging errors, consider using a more robust logging
    framework or library that supports different log levels and better error handling. This
    can help with log aggregation and monitoring in production environments.** [libs/features/orders-cron/src/index.ts [23]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-c32bdcc6ef1c2113840b13e8603d4c138d1f3a7c8adc37273b32eaf2123d1ef6R23-R23) ```diff -console.error('Error executing pipeline setOrdersToBusy :', error); +logger.error('Error executing pipeline setOrdersToBusy :', error); ```
    Log transaction hash after successful multicall for better traceability. ___ **After successfully calling contract.call('multicall', [encodedTransactions]), consider
    logging the transaction hash or receipt for better traceability and debugging. This can be
    particularly useful for monitoring the status of transactions and diagnosing issues in
    production.** [libs/nft/thirdweb-admin/src/lib/nft-thirdweb-api.ts [129]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-150c80ec08729dcba4ddde00c6d25b1897f7c9852ffc033e3407d5f122b493e7R129-R129) ```diff -await contract.call('multicall', [encodedTransactions]); +const receipt = await contract.call('multicall', [encodedTransactions]); +console.log(`Multicall transaction successful: ${receipt.transactionHash}`); ```
    Improve mock of ethers.Wallet.createRandom to return varied wallets. ___ **Consider verifying the mock implementation of ethers.Wallet.createRandom to ensure it
    returns a variety of addresses and private keys. Using a static return value might not
    adequately test scenarios where different wallets are expected.** [libs/nft/thirdweb-organizer/src/nftCollection.integration.test.ts [29-34]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-b3d88963320227a70f06c3fdb4d092a57c26c2d41a4d70bbb9c37b5452bea233R29-R34) ```diff -createRandom: jest.fn(() => ({ - privateKey: - '0x8f63072cd9a2618b1987c991f3e3037862a79692ab494510d4079bd09af8327e', - address: '0xDd43A3A2433c629D0070F052AEd53E7C2a78B4F9', -})), +createRandom: jest.fn().mockImplementation(() => { + return { + privateKey: generateRandomPrivateKey(), + address: generateRandomAddress(), + }; +}), ```
    Use Redis transactions or pipelines for executing multiple commands atomically. ___ **Consider using a transaction or pipeline when executing multiple Redis commands to ensure
    atomicity. This is particularly important when setting multiple hash values as seen in the
    code. This approach minimizes the number of round trips to the server and ensures that
    either all commands run successfully or none at all, which is crucial for maintaining data
    integrity.** [libs/payment/admin/src/lib/payment-admin.ts [481-486]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-d5b42e9028bd5be069e6e012324c6ac4abb3b9b72a12b32902df391daf9f45bdR481-R486) ```diff -const cachePromises = orders.map((order) => - cache.kv.hset(`${order.eventPassId}`, { +const pipeline = cache.kv.pipeline(); +orders.forEach((order) => { + pipeline.hset(`${order.eventPassId}`, { [order.id]: RedisOrderStatus.Pending, - }), -); -await Promise.all(cachePromises); + }); +}); +await pipeline.exec(); ```
    Use an ENUM or status table for "isDelivered" to allow for more detailed tracking. ___ **For the "isDelivered" columns added to "packNftSupply" and "eventPassNft" tables, consider
    the future need for tracking delivery attempts or statuses beyond a simple boolean. It
    might be more scalable to use an ENUM type or a separate status table if more states are
    anticipated.** [hasura/app/migrations/default/1707893596046_add_minter_temporary_wallet_add_is_delivered_boolean/up.sql [21-27]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-3ce2dc0b55fc676b522409470dc8808d1d429910b92be80c3e6c0573a2718294R21-R27) ```diff -ADD COLUMN "isDelivered" boolean NOT NULL DEFAULT false; +ADD COLUMN "deliveryStatus" delivery_status_enum NOT NULL DEFAULT 'pending'; ```
    possible issue
    Validate order quantity before encoding transactions in multicallClaim. ___ **Ensure that the multicallClaim function handles the case where order.quantity might be
    undefined or invalid. Before encoding transactions, validate that order.quantity is a
    positive integer to avoid runtime errors during the contract call.** [libs/nft/thirdweb-admin/src/lib/nft-thirdweb-api.ts [117-125]](https://github.com/Offline-Project/marketplace/pull/275/files#diff-150c80ec08729dcba4ddde00c6d25b1897f7c9852ffc033e3407d5f122b493e7R117-R125) ```diff +if (order.quantity <= 0) { + throw new Error(`Invalid quantity for order ${order.id}`); +} return contract .prepare('claimTo', [order.account.address, order.quantity]) .encode(); ```

    ✨ Improve tool usage guide:
    **Overview:** The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered [automatically](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) every time a new PR is opened, or can be invoked manually by commenting on a PR. When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L69) related to the improve tool (`pr_code_suggestions` section), use the following template: ``` /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=... ``` With a [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-app), use the following template: ``` [pr_code_suggestions] some_config1=... some_config2=... ```
    Enabling\disabling automation
    When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the improve tool is: ``` pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...] ``` meaning the `improve` tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.
    Utilizing extra instructions
    Extra instructions are very important for the `improve` tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project. Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on. Examples for extra instructions: ``` [pr_code_suggestions] # /improve # extra_instructions=""" Emphasize the following aspects: - Does the code logic cover relevant edge cases? - Is the code logic clear and easy to understand? - Is the code logic efficient? ... """ ``` Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.
    A note on code suggestions quality
    - While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically. - Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base. - Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the [custom suggestions :gem:](https://github.com/Codium-ai/pr-agent/blob/main/docs/CUSTOM_SUGGESTIONS.md) tool - With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands
    > To invoke the PR-Agent, add a comment using one of the following commands: > - **/review**: Request a review of your Pull Request. > - **/describe**: Update the PR title and description based on the contents of the PR. > - **/improve [--extended]**: Suggest code improvements. Extended mode provides a higher quality feedback. > - **/ask \**: Ask a question about the PR. > - **/update_changelog**: Update the changelog based on the PR's contents. > - **/add_docs** 💎: Generate docstring for new components introduced in the PR. > - **/generate_labels** 💎: Generate labels for the PR based on the PR's contents. > - **/analyze** 💎: Automatically analyzes the PR, and presents changes walkthrough for each component. >See the [tools guide](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md) for more details. >To list the possible configuration parameters, add a **/config** comment.
    See the [improve usage](https://github.com/Codium-ai/pr-agent/blob/main/docs/IMPROVE.md) page for a more comprehensive guide on using this tool.