q9f / eth.rb

a straightforward library to build, sign, and broadcast ethereum transactions anywhere you can run ruby.
https://q9f.github.io/eth.rb
Apache License 2.0
204 stars 88 forks source link

Add missing def_delegator for constructor_inputs #96

Closed beacoding closed 2 years ago

beacoding commented 2 years ago

constructor_inputs when creating a contract from_file was missing.

We should probably enable passing constructor params with something like this:

    def encode_constructor_params(contract, args)
      types = contract.constructor_inputs.map { |input| input.type }
      Util.bin_to_hex(Eth::Abi.encode(types, args))
    end

as well, and appending it to data in deploy and transact.

Be happy to extend this PR if that's a direction we'd want to go.

q9f commented 2 years ago

Be happy to extend this PR if that's a direction we'd want to go.

Please do if you are on it already! :)

codecov-commenter commented 2 years ago

Codecov Report

Merging #96 (41f5838) into main (854a7bc) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main      #96   +/-   ##
=======================================
  Coverage   99.73%   99.73%           
=======================================
  Files          67       67           
  Lines        3801     3802    +1     
=======================================
+ Hits         3791     3792    +1     
  Misses         10       10           
Impacted Files Coverage Δ
lib/eth/contract.rb 100.00% <100.00%> (ø)

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

beacoding commented 2 years ago

great! Feel free to merge this -- I'll file a separate PR for enabling constructor params @q9f / @kurotaky