multichain 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 0234d57073bac6f7b3f58e32f9a0364d1e1cb798
4
- data.tar.gz: 912d714a79d55990883c25e14ba43165779e1e2d
3
+ metadata.gz: 4ba3f8178158cbc38798749613e6149ca4fe0e62
4
+ data.tar.gz: ee9101315fe3f0e89179e131bc09fb0f63806a4a
5
5
  SHA512:
6
- metadata.gz: 757d4f3b949ab4b16280bd0d10995c6e8ef419e816eb6c1c519957b3e7bdabfb3e3f562d762ae235cabf7aae23b15fdf3b3e1f4c42bcb04b7d617495ccb5bd05
7
- data.tar.gz: c208a76215fc824a1400284f3a7435abf028581f37f5e090c665bf6c5a4335b971e678b5e03a03aeeb2958c7395adaed4d178d2d938066c0edb0c09c839d8613
6
+ metadata.gz: 4df5ddabab46d3d82124bab52986a29cad5a0d0f0b3bd2fdafeba36bdce7f354d56d05cb9212800452daff7a17c1142c485c3a32213b9e740d9ef94d68d4b167
7
+ data.tar.gz: 81e335ae4e289e923e49dd3ce67b60d10aca6a4cf38846cd50f05810b52ba153add2b75e892f953daa76d601a97f3f9a274e3d6e6b77d5a40c7c2205ea025de8
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .env
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
2
  --color
3
+ --require spec_helper
data/.travis.yml CHANGED
@@ -1,4 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.0
3
+ - 2.3.0
4
4
  cache: bundler
5
+ env:
6
+ global:
7
+ - secure: INcK2xF5wwTikZ8C8T1wRSLODrTlwb+Y5ekHurzMHpuAEPaL4TdQp0ebh0RR9IMwy3ZVYFl+wD2gDDEF+HG5NyT85+3naFInmMt53S+hKwlLbTIYCrEEQEMNu8WJo65CPQAdemV6/VXxRXxOBV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trOh5fF3J1yilOjnKe7N9PcpZ+IXyVlDk2Gpf/8Xk2hSGAdwTwgUwE/ReBLoKJ/31BC/UdPdmnYDh7AvLZh6U9IXULincgCNL5O3AWy5C/V4P7aKPq93kyRVViGcnWxNjMnO38SWaD8idX9Fceqc2Ho2qDAcYs4m61blIExfzPGBqZSfxRU/l88wz0yhy2bQh0yfBnm/BqIhoujmcJxT/Yzck/B8U1zLIMdR4pbZnhbFPipy4QExPzMSd/r0T2prS+a6cMbao4gFx3WbZr2e4yIlxa6DJe/1qbIdsPJrdxkDRriTRrtIQMJL66mBbnXkIDPaYeqCPPc5XQa+LMqK4Bt/covUAYVZVGELUBwSWQGufIuKZQxUNaxAaX5utTV2+JqNh0Z9ZFhXcuH2ayiXWYSoKyEA6S0VG+mnFxIcYHyYyLq1L2Ol8aDI=
data/Guardfile CHANGED
@@ -12,12 +12,3 @@ guard :rspec, cmd: 'bundle exec rspec' do
12
12
  ruby = dsl.ruby
13
13
  dsl.watch_spec_files_for(ruby.lib_files)
14
14
  end
15
-
16
- guard 'cucumber' do
17
- watch(%r{^features/.+\.feature$})
18
- watch(%r{^features/support/.+$}) { 'features' }
19
-
20
- watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
21
- Dir[File.join("**/#{m[1]}.feature")][0] || 'features'
22
- end
23
- end
data/Rakefile CHANGED
@@ -1,10 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
- require 'coveralls/rake/task'
4
- require 'cucumber/rake/task'
5
3
 
6
- Coveralls::RakeTask.new
7
4
  RSpec::Core::RakeTask.new(:spec)
8
- Cucumber::Rake::Task.new
9
5
 
10
- task :default => [:spec, :cucumber, 'coveralls:push']
6
+ task :default => [:spec]
@@ -0,0 +1,7 @@
1
+ require 'multichain'
2
+
3
+ c = Multichain::Client.new 'multichainrpc', '55nGoc9SbM6Usz3EcWfG8iXYNNqA1Y5MFGNt2d4VpT8V', 'chain.theodi.org'
4
+
5
+ mess = c.help['result'].split "\n"
6
+
7
+ puts mess
@@ -0,0 +1,12 @@
1
+ sendassettoaddress:
2
+ - address
3
+ - asset
4
+ - amount
5
+ # c.sendassettoaddress ['1JHkJyBijsUFB2KF6dKwFugcBqDcztLP5E6Eff', 'odi-coin', 1]
6
+
7
+ sendwithmetadata:
8
+ - address
9
+ - asset:
10
+ amount
11
+ - metadata
12
+ # c.sendwithmetadata ["1JHkJyBijsUFB2KF6dKwFugcBqDcztLP5E6Eff", {"odi-coin"=>1}, "313435323030393837397c687474703a2f2f6d6574726963732e7468656f64692e6f72672f6d6574726963732e6a736f6e7c7b22416363657074223a226170706c69636174696f6e2f6a736f6e227d7c62383330636561313062653632383438343362313432376630623436633964343966623166656265373261633436373831653265633330386630326562343861"]
data/lib/multichain.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'httparty'
2
2
  require 'thor'
