Company Simulator

First Flight #51
Beginner FriendlyDeFi
100 EXP
Submission Details
Impact: low
Likelihood: low

Cyfrin_Hub events properties could be indexed for better querying

Author Revealed upon completion

All the properties (topics) on the events found in the Cyfrin_Hub smart contract could be marked with indexed for better querying

Description

  • Indexed arguments (topics) make the argument searchable by clients listening to the events. Vyper supports a maximum of four (4) indexed arguments per event. This simple change could make the events searchable and indexable.

# ------------------------------------------------------------------
# EVENTS
# ------------------------------------------------------------------
event Produced:
amount: uint256
cost: uint256
event Sold:
amount: uint256
revenue: uint256
event Withdrawn_Shares:
investor: address
shares: uint256
event ReputationChanged:
new_reputation: uint256
event SharesIssued:
investor: address
amount: uint256
event ShareCapIncreased:
new_cap: uint256

Recommended Mitigation

  • We could add the indexed keyword to all topics in events:

# ------------------------------------------------------------------
# EVENTS
# ------------------------------------------------------------------
event Produced:
- amount: uint256
+ amount: indexed(uint256)
- cost: uint256
+ cost: indexed(uint256)
event Sold:
- amount: uint256
+ amount: indexed(uint256)
- revenue: uint256
+ revenue: indexed(uint256)
event Withdrawn_Shares:
- investor: address
+ investor: indexed(address)
- shares: uint256
+ shares: indexed(uint256)
event ReputationChanged:
- new_reputation: uint256
+ new_reputation: indexed(uint256)
event SharesIssued:
- investor: address
+ investor: indexed(address)
- amount: uint256
+ amount: indexed(uint256)
event ShareCapIncreased:
- new_cap: uint256
+ new_cap: indexed(uint256)

  • We could add the indexed keyword just to the topics that are of type address:

    # ------------------------------------------------------------------
    # EVENTS
    # ------------------------------------------------------------------
    event Produced:
    amount: uint256
    cost: uint256
    event Sold:
    amount: uint256
    revenue: uint256
    event Withdrawn_Shares:
    - investor: address
    + investor: indexed(address)
    shares: uint256
    event ReputationChanged:
    new_reputation: uint256
    event SharesIssued:
    - investor: address
    + investor: indexed(address)
    amount: uint256
    event ShareCapIncreased:
    new_cap: uint256

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.