platon 0.2.7 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b21ae9984ff18a3127a41dcdf874b2faf09e0a5894ff76f6a1cb8c2f0bdabd4
4
- data.tar.gz: 9e7fa8d362e19aa6a242c102dcf4ec9f26ca82d4766294e0e1bcb50c23cad4d8
3
+ metadata.gz: 5b74aa93e42dc1018e37a97771b504ce6f9afd8e54cd71d2356878e7a0b96d6f
4
+ data.tar.gz: 27c316fccb2c0e8a794e743ccd4c5f9f9bddac9510ad5d0e5060f351333e54ab
5
5
  SHA512:
6
- metadata.gz: 47433d9c023943de1c279ce43628f127670085f48e5f01d5af85a002d129d680c8401ae29330e1a481cb2192e2540879f38f5757d7b589ed3a922d72c7f247d1
7
- data.tar.gz: d24a4404809cb945d595d869d701fe6542065b352143174583cf00bf59e8a9cdae4fdc94b8623f21f3a956a1952eb40fb2774ae1321eaf8892463647d2e1c5a0
6
+ metadata.gz: 25d498145373bbcc9e769208eebbd37cfbbdfa3abdcb2f4ef1fb0d6abe3fe4ac3831ac05adb578b70a1c27bc4fdd682647b7a6e9be6af44e904bbddabaa28b7d
7
+ data.tar.gz: 96195888ad12015a29f3cf5da1d15ec7ffd2ccf8c9241eabd74308121c2a3dac14bab565c52c1ae2f5622704dcf462d6db044a1129b286ae6b88989b3715d65a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- platon (0.2.6)
4
+ platon (0.2.8)
5
5
  activesupport (>= 4.0)
6
6
  digest-sha3 (~> 1.1)
7
7
  ffi (~> 1.0)
@@ -18,7 +18,7 @@ GEM
18
18
  minitest (~> 5.1)
19
19
  tzinfo (~> 1.1)
20
20
  coderay (1.1.3)
21
- concurrent-ruby (1.1.8)
21
+ concurrent-ruby (1.1.9)
22
22
  diff-lcs (1.4.4)
23
23
  digest-sha3 (1.1.0)
24
24
  ffi (1.15.1)
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Ruby SDK for Platon & Alaya
2
2
 
3
3
 
4
-
5
4
  <p align="center">
6
5
  <img src="./platon-ruby-logo.png" width="80" title="platon ruby SDK" alt="platon ruby SDK">
7
6
  </p>
@@ -29,7 +28,7 @@ Or install it yourself as:
29
28
 
30
29
  ## Quick Start
31
30
 
32
- ```
31
+ ```ruby
33
32
  ## generate new key
34
33
  key = Platon::Key.new
35
34
 
@@ -53,7 +52,7 @@ client.transfer key,"atpxxxxxxxxxxxxxxx",10**16
53
52
 
54
53
  Create a new public/private key and get its address
55
54
 
56
- ```
55
+ ```ruby
57
56
  key = Platon::Key.new
58
57
  key.private_hex ## private key
59
58
  => "08bb093d6184cb06a3f80507953ba6768c03d8114a429b0ec7875bb6b6e1a8a6"
@@ -61,11 +60,11 @@ key.private_hex ## private key
61
60
  key.public_hex ## public key
62
61
  => "04641129e66399310ce4a41098d3b3fc4d722edf423dfdc0a76eba5d6e2155bbe611ee2a5c06011ab76040ca53b9ead4c5061d8cc8a89afa3f45af5830661d4b34"
63
62
 
64
- key.bech32_address ## bech32 address ,default "atp"
65
- => "atp1ls87d3mqfhxadjsmn0ns844tj8ljlsq89k95cn"
63
+ key.bech32_address ## bech32 address ,default "lat"
64
+ => "lat1ls87d3mqfhxadjsmn0ns844tj8ljlsq8uqnv8u"
66
65
 
67
- key.bech32_address(hrp: "lat")
68
- => "lat1ls87d3mqfhxadjsmn0ns844tj8ljlsq8uqnv8u"
66
+ key.bech32_address(hrp: "atp")
67
+ => "atp1ls87d3mqfhxadjsmn0ns844tj8ljlsq89k95cn"
69
68
 
70
69
  key.address ## EIP55 checksummed address
71
70
  => "0xFc0Fe6c7604dcDd6ca1B9be703D6AB91fF2fC007"
@@ -73,14 +72,19 @@ key.address ## EIP55 checksummed address
73
72
 
