etheruby 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/etheruby.rb +1 -0
- data/lib/etheruby/configuration.rb +15 -0
- data/lib/etheruby/contract.rb +13 -20
- data/lib/etheruby/railtie.rb +11 -6
- data/tasks/etheruby/etheruby.yml +4 -0
- data/tasks/etheruby/setup.task +9 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1a876972cf55f4558f1fc345718c70f356cafbc
|
4
|
+
data.tar.gz: bf1a77caf62874d48134b0a878179385b509297b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d51f05ba07bab799c41a86394c6443ca90d9f78e099a2763655bbe876c7730ee718c62c94923e07ee4f4ee8a63fac7769d8bd8d7558cccefe9614c233d5a606
|
7
|
+
data.tar.gz: 137e7ea4cb2a7e63698d6abd7a4c2bce1019aed8b9fc8a875971a8011e42343e73a3a8312977ac6f5b25872ac39b0dec53260242c9e34be474b9e1ce1c795354
|
data/lib/etheruby.rb
CHANGED
data/lib/etheruby/contract.rb
CHANGED
@@ -7,21 +7,6 @@ module Etheruby
|
|
7
7
|
class NoContractMethodError < StandardError; end
|
8
8
|
class NoPasswordForAddress < StandardError; end
|
9
9
|
|
10
|
-
class TransactionInformation
|
11
|
-
@@info = nil
|
12
|
-
def self.information=(_info)
|
13
|
-
@@info = _info
|
14
|
-
end
|
15
|
-
def self.set?() @@set end
|
16
|
-
def self.default_from() @@info[:default_from] end
|
17
|
-
def self.address_password(address)
|
18
|
-
unless @@info
|
19
|
-
raise NoPasswordForAddress.new("No password for address #{address}")
|
20
|
-
end
|
21
|
-
@@info[:addresses][address]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
10
|
def contract
|
26
11
|
Class.new do
|
27
12
|
def self.inherited(subclass)
|
@@ -95,17 +80,25 @@ module Etheruby
|
|
95
80
|
end
|
96
81
|
|
97
82
|
def self.do_eth_call(composed_body)
|
98
|
-
Client.eth.call(composed_body, "latest")
|
83
|
+
Client.eth.call(composed_body, Configuration.default_height || "latest")
|
99
84
|
end
|
100
85
|
|
101
86
|
def self.do_eth_transaction(composed_body)
|
102
|
-
from_address = composed_body[:from] ||
|
103
|
-
pwd =
|
104
|
-
|
87
|
+
from_address = composed_body[:from] || Configuration.default_from
|
88
|
+
pwd = Configuration.addresses[from_address]
|
89
|
+
Client.personal.sendTransaction(composed_body.merge({from: address_fix(from_address)}), pwd)
|
105
90
|
end
|
106
91
|
|
107
92
|
def self.address
|
108
|
-
|
93
|
+
address_fix(@@address)
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.address_fix(addr)
|
97
|
+
if addr.is_a? ::String
|
98
|
+
addr
|
99
|
+
else
|
100
|
+
"0x#{@@address.to_s(16)}"
|
101
|
+
end
|
109
102
|
end
|
110
103
|
end
|
111
104
|
end
|
data/lib/etheruby/railtie.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
Dir["./app/contracts/**/*.rb"].each { |f| require f }
|
2
2
|
|
3
|
+
require 'yaml'
|
4
|
+
|
3
5
|
module Etheruby
|
4
6
|
|
5
7
|
class Railtie < Rails::Railtie
|
8
|
+
# Loads configuration
|
6
9
|
initializer "etheruby.configure" do |app|
|
7
|
-
if
|
8
|
-
|
10
|
+
Etheruby::Configuration.conf = if File.exist? './config/etheruby.yml'
|
11
|
+
YAML.load_file('./config/etheruby.yml')
|
12
|
+
else
|
13
|
+
{}
|
9
14
|
end
|
15
|
+
end
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
17
|
+
# Create setup rake task
|
18
|
+
rake_tasks do
|
19
|
+
load File.join(File.dirname(__FILE__), '../../tasks/etheruby/setup.task')
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
namespace :etheruby do
|
2
|
+
desc "Creates etheruby scaffold for rails"
|
3
|
+
task :setup => :environment do
|
4
|
+
require 'fileutils'
|
5
|
+
FileUtils.mkdir('./app/contracts') unless Dir.exist? './app/contracts'
|
6
|
+
FileUtils.touch('./app/contracts/.keep')
|
7
|
+
FileUtils.cp(File.join(File.dirname(__FILE__), 'etheruby.yml'), './config/etheruby.yml')
|
8
|
+
end
|
9
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etheruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jérémy SEBAN
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/etheruby.rb
|
91
91
|
- lib/etheruby/arguments_generator.rb
|
92
92
|
- lib/etheruby/client.rb
|
93
|
+
- lib/etheruby/configuration.rb
|
93
94
|
- lib/etheruby/contract.rb
|
94
95
|
- lib/etheruby/contract_method_dsl.rb
|
95
96
|
- lib/etheruby/encoders/address.rb
|
@@ -106,6 +107,8 @@ files:
|
|
106
107
|
- lib/etheruby/response_parser.rb
|
107
108
|
- lib/etheruby/treat_variable.rb
|
108
109
|
- lib/etheruby/type_matchers.rb
|
110
|
+
- tasks/etheruby/etheruby.yml
|
111
|
+
- tasks/etheruby/setup.task
|
109
112
|
homepage: https://github.com/MechanicalSloth/etheruby
|
110
113
|
licenses:
|
111
114
|
- MIT
|