test_sdk1 1.0.0
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 +7 -0
- data/CONTRIBUTING.md +1 -0
- data/LICENSE +201 -0
- data/README.md +147 -0
- data/SECURITY.md +12 -0
- 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 +36 -0
- data/lib/entity/bid.rb +24 -0
- data/lib/entity/bid_info.rb +51 -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 +37 -0
- data/lib/entity/deploy.rb +44 -0
- data/lib/entity/deploy_approval.rb +24 -0
- data/lib/entity/deploy_executable.rb +162 -0
- data/lib/entity/deploy_executable_item_internal.rb +26 -0
- data/lib/entity/deploy_executable_transfer.rb +50 -0
- data/lib/entity/deploy_hash.rb +16 -0
- data/lib/entity/deploy_header.rb +60 -0
- data/lib/entity/deploy_info.rb +44 -0
- data/lib/entity/deploy_named_argument.rb +19 -0
- data/lib/entity/deploy_transfer.rb +10 -0
- data/lib/entity/disabled_version.rb +26 -0
- data/lib/entity/era_info.rb +18 -0
- data/lib/entity/era_summary.rb +44 -0
- data/lib/entity/era_validator.rb +23 -0
- data/lib/entity/executable_deploy_item.rb +11 -0
- data/lib/entity/group.rb +25 -0
- data/lib/entity/module_bytes.rb +50 -0
- data/lib/entity/peer.rb +25 -0
- data/lib/entity/seigniorage_allocation.rb +18 -0
- data/lib/entity/stored_contract_by_hash.rb +50 -0
- data/lib/entity/stored_contract_by_name.rb +50 -0
- data/lib/entity/stored_value.rb +57 -0
- data/lib/entity/stored_versioned_contract_by_hash.rb +61 -0
- data/lib/entity/stored_versioned_contract_by_name.rb +61 -0
- data/lib/entity/transfer.rb +65 -0
- data/lib/entity/validator_weight.rb +23 -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 +233 -0
- data/lib/rpc/rpc_error.rb +79 -0
- data/lib/serialization/cl_type_serializer.rb +76 -0
- data/lib/serialization/cl_value_bytes_parsers.rb +498 -0
- data/lib/serialization/cl_value_serializer.rb +259 -0
- data/lib/serialization/deploy_approval_serializer.rb +15 -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 +19 -0
- data/lib/serialization/deploy_serializer.rb +268 -0
- data/lib/serialization/test.rb +431 -0
- data/lib/test_sdk1.rb +289 -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 +94 -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 +10 -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/client_spec.rb +25 -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 +452 -0
- data/spec/spec_helper.rb +100 -0
- data/spec/string_spec.rb +68 -0
- data/spec/testnet_spec.rb +498 -0
- data/spec/time_utils_spec.rb +87 -0
- metadata +198 -0
@@ -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,94 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class CLType
|
4
|
+
TAGS = {
|
5
|
+
# Boolean primitive.
|
6
|
+
Bool: 0,
|
7
|
+
# Signed 32-bit integer primitive.
|
8
|
+
I32: 1,
|
9
|
+
# Signed 64-bit integer primitive.
|
10
|
+
I64: 2,
|
11
|
+
# Unsigned 8-bit integer primitive.
|
12
|
+
U8: 3,
|
13
|
+
# Unsigned 32-bit integer primitive.
|
14
|
+
U32: 4,
|
15
|
+
# Unsigned 64-bit integer primitive.
|
16
|
+
U64: 5,
|
17
|
+
# Unsigned 128-bit integer primitive.
|
18
|
+
U128: 6,
|
19
|
+
# Unsigned 256-bit integer primitive.
|
20
|
+
U256: 7,
|
21
|
+
# Unsigned 512-bit integer primitive.
|
22
|
+
U512: 8,
|
23
|
+
# Singleton value without additional semantics.
|
24
|
+
Unit: 9,
|
25
|
+
# A string. e.g. "Hello, World!".
|
26
|
+
String: 10,
|
27
|
+
# Global state key.
|
28
|
+
Key: 11,
|
29
|
+
# Unforgeable reference.
|
30
|
+
URef: 12,
|
31
|
+
# Optional value of the given type Option(CLType).
|
32
|
+
Option: 13,
|
33
|
+
# Variable-length list of values of a single `CLType` List(CLType).
|
34
|
+
List: 14,
|
35
|
+
# Fixed-length list of a single `CLType` (normally a Byte).
|
36
|
+
ByteArray: 15,
|
37
|
+
# Co-product of the the given types; one variant meaning success, the other failure.
|
38
|
+
Result: 16,
|
39
|
+
# Key-value association where keys and values have the given types Map(CLType, CLType).
|
40
|
+
Map: 17,
|
41
|
+
# Single value of the given type Tuple1(CLType).
|
42
|
+
Tuple1: 18,
|
43
|
+
# Pair consisting of elements of the given types Tuple2(CLType, CLType).
|
44
|
+
Tuple2: 19,
|
45
|
+
# Triple consisting of elements of the given types Tuple3(CLType, CLType, CLType).
|
46
|
+
Tuple3: 20,
|
47
|
+
# Indicates the type is not known.
|
48
|
+
Any: 21,
|
49
|
+
# A Public key.
|
50
|
+
PublicKey: 22
|
51
|
+
}
|
52
|
+
|
53
|
+
def initialize(value = nil)
|
54
|
+
@value = value
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [String]
|
58
|
+
def to_string
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def to_json
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_link_to
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_cl_type_tag(key)
|
71
|
+
TAGS[key]
|
72
|
+
end
|
73
|
+
|
74
|
+
# @param [Integer] value
|
75
|
+
# @return [String]
|
76
|
+
def get_tag_key(value)
|
77
|
+
TAGS.key(value).to_s
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [Integer] tag_value
|
81
|
+
def get_tag_value
|
82
|
+
@tag_value
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_tags
|
86
|
+
TAGS
|
87
|
+
end
|
88
|
+
|
89
|
+
# @param [Integer] value
|
90
|
+
# @return [Boolean]
|
91
|
+
def tag_value_isvalid(value)
|
92
|
+
TAGS.has_value?(value)
|
93
|
+
end
|
94
|
+
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
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative './cl_type.rb'
|
2
|
+
require_relative './constants.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class CLU8Type < CLType
|
6
|
+
def initialize(value = nil)
|
7
|
+
super(value)
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_string
|
12
|
+
TAGS.key(3).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
|
+
[3].pack("C*").unpack1("H*")
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative './cl_unit_type.rb'
|
2
|
+
require_relative './cl_value.rb'
|
3
|
+
require_relative '../serialization/cl_value_bytes_parsers.rb'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
class CLUnit < CLValue
|
8
|
+
# include CLValueBytesParsers::CLUnitBytesParser
|
9
|
+
|
10
|
+
def initialize(value = nil)
|
11
|
+
raise "error" unless value.nil?
|
12
|
+
super
|
13
|
+
@value = nil
|
14
|
+
@h = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_cl_type
|
18
|
+
@cl_type = CLUnitType.new
|
19
|
+
@cl_type.to_string
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_value
|
23
|
+
@value
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_json
|
27
|
+
{"bytes": "", "cl_type": get_cl_type}.to_json
|
28
|
+
end
|
29
|
+
|
30
|
+
def from_json(json)
|
31
|
+
JSON.parse(json)
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_hash
|
35
|
+
@h = {"bytes"=> "", "cl_type"=>get_cl_type}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative './cl_type.rb'
|
2
|
+
require_relative './constants.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class CLUnitType < CLType
|
6
|
+
def initialize(value = nil)
|
7
|
+
super(value)
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_string
|
12
|
+
TAGS.key(9).to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_value
|
16
|
+
@value
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_bytes
|
20
|
+
[9].pack("C*").unpack1("H*")
|
21
|
+
end
|
22
|
+
end
|