casper_network 1.0.0 → 1.0.2

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +275 -17
  3. data/lib/casper_network.rb +22 -8
  4. data/lib/crypto/00_asymmetric_key.rb +1 -1
  5. data/lib/crypto/asymmetric_key.rb +1 -1
  6. data/lib/entity/account.rb +1 -1
  7. data/lib/entity/action_thresholds.rb +2 -2
  8. data/lib/entity/associated_key.rb +1 -1
  9. data/lib/entity/auction_state.rb +57 -8
  10. data/lib/entity/bid.rb +2 -1
  11. data/lib/entity/bid_info.rb +2 -1
  12. data/lib/entity/block.rb +39 -0
  13. data/lib/entity/block_body.rb +35 -0
  14. data/lib/entity/block_header.rb +81 -0
  15. data/lib/entity/block_info.rb +56 -0
  16. data/lib/entity/block_proof.rb +24 -0
  17. data/lib/entity/contract.rb +1 -1
  18. data/lib/entity/delegator.rb +1 -0
  19. data/lib/entity/deploy.rb +1 -0
  20. data/lib/entity/deploy_approval.rb +1 -0
  21. data/lib/entity/deploy_executable.rb +4 -3
  22. data/lib/entity/deploy_executable_item_internal.rb +1 -0
  23. data/lib/entity/deploy_executable_transfer.rb +1 -0
  24. data/lib/entity/deploy_hash.rb +1 -0
  25. data/lib/entity/deploy_header.rb +1 -0
  26. data/lib/entity/deploy_info.rb +1 -0
  27. data/lib/entity/deploy_named_argument.rb +1 -0
  28. data/lib/entity/deploy_transfer.rb +1 -0
  29. data/lib/entity/era_summary.rb +14 -12
  30. data/lib/entity/era_validator.rb +1 -0
  31. data/lib/entity/executable_deploy_item.rb +1 -1
  32. data/lib/entity/group.rb +2 -2
  33. data/lib/entity/module_bytes.rb +1 -0
  34. data/lib/entity/peer.rb +1 -0
  35. data/lib/entity/status.rb +80 -0
  36. data/lib/entity/stored_contract_by_hash.rb +1 -0
  37. data/lib/entity/stored_contract_by_name.rb +2 -0
  38. data/lib/entity/stored_value.rb +86 -11
  39. data/lib/entity/stored_versioned_contract_by_hash.rb +2 -0
  40. data/lib/entity/stored_versioned_contract_by_name.rb +2 -0
  41. data/lib/entity/transfer.rb +8 -7
  42. data/lib/entity/validator_weight.rb +1 -0
  43. data/lib/rpc/rpc_client.rb +1 -1
  44. data/lib/rpc/rpc_error.rb +1 -0
  45. data/lib/serialization/cl_type_serializer.rb +1 -0
  46. data/lib/serialization/cl_value_bytes_parsers.rb +1 -1
  47. data/lib/serialization/cl_value_serializer.rb +1 -0
  48. data/lib/serialization/deploy_approval_serializer.rb +1 -0
  49. data/lib/serialization/deploy_executable_serializer.rb +3 -2
  50. data/lib/serialization/deploy_header_serializer.rb +2 -2
  51. data/lib/serialization/deploy_named_arg_serializer.rb +1 -0
  52. data/lib/serialization/deploy_serializer.rb +1 -0
  53. data/lib/types/cl_type.rb +5 -3
  54. data/lib/types/cl_uref.rb +2 -1
  55. data/lib/types/cl_value.rb +1 -0
  56. data/lib/utils/byte_utils.rb +3 -3
  57. data/lib/version.rb +1 -1
  58. data/spec/client_spec.rb +20 -20
  59. metadata +8 -2
@@ -1,5 +1,6 @@
1
1
  module Casper
2
2
  module Entity
3
+ # Represents a transfer from one purse to another
3
4
  class Transfer
4
5
 
5
6
  # @param [Hash] transfer
@@ -22,32 +23,32 @@ module Casper
22
23
  @id = transfer[:id]
23
24
  end
24
25
 
25
- # @return [String] deploy_hash
26
+ # @return [String] deploy that created the transfer
26
27
  def get_deploy_hash
27
28
  @deploy_hash
28
29
  end
29
30
 
30
- # @return [String] from
31
+ # @return [String] account from which transfer was executed
31
32
  def get_from
32
33
  @from
33
34
  end
34
35
 
35
- # @return [String] to
36
+ # @return [String] account to which funds are transferred
36
37
  def get_to
37
38
  @to
38
39
  end
39
40
 
40
- # @return [String] source
41
+ # @return [String] tource purse
41
42
  def get_source
42
43
  @source
43
44
  end
44
45
 
45
- # @return [String] target
46
+ # @return [String] target purse
46
47
  def get_target
47
48
  @target
48
49
  end
49
50
 
50
- # @return [String] amount
51
+ # @return [String] transfer amount
51
52
  def get_amount
52
53
  @amount
53
54
  end
@@ -56,7 +57,7 @@ module Casper
56
57
  def get_gas
57
58
  @gas
58
59
  end