3
+ require 'yaml'
3
4
 
4
5
  require 'multichain/cli'
6
+ require 'multichain/client'
5
7
  require 'multichain/encoder'
8
+ require 'multichain/wallets'
6
9
  require 'multichain/version'
@@ -27,13 +27,34 @@ module Multichain
27
27
 
28
28
  case v
29
29
  when true
30
- puts "'#{url}' is verified"
31
- exit 0
30
+ puts "The URL '#{url}' is verified"
31
+ exit 0 unless ENV['TEST']
32
32
 
33
33
  when false
34
- puts "'#{url}' is not verified"
35
- exit 1
34
+ puts "The URL '#{url}' is not verified"
35
+ exit 1 unless ENV['TEST']
36
36
  end
37
37
  end
38
+
39
+ desc 'send_url recipient, URL', 'Send a URL to a recipient'
40
+ def send_url recipient, url
41
+ data = Client.new.send_url recipient, url
42
+ out = "You sent '#{url}' to '#{recipient}'\n"
43
+ out << "\n"
44
+ out << "The transaction id is\n"
45
+ out << " #{data[:id]}\n"
46
+ out << "\n"
47
+ out << "The URL\n"
48
+ out << " #{url}\n"
49
+ out << "hashed to\n"
50
+ out << " #{data[:hash]}\n"
51
+ out << "at\n"
52
+ out << " #{Time.at(data[:timestamp].to_i).to_datetime}\n"
53
+ out << "\n"
54
+ out << "Verify the hash with\n"
55
+ out << " multichain verify #{data[:hex]}\n"
56
+
57
+ puts out
58
+ end
38
59
  end
39
60
  end
@@ -0,0 +1,122 @@
1
+ module Multichain
2
+ class Client
3
+
4
+ def initialize
5
+ @username = config['rpc']['user']
6
+ @password = config['rpc']['password']
7
+ @host = config['rpc']['host']
8
+ @port = config['rpc']['port']
9
+ end
10
+
11
+ def auth
12
+ "#{@username}:#{@password}"
13
+ end
14
+
15
+ def url
16
+ "http://#{auth}@#{@host}:#{@port}"
17
+ end
18
+
19
+ def config
20
+ config_file = "#{ENV['HOME']}/.multichain/config.yml"
21
+ config_file = 'spec/support/fixtures/config.yml' if ENV['TEST']
22
+ @config ||= begin
23
+ c = YAML.load_file config_file
24
+ if ENV['TEST']
25
+ c['rpc'] = {}
26
+ c['rpc']['user'] = ENV['RPC_USER']
27
+ c['rpc']['password'] = ENV['RPC_PASSWORD']
28
+ c['rpc']['host'] = ENV['RPC_HOST']
29
+ c['rpc']['port'] = ENV['RPC_PORT']
30
+ end
31
+
32
+ c
33
+ end
34
+ end
35
+
36
+ def asset
37
+ config['asset']
38
+ end
39
+
40
+ def wallets
41
+ @wallets ||= Wallets.new
42
+ end
43
+
44
+ def send_asset recipient, amount
45
+ params = [
46
+ wallets.fetch(recipient),
47
+ asset,
48
+ amount
49
+ ]
50
+
51
+ s = sendassettoaddress params
52
+
53
+ {
54
+ recipient: recipient,
55
+ asset: asset,
56
+ amount: amount,
57
+ id: s['result']
58
+ }
59
+ end
60
+
61
+ def send_asset_with_data recipient, amount, data
62
+ params = [
63
+ wallets.fetch(recipient),
64
+ {asset => amount},
65
+ data
66
+ ]
67
+
68
+ s = sendwithmetadata params
69
+
70
+ {
71
+ recipient: recipient,
72
+ asset: asset,
73
+ amount: amount,
74
+ data: data,
75
+ id: s['result']
76
+ }
77
+ end
78
+
79
+ def send_url recipient, url
80
+ hex = Encoder.hexify url
81
+ params = [
82
+ wallets.fetch(recipient),
83
+ {asset => 0},
84
+ hex
85
+ ]
86
+
87
+ s = sendwithmetadata params
88
+ data = Encoder.extract Encoder.decode hex
89
+
90
+ {
91
+ recipient: recipient,
92
+ url: url,
93
+ hash: data[:hash],
94
+ timestamp: data[:timestamp],
95
+ hex: hex,
96
+ id: s['result']
97
+ }
98
+ end
99
+
100
+ def method_missing(sym, params = [])
101
+ request = build_request(sym.to_s, params)
102
+ send_request(request)
103
+ end
104
+
105
+ private
106
+
107
+ def build_request(method, params)
108
+ {
109
+ method: method,
110
+ params: params,
111
+ id: SecureRandom.uuid
112
+ }.to_json
113
+ end
114
+
115
+ def send_request(request)
116
+ post = HTTParty.post(url, body: request, headers: {"Content-Type" => "application/json"})
117
+ response = post.body
118
+ JSON.parse(response)
119
+ end
120
+
121
+ end
122
+ end
@@ -1,3 +1,3 @@
1
1
  module Multichain
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,17 @@
1
+ module Multichain
2
+ class Wallets < Hash
3
+ def initialize
4
+ yaml_path = "#{ENV['HOME']}/.multichain/wallets.yml"
5
+ yaml_path = 'spec/support/fixtures/wallets.yml' if ENV['TEST']
6
+ self.update YAML.load_file yaml_path
7
+ end
8
+
9
+ def fetch key
10
+ keys = key.split ':'
11
+ if keys[1]
12
+ return self[keys[0]][keys[1]]
13
+ end
14
+ self[key][self[key].keys[0]]
15
+ end
16
+ end
17
+ end
data/multichain.gemspec CHANGED
@@ -29,11 +29,9 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'webmock', '~> 1.22'
30
30
  spec.add_development_dependency 'coveralls', '~> 0.8'
