-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1111 from ShivRaiGithub/main
Blockchain Development : Decentralized Voting ( New PR )
- Loading branch information
Showing
67 changed files
with
27,773 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
Blockchain_Development/PyVote/Foundry_contracts/.gitignore
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Compiler files | ||
cache/ | ||
out/ | ||
|
||
# Ignores development broadcast logs | ||
!/broadcast | ||
/broadcast/*/31337/ | ||
/broadcast/**/dry-run/ | ||
|
||
# Docs | ||
docs/ | ||
|
||
# Dotenv file | ||
.env |
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
## Voting.sol | ||
User deploys a contract as owner. User can add candidates for Voting who will be provided with array index as their id. Other users can vote once on a candidate of their choice. | ||
|
||
## 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. | ||
|
||
|
||
## Useful Commands For this Project | ||
|
||
### Compiling | ||
|
||
```shell | ||
forge compile | ||
``` | ||
|
||
### Test | ||
|
||
```shell | ||
forge test | ||
``` | ||
|
||
### Anvil | ||
|
||
```shell | ||
anvil | ||
``` | ||
|
||
### Deploy | ||
|
||
```shell | ||
forge script script/Deploy.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key> | ||
``` | ||
|
||
### Sample execution (Be within `Foundry_contracts`) | ||
|
||
1) Compile using : | ||
```shell | ||
forge compile | ||
``` | ||
2) (Optional) Test using : | ||
```shell | ||
forge test | ||
``` | ||
Note: It will automatically compile on test if not done so. | ||
|
||
3) Split terminal into 2. | ||
4) Use following command to spin up a local-chain to work on: | ||
```shell | ||
anvil | ||
``` | ||
5) Make sure anvil is working. | ||
6) Deploy using : | ||
```shell | ||
forge script script/Deploy.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key> --broadcast | ||
``` | ||
Note: Sample command provided in script/Deploy.s.sol as comment. You can get private key and rpc url from anvil itself. | ||
|
||
|
||
## Documentation | ||
|
||
https://book.getfoundry.sh/ | ||
|
||
|
||
### Help | ||
|
||
```shell | ||
$ forge --help | ||
$ anvil --help | ||
$ cast --help | ||
``` | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[profile.default] | ||
src = "src" | ||
out = "out" | ||
libs = ["lib"] | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options |
1 change: 1 addition & 0 deletions
1
Blockchain_Development/PyVote/Foundry_contracts/lib/forge-std/.gitattributes
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
src/Vm.sol linguist-generated |
128 changes: 128 additions & 0 deletions
128
Blockchain_Development/PyVote/Foundry_contracts/lib/forge-std/.github/workflows/ci.yml
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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
name: CI | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Print forge version | ||
run: forge --version | ||
|
||
# Backwards compatibility checks: | ||
# - the oldest and newest version of each supported minor version | ||
# - versions with specific issues | ||
- name: Check compatibility with latest | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
- name: Check compatibility with 0.8.0 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.8.0) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
- name: Check compatibility with 0.7.6 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.7.6) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
- name: Check compatibility with 0.7.0 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.7.0) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
- name: Check compatibility with 0.6.12 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.6.12) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
- name: Check compatibility with 0.6.2 | ||
if: always() | ||
run: | | ||
output=$(forge build --skip test --use solc:0.6.2) | ||
if echo "$output" | grep -q "Warning"; then | ||
echo "$output" | ||
exit 1 | ||
fi | ||
# via-ir compilation time checks. | ||
- name: Measure compilation time of Test with 0.8.17 --via-ir | ||
if: always() | ||
run: forge build --skip test --contracts test/compilation/CompilationTest.sol --use solc:0.8.17 --via-ir | ||
|
||
- name: Measure compilation time of TestBase with 0.8.17 --via-ir | ||
if: always() | ||
run: forge build --skip test --contracts test/compilation/CompilationTestBase.sol --use solc:0.8.17 --via-ir | ||
|
||
- name: Measure compilation time of Script with 0.8.17 --via-ir | ||
if: always() | ||
run: forge build --skip test --contracts test/compilation/CompilationScript.sol --use solc:0.8.17 --via-ir | ||
|
||
- name: Measure compilation time of ScriptBase with 0.8.17 --via-ir | ||
if: always() | ||
run: forge build --skip test --contracts test/compilation/CompilationScriptBase.sol --use solc:0.8.17 --via-ir | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Print forge version | ||
run: forge --version | ||
|
||
- name: Run tests | ||
run: forge test -vvv | ||
|
||
fmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Print forge version | ||
run: forge --version | ||
|
||
- name: Check formatting | ||
run: forge fmt --check |
31 changes: 31 additions & 0 deletions
31
Blockchain_Development/PyVote/Foundry_contracts/lib/forge-std/.github/workflows/sync.yml
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Sync Release Branch | ||
|
||
on: | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
sync-release-branch: | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.event.release.tag_name, 'v1') | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: v1 | ||
|
||
# The email is derived from the bots user id, | ||
# found here: https://api.github.com/users/github-actions%5Bbot%5D | ||
- name: Configure Git | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | ||
- name: Sync Release Branch | ||
run: | | ||
git fetch --tags | ||
git checkout v1 | ||
git reset --hard ${GITHUB_REF} | ||
git push --force |
4 changes: 4 additions & 0 deletions
4
Blockchain_Development/PyVote/Foundry_contracts/lib/forge-std/.gitignore
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cache/ | ||
out/ | ||
.vscode | ||
.idea |
Oops, something went wrong.