eth 0.5.11 → 0.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ddb9f142d1985c57f8abecee08a3275ed0e2dfd6a008cf608bf8c3ac239335d
4
- data.tar.gz: d33f16301d9421c4ae584cc293fe26c18e88e2783d8184a91999833753f6f904
3
+ metadata.gz: a6da48b3e3128860af79efba95ded96258dfe87a8bf0a374a44bff060fc2f9c3
4
+ data.tar.gz: 9ad4cbabd4d5b31419d02b9363cdff915c4e1c61ba95197b42cf2a61ed31ac50
5
5
  SHA512:
6
- metadata.gz: c32065a3eb99ca9dc142c5acd7de9a2a957e850743afa45f8c2ddb9b95597c55d75063e28dd4cce757b4ac228402fa988a7cd76fdbc6b33e2fa7770038068db7
7
- data.tar.gz: 8c44621156a464b8676ca9dd6e1bd92295e84a0c41329687b8a84f5335abc10683a3ae39ecfa548f5f5203f218adb6850aa76f227057e69da47405a55d0d81f3
6
+ metadata.gz: bbc07ab8bb0fc56f89619037ee16da5eeadb7d0fcde714572bd9b678e8c4da18b70e3fa042207c57195dd7e6e2700ebf5650bf5ca6ddf848da78661a2b8eda16
7
+ data.tar.gz: 51206666cc4a84bd05d0995ab6b7476699b17cc8bb37d3d78f789cf93116844dd3cd0f4e24360b59d7758d3588cc9fbebbe0504cdf1bd7b8a00a67e3600ac0ad
@@ -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.6.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.1', '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 }}
@@ -37,15 +37,10 @@ jobs:
37
37
  sudo apt-get update
38
38
  sudo apt-get install ethereum solc libyaml-dev
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@v4
55
+ with:
56
+ fail_ci_if_error: false
57
+ token: ${{ secrets.CODECOV_TOKEN }}
data/CHANGELOG.md CHANGED
@@ -1,6 +1,42 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.5.12]
5
+ ### Added
6
+ ### Changed
7
+
8
+ ## [0.5.11]
9
+ ### Added
10
+ * Eth/abi: allow encoding address types [#242](https://github.com/q9f/eth.rb/pull/242)
11
+ * Eth/solidity: enable --via-ir [#232](https://github.com/q9f/eth.rb/pull/232)
12
+ * Checking userinfo with the uri method [#233](https://github.com/q9f/eth.rb/pull/233)
13
+ * Eth/abi: add abicoder gem tests collection [#218](https://github.com/q9f/eth.rb/pull/218)
14
+ * Manual default_account [#215](https://github.com/q9f/eth.rb/pull/215)
15
+ * Add moonbeam networks in [#209](https://github.com/q9f/eth.rb/pull/209)
16
+
17
+ ### Changed
18
+ * Spec: run rufo [#245](https://github.com/q9f/eth.rb/pull/245)
19
+ * Fix the decoding of unsigned transactions [#243](https://github.com/q9f/eth.rb/pull/243)
20
+ * 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)
21
+ * 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)
22
+ * Eth/tx: update tx initcode cost for shanghai [#237](https://github.com/q9f/eth.rb/pull/237)
23
+ * Eth/client: remove default gas limit attribute [#235](https://github.com/q9f/eth.rb/pull/235)
24
+ * Docs: minor fixups [#229](https://github.com/q9f/eth.rb/pull/229)
25
+ * Eth/contract: ensure contract name is title case [#228](https://github.com/q9f/eth.rb/pull/228)
26
+ * Deps: require forwardable for contracts [#227](https://github.com/q9f/eth.rb/pull/227)
27
+ * Ens/resolver: remove pending for etc coin type [#219](https://github.com/q9f/eth.rb/pull/219)
28
+ * Deps: update secp256k1 to 6 [#214](https://github.com/q9f/eth.rb/pull/214)
29
+ * Eth/solidity: add docs for solc path override [#213](https://github.com/q9f/eth.rb/pull/213)
30
+ * Manually overwrite solc path [#212](https://github.com/q9f/eth.rb/pull/212)
31
+ * Abi.decoder handles arrays of string and bytes [#207](https://github.com/q9f/eth.rb/pull/207)
32
+ * Eth/util: fix compressed public key to address in [#206](https://github.com/q9f/eth.rb/pull/206)
33
+ * Eth/api: update execution apis to latest spec [#204](https://github.com/q9f/eth.rb/pull/204)
34
+ * Eth/abi: split abi class into encoder and decoder [#203](https://github.com/q9f/eth.rb/pull/203)
35
+ * Eth/client: deduplicate code [#202](https://github.com/q9f/eth.rb/pull/202)
36
+ * Eth/client: rewrite send to send_request [#201](https://github.com/q9f/eth.rb/pull/201)
37
+ * Docs: update changelog for 0.5.10 [#200](https://github.com/q9f/eth.rb/pull/200)
38
+ * Tested with Ruby 3.2 [#199](https://github.com/q9f/eth.rb/pull/199)
39
+
4
40
  ## [0.5.10]
5
41
  ### Added
6
42
  * Eth/client: add transfer_erc20 function [#197](https://github.com/q9f/eth.rb/pull/197)
@@ -51,6 +51,25 @@ 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
+ type.components.each do |c|
58
+ if c.dynamic?
59
+ pointer = Util.deserialize_big_endian_to_int arg[offset, 32] # Pointer to the size of the array's element
60
+ data_len = Util.deserialize_big_endian_to_int arg[pointer, 32] # length of the element
61
+
62
+ data[c.name] = type(c, arg[pointer, Util.ceil32(data_len) + 32])
63
+ # puts data
64
+ offset += 32
65
+ else
66
+ size = c.size
67
+ data[c.name] = type(c, arg[offset, size])
68
+ offset += size
69
+ # puts data
70
+ end
71
+ end
72
+ data
54
73
  elsif type.dynamic?
55
74
  l = Util.deserialize_big_endian_to_int arg[0, 32]
56
75
  nested_sub = type.nested_sub
@@ -106,7 +125,7 @@ module Eth
106
125
  Util.deserialize_big_endian_to_int data
107
126
  when "int"
108
127
  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
128
+ i = u >= 2 ** (type.sub_type.to_i - 1) ? (u - 2 ** 256) : u
110
129
 
111
130
  # decoded integer
112
131
  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/api.rb CHANGED
@@ -115,7 +115,6 @@ module Eth
115
115
  "eth_blockNumber",
116
116
  "eth_call",
117
117
  "eth_chainId",
118
- "eth_coinbase",
119
118
  "eth_compileLLL",
120
119
  "eth_compileSerpent",
121
120
  "eth_compileSolidity",
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
@@ -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
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 = 12.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.12
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-06-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: forwardable
@@ -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.2.32
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Ruby Ethereum library.