-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aaaa2a4
commit a7457ff
Showing
1 changed file
with
39 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,39 @@ | ||
## Foundry | ||
|
||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** | ||
|
||
Foundry consists of: | ||
|
||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). | ||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. | ||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. | ||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL. | ||
|
||
## Documentation | ||
|
||
https://book.getfoundry.sh/ | ||
|
||
## Usage | ||
|
||
### Build | ||
|
||
```shell | ||
$ forge build | ||
``` | ||
|
||
### Test | ||
|
||
```shell | ||
$ forge test | ||
``` | ||
|
||
### Format | ||
|
||
```shell | ||
$ forge fmt | ||
``` | ||
|
||
### Gas Snapshots | ||
|
||
```shell | ||
$ forge snapshot | ||
``` | ||
|
||
### Anvil | ||
|
||
```shell | ||
$ anvil | ||
``` | ||
|
||
### Deploy | ||
|
||
```shell | ||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
|
||
### Cast | ||
|
||
```shell | ||
$ cast <subcommand> | ||
``` | ||
|
||
### Help | ||
|
||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
``` | ||
# Plasa Contracts | ||
|
||
## Querying Question | ||
|
||
Each question contract has a `getQuestionView(address user)` function that returns a `QuestionView` struct. This struct contains all the information about the question and the user's voting status. | ||
It includes an array of `OptionView` structs, which contain information about each option. | ||
|
||
```solidity | ||
/// @dev Represents a comprehensive view of a question with all its details | ||
struct QuestionView { | ||
QuestionType questionType; // The type of question (Fixed or Open), set in the constructor of OpenQuestion or FixedQuestion | ||
string title; // The title of the question, can be updated with Question.updateTitle() | ||
string description; // The description of the question, can be updated with Question.updateDescription() | ||
uint256 deadline; // The voting deadline, can be updated with Question.updateDeadline() | ||
uint256 totalVoteCount; // The total number of votes across all options, calculated in Question.getQuestionView() | ||
OptionView[] options; // Array of all voting options with their details, populated in Question.getQuestionView() | ||
Status status; // The current status of the question (Active or Ended), determined by Question.getStatus() | ||
address owner; // The owner of the question contract, set in the constructor and managed by Ownable | ||
uint256 started; // The timestamp when the question was deployed, set in the Question constructor | ||
uint256 userOptionVoted; // The option ID the user voted for (0 if not voted), set in Question.getQuestionView() | ||
uint256 userPointsCurrent; // The user's current point balance, retrieved from the Points contract | ||
uint256 userPointsDeadline; // The user's point balance at the voting deadline, retrieved from the Points contract | ||
bool userCanAddOption; // Whether the user can add a new option (always false for FixedQuestion, conditional for OpenQuestion) | ||
} | ||
``` | ||
|
||
```solidity | ||
/// @dev Represents a view of a voting option with additional user-specific data | ||
struct OptionView { | ||
string title; // The title of the option, set in Question._addOption() | ||
string description; // The description of the option, set in Question._addOption() | ||
address proposer; // The address that proposed this option, set to msg.sender in Question._addOption() | ||
uint256 voteCount; // The total number of votes for this option, incremented in Question.vote() | ||
uint256 pointsAccrued; // Total points accrued for this option, updated in Question.vote() | ||
bool userVoted; // Whether the specific user voted for this option, checked in Question.getQuestionView() | ||
} | ||
``` | ||
|
||
More details about the `OptionView` struct can be found in the `IQuestion.sol` interface. |