cita-sdk-ruby 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/README.md +5 -0
- data/cita.gemspec +1 -1
- data/lib/cita/rpc.rb +5 -2
- data/lib/cita/transaction.rb +2 -2
- data/lib/cita/transaction_signer.rb +4 -4
- data/lib/cita/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bf77ee83aea26ee7e2f49e4350724c11e2109dde6a8180aa2f85a2530840356
|
4
|
+
data.tar.gz: 0a6f2346c1bdc19895e8f0e02546e8072b159fcf433ae079277f01fb9acccd24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 692ce2c43900030e44f15d2ec6481aa01d1f5cac6557428128cc258207ea64065b22a459db1da85bbafdc564914e699a3711658ccb5f46e331c8e6fb0a2d3bc0
|
7
|
+
data.tar.gz: 01d28daf64b56add72372a1790f96042d0fd1ef3193070a10c07a014f4ecdfa92e3dbcd06aad37f4b6d86e950a6a6ef6463656bd0472be254008d156eeb0e0b1
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cita-sdk-ruby (0.
|
4
|
+
cita-sdk-ruby (0.24.0)
|
5
5
|
activesupport (~> 5.2.1)
|
6
6
|
ciri-crypto (= 0.1.1)
|
7
7
|
faraday (~> 0.15.3)
|
8
8
|
google-protobuf (~> 3.7)
|
9
|
-
web3-eth (
|
9
|
+
web3-eth (= 0.2.18)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
@@ -31,14 +31,14 @@ GEM
|
|
31
31
|
digest-sha3 (1.1.0)
|
32
32
|
faraday (0.15.4)
|
33
33
|
multipart-post (>= 1.2, < 3)
|
34
|
-
ffi (1.
|
34
|
+
ffi (1.11.1)
|
35
35
|
google-protobuf (3.7.1)
|
36
36
|
i18n (1.6.0)
|
37
37
|
concurrent-ruby (~> 1.0)
|
38
38
|
jaro_winkler (1.5.1)
|
39
39
|
method_source (0.9.0)
|
40
40
|
minitest (5.11.3)
|
41
|
-
multipart-post (2.
|
41
|
+
multipart-post (2.1.1)
|
42
42
|
parallel (1.12.1)
|
43
43
|
parser (2.5.1.2)
|
44
44
|
ast (~> 2.4.0)
|
data/README.md
CHANGED
@@ -79,6 +79,11 @@ response = contract.send_func(tx: tx, private_key: private_key, method: :transfe
|
|
79
79
|
|
80
80
|
## CHANGELOG
|
81
81
|
|
82
|
+
### v0.24.0
|
83
|
+
|
84
|
+
* support transaction version = 2
|
85
|
+
* set default transaction version to 2
|
86
|
+
|
82
87
|
### v0.23.0
|
83
88
|
|
84
89
|
* add `getVersion` and `peersInfo` RPC methods
|
data/cita.gemspec
CHANGED
@@ -43,5 +43,5 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_dependency "ciri-crypto", "0.1.1"
|
44
44
|
spec.add_dependency "faraday", "~> 0.15.3"
|
45
45
|
spec.add_dependency "activesupport", "~> 5.2.1"
|
46
|
-
spec.add_dependency "web3-eth", "
|
46
|
+
spec.add_dependency "web3-eth", "0.2.18"
|
47
47
|
end
|
data/lib/cita/rpc.rb
CHANGED
@@ -74,11 +74,14 @@ module CITA
|
|
74
74
|
valid_until_block = block_number["result"].hex + 88
|
75
75
|
meta_data = get_meta_data("latest")["result"]
|
76
76
|
version = meta_data["version"]
|
77
|
-
|
77
|
+
|
78
|
+
chain_id = case version
|
79
|
+
when 0
|
78
80
|
meta_data["chainId"]
|
79
|
-
|
81
|
+
when 1, 2
|
80
82
|
meta_data["chainIdV1"]
|
81
83
|
end
|
84
|
+
|
82
85
|
transaction = Transaction.new(nonce: Utils.nonce, valid_until_block: valid_until_block, chain_id: chain_id, to: to, value: value, quota: quota, version: version)
|
83
86
|
send_transaction(transaction, private_key)
|
84
87
|
end
|
data/lib/cita/transaction.rb
CHANGED
@@ -18,8 +18,8 @@ module CITA
|
|
18
18
|
# @param quota [Integer]
|
19
19
|
#
|
20
20
|
# @return [void]
|
21
|
-
def initialize(valid_until_block:, chain_id:, nonce: nil, version: 1, to: nil, data: nil, value: "
|
22
|
-
raise VersionError, "transaction version error, expected 0 or
|
21
|
+
def initialize(valid_until_block:, chain_id:, nonce: nil, version: 1, to: nil, data: nil, value: "2", quota: 1_000_000) # rubocop:disable Metrics/ParameterLists
|
22
|
+
raise VersionError, "transaction version error, expected 0, 1 or 2, got #{version}" unless [0, 1, 2].include?(version)
|
23
23
|
|
24
24
|
@to = to
|
25
25
|
@nonce = nonce.blank? ? SecureRandom.hex : nonce
|
@@ -25,7 +25,7 @@ module CITA
|
|
25
25
|
if transaction.version.zero?
|
26
26
|
tx.to = to unless to.nil?
|
27
27
|
tx.chain_id = transaction.chain_id
|
28
|
-
elsif transaction.version == 1
|
28
|
+
elsif transaction.version == 1 || transaction.version == 2
|
29
29
|
tx.to_v1 = Utils.to_bytes(to) unless to.nil?
|
30
30
|
tx.chain_id_v1 = hex_to_bytes(transaction.chain_id)
|
31
31
|
end
|
@@ -102,11 +102,11 @@ module CITA
|
|
102
102
|
if version == 0 # rubocop:disable Style/NumericPredicate
|
103
103
|
tx.delete(:to_v1)
|
104
104
|
tx.delete(:chain_id_v1)
|
105
|
-
elsif version == 1
|
105
|
+
elsif version == 1 || version == 2
|
106
106
|
tx[:to] = tx.delete(:to_v1)
|
107
107
|
tx[:chain_id] = tx.delete(:chain_id_v1)
|
108
108
|
else
|
109
|
-
raise Transaction::VersionError, "transaction version error, expected 0 or
|
109
|
+
raise Transaction::VersionError, "transaction version error, expected 0, 1 or 2, got #{version}"
|
110
110
|
end
|
111
111
|
|
112
112
|
data
|
@@ -132,7 +132,7 @@ module CITA
|
|
132
132
|
tx.delete(:to_v1)
|
133
133
|
tx.delete(:chain_id_v1)
|
134
134
|
tx[:to] = Utils.add_prefix_for_not_blank(tx[:to])
|
135
|
-
elsif version == 1
|
135
|
+
elsif version == 1 || version == 2
|
136
136
|
tx[:to] = Utils.from_bytes(tx[:to])
|
137
137
|
tx[:chain_id] = Utils.from_bytes(tx[:chain_id])
|
138
138
|
end
|
data/lib/cita/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cita-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- classicalliu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -154,16 +154,16 @@ dependencies:
|
|
154
154
|
name: web3-eth
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- -
|
157
|
+
- - '='
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.2.
|
159
|
+
version: 0.2.18
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- -
|
164
|
+
- - '='
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.2.
|
166
|
+
version: 0.2.18
|
167
167
|
description: Ruby CITA SDK for signature and rpc call
|
168
168
|
email:
|
169
169
|
- classicalliu@gmail.com
|
@@ -218,8 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
218
218
|
- !ruby/object:Gem::Version
|
219
219
|
version: '0'
|
220
220
|
requirements: []
|
221
|
-
|
222
|
-
rubygems_version: 2.7.7
|
221
|
+
rubygems_version: 3.0.3
|
223
222
|
signing_key:
|
224
223
|
specification_version: 4
|
225
224
|
summary: Ruby CITA SDK
|