Class: ABI::Interface
- Inherits:
-
Object
- Object
- ABI::Interface
- Defined in:
- lib/abiparser/interface.rb
Overview
rename to QueryInterface or SupportInterface
or InterfaceType or InterfaceId or such - why? why not?
Instance Attribute Summary collapse
-
#interface_id ⇒ Object
readonly
Returns the value of attribute interface_id.
Instance Method Summary collapse
- #calc_interface_id ⇒ Object
-
#initialize(*functions) ⇒ Interface
constructor
todo/fix: make sure full function defs get passed in (not only sigs!!!).
-
#selectors ⇒ Object
return hexstrings of sig(natures) - why? why not? rename to sighashes - why? why not?.
- #support?(sig) ⇒ Boolean (also: #supports?)
Constructor Details
#initialize(*functions) ⇒ Interface
todo/fix: make sure full function defs get passed in (not only sigs!!!)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/abiparser/interface.rb', line 14 def initialize( *functions ) @functions = functions @selectors = {} @functions.each do |func| sig = func sighash = keccak256( sig )[0,4].hexdigest puts "0x#{sighash} => #{sig}" ## assert - no duplicates allowed if @selectors[sighash] puts "!! ERROR - duplicate function signature #{sig}; already in use; sorry" exit 1 end @selectors[sighash] = sig end @interface_id = calc_interface_id end |
Instance Attribute Details
#interface_id ⇒ Object (readonly)
Returns the value of attribute interface_id.
9 10 11 |
# File 'lib/abiparser/interface.rb', line 9 def interface_id @interface_id end |
Instance Method Details
#calc_interface_id ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/abiparser/interface.rb', line 35 def calc_interface_id interface_id = nil @selectors.each do |sighash,_| sighash = sighash.hex_to_bin ## note: convert to binary string (from hexstring)!! interface_id = if interface_id.nil? sighash ## init with sighash else interface_id ^ sighash ## use xor end end interface_id.hexdigest end |
#selectors ⇒ Object
return hexstrings of sig(natures) - why? why not? rename to sighashes - why? why not?
51 |
# File 'lib/abiparser/interface.rb', line 51 def selectors() @selectors.keys; end |