Skip to content

Commit 57b1e49

Browse files
first working implementation
1 parent 0044bf6 commit 57b1e49

14 files changed

Lines changed: 376 additions & 50 deletions

framework/base/Cargo.toml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@ version = "0.56.0"
44
edition = "2021"
55
rust-version = "1.78"
66

7-
authors = ["Andrei Marinica <andrei.marinica@multiversx.com>", "MultiversX <contact@multiversx.com>"]
7+
authors = [
8+
"Andrei Marinica <andrei.marinica@multiversx.com>",
9+
"MultiversX <contact@multiversx.com>",
10+
]
811
license = "GPL-3.0-only"
912
readme = "README.md"
1013
repository = "https://github.com/multiversx/mx-sdk-rs"
1114
homepage = "https://multiversx.com/"
1215
documentation = "https://docs.multiversx.com/"
1316
description = "MultiversX smart contract API"
1417
keywords = ["multiversx", "wasm", "webassembly", "blockchain", "contract"]
15-
categories = ["no-std", "wasm", "cryptography::cryptocurrencies", "development-tools"]
18+
categories = [
19+
"no-std",
20+
"wasm",
21+
"cryptography::cryptocurrencies",
22+
"development-tools",
23+
]
1624

1725
[package.metadata.docs.rs]
1826
all-features = true
@@ -28,6 +36,10 @@ hex-literal = "=0.4.1"
2836
bitflags = "=2.8.0"
2937
num-traits = { version = "=0.2.19", default-features = false }
3038
unwrap-infallible = "0.1.5"
39+
serde = { version = "1.0.217", features = [
40+
"derive",
41+
"alloc",
42+
], default-features = false }
3143

3244
[dependencies.multiversx-sc-derive]
3345
version = "=0.56.0"

framework/base/src/abi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ pub use contract_abi::*;
1919
pub use endpoint_abi::*;
2020
pub use esdt_attribute_abi::EsdtAttributeAbi;
2121
pub use event_abi::*;
22+
use serde::Deserialize;
2223
pub use type_abi::*;
2324
pub use type_abi_from::*;
2425
pub use type_description::*;
2526
pub use type_description_container::*;
2627

2728
pub type TypeName = alloc::string::String;
2829

