eth 0.5.11 → 0.5.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ddb9f142d1985c57f8abecee08a3275ed0e2dfd6a008cf608bf8c3ac239335d
4
- data.tar.gz: d33f16301d9421c4ae584cc293fe26c18e88e2783d8184a91999833753f6f904
3
+ metadata.gz: cc5ddb568fad899fb1b19cce7995c8152b799475fbca603932d840d561fa4b4c
4
+ data.tar.gz: fc69a4e2c2866a719336cc94a0adb9244383a6c80116ab7da8a1165262743ac9
5
5
  SHA512:
6
- metadata.gz: c32065a3eb99ca9dc142c5acd7de9a2a957e850743afa45f8c2ddb9b95597c55d75063e28dd4cce757b4ac228402fa988a7cd76fdbc6b33e2fa7770038068db7
7
- data.tar.gz: 8c44621156a464b8676ca9dd6e1bd92295e84a0c41329687b8a84f5335abc10683a3ae39ecfa548f5f5203f218adb6850aa76f227057e69da47405a55d0d81f3
6
+ metadata.gz: 35062c2f2b04723b2889195a5a16c662e2f2913fed4ecc3d5903a6167ed125d23a3b066125756023b2b71451f5899a58f5a36e61049f0e744b6a24583a6eff9e
7
+ data.tar.gz: 51732510c1e64a48d3095fb6a6502038e493ace3390da31cde1006f67f4b7a4e130f78de2ab667ae235ce4285c2bb986a3720be8b6648e91d845de5bdb6f1a8f
@@ -24,18 +24,18 @@ jobs:
24
24
  - ruby
25
25
  steps:
26
26
  - name: "Checkout repository"
27
- uses: actions/checkout@v3
27
+ uses: actions/checkout@v4
28
28
  - name: "Initialize CodeQL"
29
- uses: github/codeql-action/init@v2
29
+ uses: github/codeql-action/init@v3
30
30
  with:
31
31
  languages: "${{ matrix.language }}"
32
32
  - name: Autobuild
33
- uses: github/codeql-action/autobuild@v2
33
+ uses: github/codeql-action/autobuild@v3
34
34
  - name: "Perform CodeQL Analysis"
35
- uses: github/codeql-action/analyze@v2
35
+ uses: github/codeql-action/analyze@v3
36
36
  - uses: ruby/setup-ruby@v1
37
37
  with:
38
- ruby-version: '3.0'
38
+ ruby-version: '3.3'
39
39
  bundler-cache: true
40
40
  - name: "Run rufo code formatting checks"
41
41
  run: |
@@ -10,17 +10,17 @@ jobs:
10
10
  docs:
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: actions/checkout@v3
13
+ - uses: actions/checkout@v4
14
14
  - uses: ruby/setup-ruby@v1
15
15
  with:
16
- ruby-version: '3.0'
16
+ ruby-version: '3.3'
17
17
  bundler-cache: true
18
18
  - name: Run Yard Doc
19
19
  run: |
20
20
  gem install yard
21
21
  yard doc
22
22
  - name: Deploy GH Pages
23
- uses: JamesIves/github-pages-deploy-action@v4.4.3
23
+ uses: JamesIves/github-pages-deploy-action@v4.7.1
24
24
  with:
25
25
  branch: gh-pages
26
26
  folder: doc/
@@ -18,10 +18,10 @@ jobs:
18
18
  strategy:
19
19
  fail-fast: false
20
20
  matrix:
21
- os: [ubuntu-22.04, macos-12]
22
- ruby: ['3.0', '3.1', '3.2']
21
+ os: [ubuntu-latest, macos-latest]
22
+ ruby: ['3.2', '3.3']
23
23
  steps:
24
- - uses: actions/checkout@v3
24
+ - uses: actions/checkout@v4
25
25
  - uses: ruby/setup-ruby@v1
26
26
  with:
27
27
  ruby-version: ${{ matrix.ruby }}
@@ -29,23 +29,18 @@ jobs:
29
29
  - name: MacOs Dependencies
30
30
  run: |
31
31
  brew tap ethereum/ethereum
32
- brew install --verbose pkg-config automake autogen ethereum solidity
32
+ brew install --verbose pkg-config automake autogen geth solidity
33
33
  if: startsWith(matrix.os, 'macOS')
34
34
  - name: Ubuntu Dependencies
35
35
  run: |
36
36
  sudo add-apt-repository -y ppa:ethereum/ethereum
37
37
  sudo apt-get update
38
- sudo apt-get install ethereum solc libyaml-dev
38
+ sudo apt-get install geth solc
39
39
  if: startsWith(matrix.os, 'Ubuntu')
40
- - name: Patch Geth # https://github.com/ethereum/go-ethereum/pull/27360
41
- run: |
42
- git clone https://github.com/q9f/go-ethereum.git -b q9f/params/shanghai
43
- pushd go-ethereum/
44
- make geth
45
- popd
46
40
  - name: Run Geth
47
41
  run: |
48
- ./go-ethereum/build/bin/geth --dev --http --ipcpath /tmp/geth.ipc &
42
+ geth --dev --http --ipcpath /tmp/geth.ipc &
43
+ disown &
49
44
  - name: Gem Dependencies
50
45
  run: |
51
46
  git submodule update --init
@@ -54,5 +49,9 @@ jobs:
54
49
  run: |
55
50
  bundle exec rspec
56
51
  env:
57
- COVERAGE: true
58
52
  INFURA_TOKEN: ${{ secrets.INFURA_TOKEN }}