74
73
  Encrypt keys to json file
75
74
 
76
- ```
75
+ ```ruby
76
+ ## default address hrp:"lat"
77
77
  encrypted_key_info = Platon::Key.encrypt key,"your_password"
78
78
 
79
+ ## set address hrp
80
+
81
+ encrypted_key_info = Platon::Key.encrypt key,"your_password",{hrp:"atp"}
82
+
79
83
  ## or save to location
80
84
 
81
- Platon::Key.encrypt_and_save key,"your_password",'./some/path.json'
85
+ Platon::Key.encrypt_and_save key,"your_password",{hrp:"atp",keypath:'./some/path.json'}
82
86
 
83
- ## or default: ~/.platon/keystore
87
+ ## or default keypath: "~/.platon/keystore" ,and use default hrp:"lat"
84
88
 
85
89
  Platon::Key.encrypt_and_save key,"your_password"
86
90
 
@@ -88,7 +92,7 @@ Platon::Key.encrypt_and_save key,"your_password"
88
92
 
89
93
  Decrypt keys from json file
90
94
 
91
- ```
95
+ ```ruby
92
96
  decrypted_key = Platon::Key.decrypt encrypted_key_info,"your_password"
93
97
 
94
98
  or
@@ -100,7 +104,7 @@ decrypted_key = Platon::Key.decrypt File.read('./some/path.json'), 'your_passwor
100
104
 
101
105
  Build a transcation :
102
106
 
