libra_client 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/.travis.yml +0 -0
  4. data/CODE_OF_CONDUCT.md +0 -0
  5. data/Gemfile +0 -0
  6. data/Gemfile.lock +4 -4
  7. data/LICENSE.txt +0 -0
  8. data/README.md +11 -2
  9. data/Rakefile +0 -0
  10. data/bin/console +0 -0
  11. data/bin/setup +0 -0
  12. data/gen_proto.sh +0 -0
  13. data/lib/libra/access_path.rb +0 -0
  14. data/lib/libra/account_address.rb +0 -0
  15. data/lib/libra/account_config.rb +0 -0
  16. data/lib/libra/account_resource.rb +0 -0
  17. data/lib/libra/mnemonic.rb +0 -0
  18. data/lib/libra/version.rb +1 -1
  19. data/lib/libra_client.rb +14 -3
  20. data/libra_client.gemspec +2 -2
  21. data/libra_client.sublime-project +0 -0
  22. data/proto-lib/access_path_pb.rb +0 -0
  23. data/proto-lib/account_state_blob_pb.rb +0 -0
  24. data/proto-lib/admission_control_pb.rb +0 -0
  25. data/proto-lib/admission_control_services_pb.rb +0 -0
  26. data/proto-lib/events_pb.rb +0 -0
  27. data/proto-lib/get_with_proof_pb.rb +0 -0
  28. data/proto-lib/ledger_info_pb.rb +0 -0
  29. data/proto-lib/mempool_status_pb.rb +0 -0
  30. data/proto-lib/proof_pb.rb +0 -0
  31. data/proto-lib/transaction_info_pb.rb +0 -0
  32. data/proto-lib/transaction_pb.rb +0 -0
  33. data/proto-lib/validator_change_pb.rb +0 -0
  34. data/proto-lib/vm_errors_pb.rb +0 -0
  35. data/protos/access_path.proto +0 -0
  36. data/protos/account_state_blob.proto +0 -0
  37. data/protos/admission_control.proto +0 -0
  38. data/protos/events.proto +0 -0
  39. data/protos/get_with_proof.proto +0 -0
  40. data/protos/ledger_info.proto +0 -0
  41. data/protos/mempool_status.proto +0 -0
  42. data/protos/proof.proto +0 -0
  43. data/protos/transaction.proto +0 -0
  44. data/protos/transaction_info.proto +0 -0
  45. data/protos/validator_change.proto +0 -0
  46. data/protos/vm_errors.proto +0 -0
  47. metadata +6 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f758e04df55fe337f1c56b5fe70d037c86e109440690f22638dc135521d7c0a6
4
- data.tar.gz: 130f1edfeccc99b78345c22276b5623707e98b848c25f7548c8795f5bba699bc
3
+ metadata.gz: 589f70194d44d82434013d5d4469f69a947c67190ae78bd68cc7b3960f5bb8b4
4
+ data.tar.gz: a94e79ed350ca47b747e2c2c31a3aa6eb1fbf9f828bd890844c92474d2d72842
5
5
  SHA512:
6
- metadata.gz: 4f5973fd755d991dd2abf802372924432d27bf72ef65d2dfadc4487f924eb5c397147fcfecc52e5ce7f7f375718d72aada400504e630894a5f9e470014d62d76
7
- data.tar.gz: 97e574d53dda8187837a5102e09c2d902b6d82b7ecd7c85bbd18d2853e3fb1830cb881edde8333fa189afe359262350bbdd03ef1b235c97b1216c345bb9def5e
6
+ metadata.gz: 3642745ef336f66acf064ea77f7e3027ce0302a247101fa5ff6b1aa229a100a65db311123eb163d09468b42f230c128706688bd8a0a6cb2deb238fadedfd15e1
7
+ data.tar.gz: b7b53603586cbc630830cd072ef9d2a7ba22446502c06636f3a57c5ba8dc01c509c1287a443a8d9025cdda794392a3b109f51dd69ade9c97213436119dbfa4fb
data/.gitignore CHANGED
File without changes
File without changes
File without changes
data/Gemfile CHANGED
File without changes
@@ -2,7 +2,7 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  libra_client (0.1.2)
5
- canoser (~> 0.1.0)
5
+ canoser (~> 0.1.2)
6
6
  grpc (~> 1.23)
7
7
  rest-client (~> 2.0)
8
8
 
@@ -10,13 +10,13 @@ GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  byebug (11.0.1)
13
- canoser (0.1.1)
13
+ canoser (0.1.2)
14
14
  domain_name (0.5.20190701)
