getTrade(uint256) :
This function retrieves the details of a trade from the trades mapping. It takes a uint256 _trade as an input parameter, which is used to look up the trade in the trades mapping. The function then returns the address of the poster, the item being traded, the price of the item, and the status of the trade as a tuple. (autogenerated documentation)
openTrade(uint256,uint256) :
This function allows a user to open a trade on the blockchain. It takes two parameters, _item and _price, and uses the itemToken contract to transfer the item from the user to the contract. It then stores the trade information in the trades array, and increments the tradeCounter. Finally, it emits a TradeStatusChange event with the tradeCounter and the status "Open". (autogenerated documentation)
executeTrade(uint256) :
This function executes a trade between two parties. It takes in a trade ID as an argument and checks if the trade is in an "Open" status. If it is, it transfers the currency from the buyer to the seller and the item from the contract to the buyer. Finally, it updates the trade status to "Executed" and emits an event to notify of the status change. (autogenerated documentation)
cancelTrade(uint256) :
This function allows the poster of a trade to cancel the trade. It requires that the sender of the transaction is the poster of the trade and that the trade is still open. It then transfers the item associated with the trade back to the poster and sets the status of the trade to "Cancelled". Finally, it emits an event to indicate that the status of the trade has changed. (autogenerated documentation)