103
- ```
107
+ ```ruby
104
108
  args = {
105
109
  from: key.address,
106
110
  to: key2.address,
@@ -116,13 +120,13 @@ tx = Platon::Tx.new args
116
120
 
117
121
  Or decode from an encoded raw transaction
118
122
 
119
- ```
123
+ ```ruby
120
124
  tx = Platon::Tx.decode hex
121
125
  ```
122
126
 
123
127
  You can sign the transaction:
124
128
 
125
- ```
129
+ ```ruby
126
130
  tx.sign key
127
131
  platon_send_raw_transaction(tx.hex)
128
132
  ```
@@ -133,7 +137,7 @@ Get the raw transaction with `tx.hex`, and broadcast it through any PlatON node
133
137
 
134
138
  By default methods interactiong with contracts&PPOS will use default JSON RPC Client that will handle connection to platon node.
135
139
 
136
- ```
140
+ ```ruby
137
141
  client = Platon::HttpClient.new("http://127.0.0.1:6789",:alayadev)
138
142
  ```
139
143
 
@@ -146,7 +150,7 @@ Default setting:
146
150
 
147
151
  You can use `client.update_setting` to change chain configs:
148
152
 
149
- ```
153
+ ```ruby
150
154
  client.update_setting(hrp:"atx",chain_id: 1234)
151
155
  ```
152
156
 
@@ -154,12 +158,12 @@ client.update_setting(hrp:"atx",chain_id: 1234)
154
158
 
155
159
  You can get contract from blockchain. To do so you need a contract name ,contract address and ABI definition:
156
160
 
157
- ```
161
+ ```ruby
158
162
  contract = Platon::Contract.create(client: client ,name: "MyContract", address: "atpxxxx_your_bench32_address", abi: abi)
159
163
  ```
160
164
 
161
165
  Alternatively you can obtain abi definition and name from contract source file:
162
- ```
166
+ ```ruby
163
167
  contract = Platon::Contract.create(client: client , file: "MyContract.sol", address: "atpxxxx_your_bench32_address")
164
168
  ```
165
169
 
@@ -167,7 +171,7 @@ Interacting with contracts:
167
171
 
168
172
  You can `call` contract read-only method , no transaction will be sent to the network. If method changes contract state ,`transact` method can be used .
169
173
 
170
- ```
174
+ ```ruby
171
175
  contract.call.[function_name](params)
172
176
 
173
177
  contract.transact.[function_name](params)
@@ -181,7 +185,7 @@ All PPOS methods have been implemented. See [Docs](./doc/zh-cn.md)
181
185
 
182
186
  #### Utils
183
187
 
184
- ```
188
+ ```ruby
185
189
  Platon::Utils.is_bech32_address?("atp1tfm3e44jwdjmelcc9yacus700wcts0zhgw6425")
186
190
  => true
187
191
 
data/doc/zh-cn.md CHANGED
@@ -66,13 +66,18 @@ key.address ## EIP55 checksummed address
66
66
  将key加密保存至json文件
67
67
 
68
68
  ```ruby
69
+ ## default address hrp:"lat"
69
70
  encrypted_key_info = Platon::Key.encrypt key,"your_password"
70
71
 
72
+ ## set address hrp
73
+
74
+ encrypted_key_info = Platon::Key.encrypt key,"your_password",{hrp:"atp"}
75
+
71
76
  ## or save to location
72
77
 
73
- Platon::Key.encrypt_and_save key,"your_password",'./some/path.json'
78
+ Platon::Key.encrypt_and_save key,"your_password",{hrp:"atp",keypath:'./some/path.json'}
74
79
 
75
- ## or default: ~/.platon/keystore
80
+ ## or default keypath: "~/.platon/keystore" ,and use default hrp:"lat"
76
81
 
77
82
  Platon::Key.encrypt_and_save key,"your_password"
78
83
 
@@ -929,11 +934,11 @@ key.public_hex ## 公钥
929
934
  key.address
930
935
  => "0xFc0Fe6c7604dcDd6ca1B9be703D6AB91fF2fC007"
931
936
 
932
- key.bech32_address ## bech32 格式公钥 ,默认是 "atp"
933
- => "atp1ls87d3mqfhxadjsmn0ns844tj8ljlsq89k95cn"
937
+ key.bech32_address ## bech32 格式公钥 ,默认是 "lat"
938
+ => "lat1ls87d3mqfhxadjsmn0ns844tj8ljlsq8uqnv8u"
934
939
 
935
- key.bech32_address(hrp: "lat")
936
- => "lat1ls87d3mqfhxadjsmn0ns844tj8ljlsq8uqnv8u"
940
+ key.bech32_address(hrp: "atp")
941
+ => "atp1ls87d3mqfhxadjsmn0ns844tj8ljlsq89k95cn"
937
942
  ```
938
943
 
939
944
  ### 使用已有私钥导入创建key
@@ -945,40 +950,53 @@ key = Platon::Key.new priv: private_key
945
950
 
946
951
  ### 备份钱包 encrypt
947
952
 
948
- 备份钱包,输入密码加密得到json字符串
953
+ 备份钱包,输入密码加密得到json字符串。第三个参数为options,hash类型,可传参数有: hrp
949
954
 
950
955
  ```ruby
956
+ # 默认使用的hrp为"lat"
951
957
  encrypted_key_info = Platon::Key.encrypt key,"your_password"
952
958
 
953
- # or
959
+ #or
954
960
 
955
- Platon::Key.encrypt_and_save key,"your_password",'./some/path.json'
961
+ encrypted_key_info = Platon::Key.encrypt key,"your_password",{hrp:"atp"}
962
+
963
+ ```
964
+ ### 备份钱包且存储
956
965
 
957
- # or 使用默认地址: ~/.platon/keystore
966
+ 备份钱包,输入密码加密得到json字符串,并存储于指定路径或默认路径。第三个参数为options,hash类型,可传参数有: hrp ,keypath
958
967
 
968
+ ```ruby
969
+ #使用默认地址: ~/.platon/keystore ,默认hrp: "lat"
959
970
  Platon::Key.encrypt_and_save key,"your_password"
960
971
 
972
+ # or
973
+
974
+ Platon::Key.encrypt_and_save key,"your_password",{hrp:"atp",keypath:'./some/path.json'}
975
+
961
976
  ```
962
977
 
978
+
963
979
  ### 恢复钱包 decrypt
964
- 恢复钱包,输入密码得到key对象
980
+ 恢复钱包,输入密码得到key对象, 恢复钱包可适配任意hrp,无需指定hrp
965
981
 
966
982
  ```ruby
967
983
  decrypted_key = Platon::Key.decrypt encrypted_key_info,"your_password"
968
984
 
969
- # or
985
+ # or 先读取指定路径的钱包文件
970
986
 
971
987
  decrypted_key = Platon::Key.decrypt File.read('./some/path.json'), 'your_password'
972
988
  ```
973
989
 
974
990
  ###查询本地钱包 list_wallets
975
991
 
992
+ 可传参数options,默认路径为 "~/.platon/keystore"
993
+
976
994
  ```ruby
977
995
  Platon::Key.list_wallets
978
996
 
979
997
  # or
980
998
 
981
- Platon::Key.list_wallets("/your/wallet/path/")
999
+ Platon::Key.list_wallets(keypath:"/your/wallet/path/")
982
1000
  ```
983
1001
 
984
1002
 
@@ -1040,7 +1058,7 @@ rake 'platon:contract:compile[./spec/fixtures/greeter.sol]'
1040
1058
 
1041
1059
  * 参数
1042
1060
  * `Object`: 发起方的 Key 实例,通过 Platon::Key.new 创建或导入
1043
- * `Integer`: typ, 表示使用账户自由金额还是账户的锁仓金额做质押,0: 自由金额; 1: 锁仓金额
1061
+ * `Integer`: typ, 表示使用账户自由金额还是账户的锁仓金额做质押,0: 自由金额; 1: 锁仓金额 2:优先使用锁仓余额,锁仓余额不足,则剩下使用自由金额
1044
1062
  * `String`: benefitAddress,用于接受出块奖励和质押奖励的收益账户
1045
1063
  * `String`: nodeId,被质押的节点Id(也叫候选人的节点Id)
1046
1064
  * `String`: externalId,外部Id(有长度限制,给第三方拉取节点描述的Id)
@@ -0,0 +1,17 @@
1
+ require "platon"
2
+
3
+ puts "Example : generate key , print address and private_key"
4
+
5
+ while true
6
+ puts ""
7
+ puts "Press any key to Generate keys.."
8
+ STDIN.readline
9
+
10
+
11
+ key = Platon::Key.new
12
+ puts "Address on PlatON: #{key.bech32_address(hrp: "lat")}"
13
+ puts "Address on Alaya: #{key.bech32_address(hrp: "atp")}"
14
+ puts "EIP55 address: #{key.address}"
15
+ puts "PrivateKey: #{key.private_hex}"
16
+ puts "===================================="
17
+ end
@@ -0,0 +1,33 @@
1
+ ### Get Core Token(lat or atp) balance
2
+ ### Get Arc20/Prc20 balance
3
+
4
+ require "platon"
5
+
6
+ ### Example on Alaya:
7
+
8
+ RPC = "http://127.0.0.1:6789" # change to your rpc address
9
+
10
+ TARGET_ADDRESS_1 = "atp1lsds5k5wys93vhm8gvkvepyx5e9hxtfz8w4r5x"
11
+ TARGET_ADDRESS_2 = "atp1djc6dvd2y2kj04hhy30rmctkc9nnqmmzlk42uv"
12
+
13
+
14
+ client = Platon::HttpClient.new(RPC,"alaya")
15
+
16
+ ###Get Core Token(lat or atp) balance
17
+ res = client.platon_get_balance(TARGET_ADDRESS_1,"latest")
18
+ balance = res / 10**18.to_f
19
+ puts "#{TARGET_ADDRESS_1} #{client.hrp.upcase} balance: #{balance} "
20
+
21
+ ###Get Arc20/Prc20 balance
22
+ client.default_account = Platon::Key.new.bech32_address # 随机生成地址并指定即可。 因platon节点要求call也必须传入from参数
23
+ minABI=[{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"}];
24
+ contract = Platon::Contract.create(
25
+ client:client,
26
+ name: "MyContract",
27
+ address: "atp16lellpkrv894hmg8am7ns3p2qny2vqj85ud8s6", #ARC20 contract address
28
+ abi:minABI # Arc20 contract abi
29
+ )
30
+
31
+ res2 = contract.call.balance_of(TARGET_ADDRESS_2)
32
+ aETH_balance = res2 / 10**18.to_f
33
+ puts "#{TARGET_ADDRESS_2} aETH balance: #{aETH_balance}"
data/lib/platon.rb CHANGED
@@ -9,8 +9,6 @@ require 'ffi'
9
9
  require 'money-tree'
10
10
  require 'rlp'
11
11
 
12
- require 'bech32'
13
-
14
12
  module Platon
15
13
 
16
14
  BYTE_ZERO = "\x00".freeze
@@ -38,28 +36,29 @@ module Platon
38
36
  end
39
37
  end
40
38
 
41
- require 'platon/abi'
42
- require 'platon/client'
43
- require 'platon/ipc_client'
44
- require 'platon/http_client'
45
- require 'platon/singleton'
46
- require 'platon/solidity'
47
- require 'platon/initializer'
48
- require 'platon/contract'
49
- require 'platon/explorer_url_helper'
50
- require 'platon/function'
51
- require 'platon/function_input'
52
- require 'platon/function_output'
53
- require 'platon/contract_event'
54
- require 'platon/encoder'
55
- require 'platon/decoder'
56
- require 'platon/formatter'
57
- require 'platon/transaction'
58
- require 'platon/deployment'
59
- require 'platon/contract_initializer'
60
- require 'platon/railtie' if defined?(Rails)
61
-
62
- require 'platon/ppos'
39
+ require_relative 'platon/bech32'
40
+ require_relative 'platon/abi'
41
+ require_relative 'platon/client'
42
+ require_relative 'platon/ipc_client'
43
+ require_relative 'platon/http_client'
44
+ require_relative 'platon/singleton'
45
+ require_relative 'platon/solidity'
46
+ require_relative 'platon/initializer'
47
+ require_relative 'platon/contract'
48
+ require_relative 'platon/explorer_url_helper'
49
+ require_relative 'platon/function'
50
+ require_relative 'platon/function_input'
51
+ require_relative 'platon/function_output'
52
+ require_relative 'platon/contract_event'
53
+ require_relative 'platon/encoder'
54
+ require_relative 'platon/decoder'
55
+ require_relative 'platon/formatter'
56
+ require_relative 'platon/transaction'
57
+ require_relative 'platon/deployment'
58
+ require_relative 'platon/contract_initializer'
59
+ require_relative 'platon/railtie' if defined?(Rails)
60
+
61
+ require_relative 'platon/ppos'
63
62
 
64
63
  autoload :Address, 'platon/address'
65
64
  autoload :Gas, 'platon/gas'
File without changes
data/lib/platon/client.rb CHANGED
@@ -138,7 +138,7 @@ module Platon
138
138
  # end
139
139
 
140
140
  payload = {jsonrpc: "2.0", method: command, params: encode_params(args), id: get_id}
141
- # puts payload
141
+ puts payload
142
142
  @logger.info("Sending #{payload.to_json}") if @log
143
143
  if @batch
144
144
  @batch << payload
@@ -146,7 +146,7 @@ module Platon
146
146
  else
147
147
  # tmp = send_single(payload.to_json)
148
148
  # output = JSON.parse(tmp)
149
- output = JSON.parse(send_single(payload.to_json))
149
+ p output = JSON.parse(send_single(payload.to_json))
150
150
  @logger.info("Received #{output.to_json}") if @log
151
151
  reset_id
152
152
  raise IOError, output["error"]["message"] if output["error"]
@@ -11,10 +11,6 @@ module Platon
11
11
  attr_accessor :call_raw_proxy, :call_proxy, :transact_proxy, :transact_and_wait_proxy
12
12
  attr_accessor :new_filter_proxy, :get_filter_logs_proxy, :get_filter_change_proxy
13
13
 
14
- def self.hello
15
- puts 111
16
- end
17
-
18
14
  def initialize(name, code, abi, client = Platon::Singleton.instance)
19
15
  @name = name
20
16
  @code = code
data/lib/platon/key.rb CHANGED
@@ -5,10 +5,10 @@ module Platon
5
5
 
6
6
  attr_reader :private_key, :public_key
7
7
 
8
- def self.encrypt(key, password)
8
+ def self.encrypt(key, password,options={})
9
9
  key = new(priv: key) unless key.is_a?(Key)
10
10
 
11
- Encrypter.perform key.private_hex, password
11
+ Encrypter.perform key.private_hex, password ,options
12
12
  end
13
13
 
14
14
  def self.decrypt(data, password)
@@ -16,9 +16,10 @@ module Platon
16
16
  new priv: priv
17
17
  end
18
18
 
19
- def self.encrypt_and_save(key,password,keypath=nil)
20
- encrypted_key_info = encrypt(key,password)
19
+ def self.encrypt_and_save(key,password,options={})
20
+ encrypted_key_info = encrypt(key,password,options)
21
21
  ## PlatON似乎打算兼容以太地址, 暂时默认以 0x 地址命名
22
+ keypath = options[:keypath]
22
23
  if keypath==nil || keypath==""
23
24
  address = key.address
24
25
  dirname = "#{ENV['HOME']}/.platon/keystore/"
@@ -30,7 +31,8 @@ module Platon
30
31
  return encrypted_key_info
31
32
  end
32
33
 
33
- def self.list_wallets(keypath=nil)
34
+ def self.list_wallets(options={})
35
+ keypath = options[:keypath]
34
36
  if keypath==nil || keypath==""
35
37
  Dir.glob("#{ENV['HOME']}/.platon/keystore/*").select { |e| File.file? e }
36
38
  else
@@ -64,8 +66,8 @@ module Platon
64
66
  Utils.public_key_to_address public_hex
65
67
  end
66
68
 
67
- def bech32_address(hrp:"atp")
68
- Utils.to_bech32_address(hrp,address) ##TODO
69
+ def bech32_address(hrp:"lat")
70
+ Utils.to_bech32_address(hrp,address)
69
71
  end
70
72
  alias_method :to_address, :address
71
73
 
@@ -122,7 +122,7 @@ class Platon::Key::Encrypter
122
122
  end
123
123
 
124
124
  def address
125
- Platon::Key.new(priv: key).address
125
+ Platon::Key.new(priv: key).bech32_address(hrp: options[:hrp] ? options[:hrp]:"atp")
126
126
  end
127
127
 
128
128
  end
@@ -9,7 +9,7 @@ module Platon
9
9
  ffi_lib 'libeay32', 'ssleay32'
10
10
  else
11
11
  ffi_lib [
12
- 'libssl.so.1.1.0', 'libssl.so.1.1',
12
+ 'libssl.so.1.1.0', 'libssl.so.1.1', 'libssl.1.1',
13
13
  'libssl.so.1.0.0', 'libssl.so.10',
14
14
  'ssl'
15
15
  ]
@@ -55,22 +55,21 @@ module Platon
55
55
  # @return [Integer] version number as an integer.
56
56
  def self.version
57
57
  if self.respond_to?(:OpenSSL_version_num)
58
- OpenSSL_version_num()
58
+ OpenSSL_version_num()
59
59
  else
60
- SSLeay()
60
+ # Hardcode here: OpenSSL verson > 1.1 should < 269484032 . But on MacOS ,version 1.0.2 ,SSLeay returns 536870912 ,that is v2.0.0
61
+ [SSLeay(),269484031].min
61
62
  end
62
63
  end
63
64
 
64
- # if version >= VERSION_1_1_0_NUM
65
-
66
- # # Initialization procedure for the library was changed in OpenSSL 1.1.0
67
- # attach_function :OPENSSL_init_ssl, [:uint64, :pointer], :int
68
- # else
69
-
65
+ if version >= VERSION_1_1_0_NUM
66
+ # Initialization procedure for the library was changed in OpenSSL 1.1.0
67
+ attach_function :OPENSSL_init_ssl, [:uint64, :pointer], :int
68
+ else
70
69
  attach_function :SSL_library_init, [], :int
71
70
  attach_function :ERR_load_crypto_strings, [], :void
72
71
  attach_function :SSL_load_error_strings, [], :void
73
- # end
72
+ end
74
73
 
75
74
  attach_function :RAND_poll, [], :int
76
75
  attach_function :BN_CTX_free, [:pointer], :int
@@ -227,16 +226,16 @@ module Platon
227
226
  def init_ffi_ssl
228
227
  return if @ssl_loaded
229
228
 
230
- # if version >= VERSION_1_1_0_NUM
231
- # OPENSSL_init_ssl(
232
- # OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_ENGINE_ALL_BUILTIN,
233
- # nil
234
- # )
235
- # else
229
+ if version >= VERSION_1_1_0_NUM
230
+ OPENSSL_init_ssl(
231
+ OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_ENGINE_ALL_BUILTIN,
232
+ nil
233
+ )
234
+ else
236
235
  SSL_library_init()
237
236
  ERR_load_crypto_strings()
238
237
  SSL_load_error_strings()
239
- # end
238
+ end
240
239
 
241
240
  RAND_poll()
242
241
  @ssl_loaded = true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Platon
4
- VERSION = "0.2.7"
4
+ VERSION = "0.2.9"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - vianull
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-01 00:00:00.000000000 Z
11
+ date: 2021-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -169,10 +169,12 @@ files:
169
169
  - bin/console
170
170
  - bin/setup
171
171
  - doc/zh-cn.md
172
- - lib/bech32.rb
172
+ - examples/generate_keys.rb
173
+ - examples/get_balance.rb
173
174
  - lib/platon.rb
174
175
  - lib/platon/abi.rb
175
176
  - lib/platon/address.rb
177
+ - lib/platon/bech32.rb
176
178
  - lib/platon/client.rb
177
179
  - lib/platon/contract.rb
178
180
  - lib/platon/contract_event.rb
@@ -207,7 +209,6 @@ files:
207
209
  - lib/tasks/platon_contract.rake
208
210
  - platon-ruby-logo.png
209
211
  - platon.gemspec
210
- - platon.gemspec.bak
211
212
  homepage:
212
213
  licenses:
213
214
  - MIT