31
31
  spec.add_development_dependency 'timecop', '~> 0.8'
32
- spec.add_development_dependency 'guard-rspec', '~> 4.6'
33
- spec.add_development_dependency 'cucumber', '~> 2.1'
34
- spec.add_development_dependency 'aruba', '~> 0.12'
35
32
  spec.add_development_dependency 'guard', '~> 2.13'
36
- spec.add_development_dependency 'guard-cucumber', '~> 2.0'
33
+ spec.add_development_dependency 'guard-rspec', '~> 4.6'
37
34
  spec.add_development_dependency 'terminal-notifier-guard', '~> 1.6'
35
+ spec.add_development_dependency 'dotenv', '~> 2.0'
38
36
  spec.add_development_dependency 'pry'
39
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multichain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pikesley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-05 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -137,63 +137,49 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.8'
139
139
  - !ruby/object:Gem::Dependency
140
- name: guard-rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '4.6'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '4.6'
153
- - !ruby/object:Gem::Dependency
154
- name: cucumber
140
+ name: guard
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: '2.1'
145
+ version: '2.13'
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
- version: '2.1'
152
+ version: '2.13'
167
153
  - !ruby/object:Gem::Dependency
168
- name: aruba
154
+ name: guard-rspec
169
155
  requirement: !ruby/object:Gem::Requirement
170
156
  requirements:
171
157
  - - "~>"
172
158
  - !ruby/object:Gem::Version
173
- version: '0.12'
159
+ version: '4.6'
174
160
  type: :development
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
164
  - - "~>"
179
165
  - !ruby/object:Gem::Version
180
- version: '0.12'
166
+ version: '4.6'
181
167
  - !ruby/object:Gem::Dependency
182
- name: guard
168
+ name: terminal-notifier-guard
183
169
  requirement: !ruby/object:Gem::Requirement
184
170
  requirements:
185
171
  - - "~>"
186
172
  - !ruby/object:Gem::Version
187
- version: '2.13'
173
+ version: '1.6'
188
174
  type: :development
189
175
  prerelease: false
190
176
  version_requirements: !ruby/object:Gem::Requirement
191
177
  requirements:
192
178
  - - "~>"
193
179
  - !ruby/object:Gem::Version
194
- version: '2.13'
180
+ version: '1.6'
195
181
  - !ruby/object:Gem::Dependency
196
- name: guard-cucumber
182
+ name: dotenv
197
183
  requirement: !ruby/object:Gem::Requirement
198
184
  requirements:
199
185
  - - "~>"
@@ -206,20 +192,6 @@ dependencies:
206
192
  - - "~>"
207
193
  - !ruby/object:Gem::Version
208
194
  version: '2.0'
209
- - !ruby/object:Gem::Dependency
210
- name: terminal-notifier-guard
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: '1.6'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: '1.6'
223
195
  - !ruby/object:Gem::Dependency
224
196
  name: pry
225
197
  requirement: !ruby/object:Gem::Requirement
@@ -253,10 +225,14 @@ files:
253
225
  - bin/console
254
226
  - bin/multichain
255
227
  - bin/setup
228
+ - command_fetcher.rb
229
+ - config/commands.yml
256
230
  - lib/multichain.rb
257
231
  - lib/multichain/cli.rb
232
+ - lib/multichain/client.rb
258
233
  - lib/multichain/encoder.rb
259
234
  - lib/multichain/version.rb
235
+ - lib/multichain/wallets.rb
260
236
  - multichain.gemspec
261
237
  homepage: http://github.com/theodi
262
238
  licenses: