solidity 0.0.1 → 0.1.1

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
- SHA1:
3
- metadata.gz: 9faf35cb510544cdeeda413efe3b0e4afef0f066
4
- data.tar.gz: '013219c327a0515ddac5f3359ad20a1b533f904d'
2
+ SHA256:
3
+ metadata.gz: e72e223ba2202849d7dbb405a56b1edf7345b911813b3449bbf2059a9ebe87e5
4
+ data.tar.gz: 2aa7d53cc55bc04929440cb3c49c99b85cc3efe0a151d24f9b887c2ac6297f09
5
5
  SHA512:
6
- metadata.gz: ae5925d7c00a81b194fa52e885f81ab1c29f4f377547fdc7d39f1db34275f93e18e92025296463005a6c8a034e15448c3ebe8bc0bccfc8272b18b90720808560
7
- data.tar.gz: d6d5bdbbc7a7b0f5bef7a727c3f40980a2375436b3dfe990026c1430005a539fcc1bc16d68a8df18d532c8fe14f6cd18808a47f69a992489a3f8862e44bfdae5
6
+ metadata.gz: 25a530da83da24bbbf6ae85bc97a4ecac8d27eb0745d2952f3f43fda6ad3422021d798edffcafc9e03afcf6bd6d0c7985103fec52caa34987ffdb5d84a8699fd
7
+ data.tar.gz: '09339328d15e47d6d9a6345f000cbc1dee7fce14dee04e14765f82add73824dbce6fa41ba0dfe1a190059b5aeef93b6c27dc3acf759f67bb0348556098f127e5'
data/Manifest.txt CHANGED
@@ -1,5 +1,4 @@
1
1
  CHANGELOG.md
2
- LICENSE.md
3
2
  Manifest.txt
4
3
  README.md
5
4
  Rakefile
data/README.md CHANGED
@@ -1,22 +1,103 @@
1
+ # Solidity
1
2
 
2
- # Solidity - type-safe (crypto) contracts
3
+ solidity gem - (fuzzy) parser for (crypto) contracts for ethereum & co.
3
4
 
4
- solidity gem / library - type-safe (crypto) contracts
5
5
 
