-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1777 from multiversx/vm-core
chain-core crate
- Loading branch information
Showing
61 changed files
with
1,123 additions
and
1,051 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
use super::*; | ||
|
||
use alloc::vec::Vec; | ||
use multiversx_chain_core::types::{ | ||
Address, BoxedBytes, CodeMetadata, EsdtLocalRole, EsdtTokenType, H256, | ||
}; | ||
|
||
impl TypeAbiFrom<Self> for H256 {} | ||
|
||
impl TypeAbi for H256 { | ||
type Unmanaged = Self; | ||
|
||
fn type_name() -> TypeName { | ||
"H256".into() | ||
} | ||
|
||
fn type_name_rust() -> TypeName { | ||
"H256".into() | ||
} | ||
} | ||
|
||
impl TypeAbiFrom<Self> for Address {} | ||
|
||
impl TypeAbi for Address { | ||
type Unmanaged = Self; | ||
|
||
fn type_name() -> TypeName { | ||
"Address".into() | ||
} | ||
|
||
fn type_name_rust() -> TypeName { | ||
"Address".into() | ||
} | ||
} | ||
|
||
impl TypeAbiFrom<Self> for BoxedBytes {} | ||
|
||
impl TypeAbi for BoxedBytes { | ||
type Unmanaged = Self; | ||
|
||
fn type_name() -> TypeName { | ||
"bytes".into() | ||
} | ||
|
||
fn type_name_rust() -> TypeName { | ||
"BoxedBytes".into() | ||
} | ||
} | ||
|
||
impl TypeAbiFrom<Self> for CodeMetadata {} | ||
impl TypeAbi for CodeMetadata { | ||
type Unmanaged = Self; | ||
|
||
fn type_name() -> TypeName { | ||
"CodeMetadata".into() | ||
} | ||
|
||
fn type_name_rust() -> TypeName { | ||
"CodeMetadata".into() | ||
} | ||
} | ||
|
||
impl TypeAbiFrom<Self> for EsdtTokenType {} | ||
impl TypeAbiFrom<&Self> for EsdtTokenType {} | ||
|
||
// implementation originally geneated via #[type_abi] attribute | ||
impl TypeAbi for EsdtTokenType { | ||
type Unmanaged = Self; | ||
fn type_name() -> TypeName { | ||
"EsdtTokenType".into() | ||
} | ||
|
||
#[allow(clippy::vec_init_then_push)] | ||
fn provide_type_descriptions<TDC: TypeDescriptionContainer>(accumulator: &mut TDC) { | ||
let type_names = Self::type_names(); | ||
if !accumulator.contains_type(&type_names.abi) { | ||
accumulator.reserve_type_name(type_names.clone()); | ||
let mut variant_descriptions = Vec::new(); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"Fungible", | ||
0usize, | ||
Vec::new(), | ||
)); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"NonFungible", | ||
1usize, | ||
Vec::new(), | ||
)); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"SemiFungible", | ||
2usize, | ||
Vec::new(), | ||
)); | ||
variant_descriptions.push(EnumVariantDescription::new(&[], "Meta", 3usize, Vec::new())); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"Invalid", | ||
4usize, | ||
Vec::new(), | ||
)); | ||
accumulator.insert( | ||
type_names.clone(), | ||
TypeDescription::new( | ||
&[], | ||
type_names, | ||
TypeContents::Enum(variant_descriptions), | ||
&[ | ||
"TopDecode", | ||
"TopEncode", | ||
"NestedDecode", | ||
"NestedEncode", | ||
"Clone", | ||
"PartialEq", | ||
"Eq", | ||
"Debug", | ||
"ManagedVecItem", | ||
], | ||
), | ||
); | ||
} | ||
} | ||
} | ||
|
||
impl TypeAbiFrom<Self> for EsdtLocalRole {} | ||
impl TypeAbiFrom<&Self> for EsdtLocalRole {} | ||
|
||
// implementation originally geneated via #[type_abi] attribute | ||
impl TypeAbi for EsdtLocalRole { | ||
type Unmanaged = Self; | ||
|
||
fn type_name() -> TypeName { | ||
"EsdtLocalRole".into() | ||
} | ||
|
||
#[allow(clippy::vec_init_then_push)] | ||
fn provide_type_descriptions<TDC: TypeDescriptionContainer>(accumulator: &mut TDC) { | ||
let type_names = Self::type_names(); | ||
if !accumulator.contains_type(&type_names.abi) { | ||
accumulator.reserve_type_name(type_names.clone()); | ||
let mut variant_descriptions = Vec::new(); | ||
variant_descriptions.push(EnumVariantDescription::new(&[], "None", 0usize, Vec::new())); | ||
variant_descriptions.push(EnumVariantDescription::new(&[], "Mint", 1usize, Vec::new())); | ||
variant_descriptions.push(EnumVariantDescription::new(&[], "Burn", 2usize, Vec::new())); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"NftCreate", | ||
3usize, | ||
Vec::new(), | ||
)); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"NftAddQuantity", | ||
4usize, | ||
Vec::new(), | ||
)); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"NftBurn", | ||
5usize, | ||
Vec::new(), | ||
)); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"NftAddUri", | ||
6usize, | ||
Vec::new(), | ||
)); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"NftUpdateAttributes", | ||
7usize, | ||
Vec::new(), | ||
)); | ||
variant_descriptions.push(EnumVariantDescription::new( | ||
&[], | ||
"Transfer", | ||
8usize, | ||
Vec::new(), | ||
)); | ||
accumulator.insert( | ||
type_names.clone(), | ||
TypeDescription::new( | ||
&[], | ||
type_names, | ||
TypeContents::Enum(variant_descriptions), | ||
&[ | ||
"TopDecode", | ||
"TopEncode", | ||
"NestedDecode", | ||
"NestedEncode", | ||
"Clone", | ||
"PartialEq", | ||
"Eq", | ||
"Debug", | ||
"Copy", | ||
], | ||
), | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use multiversx_chain_core::types::CodeMetadata; | ||
|
||
use super::{hex_util, FormatByteReceiver, SCBinary, SCDisplay, SCLowerHex}; | ||
|
||
impl SCDisplay for CodeMetadata { | ||
fn fmt<F: FormatByteReceiver>(&self, f: &mut F) { | ||
self.for_each_string_token(|token| f.append_bytes(token.as_bytes())) | ||
} | ||
} | ||
|
||
impl SCLowerHex for CodeMetadata { | ||
fn fmt<F: FormatByteReceiver>(&self, f: &mut F) { | ||
let num = self.bits().to_be_bytes(); | ||
f.append_bytes(&hex_util::byte_to_hex_digits(num[0])[..]); | ||
f.append_bytes(&hex_util::byte_to_hex_digits(num[1])[..]); | ||
} | ||
} | ||
|
||
impl SCBinary for CodeMetadata { | ||
fn fmt<F: FormatByteReceiver>(&self, f: &mut F) { | ||
let num = self.bits().to_be_bytes(); | ||
f.append_bytes(&hex_util::byte_to_binary_digits(num[0])[..]); | ||
f.append_bytes(&hex_util::byte_to_binary_digits(num[1])[..]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.