ethereum 0.4.61 → 0.4.62

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: f7beb51d137130932441fc4bc67546dc9f3af464
4
- data.tar.gz: 628409d7b7168db426e6be1899f0865c462e51a8
3
+ metadata.gz: 7167e08de3db947aa03d0552b7ba34921124411a
4
+ data.tar.gz: c5ebedb054a9f7bd457601ab695609512269b6c9
5
5
  SHA512:
6
- metadata.gz: 456cba06bd329c4aebbda4c3f993512ea38f7bc90921acafd95213c005672ea5861ab243651353e162a4d84015a0dce93769eb984435df05a7355672f99fa190
7
- data.tar.gz: 59b48d04f86198c287bbce053132bb1359288e84d851b6ba266a9ff37d6c6d1d94ab2ae46bcbdaac93b2ca231cfd116851b33291d13027da381b636dbc7f20de
6
+ metadata.gz: ca9324dbc0687a680fd8502c45ed5705fb9acfea004be6e776ca5b8c6b1749ad7dcb581ffedbd8c6dcab7931f504973b5150dc4562c60dc21768e11560d50c21
7
+ data.tar.gz: 902db7a87860f4e962ad7857cabccbd48109a168d12f4a6dc8cf6dc483ec81ffb133057a9839e2cfd1b671d0a3a6adfc9973207cf5c9f0b9d9472e81a9604b7d
@@ -23,6 +23,7 @@ module Ethereum
23
23
  functions = @functions
24
24
  constructor_inputs = @constructor_inputs
25
25
  code = @code
26
+
26
27
  class_methods = Class.new do
27
28
 
28
29
  define_method "connection".to_sym do
@@ -88,8 +89,16 @@ module Ethereum
88
89
 
89
90
  fun_count = functions.select {|x| x.name == fun.name }.count
90
91
  derived_function_name = (fun_count == 1) ? "#{fun.name.underscore}" : "#{fun.name.underscore}__#{fun.inputs.collect {|x| x.type}.join("__")}"
91
-
92
- define_method "call_#{derived_function_name}".to_sym do |*args|
92
+ call_function_name = "call_#{derived_function_name}".to_sym
93
+ call_function_name_alias = "c_#{derived_function_name}".to_sym
94
+ call_raw_function_name = "call_raw_#{derived_function_name}".to_sym
95
+ call_raw_function_name_alias = "cr_#{derived_function_name}".to_sym
96
+ transact_function_name = "transact_#{derived_function_name}".to_sym
97
+ transact_function_name_alias = "t_#{derived_function_name}".to_sym
98
+ transact_and_wait_function_name = "transact_and_wait_#{derived_function_name}".to_sym
99
+ transact_and_wait_function_name_alias = "tw_#{derived_function_name}".to_sym
100
+
101
+ define_method call_raw_function_name do |*args|
93
102
  formatter = Ethereum::Formatter.new
94
103
  arg_types = fun.inputs.collect(&:type)
95
104
  connection = self.connection
@@ -102,15 +111,20 @@ module Ethereum
102
111
  raw_result = connection.call({to: self.address, from: self.sender, data: payload.join()})["result"]
103
112
  formatted_result = fun.outputs.collect {|x| x.type }.zip(raw_result.gsub(/^0x/,'').scan(/.{64}/))
104
113
  output = formatted_result.collect {|x| formatter.from_payload(x) }
105
- #return {data: payload.join(), raw: raw_result, formatted: output}
106
- if output.length == 0
114
+ return {data: payload.join(), raw: raw_result, formatted: output}
115
+ end
116
+
117
+ define_method call_function_name do |*args|
118
+ data = self.send(call_raw_function_name, *args)
119
+ output = data[:formatted]
120
+ if output.length == 1
107
121
  return output[0]
108
122
  else
109
123
  return output
110
124
  end
111
125
  end
112
126
 
113
- define_method "transact_#{derived_function_name}".to_sym do |*args|
127
+ define_method transact_function_name do |*args|
114
128
  formatter = Ethereum::Formatter.new
115
129
  arg_types = fun.inputs.collect(&:type)
116
130
  connection = self.connection
@@ -124,13 +138,18 @@ module Ethereum
124
138
  return Ethereum::Transaction.new(txid, self.connection, payload.join(), args)
125
139
  end
126
140
 
127
- define_method "transact_and_wait_#{derived_function_name}".to_sym do |*args|
141
+ define_method transact_and_wait_function_name do |*args|
128
142
  function_name = "transact_#{derived_function_name}".to_sym
129
143
  tx = self.send(function_name, *args)
130
144
  tx.wait_for_miner
131
145
  return tx
132
146
  end
133
147
 
148
+ alias_method call_function_name_alias, call_function_name
149
+ alias_method call_raw_function_name_alias, call_raw_function_name
150
+ alias_method transact_function_name_alias, transact_function_name
151
+ alias_method transact_and_wait_function_name_alias, transact_and_wait_function_name
152
+
134
153
  end
135
154
  end
136
155
  Object.const_set(class_name, class_methods) unless Object.const_defined?(class_name)
@@ -1,3 +1,3 @@
1
1
  module Ethereum
2
- VERSION = "0.4.61"
2
+ VERSION = "0.4.62"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethereum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.61
4
+ version: 0.4.62
5
5
  platform: ruby
6
6
  authors:
7
7
  - DigixGlobal Pte Ltd (https://dgx.io)