Fabcoin Core  0.16.2
P2P Digital Currency
contractabi.cpp
Go to the documentation of this file.
1 #include <contractabi.h>
2 #include <univalue.h>
3 #include <libethcore/ABI.h>
4 #include <math.h>
5 
6 namespace ContractABI_NS
7 {
8 // Defining json preprocessor functions in order to avoid repetitive code with slight difference
9 #define ReadJsonString(json, param, result) if(json.exists(#param) && json[#param].isStr())\
10  result.param = json[#param].get_str();
11 #define ReadJsonBool(json, param, result) if(json.exists(#param) && json[#param].isBool())\
12  result.param = json[#param].get_bool();
13 #define ReadJsonArray(json, param, result) if(json.exists(#param) && json[#param].isArray())\
14  result = json[#param].get_array();
15 
16 // String parsing functions
17 inline bool startsWithString(const std::string& str, const std::string& s, size_t& pos)
18 {
19  if(pos >= str.length()) return false;
20 
21  size_t length = s.length();
22  bool ret = (str.substr(pos, length) == s);
23  if(ret) pos += length;
24  return ret;
25 }
26 
27 inline std::string startsWithNumber(const std::string& str, size_t& pos)
28 {
29  if(pos >= str.length()) return "";
30 
31  std::stringstream ss;
32  for(size_t i = pos; i < str.size(); i++)
33  {
34  char c = str[i];
35  if(c >= '0' && c <= '9')
36  ss << c;
37  else
38  break;
39  }
40 
41  std::string s = ss.str();
42  pos += s.length();
43  return s;
44 }
45 
46 // define constransts
47 const static int HEX_INSTRUCTION_SIZE = 64;
48 }
49 using namespace ContractABI_NS;
50 
52 {}
53 
54 bool ContractABI::loads(const std::string &json_data)
55 {
56  clean();
57 
58  UniValue json_contract;
59  bool ret = json_contract.read(json_data);
60  if(ret && json_contract.isArray())
61  {
62  // Read all functions from the contract
63  size_t size = json_contract.size();
64  for(size_t i = 0; i < size; i++)
65  {
66  const UniValue& json_function = json_contract[i];
67  FunctionABI function;
68  ReadJsonString(json_function, name, function);
69  ReadJsonString(json_function, type, function);
70  ReadJsonBool(json_function, payable, function);
71  ReadJsonBool(json_function, constant, function);
72  ReadJsonBool(json_function, anonymous, function);
73 
74  UniValue json_inputs;
75  ReadJsonArray(json_function, inputs, json_inputs);
76  for(size_t j = 0; j < json_inputs.size(); j++)
77  {
78  const UniValue& json_param = json_inputs[j];
79  ParameterABI param;
80  ReadJsonString(json_param, name, param);
81  ReadJsonString(json_param, type, param);
82  function.inputs.push_back(param);
83  }
84 
85  UniValue json_outputs;
86  ReadJsonArray(json_function, outputs, json_outputs);
87  for(size_t j = 0; j < json_outputs.size(); j++)
88  {
89  const UniValue& json_param = json_outputs[j];
90  ParameterABI param;
91  ReadJsonString(json_param, name, param);
92  ReadJsonString(json_param, type, param);
93  ReadJsonBool(json_param, indexed, param);
94  function.outputs.push_back(param);
95  }
96 
97  functions.push_back(function);
98  }
99  }
100 
101  FunctionABI function;
102  function.type = "default";
103  function.payable = true;
104  functions.push_back(function);
105 
106  return ret;
107 }
108 
110 {
111  functions.clear();
112 }
113 
114 FunctionABI::FunctionABI(const std::string &_name,
115  const std::string &_type,
116  const std::vector<ParameterABI> &_inputs,
117  const std::vector<ParameterABI> &_outputs,
118  bool _payable, bool _constant, bool _anonymous):
119  name(_name),
120  type(_type),
121  inputs(_inputs),
122  outputs(_outputs),
123  payable(_payable),
124  constant(_constant),
125  anonymous(_anonymous)
126 {}
127 
128 bool FunctionABI::abiIn(const std::vector<std::vector<std::string>> &values, std::string &data, std::vector<ParameterABI::ErrorType>& errors) const
129 {
130  bool ret = inputs.size() == values.size();
131  std::string params;
132  std::map<int, std::string> mapDynamic;
133  for(size_t i = 0; i < inputs.size(); i++)
134  {
135  ret &= inputs[i].abiIn(values[i], params, mapDynamic);
136  errors.push_back(inputs[i].lastError());
137  }
138  if(ret)
139  {
140  processDynamicParams(mapDynamic, params);
141  data = selector() + params;
142  }
143  return ret;
144 }
145 
146 bool FunctionABI::abiOut(const std::string &data, std::vector<std::vector<std::string>> &values, std::vector<ParameterABI::ErrorType>& errors) const
147 {
148  size_t pos = 0;
149  bool ret = true;
150  for(size_t i = 0; i < outputs.size(); i++)
151  {
152  std::vector<std::string> value;
153  ret &= outputs[i].abiOut(data, pos, value);
154  values.push_back(value);
155  errors.push_back(outputs[i].lastError());
156  }
157  return ret;
158 }
159 
160 std::string FunctionABI::selector() const
161 {
162  if(type == "default")
163  {
164  return defaultSelector();
165  }
166 
167  if(type == "constructor" || (type == "event" && anonymous))
168  {
169  return "";
170  }
171 
172  std::stringstream id;
173  id << name;
174  id << "(";
175  if(inputs.size() > 0)
176  {
177  id << inputs[0].type;
178  }
179  for(size_t i = 1; i < inputs.size(); i++)
180  {
181  id << "," << inputs[i].type;
182  }
183  id << ")";
184  std::string sig = id.str();
185 
186  dev::bytes hash;
187  if(type == "event")
188  {
189  hash = dev::sha3(sig).ref().toBytes();
190  }
191  else
192  {
193  hash = dev::sha3(sig).ref().cropped(0, 4).toBytes();
194  }
195 
196  return dev::toHex(hash);
197 }
198 
200 {
201  return "00";
202 }
203 
204 QString FunctionABI::errorMessage(std::vector<ParameterABI::ErrorType> &errors, bool in) const
205 {
206  if(in && errors.size() != inputs.size())
207  return "";
208  if(!in && errors.size() != outputs.size())
209  return "";
210  const std::vector<ParameterABI>& params = in ? inputs : outputs;
211 
212  QStringList messages;
213  messages.append(QObject::tr("ABI parsing error:"));
214  for(size_t i = 0; i < errors.size(); i++)
215  {
216  ParameterABI::ErrorType err = errors[i];
217  if(err == ParameterABI::Ok) continue;
218  const ParameterABI& param = params[i];
219  QString _type = QString::fromStdString(param.type);
220  QString _name = QString::fromStdString(param.name);
221 
222  switch (err) {
224  messages.append(QObject::tr("Unsupported type %1 %2.").arg(_type, _name));
225  break;
227  messages.append(QObject::tr("Error encoding parameter %1 %2.").arg(_type, _name));
228  break;
230  messages.append(QObject::tr("Error decoding parameter %1 %2.").arg(_type, _name));
231  break;
232  default:
233  break;
234  }
235  }
236  return messages.join('\n');
237 }
238 
239 void FunctionABI::processDynamicParams(const std::map<int, std::string> &mapDynamic, std::string &data) const
240 {
241  for(auto i = mapDynamic.begin(); i != mapDynamic.end(); i++)
242  {
243  int pos = i->first;
244  std::string value = i->second;
245  dev::u256 inRef = data.size() / 2;
247  std::string strRef = dev::toHex(rawRef);
248  data.replace(pos, strRef.size(), strRef);
249  data += value;
250  }
251 }
252 
253 ParameterABI::ParameterABI(const std::string &_name, const std::string &_type, bool _indexed):
254  name(_name),
255  type(_type),
256  indexed(_indexed),
257  m_lastError(ParameterABI::Ok)
258 {}
259 
261 {}
262 
263 bool ParameterABI::abiInBasic(ParameterType::Type abiType, std::string value, std::string &data) const
264 {
265  switch (abiType) {
267  {
268  value = dev::asString(dev::fromHex(value));
269  dev::string32 inData = dev::eth::toString32(value);
270  data += dev::toHex(inData);
271  }
272  break;
274  value = value == "false" ? "0" : "1";
277  {
278  dev::u256 inData(value.c_str());
280  data += dev::toHex(rawData);
281  }
282  break;
284  {
285  dev::u160 inData = dev::fromBigEndian<dev::u160, dev::bytes>(dev::fromHex(value));
287  data += dev::toHex(rawData);
288  }
289  break;
290  default:
292  return false;
293  }
294  return true;
295 }
296 
297 bool ParameterABI::abiOutBasic(ParameterType::Type abiType, const std::string &data, size_t &pos, std::string &value) const
298 {
299  switch (abiType) {
301  {
302  dev::bytes rawData = dev::fromHex(data.substr(pos, HEX_INSTRUCTION_SIZE));
303  dev::bytesConstRef o(&rawData);
305  value = dev::toHex(outData);
306  }
307  break;
309  {
310  dev::bytes rawData = dev::fromHex(data.substr(pos, HEX_INSTRUCTION_SIZE));
311  dev::bytesConstRef o(&rawData);
313  value = outData.str();
314  }
315  break;
317  {
318  dev::bytes rawData = dev::fromHex(data.substr(pos, HEX_INSTRUCTION_SIZE));
319  dev::bytesConstRef o(&rawData);
321  value = outData.str();
322  }
323  break;
325  {
326  dev::bytes rawData = dev::fromHex(data.substr(pos, HEX_INSTRUCTION_SIZE));
327  dev::bytesConstRef o(&rawData);
329  dev::bytes rawAddress(20);
330  dev::toBigEndian<dev::u160, dev::bytes>(outData, rawAddress);
331  value = dev::toHex(rawAddress);
332  }
333  break;
335  {
336  dev::bytes rawData = dev::fromHex(data.substr(pos, HEX_INSTRUCTION_SIZE));
337  dev::bytesConstRef o(&rawData);
339  value = outData == 0 ? "false" : "true";
340  }
341  break;
342  default:
344  return false;
345  }
346 
347  pos += HEX_INSTRUCTION_SIZE;
348 
349  return true;
350 }
351 
352 void ParameterABI::addDynamic(const std::string &paramData, std::string &data, std::map<int, std::string> &mapDynamic) const
353 {
354  int key = data.size();
355  data += paramData.substr(0, HEX_INSTRUCTION_SIZE);
356  mapDynamic[key] = paramData.substr(HEX_INSTRUCTION_SIZE);
357 }
358 
359 bool ParameterABI::abiIn(const std::vector<std::string> &value, std::string &data, std::map<int, std::string>& mapDynamic) const
360 {
361  try
362  {
363  m_lastError = Ok;
364  ParameterType::Type abiType = decodeType().type();
365  if(decodeType().isDynamic() && !decodeType().isList())
366  {
367  // Dynamic basic type (list of bytes or chars)
368  std::string _value = value[0];
369  switch (abiType) {
371  _value = dev::asString(dev::fromHex(_value));
373  {
374  std::string paramData = dev::toHex(dev::eth::ABISerialiser<std::string>::serialise(_value));
375  addDynamic(paramData, data, mapDynamic);
376  }
377  break;
378  default:
380  return false;
381  }
382  }
383  else if(!decodeType().isDynamic() && !decodeType().isList())
384  {
385  // Static basic type
386  abiInBasic(abiType, value[0], data);
387  }
388  else if(decodeType().isDynamic() && decodeType().isList())
389  {
390  // Dynamic list type
391  std::string paramData;
392  abiInBasic(ParameterType::abi_uint, "32", paramData);
393  size_t length = value.size();
394  abiInBasic(ParameterType::abi_uint, std::to_string(length), paramData);
395  for(size_t i = 0; i < length; i++)
396  {
397  abiInBasic(abiType, value[i], paramData);
398  }
399  addDynamic(paramData, data, mapDynamic);
400  }
401  else if(!decodeType().isDynamic() && decodeType().isList())
402  {
403  // Static list type
404  size_t length = decodeType().length();
405  for(size_t i = 0; i < length; i++)
406  {
407  abiInBasic(abiType, value[i], data);
408  }
409  }
410  else
411  {
412  // Unknown type
414  return false;
415  }
416  }
417  catch(...)
418  {
420  return false;
421  }
422 
423  return true;
424 }
425 
426 bool ParameterABI::abiOut(const std::string &data, size_t &pos, std::vector<std::string> &value) const
427 {
428  try
429  {
430  m_lastError = Ok;
431  ParameterType::Type abiType = decodeType().type();
432  if(decodeType().isDynamic() && !decodeType().isList())
433  {
434  // Dynamic basic type
435  switch (abiType) {
437  {
438  dev::bytes rawData = dev::fromHex(data.substr(pos));
439  dev::bytesConstRef o(&rawData);
441  value.push_back(dev::toHex(outData));
442  }
443  break;
445  {
446  dev::bytes rawData = dev::fromHex(data.substr(pos));
447  dev::bytesConstRef o(&rawData);
449  }
450  break;
451  default:
453  return false;
454  }
455 
456  pos += HEX_INSTRUCTION_SIZE;
457  }
458  else if(!decodeType().isDynamic() && !decodeType().isList())
459  {
460  // Static basic type
461  std::string paramValue;
462  if(abiOutBasic(abiType, data, pos, paramValue))
463  {
464  value.push_back(paramValue);
465  }
466  else
467  {
468  return false;
469  }
470  }
471  else if(decodeType().isDynamic() && decodeType().isList())
472  {
473  // Dynamic list type
474 
475  // Get position
476  std::string paramValue;
477  if(!abiOutBasic(ParameterType::abi_uint, data, pos, paramValue))
478  return false;
479  size_t oldPos = pos;
480  pos = std::atoi(paramValue.c_str()) * 2;
481 
482  // Get length
483  if(!abiOutBasic(ParameterType::abi_uint, data, pos, paramValue))
484  return false;
485  size_t length = std::atoi(paramValue.c_str());
486 
487  // Read list
488  for(size_t i = 0; i < length; i++)
489  {
490  if(!abiOutBasic(abiType, data, pos, paramValue))
491  return false;
492  value.push_back(paramValue);
493  }
494 
495  // Restore position
496  pos = oldPos;
497  }
498  else if(!decodeType().isDynamic() && decodeType().isList())
499  {
500  // Static list type
501  std::string paramValue;
502  size_t length = decodeType().length();
503 
504  // Read list
505  for(size_t i = 0; i < length; i++)
506  {
507  if(!abiOutBasic(abiType, data, pos, paramValue))
508  return false;
509  value.push_back(paramValue);
510  }
511  }
512  else
513  {
514  // Unknown type
516  return false;
517  }
518  }
519  catch(...)
520  {
522  return false;
523  }
524 
525  return true;
526 }
527 
528 bool ParameterABI::getRegularExpession(const ParameterType &paramType, QRegularExpression &regEx)
529 {
530  bool ret = false;
531  switch (paramType.type()) {
533  {
534  if(paramType.isDynamic())
535  {
536  regEx.setPattern(paternBytes);
537  }
538  else
539  {
540  // Expression to check the number of bytes encoded in hex (1-32)
541  regEx.setPattern(QString(paternBytes32).arg(paramType.totalBytes()*2));
542  }
543  ret = true;
544  break;
545  }
547  {
548  regEx.setPattern(paternUint);
549  ret = true;
550  break;
551  }
553  {
554  regEx.setPattern(paternInt);
555  ret = true;
556  break;
557  }
559  {
560  regEx.setPattern(paternAddress);
561  ret = true;
562  break;
563  }
565  {
566  regEx.setPattern(paternBool);
567  ret = true;
568  break;
569  }
570  default:
571  {
572  ret = false;
573  break;
574  }
575  }
576  return ret;
577 }
578 
580 {
581  return m_lastError;
582 }
583 
585 {
586  if(m_decodeType.canonical() != type)
587  {
589  }
590 
591  return m_decodeType;
592 }
593 
594 ParameterType::ParameterType(const std::string& _type):
595  m_type(ParameterType::abi_none),
596  m_whole(0),
597  m_decimal(0),
598  m_length(0),
599  m_isList(false),
600  m_valid(false)
601 {
602  determine(_type);
603 }
604 
605 bool ParameterType::determine(const std::string &_type)
606 {
607  clean();
608 
609  // Initialize variables
610  bool ret = true;
611  size_t pos = 0;
612 
613  // Set string representation
614  m_canonical = _type;
615 
616  // Determine the basic type
617  if(startsWithString(m_canonical, "uint", pos))
618  {
619  m_type = abi_uint;
620  }
621  else if(startsWithString(m_canonical, "int", pos))
622  {
623  m_type = abi_int;
624  }
625  else if(startsWithString(m_canonical, "address", pos))
626  {
628  }
629  else if(startsWithString(m_canonical, "bool", pos))
630  {
631  m_type = abi_bool;
632  }
633  else if(startsWithString(m_canonical, "fixed", pos))
634  {
635  m_type = abi_fixed;
636  }
637  else if(startsWithString(m_canonical, "ufixed", pos))
638  {
639  m_type = abi_ufixed;
640  }
641  else if(startsWithString(m_canonical, "bytes", pos))
642  {
643  m_type = abi_bytes;
644  }
645  else if(startsWithString(m_canonical, "string", pos))
646  {
647  m_type = abi_string;
648  }
649 
650  // Provide more informations about the type
651  if(m_type != abi_none)
652  {
653  // Get the whole number part size
654  std::string strWhole = startsWithNumber(m_canonical, pos);
655  if(!strWhole.empty())
656  {
657  m_whole = atoi(strWhole.c_str());
658  }
659 
660  // Get the decimal number part size
661  if(startsWithString(m_canonical, "x", pos))
662  {
663  std::string strDecimal = startsWithNumber(m_canonical, pos);
664  if(!strDecimal.empty())
665  {
666  m_decimal = atoi(strDecimal.c_str());
667  }
668  else
669  {
670  ret = false;
671  }
672  }
673 
674  // Get information for list type
675  if(startsWithString(m_canonical, "[", pos))
676  {
677  std::string strLength = startsWithNumber(m_canonical, pos);
678  if(!strLength.empty())
679  {
680  m_length = atoi(strLength.c_str());
681  }
682  if(startsWithString(m_canonical, "]", pos))
683  {
684  m_isList = true;
685  }
686  else
687  {
688  ret = false;
689  }
690  }
691  }
692 
693  // Return if not parsed correctly
694  if(m_canonical.length() != pos || ret == false)
695  ret = false;
696 
697  // Check the validity of the types
698  if(ret && (m_type == abi_int || m_type == abi_uint))
699  {
700  ret &= m_whole > 0;
701  ret &= m_whole <= 256;
702  ret &= m_whole % 8 == 0;
703  ret &= m_decimal == 0;
704  }
705 
706  if(ret && m_type == abi_address)
707  {
708  ret &= m_whole == 0;
709  ret &= m_decimal == 0;
710  if(ret) m_whole = 160;
711  }
712 
713  if(ret && (m_type == abi_fixed || m_type == abi_ufixed))
714  {
715  ret &= m_whole > 0;
716  ret &= m_decimal > 0;
717  ret &= (m_whole + m_decimal) <= 256;
718  }
719 
720  if(ret && m_type == abi_bytes)
721  {
722  m_whole *= 8;
723  ret &= m_whole > 0;
724  ret &= m_whole <= 256;
725  ret &= m_decimal == 0;
726  }
727 
728  if(ret && m_type == abi_function)
729  {
730  ret &= m_whole == 0;
731  ret &= m_decimal == 0;
732  if(ret) m_whole = 196;
733  }
734 
735  if(ret && m_type == abi_string)
736  {
737  ret &= m_whole == 0;
738  ret &= m_decimal == 0;
739  }
740 
741  m_valid = ret;
742 
743  return m_valid;
744 }
745 
747 {
748  return m_whole;
749 }
750 
752 {
753  return m_decimal;
754 }
755 
757 {
758  return ceil((m_whole + m_decimal) / 8.0);
759 }
760 
761 size_t ParameterType::length() const
762 {
763  return m_length;
764 }
765 
767 {
768  return m_isList;
769 }
770 
772 {
773  // Type bytes is dynamic when the count of bytes is not known.
774  // Type string is always dynamic.
775  if((m_type == abi_bytes && totalBytes() == 0) || m_type == abi_string)
776  {
777  return true;
778  }
779 
780  // Type list is dynamic when the count of elements is not known.
781  if(m_isList)
782  return m_length == 0;
783 
784  return false;
785 }
786 
788 {
789  return m_valid;
790 }
791 
792 const std::string& ParameterType::canonical() const
793 {
794  return m_canonical;
795 }
796 
798 {
800  m_whole = 0;
801  m_decimal = 0;
802  m_length = 0;
803  m_isList = false;
804  m_valid = false;
805  m_canonical = "";
806 }
807 
809 {
810  return m_type;
811 }
string32 toString32(std::string const &_s)
Definition: ABI.h:34
std::vector< ParameterABI > outputs
Definition: contractabi.h:183
size_t size() const
Definition: univalue.h:70
void clean()
clean Set the value to the defaults
std::string toHex(T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
Definition: CommonData.h:54
bool startsWithString(const std::string &str, const std::string &s, size_t &pos)
Definition: contractabi.cpp:17
size_t decimalBits() const
decimalBits Get the number of bits for the decimal part of the number
size_t length() const
length Length of the list, applicable for list only
#define ReadJsonString(json, param, result)
Definition: contractabi.cpp:9
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void >> s256
Definition: Common.h:126
std::string startsWithNumber(const std::string &str, size_t &pos)
Definition: contractabi.cpp:27
bool read(const char *raw, size_t len)
ErrorType m_lastError
Definition: contractabi.h:156
bool determine(const std::string &_type)
determine Determine the type from the string
bool isList() const
isList Is the data type list
bool anonymous
Definition: contractabi.h:186
bool isArray() const
Definition: univalue.h:85
#define c(i)
QString errorMessage(std::vector< ParameterABI::ErrorType > &errors, bool in) const
#define paternBytes32
Definition: contractabi.h:15
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
Definition: CommonData.cpp:141
bool isDynamic() const
isDynamic Check if the type is dynamic.
bool abiIn(const std::vector< std::vector< std::string >> &values, std::string &data, std::vector< ParameterABI::ErrorType > &errors) const
#define paternAddress
Definition: contractabi.h:11
std::string m_canonical
Definition: contractabi.h:121
bool abiOut(const std::string &data, size_t &pos, std::vector< std::string > &value) const
void addDynamic(const std::string &paramData, std::string &data, std::map< int, std::string > &mapDynamic) const
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 160, 160, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u160
Definition: Common.h:127
#define paternUint
Definition: contractabi.h:9
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
Definition: CommonData.cpp:99
ErrorType lastError() const
bool abiOut(const std::string &data, std::vector< std::vector< std::string >> &values, std::vector< ParameterABI::ErrorType > &errors) const
std::string name
Definition: contractabi.h:142
The ParameterType class Decode the api parameter type, provide more informations about the data type ...
Definition: contractabi.h:22
#define paternBool
Definition: contractabi.h:12
const char * name
Definition: rest.cpp:36
std::string type
Definition: contractabi.h:181
std::vector< ParameterABI > inputs
Definition: contractabi.h:182
ParameterABI(const std::string &_name="", const std::string &_type="", bool _indexed=false)
std::vector< byte > bytes
Definition: Common.h:75
bool abiInBasic(ParameterType::Type abiType, std::string value, std::string &data) const
std::string name
Definition: contractabi.h:180
#define paternBytes
Definition: contractabi.h:14
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
bool abiOutBasic(ParameterType::Type abiType, const std::string &data, size_t &pos, std::string &value) const
const std::string & canonical() const
canonical Get the canonical type
std::string type
Definition: contractabi.h:143
void processDynamicParams(const std::map< int, std::string > &mapDynamic, std::string &data) const
const ParameterType & decodeType() const
std::array< char, 32 > string32
Definition: Common.h:150
bool abiIn(const std::vector< std::string > &value, std::string &data, std::map< int, std::string > &mapDynamic) const
s256 u2s(u256 _u)
Interprets _u as a two&#39;s complement signed number and returns the resulting s256. ...
Definition: Common.h:159
#define ReadJsonBool(json, param, result)
Definition: contractabi.cpp:11
static bool getRegularExpession(const ParameterType &paramType, QRegularExpression &regEx)
ParameterType m_decodeType
Definition: contractabi.h:155
PlatformStyle::TableColorType type
Definition: rpcconsole.cpp:61
uint8_t const size_t const size
Definition: sha3.h:20
size_t wholeBits() const
wholeBits Get the number of bits for the whole part of the number
ParameterType(const std::string &_type="")
ParameterType Constructor.
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
Definition: SHA3.cpp:214
bool loads(const std::string &json_data)
Definition: contractabi.cpp:54
size_t totalBytes() const
totalBytes Get the total size in bytes
static std::string defaultSelector()
#define paternInt
Definition: contractabi.h:10
Type
The Type enum ABI data types.
Definition: contractabi.h:28
bool isValid() const
isValid Check if the type is valid
#define ReadJsonArray(json, param, result)
Definition: contractabi.cpp:13
FunctionABI(const std::string &_name="", const std::string &_type="function", const std::vector< ParameterABI > &_inputs=std::vector< ParameterABI >(), const std::vector< ParameterABI > &_outputs=std::vector< ParameterABI >(), bool _payable=false, bool _constant=false, bool _anonymous=false)
uint8_t const * data
Definition: sha3.h:19
std::string asString(bytes const &_b)
Converts byte array to a string containing the same (binary) data.
Definition: CommonData.h:79
Type type() const
type Get the type
int atoi(const std::string &str)
std::string selector() const