tealrb 0.7.0 → 0.8.0
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/tealrb/contract.rb +19 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2480b69400b8916b30ebd58c19b804190a6390780ad335006ac0364ea9d4ad4e
|
4
|
+
data.tar.gz: 6cf7f7f79217b1938f71bf07348923a7d31d3d83d76a4219f43e58bb1db2e3bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8220e4aadbdcbe9a992ada723431281665edda6a19c07771978b5a8b4ae9cf987a208ed69e9c96f4360a6a3ace9762dc930e4bab99574b2114effc0ffd1060e
|
7
|
+
data.tar.gz: 47790d4ee2171f4c2e95473f7c7cc6674d9634804c8c0dac2eeafff368df073166d9dfd371efc24026e1c94f4c333b1904af9fa4a959992116df7859dc314875
|
data/lib/tealrb/contract.rb
CHANGED
@@ -11,7 +11,8 @@ module TEALrb
|
|
11
11
|
attr_reader :teal
|
12
12
|
|
13
13
|
class << self
|
14
|
-
attr_accessor :subroutines, :version, :teal_methods, :abi_method_hash, :abi_description, :debug
|
14
|
+
attr_accessor :subroutines, :version, :teal_methods, :abi_method_hash, :abi_description, :debug,
|
15
|
+
:disable_abi_routing
|
15
16
|
|
16
17
|
private
|
17
18
|
|
@@ -22,6 +23,7 @@ module TEALrb
|
|
22
23
|
klass.abi_description = ABI::ABIDescription.new
|
23
24
|
klass.abi_method_hash = {}
|
24
25
|
klass.debug = false
|
26
|
+
klass.disable_abi_routing = false
|
25
27
|
super
|
26
28
|
end
|
27
29
|
end
|
@@ -164,14 +166,28 @@ module TEALrb
|
|
164
166
|
nil
|
165
167
|
end
|
166
168
|
|
167
|
-
# transpiles #main
|
169
|
+
# transpiles #main and routes abi methods. To disable abi routing, set `@disable_abi_routing` to true in your
|
170
|
+
# Contract subclass
|
168
171
|
def compile
|
169
172
|
TEAL.instance << 'main:' if TEAL.instance.include? 'b main'
|
170
|
-
|
173
|
+
route_abi_methods unless self.class.disable_abi_routing
|
174
|
+
eval_tealrb(rewrite(method(:main).source, method_rewriter: true), debug_context: 'main') if respond_to? :main
|
171
175
|
end
|
172
176
|
|
173
177
|
private
|
174
178
|
|
179
|
+
def route_abi_methods
|
180
|
+
self.class.abi_description.methods.each do |meth|
|
181
|
+
signature = "#{meth[:name]}(#{meth[:args].map{ _1[:type]}.join(',')})#{meth[:returns][:type]}"
|
182
|
+
selector = OpenSSL::Digest.new('SHA512-256').hexdigest(signature)[..7]
|
183
|
+
|
184
|
+
IfBlock.new(AppArgs[0] == byte(selector)) do
|
185
|
+
callsub(meth[:name])
|
186
|
+
approve
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
175
191
|
def generate_method_source(name, definition)
|
176
192
|
new_source = rewrite(definition.source, method_rewriter: true)
|
177
193
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tealrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Polny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|