29-
#[derive(Clone, Default, Debug, PartialEq, Eq)]
30+
#[derive(Clone, Default, Debug, PartialEq, Eq, Deserialize)]
3031
pub struct TypeNames {
3132
pub abi: alloc::string::String,
3233
pub rust: alloc::string::String,

framework/base/src/abi/build_info_abi.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/// Deisgned to hold metadata of the contract crate.
22
/// Must be instanced inside the smart contract crate to work,
33
/// that is why a `create` associated method would not make sense here.
4-
#[derive(Clone, Default, Debug)]
4+
#[derive(Clone, Default, Debug, PartialEq)]
55
pub struct BuildInfoAbi {
66
pub contract_crate: ContractCrateBuildAbi,
77
pub framework: FrameworkBuildAbi,
88
}
99

10-
#[derive(Clone, Default, Debug)]
10+
#[derive(Clone, Default, Debug, PartialEq)]
1111
pub struct ContractCrateBuildAbi {
1212
pub name: &'static str,
1313
pub version: &'static str,
@@ -16,7 +16,7 @@ pub struct ContractCrateBuildAbi {
1616

1717
/// Gives the multiversx-sc metadata.
1818
/// Should be instanced via the `create` associated function.
19-
#[derive(Clone, Default, Debug)]
19+
#[derive(Clone, Default, Debug, PartialEq)]
2020
pub struct FrameworkBuildAbi {
2121
pub name: &'static str,
2222
pub version: &'static str,

framework/base/src/abi/endpoint_abi.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ use alloc::{
44
string::{String, ToString},
55
vec::Vec,
66
};
7+
use serde::Deserialize;
78

8-
#[derive(Clone, Debug)]
9+
#[derive(Clone, Debug, PartialEq, Deserialize)]
910
pub struct InputAbi {
1011
pub arg_name: String,
1112
pub type_names: TypeNames,
1213
pub multi_arg: bool,
1314
}
1415

15-
#[derive(Clone, Debug)]
16+
#[derive(Clone, Debug, PartialEq, Deserialize)]
1617
pub struct OutputAbi {
1718
pub output_name: String,
1819
pub type_names: TypeNames,
@@ -21,15 +22,15 @@ pub struct OutputAbi {
2122

2223
pub type OutputAbis = Vec<OutputAbi>;
2324

24-
#[derive(Clone, Default, Debug)]
25+
#[derive(Clone, Default, Debug, PartialEq, Deserialize)]
2526
pub enum EndpointMutabilityAbi {
2627
#[default]
2728
Mutable,
2829
Readonly,
2930
Pure,
3031
}
3132

32-
#[derive(Clone, Default, Debug)]
33+
#[derive(Clone, Default, Debug, PartialEq, Deserialize)]
3334
pub enum EndpointTypeAbi {
3435
#[default]
3536
Init,
@@ -38,7 +39,7 @@ pub enum EndpointTypeAbi {
3839
PromisesCallback,
3940
}
4041

41-
#[derive(Clone, Default, Debug)]
42+
#[derive(Clone, Default, Debug, PartialEq, Deserialize)]
4243
pub struct EndpointAbi {
4344
pub docs: Vec<String>,
4445
pub name: String,

framework/base/src/abi/esdt_attribute_abi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use alloc::string::{String, ToString};
2+
use serde::Deserialize;
23

34
use super::{TypeAbi, TypeDescriptionContainerImpl, TypeName};
45

5-
#[derive(Clone, Debug)]
6+
#[derive(Clone, Debug, PartialEq, Deserialize)]
67
pub struct EsdtAttributeAbi {
78
pub ticker: String,
89
pub ty: TypeName,

framework/base/src/abi/event_abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use alloc::{
44
vec::Vec,
55
};
66

7-
#[derive(Clone, Debug)]
7+
#[derive(Clone, Debug, PartialEq, Deserialize)]
88
pub struct EventInputAbi {
99
pub arg_name: String,
1010
pub type_name: TypeName,
1111
pub indexed: bool,
1212
}
1313

14-
#[derive(Clone, Debug)]
14+
#[derive(Clone, Debug, PartialEq, Deserialize)]
1515
pub struct EventAbi {
1616
pub docs: Vec<String>,
1717
pub identifier: String,

framework/base/src/abi/type_description.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ use alloc::{
22
string::{String, ToString},
33
vec::Vec,
44
};
5+
use serde::Deserialize;
56

67
use super::TypeNames;
78

8-
#[derive(Clone, Debug)]
9+
#[derive(Clone, Debug, PartialEq, Deserialize)]
910
pub struct TypeDescription {
1011
pub docs: Vec<String>,
1112
pub names: TypeNames,
@@ -46,7 +47,7 @@ impl TypeDescription {
4647
}
4748
}
4849

49-
#[derive(Clone, Debug)]
50+
#[derive(Clone, Debug, PartialEq, Deserialize)]
5051
pub enum TypeContents {
5152
NotSpecified,
5253
Enum(Vec<EnumVariantDescription>),
@@ -60,7 +61,7 @@ impl TypeContents {
6061
}
6162
}
6263

63-
#[derive(Clone, Debug, PartialEq, Eq)]
64+
#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
6465
pub struct EnumVariantDescription {
6566
pub docs: Vec<String>,
6667
pub name: String,
@@ -87,7 +88,7 @@ impl EnumVariantDescription {
8788
}
8889
}
8990

90-
#[derive(Clone, Debug, PartialEq, Eq)]
91+
#[derive(Clone, Debug, PartialEq, Eq, Deserialize)]
9192
pub struct StructFieldDescription {
9293
pub docs: Vec<String>,
9394
pub name: String,
@@ -110,7 +111,7 @@ impl StructFieldDescription {
110111
/// This makes it easier for humans to read readable in the transaction output.
111112
///
112113
/// It cannot have data fields, only simple enums allowed.
113-
#[derive(Clone, Debug)]
114+
#[derive(Clone, Debug, PartialEq, Deserialize)]
114115
pub struct ExplicitEnumVariantDescription {
115116
pub docs: Vec<String>,
116117
pub name: String,

framework/base/src/abi/type_description_container.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub trait TypeDescriptionContainer {
1717
fn insert_all(&mut self, other: &Self);
1818
}
1919

20-
#[derive(Clone, Default, Debug)]
20+
#[derive(Clone, Default, Debug, PartialEq, Deserialize)]
2121
pub struct TypeDescriptionContainerImpl(pub Vec<(TypeNames, TypeDescription)>);
2222

2323
impl TypeDescriptionContainer for TypeDescriptionContainerImpl {

framework/meta-lib/src/contract/generate_snippets.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod snippet_abi_check;
12
pub mod snippet_crate_gen;
23
pub mod snippet_gen_common;
34
pub mod snippet_gen_main;

0 commit comments

Comments
 (0)