casper_network 0.2.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -4
- data/lib/casper_network.rb +62 -8
- data/lib/crypto/00_asymmetric_key.rb +95 -0
- data/lib/crypto/01_ed25519.rb +67 -0
- data/lib/crypto/asymmetric_key.rb +87 -0
- data/lib/crypto/ed25519_key.rb +44 -0
- data/lib/crypto/key_pair.rb +40 -0
- data/lib/crypto/keys.rb +7 -0
- data/lib/crypto/secp256k1_key.rb +0 -0
- data/lib/crypto/test_ed25519_key.rb +44 -0
- data/lib/entity/account.rb +45 -0
- data/lib/entity/action_thresholds.rb +25 -0
- data/lib/entity/associated_key.rb +24 -0
- data/lib/entity/auction_state.rb +1 -0
- data/lib/entity/bid.rb +1 -0
- data/lib/entity/bid_info.rb +1 -0
- data/lib/entity/contract.rb +47 -0
- data/lib/entity/contract_package.rb +41 -0
- data/lib/entity/contract_version.rb +33 -0
- data/lib/entity/delegator.rb +1 -0
- data/lib/entity/deploy.rb +1 -0
- data/lib/entity/deploy_approval.rb +8 -6
- data/lib/entity/deploy_executable.rb +155 -1
- data/lib/entity/deploy_executable_item_internal.rb +27 -0
- data/lib/entity/deploy_executable_transfer.rb +51 -0
- data/lib/entity/deploy_hash.rb +1 -0
- data/lib/entity/deploy_header.rb +18 -15
- data/lib/entity/deploy_info.rb +45 -0
- data/lib/entity/deploy_named_argument.rb +20 -0
- data/lib/entity/deploy_transfer.rb +11 -0
- data/lib/entity/disabled_version.rb +26 -0
- data/lib/entity/era_info.rb +18 -0
- data/lib/entity/era_summary.rb +1 -0
- data/lib/entity/era_validator.rb +1 -0
- data/lib/entity/executable_deploy_item.rb +11 -0
- data/lib/entity/group.rb +25 -0
- data/lib/entity/module_bytes.rb +51 -0
- data/lib/entity/peer.rb +1 -0
- data/lib/entity/seigniorage_allocation.rb +18 -0
- data/lib/entity/stored_contract_by_hash.rb +51 -0
- data/lib/entity/stored_contract_by_name.rb +52 -0
- data/lib/entity/stored_value.rb +57 -0
- data/lib/entity/stored_versioned_contract_by_hash.rb +63 -0
- data/lib/entity/stored_versioned_contract_by_name.rb +63 -0
- data/lib/entity/transfer.rb +66 -0
- data/lib/entity/validator_weight.rb +1 -0
- data/lib/entity/vesting_schedule.rb +22 -0
- data/lib/include.rb +18 -0
- data/lib/rpc/rpc.rb +227 -0
- data/lib/rpc/rpc_client.rb +45 -39
- data/lib/rpc/rpc_error.rb +1 -0
- data/lib/serialization/cl_type_serializer.rb +77 -0
- data/lib/serialization/cl_value_bytes_parsers.rb +498 -0
- data/lib/serialization/cl_value_serializer.rb +260 -0
- data/lib/serialization/deploy_approval_serializer.rb +16 -0
- data/lib/serialization/deploy_executable_serializer.rb +27 -0
- data/lib/serialization/deploy_header_serializer.rb +49 -0
- data/lib/serialization/deploy_named_arg_serializer.rb +20 -0
- data/lib/serialization/deploy_serializer.rb +269 -0
- data/lib/serialization/test.rb +431 -0
- data/lib/types/cl_account_hash.rb +24 -0
- data/lib/types/cl_account_hash_type.rb +22 -0
- data/lib/types/cl_any.rb +25 -0
- data/lib/types/cl_any_type.rb +22 -0
- data/lib/types/cl_bool.rb +32 -0
- data/lib/types/cl_bool_type.rb +35 -0
- data/lib/types/cl_byte_array.rb +25 -0
- data/lib/types/cl_byte_array_type.rb +27 -0
- data/lib/types/cl_i32.rb +26 -0
- data/lib/types/cl_i32_type.rb +26 -0
- data/lib/types/cl_i64.rb +26 -0
- data/lib/types/cl_i64_type.rb +27 -0
- data/lib/types/cl_key.rb +39 -0
- data/lib/types/cl_key_type.rb +27 -0
- data/lib/types/cl_list.rb +25 -0
- data/lib/types/cl_list_type.rb +26 -0
- data/lib/types/cl_map.rb +25 -0
- data/lib/types/cl_map_type.rb +26 -0
- data/lib/types/cl_option.rb +33 -0
- data/lib/types/cl_option_type.rb +52 -0
- data/lib/types/cl_public_key.rb +152 -0
- data/lib/types/cl_public_key_type.rb +26 -0
- data/lib/types/cl_result.rb +25 -0
- data/lib/types/cl_result_type.rb +26 -0
- data/lib/types/cl_string.rb +39 -0
- data/lib/types/cl_string_type.rb +32 -0
- data/lib/types/cl_tuple.rb +151 -0
- data/lib/types/cl_tuple_type.rb +108 -0
- data/lib/types/cl_type.rb +96 -0
- data/lib/types/cl_type_tag.rb +51 -0
- data/lib/types/cl_u128.rb +26 -0
- data/lib/types/cl_u128_type.rb +26 -0
- data/lib/types/cl_u256.rb +26 -0
- data/lib/types/cl_u256_type.rb +26 -0
- data/lib/types/cl_u32.rb +26 -0
- data/lib/types/cl_u32_type.rb +26 -0
- data/lib/types/cl_u512.rb +26 -0
- data/lib/types/cl_u512_type.rb +26 -0
- data/lib/types/cl_u64.rb +26 -0
- data/lib/types/cl_u64_type.rb +27 -0
- data/lib/types/cl_u8.rb +26 -0
- data/lib/types/cl_u8_type.rb +26 -0
- data/lib/types/cl_unit.rb +38 -0
- data/lib/types/cl_unit_type.rb +22 -0
- data/lib/types/cl_uref.rb +120 -0
- data/lib/types/cl_uref_type.rb +46 -0
- data/lib/types/cl_value.rb +11 -0
- data/lib/types/constants.rb +50 -0
- data/lib/types/error.rb +7 -0
- data/lib/utils/base_16.rb +18 -0
- data/lib/utils/byte_utils.rb +107 -0
- data/lib/utils/find_byte_parser_by_cl_type.rb +53 -0
- data/lib/utils/hash_utils.rb +19 -0
- data/lib/utils/hex_utils.rb +12 -0
- data/lib/utils/time_utils.rb +85 -0
- data/lib/utils/utils.rb +2 -0
- data/lib/version.rb +3 -0
- data/spec/a_spec.rb +697 -0
- data/spec/byte_utils_spec.rb +72 -0
- data/spec/cl_public_spec.rb +169 -0
- data/spec/cl_types_spec.rb +715 -0
- data/spec/cl_value_serializer_spec.rb +140 -0
- data/spec/crypto_spec.rb +42 -0
- data/spec/deploy_approval_serializer_spec.rb +26 -0
- data/spec/deploy_executable_serializer_spec.rb +0 -0
- data/spec/deploy_header_serializer_spec.rb +21 -0
- data/spec/deploy_named_arg_serializer_spec.rb +49 -0
- data/spec/deploy_serializer_spec.rb +77 -0
- data/spec/deploy_serializer_test_spec.rb +225 -0
- data/spec/mainnet_spec.rb +8 -8
- data/spec/string_spec.rb +68 -0
- data/spec/testnet_spec.rb +11 -11
- data/spec/time_utils_spec.rb +87 -0
- metadata +130 -2
@@ -0,0 +1,151 @@
|
|
1
|
+
require_relative './cl_tuple_type.rb'
|
2
|
+
require_relative './cl_value.rb'
|
3
|
+
require_relative './error.rb'
|
4
|
+
require_relative '../serialization/cl_value_bytes_parsers.rb'
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
class CLTuple < CLValue
|
9
|
+
include CLValueBytesParsers::CLTupleBytesParser
|
10
|
+
attr_accessor :size, :data
|
11
|
+
# before_filter: get_cl_type
|
12
|
+
def initialize(size, data)
|
13
|
+
super()
|
14
|
+
@size = size
|
15
|
+
@data = data
|
16
|
+
@all_members_are_clvalues = data.all? { |item| item.is_a?(CLValue)}
|
17
|
+
@tuple_name = ""
|
18
|
+
if data.size > size && @all_members_are_clvalues
|
19
|
+
begin
|
20
|
+
raise Error.new("Too many elements!")
|
21
|
+
rescue => e
|
22
|
+
e.err
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if @all_members_are_clvalues && data.size == size
|
27
|
+
@size = size
|
28
|
+
@data = data
|
29
|
+
else
|
30
|
+
begin
|
31
|
+
raise Error.new("Invalid data type(s) provided.")
|
32
|
+
rescue => e
|
33
|
+
e.err
|
34
|
+
end
|
35
|
+
end
|
36
|
+
get_full_type
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_full_type
|
40
|
+
if @all_members_are_clvalues
|
41
|
+
if @data.size == @size
|
42
|
+
if @data.size == 1
|
43
|
+
@cl_type = CLTuple1Type.new
|
44
|
+
@tuple_name = @cl_type.to_string
|
45
|
+
@cl_type.to_string + " (" + @data[0].get_cl_type + ")"
|
46
|
+
elsif @data.size == 2
|
47
|
+
@cl_type = CLTuple2Type.new
|
48
|
+
@tuple_name = @cl_type.to_string
|
49
|
+
@cl_type.to_string + " (" + @data[0].get_cl_type + ", " + @data[1].get_cl_type + ")"
|
50
|
+
elsif @data.size == 3
|
51
|
+
@cl_type = CLTuple3Type.new
|
52
|
+
@tuple_name = @cl_type.to_string
|
53
|
+
@cl_type.to_string + " (" + @data[0].get_cl_type + ", " + @data[1].get_cl_type + ", " + @data[2].get_cl_type + ")"
|
54
|
+
else
|
55
|
+
begin
|
56
|
+
raise Error.new("Tuple is not defined!")
|
57
|
+
rescue => e
|
58
|
+
e.err
|
59
|
+
end
|
60
|
+
end
|
61
|
+
elsif @data.size > size
|
62
|
+
begin
|
63
|
+
raise Error.new("Too many elements!")
|
64
|
+
rescue => e
|
65
|
+
e.err
|
66
|
+
end
|
67
|
+
end
|
68
|
+
else
|
69
|
+
begin
|
70
|
+
raise Error.new("Invalid data type(s) provided.")
|
71
|
+
rescue => e
|
72
|
+
e.err
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_tuple_name
|
78
|
+
@tuple_name
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_value
|
82
|
+
@data
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_size
|
86
|
+
@size
|
87
|
+
end
|
88
|
+
|
89
|
+
def get(index)
|
90
|
+
if index >= @size
|
91
|
+
Error.new("Tuple index out of bounds.")
|
92
|
+
else
|
93
|
+
@data[index]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def set(index, item)
|
98
|
+
if index >= @size
|
99
|
+
Error.new("Tuple index out of bounds.")
|
100
|
+
else
|
101
|
+
data[index] = item
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def push(item)
|
106
|
+
if @data.size < @size
|
107
|
+
@data.push(item)
|
108
|
+
else
|
109
|
+
Error.new("No more space in this tuple!")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
class CLTuple1 < CLTuple
|
117
|
+
|
118
|
+
def initialize(data)
|
119
|
+
super(1, data)
|
120
|
+
end
|
121
|
+
|
122
|
+
def get_cl_type
|
123
|
+
@cl_tuple_type = CLTuple1Type.new
|
124
|
+
@cl_tuple_type.to_string
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class CLTuple2 < CLTuple
|
129
|
+
|
130
|
+
def initialize(data)
|
131
|
+
super(2, data)
|
132
|
+
end
|
133
|
+
|
134
|
+
def get_cl_type
|
135
|
+
@cl_tuple_type = CLTuple2Type.new
|
136
|
+
@cl_tuple_type.to_string
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
class CLTuple3 < CLTuple
|
141
|
+
|
142
|
+
def initialize(data)
|
143
|
+
super(3, data)
|
144
|
+
# puts data
|
145
|
+
end
|
146
|
+
|
147
|
+
def get_cl_type
|
148
|
+
@cl_tuple_type = CLTuple3Type.new
|
149
|
+
@cl_tuple_type.to_string
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require_relative './cl_type.rb'
|
2
|
+
require_relative './constants.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class CLTupleType < CLType
|
6
|
+
def initialize(data = nil)
|
7
|
+
super()
|
8
|
+
@data = data
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_string
|
12
|
+
if @data.size == 1
|
13
|
+
@cl_type = CLTuple1Type.new
|
14
|
+
@cl_type.to_string
|
15
|
+
elsif @data.size == 2
|
16
|
+
@cl_type = CLTuple2Type.new
|
17
|
+
@cl_type.to_string
|
18
|
+
elsif @data.size == 3
|
19
|
+
@cl_type = CLTuple3Type.new
|
20
|
+
@cl_type.to_string
|
21
|
+
else
|
22
|
+
raise "Invalid Type"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_data
|
27
|
+
@data
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_json
|
31
|
+
to_string
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
class CLTuple1Type < CLTupleType
|
37
|
+
def initialize(value = nil)
|
38
|
+
super(value)
|
39
|
+
@value = value
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_string
|
43
|
+
# TUPLE1_ID
|
44
|
+
TAGS.key(18).to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_value
|
48
|
+
@value
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_json
|
52
|
+
to_string
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_bytes
|
56
|
+
[18].pack("C*").unpack1("H*")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class CLTuple2Type < CLTupleType
|
61
|
+
def initialize(value = nil)
|
62
|
+
super(value)
|
63
|
+
@value = value
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_string
|
67
|
+
# TUPLE2_ID
|
68
|
+
TAGS.key(19).to_s
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_value
|
72
|
+
@value
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_json
|
76
|
+
to_string
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_bytes
|
80
|
+
[19].pack("C*").unpack1("H*")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class CLTuple3Type < CLTupleType
|
85
|
+
def initialize(value = nil)
|
86
|
+
super(value)
|
87
|
+
@value = value
|
88
|
+
end
|
89
|
+
|
90
|
+
def to_string
|
91
|
+
# TUPLE3_ID
|
92
|
+
TAGS.key(20).to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
def get_value
|
96
|
+
@value
|
97
|
+
end
|
98
|
+
|
99
|
+
def to_json
|
100
|
+
to_string
|
101
|
+
end
|
102
|
+
|
103
|
+
def to_bytes
|
104
|
+
[20].pack("C*").unpack1("H*")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
# Casper types, i.e. types which can be stored and manipulated by smart contracts.
|
4
|
+
# Provides a description of the underlying data type of a CLValue.
|
5
|
+
class CLType
|
6
|
+
TAGS = {
|
7
|
+
# Boolean primitive.
|
8
|
+
Bool: 0,
|
9
|
+
# Signed 32-bit integer primitive.
|
10
|
+
I32: 1,
|
11
|
+
# Signed 64-bit integer primitive.
|
12
|
+
I64: 2,
|
13
|
+
# Unsigned 8-bit integer primitive.
|
14
|
+
U8: 3,
|
15
|
+
# Unsigned 32-bit integer primitive.
|
16
|
+
U32: 4,
|
17
|
+
# Unsigned 64-bit integer primitive.
|
18
|
+
U64: 5,
|
19
|
+
# Unsigned 128-bit integer primitive.
|
20
|
+
U128: 6,
|
21
|
+
# Unsigned 256-bit integer primitive.
|
22
|
+
U256: 7,
|
23
|
+
# Unsigned 512-bit integer primitive.
|
24
|
+
U512: 8,
|
25
|
+
# Singleton value without additional semantics.
|
26
|
+
Unit: 9,
|
27
|
+
# A string. e.g. "Hello, World!".
|
28
|
+
String: 10,
|
29
|
+
# Global state key.
|
30
|
+
Key: 11,
|
31
|
+
# Unforgeable reference.
|
32
|
+
URef: 12,
|
33
|
+
# Optional value of the given type Option(CLType).
|
34
|
+
Option: 13,
|
35
|
+
# Variable-length list of values of a single `CLType` List(CLType).
|
36
|
+
List: 14,
|
37
|
+
# Fixed-length list of a single `CLType` (normally a Byte).
|
38
|
+
ByteArray: 15,
|
39
|
+
# Co-product of the the given types; one variant meaning success, the other failure.
|
40
|
+
Result: 16,
|
41
|
+
# Key-value association where keys and values have the given types Map(CLType, CLType).
|
42
|
+
Map: 17,
|
43
|
+
# Single value of the given type Tuple1(CLType).
|
44
|
+
Tuple1: 18,
|
45
|
+
# Pair consisting of elements of the given types Tuple2(CLType, CLType).
|
46
|
+
Tuple2: 19,
|
47
|
+
# Triple consisting of elements of the given types Tuple3(CLType, CLType, CLType).
|
48
|
+
Tuple3: 20,
|
49
|
+
# Indicates the type is not known.
|
50
|
+
Any: 21,
|
51
|
+
# A Public key.
|
52
|
+
PublicKey: 22
|
53
|
+
}
|
54
|
+
|
55
|
+
def initialize(value = nil)
|
56
|
+
@value = value
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [String]
|
60
|
+
def to_string
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_json
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_link_to
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_cl_type_tag(key)
|
73
|
+
TAGS[key]
|
74
|
+
end
|
75
|
+
|
76
|
+
# @param [Integer] value
|
77
|
+
# @return [String]
|
78
|
+
def get_tag_key(value)
|
79
|
+
TAGS.key(value).to_s
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [Integer] tag_value
|
83
|
+
def get_tag_value
|
84
|
+
@tag_value
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_tags
|
88
|
+
TAGS
|
89
|
+
end
|
90
|
+
|
91
|
+
# @param [Integer] value
|
92
|
+
# @return [Boolean]
|
93
|
+
def tag_value_isvalid(value)
|
94
|
+
TAGS.has_value?(value)
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
class CLTypeTag
|
3
|
+
TAGS = {
|
4
|
+
Bool: 0,
|
5
|
+
I32: 1,
|
6
|
+
I64: 2,
|
7
|
+
U8: 3,
|
8
|
+
U32: 4,
|
9
|
+
U64: 5,
|
10
|
+
U128: 6,
|
11
|
+
U256: 7,
|
12
|
+
U512: 8,
|
13
|
+
Unit: 9,
|
14
|
+
String: 10,
|
15
|
+
Key: 11,
|
16
|
+
URef: 12,
|
17
|
+
Option: 13,
|
18
|
+
List: 14,
|
19
|
+
ByteArray: 15,
|
20
|
+
Result: 16,
|
21
|
+
Map: 17,
|
22
|
+
Tuple1: 18,
|
23
|
+
Tuple2: 19,
|
24
|
+
Tuple3: 20,
|
25
|
+
Any: 21,
|
26
|
+
PublicKey: 22
|
27
|
+
}
|
28
|
+
|
29
|
+
# Constructor
|
30
|
+
# @param [Integer] tag_value
|
31
|
+
def initialize(tag_value)
|
32
|
+
@tag_value = tag_value
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param [Integer] tag_value
|
36
|
+
# @return [Boolean] true or false
|
37
|
+
def tag_value_isvalid(tag_value)
|
38
|
+
TAGS.has_value?(tag_value)
|
39
|
+
# "#{tag_value} is invalid CLType tag"
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Integer] tag_value
|
43
|
+
def get_tag_value
|
44
|
+
@tag_value
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [String]
|
48
|
+
def get_tag_name
|
49
|
+
TAGS.key(@tag_value).to_s
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_u128_type.rb'
|
2
|
+
require_relative './cl_value.rb'
|
3
|
+
require_relative '../serialization/cl_value_bytes_parsers.rb'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
class CLu128 < CLValue
|
8
|
+
include CLValueBytesParsers::CLU128BytesParser
|
9
|
+
|
10
|
+
def initialize(value)
|
11
|
+
raise "error" unless value.instance_of? Integer
|
12
|
+
super
|
13
|
+
@value = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_cl_type
|
17
|
+
@cl_type = CLU128Type.new
|
18
|
+
@cl_type.to_string
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_value
|
22
|
+
@value
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_type.rb'
|
2
|
+
require_relative './constants.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class CLU128Type < CLType
|
6
|
+
def initialize(value = nil)
|
7
|
+
super(value)
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_string
|
12
|
+
TAGS.key(6).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_value
|
16
|
+
@value
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json
|
20
|
+
to_string
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_bytes
|
24
|
+
[6].pack("C*").unpack1("H*")
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_u256_type.rb'
|
2
|
+
require_relative './cl_value.rb'
|
3
|
+
require_relative '../serialization/cl_value_bytes_parsers.rb'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
class CLu256 < CLValue
|
8
|
+
include CLValueBytesParsers::CLU256BytesParser
|
9
|
+
|
10
|
+
def initialize(value)
|
11
|
+
raise "error" unless value.instance_of? Integer
|
12
|
+
super
|
13
|
+
@value = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_cl_type
|
17
|
+
@cl_type = CLU256Type.new
|
18
|
+
@cl_type.to_string
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_value
|
22
|
+
@value
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_type.rb'
|
2
|
+
require_relative './constants.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class CLU256Type < CLType
|
6
|
+
def initialize(value = nil)
|
7
|
+
super(value)
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_string
|
12
|
+
TAGS.key(7).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_value
|
16
|
+
@value
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json
|
20
|
+
to_string
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_bytes
|
24
|
+
[7].pack("C*").unpack1("H*")
|
25
|
+
end
|
26
|
+
end
|
data/lib/types/cl_u32.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_u32_type.rb'
|
2
|
+
require_relative './cl_value.rb'
|
3
|
+
require_relative '../serialization/cl_value_bytes_parsers.rb'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
class CLu32 < CLValue
|
8
|
+
include CLValueBytesParsers::CLU32BytesParser
|
9
|
+
|
10
|
+
def initialize(value)
|
11
|
+
raise "error" unless value.instance_of? Integer
|
12
|
+
super
|
13
|
+
@value = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_cl_type
|
17
|
+
@cl_type = CLU32Type.new
|
18
|
+
@cl_type.to_string
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_value
|
22
|
+
@value
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_type.rb'
|
2
|
+
require_relative './constants.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class CLU32Type < CLType
|
6
|
+
def initialize(value = nil)
|
7
|
+
super(value)
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_string
|
12
|
+
TAGS.key(4).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_value
|
16
|
+
@value
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json
|
20
|
+
to_string
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_bytes
|
24
|
+
[4].pack("C*").unpack1("H*")
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_u512_type.rb'
|
2
|
+
require_relative './cl_value.rb'
|
3
|
+
require_relative '../serialization/cl_value_bytes_parsers.rb'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
class CLu512 < CLValue
|
8
|
+
include CLValueBytesParsers::CLU512BytesParser
|
9
|
+
|
10
|
+
def initialize(value)
|
11
|
+
raise "error" unless value.instance_of? Integer
|
12
|
+
super
|
13
|
+
@value = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_cl_type
|
17
|
+
@cl_type = CLU512Type.new
|
18
|
+
@cl_type.to_string
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_value
|
22
|
+
@value
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_type.rb'
|
2
|
+
require_relative './constants.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class CLU512Type < CLType
|
6
|
+
def initialize(value = nil)
|
7
|
+
super(value)
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_string
|
12
|
+
TAGS.key(8).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_value
|
16
|
+
@value
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json
|
20
|
+
to_string
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_bytes
|
24
|
+
[8].pack("C*").unpack1("H*")
|
25
|
+
end
|
26
|
+
end
|
data/lib/types/cl_u64.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_u64_type.rb'
|
2
|
+
require_relative './cl_value.rb'
|
3
|
+
require_relative '../serialization/cl_value_bytes_parsers.rb'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
class CLu64 < CLValue
|
8
|
+
include CLValueBytesParsers::CLU64BytesParser
|
9
|
+
|
10
|
+
def initialize(value)
|
11
|
+
raise "error" unless value.instance_of? Integer
|
12
|
+
super
|
13
|
+
@value = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_cl_type
|
17
|
+
@cl_type = CLU64Type.new
|
18
|
+
@cl_type.to_string
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_value
|
22
|
+
@value
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative './cl_type.rb'
|
2
|
+
require_relative './constants.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class CLU64Type < CLType
|
6
|
+
def initialize(value = nil)
|
7
|
+
super(value)
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_string
|
12
|
+
TAGS.key(5).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_value
|
16
|
+
@value
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json
|
20
|
+
to_string
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_bytes
|
24
|
+
[5].pack("C*").unpack1("H*")
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/types/cl_u8.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_u8_type.rb'
|
2
|
+
require_relative './cl_value.rb'
|
3
|
+
require_relative '../serialization/cl_value_bytes_parsers.rb'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
class CLu8 < CLValue
|
8
|
+
include CLValueBytesParsers::CLU8BytesParser
|
9
|
+
|
10
|
+
def initialize(value)
|
11
|
+
raise "error" unless value.instance_of? Integer
|
12
|
+
super
|
13
|
+
@value = value
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_cl_type
|
17
|
+
@cl_type = CLU8Type.new
|
18
|
+
@cl_type.to_string
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_value
|
22
|
+
@value
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|