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
200 stars 86 forks source link

eth/contract: ensure address arrays support #194

Closed q9f closed 1 year ago

q9f commented 1 year ago

fix #143

geth = Client.create "/tmp/geth.ipc"
# => #<Eth::Client::Ipc:0x000055a8e12bccc8 @gas_limit=21000, @id=0, @max_fee_per_gas=0.4269e11, @max_priority_fee_per_gas=0.101e10, @path="/tmp/geth.ipc">
contract = Contract.from_file file: "spec/fixtures/contracts/address_storage.sol"
# => #<Eth::Contract::AddressStorage:0x000055a8e1116b30>
geth.deploy_and_wait contract
# => "0x7aD1FF3AFcA45262C22E32367fAF1B91e24A0909"
geth.call(contract, "retrieveMyAddress")
# => "0x0000000000000000000000000000000000000000"
geth.transact_and_wait(contract, "storeMyAddress", Key.new.address.to_s)
# => "0x5a6728574db598f515e2f93b872d73239efa0470672487325888ce71062835aa"
geth.call(contract, "retrieveMyAddress")
# => "0xbdc4d90b1d46353eb65eca3d0aeb968039f8aa9d"
geth.transact_and_wait(contract, "storeMyArray", [Key.new.address.to_s, Key.new.address.to_s])
# => "0x661ea3fdfdcca66832898917790ea104e54b25753eeb219a5a2b3e7f842005d5"
geth.call(contract, "retrieveMyArray", 0)
# => "0xae2cbef824c78274c6a4910461658e8a390cd9ce"
geth.call(contract, "retrieveMyArray", 1)
# => "0xdd902b8e5d69c08c914c94acc2c1115b6ed74029"
codecov-commenter commented 1 year ago

Codecov Report

Merging #194 (b9613a5) into main (cb79fcb) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #194   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files          74       74           
  Lines        4321     4332   +11     
=======================================
+ Hits         4311     4322   +11     
  Misses         10       10           
Impacted Files Coverage Δ
spec/eth/contract_spec.rb 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more