-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathsc_utils.h
More file actions
50 lines (43 loc) · 1.25 KB
/
sc_utils.h
File metadata and controls
50 lines (43 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <cstdint>
#include <map>
#include <string>
enum ValueType {
SINT8,
UINT8,
SINT16,
UINT16,
SINT32,
UINT32,
SINT64,
UINT64,
UNKNOWN
};
struct ContractPrimitive {
std::string type;
std::string value;
unsigned long long getSize();
unsigned long long getAlignment();
void dumpIntoBuffer(void *buffer);
static ContractPrimitive fromBuffer(const uint8_t *buffer, std::string type);
void print(int indent = 0);
std::string toString();
bool isEmpty();
};
// A struct respersent data type in a contract, it can be primitive, object or array of object
struct ContractObject {
std::map<int, ContractPrimitive> primitive;
std::map<int, ContractObject> object;
bool isArray;
int arrayMaxSize;
int numberOfFields;
unsigned long long getSize();
unsigned long long getAlignment();
void dumpIntoBuffer(void *buffer);
static ContractObject fromBuffer(void *buffer, const char* format, bool isRoot = false);
void print(int indent = 1, bool hasNext = false);
std::string toString();
bool isEmpty();
};
void dumpContractToCSV(const char* input, uint32_t contractId, const char* output);
ContractObject buildContractObject(const char *format, bool isRoot);