coloredcoins 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/Gemfile +3 -0
- data/lib/coloredcoins.rb +6 -1
- data/lib/coloredcoins/connection.rb +7 -3
- data/lib/coloredcoins/multisig_tx.rb +2 -3
- data/lib/coloredcoins/version.rb +1 -1
- data/spec/coloredcoins/connection_spec.rb +6 -2
- data/spec/coloredcoins_spec.rb +55 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40f72c8e938e9f3342eef82b2056bbb8176fb433
|
4
|
+
data.tar.gz: ce500a133e9c5febfacd849ad05c41e19989c9ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6667d99867bfb7cf98e6c6bcea8040eb8ab397209267d665b77980aa53a1b72ccb94ea50d11cd9c83ae0bf9d5dc1450224944168cd10208da25232aaa73d4936
|
7
|
+
data.tar.gz: 455537aab1c344785b7aff34a1eac41169f53800475da392c55425194970aa5c74fbded32825107037a48dbf0c5a6dbfec2018af12c9da6966129181fc4675d1
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/lib/coloredcoins.rb
CHANGED
@@ -34,6 +34,11 @@ module Coloredcoins
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.method_missing(sym, *args, &block)
|
37
|
-
api.send(sym, *args, &block)
|
37
|
+
return api.send(sym, *args, &block) if api.respond_to?(sym)
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.respond_to_missing?(method_name, include_private = false)
|
42
|
+
api.respond_to?(method_name) || super
|
38
43
|
end
|
39
44
|
end
|
@@ -16,13 +16,17 @@ module Coloredcoins
|
|
16
16
|
query :post, path, payload
|
17
17
|
end
|
18
18
|
|
19
|
-
def query(method, path, payload = {})
|
19
|
+
def query(method, path, payload = {}) # rubocop:disable Metrics/MethodLength
|
20
20
|
uri = endpoint_uri(path)
|
21
21
|
response = RestClient::Request.execute(
|
22
22
|
method: method,
|
23
23
|
url: uri,
|
24
|
-
payload: payload,
|
25
|
-
ssl_version: 'SSLv23'
|
24
|
+
payload: payload.to_json,
|
25
|
+
ssl_version: 'SSLv23',
|
26
|
+
headers: {
|
27
|
+
content_type: :json,
|
28
|
+
accept: :json
|
29
|
+
}
|
26
30
|
)
|
27
31
|
JSON.parse(response, symbolize_names: true)
|
28
32
|
rescue RestClient::ExceptionWithResponse => e
|
@@ -32,9 +32,8 @@ module Coloredcoins
|
|
32
32
|
|
33
33
|
def check
|
34
34
|
raise ArgumentError, 'Set "m" before signing' unless multisig.m
|
35
|
-
if
|
36
|
-
|
37
|
-
end
|
35
|
+
return true if multisig.pub_keys || multisig.redeem_script
|
36
|
+
raise ArgumentError, 'Set "pub_keys" or "redeem_script" before signing'
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
data/lib/coloredcoins/version.rb
CHANGED
@@ -7,8 +7,12 @@ describe Coloredcoins::Connection do
|
|
7
7
|
{
|
8
8
|
method: nil,
|
9
9
|
url: "#{base_url}#{path}",
|
10
|
-
payload: payload,
|
11
|
-
ssl_version: 'SSLv23'
|
10
|
+
payload: payload.to_json,
|
11
|
+
ssl_version: 'SSLv23',
|
12
|
+
headers: {
|
13
|
+
content_type: :json,
|
14
|
+
accept: :json
|
15
|
+
}
|
12
16
|
}
|
13
17
|
end
|
14
18
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
describe Coloredcoins do
|
2
|
+
describe '#issue_asset' do
|
3
|
+
it 'should call the API' do
|
4
|
+
allow(Coloredcoins.api).to receive(:issue_asset)
|
5
|
+
Coloredcoins.issue_asset({})
|
6
|
+
expect(Coloredcoins.api).to have_received(:issue_asset)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#send_asset' do
|
11
|
+
it 'should call the API' do
|
12
|
+
allow(Coloredcoins.api).to receive(:send_asset)
|
13
|
+
Coloredcoins.send_asset({})
|
14
|
+
expect(Coloredcoins.api).to have_received(:send_asset)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#broadcast' do
|
19
|
+
it 'should call the API' do
|
20
|
+
allow(Coloredcoins.api).to receive(:broadcast)
|
21
|
+
Coloredcoins.broadcast('tx_hex')
|
22
|
+
expect(Coloredcoins.api).to have_received(:broadcast)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#address_info' do
|
27
|
+
it 'should call the API' do
|
28
|
+
allow(Coloredcoins.api).to receive(:address_info)
|
29
|
+
Coloredcoins.address_info('address')
|
30
|
+
expect(Coloredcoins.api).to have_received(:address_info)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#asset_holders' do
|
35
|
+
it 'should call the API' do
|
36
|
+
allow(Coloredcoins.api).to receive(:asset_holders)
|
37
|
+
Coloredcoins.asset_holders('asset_id')
|
38
|
+
expect(Coloredcoins.api).to have_received(:asset_holders)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#asset_metadata' do
|
43
|
+
it 'should call the API' do
|
44
|
+
allow(Coloredcoins.api).to receive(:asset_metadata)
|
45
|
+
Coloredcoins.asset_metadata('asset_id', 'utxo')
|
46
|
+
expect(Coloredcoins.api).to have_received(:asset_metadata)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#some_undifined_method' do
|
51
|
+
it 'should not call the API' do
|
52
|
+
expect { Coloredcoins.some_undifined_method }.to raise_error(NoMethodError)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coloredcoins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genaro Madrid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03
|
11
|
+
date: 2016-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- spec/coloredcoins/api_spec.rb
|
187
187
|
- spec/coloredcoins/connection_spec.rb
|
188
188
|
- spec/coloredcoins/multisig_tx_spec.rb
|
189
|
+
- spec/coloredcoins_spec.rb
|
189
190
|
- spec/spec_helper.rb
|
190
191
|
homepage: https://github.com/genaromadrid/coloredcoins-ruby
|
191
192
|
licenses:
|
@@ -215,4 +216,5 @@ test_files:
|
|
215
216
|
- spec/coloredcoins/api_spec.rb
|
216
217
|
- spec/coloredcoins/connection_spec.rb
|
217
218
|
- spec/coloredcoins/multisig_tx_spec.rb
|
219
|
+
- spec/coloredcoins_spec.rb
|
218
220
|
- spec/spec_helper.rb
|