libra_client 0.1.2 → 0.1.3
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/.gitignore +0 -0
- data/.travis.yml +0 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +4 -4
- data/LICENSE.txt +0 -0
- data/README.md +11 -2
- data/Rakefile +0 -0
- data/bin/console +0 -0
- data/bin/setup +0 -0
- data/gen_proto.sh +0 -0
- data/lib/libra/access_path.rb +0 -0
- data/lib/libra/account_address.rb +0 -0
- data/lib/libra/account_config.rb +0 -0
- data/lib/libra/account_resource.rb +0 -0
- data/lib/libra/mnemonic.rb +0 -0
- data/lib/libra/version.rb +1 -1
- data/lib/libra_client.rb +14 -3
- data/libra_client.gemspec +2 -2
- data/libra_client.sublime-project +0 -0
- data/proto-lib/access_path_pb.rb +0 -0
- data/proto-lib/account_state_blob_pb.rb +0 -0
- data/proto-lib/admission_control_pb.rb +0 -0
- data/proto-lib/admission_control_services_pb.rb +0 -0
- data/proto-lib/events_pb.rb +0 -0
- data/proto-lib/get_with_proof_pb.rb +0 -0
- data/proto-lib/ledger_info_pb.rb +0 -0
- data/proto-lib/mempool_status_pb.rb +0 -0
- data/proto-lib/proof_pb.rb +0 -0
- data/proto-lib/transaction_info_pb.rb +0 -0
- data/proto-lib/transaction_pb.rb +0 -0
- data/proto-lib/validator_change_pb.rb +0 -0
- data/proto-lib/vm_errors_pb.rb +0 -0
- data/protos/access_path.proto +0 -0
- data/protos/account_state_blob.proto +0 -0
- data/protos/admission_control.proto +0 -0
- data/protos/events.proto +0 -0
- data/protos/get_with_proof.proto +0 -0
- data/protos/ledger_info.proto +0 -0
- data/protos/mempool_status.proto +0 -0
- data/protos/proof.proto +0 -0
- data/protos/transaction.proto +0 -0
- data/protos/transaction_info.proto +0 -0
- data/protos/validator_change.proto +0 -0
- data/protos/vm_errors.proto +0 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 589f70194d44d82434013d5d4469f69a947c67190ae78bd68cc7b3960f5bb8b4
|
4
|
+
data.tar.gz: a94e79ed350ca47b747e2c2c31a3aa6eb1fbf9f828bd890844c92474d2d72842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3642745ef336f66acf064ea77f7e3027ce0302a247101fa5ff6b1aa229a100a65db311123eb163d09468b42f230c128706688bd8a0a6cb2deb238fadedfd15e1
|
7
|
+
data.tar.gz: b7b53603586cbc630830cd072ef9d2a7ba22446502c06636f3a57c5ba8dc01c509c1287a443a8d9025cdda794392a3b109f51dd69ade9c97213436119dbfa4fb
|
data/.gitignore
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/CODE_OF_CONDUCT.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/Gemfile.lock
CHANGED
@@ -2,7 +2,7 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
libra_client (0.1.2)
|
5
|
-
canoser (~> 0.1.
|
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.
|
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)
|
data/LICENSE.txt
CHANGED
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
|
data/bin/console
CHANGED
File without changes
|
data/bin/setup
CHANGED
File without changes
|
data/gen_proto.sh
CHANGED
File without changes
|
data/lib/libra/access_path.rb
CHANGED
File without changes
|
File without changes
|
data/lib/libra/account_config.rb
CHANGED
File without changes
|
File without changes
|
data/lib/libra/mnemonic.rb
CHANGED
File without changes
|
data/lib/libra/version.rb
CHANGED
data/lib/libra_client.rb
CHANGED
@@ -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
|
63
|
+
state.sequence_number
|
53
64
|
end
|
54
65
|
|
55
66
|
def get_balance(address)
|
56
67
|
state = get_account_state(address)
|
57
|
-
state
|
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)
|
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
|
data/libra_client.gemspec
CHANGED
@@ -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.
|
45
|
+
spec.add_dependency "canoser", "~> 0.1.2"
|
46
46
|
spec.add_dependency "rest-client", "~> 2.0"
|
47
|
-
#spec.add_dependency "openssl", "~>
|
47
|
+
#spec.add_dependency "openssl", "~> 3.0.0" #not ready, need SHA3 support.
|
48
48
|
|
49
49
|
end
|
File without changes
|
data/proto-lib/access_path_pb.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/proto-lib/events_pb.rb
CHANGED
File without changes
|
File without changes
|
data/proto-lib/ledger_info_pb.rb
CHANGED
File without changes
|
File without changes
|
data/proto-lib/proof_pb.rb
CHANGED
File without changes
|
File without changes
|
data/proto-lib/transaction_pb.rb
CHANGED
File without changes
|
File without changes
|
data/proto-lib/vm_errors_pb.rb
CHANGED
File without changes
|
data/protos/access_path.proto
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/protos/events.proto
CHANGED
File without changes
|
data/protos/get_with_proof.proto
CHANGED
File without changes
|
data/protos/ledger_info.proto
CHANGED
File without changes
|
data/protos/mempool_status.proto
CHANGED
File without changes
|
data/protos/proof.proto
CHANGED
File without changes
|
data/protos/transaction.proto
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/protos/vm_errors.proto
CHANGED
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.
|
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-
|
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.
|
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.
|
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
|
-
|
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.
|