Repository: OpenZeppelin/rust-contracts-stylus
Pull request #280 (2024-09-11 06:45:09)

ref: new workspace structure and version management
- [x]  Set `motsu` version to `v0.1.0`
- [x] Improve version management for the workspace
  - `contracts`, `lib/crypto`, `examples`, and `benches` use version set for the whole workspace 
  - `motsu`, `motsu-proc`, `e2e`, `e2e-proc` have their own version per crate
- [x] Cleanup dependencies for the workspace
- [x] Add CI checks for pre-publishing on crates.io
- [x] Fix issues with publishing `motsu` to crates.io:
```
cargo publish -p motsu --target wasm32-unknown-unknown --dry-run
    Updating crates.io index
error: all dependencies must have a version specified when publishing.
dependency `motsu-proc` does not specify a version
Note: The published dependency will use the version from crates.io,
the `path` specification will be removed from the dependency declaration.
```




codecov[bot]: ## [Codecov](https://app.codecov.io/gh/OpenZeppelin/rust-contracts-stylus/pull/280?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OpenZeppelin) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 77.9%. Comparing base [(`42c859f`)](https://app.codecov.io/gh/OpenZeppelin/rust-contracts-stylus/commit/42c859f37d7332fbd78a216a283064a5227f9c68?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OpenZeppelin) to head [(`ef3b344`)](https://app.codecov.io/gh/OpenZeppelin/rust-contracts-stylus/commit/ef3b34460487dfd4c2722af0c6d334d4e0cedb8a?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OpenZeppelin).

<details><summary>Additional details and impacted files</summary>


