ethereum 0.4.62 → 0.4.65
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ethereum/contract.rb +22 -15
- data/lib/ethereum/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dccc79e9ed08f479e0b29a23b118219cc6a4279e
|
4
|
+
data.tar.gz: 6698a12c7b695fa55e5cbfef02cfe659e0bdf4a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc37866485be2014731cc2e909c013a02f3c0f6765fb2a1650644f3c4062f998de0775e579278538e721d674a05d5129cb6ea9c238bb2f1ee97a31a2b87d928e
|
7
|
+
data.tar.gz: 2a7370d6d0fba1ec25987e3dfb130dd081803b61b409cb207c7ca21c3d8720ec3cf1b5fd052ff3d0c1f0c1941f96190ea7d87a265773d34e574265df2043f9e1
|
data/lib/ethereum/contract.rb
CHANGED
@@ -22,7 +22,7 @@ module Ethereum
|
|
22
22
|
class_name = @name
|
23
23
|
functions = @functions
|
24
24
|
constructor_inputs = @constructor_inputs
|
25
|
-
|
25
|
+
binary = @code
|
26
26
|
|
27
27
|
class_methods = Class.new do
|
28
28
|
|
@@ -32,57 +32,61 @@ module Ethereum
|
|
32
32
|
|
33
33
|
define_method :deploy do |*params|
|
34
34
|
formatter = Ethereum::Formatter.new
|
35
|
+
deploy_code = binary
|
36
|
+
deploy_arguments = ""
|
35
37
|
if constructor_inputs.present?
|
36
38
|
raise "Missing constructor parameter" and return if params.length != constructor_inputs.length
|
37
39
|
constructor_inputs.each_index do |i|
|
38
40
|
args = [constructor_inputs[i]["type"], params[i]]
|
39
|
-
|
41
|
+
deploy_arguments << formatter.to_payload(args)
|
40
42
|
end
|
41
43
|
end
|
42
|
-
|
43
|
-
|
44
|
+
deploy_payload = deploy_code + deploy_arguments
|
45
|
+
puts "sending payload #{deploy_payload}"
|
46
|
+
deploytx = connection.send_transaction({from: self.sender, gas: 2000000, gasPrice: 60000000000, data: deploy_payload})["result"]
|
47
|
+
instance_variable_set("@deployment", Ethereum::Deployment.new(deploytx, connection))
|
44
48
|
end
|
45
49
|
|
46
50
|
define_method :deployment do
|
47
|
-
|
51
|
+
instance_variable_get("@deployment")
|
48
52
|
end
|
49
53
|
|
50
54
|
define_method :deploy_and_wait do |time = 60.seconds, *params|
|
51
55
|
self.deploy(*params)
|
52
56
|
self.deployment.wait_for_deployment(time)
|
53
|
-
|
57
|
+
instance_variable_set("@address", self.deployment.contract_address)
|
54
58
|
end
|
55
59
|
|
56
60
|
define_method :at do |addr|
|
57
|
-
|
61
|
+
instance_variable_set("@address", addr)
|
58
62
|
end
|
59
63
|
|
60
64
|
define_method :address do
|
61
|
-
|
65
|
+
instance_variable_get("@address")
|
62
66
|
end
|
63
67
|
|
64
68
|
define_method :as do |addr|
|
65
|
-
|
69
|
+
instance_variable_set("@sender", addr)
|
66
70
|
end
|
67
71
|
|
68
72
|
define_method :sender do
|
69
|
-
|
73
|
+
instance_variable_get("@sender") || connection.coinbase["result"]
|
70
74
|
end
|
71
75
|
|
72
76
|
define_method :set_gas_price do |gp|
|
73
|
-
|
77
|
+
instance_variable_set("@gas_price", gp)
|
74
78
|
end
|
75
79
|
|
76
80
|
define_method :gas_price do
|
77
|
-
|
81
|
+
instance_variable_get("@gas_price") || 60000000000
|
78
82
|
end
|
79
83
|
|
80
84
|
define_method :set_gas do |gas|
|
81
|
-
|
85
|
+
instance_variable_set("@gas", gas)
|
82
86
|
end
|
83
87
|
|
84
88
|
define_method :gas do
|
85
|
-
|
89
|
+
instance_variable_get("@gas") || 2000000
|
86
90
|
end
|
87
91
|
|
88
92
|
functions.each do |fun|
|
@@ -152,7 +156,10 @@ module Ethereum
|
|
152
156
|
|
153
157
|
end
|
154
158
|
end
|
155
|
-
|
159
|
+
if Object.const_defined?(class_name)
|
160
|
+
Object.send(:remove_const, class_name)
|
161
|
+
end
|
162
|
+
Object.const_set(class_name, class_methods)
|
156
163
|
end
|
157
164
|
|
158
165
|
end
|
data/lib/ethereum/version.rb
CHANGED