Skip to content
Draft
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
32 changes: 30 additions & 2 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
resolver = "3"

members = [
"data/abi",
"data/abi-derive-common",
"data/abi-derive",
"data/codec",
"data/codec-derive",
"data/human-readable",
Expand Down
2 changes: 1 addition & 1 deletion chain/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ serde = { version = "1.0", features = ["derive"], optional = true }
hex = { version = "0.4", optional = true }

[dependencies.multiversx-sc-codec]
version = "=0.25.0"
version = "0.25.0"
path = "../../data/codec"
features = ["derive"]
2 changes: 1 addition & 1 deletion contracts/examples/multisig/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "multisig"
version = "1.0.0"
version = "0.0.0"
authors = ["Andrei Marinica <andrei.marinica@multiversx.com>"]
edition = "2024"
publish = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"version": "0.0.0",
"gitVersion": "<git version here>"
},
"abi": {
"name": "multiversx-sc-abi",
"version": "0.25.0"
},
"framework": {
"name": "multiversx-sc",
"version": "0.65.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"version": "0.0.0",
"gitVersion": "<git version here>"
},
"abi": {
"name": "multiversx-sc-abi",
"version": "0.25.0"
},
"framework": {
"name": "multiversx-sc",
"version": "0.65.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
{
"step": "scCall",
"id": "0",
"txId": "0",
"tx": {
"from": "0x66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925",
"to": "0x0000000000000000fb1397e8225ea85e0f0e6e8c7b126d0016ccbde0e667151e",
Expand Down Expand Up @@ -85,7 +85,7 @@
},
{
"step": "scQuery",
"id": "1",
"txId": "1",
"tx": {
"to": "0x0000000000000000fb1397e8225ea85e0f0e6e8c7b126d0016ccbde0e667151e",
"function": "getTotalValue",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"version": "0.0.0",
"gitVersion": "<git version here>"
},
"abi": {
"name": "multiversx-sc-abi",
"version": "0.25.0"
},
"framework": {
"name": "multiversx-sc",
"version": "0.65.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"version": "0.0.0",
"gitVersion": "<git version here>"
},
"abi": {
"name": "multiversx-sc-abi",
"version": "0.25.0"
},
"framework": {
"name": "multiversx-sc",
"version": "0.65.0"
Expand Down
28 changes: 28 additions & 0 deletions data/abi-derive-common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "multiversx-sc-abi-derive-common"
version = "0.25.0"
edition = "2024"
publish = false

authors = [
"Andrei Marinica <andrei.marinica@multiversx.com>",
"MultiversX <contact@multiversx.com>",
]
license = "GPL-3.0-only"
readme = "README.md"
repository = "https://github.com/multiversx/mx-sdk-rs"
homepage = "https://multiversx.com/"
documentation = "https://docs.multiversx.com/"
description = "MultiversX ABI common functionality for derive macros"
keywords = ["multiversx", "wasm", "webassembly", "blockchain", "contract"]
categories = [
"no-std",
"wasm",
"cryptography::cryptocurrencies",
"development-tools",
]

[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0", features = ["full", "extra-traits"] }
10 changes: 10 additions & 0 deletions data/abi-derive-common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# multiversx-sc-abi-derive-common

Common logic for the `TypeAbi` derive macros in MultiversX smart contracts.

This is a regular library crate (not a proc-macro crate) that contains the shared implementation used by both `multiversx-sc-abi-derive` and `multiversx-sc-derive`.

## Contents

- **`type_abi_derive`** — generates `TypeAbi` trait implementations for structs and enums
- **`parse`** — attribute parsing utilities (doc comments, macro attributes)
13 changes: 13 additions & 0 deletions data/abi-derive-common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// ensure we don't run out of macro stack
#![recursion_limit = "1024"]
// TODO: remove once minimum version is 1.87+
#![allow(unknown_lints)]
#![allow(clippy::collapsible_if)]
#![allow(clippy::manual_is_multiple_of)]

/// Common code for derive macros, shared between `data/abi-derive` and `framework/derive`.
pub mod parse;

mod type_abi_derive;

pub use type_abi_derive::{TypeAbiImportCrate, type_abi_derive, type_abi_full};
1 change: 1 addition & 0 deletions data/abi-derive-common/src/parse.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod attributes;
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
use quote::ToTokens;

use super::{attr_names::*, util::*};

/// unlike the others, this is standard Rust,
/// all doc comments get automatically transformed into "doc" attributes
static ATTR_DOC: &str = "doc";

/// Doc comments are actually syntactic sugar for doc attributes,
/// so extracting doc comments means parsing "doc" attributes.
pub fn extract_doc(attrs: &[syn::Attribute]) -> Vec<String> {
const ATTR_DOC: &str = "doc";

attrs
.iter()
.filter(|attr| {
Expand Down Expand Up @@ -79,25 +75,3 @@ fn remove_backslashes(input: &str) -> String {
.replace("\\\"", "\"")
.replace("\\'", "'")
}

pub struct OutputNameAttribute {
pub output_name: String,
}

impl OutputNameAttribute {
pub fn parse(attr: &syn::Attribute) -> Option<Self> {
is_attr_one_string_arg(attr, ATTR_OUTPUT_NAME).map(|arg_str| OutputNameAttribute {
output_name: arg_str,
})
}
}

pub struct TitleAttribute {
pub title: String,
}

impl TitleAttribute {
pub fn parse(attr: &syn::Attribute) -> Option<Self> {
is_attr_one_string_arg(attr, ATTR_TITLE).map(|arg_str| TitleAttribute { title: arg_str })
}
}
Loading
Loading