[see 2 files with indirect coverage changes](https://app.codecov.io/gh/OpenZeppelin/rust-contracts-stylus/pull/280/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=OpenZeppelin)

</details>
netlify[bot]: ### <span aria-hidden="true">👷</span> Deploy Preview for *contracts-stylus* processing.


|  Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 30a788ba123ef0d042b8c3c138af524cbd85e620 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/sites/contracts-stylus/deploys/66e179f43fb51b0008daa738 |

Patch:
diff --git a/.github/workflows/check-publish.yml b/.github/workflows/check-publish.yml
new file mode 100644
index 0000000..67bbb31
--- /dev/null
+++ b/.github/workflows/check-publish.yml
@@ -0,0 +1,42 @@
+name: check-publish
+# This workflow checks that the libraries can be published on crates.io.
+permissions:
+  contents: read
+on:
+  push:
+    branches: [ main ]
+  pull_request:
+concurrency:
+  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+  cancel-in-progress: true
+env:
+  CARGO_TERM_COLOR: always
+jobs:
+  check-publish:
+    name: Check publish on crates.io
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: set up rust
+        uses: dtolnay/rust-toolchain@master
+        id: toolchain
+        with:
+          target: wasm32-unknown-unknown
+          components: rust-src
+          toolchain: nightly-2024-01-01
+
+      - uses: Swatinem/rust-cache@v2
+
+      - name: check motsu-proc
+        run: cargo publish -p motsu-proc --dry-run
+
+      - name: check motsu
+        run: cargo publish -p motsu --dry-run
+
+      - name: check openzeppelin-crypto
+        run: cargo publish -p openzeppelin-crypto --target wasm32-unknown-unknown  --dry-run
+
+        # TODO: https://github.com/OpenZeppelin/rust-contracts-stylus/issues/291
+      # - name: check openzeppelin-stylus
+        # run: cargo publish -p openzeppelin-stylus --target wasm32-unknown-unknown  --dry-run
diff --git a/Cargo.lock b/Cargo.lock
index ebb25bb..591250e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,7 +4,7 @@ version = 3
 
 [[package]]
 name = "access-control-example"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy",
  "alloy-primitives",
@@ -794,7 +794,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
 
 [[package]]
 name = "basic-example"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy-primitives",
  "mini-alloc",
@@ -816,7 +816,7 @@ dependencies = [
 
 [[package]]
 name = "benches"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy",
  "alloy-primitives",
@@ -1262,7 +1262,7 @@ dependencies = [
 
 [[package]]
 name = "cryptography-example"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy",
  "alloy-primitives",
@@ -1514,7 +1514,7 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
 
 [[package]]
 name = "erc20-example"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy",
  "alloy-primitives",
@@ -1529,7 +1529,7 @@ dependencies = [
 
 [[package]]
 name = "erc20-permit-example"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy",
  "alloy-primitives",
@@ -1544,7 +1544,7 @@ dependencies = [
 
 [[package]]
 name = "erc721-consecutive-example"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy",
  "alloy-primitives",
@@ -1561,7 +1561,7 @@ dependencies = [
 
 [[package]]
 name = "erc721-example"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy",
  "alloy-primitives",
@@ -1577,7 +1577,7 @@ dependencies = [
 
 [[package]]
 name = "erc721-metadata-example"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy",
  "alloy-primitives",
@@ -2360,7 +2360,7 @@ checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
 
 [[package]]
 name = "merkle-proofs-example"
-version = "0.0.0"
+version = "0.1.0-rc"
 dependencies = [
  "alloy-primitives",
  "alloy-sol-types",
diff --git a/Cargo.toml b/Cargo.toml
index f196fd1..059b99e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -48,6 +48,7 @@ edition = "2021"
 license = "MIT"
 keywords = ["arbitrum", "ethereum", "stylus"]
 repository = "https://github.com/OpenZeppelin/rust-contracts-stylus"
+version = "0.1.0-rc"
 
 [workspace.lints.rust]
 missing_docs = "warn"
@@ -95,6 +96,14 @@ syn = { version = "2.0.58", features = ["full"] }
 proc-macro2 = "1.0.79"
 quote = "1.0.35"
 
+# members
+openzeppelin-stylus = { path = "contracts" }
+openzeppelin-crypto = { path = "lib/crypto" }
+motsu = { path = "lib/motsu"}
+motsu-proc = { path = "lib/motsu-proc", version = "0.1.0" }
+e2e = { path = "lib/e2e" }
+e2e-proc = {path = "lib/e2e-proc"}
+
 [profile.release]
 codegen-units = 1
 panic = "abort"
diff --git a/benches/Cargo.toml b/benches/Cargo.toml
index 921de2f..f16effd 100644
--- a/benches/Cargo.toml
+++ b/benches/Cargo.toml
@@ -4,15 +4,15 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-stylus = { path = "../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives = { workspace = true, features = ["tiny-keccak"] }
 alloy.workspace = true
 tokio.workspace = true
 eyre.workspace = true
 koba.workspace = true
-e2e = { path = "../lib/e2e" }
+e2e.workspace = true
 serde = "1.0.203"
 keccak-const = "0.2.0"
diff --git a/contracts/Cargo.toml b/contracts/Cargo.toml
index d7c6434..f079ce0 100644
--- a/contracts/Cargo.toml
+++ b/contracts/Cargo.toml
@@ -6,7 +6,7 @@ edition.workspace = true
 keywords.workspace = true
 license.workspace = true
 repository.workspace = true
-version = "0.1.0-rc"
+version.workspace = true
 
 [dependencies]
 alloy-primitives.workspace = true
@@ -18,7 +18,7 @@ keccak-const.workspace = true
 
 [dev-dependencies]
 alloy-primitives = { workspace = true, features = ["arbitrary"] }
-motsu = { path = "../lib/motsu" }
+motsu.workspace = true
 rand.workspace = true
 
 [features]
diff --git a/examples/access-control/Cargo.toml b/examples/access-control/Cargo.toml
index d3fdeef..cf03218 100644
--- a/examples/access-control/Cargo.toml
+++ b/examples/access-control/Cargo.toml
@@ -4,10 +4,10 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-stylus = { path = "../../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives.workspace = true
 stylus-sdk.workspace = true
 stylus-proc.workspace = true
@@ -15,7 +15,7 @@ mini-alloc.workspace = true
 
 [dev-dependencies]
 alloy.workspace = true
-e2e = { path = "../../lib/e2e" }
+e2e.workspace = true
 tokio.workspace = true
 eyre.workspace = true
 
diff --git a/examples/basic/token/Cargo.toml b/examples/basic/token/Cargo.toml
index baee128..077980f 100644
--- a/examples/basic/token/Cargo.toml
+++ b/examples/basic/token/Cargo.toml
@@ -4,10 +4,10 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-stylus = { path = "../../../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives.workspace = true
 stylus-sdk.workspace = true
 stylus-proc.workspace = true
diff --git a/examples/ecdsa/Cargo.toml b/examples/ecdsa/Cargo.toml
index 2d5b3a9..7cac7e5 100644
--- a/examples/ecdsa/Cargo.toml
+++ b/examples/ecdsa/Cargo.toml
@@ -4,10 +4,10 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-stylus = { path = "../../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives.workspace = true
 stylus-sdk.workspace = true
 stylus-proc.workspace = true
@@ -15,7 +15,7 @@ mini-alloc.workspace = true
 
 [dev-dependencies]
 alloy.workspace = true
-e2e = { path = "../../lib/e2e" }
+e2e.workspace = true
 tokio.workspace = true
 eyre.workspace = true
 
diff --git a/examples/erc20-permit/Cargo.toml b/examples/erc20-permit/Cargo.toml
index 29cc342..9008195 100644
--- a/examples/erc20-permit/Cargo.toml
+++ b/examples/erc20-permit/Cargo.toml
@@ -4,10 +4,10 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-stylus = { path = "../../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives = { workspace = true, features = ["tiny-keccak"] }
 stylus-sdk.workspace = true
 stylus-proc.workspace = true
@@ -17,7 +17,7 @@ mini-alloc.workspace = true
 alloy.workspace = true
 eyre.workspace = true
 tokio.workspace = true
-e2e = { path = "../../lib/e2e" }
+e2e.workspace = true
 
 [features]
 e2e = []
diff --git a/examples/erc20/Cargo.toml b/examples/erc20/Cargo.toml
index 1815680..037d3be 100644
--- a/examples/erc20/Cargo.toml
+++ b/examples/erc20/Cargo.toml
@@ -4,10 +4,10 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-stylus = { path = "../../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives.workspace = true
 stylus-sdk.workspace = true
 stylus-proc.workspace = true
@@ -17,7 +17,7 @@ mini-alloc.workspace = true
 alloy.workspace = true
 eyre.workspace = true
 tokio.workspace = true
-e2e = { path = "../../lib/e2e" }
+e2e.workspace = true
 
 [features]
 e2e = []
diff --git a/examples/erc721-consecutive/Cargo.toml b/examples/erc721-consecutive/Cargo.toml
index 2c6eef2..08b7f5b 100644
--- a/examples/erc721-consecutive/Cargo.toml
+++ b/examples/erc721-consecutive/Cargo.toml
@@ -4,10 +4,10 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-stylus = { path = "../../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives.workspace = true
 alloy-sol-types.workspace = true
 stylus-sdk.workspace = true
@@ -16,7 +16,7 @@ mini-alloc.workspace = true
 
 [dev-dependencies]
 alloy.workspace = true
-e2e = { path = "../../lib/e2e" }
+e2e.workspace = true
 tokio.workspace = true
 eyre.workspace = true
 rand.workspace = true
diff --git a/examples/erc721-metadata/Cargo.toml b/examples/erc721-metadata/Cargo.toml
index 1bc6050..62b1f29 100644
--- a/examples/erc721-metadata/Cargo.toml
+++ b/examples/erc721-metadata/Cargo.toml
@@ -4,10 +4,10 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-stylus = { path = "../../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives.workspace = true
 stylus-sdk.workspace = true
 stylus-proc.workspace = true
@@ -15,7 +15,7 @@ mini-alloc.workspace = true
 
 [dev-dependencies]
 alloy.workspace = true
-e2e = { path = "../../lib/e2e" }
+e2e.workspace = true
 tokio.workspace = true
 eyre.workspace = true
 rand.workspace = true
diff --git a/examples/erc721/Cargo.toml b/examples/erc721/Cargo.toml
index 6f70bb7..c11254d 100644
--- a/examples/erc721/Cargo.toml
+++ b/examples/erc721/Cargo.toml
@@ -4,10 +4,10 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-stylus = { path = "../../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives.workspace = true
 stylus-sdk.workspace = true
 stylus-proc.workspace = true
@@ -15,7 +15,7 @@ mini-alloc.workspace = true
 
 [dev-dependencies]
 alloy.workspace = true
-e2e = { path = "../../lib/e2e" }
+e2e.workspace = true
 tokio.workspace = true
 eyre.workspace = true
 rand.workspace = true
diff --git a/examples/merkle-proofs/Cargo.toml b/examples/merkle-proofs/Cargo.toml
index 60931af..e741ccb 100644
--- a/examples/merkle-proofs/Cargo.toml
+++ b/examples/merkle-proofs/Cargo.toml
@@ -4,10 +4,10 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 publish = false
-version = "0.0.0"
+version.workspace = true
 
 [dependencies]
-openzeppelin-crypto = { path = "../../lib/crypto" }
+openzeppelin-crypto.workspace = true
 alloy-primitives.workspace = true
 alloy-sol-types.workspace = true
 stylus-sdk.workspace = true
diff --git a/examples/ownable/Cargo.toml b/examples/ownable/Cargo.toml
index 13ebcbe..6ac97fa 100644
--- a/examples/ownable/Cargo.toml
+++ b/examples/ownable/Cargo.toml
@@ -7,7 +7,7 @@ publish = false
 version = "0.0.0"
 
 [dependencies]
-openzeppelin-stylus = { path = "../../contracts" }
+openzeppelin-stylus.workspace = true
 alloy-primitives.workspace = true
 stylus-sdk.workspace = true
 stylus-proc.workspace = true
@@ -15,7 +15,7 @@ mini-alloc.workspace = true
 
 [dev-dependencies]
 alloy.workspace = true
-e2e = { path = "../../lib/e2e" }
+e2e.workspace = true
 tokio.workspace = true
 eyre.workspace = true
 
diff --git a/lib/crypto/Cargo.toml b/lib/crypto/Cargo.toml
index cf119fc..81a44fd 100644
--- a/lib/crypto/Cargo.toml
+++ b/lib/crypto/Cargo.toml
@@ -6,7 +6,7 @@ edition.workspace = true
 keywords.workspace = true
 license.workspace = true
 repository.workspace = true
-version = "0.1.0-rc"
+version.workspace = true
 
 [dependencies]
 mini-alloc.workspace = true
diff --git a/lib/motsu-proc/Cargo.toml b/lib/motsu-proc/Cargo.toml
index 1e6bbbc..7b172b6 100644
--- a/lib/motsu-proc/Cargo.toml
+++ b/lib/motsu-proc/Cargo.toml
@@ -13,7 +13,7 @@ quote.workspace = true
 syn.workspace = true
 
 [dev-dependencies]
-motsu = { path = "../motsu" }
+motsu.workspace = true
 alloy-primitives.workspace = true
 alloy-sol-types.workspace = true
 stylus-sdk.workspace = true
diff --git a/lib/motsu/Cargo.toml b/lib/motsu/Cargo.toml
index ed66709..57f1f19 100644
--- a/lib/motsu/Cargo.toml
+++ b/lib/motsu/Cargo.toml
@@ -12,7 +12,7 @@ const-hex.workspace = true
 once_cell.workspace = true
 tiny-keccak.workspace = true
 stylus-sdk.workspace = true
-motsu-proc = { path = "../motsu-proc" }
+motsu-proc.workspace = true
 
 [lints]
 workspace = true


Test patch:
diff --git a/lib/e2e/Cargo.toml b/lib/e2e/Cargo.toml
index 6d6cf93..0c48aa1 100644
--- a/lib/e2e/Cargo.toml
+++ b/lib/e2e/Cargo.toml
@@ -15,7 +15,7 @@ eyre.workspace = true
 regex.workspace = true
 once_cell.workspace = true
 koba.workspace = true
-e2e-proc = { path = "../e2e-proc" }
+e2e-proc.workspace = true
 toml = "0.8.13"
 
 [lints]