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
8 changes: 4 additions & 4 deletions chain/vm/src/host/context/tx_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ impl TxCache {

fn load_account_if_necessary(&self, address: &VMAddress) {
let mut accounts_mut = self.accounts.lock().unwrap();
if !accounts_mut.contains_key(address) {
if let Some(blockchain_account) = self.source_ref.load_account(address) {
accounts_mut.insert(address.clone(), blockchain_account);
}
if !accounts_mut.contains_key(address)
&& let Some(blockchain_account) = self.source_ref.load_account(address)
{
accounts_mut.insert(address.clone(), blockchain_account);
}
}

Expand Down
16 changes: 8 additions & 8 deletions chain/vm/src/host/execution/exec_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ where

// legacy async call
// the async call also gets reset
if tx_result.result_status.is_success() {
if let Some(async_data) = pending_calls.async_call {
let (async_result, callback_result) =
commit_async_call_and_callback(async_data, state, runtime);
if tx_result.result_status.is_success()
&& let Some(async_data) = pending_calls.async_call
{
let (async_result, callback_result) =
commit_async_call_and_callback(async_data, state, runtime);

tx_result = merge_async_results(tx_result, async_result);
tx_result = merge_async_results(tx_result, callback_result);
tx_result = merge_async_results(tx_result, async_result);
tx_result = merge_async_results(tx_result, callback_result);

return tx_result;
}
return tx_result;
}

// calling all promises
Expand Down
41 changes: 20 additions & 21 deletions chain/vm/src/host/vm_hooks/vh_handler/vh_blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,23 +410,22 @@ impl<C: VMHooksContext> VMHooksHandler<C> {
let address = VMAddress::from_slice(self.context.m_types_lock().mb_get(address_handle));
let token_id_bytes = self.context.m_types_lock().mb_get(token_id_handle).to_vec();

if let Some(account) = self.context.account_data(&address) {
if let Some(esdt_data) = account.esdt.get_by_identifier(token_id_bytes.as_slice()) {
if let Some(instance) = esdt_data.instances.get_by_nonce(nonce) {
self.set_esdt_data_values(
esdt_data,
instance,
value_handle,
properties_handle,
hash_handle,
name_handle,
attributes_handle,
creator_handle,
royalties_handle,
uris_handle,
)?
}
}
if let Some(account) = self.context.account_data(&address)
&& let Some(esdt_data) = account.esdt.get_by_identifier(token_id_bytes.as_slice())
&& let Some(instance) = esdt_data.instances.get_by_nonce(nonce)
{
self.set_esdt_data_values(
esdt_data,
instance,
value_handle,
properties_handle,
hash_handle,
name_handle,
attributes_handle,
creator_handle,
royalties_handle,
uris_handle,
)?
}

// missing account/token identifier/nonce
Expand Down Expand Up @@ -496,10 +495,10 @@ impl<C: VMHooksContext> VMHooksHandler<C> {

let address = VMAddress::from_slice(self.context.m_types_lock().mb_get(address_handle));
let token_id_bytes = self.context.m_types_lock().mb_get(token_id_handle).to_vec();
if let Some(account) = self.context.account_data(&address) {
if let Some(esdt_data) = account.esdt.get_by_identifier(token_id_bytes.as_slice()) {
return Ok(esdt_data.frozen);
}
if let Some(account) = self.context.account_data(&address)
&& let Some(esdt_data) = account.esdt.get_by_identifier(token_id_bytes.as_slice())
{
return Ok(esdt_data.frozen);
}

// Might be better to return Err and check
Expand Down
6 changes: 2 additions & 4 deletions chain/vm/src/system_sc/system_sc_issue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,12 @@ fn generate_token_identifier_from_ticker(
let new_random = keccak256(&new_random_base);
let new_random_for_ticker = &new_random[..3];

let token_identifier = [
[
ticker,
"-".as_bytes(),
hex::encode(new_random_for_ticker).as_bytes(),
]
.concat();

token_identifier
.concat()
}

#[cfg(test)]
Expand Down
8 changes: 4 additions & 4 deletions contracts/examples/multisig/src/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ pub trait Multisig:
let mut result = MultiValueEncoded::new();
let num_users = self.user_mapper().get_user_count();
for user_id in 1..=num_users {
if self.user_id_to_role(user_id).get() == role {
if let Some(address) = self.user_mapper().get_user_address(user_id) {
result.push(address);
}
if self.user_id_to_role(user_id).get() == role
&& let Some(address) = self.user_mapper().get_user_address(user_id)
{
result.push(address);
}
}
result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ pub trait ForwarderSyncCallModule {
let payment = self.call_value().single_esdt();
let half_gas = self.blockchain().get_gas_left() / 2;

let result = self
.tx()
self.tx()
.to(&to)
.gas(half_gas)
.typed(vault_proxy::VaultProxy)
Expand All @@ -114,9 +113,7 @@ pub trait ForwarderSyncCallModule {
&payment.amount,
)
.returns(ReturnsBackTransfersSingleESDT)
.sync_call();

result
.sync_call()
}

#[allow(deprecated)]
Expand Down
11 changes: 5 additions & 6 deletions data/codec-derive/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,14 @@
}

pub fn sanitize_type_path(mut field: syn::Type) -> proc_macro2::TokenStream {
if let syn::Type::Path(ref mut p) = field {
if p.path
if let syn::Type::Path(ref mut p) = field

Check failure on line 168 in data/codec-derive/src/util.rs

View workflow job for this annotation

GitHub Actions / Gas test (prod wasmer)

`let` expressions in this position are unstable

Check failure on line 168 in data/codec-derive/src/util.rs

View workflow job for this annotation

GitHub Actions / Gas test (experimental wasmer)

`let` expressions in this position are unstable

Check failure on line 168 in data/codec-derive/src/util.rs

View workflow job for this annotation

GitHub Actions / Proxy compare - newly generated vs present in file tree

`let` expressions in this position are unstable

Check failure on line 168 in data/codec-derive/src/util.rs

View workflow job for this annotation

GitHub Actions / Template tool test - released templates

`let` expressions in this position are unstable

Check failure on line 168 in data/codec-derive/src/util.rs

View workflow job for this annotation

GitHub Actions / Plotter tests

`let` expressions in this position are unstable

Check failure on line 168 in data/codec-derive/src/util.rs

View workflow job for this annotation

GitHub Actions / Template tool test - current (unreleased) templates

`let` expressions in this position are unstable

Check failure on line 168 in data/codec-derive/src/util.rs

View workflow job for this annotation

GitHub Actions / Rust VM BLS test

`let` expressions in this position are unstable

Check failure on line 168 in data/codec-derive/src/util.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

`let` expressions in this position are unstable

Check failure on line 168 in data/codec-derive/src/util.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] data/codec-derive/src/util.rs#L168

error[E0658]: `let` expressions in this position are unstable --> data/codec-derive/src/util.rs:168:8 | 168 | if let syn::Type::Path(ref mut p) = field | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
Raw output
data/codec-derive/src/util.rs:168:8:e:error[E0658]: `let` expressions in this position are unstable
   --> data/codec-derive/src/util.rs:168:8
    |
168 |     if let syn::Type::Path(ref mut p) = field
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information


__END__
&& p.path
.to_token_stream()
.to_string()
.contains(BITFLAGS_INTERNAL_PATH)
{
let modified_path = p.path.segments.last_mut().unwrap();
modified_path.ident = syn::Ident::new(PRIMITIVE, modified_path.ident.span());
}
{
let modified_path = p.path.segments.last_mut().unwrap();
modified_path.ident = syn::Ident::new(PRIMITIVE, modified_path.ident.span());
}

quote! (#field)
Expand Down
17 changes: 8 additions & 9 deletions framework/derive/src/generate/convert_to_owned_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
return quote! {
multiversx_sc::types::Box<[#slice_elem]>
};
} else if let syn::Type::Path(syn::TypePath { path, .. }) = &*type_reference.elem {
if let Some(ident) = path.get_ident() {
if *ident == "str" {
// TODO: generalize for all unsized types using Box
return quote! {
multiversx_sc::types::Box<str>
};
}
}
} else if let syn::Type::Path(syn::TypePath { path, .. }) = &*type_reference.elem

Check failure on line 21 in framework/derive/src/generate/convert_to_owned_type.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

`let` expressions in this position are unstable

Check failure on line 21 in framework/derive/src/generate/convert_to_owned_type.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/derive/src/generate/convert_to_owned_type.rs#L21

error[E0658]: `let` expressions in this position are unstable --> framework/derive/src/generate/convert_to_owned_type.rs:21:19 | 21 | } else if let syn::Type::Path(syn::TypePath { path, .. }) = &*type_reference.elem | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
Raw output
framework/derive/src/generate/convert_to_owned_type.rs:21:19:e:error[E0658]: `let` expressions in this position are unstable
  --> framework/derive/src/generate/convert_to_owned_type.rs:21:19
   |
21 |         } else if let syn::Type::Path(syn::TypePath { path, .. }) = &*type_reference.elem
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information


__END__
&& let Some(ident) = path.get_ident()

Check failure on line 22 in framework/derive/src/generate/convert_to_owned_type.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

`let` expressions in this position are unstable

Check failure on line 22 in framework/derive/src/generate/convert_to_owned_type.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/derive/src/generate/convert_to_owned_type.rs#L22

error[E0658]: `let` expressions in this position are unstable --> framework/derive/src/generate/convert_to_owned_type.rs:22:16 | 22 | && let Some(ident) = path.get_ident() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
Raw output
framework/derive/src/generate/convert_to_owned_type.rs:22:16:e:error[E0658]: `let` expressions in this position are unstable
  --> framework/derive/src/generate/convert_to_owned_type.rs:22:16
   |
22 |             && let Some(ident) = path.get_ident()
   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information


__END__
&& *ident == "str"
{
// TODO: generalize for all unsized types using Box
return quote! {
Box<str>
};
}

let referenced_type = &*type_reference.elem;
Expand Down
36 changes: 18 additions & 18 deletions framework/derive/src/generate/restricted_caller_gen.rs
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
use crate::model::{Method, PublicRole};

pub fn generate_only_owner_snippet(m: &Method) -> proc_macro2::TokenStream {
if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role {
if endpoint_metadata.only_owner {
return quote! {
self.blockchain().check_caller_is_owner();
};
}
if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role

Check failure on line 4 in framework/derive/src/generate/restricted_caller_gen.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

`let` expressions in this position are unstable

Check failure on line 4 in framework/derive/src/generate/restricted_caller_gen.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/derive/src/generate/restricted_caller_gen.rs#L4

error[E0658]: `let` expressions in this position are unstable --> framework/derive/src/generate/restricted_caller_gen.rs:4:8 | 4 | if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
Raw output
framework/derive/src/generate/restricted_caller_gen.rs:4:8:e:error[E0658]: `let` expressions in this position are unstable
 --> framework/derive/src/generate/restricted_caller_gen.rs:4:8
  |
4 |     if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information


__END__
&& endpoint_metadata.only_owner
{
return quote! {
self.blockchain().check_caller_is_owner();
};
}
quote! {}
}

pub fn generate_only_admin_snippet(m: &Method) -> proc_macro2::TokenStream {
if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role {
if endpoint_metadata.only_admin {
return quote! {
self.require_caller_is_admin();
};
}
if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role

Check failure on line 15 in framework/derive/src/generate/restricted_caller_gen.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

`let` expressions in this position are unstable

Check failure on line 15 in framework/derive/src/generate/restricted_caller_gen.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/derive/src/generate/restricted_caller_gen.rs#L15

error[E0658]: `let` expressions in this position are unstable --> framework/derive/src/generate/restricted_caller_gen.rs:15:8 | 15 | if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
Raw output
framework/derive/src/generate/restricted_caller_gen.rs:15:8:e:error[E0658]: `let` expressions in this position are unstable
  --> framework/derive/src/generate/restricted_caller_gen.rs:15:8
   |
15 |     if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information


__END__
&& endpoint_metadata.only_admin
{
return quote! {
self.require_caller_is_admin();
};
}
quote! {}
}

pub fn generate_only_user_account_snippet(m: &Method) -> proc_macro2::TokenStream {
if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role {
if endpoint_metadata.only_user_account {
return quote! {
self.blockchain().check_caller_is_user_account();
};
}
if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role

Check failure on line 26 in framework/derive/src/generate/restricted_caller_gen.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

`let` expressions in this position are unstable

Check failure on line 26 in framework/derive/src/generate/restricted_caller_gen.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/derive/src/generate/restricted_caller_gen.rs#L26

error[E0658]: `let` expressions in this position are unstable --> framework/derive/src/generate/restricted_caller_gen.rs:26:8 | 26 | if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
Raw output
framework/derive/src/generate/restricted_caller_gen.rs:26:8:e:error[E0658]: `let` expressions in this position are unstable
  --> framework/derive/src/generate/restricted_caller_gen.rs:26:8
   |
26 |     if let PublicRole::Endpoint(endpoint_metadata) = &m.public_role
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information


__END__
&& endpoint_metadata.only_user_account
{
return quote! {
self.blockchain().check_caller_is_user_account();
};
}
quote! {}
}
12 changes: 6 additions & 6 deletions framework/derive/src/parse/attributes/doc_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
let mut macro_attributes = Vec::new();

for a in attrs {
if let syn::Meta::List(list) = &a.meta {
if list.path.is_ident("derive") {
for token in list.tokens.clone().into_iter() {
if let proc_macro2::TokenTree::Ident(ident) = token {
macro_attributes.push(ident.to_string());
}
if let syn::Meta::List(list) = &a.meta

Check failure on line 52 in framework/derive/src/parse/attributes/doc_attr.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

`let` expressions in this position are unstable

Check failure on line 52 in framework/derive/src/parse/attributes/doc_attr.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/derive/src/parse/attributes/doc_attr.rs#L52

error[E0658]: `let` expressions in this position are unstable --> framework/derive/src/parse/attributes/doc_attr.rs:52:12 | 52 | if let syn::Meta::List(list) = &a.meta | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
Raw output
framework/derive/src/parse/attributes/doc_attr.rs:52:12:e:error[E0658]: `let` expressions in this position are unstable
  --> framework/derive/src/parse/attributes/doc_attr.rs:52:12
   |
52 |         if let syn::Meta::List(list) = &a.meta
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information


__END__
&& list.path.is_ident("derive")
{
for token in list.tokens.clone().into_iter() {
if let proc_macro2::TokenTree::Ident(ident) = token {
macro_attributes.push(ident.to_string());
}
}
}
Expand Down
108 changes: 54 additions & 54 deletions framework/derive/src/parse/attributes/util.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::model::EsdtAttribute;

pub(super) fn is_attribute_with_no_args(attr: &syn::Attribute, name: &str) -> bool {
if let Some(first_seg) = attr.path().segments.first() {
if first_seg.ident == name {
assert!(
attr.meta.require_path_only().is_ok(),
"no arguments allowed for attribute `{name}`"
);
return true;
}
if let Some(first_seg) = attr.path().segments.first()

Check failure on line 4 in framework/derive/src/parse/attributes/util.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

`let` expressions in this position are unstable

Check failure on line 4 in framework/derive/src/parse/attributes/util.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/derive/src/parse/attributes/util.rs#L4

error[E0658]: `let` expressions in this position are unstable --> framework/derive/src/parse/attributes/util.rs:4:8 | 4 | if let Some(first_seg) = attr.path().segments.first() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
Raw output
framework/derive/src/parse/attributes/util.rs:4:8:e:error[E0658]: `let` expressions in this position are unstable
 --> framework/derive/src/parse/attributes/util.rs:4:8
  |
4 |     if let Some(first_seg) = attr.path().segments.first()
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information


__END__
&& first_seg.ident == name
{
assert!(
attr.meta.require_path_only().is_ok(),
"no arguments allowed for attribute `{name}`"
);
return true;
};

false
Expand All @@ -19,61 +19,61 @@
name: &str,
) -> Option<EsdtAttribute> {
let attr_path = &attr.path();
if let Some(first_seg) = attr_path.segments.first() {
if first_seg.ident == name {
let (ticker, ty) = match attr.meta.clone() {
syn::Meta::Path(_) => {
panic!("attribute needs 2 arguments: ticker (string) and type")
}
syn::Meta::List(list) => {
assert!(
!list.tokens.is_empty(),
"argument can not be empty. attribute needs 2 arguments: ticker (string) and type"
);
if let Some(first_seg) = attr_path.segments.first()

Check failure on line 22 in framework/derive/src/parse/attributes/util.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

`let` expressions in this position are unstable

Check failure on line 22 in framework/derive/src/parse/attributes/util.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] framework/derive/src/parse/attributes/util.rs#L22

error[E0658]: `let` expressions in this position are unstable --> framework/derive/src/parse/attributes/util.rs:22:8 | 22 | if let Some(first_seg) = attr_path.segments.first() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
Raw output
framework/derive/src/parse/attributes/util.rs:22:8:e:error[E0658]: `let` expressions in this position are unstable
  --> framework/derive/src/parse/attributes/util.rs:22:8
   |
22 |     if let Some(first_seg) = attr_path.segments.first()
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information


__END__
&& first_seg.ident == name
{
let (ticker, ty) = match attr.meta.clone() {
syn::Meta::Path(_) => {
panic!("attribute needs 2 arguments: ticker (string) and type")
}
syn::Meta::List(list) => {
assert!(
!list.tokens.is_empty(),
"argument can not be empty. attribute needs 2 arguments: ticker (string) and type"
);

let mut iter = list.tokens.into_iter();

let first_literal = match iter.next() {
Some(proc_macro2::TokenTree::Literal(literal)) => literal.to_string(),
_ => {
panic!("expected a string as the first token in the attribute argument")
}
};

let mut iter = list.tokens.into_iter();
let ticker = clean_string(first_literal);

let first_literal = match iter.next() {
Some(proc_macro2::TokenTree::Literal(literal)) => literal.to_string(),
_ => {
panic!("expected a string as the first token in the attribute argument")
let _ = match iter.next() {
Some(proc_macro2::TokenTree::Punct(punct)) => punct,
_ => panic!("expected a punctuation token after the first literal"),
};

let mut ty = proc_macro2::TokenStream::new();

for token in &mut iter {
match token {
proc_macro2::TokenTree::Punct(punct) => {
ty.extend(quote! { #punct });
}
};

let ticker = clean_string(first_literal);

let _ = match iter.next() {
Some(proc_macro2::TokenTree::Punct(punct)) => punct,
_ => panic!("expected a punctuation token after the first literal"),
};

let mut ty = proc_macro2::TokenStream::new();

for token in &mut iter {
match token {
proc_macro2::TokenTree::Punct(punct) => {
ty.extend(quote! { #punct });
}
proc_macro2::TokenTree::Ident(ident) => {
ty.extend(quote! { #ident });
}
_ => break,
proc_macro2::TokenTree::Ident(ident) => {
ty.extend(quote! { #ident });
}
_ => break,
}
}

if ticker.trim().is_empty() {
panic!("ticker field can't be empty");
}

(ticker, ty)
if ticker.trim().is_empty() {
panic!("ticker field can't be empty");
}
syn::Meta::NameValue(_) => panic!("arguments can not be name value"),
};

let esdt_attribute = EsdtAttribute { ticker, ty };
(ticker, ty)
}
syn::Meta::NameValue(_) => panic!("arguments can not be name value"),
};

let esdt_attribute = EsdtAttribute { ticker, ty };

return Some(esdt_attribute);
}
return Some(esdt_attribute);
}

None
Expand Down
Loading
Loading