web3ethereum 1.0.0

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.
@@ -0,0 +1,41 @@
1
+ module Web3
2
+ module Eth
3
+
4
+ class TransactionReceipt
5
+
6
+ include Web3::Eth::Utility
7
+
8
+ attr_reader :raw_data
9
+
10
+ def initialize transaction_data
11
+ @raw_data = transaction_data
12
+
13
+ transaction_data.each do |k, v|
14
+ self.instance_variable_set("@#{k}", v)
15
+ self.class.send(:define_method, k, proc {self.instance_variable_get("@#{k}")})
16
+ end
17
+
18
+ @logs = @logs.collect {|log| Web3::Eth::Log.new log }
19
+
20
+ end
21
+
22
+ def block_number
23
+ from_hex blockNumber
24
+ end
25
+
26
+ def success?
27
+ status==1 || status=='0x1' || status.nil?
28
+ end
29
+
30
+ def gas_used
31
+ from_hex gasUsed
32
+ end
33
+
34
+
35
+ def cumulative_gas_used
36
+ from_hex cumulativeGasUsed
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,24 @@
1
+ module Web3
2
+ module Eth
3
+
4
+ module Utility
5
+
6
+ def hex num
7
+ '0x' + num.to_s(16)
8
+ end
9
+
10
+ def wei_to_ether(wei)
11
+ 1.0 * wei / 10**18
12
+ end
13
+
14
+ def from_hex h
15
+ h.to_i 16
16
+ end
17
+
18
+ def remove_0x_head(s)
19
+ s[0,2] == '0x' ? s[2..-1] : s
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ module Web3
2
+ module Eth
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
data/web3eth.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/web3/eth/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "web3ethereum"
7
+ spec.version = Web3::Eth::VERSION
8
+ spec.authors = ["Will Binns"]
9
+ spec.email = ["hello@willbinns.org"]
10
+
11
+ spec.summary = %q{Interact with the Ethereum network.}
12
+ spec.description = %q{Connect with a local or remote node to interact with the Ethereum network in your Ruby or Rails apps.}
13
+ spec.homepage = "https://github.com/wbnns/web3eth"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/wbnns/web3eth"
21
+ spec.metadata["changelog_uri"] = "https://github.com/wbnns/web3eth/blob/main/CHANGELOG.md"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ # spec.add_dependency "example-gem", "~> 1.0"
34
+ spec.add_dependency('rlp', '~> 0.7.3')
35
+ spec.add_dependency('digest-sha3', '~> 1.0.2')
36
+
37
+ # For more information and examples about making a new gem, checkout our
38
+ # guide at: https://bundler.io/guides/creating_gem.html
39
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: web3ethereum
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Will Binns
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rlp
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.7.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: digest-sha3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.2
41
+ description: Connect with a local or remote node to interact with the Ethereum network
42
+ in your Ruby or Rails apps.
43
+ email:
44
+ - hello@willbinns.org
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".github/workflows/main.yml"
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - ".rubocop.yml"
53
+ - CHANGELOG.md
54
+ - CODE_OF_CONDUCT.md
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - bin/console
60
+ - bin/setup
61
+ - lib/web3/eth.rb
62
+ - lib/web3/eth/abi/abi_coder.rb
63
+ - lib/web3/eth/abi/constant.rb
64
+ - lib/web3/eth/abi/exceptions.rb
65
+ - lib/web3/eth/abi/type.rb
66
+ - lib/web3/eth/abi/utils.rb
67
+ - lib/web3/eth/block.rb
68
+ - lib/web3/eth/call_trace.rb
69
+ - lib/web3/eth/contract.rb
70
+ - lib/web3/eth/eth_module.rb
71
+ - lib/web3/eth/etherscan.rb
72
+ - lib/web3/eth/log.rb
73
+ - lib/web3/eth/rpc.rb
74
+ - lib/web3/eth/trace_module.rb
75
+ - lib/web3/eth/transaction.rb
76
+ - lib/web3/eth/transaction_receipt.rb
77
+ - lib/web3/eth/utility.rb
78
+ - lib/web3/eth/version.rb
79
+ - web3eth.gemspec
80
+ homepage: https://github.com/wbnns/web3eth
81
+ licenses:
82
+ - MIT
83
+ metadata:
84
+ allowed_push_host: https://rubygems.org
85
+ homepage_uri: https://github.com/wbnns/web3eth
86
+ source_code_uri: https://github.com/wbnns/web3eth
87
+ changelog_uri: https://github.com/wbnns/web3eth/blob/main/CHANGELOG.md
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.4.0
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.2.15
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Interact with the Ethereum network.
107
+ test_files: []