15
15
  unf (>= 0.0.5, < 1.0.0)
16
- google-protobuf (3.9.1)
16
+ google-protobuf (3.9.1-x86_64-linux)
17
17
  googleapis-common-protos-types (1.0.4)
18
18
  google-protobuf (~> 3.0)
19
- grpc (1.23.0)
19
+ grpc (1.23.0-x86_64-linux)
20
20
  google-protobuf (~> 3.8)
21
21
  googleapis-common-protos-types (~> 1.0)
22
22
  http-accept (1.7.0)
File without changes
data/README.md CHANGED
@@ -21,7 +21,16 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
+ ### Get Account state
25
+ ```ruby
26
+ require 'libra_client'
27
+ client = Libra::Client.new(:testnet)
28
+ state = client.get_account_state("000000000000000000000000000000000000000000000000000000000a550c18")
29
+ state.balance #the balance of the account
30
+ state.sequence_number #the sequence_number of the account
31
+ ```
24
32
 
33
+ ### Get Transaction
25
34
  ```ruby
26
35
  require 'libra_client'
27
36
  client = Libra::Client.new(:testnet)
@@ -29,10 +38,10 @@ client.get_transaction(0) #get the genesis transaction
29
38
  client.get_transaction(1) #get the first transaction
30
39
  version = client.get_latest_transaction_version
31
40
  client.get_transaction(version) #get the latest transaction
32
-
33
- client.get_account_state(ASSOCIATION_ADDRESS)
34
41
  ```
35
42
 
43
+
44
+
36
45
  ## Development
37
46
 
38
47
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/Rakefile CHANGED
File without changes
File without changes
data/bin/setup CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module Libra
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -17,6 +17,17 @@ require 'libra/mnemonic'
17
17
  module Libra
18
18
  class LibraError < StandardError; end
19
19
 
20
+ module BinaryExtensions
21
+ # bin-to-hex
22
+ def bin2hex; unpack("H*")[0]; end
23
+ # hex-to-bin
24
+ def hex2bin; [self].pack("H*"); end
25
+ end
26
+
27
+ class ::String
28
+ include Libra::BinaryExtensions
29
+ end
30
+
20
31
  NETWORKS = {
21
32
  testnet:{
22
33
  host: "ac.testnet.libra.org:8000",
@@ -49,12 +60,12 @@ module Libra
49
60
 
50
61
  def get_sequence_number(address)
51
62
  state = get_account_state(address)
52
- state["sequence_number"]
63
+ state.sequence_number
53
64
  end
54
65
 
55
66
  def get_balance(address)
56
67
  state = get_account_state(address)
57
- state["balance"]
68
+ state.balance
58
69
  end
59
70
 
60
71
  def get_account_state(address)
@@ -62,7 +73,7 @@ module Libra
62
73
  item = Types::RequestItem.new(get_account_state_request: query)
63
74
  resp = update_to_latest_ledger([item])
64
75
  state = resp.response_items[0].get_account_state_response.account_state_with_proof
65
- map = Libra::AccountState.deserialize(state.blob.blob)["blob"]
76
+ map = Libra::AccountState.deserialize(state.blob.blob).blob
66
77
  resource = map[AccountConfig::ACCOUNT_RESOURCE_PATH]
67
78
  Libra::AccountResource.deserialize(resource.pack('C*'))
68
79
  end
@@ -42,8 +42,8 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency "byebug", "~> 11.0"
43
43
 
44
44
  spec.add_dependency "grpc", "~> 1.23"
45
- spec.add_dependency "canoser", "~> 0.1.0"
45
+ spec.add_dependency "canoser", "~> 0.1.2"
46
46
  spec.add_dependency "rest-client", "~> 2.0"
47
- #spec.add_dependency "openssl", "~> 2.1.3"
47
+ #spec.add_dependency "openssl", "~> 3.0.0" #not ready, need SHA3 support.
48
48
 
49
49
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libra_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - yuan xinyu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-01 00:00:00.000000000 Z
11
+ date: 2019-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.1.0
89
+ version: 0.1.2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.1.0
96
+ version: 0.1.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rest-client
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -183,7 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0'
185
185
  requirements: []
186
- rubygems_version: 3.0.1
186
+ rubyforge_project:
187
+ rubygems_version: 2.7.7
187
188
  signing_key:
188
189
  specification_version: 4
189
190
  summary: A ruby client for Libra network.