Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pending transaction nonce as a default #58

Merged
merged 2 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ethereum/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_chain
end

def get_nonce(address)
eth_get_transaction_count(address, "latest")["result"].to_i(16)
eth_get_transaction_count(address, "pending")["result"].to_i(16)
end


Expand Down
4 changes: 2 additions & 2 deletions lib/ethereum/contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Contract

attr_reader :address
attr_accessor :key
attr_accessor :gas_limit, :gas_price
attr_accessor :gas_limit, :gas_price, :nonce
attr_accessor :code, :name, :abi, :class_object, :sender, :deployment, :client
attr_accessor :events, :functions, :constructor_inputs
attr_accessor :call_raw_proxy, :call_proxy, :transact_proxy, :transact_and_wait_proxy
Expand Down Expand Up @@ -247,7 +247,7 @@ def build
extend Forwardable
def_delegators :parent, :deploy_payload, :deploy_args, :call_payload, :call_args
def_delegators :parent, :signed_deploy, :key, :key=
def_delegators :parent, :gas_limit, :gas_price, :gas_limit=, :gas_price=
def_delegators :parent, :gas_limit, :gas_price, :gas_limit=, :gas_price=, :nonce, :nonce=
def_delegators :parent, :abi, :deployment, :events
def_delegators :parent, :estimate, :deploy, :deploy_and_wait
def_delegators :parent, :address, :address=, :sender, :sender=
Expand Down
2 changes: 1 addition & 1 deletion spec/ethereum/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
end

describe ".get_nonce" do
let (:request) { {"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"],"id":1} }
let (:request) { {"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "pending"],"id":1} }
let (:response) { '{"jsonrpc":"2.0","result":"0xd30beea08891180","id":1}' }
it "returns chain no" do
expect(client).to receive(:send_single).once.with(request.to_json).and_return(response)
Expand Down