Skip to content

Commit

Permalink
Merge pull request #59 from OffchainLabs/docs-and-nostd
Browse files Browse the repository at this point in the history
Docs & `#[no_std]` fixes
  • Loading branch information
rachel-bousfield authored Sep 12, 2023
2 parents 74df668 + 5ea9958 commit f3d8d9d
Show file tree
Hide file tree
Showing 31 changed files with 946 additions and 256 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
target/
.config/spellcheck.toml
.config/stylus.dic
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ members = ["stylus-sdk", "stylus-proc"]
resolver = "2"

[workspace.package]
version = "0.2.4"
version = "0.3.0"
edition = "2021"
authors = ["Offchain Labs"]
license = "MIT OR Apache-2.0"
homepage = "https://github.com/OffchainLabs/stylus-sdk-rs"
repository = "https://github.com/OffchainLabs/stylus-sdk-rs"
rust-version = "1.71.0"

[workspace.dependencies]
alloy-primitives = { version = "0.3.1", default-features = false , features = ["native-keccak"] }
alloy-sol-types = { version = "0.3.1", default-features = false }
derivative = { version = "2.2.0", use_core = true }
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"
Expand All @@ -33,4 +35,4 @@ convert_case = "0.6.0"

# members
stylus-sdk = { path = "stylus-sdk" }
stylus-proc = { path = "stylus-proc", version = "0.2.0" }
stylus-proc = { path = "stylus-proc", version = "0.3.0" }
4 changes: 3 additions & 1 deletion stylus-proc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ version.workspace = true
[dependencies]
alloy-primitives.workspace = true
alloy-sol-types.workspace = true
cfg-if.workspace = true
convert_case.workspace = true
lazy_static.workspace = true
proc-macro2.workspace = true
Expand All @@ -25,9 +26,10 @@ quote.workspace = true
[features]
export-abi = []
storage-cache = []
reentrant = []

[package.metadata.docs.rs]
all-features = true
features = ["export-abi", "storage-cache"]

[lib]
proc-macro = true
10 changes: 6 additions & 4 deletions stylus-proc/src/calls/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright 2023, Offchain Labs, Inc.
// For licensing, see https://github.com/OffchainLabs/stylus-sdk-rs/blob/stylus/licenses/COPYRIGHT.md

use crate::types::solidity_type_info;
use convert_case::{Case, Casing};
use proc_macro::TokenStream;
use proc_macro2::Ident;
use quote::quote;
use sha3::{Digest, Keccak256};
use std::borrow::Cow;
use syn_solidity::{FunctionAttribute, Item, Mutability, SolIdent, Visibility};

use crate::types::solidity_type_info;

pub fn sol_interface(input: TokenStream) -> TokenStream {
let input = match syn_solidity::parse(input) {
Ok(f) => f,
Expand Down Expand Up @@ -80,7 +80,7 @@ pub fn sol_interface(input: TokenStream) -> TokenStream {
quote! { stylus_sdk::call::call },
),
Payable => (
quote! { impl stylus_sdk::call::PayableCallContext },
quote! { impl stylus_sdk::call::MutatingCallContext },
quote! { stylus_sdk::call::call },
),
};
Expand Down Expand Up @@ -135,8 +135,10 @@ pub fn sol_interface(input: TokenStream) -> TokenStream {
let selector2 = selector[2];
let selector3 = selector[3];

let rust_name = Ident::new(&name.to_string().to_case(Case::Snake), name.span());

method_impls.extend(quote! {
pub fn #name(&self, context: #context #(, #rust_args)*) ->
pub fn #rust_name(&self, context: #context #(, #rust_args)*) ->
Result<<#return_type as #sol_type>::RustType, stylus_sdk::call::Error>
{
use alloc::vec;
Expand Down
Loading

0 comments on commit f3d8d9d

Please sign in to comment.