epm 0.3.8 → 0.3.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
  SHA1:
3
- metadata.gz: c8e8e2cd6ae1fdc92666e3e948a009218c7f8358
4
- data.tar.gz: c7665f92c40968a6c79114733dbaf3845ecf00d8
3
+ metadata.gz: ef982ea31708c1c2a67a0a5ba911a8e375824da7
4
+ data.tar.gz: 4889a8909a63e22e9a42a9af9db25b30389dce1b
5
5
  SHA512:
6
- metadata.gz: f655e176c87bb35b0764f3b3727788e5ec7fdef3f6084d1b9a29b589fdcbe13099727672f005c95c5804faa761b7456094fcd815cd69980b7d8f827a00c6fe4c
7
- data.tar.gz: 44e925b9ef94f08c268487a1277dbfdf27dad679244fae2119e810a8432bd3d8e4d4fdc62713b8249ee8639784a8fefdf36b404c9c1f968df6f6a06179a260c8
6
+ metadata.gz: 4e1c9ffc5d92040d36ae42a340f576e8df39c720834b686b777e9fd686253521db7b124db6f81a0ba97a8d6e228d46cebf824139c1a5b4093e88866ef70d1207
7
+ data.tar.gz: 4772ba7447a951758197988da76aa45b9a057fa90c0c5a00899494faab49b7baf0db4f3fd5490270b993fda5138c28ba4ec97fbcb0d194f75ccb990b75f4835f
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Stories in Ready](https://badge.waffle.io/project-douglas/epm.png?label=ready&title=Ready)](https://waffle.io/project-douglas/epm)
1
2
  # Introduction
2
3
 
3
4
  EPM is a package (provision?) manager. It is meant to simplify the management of git hosted repositories which contain Ethereum standard or customized contracts. This package manager should work in the way which most package managers operate -- with the addition that it will be able to interact with the Ethereum BlockChain.
data/bin/epm CHANGED
@@ -54,6 +54,25 @@ command :query do |c|
54
54
  end
55
55
  end
56
56
 
57
+ command :rpc do |c|
58
+ c.syntax = 'epm rpc [method] [...args...]'
59
+ c.description = 'RPC json query, keywords map to elements in it.'
60
+ c.option '--a ADDRESS', String, 'Some address.'
61
+ c.option '--x VALUE', String, 'Some value.'
62
+ c.option '--s STRING', String, 'Some string, for lll, lll code.'
63
+ c.option '--aDest ADDRESS', String, 'Destination address.'
64
+ c.option '--bData HEX', String, 'Hex data.'
65
+ c.option '--sec HEX', String, 'Private key. (yikes! chill, its testnet)'
66
+ c.option '--xGas VALUE', String, 'Gas budget.'
67
+ c.option '--xGasPrice VALUE', String, 'Gas price offered.'
68
+ c.option '--xValue VALUE', String, 'ethers along with transaction.'
69
+ c.option '--bCode HEX', String, 'Binary code as hex value.'
70
+ c.option '--xEndowment VALUE', String, 'Ethers to give a created contract.'
71
+ c.action do |args, opts|
72
+ print "#{EPM.rpc args, opts}\n"
73
+ end
74
+ end
75
+
57
76
  command :start do |c|
58
77
  c.syntax = 'epm start'
59
78
  c.description = 'Start your default ethereum server.'
@@ -82,4 +101,4 @@ command :restart do |c|
82
101
  EPM.restart
83
102
  print "Server has been restarted.\n"
84
103
  end
85
- end
104
+ end
data/lib/epm.rb CHANGED
@@ -54,6 +54,19 @@ module EPM
54
54
  EPM::Query.new(address, position, settings).query
55
55
  end
56
56
 
57
+ def rpc args, opts
58
+ name = args.shift
59
+ arg_list = EPM::RPC.rpc_arg_list name
60
+ opt_vals = { # `opts.instance_variable_get` doesnt seem to work, nor `opts.send`
61
+ 'a' => opts.a, 'x' => opts.x,'s' => opts.s, 'aDest' => opts.aDest,
62
+ 'bData' => opts.bData, 'sec' => opts.sec, 'xGas' => opts.xGas,
63
+ 'xGasPrice' => opts.xGasPrice, 'xValue' => opts.xValue,
64
+ 'bCode' => opts.bCode,'xEndowment' => opts.xEndowment
65
+ }
66
+ params = EPM::RPC.rpc_from_args name, arg_list, args, opt_vals
67
+ return EPM::RPC.post_rpc_with_params name, params
68
+ end
69
+
57
70
  def version
58
71
  return VERSION
59
72
  end
@@ -74,4 +87,4 @@ module EPM
74
87
  def setup
75
88
  return EPM::Settings.check
76
89
  end
77
- end
90
+ end
data/lib/epm/rpc.rb ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # General RPC command handler
4
+
5
+ module EPM
6
+
7
+ module RPC
8
+ extend self
9
+
10
+ # Returns the default, given other inputs.
11
+ def rpc_default name, arg_name, params
12
+ case arg_name
13
+ when 'aOrigin'
14
+ return (EPM::setup)['address-public-key']
15
+ when 'aSender'
16
+ return (params['aOrigin'] or (EPM::setup)['address-public-key'])
17
+ when 'xValue', 'bData'
18
+ return ''
19
+ when 'xGas'
20
+ return '100000'
21
+ when 'xGasPrice'
22
+ return '100000000000000'
23
+ end
24
+ end
25
+
26
+ # Returns the argument list under a particular method.
27
+ def rpc_arg_list name
28
+ case name
29
+ when 'transact'
30
+ return [["aDest", :a], ["bData", :d], ["sec", :p],
31
+ ["xGas", :v], ["xGasPrice", :v], ["xValue", :v]]
32
+ when 'create'
33
+ return [["bCode", :d], ["sec", :p], ["xEndowment", :v],
34
+ ["xGas", :v], ["xGasPrice", :v]]
35
+ when 'storageAt'
36
+ return [['a', :a], ['x', :i]]
37
+ when 'lll'
38
+ return [['s', :s]]
39
+ when 'balanceAt', 'check', 'isContractAt', 'secretToAddress', 'txCountAt'
40
+ return [['a', :a]]
41
+ when 'block', 'coinbase', 'gasPrice', 'isListening', 'isMining',
42
+ 'key', 'keys', 'lastBlock', 'peerCount', 'procedures'
43
+ return []
44
+ else
45
+ return 'Unknown RPC command.'
46
+ end
47
+ end
48
+
49
+ def post_rpc_with_params name, params
50
+ # TODO ethereal compatibility here?
51
+
52
+ return post_rpc 'method' => name, 'params' => params,
53
+ 'id' => 'epm-rpc', 'jsonrpc' => '2.0'
54
+ end
55
+
56
+ def post_rpc post_body
57
+ url = URI.parse "http://localhost:#{(EPM::setup)['json-port']}"
58
+ return EPM::Server.http_post_request url, post_body.to_json
59
+ end
60
+
61
+ # Takes actual option map and argument list to determine `params`.
62
+ def rpc_from_args name, method, args, opt_vals
63
+ params = {}
64
+ for a in method # Go through all arguments, and use them.(keywords before real)
65
+ val = (opt_vals[a[0]] or args.shift)
66
+ if val != nil && val != ''
67
+ case a[1] # Respond to kind of parameter.
68
+ when :d, :p, :v, :i
69
+ params[a[0]] = val
70
+ when :a
71
+ params[a[0]] = (EPM::HexData.hex_guard val)
72
+ else
73
+ raise 'Unidentified kind of data'
74
+ end
75
+ else
76
+ params[a[0]] = rpc_default(name, a[0], params)
77
+ end
78
+ end
79
+ return params
80
+ end
81
+ end # end RPC
82
+ end
data/lib/epm/version.rb CHANGED
@@ -1 +1 @@
1
- VERSION ||= "0.3.8"
1
+ VERSION ||= "0.3.9"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey Kuhlman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-13 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -46,6 +46,7 @@ files:
46
46
  - lib/epm/create.rb
47
47
  - lib/epm/deploy.rb
48
48
  - lib/epm/query.rb
49
+ - lib/epm/rpc.rb
49
50
  - lib/epm/transact.rb
50
51
  - lib/epm/utils.rb
51
52
  - lib/epm/version.rb