59
- # @return [Integer] id
60
+ # @return [Integer] user-defined id
60
61
  def get_id
61
62
  @id
62
63
  end
@@ -1,5 +1,6 @@
1
1
  module Casper
2
2
  module Entity
3
+ # A validator's weight.
3
4
  class ValidatorWeight
4
5
 
5
6
  # @param [String] public_key
@@ -8,8 +8,8 @@ require 'active_support/core_ext/hash/keys'
8
8
  require 'timeout'
9
9
  require 'net/http'
10
10
  require_relative './rpc_error.rb'
11
- # Class for interacting with the network via RPC
12
11
  module Casper
12
+ # Interacting with the network via RPC
13
13
  class RpcClient
14
14
  attr_accessor :ip_address, :port, :url, :state_root_hash
15
15
 
data/lib/rpc/rpc_error.rb CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  module Casper
3
3
  module RpcError
4
+ # Exception handling
4
5
  class ErrorHandle
5
6
  # @param [Integer] code
6
7
  # @param [String] message
@@ -20,6 +20,7 @@ require_relative '../types/cl_tuple_type.rb'
20
20
  require_relative '../types/cl_any_type.rb'
21
21
  require_relative '../types/cl_public_key_type.rb'
22
22
 
23
+ # Byte serializer for CLType
23
24
  class CLTypeSerizalizer
24
25
 
25
26
  def self.serialize_cl_type(cl_type)
@@ -311,7 +311,7 @@ module CLValueBytesParsers
311
311
  module CLOptionBytesParser
312
312
  extend self
313
313
 
314
- # @param [CLOption]
314
+ # @param [CLOption] cl_option
315
315
  def to_bytes(cl_option)
316
316
 
317
317
  end
@@ -20,6 +20,7 @@ require_relative '../types/cl_public_key.rb'
20
20
  require_relative '../types/constants.rb'
21
21
  require_relative '../serialization/cl_value_bytes_parsers.rb'
22
22
 
23
+ # Byte serializer for CLValue
23
24
  class CLValueSerializer
24
25
 
25
26
  def to_bytes(clvalue)
@@ -3,6 +3,7 @@ require_relative '../serialization/cl_value_bytes_parsers.rb'
3
3
  require_relative '../utils/time_utils.rb'
4
4
  require_relative '../utils/byte_utils.rb'
5
5
 
6
+ # Byte serializer for DeployApproval object
6
7
  class DeployApprovalSerializer
7
8
  def to_bytes(deploy_approval)
8
9
  @approval_serializer = ""
@@ -1,12 +1,13 @@
1
1
  require_relative '../entity/deploy_executable.rb'
2
2
 
3
-
3
+ # Byte serializer for DeployExecutable object
4
4
  class DeployExecutableSerializer
5
5
 
6
6
  def initialize
7
- # @deploy_executable = Casper::Entity::DeployExecutable.new
7
+ @deploy_executable = Casper::Entity::DeployExecutable.new
8
8
  end
9
9
 
10
+ # @param [DeployExecutable] deploy_executable
10
11
  def to_bytes(deploy_executable)
11
12
  if deploy_executable.module_bytes?
12
13
  deploy_executable.get_module_bytes.to_bytes
@@ -3,10 +3,10 @@ require_relative '../serialization/cl_value_bytes_parsers.rb'
3
3
  require_relative '../utils/time_utils.rb'
4
4
  require_relative '../utils/byte_utils.rb'
5
5
 
6
-
6
+ # Byte serializer for DeployHeader object
7
7
  class DeployHeaderSerializer
8
8
 
9
- # @param [DeployerHeader] header
9
+ # @param [DeployerHeader] deploy_header
10
10
  # @return [String] serialized_header
11
11
  def to_bytes(deploy_header)
12
12
  @serialized_header = ""
@@ -4,6 +4,7 @@ require_relative '../utils/byte_utils.rb'
4
4
  require_relative './cl_type_serializer.rb'
5
5
  require_relative './cl_value_serializer.rb'
6
6
 
7
+ # Byte serializer for DeployNamedArg object
7
8
  class DeployNamedArgSerializer
8
9
 
9
10
  def to_bytes(arg)
@@ -4,6 +4,7 @@ require_relative './deploy_executable_serializer'
4
4
  require_relative './deploy_named_arg_serializer'
5
5
  require_relative '../utils/byte_utils.rb'
6
6
 
7
+ # Byte serializer for Deploy object
7
8
  class DeploySerializer
8
9
 
9
10
  def to_bytes(deploy)
data/lib/types/cl_type.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'json'
2
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.
3
5
  class CLType
4
6
  TAGS = {
5
7
  # Boolean primitive.
@@ -71,7 +73,7 @@ class CLType
71
73
  TAGS[key]
72
74
  end
73
75
 
74
- # @param [Integer]
76
+ # @param [Integer] value
75
77
  # @return [String]
76
78
  def get_tag_key(value)
77
79
  TAGS.key(value).to_s
@@ -86,8 +88,8 @@ class CLType
86
88
  TAGS
87
89
  end
88
90
 
89
- # @param [Integer] tag_value
90
- # @return [Boolean] true or false
91
+ # @param [Integer] value
92
+ # @return [Boolean]
91
93
  def tag_value_isvalid(value)
92
94
  TAGS.has_value?(value)
93
95
  end
data/lib/types/cl_uref.rb CHANGED
@@ -11,7 +11,8 @@ require 'json'
11
11
  class CLURef < CLValue
12
12
  include CLValueBytesParsers::CLURefBytesParser
13
13
  attr_accessor :err
14
- # @param [Array<Integer>]
14
+ # @param [Array<Integer>] value
15
+ # @param [AccessRights] access_rights
15
16
  # value is an uint8array
16
17
  def initialize(value = nil, access_rights = nil)
17
18
  super()
@@ -1,5 +1,6 @@
1
1
  require_relative './cl_type.rb'
2
2
 
3
+ # A Casper value, i.e. a value which can be stored and manipulated by smart contracts.
3
4
  class CLValue
4
5
 
5
6
  def initialize(bytes = nil, cl_type = nil, parsed = nil)
@@ -2,7 +2,7 @@ module Utils
2
2
  module ByteUtils
3
3
  extend self
4
4
 
5
- # @param [String] string
5
+ # @param [String] str
6
6
  # @return [String]
7
7
  def string_to_hex(str)
8
8
  # str.unpack1("H*")
@@ -28,7 +28,7 @@ module Utils
28
28
  byte_array.pack("C*").unpack("H*").first
29
29
  end
30
30
 
31
- # @param [String] string
31
+ # @param [String] str
32
32
  # @return [Array]
33
33
  def string_to_byte_array(str)
34
34
  str.unpack("C*")
@@ -78,7 +78,7 @@ module Utils
78
78
  end
79
79
 
80
80
  # @param [String] hex_str
81
- # @param [String]
81
+ # @return [String]
82
82
  def hex_from_little_endian_to_big_endian(hex_str)
83
83
  # [hex_str].pack("H*").unpack('N*').pack('V*').unpack1('H*')
84
84
  [hex_str].pack("H*").unpack('N*').pack('V*').unpack('H*').first
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CasperNetworkSDK
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.2'
3
3
  end
data/spec/client_spec.rb CHANGED
@@ -1,25 +1,25 @@
1
1
  # client_spec.rb
2
- # require './lib/casper_network.rb'
2
+ require './lib/rpc/rpc_client.rb'
3
3
 
4
- # describe CasperClient do
5
- # client1 = CasperClient.new("185.246.84.43")
6
- # # Test info_get_peers()
7
- # describe "#info_get_peers" do
8
- # it "returns peers array." do
9
- # # Check whether ıt is an array or not
10
- # expect(client1.info_get_peers).to be_an(Array)
11
- # # Check the length of the peers array
12
- # expect(client1.info_get_peers.length).to be > 0
4
+ describe Casper::RpcClient do
5
+ client1 = Casper::RpcClient.new("185.246.84.43")
6
+ # Test info_get_peers()
7
+ describe "#info_get_peers" do
8
+ it "returns peers array." do
9
+ # Check whether ıt is an array or not
10
+ expect(client1.info_get_peers).to be_an(Array)
11
+ # Check the length of the peers array
12
+ expect(client1.info_get_peers.length).to be > 0
13
13
 
14
- # end
15
- # end
16
- # # Test chain_get_StateRootHash()
17
- # describe "#chain_get_StateRootHash" do
18
- # it "returns current state_root_hash." do
19
- # # Check whether its type is string or not
20
- # expect(client1.chain_get_StateRootHash).to be_an(String)
21
- # end
22
- # end
14
+ end
15
+ end
16
+ # Test chain_get_StateRootHash()
17
+ describe "#chain_get_StateRootHash" do
18
+ it "returns current state_root_hash." do
19
+ # Check whether its type is string or not
20
+ expect(client1.chain_get_StateRootHash).to be_an(String)
21
+ end
22
+ end
23
23
 
24
24
 
25
- # end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casper_network
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Sait Gülmez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-18 00:00:00.000000000 Z
11
+ date: 2022-09-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby gem enables developers to interact with the Casper Network.
14
14
  email: cenggulmez.65@gmail.com
@@ -35,6 +35,11 @@ files:
35
35
  - lib/entity/auction_state.rb
36
36
  - lib/entity/bid.rb
37
37
  - lib/entity/bid_info.rb
38
+ - lib/entity/block.rb
39
+ - lib/entity/block_body.rb
40
+ - lib/entity/block_header.rb
41
+ - lib/entity/block_info.rb
42
+ - lib/entity/block_proof.rb
38
43
  - lib/entity/contract.rb
39
44
  - lib/entity/contract_package.rb
40
45
  - lib/entity/contract_version.rb
@@ -58,6 +63,7 @@ files:
58
63
  - lib/entity/module_bytes.rb
59
64
  - lib/entity/peer.rb
60
65
  - lib/entity/seigniorage_allocation.rb
66
+ - lib/entity/status.rb
61
67
  - lib/entity/stored_contract_by_hash.rb
62
68
  - lib/entity/stored_contract_by_name.rb
63
69
  - lib/entity/stored_value.rb