katapaty 1.0.3 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/katapaty/block.rb +2 -2
- data/lib/katapaty/configuration.rb +10 -3
- data/lib/katapaty/party.rb +17 -8
- data/lib/katapaty/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c57f564a612b8926401f895aa95f2849ad36387ea9ce14edf0a74e51aaa3a9e
|
4
|
+
data.tar.gz: 0a45df7a610a4c686a11316aaf6055bd1694d2e9767844c806be86006d131556
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64eca40df5cab8167fdb240acdb8d9cd168a42ed7638943940348fc82993b94e85e4fd7e39893d53b9161a93018470d6e6cc4cf4078b5d763a24f9ba56663bc6
|
7
|
+
data.tar.gz: 57e2cc8b1880c0c3d1d60b5dbe40f9ca195b443913d0d22806ccba2f4f46c3acd2443d62e8388f13f2dae531055cb52483efa67238c4379d6802cbb610d874dd
|
data/README.md
CHANGED
data/lib/katapaty/block.rb
CHANGED
@@ -7,7 +7,7 @@ module Katapaty
|
|
7
7
|
class << self
|
8
8
|
|
9
9
|
def request(method_name, params={})
|
10
|
-
client = RestClient::Resource.new Katapaty.configuration.
|
10
|
+
client = RestClient::Resource.new(Katapaty.configuration.counterblock_url, timeout: Katapaty.configuration.timeout)
|
11
11
|
request = { method: method_name, params: params, jsonrpc: '2.0', id: '0' }.to_json
|
12
12
|
response = JSON.parse client.post(
|
13
13
|
request,
|
@@ -25,7 +25,7 @@ module Katapaty
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def proxy_to_cp(method:, params: {})
|
28
|
-
client = RestClient::Resource.new Katapaty.configuration.
|
28
|
+
client = RestClient::Resource.new(Katapaty.configuration.counterblock_url, timeout: Katapaty.configuration.timeout)
|
29
29
|
request = { method: :proxy_to_counterpartyd, params: { method: method, params: params }, jsonrpc: '2.0', id: '0' }.to_json
|
30
30
|
response = JSON.parse client.post(
|
31
31
|
request,
|
@@ -8,20 +8,27 @@ module Katapaty
|
|
8
8
|
:block_password,
|
9
9
|
:block_host,
|
10
10
|
:block_port,
|
11
|
-
:ssl
|
11
|
+
:ssl,
|
12
|
+
:timeout
|
13
|
+
|
14
|
+
DEFAULT_TIMEOUT_IN_SECONDS = 120
|
12
15
|
|
13
16
|
def counterparty_url
|
14
17
|
return 'http://rpc:1234@public.coindaddy.io:14000/api/' unless @host
|
15
|
-
"#{protocol}://#{@username}:#{@password}@#{@host}:#{@port}/api/"
|
18
|
+
"#{protocol}://#{@username}:#{CGI.escape(@password)}@#{@host}:#{@port}/api/"
|
16
19
|
end
|
17
20
|
|
18
21
|
def counterblock_url
|
19
22
|
return 'http://rpc:1234@public.coindaddy.io:14100/api/' unless @block_host
|
20
23
|
authen = ''
|
21
|
-
authen = "#{@block_username}:#{@block_password}@" if @block_username
|
24
|
+
authen = "#{@block_username}:#{CGI.escape(@block_password)}@" if @block_username
|
22
25
|
"#{protocol}://#{authen}#{@block_host}:#{@block_port}/api/"
|
23
26
|
end
|
24
27
|
|
28
|
+
def timeout
|
29
|
+
@timeout || DEFAULT_TIMEOUT_IN_SECONDS
|
30
|
+
end
|
31
|
+
|
25
32
|
private
|
26
33
|
|
27
34
|
def protocol
|
data/lib/katapaty/party.rb
CHANGED
@@ -9,11 +9,20 @@ module Katapaty
|
|
9
9
|
request('get_running_info')
|
10
10
|
end
|
11
11
|
|
12
|
-
def address_token_balance(address
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
def address_token_balance(address:, token:, proxy: false)
|
13
|
+
filters_params = {
|
14
|
+
"filters": [
|
15
|
+
{ "field": 'address', "op": '==', "value": address },
|
16
|
+
{ "field": 'asset', "op": '==', "value": token }
|
17
|
+
]
|
18
|
+
}
|
19
|
+
if proxy
|
20
|
+
response = Katapaty::Block.proxy_to_cp(method: :get_balances, params: filters_params)
|
21
|
+
else
|
22
|
+
response = request('get_balances', filters_params)
|
23
|
+
end
|
24
|
+
return 0 if response.blank?
|
25
|
+
response.first['quantity'].to_i
|
17
26
|
end
|
18
27
|
|
19
28
|
def get_asset_info(assets)
|
@@ -45,11 +54,11 @@ module Katapaty
|
|
45
54
|
end
|
46
55
|
|
47
56
|
def request(method_name, payload={})
|
48
|
-
client = RestClient::Resource.new Katapaty.configuration.
|
57
|
+
client = RestClient::Resource.new(Katapaty.configuration.counterparty_url, timeout: Katapaty.configuration.timeout)
|
49
58
|
request = { method: method_name.to_s, params: payload, jsonrpc: '2.0', id: '0' }.to_json
|
50
59
|
response = JSON.parse client.post(request,
|
51
|
-
|
52
|
-
|
60
|
+
accept: 'json',
|
61
|
+
content_type: 'json' )
|
53
62
|
raise Katapaty::JsonResponseError.new response if response.has_key? 'code'
|
54
63
|
raise Katapaty::ResponseError.new response['error'] if response.has_key? 'error'
|
55
64
|
response['result']
|
data/lib/katapaty/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katapaty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- longhoang.wkm
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
-
description:
|
153
|
+
description:
|
154
154
|
email:
|
155
155
|
- longhoang@wakumo.vn
|
156
156
|
executables: []
|
@@ -178,7 +178,7 @@ homepage: https://github.com/longhoangwkm/katapaty
|
|
178
178
|
licenses:
|
179
179
|
- MIT
|
180
180
|
metadata: {}
|
181
|
-
post_install_message:
|
181
|
+
post_install_message:
|
182
182
|
rdoc_options: []
|
183
183
|
require_paths:
|
184
184
|
- lib
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
196
|
rubygems_version: 3.1.3
|
197
|
-
signing_key:
|
197
|
+
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: A ruby gem for communicating with a Counterparty (Bitcoin / XCP) API server
|
200
200
|
test_files: []
|