Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor proc macros #164

Merged
merged 8 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 285 additions & 51 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,30 @@ repository = "https://github.com/OffchainLabs/stylus-sdk-rs"
rust-version = "1.71.0"

[workspace.dependencies]
alloy-primitives = { version = "=0.7.7", default-features = false , features = ["native-keccak"] }
alloy-sol-types = { version = "=0.7.7", default-features = false }
alloy-primitives = { version = "=0.8.3", default-features = false , features = ["native-keccak"] }
alloy-sol-types = { version = "=0.8.3", default-features = false }
cfg-if = "1.0.0"
derivative = { version = "2.2.0", features = ["use_core"] }
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
keccak-const = "0.2.0"
lazy_static = "1.4.0"
lazy_static = "1.5.0"
sha3 = "0.10.8"

# proc macros
syn = { version = "1.0", features = ["full"] }
paste = "1.0.14"
quote = "1.0"
regex = "1.9.1"
proc-macro2 = "1.0"
syn-solidity = "0.7.6"
convert_case = "0.6.0"
paste = "1.0.15"
proc-macro-error = "1.0"
proc-macro2 = "1.0"
quote = "1.0"
regex = "1.10.6"
syn = { version = "2.0", features = ["full", "visit-mut"] }
syn-solidity = "0.8.3"

# proc macro dev
pretty_assertions = "1.4.1"
prettyplease = "0.2.22"

trybuild = "1.0"

# members
mini-alloc = { path = "mini-alloc" }
Expand Down
13 changes: 11 additions & 2 deletions stylus-proc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ alloy-sol-types.workspace = true
cfg-if.workspace = true
convert_case.workspace = true
lazy_static.workspace = true
proc-macro-error.workspace = true
proc-macro2.workspace = true
quote.workspace = true
regex.workspace = true
sha3.workspace = true
syn.workspace = true
syn-solidity.workspace = true
quote.workspace = true
trybuild.workspace = true

[dev-dependencies]
paste.workspace = true
pretty_assertions.workspace = true
prettyplease.workspace = true
stylus-sdk.workspace = true

[features]
export-abi = []
default = []
export-abi = ["stylus-sdk/export-abi"]
reentrant = []

[package.metadata.docs.rs]
Expand Down
38 changes: 38 additions & 0 deletions stylus-proc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# stylus_proc

Procedural Macros for Stylus SDK

## Macro usage

Macro usage should be done through the [stylus-sdk] crate. Refer to the
[documentation] for additional information and examples.

## Development Considerations

### Error handling

The [proc_macro_error] crate is used for error handling to ensure consistency
across rust versions and for convenience.

Prefer [emit_error!] where possible to allow multiple errors to be displayed to
the user. If an error is reached where compilation must be halted, [abort!]
should be used instead.

### Testing

Procedural macro implementations should be written in a way that returns AST
data structures from the [syn] crate before converting them to
[proc_macro::TokenStream]. This allows the implementation to be unit tested
within its module to ensure the generated code is as expected.

The [trybuild] crate is used to write test cases which should fail to compile.
These tests are located in [tests/fail/] directory.

[stylus-sdk]: https://crates.io/crates/stylus-sdk
[documentation]: https://crates.io/crates/stylus-proc
[proc_macro_error]: https://crates.io/crates/proc-macro-error
[emit_error!]: https://docs.rs/proc-macro-error/latest/proc_macro_error/macro.emit_error.html
[abort!]: https://docs.rs/proc-macro-error/latest/proc_macro_error/macro.abort.html
[syn]: https://crates.io/crates/syn
[proc_macro::TokenStream]: https://docs.rs/proc-macro/latest/proc_macro/struct.TokenStream.html
[trybuild]: https://crates.io/crates/trybuild
18 changes: 0 additions & 18 deletions stylus-proc/src/abi.rs

This file was deleted.

253 changes: 0 additions & 253 deletions stylus-proc/src/calls/mod.rs

This file was deleted.

Loading
Loading