Closed edisontim closed 4 days ago
The latest updates on your projects. Learn more about Vercel for Git โ๏ธ
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
eternum | โ Ready (Inspect) | Visit Preview | ๐ฌ Add feedback | Jun 29, 2024 8:51am |
โฑ๏ธ Estimated effort to review [1-5] | 4 |
๐งช Relevant tests | No |
๐ Security concerns | No |
โก Key issues to review |
Possible Bug: The useEntities hook in useEntities.tsx has added complex nested functions like getPlayerAddressFromEntity and getAddressNameFromEntity . These functions could potentially lead to performance issues due to deep nested calls and should be optimized or simplified. |
Code Organization: The useResources.tsx file has undergone significant refactoring with the addition of getResourceBalance and changes to import statements. It's crucial to ensure that these changes do not affect existing functionalities and that they follow best practices for hooks. | |
Data Handling: The new MarketTradingHistory.tsx component involves complex GraphQL queries and state management which could be prone to errors. It's important to ensure that the data handling is robust, especially in the queryTrades function where multiple states are updated based on query results. |
Category | Suggestion | Score |
Possible issue |
Provide a fallback URL for
___
**Since | 9 |
Ensure
___
**Verify that the | 9 | |
Update the
___
**Ensure that the | 8 | |
Possible bug |
Add null checks for
___
**Consider checking for undefined or null values for | 8 |
Enhancement |
Add a check for empty results in
___
**To ensure that | 7 |
Add validation before emitting trade events to ensure data consistency___ **Consider adding error handling or validation logic when emittingAcceptOrder and CancelOrder events to ensure that the state changes are valid and consistent before broadcasting these events.** [contracts/src/systems/trade/contracts/trade_systems.cairo [282-287]](https://github.com/BibliothecaDAO/eternum/pull/1043/files#diff-e84e5e5d21898c44ad2cd3739a38f25dc14b6b8f1b627db54326aabdb5bcc22dR282-R287) ```diff -emit!( - world, - (AcceptOrder { - taker_id, - maker_id: trade.maker_id, - trade_id, - timestamp: starknet::get_block_timestamp() - }) -) +if validate_trade(trade_id) { + emit!( + world, + (AcceptOrder { + taker_id, + maker_id: trade.maker_id, + trade_id, + timestamp: starknet::get_block_timestamp() + }) + ) +} ``` Suggestion importance[1-10]: 7Why: Adding validation logic before emitting events can enhance the robustness of the system by ensuring state changes are valid. However, the exact implementation of `validate_trade` is not provided, which slightly reduces the score. | 7 | |
Use a trade-specific timestamp for the
___
**Ensure that the timestamp used in the | 6 | |
Performance |
Optimize GraphQL queries in
___
**To improve the performance of the | 6 |
PR Type
Enhancement, Bug fix
Description
client
constant ineventPoller.tsx
.AddressName
component and address-related functions inuseEntities.tsx
.DetachedResource
component andgetResourceBalance
function inuseResources.tsx
.useAddressStore.tsx
.MarketTradingHistory.tsx
.TradeHistoryEvent
component.BattleActions.tsx
.hexToAscii
function inutils.tsx
.events.ts
.global.ts
..env.local
copy command inclient.sh
.manifest.json
andmanifest.toml
.AcceptOrder
andCancelOrder
intrade_systems.cairo
.Changes walkthrough ๐
17 files
eventPoller.tsx
Export `client` constant for external usage.
client/src/hooks/eventPoller.tsx - Exported `client` constant.
useEntities.tsx
Add address-related functions and components.
client/src/hooks/helpers/useEntities.tsx
AddressName
to the components.getPlayerAddressFromEntity
andgetAddressNameFromEntity
functions.
useResources.tsx
Add DetachedResource component and getResourceBalance function.
client/src/hooks/helpers/useResources.tsx
DetachedResource
to the components.getResourceBalance
function.useAddressStore.tsx
Clean up commented-out address fetching code.
client/src/hooks/store/useAddressStore.tsx - Removed commented-out code related to fetching address name.
BankList.tsx
Reorganize imports in BankList component.
client/src/ui/components/bank/BankList.tsx - Reorganized imports for better readability.
Login.tsx
Clean up imports and remove debug logs.
client/src/ui/components/chat/Login.tsx
useMemo
anduseState
imports for consistency.MarketModal.tsx
Reorganize imports and update MarketTradingHistory usage.
client/src/ui/components/trading/MarketModal.tsx
MarketTradingHistory
component usage.MarketTradingHistory.tsx
Implement trade history querying and display.
client/src/ui/components/trading/MarketTradingHistory.tsx - Implemented trade history querying and display.
TradeHistoryEvent.tsx
Add TradeHistoryEvent component.
client/src/ui/components/trading/TradeHistoryEvent.tsx - Added new component for displaying trade history events.
BattleActions.tsx
Update battle view after battle action.
client/src/ui/modules/military/battle-view/BattleActions.tsx - Added `setBattleView` call after battle action.
utils.tsx
Remove unused hexToAscii function.
client/src/ui/utils/utils.tsx - Removed unused `hexToAscii` function.
events.ts
Add constants for accept and cancel order events.
sdk/packages/eternum/src/constants/events.ts
ACCEPT_ORDER_EVENT
andCANCEL_ORDER_EVENT
.global.ts
Update armies tick interval to 30 seconds.
sdk/packages/eternum/src/constants/global.ts - Updated `armiesTickIntervalInSeconds` to 30 seconds.
client.sh
Comment out .env.local copy command.
scripts/client.sh - Commented out the line copying `.env.sample` to `.env.local`.
manifest.json
Update block number and class hashes.
contracts/manifests/dev/manifest.json - Updated block number and class hashes.
manifest.toml
Update block number and class hashes.
contracts/manifests/dev/manifest.toml - Updated block number and class hashes.
trade_systems.cairo
Add AcceptOrder and CancelOrder events with timestamps.
contracts/src/systems/trade/contracts/trade_systems.cairo
AcceptOrder
andCancelOrder
.CreateOrder
event to include timestamp.