Skip to content

Commit

Permalink
eth/api: remove coinbase as default account (#269)
Browse files Browse the repository at this point in the history
* eth/api: remove coinbase as default account

* solidity canary

* solidity canary

* fix codecov
  • Loading branch information
q9f authored Jun 23, 2024
1 parent b437f59 commit 91693b1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ jobs:
run: |
bundle exec rspec
env:
COVERAGE: true
INFURA_TOKEN: ${{ secrets.INFURA_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion lib/eth/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ module Api
"eth_blockNumber",
"eth_call",
"eth_chainId",
"eth_coinbase",
"eth_compileLLL",
"eth_compileSerpent",
"eth_compileSolidity",
Expand Down
16 changes: 8 additions & 8 deletions lib/eth/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Client
# The connected network's chain ID.
attr_reader :chain_id

# The connected network's client coinbase.
# The connected network's client default account.
attr_accessor :default_account

# The default transaction max priority fee per gas in Wei, defaults to {Tx::DEFAULT_PRIORITY_FEE}.
Expand Down Expand Up @@ -62,15 +62,15 @@ def initialize(_)
@max_fee_per_gas = Tx::DEFAULT_GAS_PRICE
end

# Gets the default account (coinbase) of the connected client.
# Gets the default account (first account) of the connected client.
#
# **Note**, that many remote providers (e.g., Infura) do not provide
# any accounts.
#
# @return [Eth::Address] the coinbase account address.
# @return [Eth::Address] the default account address.
def default_account
raise ArgumentError, "The default account is not available on remote connections!" unless local? || @default_account
@default_account ||= Address.new eth_coinbase["result"]
@default_account ||= Address.new eth_accounts["result"].first
end

# Gets the chain ID of the connected network.
Expand Down Expand Up @@ -108,7 +108,7 @@ def resolve_ens(ens_name, registry = Ens::DEFAULT_ADDRESS, coin_type = Ens::Coin
end

# Simply transfer Ether to an account and waits for it to be mined.
# Uses `eth_coinbase` and external signer if no sender key is
# Uses `eth_accounts` and external signer if no sender key is
# provided.
#
# See {#transfer} for params and overloads.
Expand All @@ -119,7 +119,7 @@ def transfer_and_wait(destination, amount, **kwargs)
end

# Simply transfer Ether to an account without any call data or
# access lists attached. Uses `eth_coinbase` and external signer
# access lists attached. Uses `eth_accounts` and external signer
# if no sender key is provided.
#
# **Note**, that many remote providers (e.g., Infura) do not provide
Expand Down Expand Up @@ -179,7 +179,7 @@ def transfer_erc20(erc20_contract, destination, amount, **kwargs)
end

# Deploys a contract and waits for it to be mined. Uses
# `eth_coinbase` or external signer if no sender key is provided.
# `eth_accounts` or external signer if no sender key is provided.
#
# See {#deploy} for params and overloads.
#
Expand All @@ -190,7 +190,7 @@ def deploy_and_wait(contract, *args, **kwargs)
contract.address = Address.new(addr).to_s
end

# Deploys a contract. Uses `eth_coinbase` or external signer
# Deploys a contract. Uses `eth_accounts` or external signer
# if no sender key is provided.
#
# **Note**, that many remote providers (e.g., Infura) do not provide
Expand Down
3 changes: 2 additions & 1 deletion spec/eth/solidity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
result = solc.compile contract
expect(result["DepositContract"]).to be
payload = result["DepositContract"]["bin"]
expect(payload).to start_with "604060808152"
expect(payload).to start_with "60"
expect(payload).to end_with "33"
params = {
from: geth.default_account,
priority_fee: 0,
Expand Down

0 comments on commit 91693b1

Please sign in to comment.