Open shadowaxe99 opened 5 months ago
87cc2dd504
)[!TIP] I can email you next time I complete a pull request if you set up your email here!
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
server/app/blockchain/smart_contracts.py
✓ https://github.com/shadowaxe99/creator-Econ/commit/d6ef5a4b637d7915acc41dde1c9deb77109b06ef Edit
Modify server/app/blockchain/smart_contracts.py with contents:
• Correct the syntax error in the `get_asset_details` method by moving the `try` block above the `except` block.
• In the `create_asset` method, remove the duplicate 'gasPrice' key in the transaction dictionary to resolve the syntax error.
• Modify the `purchase_asset` method to return a dictionary containing both a success flag and transaction details instead of just a boolean. This change will allow the front-end to display more informative messages to the user based on the transaction outcome.
--- +++ @@ -47,12 +47,11 @@ return False def get_asset_details(self, asset_id: str) -> dict: + try: + return self.contract.functions.getAssetDetails(asset_id).call() except Exception as e: print('An error occurred during the get_asset_details operation:', e) return {} - - try: - return self.contract.functions.getAssetDetails(asset_id).call() except Exception as e: print('An error occurred while getting the asset details:', e) return {} @@ -60,8 +59,6 @@ def create_asset(self, title: str, description: str, price: int, image_url: str) -> bool: nonce = self.w3.eth.getTransactionCount(signer_account.address) transaction = self.contract.functions.createAsset(title, description, price, image_url).buildTransaction({ - 'gasPrice': self.w3.eth.generateGasPrice(), 'chainId': self.w3.net.chainId - 'gas': 2000000, 'gasPrice': self.w3.toWei('50', 'gwei'), 'nonce': nonce
server/app/blockchain/smart_contracts.py
✓ Edit
Check server/app/blockchain/smart_contracts.py with contents:
Ran GitHub Actions for d6ef5a4b637d7915acc41dde1c9deb77109b06ef:
client/src/components/marketplace/AssetItem.tsx
✓ https://github.com/shadowaxe99/creator-Econ/commit/08cc22ede871d68c79c7ad37a93769cee426a8ec Edit
Modify client/src/components/marketplace/AssetItem.tsx with contents:
• Update the `handlePurchase` function to correctly interpret the response from the `purchaseAsset` function. Adjust the condition to check if the transactionReceipt's status is true (indicating success) instead of checking for a 'success' string.
--- +++ @@ -16,7 +16,7 @@ const handlePurchase = async () => { try { const transactionReceipt = await purchaseAsset(id); - if (transactionReceipt.status === 'success') { + if (transactionReceipt.status === true) { alert('Purchase successful!'); } else { alert('Purchase failed.');
client/src/components/marketplace/AssetItem.tsx
✓ Edit
Check client/src/components/marketplace/AssetItem.tsx with contents:
Ran GitHub Actions for 08cc22ede871d68c79c7ad37a93769cee426a8ec:
server/app/api/routes.py
✓ https://github.com/shadowaxe99/creator-Econ/commit/1bf135dc070c3711448f25e588171e20b2338531 Edit
Modify server/app/api/routes.py with contents:
• Update the `purchase_asset` route to correctly unpack the success flag and transaction details from the response of the `purchase_asset` method in the `SmartContractManager`. Use these details to construct a more informative response JSON that includes whether the purchase was successful and any relevant transaction details.
--- +++ @@ -35,7 +35,9 @@ return jsonify({'message': 'Asset already sold'}), 400 buyer_address = data['buyer_address'] - success, transaction_details = sc_manager.purchase_asset(asset_id, buyer_address) + purchase_response = sc_manager.purchase_asset(asset_id, buyer_address) + success = purchase_response['success'] + transaction_details = purchase_response['transaction_details'] if success: asset.is_sold = True
server/app/api/routes.py
✓ Edit
Check server/app/api/routes.py with contents:
Ran GitHub Actions for 1bf135dc070c3711448f25e588171e20b2338531:
I have finished reviewing the code for completeness. I did not find errors for sweep/_31b87
.
💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.
This is an automated message generated by Sweep AI.
Details
make this functional
Checklist
- [X] Modify `server/app/blockchain/smart_contracts.py` ✓ https://github.com/shadowaxe99/creator-Econ/commit/d6ef5a4b637d7915acc41dde1c9deb77109b06ef [Edit](https://github.com/shadowaxe99/creator-Econ/edit/sweep/_31b87/server/app/blockchain/smart_contracts.py) - [X] Running GitHub Actions for `server/app/blockchain/smart_contracts.py` ✓ [Edit](https://github.com/shadowaxe99/creator-Econ/edit/sweep/_31b87/server/app/blockchain/smart_contracts.py) - [X] Modify `client/src/components/marketplace/AssetItem.tsx` ✓ https://github.com/shadowaxe99/creator-Econ/commit/08cc22ede871d68c79c7ad37a93769cee426a8ec [Edit](https://github.com/shadowaxe99/creator-Econ/edit/sweep/_31b87/client/src/components/marketplace/AssetItem.tsx) - [X] Running GitHub Actions for `client/src/components/marketplace/AssetItem.tsx` ✓ [Edit](https://github.com/shadowaxe99/creator-Econ/edit/sweep/_31b87/client/src/components/marketplace/AssetItem.tsx) - [X] Modify `server/app/api/routes.py` ✓ https://github.com/shadowaxe99/creator-Econ/commit/1bf135dc070c3711448f25e588171e20b2338531 [Edit](https://github.com/shadowaxe99/creator-Econ/edit/sweep/_31b87/server/app/api/routes.py) - [X] Running GitHub Actions for `server/app/api/routes.py` ✓ [Edit](https://github.com/shadowaxe99/creator-Econ/edit/sweep/_31b87/server/app/api/routes.py)