Skip to content

Commit

Permalink
Merge pull request #686 from eosnetworkfoundation/backport-partial-st…
Browse files Browse the repository at this point in the history
…darray-smart-contracts-support

[3.2] Merge pull request #10727 from EOSIO/keke_epe948
  • Loading branch information
oschwaldp-oci authored Jul 18, 2022
2 parents 29e6a1a + f784beb commit b5132e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions libraries/chain/abi_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ namespace eosio { namespace chain {
return ends_with(type, "[]");
}

bool abi_serializer::is_szarray(const string_view& type)const {
auto pos1 = type.find_last_of('[');
auto pos2 = type.find_last_of(']');
if(pos1 == string_view::npos || pos2 == string_view::npos) return false;
auto pos = pos1 + 1;
if(pos == pos2) return false;
while(pos < pos2) {
if( ! (type[pos] >= '0' && type[pos] <= '9') ) return false;
++pos;
}
return true;
}

bool abi_serializer::is_optional(const string_view& type)const {
return ends_with(type, "?");
}
Expand All @@ -227,6 +240,8 @@ namespace eosio { namespace chain {
std::string_view abi_serializer::fundamental_type(const std::string_view& type)const {
if( is_array(type) ) {
return type.substr(0, type.size()-2);
} else if (is_szarray (type) ){
return type.substr(0, type.find_last_of('['));
} else if ( is_optional(type) ) {
return type.substr(0, type.size()-1);
} else {
Expand Down
1 change: 1 addition & 0 deletions libraries/chain/include/eosio/chain/abi_serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct abi_serializer {
/// @return string_view of `t` or internal string type
std::string_view resolve_type(const std::string_view& t)const;
bool is_array(const std::string_view& type)const;
bool is_szarray(const std::string_view& type)const;
bool is_optional(const std::string_view& type)const;
bool is_type( const std::string_view& type, const yield_function_t& yield )const;
[[deprecated("use the overload with yield_function_t[=create_yield_function(max_serialization_time)]")]]
Expand Down

0 comments on commit b5132e5

Please sign in to comment.