Skip to content

Commit

Permalink
Reorganize project directories (#783)
Browse files Browse the repository at this point in the history
## Type of change

<!--Delete points that do not apply-->

- Improvement (refactoring, restructuring repository, cleaning tech
debt, ...)

## Changes

The following changes have been made:

Changes the project structure for all projects to:
```
My_app
├── src/
│   └────── main.tsx
├── app-contract
│   ├────── src/main.sw
│   └────── tests/harness.rs
├── package.json
├── index.html
├── README.md
└── SPECIFICATION.md
```

This should allow for quicker access to the project's source code and
not be buried in a million directories.

## Notes

- Some projects such as TicTacToe/NFT have been removed from
"games"/"native-assets" and moved into the parent directory
- This may break any other open pull requests that depend on this
project structure
- Empty UI folders have been removed

---------

Co-authored-by: Matt Auer <mattauer@umich.edu>
  • Loading branch information
bitzoic and matt-user authored Mar 29, 2024
1 parent 39d1907 commit 51d2171
Show file tree
Hide file tree
Showing 701 changed files with 1,264 additions and 2,400 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
resolver = "2"
members = [
"./contracts/NFT-contract",
"./template-contract",
]

File renamed without changes.
2 changes: 2 additions & 0 deletions .devops/.template/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["./template-contract"]
28 changes: 11 additions & 17 deletions .devops/.template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

TODO: A summary of the application should be written here.

More information about the contract can be found [here](./project/SPECIFICATION.md) and for the user interface [here](./ui/SPECIFICATION.md).
More information about the contract can be found [here](./SPECIFICATION.md).

## Project structure

Expand All @@ -31,31 +31,25 @@ The project consists of a smart contract.

```sh
Template
├── project
│   ├── contracts
│   │   └── template-contract
│   │   ├── src/main.sw
│   │   └── tests/harness.rs
│   ├── libraries
│   ├── predicates
│   ├── scripts
│   ├── README.md
│   └── SPECIFICATION.md
├── ui
│ ├── README.md
│ └── SPECIFICATION.md
└── README.md
├── template-contract
│   ├── src/main.sw
│   └── tests/harness.rs
├── libraries
├── predicates
├── scripts
├── README.md
└── SPECIFICATION.md
```

## Running the project

### User interface

TODO: The user interface does not currently exist therefore its [README.md](ui/README.md) and [SPECIFICATION.md](ui/SPECIFICATION.md) are empty.
TODO: The user interface does not currently exist.

### Project

In order to run the subsequent commands change into the following directory `/path/to/Template/project/<here>`.
In order to run the subsequent commands change into the following directory `/path/to/Template/<here>`.

#### Program compilation

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions .devops/.template/project/Cargo.toml

This file was deleted.

2 changes: 0 additions & 2 deletions .devops/.template/project/Forc.toml

This file was deleted.

3 changes: 0 additions & 3 deletions .devops/.template/project/README.md

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fuels::prelude::*;

abigen!(Contract(
name = "Template",
abi = "./contracts/template-contract/out/debug/template-contract-abi.json"
abi = "./template-contract/out/debug/template-contract-abi.json"
));

const TEMPLATE_CONTRACT_BINARY_PATH: &str = "./out/debug/template-contract.bin";
Expand Down
13 changes: 0 additions & 13 deletions .devops/.template/ui/README.md

This file was deleted.

Empty file removed .devops/.template/ui/app/.gitkeep
Empty file.
56 changes: 0 additions & 56 deletions .devops/.template/ui/config/chainConfig.json

This file was deleted.

3 changes: 0 additions & 3 deletions .devops/.template/ui/scripts/start_node.sh

This file was deleted.

10 changes: 5 additions & 5 deletions .devops/aurora/apps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ AMM
DAO
OTC-swap-predicate
airdrop
auctions/english-auction
english-auction
counter-script
escrow
fundraiser
games/TicTacToe
TicTacToe
multisig-wallet
name-registry
native-assets/NFT
native-assets/native-asset
native-assets/fractional-NFT
NFT
native-asset
fractional-NFT
oracle
timelock
2 changes: 1 addition & 1 deletion .devops/aurora/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(crate) fn repo_root() -> String {

pub(crate) fn project_path(app: String, root: String) -> anyhow::Result<PathBuf> {
Ok(
std::fs::canonicalize(format!("{}/{}/project", root, app)).map_err(|error| {
std::fs::canonicalize(format!("{}/{}/", root, app)).map_err(|error| {
anyhow!(
"Failed to canonicalize path to project for app '{}': {}",
app,
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ jobs:
[
"airdrop",
"AMM",
"auctions/english-auction",
"english-auction",
"counter-script",
"DAO",
"escrow",
"fundraiser",
"games/TicTacToe",
"TicTacToe",
"multisig-wallet",
"name-registry",
"native-assets/NFT",
"native-assets/native-asset",
"native-assets/fractional-NFT",
"NFT",
"native-asset",
"fractional-NFT",
"oracle",
"OTC-swap-predicate",
".devops/.template",
Expand Down Expand Up @@ -80,37 +80,37 @@ jobs:

- name: Check Sway formatting
run: |
cd ${{ matrix.project }}/project
cd ${{ matrix.project }}
forc fmt --check
- name: Check Rust formatting
run: |
cd ${{ matrix.project }}/project
cd ${{ matrix.project }}
cargo fmt --verbose --check
- name: Build Sway
run: |
cd ${{ matrix.project }}/project
cd ${{ matrix.project }}
forc build --locked
- name: Build Rust files
run: |
cd ${{ matrix.project }}/project
cd ${{ matrix.project }}
cargo build --locked
- name: Check Clippy Linter
run: |
cd ${{ matrix.project }}/project
cd ${{ matrix.project }}
cargo clippy --all-features --all-targets -- -D warnings
- name: Run Rust tests
run: |
cd ${{ matrix.project }}/project
cd ${{ matrix.project }}
cargo test --locked
- name: Run Sway tests
run: |
cd ${{ matrix.project }}/project
cd ${{ matrix.project }}
forc test
contributing-book:
Expand Down
7 changes: 1 addition & 6 deletions AMM/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
target
project/contracts/AMM-contract/out
project/contracts/exchange-contract/out
project/contracts/test-artifacts/malicious-implementation/out
project/scripts/atomic-add-liquidity/out
project/scripts/swap-exact-input/out
project/scripts/swap-exact-output/out
out
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "Apache-2.0"

[dependencies]
fuels = { version = "0.55.0", features = ["fuel-core-lib"] }
test-utils = { path = "../../test-utils" }
test-utils = { path = "../test-utils" }
tokio = { version = "1.21.0", features = ["rt", "macros"] }

[[test]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "AMM-contract"

[dependencies]
libraries = { path = "../../libraries" }
libraries = { path = "../libraries" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions AMM/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[workspace]
resolver = "2"
members = [
"./AMM-contract",
"./exchange-contract",
"./atomic-add-liquidity",
"./swap-exact-input",
"./swap-exact-output",
"./test-utils",
]
File renamed without changes.
9 changes: 9 additions & 0 deletions AMM/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[workspace]
members = [
"./AMM-contract",
"./exchange-contract",
"./test-utils/test-artifacts/malicious-implementation",
"./atomic-add-liquidity",
"./swap-exact-input",
"./swap-exact-output",
]
29 changes: 11 additions & 18 deletions AMM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,17 @@ The contracts are designed to

```sh
AMM
├── project
│   ├── contracts
│   │   ├── AMM-contract
│   │   └── exchange-contract
│   ├── libraries
│   │   └── src/interface.sw
│   ├── scripts
│   │   ├── atomic-add-liquidity
│   │   ├── swap-exact-input
│   │   └── swap-exact-output
| ├── test-utils
| | └── src/lib.rs
| ├── README.md
│   └── SPECIFICATION.md
├── ui
│ ├── README.md
│ └── SPECIFICATION.md
└─── README.md
├── AMM-contract
├── exchange-contract
├── libraries
│   └── src/interface.sw
├── atomic-add-liquidity
├── swap-exact-input
└── swap-exact-output
├── test-utils
└── src/lib.rs
├── README.md
└── SPECIFICATION.md
```

All contracts and scripts have the structure:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "Apache-2.0"

[dev-dependencies]
fuels = { version = "0.55.0", features = ["fuel-core-lib"] }
test-utils = { path = "../../test-utils" }
test-utils = { path = "../test-utils" }
tokio = { version = "1.12", features = ["rt", "macros"] }

[[test]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "atomic-add-liquidity"

[dependencies]
libraries = { path = "../../libraries" }
libraries = { path = "../libraries" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "Apache-2.0"

[dependencies]
fuels = { version = "0.55.0", features = ["fuel-core-lib"] }
test-utils = { path = "../../test-utils" }
test-utils = { path = "../test-utils" }
tokio = { version = "1.21.0", features = ["rt", "macros"] }

[[test]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ license = "Apache-2.0"
name = "exchange-contract"

[dependencies]
libraries = { path = "../../libraries" }
libraries = { path = "../libraries" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions AMM/project/Cargo.toml

This file was deleted.

9 changes: 0 additions & 9 deletions AMM/project/Forc.toml

This file was deleted.

6 changes: 0 additions & 6 deletions AMM/project/README.md

This file was deleted.

Loading

0 comments on commit 51d2171

Please sign in to comment.