6
- * home :: [github.com/s6ruby/ruby-to-solidity](https://github.com/s6ruby/ruby-to-solidity)
7
- * bugs :: [github.com/s6ruby/ruby-to-solidity/issues](https://github.com/s6ruby/ruby-to-solidity/issues)
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
8
  * gem :: [rubygems.org/gems/solidity](https://rubygems.org/gems/solidity)
9
9
  * rdoc :: [rubydoc.info/gems/solidity](http://rubydoc.info/gems/solidity)
10
10
 
11
11
 
12
12
 
13
+
14
+
13
15
  ## Usage
14
16
 
15
- To be done
17
+ Get / generate outline from source in the solidity (`.sol`) contract programming language:
16
18
 
17
- ## License
19
+ ```ruby
20
+ [
21
+ "0x34625ecaa75c0ea33733a05c584f4cf112c10b6b",
22
+ "0x0cfdb3ba1694c2bb2cfacb0339ad7b1ae5932b63",
23
+ "0x031920cc2d9f5c10b444fd44009cd64f829e7be2"
24
+ ].each do |addr|
25
+
26
+ path = "awesome-contracts/address/#{addr}/contract.sol"
27
+ txt = read_text( path )
28
+
29
+ parser = Solidity::Parser.new( txt )
30
+
31
+ puts "---"
32
+ puts "outline:"
33
+ puts parser.outline
34
+
35
+ ## bonus: dump the pragmas (required solidity compiler versions)
36
+ puts
37
+ puts "pragmas:"
38
+ puts parser.pragmas
39
+ ```
40
+
41
+ Resulting in:
42
+
43
+ ```
44
+ outline:
45
+ contract NounsDescriptor is INounsDescriptor, Ownable
46
+ abstract contract Ownable is Context
47
+ library Strings
48
+ interface INounsDescriptor
49
+ interface INounsSeeder
50
+ library NFTDescriptor
51
+ library MultiPartRLEToSVG
52
+ abstract contract Context
53
+ library Base64
54
+ ```
18
55
 
19
- ![](https://publicdomainworks.github.io/buttons/zero88x31.png)
56
+
57
+ ```
58
+ outline:
59
+ contract Indelible is ERC721A, ReentrancyGuard, Ownable
60
+ library DynamicBuffer
61
+ library HelperLib
62
+ library SSTORE2
63
+ library Bytecode
64
+ abstract contract Ownable is Context
65
+ abstract contract ReentrancyGuard
66
+ library Address
67
+ library Base64
68
+ abstract contract Context
69
+ library MerkleProof
70
+ contract ERC721A is IERC721A
71
+ interface IERC721A
72
+ ```
73
+
74
+
75
+ ```
76
+ outline:
77
+ contract CryptoZunks is Ownable, ERC721Enumerable, ERC721Burnable, ReentrancyGuard
78
+ abstract contract Ownable is Context
79
+ abstract contract ReentrancyGuard
80
+ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata
81
+ abstract contract ERC721Burnable is Context, ERC721
82
+ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable
83
+ library Strings
84
+ library EnumerableMap
85
+ library console
86
+ abstract contract Context
87
+ interface IERC721 is IERC165
88
+ interface IERC721Receiver
89
+ interface IERC721Metadata is IERC721
90
+ library Address
91
+ abstract contract ERC165 is IERC165
92
+ interface IERC165
93
+ interface IERC721Enumerable is IERC721
94
+ library EnumerableSet
95
+ ```
96
+
97
+
98
+
99
+
100
+ ## License
20
101
 
21
102
  The `solidity` scripts are dedicated to the public domain.
22
103
  Use it as you please with no restrictions whatsoever.
@@ -24,5 +105,5 @@ Use it as you please with no restrictions whatsoever.
24
105
 
25
106
  ## Questions? Comments?
26
107
 
27
- Send them along to the [wwwmake forum](http://groups.google.com/group/wwwmake).
28
- Thanks!
108
+ Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.
109
+
data/Rakefile CHANGED
@@ -5,10 +5,10 @@ Hoe.spec 'solidity' do
5
5
 
6
6
  self.version = Solidity::VERSION
7
7
 
8
- self.summary = "solidity - type-safe (crypto) contracts"
8
+ self.summary = "solidity - (fuzzy) parser for (crypto) contracts for ethereum & co."
9
9
  self.description = summary
10
10
 
11
- self.urls = ['https://github.com/s6ruby/ruby-to-solidity']
11
+ self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
14
  self.email = 'wwwmake@googlegroups.com'
@@ -18,6 +18,7 @@ Hoe.spec 'solidity' do
18
18
  self.history_file = 'CHANGELOG.md'
19
19
 
20
20
  self.extra_deps = [
21
+ ['cocos'],
21
22
  ]
22
23
 
23
24
  self.licenses = ['Public Domain']
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
-
3
1
 
4
2
  module Solidity
5
3
 
6
4
  MAJOR = 0
7
- MINOR = 0
5
+ MINOR = 1
8
6
  PATCH = 1
9
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
8
 
@@ -13,11 +11,11 @@ module Solidity
13
11
  end
14
12
 
15
13
  def self.banner
16
- "solidity/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
14
+ "solidity/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
17
15
  end
18
16
 
19
17
  def self.root
20
- "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
18
+ File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
21
19
  end
22
20
 
23
21
  end # module Solidity
data/lib/solidity.rb CHANGED
@@ -1,9 +1,128 @@
1
- # encoding: utf-8
1
+ require 'cocos'
2
2
 
3
- require 'pp'
4
3
 
5
4
  ## our own code
6
- require 'solidity/version' # note: let version always go first
5
+ require_relative 'solidity/version' # note: let version always go first
6
+
7
+
8
+
9
+
10
+ module Solidity
11
+
12
+ class Parser
13
+ def initialize( txt )
14
+ @txt = txt
15
+ end
16
+
17
+
18
+ SINGLE_COMMENT_RX = %r{^[ ]*//}
19
+ MULTI_COMMENT_BEGIN_RX = %r{^[ ]*/\*}
20
+ MULTI_COMMENT_END_RX = %r{\*/[ ]*$}
21
+
22
+ ID = '[a-zA-Z][a-zA-Z0-9]*'
23
+
24
+ PRAGMA_RX = %r{^[ ]*pragma}
25
+ LIBRARY_RX = %r{^[ ]*library[ ]+(?<id>#{ID})[ \{]}
26
+ ABSTRACT_CONTRACT_RX = %r{^[ ]*abstract[ ]+contract[ ]+(?<id>#{ID})[ \{]}
27
+ CONTRACT_RX = %r{^[ ]*contract[ ]+(?<id>#{ID})[ \{]}
28
+ INTERFACE_RX = %r{^[ ]*interface[ ]+(?<id>#{ID})[ \{]}
29
+
30
+
31
+ def _quick_pass_one
32
+ tree = []
33
+ node = nil
34
+
35
+ inside_comment = false
36
+
37
+ @txt.each_line do |line|
38
+ line = line.chomp ## remove trailing newline
39
+ ## pp line
40
+
41
+ if inside_comment
42
+ node[1] << line
43
+ if MULTI_COMMENT_END_RX.match( line )
44
+ tree << node
45
+ inside_comment = false
46
+ end
47
+ else
48
+ if SINGLE_COMMENT_RX.match( line ) # end-of-line comments
49
+ line = line.strip ## remove leading & trailing spaces
50
+ ## note: fold end-of-line comments into a block (if not separated by newline)
51
+ node = tree[-1]
52
+ if node.is_a?( Array ) &&
53
+ node[0] == :comment && node[1][0].start_with?( '//' )
54
+ node[1] << line
55
+ else
56
+ tree << [:comment, [line]]
57
+ end
58
+ elsif MULTI_COMMENT_BEGIN_RX.match( line )
59
+ inside_comment = true
60
+ node = [:comment, [line]]
61
+ elsif PRAGMA_RX.match( line )
62
+ line = line.strip
63
+ tree << [:pragma, line]
64
+ elsif LIBRARY_RX.match( line )
65
+ line = line.strip
66
+ tree << [:library, line]
67
+ elsif ABSTRACT_CONTRACT_RX.match( line )
68
+ line = line.strip
69
+ tree << [:abstract_contract, line]
70
+ elsif CONTRACT_RX.match( line )
71
+ line = line.strip
72
+ tree << [:contract, line]
73
+ elsif INTERFACE_RX.match( line )
74
+ line = line.strip
75
+ tree << [:interface, line]
76
+ else
77
+ tree << line
78
+ end
79
+ end
80
+ end # each_line
81
+
82
+ tree
83
+ end
84
+
85
+
86
+ def outline
87
+ buf = String.new( '' )
88
+ tree = _quick_pass_one
89
+
90
+ tree.each do |node|
91
+ if node.is_a?( Array )
92
+ case node[0]
93
+ when :contract then buf << node[1] << "\n"
94
+ when :abstract_contract then buf << node[1] << "\n"
95
+ when :interface then buf << node[1] << "\n"
96
+ when :library then buf << node[1] << "\n"
97
+ else
98
+ end
99
+ end
100
+ end
101
+
102
+ buf
103
+ end
104
+
105
+ def pragmas
106
+ buf = String.new( '' )
107
+ tree = _quick_pass_one
108
+
109
+ tree.each do |node|
110
+ if node.is_a?( Array )
111
+ case node[0]
112
+ when :pragma then buf << node[1] << "\n"
113
+ end
114
+ end
115
+ end
116
+
117
+ buf
118
+ end
119
+
120
+
121
+ end # class Parser
122
+
123
+
124
+ end # module Solidity
125
+
7
126
 
8
127
 
9
128
  puts Solidity.banner ## say hello
metadata CHANGED
@@ -1,65 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-11 00:00:00.000000000 Z
11
+ date: 2023-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cocos
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'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rdoc
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - "~>"
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
33
  version: '4.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '7'
20
37
  type: :development
21
38
  prerelease: false
22
39
  version_requirements: !ruby/object:Gem::Requirement
23
40
  requirements:
24
- - - "~>"
41
+ - - ">="
25
42
  - !ruby/object:Gem::Version
26
43
  version: '4.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '7'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: hoe
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
51
  - - "~>"
32
52
  - !ruby/object:Gem::Version
33
- version: '3.16'
53
+ version: '3.23'
34
54
  type: :development
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
58
  - - "~>"
39
59
  - !ruby/object:Gem::Version
40
- version: '3.16'
41
- description: solidity - type-safe (crypto) contracts
60
+ version: '3.23'
61
+ description: solidity - (fuzzy) parser for (crypto) contracts for ethereum & co.
42
62
  email: wwwmake@googlegroups.com
43
63
  executables: []
44
64
  extensions: []
45
65
  extra_rdoc_files:
46
66
  - CHANGELOG.md
47
- - LICENSE.md
48
67
  - Manifest.txt
49
68
  - README.md
50
69
  files:
51
70
  - CHANGELOG.md
52
- - LICENSE.md
53
71
  - Manifest.txt
54
72
  - README.md
55
73
  - Rakefile
56
74
  - lib/solidity.rb
57
75
  - lib/solidity/version.rb
58
- homepage: https://github.com/s6ruby/ruby-to-solidity
76
+ homepage: https://github.com/rubycocos/blockchain
59
77
  licenses:
60
78
  - Public Domain
61
79
  metadata: {}
62
- post_install_message:
80
+ post_install_message:
63
81
  rdoc_options:
64
82
  - "--main"
65
83
  - README.md
@@ -76,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
94
  - !ruby/object:Gem::Version
77
95
  version: '0'
78
96
  requirements: []
79
- rubyforge_project:
80
- rubygems_version: 2.5.2
81
- signing_key:
97
+ rubygems_version: 3.3.7
98
+ signing_key:
82
99
  specification_version: 4
83
- summary: solidity - type-safe (crypto) contracts
100
+ summary: solidity - (fuzzy) parser for (crypto) contracts for ethereum & co.
84
101
  test_files: []
data/LICENSE.md DELETED
@@ -1,116 +0,0 @@
1
- CC0 1.0 Universal
2
-
3
- Statement of Purpose
4
-
5
- The laws of most jurisdictions throughout the world automatically confer
6
- exclusive Copyright and Related Rights (defined below) upon the creator and
7
- subsequent owner(s) (each and all, an "owner") of an original work of
8
- authorship and/or a database (each, a "Work").
9
-
10
- Certain owners wish to permanently relinquish those rights to a Work for the
11
- purpose of contributing to a commons of creative, cultural and scientific
12
- works ("Commons") that the public can reliably and without fear of later
13
- claims of infringement build upon, modify, incorporate in other works, reuse
14
- and redistribute as freely as possible in any form whatsoever and for any
15
- purposes, including without limitation commercial purposes. These owners may
16
- contribute to the Commons to promote the ideal of a free culture and the
17
- further production of creative, cultural and scientific works, or to gain
18
- reputation or greater distribution for their Work in part through the use and
19
- efforts of others.
20
-
21
- For these and/or other purposes and motivations, and without any expectation
22
- of additional consideration or compensation, the person associating CC0 with a
23
- Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24
- and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25
- and publicly distribute the Work under its terms, with knowledge of his or her
26
- Copyright and Related Rights in the Work and the meaning and intended legal
27
- effect of CC0 on those rights.
28
-
29
- 1. Copyright and Related Rights. A Work made available under CC0 may be
30
- protected by copyright and related or neighboring rights ("Copyright and
31
- Related Rights"). Copyright and Related Rights include, but are not limited
32
- to, the following:
33
-
34
- i. the right to reproduce, adapt, distribute, perform, display, communicate,
35
- and translate a Work;
36
-
37
- ii. moral rights retained by the original author(s) and/or performer(s);
38
-
39
- iii. publicity and privacy rights pertaining to a person's image or likeness
40
- depicted in a Work;
41
-
42
- iv. rights protecting against unfair competition in regards to a Work,
43
- subject to the limitations in paragraph 4(a), below;
44
-
45
- v. rights protecting the extraction, dissemination, use and reuse of data in
46
- a Work;
47
-
48
- vi. database rights (such as those arising under Directive 96/9/EC of the
49
- European Parliament and of the Council of 11 March 1996 on the legal
50
- protection of databases, and under any national implementation thereof,
51
- including any amended or successor version of such directive); and
52
-
53
- vii. other similar, equivalent or corresponding rights throughout the world
54
- based on applicable law or treaty, and any national implementations thereof.
55
-
56
- 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57
- applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58
- unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59
- and Related Rights and associated claims and causes of action, whether now
60
- known or unknown (including existing as well as future claims and causes of
61
- action), in the Work (i) in all territories worldwide, (ii) for the maximum
62
- duration provided by applicable law or treaty (including future time
63
- extensions), (iii) in any current or future medium and for any number of
64
- copies, and (iv) for any purpose whatsoever, including without limitation
65
- commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66
- the Waiver for the benefit of each member of the public at large and to the
67
- detriment of Affirmer's heirs and successors, fully intending that such Waiver
68
- shall not be subject to revocation, rescission, cancellation, termination, or
69
- any other legal or equitable action to disrupt the quiet enjoyment of the Work
70
- by the public as contemplated by Affirmer's express Statement of Purpose.
71
-
72
- 3. Public License Fallback. Should any part of the Waiver for any reason be
73
- judged legally invalid or ineffective under applicable law, then the Waiver
74
- shall be preserved to the maximum extent permitted taking into account
75
- Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76
- is so judged Affirmer hereby grants to each affected person a royalty-free,
77
- non transferable, non sublicensable, non exclusive, irrevocable and
78
- unconditional license to exercise Affirmer's Copyright and Related Rights in
79
- the Work (i) in all territories worldwide, (ii) for the maximum duration
80
- provided by applicable law or treaty (including future time extensions), (iii)
81
- in any current or future medium and for any number of copies, and (iv) for any
82
- purpose whatsoever, including without limitation commercial, advertising or
83
- promotional purposes (the "License"). The License shall be deemed effective as
84
- of the date CC0 was applied by Affirmer to the Work. Should any part of the
85
- License for any reason be judged legally invalid or ineffective under
86
- applicable law, such partial invalidity or ineffectiveness shall not
87
- invalidate the remainder of the License, and in such case Affirmer hereby
88
- affirms that he or she will not (i) exercise any of his or her remaining
89
- Copyright and Related Rights in the Work or (ii) assert any associated claims
90
- and causes of action with respect to the Work, in either case contrary to
91
- Affirmer's express Statement of Purpose.
92
-
93
- 4. Limitations and Disclaimers.
94
-
95
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
96
- surrendered, licensed or otherwise affected by this document.
97
-
98
- b. Affirmer offers the Work as-is and makes no representations or warranties
99
- of any kind concerning the Work, express, implied, statutory or otherwise,
100
- including without limitation warranties of title, merchantability, fitness
101
- for a particular purpose, non infringement, or the absence of latent or
102
- other defects, accuracy, or the present or absence of errors, whether or not
103
- discoverable, all to the greatest extent permissible under applicable law.
104
-
105
- c. Affirmer disclaims responsibility for clearing rights of other persons
106
- that may apply to the Work or any use thereof, including without limitation
107
- any person's Copyright and Related Rights in the Work. Further, Affirmer
108
- disclaims responsibility for obtaining any necessary consents, permissions
109
- or other rights required for any use of the Work.
110
-
111
- d. Affirmer understands and acknowledges that Creative Commons is not a
112
- party to this document and has no duty or obligation with respect to this
113
- CC0 or use of the Work.
114
-
115
- For more information, please see
116
- <http://creativecommons.org/publicdomain/zero/1.0/