test_sdk1 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,26 @@
|
|
1
|
+
require_relative './deploy_named_argument.rb'
|
2
|
+
|
3
|
+
module Casper
|
4
|
+
module Entity
|
5
|
+
class DeployExecutableItemInternal
|
6
|
+
attr_accessor :args
|
7
|
+
def initialize(deploy_named_args = [])
|
8
|
+
@args = deploy_named_args
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Array<DeployNamedArg>]
|
12
|
+
def get_args
|
13
|
+
@args
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [DeployNamedArg]
|
17
|
+
def get_arg_by_name(arg)
|
18
|
+
@args.include?(arg) == true ? arg : nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_arg(deploy_named_arg)
|
22
|
+
@args << [deploy_named_arg]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative './deploy_executable_item_internal.rb'
|
2
|
+
|
3
|
+
=begin
|
4
|
+
"Transfer": {
|
5
|
+
"args": [
|
6
|
+
[
|
7
|
+
"amount",
|
8
|
+
{
|
9
|
+
"cl_type": "I32",
|
10
|
+
"bytes": "e8030000",
|
11
|
+
"parsed": 1000
|
12
|
+
}
|
13
|
+
]
|
14
|
+
]
|
15
|
+
}
|
16
|
+
|
17
|
+
=end
|
18
|
+
module Casper
|
19
|
+
module Entity
|
20
|
+
class DeployExecutableTransfer < DeployExecutableItemInternal
|
21
|
+
|
22
|
+
# @param [Array<Array<DeployNamedArgument>>] args
|
23
|
+
def initialize(args)
|
24
|
+
@tag = 5
|
25
|
+
@args = args
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_tag
|
29
|
+
@tag
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_args
|
33
|
+
@args
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_bytes
|
37
|
+
serializer = DeployNamedArgSerializer.new
|
38
|
+
num_of_args = @args.length
|
39
|
+
bytes = Utils::ByteUtils.to_u8(@tag) + Utils::ByteUtils.to_u32(num_of_args)
|
40
|
+
|
41
|
+
@args.each do |arg|
|
42
|
+
arg.each do |item|
|
43
|
+
bytes += serializer.to_bytes(item)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
Utils::ByteUtils.hex_to_byte_array(bytes)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
class DeployHeader
|
4
|
+
|
5
|
+
# @param [Hash] header
|
6
|
+
# @option header [String] :account
|
7
|
+
# @option header [Integer] :timestamp
|
8
|
+
# @option header [Integer] :ttl
|
9
|
+
# @option header [Integer] :gas_price
|
10
|
+
# @option header [String] :body_hash
|
11
|
+
# @option header [Array] :dependencies
|
12
|
+
# @option header [String] :chain_name
|
13
|
+
def initialize(header = {})
|
14
|
+
@account = header[:account]
|
15
|
+
@timestamp = header[:timestamp]
|
16
|
+
@ttl = header[:ttl]
|
17
|
+
@gas_price = header[:gas_price]
|
18
|
+
@body_hash = header[:body_hash]
|
19
|
+
@dependencies = header[:dependencies]
|
20
|
+
@chain_name = header[:chain_name]
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# @return [String] account
|
25
|
+
def get_account
|
26
|
+
@account
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Integer] timestamp
|
30
|
+
def get_timestamp
|
31
|
+
@timestamp
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Integer] ttl
|
35
|
+
def get_ttl
|
36
|
+
@ttl
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Integer] gas_price
|
40
|
+
def get_gas_price
|
41
|
+
@gas_price
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [String] body_hash
|
45
|
+
def get_body_hash
|
46
|
+
@body_hash
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Array] dependencies
|
50
|
+
def get_dependencies
|
51
|
+
@dependencies
|
52
|
+
end
|
53
|
+
|
54
|
+
# @return [String] chain_name
|
55
|
+
def get_chain_name
|
56
|
+
@chain_name
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
class DeployInfo
|
4
|
+
|
5
|
+
# @param [String] hash
|
6
|
+
# @param [Array] transfers
|
7
|
+
# @param [String] from
|
8
|
+
# @param [String] source
|
9
|
+
# @param [String] gas
|
10
|
+
def initialize(hash, transfers, from, source, gas)
|
11
|
+
@hash = hash
|
12
|
+
@transfers = transfers
|
13
|
+
@from = from
|
14
|
+
@source = source
|
15
|
+
@gas = gas
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String] hash
|
19
|
+
def get_hash
|
20
|
+
@hash
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Array] transfers
|
24
|
+
def get_transfers
|
25
|
+
@transfers
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [String] from
|
29
|
+
def get_from
|
30
|
+
@from
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [String] source
|
34
|
+
def get_source
|
35
|
+
@source
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String] gas
|
39
|
+
def get_gas
|
40
|
+
@gas
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
|
4
|
+
# A disabled version of a contract.
|
5
|
+
class DisabledVersion
|
6
|
+
|
7
|
+
# @param [Integer] protocol_version_major
|
8
|
+
# @param [Integer] contract_version
|
9
|
+
def initialize(protocol_version_major, contract_version)
|
10
|
+
@protocol_version_major = protocol_version_major
|
11
|
+
@contract_version = contract_version
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Integer] protocol_version_major
|
15
|
+
def get_protocol_version_major
|
16
|
+
@protocol_version_major
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Integer] contract_version
|
20
|
+
def get_contract_version
|
21
|
+
@contract_version
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
|
4
|
+
# Auction metadata, intended to be recorded each era.
|
5
|
+
class EraInfo
|
6
|
+
|
7
|
+
# @param [Array] seigniorage_allocations rewards list allocated to validators and delegators
|
8
|
+
def initialize(seigniorage_allocations)
|
9
|
+
@seigniorage_allocations = seigniorage_allocations
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Array]
|
13
|
+
def get_seigniorage_allocations
|
14
|
+
@seigniorage_allocations
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
class EraSummary
|
4
|
+
|
5
|
+
# @param [String] block_hash_
|
6
|
+
# @param [Integer] era_id_
|
7
|
+
# @param [StoredValue] stored_value_
|
8
|
+
# @param [String] state_root_hash_
|
9
|
+
# @param [String] merkle_proof_
|
10
|
+
def initialize(block_hash_, era_id_, stored_value_, state_root_hash_, merkle_proof_)
|
11
|
+
@block_hash = block_hash_
|
12
|
+
@era_id = era_id_
|
13
|
+
@stored_value = stored_value_
|
14
|
+
@state_root_hash = state_root_hash_
|
15
|
+
@merkle_proof = merkle_proof_
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String] block_hash
|
19
|
+
def get_block_hash
|
20
|
+
@block_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Integer] era_id
|
24
|
+
def get_era_id
|
25
|
+
@era_id
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [StoredValue] StoredValue
|
29
|
+
def get_stored_value
|
30
|
+
@stored_value
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [String] state_root_hash
|
34
|
+
def get_state_root_hash
|
35
|
+
@state_root_hash
|
36
|
+
end
|
37
|
+
|
38
|
+
# @return [String] merkle_proof
|
39
|
+
def get_merkle_proof
|
40
|
+
@merkle_proof
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
class EraValidator
|
4
|
+
|
5
|
+
# @param [Integer] era_id
|
6
|
+
# @param [Array<ValidatorWeight>] validator_weights
|
7
|
+
def initialize(era_id, validator_weights)
|
8
|
+
@era_id = era_id
|
9
|
+
@validator_weights = validator_weights
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Integer] era_id
|
13
|
+
def get_era_id
|
14
|
+
@era_id
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Array<ValidatorWeight>] validator_weights
|
18
|
+
def get_validator_weights
|
19
|
+
@validator_weights
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/entity/group.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
|
4
|
+
class Group
|
5
|
+
|
6
|
+
# @param [String] group
|
7
|
+
# @param [Array<CLURef>] keys
|
8
|
+
def initialize(group, keys)
|
9
|
+
@group = group
|
10
|
+
@keys = keys
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String] group
|
14
|
+
def get_group
|
15
|
+
@group
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Array<CLURef>] keys
|
19
|
+
def get_keys
|
20
|
+
@keys
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative './deploy_executable_item_internal.rb'
|
2
|
+
|
3
|
+
module Casper
|
4
|
+
module Entity
|
5
|
+
class ModuleBytes < DeployExecutableItemInternal
|
6
|
+
|
7
|
+
# @param [String] module_bytes
|
8
|
+
# @param [Array<Array<DeployNamedArgument>>] args
|
9
|
+
def initialize(module_bytes=nil, args = [])
|
10
|
+
@tag = 0
|
11
|
+
@module_bytes = module_bytes
|
12
|
+
@args = args
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_tag
|
16
|
+
@tag
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_module_bytes
|
20
|
+
@module_bytes
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_args
|
24
|
+
@args
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_arg(deploy_named_arg)
|
28
|
+
@args << [deploy_named_arg]
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_bytes
|
32
|
+
bytes = ""
|
33
|
+
serializer = DeployNamedArgSerializer.new
|
34
|
+
num_of_args = @args.length
|
35
|
+
bytes += Utils::ByteUtils.to_u8(@tag)
|
36
|
+
|
37
|
+
if @module_bytes == ""
|
38
|
+
bytes += Utils::ByteUtils.to_u32(0)
|
39
|
+
end
|
40
|
+
bytes += Utils::ByteUtils.to_u32(num_of_args)
|
41
|
+
@args.each do |arg|
|
42
|
+
arg.each do |item|
|
43
|
+
bytes += serializer.to_bytes(item)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
Utils::ByteUtils.hex_to_byte_array(bytes)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/entity/peer.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
class Peer
|
4
|
+
|
5
|
+
# @param [Hash] peer
|
6
|
+
# @option peer [String] :node_id
|
7
|
+
# @option peer [String] :address
|
8
|
+
def initialize(peer = {})
|
9
|
+
@node_id = peer[:node_id]
|
10
|
+
@address = peer[:address]
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String] node_id
|
14
|
+
def get_node_id
|
15
|
+
@node_id
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String] address
|
19
|
+
def get_address
|
20
|
+
@address
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
|
4
|
+
# Information about seigniorage allocation.
|
5
|
+
class SeigniorageAllocation
|
6
|
+
|
7
|
+
# @param [Array] seigniorage_allocations rewards list allocated to validators and delegators
|
8
|
+
def initialize(seigniorage_allocations)
|
9
|
+
@seigniorage_allocations = seigniorage_allocations
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Array]
|
13
|
+
def get_seigniorage_allocations
|
14
|
+
@seigniorage_allocations
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative './deploy_executable_item_internal.rb'
|
2
|
+
|
3
|
+
module Casper
|
4
|
+
module Entity
|
5
|
+
class StoredContractByHash < DeployExecutableItemInternal
|
6
|
+
|
7
|
+
# @param [String] hash
|
8
|
+
# @param [String] entry_point
|
9
|
+
# @param [Array<Array<DeployNamedArgument>>] args
|
10
|
+
def initialize(hash, entry_point, args)
|
11
|
+
@tag = 1
|
12
|
+
@hash = hash
|
13
|
+
@entry_point = entry_point
|
14
|
+
@args = args
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_tag
|
18
|
+
@tag
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_hash
|
22
|
+
@hash
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_entry_point
|
26
|
+
@entry_point
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_args
|
30
|
+
@args
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_bytes
|
34
|
+
serializer = DeployNamedArgSerializer.new
|
35
|
+
num_of_args = @args.length
|
36
|
+
bytes = Utils::ByteUtils.to_u8(@tag)
|
37
|
+
bytes += @hash
|
38
|
+
bytes += CLValueBytesParsers::CLStringBytesParser.to_bytes(@entry_point)
|
39
|
+
bytes += Utils::ByteUtils.to_u32(num_of_args)
|
40
|
+
@args.each do |arg|
|
41
|
+
arg.each do |item|
|
42
|
+
bytes += serializer.to_bytes(item)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
Utils::ByteUtils.hex_to_byte_array(bytes)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative './deploy_executable_item_internal.rb'
|
2
|
+
|
3
|
+
module Casper
|
4
|
+
module Entity
|
5
|
+
class StoredContractByName < DeployExecutableItemInternal
|
6
|
+
|
7
|
+
# @param [String] name
|
8
|
+
# @param [String] entry_point
|
9
|
+
# @param [Array<Array<DeployNamedArgument>>] args
|
10
|
+
def initialize(name, entry_point, args)
|
11
|
+
@tag = 2
|
12
|
+
@name = name
|
13
|
+
@entry_point = entry_point
|
14
|
+
@args = args
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_tag
|
18
|
+
@tag
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_name
|
22
|
+
@name
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_entry_point
|
26
|
+
@entry_point
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_args
|
30
|
+
@args
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def to_bytes
|
35
|
+
serializer = DeployNamedArgSerializer.new
|
36
|
+
num_of_args = @args.length
|
37
|
+
bytes = Utils::ByteUtils.to_u8(@tag)
|
38
|
+
bytes += CLValueBytesParsers::CLStringBytesParser.to_bytes(@name)
|
39
|
+
bytes += CLValueBytesParsers::CLStringBytesParser.to_bytes(@entry_point)
|
40
|
+
bytes += Utils::ByteUtils.to_u32(num_of_args)
|
41
|
+
@args.each do |arg|
|
42
|
+
arg.each do |item|
|
43
|
+
bytes += serializer.to_bytes(item)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
Utils::ByteUtils.hex_to_byte_array(bytes)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Casper
|
2
|
+
module Entity
|
3
|
+
|
4
|
+
# A class that represents a value stored in global state.
|
5
|
+
class StoredValue
|
6
|
+
|
7
|
+
def initialize(cl_value, account, contract, contract_package, transfer, deploy_info, era_info, bid, withdraw)
|
8
|
+
@cl_value = cl_value
|
9
|
+
@account = account
|
10
|
+
@contract = contract
|
11
|
+
@contract_package = contract_package
|
12
|
+
@transfer = transfer
|
13
|
+
@deploy_info = deploy_info
|
14
|
+
@era_info = era_info
|
15
|
+
@bid = bid
|
16
|
+
@withdraw = withdraw
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_cl_value
|
20
|
+
@cl_value
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_account
|
24
|
+
@account
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_contract
|
28
|
+
@contract
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_contract_package
|
32
|
+
@contract_package
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_transfer
|
36
|
+
@transfer
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_deploy_info
|
40
|
+
@deploy_info
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_era_info
|
44
|
+
@era_info
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_bid
|
48
|
+
@bid
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_withdraw
|
52
|
+
@withdraw
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative './deploy_executable_item_internal.rb'
|
2
|
+
|
3
|
+
module Casper
|
4
|
+
module Entity
|
5
|
+
class StoredVersionedContractByHash < DeployExecutableItemInternal
|
6
|
+
|
7
|
+
# @param [String] hash
|
8
|
+
# @param [Integer] version
|
9
|
+
# @param [String] entry_point
|
10
|
+
# @param [Array<Array<DeployNamedArgument>>] args
|
11
|
+
def initialize(hash, version, entry_point, args)
|
12
|
+
@tag = 3
|
13
|
+
@hash = hash
|
14
|
+
@version = version
|
15
|
+
@entry_point = entry_point
|
16
|
+
@args = args
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_tag
|
20
|
+
@tag
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_hash
|
24
|
+
@hash
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_version
|
28
|
+
@version
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_entry_point
|
32
|
+
@entry_point
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_args
|
36
|
+
@args
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_bytes
|
40
|
+
serializer = DeployNamedArgSerializer.new
|
41
|
+
num_of_args = @args.length
|
42
|
+
bytes = Utils::ByteUtils.to_u8(@tag)
|
43
|
+
bytes += @hash
|
44
|
+
if @version == nil
|
45
|
+
bytes += Utils::ByteUtils.to_u8(0)
|
46
|
+
else
|
47
|
+
bytes += Utils::ByteUtils.to_u8(1)
|
48
|
+
end
|
49
|
+
bytes += CLValueBytesParsers::CLStringBytesParser.to_bytes(@entry_point)
|
50
|
+
bytes += Utils::ByteUtils.to_u32(num_of_args)
|
51
|
+
@args.each do |arg|
|
52
|
+
arg.each do |item|
|
53
|
+
bytes += serializer.to_bytes(item)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
Utils::ByteUtils.hex_to_byte_array(bytes)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|