abigen 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/Manifest.txt +5 -0
  4. data/README.md +31 -0
  5. data/Rakefile +30 -0
  6. data/lib/abigen.rb +99 -0
  7. metadata +102 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2af88adfb037b066adbcdb376f41d9c7b22f90ac72832ed0804b6f14de2964e3
4
+ data.tar.gz: f95aee9a46c98b9896d9c9c09587ddfe55b1ac1b81d4e6d1a9905b07b5e5d9a5
5
+ SHA512:
6
+ metadata.gz: 3395ab689b6efc2b354287940f376567c5b7c0e34e6693662931150a7c19da0768c377ab1187a82563a5d33f667c1684d4aedc720b9a7da0fdfed484a5b33097
7
+ data.tar.gz: 470b580d57671302f73b10abaebf83e1519096c6e93d4843626160a30b4dd268ad4f45c8ff5f9e895eb48f9973955e72ced6b434745e7027a0bc884f9bb0626f
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ### 0.0.1 / 2023-01-10
2
+
3
+ * Everything is new. First release
data/Manifest.txt ADDED
@@ -0,0 +1,5 @@
1
+ CHANGELOG.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ lib/abigen.rb
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Application Binary Interface (ABI) Contract Generator
2
+
3
+ abigen - generate ready-to-use (blockchain) contract services / function calls for ethereum & co. via application binary inferfaces (abis)
4
+
5
+
6
+ * home :: [github.com/rubycocos/blockchain](https://github.com/rubycocos/blockchain)
7
+ * bugs :: [github.com/rubycocos/blockchain/issues](https://github.com/rubycocos/blockchain/issues)
8
+ * gem :: [rubygems.org/gems/abigen](https://rubygems.org/gems/abigen)
9
+ * rdoc :: [rubydoc.info/gems/abigen](http://rubydoc.info/gems/abigen)
10
+
11
+
12
+
13
+ ## Usage
14
+
15
+ To be done
16
+
17
+
18
+
19
+
20
+ ## License
21
+
22
+ The scripts are dedicated to the public domain.
23
+ Use it as you please with no restrictions whatsoever.
24
+
25
+
26
+ ## Questions? Comments?
27
+
28
+
29
+ Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.
30
+
31
+
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'hoe'
2
+
3
+
4
+ Hoe.spec 'abigen' do
5
+
6
+ self.version = '0.0.1'
7
+ self.summary = "abigen - generate ready-to-use (blockchain) contract services / function calls for ethereum & co. via application binary inferfaces (abis)"
8
+ self.description = summary
9
+
10
+ self.urls = { home: 'https://github.com/rubycocos/blockchain' }
11
+
12
+ self.author = 'Gerald Bauer'
13
+ self.email = 'wwwmake@googlegroups.com'
14
+
15
+ # switch extension to .markdown for gihub formatting
16
+ self.readme_file = 'README.md'
17
+ self.history_file = 'CHANGELOG.md'
18
+
19
+ self.extra_deps = [
20
+ ['abiparser'],
21
+ ]
22
+
23
+ self.licenses = ['Public Domain']
24
+
25
+ self.spec_extras = {
26
+ required_ruby_version: '>= 2.3'
27
+ }
28
+
29
+ end
30
+
data/lib/abigen.rb ADDED
@@ -0,0 +1,99 @@
1
+ require 'abiparser'
2
+
3
+
4
+ ## our own code
5
+ ## require_relative 'abidoc/version' # note: let version always go first
6
+
7
+
8
+
9
+ module ABI
10
+ class Contract
11
+
12
+
13
+ def generate_code( name: 'Contract', address: nil )
14
+ buf = ''
15
+ buf << "#########################\n"
16
+ buf << "# #{name} contract / (blockchain) services / function calls\n"
17
+ buf << "# auto-generated via abigen (see https://rubygems.org/gems/abigen) on #{Time.now.utc}\n"
18
+ buf << "# - #{query_functions.size} query functions(s)\n\n"
19
+
20
+
21
+ buf << "class #{name} < Ethlite::Contract\n\n"
22
+
23
+ if address
24
+ buf << " address "
25
+ buf << %Q{"#{address}"}
26
+ buf << "\n"
27
+ end
28
+
29
+
30
+ if query_functions.size > 0
31
+ buf << "\n"
32
+ query_functions.each do |func|
33
+ buf << "# #{func.doc} _readonly_\n"
34
+
35
+ buf << %Q{sig "#{func.name}"}
36
+
37
+ if func.inputs.size > 0
38
+ quoted_types = func.inputs.map {|param| %Q{"#{param.sig}"} }
39
+ buf << ", inputs: [#{quoted_types.join(',')}]"
40
+ end
41
+
42
+ if func.outputs.size > 0
43
+ quoted_types = func.outputs.map {|param| %Q{"#{param.sig}"} }
44
+ buf << ", outputs: [#{quoted_types.join(',')}]"
45
+ end
46
+ buf << "\n"
47
+
48
+ buf << "def #{func.name}("
49
+
50
+ func.inputs.each_with_index do |param,i|
51
+ buf << ", " if i > 0
52
+ if param.name
53
+ buf << "#{param.name}"
54
+ else
55
+ buf << "arg#{i}"
56
+ end
57
+ end
58
+
59
+ buf << ")\n"
60
+
61
+ buf << " do_call("
62
+ buf << %Q{"#{func.name}"}
63
+
64
+ func.inputs.each_with_index do |param,i|
65
+ buf << ", "
66
+ if param.name
67
+ buf << "#{param.name}"
68
+ else
69
+ buf << "arg#{i}"
70
+ end
71
+ end
72
+
73
+ buf << ")\n"
74
+
75
+ buf << "end\n"
76
+ buf << "\n"
77
+ end
78
+ end
79
+
80
+
81
+ ### todo: add (pure) helper functions too!!!
82
+ =begin
83
+ if helper_functions.size > 0
84
+ buf << "\n"
85
+ buf << "# #{helper_functions.size} Helper Functions(s)\n\n"
86
+ helper_functions.each do |func|
87
+ buf << "# - #{func.doc}\n"
88
+ ## buf << " - sig #{func.sig} => 0x#{sig(func.sig).hexdigest}\n"
89
+ end
90
+ end
91
+ =end
92
+
93
+ buf << "end ## class #{name}\n"
94
+ buf << "\n"
95
+ buf
96
+ end
97
+
98
+ end ## class Contract
99
+ end ## module ABI
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: abigen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: abiparser
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '7'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '4.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '7'
47
+ - !ruby/object:Gem::Dependency
48
+ name: hoe
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.23'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.23'
61
+ description: abigen - generate ready-to-use (blockchain) contract services / function
62
+ calls for ethereum & co. via application binary inferfaces (abis)
63
+ email: wwwmake@googlegroups.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files:
67
+ - CHANGELOG.md
68
+ - Manifest.txt
69
+ - README.md
70
+ files:
71
+ - CHANGELOG.md
72
+ - Manifest.txt
73
+ - README.md
74
+ - Rakefile
75
+ - lib/abigen.rb
76
+ homepage: https://github.com/rubycocos/blockchain
77
+ licenses:
78
+ - Public Domain
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options:
82
+ - "--main"
83
+ - README.md
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '2.3'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubygems_version: 3.3.7
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: abigen - generate ready-to-use (blockchain) contract services / function
101
+ calls for ethereum & co. via application binary inferfaces (abis)
102
+ test_files: []