53
+ - name: Upload coverage to Codecov
54
+ uses: codecov/codecov-action@v5
55
+ with:
56
+ fail_ci_if_error: true
57
+ token: ${{ secrets.CODECOV_TOKEN }}
data/CHANGELOG.md CHANGED
@@ -1,6 +1,80 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.5.13]
5
+ ### Changed
6
+ * Eth/api: update to latest available go-ethereum apis [#301](https://github.com/q9f/eth.rb/pull/301)
7
+ * Eth/chain: update ids [#300](https://github.com/q9f/eth.rb/pull/300)
8
+ * Spec: update ethereum/tests fixtures [#303](https://github.com/q9f/eth.rb/pull/303)
9
+ * Ci: fix codecov uploader [#302](https://github.com/q9f/eth.rb/pull/302)
10
+ * Eth/tx: only enforce block gas limit on mainnet [#299](https://github.com/q9f/eth.rb/pull/299)
11
+ * Eth/util: fix single-byte hex-string nibbles [#298](https://github.com/q9f/eth.rb/pull/298)
12
+ * Eth/address: rename null address to zero address [#297](https://github.com/q9f/eth.rb/pull/297)
13
+ * Eth/address: add support to check for the ethereum "null address" [#296](https://github.com/q9f/eth.rb/pull/296)
14
+ * Build(deps): bump codecov/codecov-action from 4 to 5 [#295](https://github.com/q9f/eth.rb/pull/295)
15
+ * Build(deps): bump JamesIves/github-pages-deploy-action [#294](https://github.com/q9f/eth.rb/pull/294)
16
+ * Build(deps): bump JamesIves/github-pages-deploy-action [#288](https://github.com/q9f/eth.rb/pull/288)
17
+ * Eth/client: always return hash even if transaction didn't succeed [#284](https://github.com/q9f/eth.rb/pull/284)
18
+ * Eth/chain: update list of chains [#283](https://github.com/q9f/eth.rb/pull/283)
19
+ * Fix undefined method `raise_error' for an instance of Eth::Tx::Eip1559 (NoMethodError) [#282](https://github.com/q9f/eth.rb/pull/282)
20
+ * Gem: bump version to 0.5.13 [#281](https://github.com/q9f/eth.rb/pull/281)
21
+
22
+ ## [0.5.12]
23
+ ### Added
24
+ * Allow to call JSON RPC with custom block number [#268](https://github.com/q9f/eth.rb/pull/268)
25
+ * Support tuple params in EventLog [#276](https://github.com/q9f/eth.rb/pull/276)
26
+
27
+ ### Changed
28
+ * Eth: update version [#280](https://github.com/q9f/eth.rb/pull/280)
29
+ * Eth/abi: fix negative integer coding [#279](https://github.com/q9f/eth.rb/pull/279)
30
+ * Support negative number from JSON RPC [#267](https://github.com/q9f/eth.rb/pull/267)
31
+ * Abi/event: confirm decoding tuples works [#278](https://github.com/q9f/eth.rb/pull/278)
32
+ * Allow to call JSON RPC with custom block number [#268](https://github.com/q9f/eth.rb/pull/268)
33
+ * Gem: run rufo [#277](https://github.com/q9f/eth.rb/pull/277)
34
+ * Fix event signature [#250](https://github.com/q9f/eth.rb/pull/250)
35
+ * Support tuple params in EventLog [#276](https://github.com/q9f/eth.rb/pull/276)
36
+ * Ci: update ruby version [#271](https://github.com/q9f/eth.rb/pull/271)
37
+ * Eth/api: remove coinbase as default account [#269](https://github.com/q9f/eth.rb/pull/269)
38
+ * Build(deps): bump JamesIves/github-pages-deploy-action from 4.5.0 to 4.6.1 [#275](https://github.com/q9f/eth.rb/pull/275)
39
+ * Build(deps): bump github/codeql-action from 2 to 3 [#257](https://github.com/q9f/eth.rb/pull/257)
40
+ * Build(deps): bump JamesIves/github-pages-deploy-action from 4.4.3 to 4.5.0 [#256](https://github.com/q9f/eth.rb/pull/256)
41
+ * Fix typo in contract_spec.rb [#253](https://github.com/q9f/eth.rb/pull/253)
42
+ * Eth/eip721: fix data type bug for bytes, fix #251 [#252](https://github.com/q9f/eth.rb/pull/252)
43
+ * Ci: unpatch geth [#248](https://github.com/q9f/eth.rb/pull/248)
44
+ * Build(deps): bump actions/checkout from 3 to 4 [#246](https://github.com/q9f/eth.rb/pull/246)
45
+
46
+ ## [0.5.11]
47
+ ### Added
48
+ * Eth/abi: allow encoding address types [#242](https://github.com/q9f/eth.rb/pull/242)
49
+ * Eth/solidity: enable --via-ir [#232](https://github.com/q9f/eth.rb/pull/232)
50
+ * Checking userinfo with the uri method [#233](https://github.com/q9f/eth.rb/pull/233)
51
+ * Eth/abi: add abicoder gem tests collection [#218](https://github.com/q9f/eth.rb/pull/218)
52
+ * Manual default_account [#215](https://github.com/q9f/eth.rb/pull/215)
53
+ * Add moonbeam networks in [#209](https://github.com/q9f/eth.rb/pull/209)
54
+
55
+ ### Changed
56
+ * Spec: run rufo [#245](https://github.com/q9f/eth.rb/pull/245)
57
+ * Fix the decoding of unsigned transactions [#243](https://github.com/q9f/eth.rb/pull/243)
58
+ * Build(deps): bump JamesIves/github-pages-deploy-action from 4.4.2 to 4.4.3 [#244](https://github.com/q9f/eth.rb/pull/244)
59
+ * Build(deps): bump JamesIves/github-pages-deploy-action from 4.4.1 to 4.4.2 [#240](https://github.com/q9f/eth.rb/pull/240)
60
+ * Eth/tx: update tx initcode cost for shanghai [#237](https://github.com/q9f/eth.rb/pull/237)
61
+ * Eth/client: remove default gas limit attribute [#235](https://github.com/q9f/eth.rb/pull/235)
62
+ * Docs: minor fixups [#229](https://github.com/q9f/eth.rb/pull/229)
63
+ * Eth/contract: ensure contract name is title case [#228](https://github.com/q9f/eth.rb/pull/228)
64
+ * Deps: require forwardable for contracts [#227](https://github.com/q9f/eth.rb/pull/227)
65
+ * Ens/resolver: remove pending for etc coin type [#219](https://github.com/q9f/eth.rb/pull/219)
66
+ * Deps: update secp256k1 to 6 [#214](https://github.com/q9f/eth.rb/pull/214)
67
+ * Eth/solidity: add docs for solc path override [#213](https://github.com/q9f/eth.rb/pull/213)
68
+ * Manually overwrite solc path [#212](https://github.com/q9f/eth.rb/pull/212)
69
+ * Abi.decoder handles arrays of string and bytes [#207](https://github.com/q9f/eth.rb/pull/207)
70
+ * Eth/util: fix compressed public key to address in [#206](https://github.com/q9f/eth.rb/pull/206)
71
+ * Eth/api: update execution apis to latest spec [#204](https://github.com/q9f/eth.rb/pull/204)
72
+ * Eth/abi: split abi class into encoder and decoder [#203](https://github.com/q9f/eth.rb/pull/203)
73
+ * Eth/client: deduplicate code [#202](https://github.com/q9f/eth.rb/pull/202)
74
+ * Eth/client: rewrite send to send_request [#201](https://github.com/q9f/eth.rb/pull/201)
75
+ * Docs: update changelog for 0.5.10 [#200](https://github.com/q9f/eth.rb/pull/200)
76
+ * Tested with Ruby 3.2 [#199](https://github.com/q9f/eth.rb/pull/199)
77
+
4
78
  ## [0.5.10]
5
79
  ### Added
6
80
  * Eth/client: add transfer_erc20 function [#197](https://github.com/q9f/eth.rb/pull/197)
@@ -19,7 +93,7 @@ All notable changes to this project will be documented in this file.
19
93
 
20
94
  ## [0.5.9]
21
95
  ### Added
22
- * Eth/abi: dynamic struct encoding (#135) [#185](https://github.com/q9f/eth.rb/pull/185)
96
+ * Eth/abi: dynamic struct encoding [#135](https://github.com/q9f/eth.rb/pull/135) [#185](https://github.com/q9f/eth.rb/pull/185)
23
97
  * Eth/client: support camel case (convert before sending the tx) [#172](https://github.com/q9f/eth.rb/pull/172)
24
98
  * Eth/client: add `tx_succeeded?` [#173](https://github.com/q9f/eth.rb/pull/173)
25
99
 
data/Gemfile CHANGED
@@ -3,14 +3,14 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  group :test, :development do
6
- gem "bundler", "~> 2.2"
7
- gem "codecov", "~> 0.6"
8
- gem "pry", "~> 0.14"
9
- gem "rake", "~> 13.0"
10
- gem "rdoc", "~> 6.4"
11
- gem "rspec", "~> 3.11"
12
- gem "rufo", "~> 0.13"
13
- gem "simplecov", "~> 0.21"
6
+ gem "bundler", "~> 2.4"
7
+ gem "pry", "~> 0.15"
8
+ gem "rake", "~> 13.2"
9
+ gem "rdoc", "~> 6.9"
10
+ gem "rspec", "~> 3.13"
11
+ gem "rufo", "~> 0.18"
12
+ gem "simplecov", "~> 0.22"
13
+ gem "simplecov-cobertura", "~> 2.1"
14
14
  gem "yard", "~> 0.9"
15
15
  end
16
16
 
data/SECURITY.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Supported Versions
4
4
 
5
- Ruby Ethereum 0.5.0 is a complete rewrite of the old `eth` 0.4.x gem.
5
+ Ruby Ethereum 0.5.x is a complete rewrite of the old `eth` 0.4.x gem.
6
6
  It also contains modules from `abi`, `rlp` and the `ethereum` gem.
7
7
 
8
8
  None of these gems are maintained anymore except for `eth` 0.5.0 and
data/eth.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.test_files = spec.files.grep %r{^(test|spec|features)/}
33
33
 
34
34
  spec.platform = Gem::Platform::RUBY
35
- spec.required_ruby_version = ">= 2.7", "< 4.0"
35
+ spec.required_ruby_version = ">= 3.0", "< 4.0"
36
36
 
37
37
  # forwardable for contracts meta programming
38
38
  spec.add_dependency "forwardable", "~> 1.3"
@@ -51,6 +51,24 @@ module Eth
51
51
  type(Type.parse(type.base_type), arg[pointer + 32, Util.ceil32(data_l) + 32])
52
52
  end
53
53
  end
54
+ elsif type.base_type == "tuple"
55
+ offset = 0
56
+ data = {}
57
+ raise DecodingError, "Cannot decode tuples without known components" if type.components.nil?
58
+ type.components.each do |c|
59
+ if c.dynamic?
60
+ pointer = Util.deserialize_big_endian_to_int arg[offset, 32] # Pointer to the size of the array's element
61
+ data_len = Util.deserialize_big_endian_to_int arg[pointer, 32] # length of the element
62
+
63
+ data[c.name] = type(c, arg[pointer, Util.ceil32(data_len) + 32])
64
+ offset += 32
65
+ else
66
+ size = c.size
67
+ data[c.name] = type(c, arg[offset, size])
68
+ offset += size
69
+ end
70
+ end
71
+ data
54
72
  elsif type.dynamic?
55
73
  l = Util.deserialize_big_endian_to_int arg[0, 32]
56
74
  nested_sub = type.nested_sub
@@ -106,7 +124,7 @@ module Eth
106
124
  Util.deserialize_big_endian_to_int data
107
125
  when "int"
108
126
  u = Util.deserialize_big_endian_to_int data
109
- i = u >= 2 ** (type.sub_type.to_i - 1) ? (u - 2 ** type.sub_type.to_i) : u
127
+ i = u >= 2 ** (type.sub_type.to_i - 1) ? (u - 2 ** 256) : u
110
128
 
111
129
  # decoded integer
112
130
  i
@@ -138,7 +138,7 @@ module Eth
138
138
  real_size = type.sub_type.to_i
139
139
  i = arg.to_i
140
140
  raise ValueOutOfBounds, arg unless i >= -2 ** (real_size - 1) and i < 2 ** (real_size - 1)
141
- Util.zpad_int(i % 2 ** type.sub_type.to_i)
141
+ Util.zpad_int(i % 2 ** 256)
142
142
  end
143
143
 
144
144
  # Properly encodes booleans.
data/lib/eth/abi/event.rb CHANGED
@@ -40,10 +40,20 @@ module Eth
40
40
  def signature(interface)
41
41
  name = interface.fetch("name")
42
42
  inputs = interface.fetch("inputs", [])
43
- types = inputs.map { |i| i.fetch("type") }
43
+ types = inputs.map { |i| type(i) }
44
44
  "#{name}(#{types.join(",")})"
45
45
  end
46
46
 
47
+ def type(input)
48
+ if input["type"] == "tuple"
49
+ "(#{input["components"].map { |c| type(c) }.join(",")})"
50
+ elsif input["type"] == "enum"
51
+ "uint8"
52
+ else
53
+ input["type"]
54
+ end
55
+ end
56
+
47
57
  # A decoded event log.
48
58
  class LogDescription
49
59
  # The event ABI interface used to decode the log.
@@ -116,9 +126,20 @@ module Eth
116
126
  def decode_log(inputs, data, topics, anonymous = false)
117
127
  topic_inputs, data_inputs = inputs.partition { |i| i["indexed"] }
118
128
 
119
- topic_types = topic_inputs.map { |i| i["type"] }
120
- data_types = data_inputs.map { |i| i["type"] }
121
-
129
+ topic_types = topic_inputs.map do |i|
130
+ if i["type"] == "tuple"
131
+ Type.parse(i["type"], i["components"], i["name"])
132
+ else
133
+ i["type"]
134
+ end
135
+ end
136
+ data_types = data_inputs.map do |i|
137
+ if i["type"] == "tuple"
138
+ Type.parse(i["type"], i["components"], i["name"])
139
+ else
140
+ i["type"]
141
+ end
142
+ end
122
143
  # If event is anonymous, all topics are arguments. Otherwise, the first
123
144
  # topic will be the event signature.
124
145
  if anonymous == false
data/lib/eth/abi/type.rb CHANGED
@@ -71,7 +71,15 @@ module Eth
71
71
  # @return [Eth::Abi::Type] a parsed Type object.
72
72
  # @raise [ParseError] if it fails to parse the type.
73
73
  def parse(type, components = nil, component_name = nil)
74
- return type if type.is_a?(Type)
74
+ if type.is_a?(Type)
75
+ @base_type = type.base_type
76
+ @sub_type = type.sub_type
77
+ @dimensions = type.dimensions
78
+ @components = type.components
79
+ @name = type.name
80
+ return
81
+ end
82
+
75
83
  _, base_type, sub_type, dimension = /([a-z]*)([0-9]*x?[0-9]*)((\[[0-9]*\])*)/.match(type).to_a
76
84
 
77
85
  # type dimension can only be numeric
data/lib/eth/address.rb CHANGED
@@ -17,6 +17,7 @@ module Eth
17
17
 
18
18
  # The {Eth::Address} class to handle checksummed Ethereum addresses.
19
19
  class Address
20
+ ZERO = "0x0000000000000000000000000000000000000000"
20
21
 
21
22
  # Provides a special checksum error if EIP-55 is violated.
22
23
  class CheckSumError < StandardError; end
@@ -51,6 +52,13 @@ module Eth
51
52
  end
52
53
  end
53
54
 
55
+ # Checks that the address is the zero address.
56
+ #
57
+ # @return [Boolean] true if the address is the zero address.
58
+ def zero?
59
+ address == ZERO
60
+ end
61
+
54
62
  # Generate a checksummed address.
55
63
  #
56
64
  # @return [String] prefixed hexstring representing an checksummed address.
data/lib/eth/api.rb CHANGED
@@ -27,17 +27,25 @@ module Eth
27
27
  "account_signTypedData",
28
28
  "admin_addPeer",
29
29
  "admin_addTrustedPeer",
30
+ "admin_clearHistory",
30
31
  "admin_datadir",
31
32
  "admin_exportChain",
33
+ "admin_getDatadir",
34
+ "admin_getNodeInfo",
35
+ "admin_getPeers",
32
36
  "admin_importChain",
33
37
  "admin_nodeInfo",
34
38
  "admin_peerEvents",
35
39
  "admin_peers",
36
40
  "admin_removePeer",
37
41
  "admin_removeTrustedPeer",
42
+ "admin_sleep",
43
+ "admin_sleepBlocks",
38
44
  "admin_startHTTP",
45
+ "admin_startRPC",
39
46
  "admin_startWS",
40
47
  "admin_stopHTTP",
48
+ "admin_stopRPC",
41
49
  "admin_stopWS",
42
50
  "clef_deriveAccount",
43
51
  "clef_listWallets",
@@ -78,6 +86,7 @@ module Eth
78
86
  "debug_getRawHeader",
79
87
  "debug_getRawReceipts",
80
88
  "debug_getRawTransaction",
89
+ "debug_getTrieFlushInterval",
81
90
  "debug_goTrace",
82
91
  "debug_intermediateRoots",
83
92
  "debug_memStats",
@@ -89,6 +98,7 @@ module Eth
89
98
  "debug_setGCPercent",
90
99
  "debug_setHead",
91
100
  "debug_setMutexProfileFraction",
101
+ "debug_setTrieFlushInterval",
92
102
  "debug_stacks",
93
103
  "debug_standardTraceBadBlockToFile",
94
104
  "debug_standardTraceBlockToFile",
@@ -111,52 +121,92 @@ module Eth
111
121
  "debug_writeBlockProfile",
112
122
  "debug_writeMemProfile",
113
123
  "debug_writeMutexProfile",
124
+ "dev_addWithdrawal",
125
+ "dev_setFeeRecipient",
114
126
  "eth_accounts",
127
+ "eth_blobBaseFee",
115
128
  "eth_blockNumber",
116
129
  "eth_call",
117
130
  "eth_chainId",
118
131
  "eth_coinbase",
132
+ "eth_compile",
119
133
  "eth_compileLLL",
120
134
  "eth_compileSerpent",
121
135
  "eth_compileSolidity",
136
+ "eth_contract",
122
137
  "eth_createAccessList",
138
+ "eth_defaultAccount",
139
+ "eth_defaultBlock",
123
140
  "eth_estimateGas",
124
141
  "eth_feeHistory",
142
+ "eth_fillTransaction",
143
+ "eth_filter",
125
144
  "eth_gasPrice",
145
+ "eth_getAccounts",
126
146
  "eth_getBalance",
147
+ "eth_getBlobBaseFee",
148
+ "eth_getBlock",
127
149
  "eth_getBlockByHash",
128
150
  "eth_getBlockByNumber",
151
+ "eth_getBlockNumber",
152
+ "eth_getBlockReceipts",
153
+ "eth_getBlockTransactionCount",
129
154
  "eth_getBlockTransactionCountByHash",
130
155
  "eth_getBlockTransactionCountByNumber",
156
+ "eth_getBlockUncleCount",
131
157
  "eth_getCode",
158
+ "eth_getCoinbase",
132
159
  "eth_getCompilers",
133
160
  "eth_getFilterChanges",
134
161
  "eth_getFilterLogs",
162
+ "eth_getGasPrice",
163
+ "eth_getHashrate",
164
+ "eth_getHeaderByHash",
165
+ "eth_getHeaderByNumber",
135
166
  "eth_getLogs",
167
+ "eth_getMaxPriorityFeePerGas",
168
+ "eth_getMining",
169
+ "eth_getPendingTransactions",
136
170
  "eth_getProof",
171
+ "eth_getProtocolVersion",
172
+ "eth_getRawTransaction",
173
+ "eth_getRawTransactionFromBlock",
137
174
  "eth_getStorageAt",
175
+ "eth_getSyncing",
176
+ "eth_getTransaction",
138
177
  "eth_getTransactionByBlockHashAndIndex",
139
178
  "eth_getTransactionByBlockNumberAndIndex",
140
179
  "eth_getTransactionByHash",
141
180
  "eth_getTransactionCount",
181
+ "eth_getTransactionFromBlock",
142
182
  "eth_getTransactionReceipt",
183
+ "eth_getUncle",
143
184
  "eth_getUncleByBlockHashAndIndex",
144
185
  "eth_getUncleByBlockNumberAndIndex",
145
186
  "eth_getUncleCountByBlockHash",
146
187
  "eth_getUncleCountByBlockNumber",
147
188
  "eth_getWork",
148
189
  "eth_hashrate",
190
+ "eth_iban",
191
+ "eth_icapNamereg",
192
+ "eth_isSyncing",
149
193
  "eth_maxPriorityFeePerGas",
150
194
  "eth_mining",
195
+ "eth_namereg",
151
196
  "eth_newBlockFilter",
152
197
  "eth_newFilter",
153
198
  "eth_newPendingTransactionFilter",
199
+ "eth_pendingTransactions",
154
200
  "eth_protocolVersion",
201
+ "eth_resend",
202
+ "eth_sendIBANTransaction",
155
203
  "eth_sendRawTransaction",
156
204
  "eth_sendTransaction",
157
205
  "eth_sign",
158
206
  "eth_signTransaction",
207
+ "eth_simulateV1",
159
208
  "eth_submitHashrate",
209
+ "eth_submitTransaction",
160
210
  "eth_submitWork",
161
211
  "eth_syncing",
162
212
  "eth_uninstallFilter",
@@ -178,6 +228,9 @@ module Eth
178
228
  "miner_setRecommitInterval",
179
229
  "miner_start",
180
230
  "miner_stop",
231
+ "net_getListening",
232
+ "net_getPeerCount",
233
+ "net_getVersion",
181
234
  "net_listening",
182
235
  "net_peerCount",
183
236
  "net_version",
@@ -196,6 +249,8 @@ module Eth
196
249
  "personal_signTransaction",
197
250
  "personal_unlockAccount",
198
251
  "personal_unpair",
252
+ "rpc_getModules",
253
+ "rpc_modules",
199
254
  "shh_addToGroup",
200
255
  "shh_getFilterChanges",
201
256
  "shh_getMessages",
@@ -208,10 +263,49 @@ module Eth
208
263
  "shh_version",
209
264
  "txpool_content",
210
265
  "txpool_contentFrom",
266
+ "txpool_getContent",
267
+ "txpool_getInspect",
268
+ "txpool_getStatus",
211
269
  "txpool_inspect",
212
270
  "txpool_status",
271
+ "web3_admin",
272
+ "web3_bzz",
213
273
  "web3_clientVersion",
274
+ "web3_createBatch",
275
+ "web3_currentProvider",
276
+ "web3_db",
277
+ "web3_debug",
278
+ "web3_dev",
279
+ "web3_eth",
280
+ "web3_fromAscii",
281
+ "web3_fromDecimal",
282
+ "web3_fromICAP",
283
+ "web3_fromUtf8",
284
+ "web3_fromWei",
285
+ "web3_isAddress",
286
+ "web3_isChecksumAddress",
287
+ "web3_isConnected",
288
+ "web3_isIBAN",
289
+ "web3_miner",
290
+ "web3_net",
291
+ "web3_padLeft",
292
+ "web3_padRight",
293
+ "web3_personal",
294
+ "web3_providers",
295
+ "web3_reset",
296
+ "web3_rpc",
297
+ "web3_setProvider",
298
+ "web3_settings",
214
299
  "web3_sha3",
300
+ "web3_shh",
301
+ "web3_toAscii",
302
+ "web3_toChecksumAddress",
303
+ "web3_toDecimal",
304
+ "web3_toHex",
305
+ "web3_toUtf8",
306
+ "web3_toWei",
307
+ "web3_txpool",
308
+ "web3_version",
215
309
  ]
216
310
  end
217
311
  end
data/lib/eth/chain.rb CHANGED
@@ -32,6 +32,15 @@ module Eth
32
32
  # Chain ID for Optimistic Ethereum mainnet.
33
33
  OPTIMISM = 10.freeze
34
34
 
35
+ # Chain ID for Cronos mainnet.
36
+ CRONOS = 25.freeze
37
+
38
+ # Chain ID for Rootstock mainnet.
39
+ RSK = 30.freeze
40
+
41
+ # Chain ID for BNB Smart Chain mainnet.
42
+ BNB = 56.freeze
43
+
35
44
  # Chain ID for Ethereum Classic mainnet.
36
45
  CLASSIC = 61.freeze
37
46
 
@@ -50,9 +59,45 @@ module Eth
50
59
  # Chain ID for the Polygon mainnet (formerly Matic).
51
60
  POLYGON = MATIC.freeze
52
61
 
53
- # Chain ID for Arbitrum mainnet.
62
+ # Chain ID for Filecoin mainnet.
63
+ FILECOIN = 314.freeze
64
+
65
+ # Chain ID for the Cronos zkEVM chain.
66
+ CRONOS_ZK = 388.freeze
67
+
68
+ # Chain ID for Redstone Optimistic Rollup.
69
+ REDSTONE = 690.freeze
70
+
71
+ # Chain ID for the Polygon zkEVM.
72
+ POLYGON_ZK = 1101.freeze
73
+
74
+ # Chain ID for the Lisk layer 2.
75
+ LISK = 1135.freeze
76
+
77
+ # Chain ID for Moonbeam
78
+ MOONBEAM = 1284.freeze
79
+
80
+ # Chain ID for Base mainnet.
81
+ BASE = 8453.freeze
82
+
83
+ # Chain ID for the EVMOS mainnet.
84
+ EVMOS = 9001.freeze
85
+
86
+ # Chain ID for the Celo layer 2.
87
+ CELO = 42220.freeze
88
+
89
+ # Chain ID for Arbitrum One mainnet.
54
90
  ARBITRUM = 42161.freeze
55
91
 
92
+ # Chain ID for Avalance C-Chain mainnet.
93
+ AVALANCHE = 43114.freeze
94
+
95
+ # Chain ID for Linea mainnet.
96
+ LINEA = 59144.freeze
97
+
98
+ # Chain ID for the Scroll layer 2.
99
+ SCROLL = 534352.freeze
100
+
56
101
  # Chain ID for Morden (Ethereum) testnet.
57
102
  MORDEN = 2.freeze
58
103
 
@@ -77,7 +122,7 @@ module Eth
77
122
  # Chain ID for Mordor testnet.
78
123
  MORDOR = 63.freeze
79
124
 
80
- # Chain ID for Optimistik Kovan testnet.
125
+ # Chain ID for Optimistm Kovan testnet.
81
126
  KOVAN_OPTIMISM = 69.freeze
82
127
 
83
128
  # Chain ID for Arbitrum xDAI testnet.
@@ -86,6 +131,15 @@ module Eth
86
131
  # Chain ID for Optimistic Goerli testnet.
87
132
  GOERLI_OPTIMISM = 420.freeze
88
133
 
134
+ # Chain ID for Moonriver testnet
135
+ MOONRIVER = 1285.freeze
136
+
137
+ # Chain ID for Moonbase alpha
138
+ MOONBASE = 1287.freeze
139
+
140
+ # Chain ID for the Garnet Holesky testnet
141
+ GARNET = 17069.freeze
142
+
89
143
  # Chain ID for the Polygon Mumbai testnet.
90
144
  MUMBAI = 80001.freeze
91
145
 
@@ -100,19 +154,11 @@ module Eth
100
154
 
101
155
  # Chain ID for Holesovice testnet.
102
156
  HOLESOVICE = 11166111.freeze
157
+ HOLESKY = HOLESOVICE
103
158
 
104
159
  # Chain ID for the geth private network preset.
105
160
  PRIVATE_GETH = 1337.freeze
106
161
 
107
- # Chain ID for Moonbase
108
- MOONBASE = 1287.freeze
109
-
110
- # Chain ID for Moonriver
111
- MOONRIVER = 1285.freeze
112
-
113
- # Chain ID for Moonbeam
114
- MOONBEAM = 1284.freeze
115
-
116
162
  # Indicates wether the given `v` indicates a legacy chain value
117
163
  # used by ledger wallets without EIP-155 replay protection.
118
164
  #
data/lib/eth/client.rb CHANGED
@@ -25,7 +25,7 @@ module Eth
25
25
  # The connected network's chain ID.
26
26
  attr_reader :chain_id
27
27
 
28
- # The connected network's client coinbase.
28
+ # The connected network's client default account.
29
29
  attr_accessor :default_account
30
30
 
31
31
  # The default transaction max priority fee per gas in Wei, defaults to {Tx::DEFAULT_PRIORITY_FEE}.
@@ -34,6 +34,9 @@ module Eth
34
34
  # The default transaction max fee per gas in Wei, defaults to {Tx::DEFAULT_GAS_PRICE}.
35
35
  attr_accessor :max_fee_per_gas
36
36
 
37
+ # The block number used for archive calls.
38
+ attr_accessor :block_number
39
+
37
40
  # A custom error type if a contract interaction fails.
38
41
  class ContractExecutionError < StandardError; end
39
42
 
@@ -62,15 +65,15 @@ module Eth
62
65
  @max_fee_per_gas = Tx::DEFAULT_GAS_PRICE
63
66
  end
64
67
 
65
- # Gets the default account (coinbase) of the connected client.
68
+ # Gets the default account (first account) of the connected client.
66
69
  #
67
70
  # **Note**, that many remote providers (e.g., Infura) do not provide
68
71
  # any accounts.
69
72
  #
70
- # @return [Eth::Address] the coinbase account address.
73
+ # @return [Eth::Address] the default account address.
71
74
  def default_account
72
75
  raise ArgumentError, "The default account is not available on remote connections!" unless local? || @default_account
73
- @default_account ||= Address.new eth_coinbase["result"]
76
+ @default_account ||= Address.new eth_accounts["result"].first
74
77
  end
75
78
 
76
79
  # Gets the chain ID of the connected network.
@@ -108,7 +111,7 @@ module Eth
108
111
  end
109
112
 
110
113
  # Simply transfer Ether to an account and waits for it to be mined.
111
- # Uses `eth_coinbase` and external signer if no sender key is
114
+ # Uses `eth_accounts` and external signer if no sender key is
112
115
  # provided.
113
116
  #
114
117
  # See {#transfer} for params and overloads.
@@ -119,7 +122,7 @@ module Eth
119
122
  end
120
123
 
121
124
  # Simply transfer Ether to an account without any call data or
122
- # access lists attached. Uses `eth_coinbase` and external signer
125
+ # access lists attached. Uses `eth_accounts` and external signer
123
126
  # if no sender key is provided.
124
127
  #
125
128
  # **Note**, that many remote providers (e.g., Infura) do not provide
@@ -179,7 +182,7 @@ module Eth
179
182
  end
180
183
 
181
184
  # Deploys a contract and waits for it to be mined. Uses
182
- # `eth_coinbase` or external signer if no sender key is provided.
185
+ # `eth_accounts` or external signer if no sender key is provided.
183
186
  #
184
187
  # See {#deploy} for params and overloads.
185
188
  #
@@ -190,7 +193,7 @@ module Eth
190
193
  contract.address = Address.new(addr).to_s
191
194
  end
192
195
 
193
- # Deploys a contract. Uses `eth_coinbase` or external signer
196
+ # Deploys a contract. Uses `eth_accounts` or external signer
194
197
  # if no sender key is provided.
195
198
  #
196
199
  # **Note**, that many remote providers (e.g., Infura) do not provide
@@ -312,11 +315,11 @@ module Eth
312
315
  # See {#transact} for params and overloads.
313
316
  #
314
317
  # @raise [Client::ContractExecutionError] if the execution fails.
315
- # @return [Object] returns the result of the transaction.
318
+ # @return [Object, Boolean] returns the result of the transaction (hash and execution status).
316
319
  def transact_and_wait(contract, function, *args, **kwargs)
317
320
  begin
318
321
  hash = wait_for_tx(transact(contract, function, *args, **kwargs))
319
- return hash if tx_succeeded? hash
322
+ return hash, tx_succeeded?(hash)
320
323
  rescue IOError => e
321
324
  raise ContractExecutionError, e
322
325
  end
@@ -469,7 +472,8 @@ module Eth
469
472
 
470
473
  # Prepares parameters and sends the command to the client.
471
474
  def send_command(command, args)
472
- args << "latest" if ["eth_getBalance", "eth_call"].include? command
475
+ @block_number ||= "latest"
476
+ args << block_number if ["eth_getBalance", "eth_call"].include? command
473
477
  payload = {
474
478
  jsonrpc: "2.0",
475
479
  method: command,
@@ -26,9 +26,11 @@ module Eth
26
26
  # @param data [Hash] contract event data.
27
27
  def initialize(data)
28
28
  @name = data["name"]
29
- @input_types = data["inputs"].collect { |x| x["type"] }
29
+ @input_types = data["inputs"].collect do |x|
30
+ type_name x
31
+ end
30
32
  @inputs = data["inputs"].collect { |x| x["name"] }
31
- @event_string = "#{@name}(#{@input_types.join(",")})"
33
+ @event_string = Abi::Event.signature(data)
32
34
  @signature = Digest::Keccak.hexdigest(@event_string, 256)
33
35
  end
34
36
 
@@ -38,5 +40,17 @@ module Eth
38
40
  def set_address(address)
39
41
  @address = address.nil? ? nil : Eth::Address.new(address).address
40
42
  end
43
+
44
+ private
45
+
46
+ def type_name(x)
47
+ type = x["type"]
48
+ case type
49
+ when "tuple"
50
+ "(#{x["components"].collect { |c| type_name(c) }.join(",")})"
51
+ else
52
+ type
53
+ end
54
+ end
41
55
  end
42
56
  end
data/lib/eth/eip712.rb CHANGED
@@ -114,9 +114,13 @@ module Eth
114
114
  value = data[field[:name].to_sym]
115
115
  type = field[:type]
116
116
  raise NotImplementedError, "Arrays currently unimplemented for EIP-712." if type.end_with? "]"
117
- if type == "string" or type == "bytes"
117
+ if type == "string"
118
118
  encoded_types.push "bytes32"
119
119
  encoded_values.push Util.keccak256 value
120
+ elsif type == "bytes"
121
+ encoded_types.push "bytes32"
122
+ value = Util.hex_to_bin value
123
+ encoded_values.push Util.keccak256 value
120
124
  elsif !types[type.to_sym].nil?
121
125
  encoded_types.push "bytes32"
122
126
  value = encode_data type, value, types
@@ -180,7 +180,7 @@ module Eth
180
180
  # allows us to force-setting a signature if the transaction is signed already
181
181
  _set_signature(recovery_id, r, s)
182
182
  else
183
- raise_error DecoderError, "Cannot decode EIP-1559 payload!"
183
+ raise DecoderError, "Cannot decode EIP-1559 payload!"
184
184
  end
185
185
 
186
186
  # last but not least, set the type.
@@ -175,7 +175,7 @@ module Eth
175
175
  # allows us to force-setting a signature if the transaction is signed already
176
176
  _set_signature(recovery_id, r, s)
177
177
  else
178
- raise_error DecoderError, "Cannot decode EIP-2930 payload!"
178
+ raise DecoderError, "Cannot decode EIP-2930 payload!"
179
179
  end
180
180
 
181
181
  # last but not least, set the type.
data/lib/eth/tx.rb CHANGED
@@ -210,7 +210,9 @@ module Eth
210
210
  if fields[:nonce].nil? or fields[:nonce] < 0
211
211
  raise ParameterError, "Invalid signer nonce #{fields[:nonce]}!"
212
212
  end
213
- if fields[:gas_limit].nil? or fields[:gas_limit] < DEFAULT_GAS_LIMIT or fields[:gas_limit] > BLOCK_GAS_LIMIT
213
+ if fields[:gas_limit].nil? or
214
+ fields[:gas_limit] < DEFAULT_GAS_LIMIT or
215
+ (fields[:gas_limit] > BLOCK_GAS_LIMIT and fields[:chain_id] == Chain::ETHEREUM)
214
216
  raise ParameterError, "Invalid gas limit #{fields[:gas_limit]}!"
215
217
  end
216
218
  unless fields[:value] >= 0
data/lib/eth/util.rb CHANGED
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ # -*- encoding : ascii-8bit -*-
16
+
15
17
  require "digest/keccak"
16
18
 
17
19
  # Provides the {Eth} module.
@@ -48,7 +50,7 @@ module Eth
48
50
  # @raise [TypeError] if value is not a string.
49
51
  def bin_to_hex(bin)
50
52
  raise TypeError, "Value must be an instance of String" unless bin.instance_of? String
51
- bin.unpack("H*").first
53
+ hex = bin.unpack("H*").first
52
54
  end
53
55
 
54
56
  # Packs a hexa-decimal string into a binary string. Also works with
@@ -61,7 +63,8 @@ module Eth
61
63
  raise TypeError, "Value must be an instance of String" unless hex.instance_of? String
62
64
  hex = remove_hex_prefix hex
63
65
  raise TypeError, "Non-hexadecimal digit found" unless hex? hex
64
- [hex].pack("H*")
66
+ hex = "0#{hex}" if hex.size % 2 != 0
67
+ bin = [hex].pack("H*")
65
68
  end
66
69
 
67
70
  # Prefixes a hexa-decimal string with `0x`.
data/lib/eth/version.rb CHANGED
@@ -22,7 +22,7 @@ module Eth
22
22
  MINOR = 5.freeze
23
23
 
24
24
  # Defines the patch version of the {Eth} module.
25
- PATCH = 11.freeze
25
+ PATCH = 13.freeze
26
26
 
27
27
  # Defines the version string of the {Eth} module.
28
28
  VERSION = [MAJOR, MINOR, PATCH].join(".").freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.11
4
+ version: 0.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Ellis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-08-03 00:00:00.000000000 Z
12
+ date: 2024-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: forwardable
@@ -192,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
192
  requirements:
193
193
  - - ">="
194
194
  - !ruby/object:Gem::Version
195
- version: '2.7'
195
+ version: '3.0'
196
196
  - - "<"
197
197
  - !ruby/object:Gem::Version
198
198
  version: '4.0'
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  - !ruby/object:Gem::Version
203
203
  version: '0'
204
204
  requirements: []
205
- rubygems_version: 3.3.25
205
+ rubygems_version: 3.5.16
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Ruby Ethereum library.