abidump 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +46 -102
  3. data/Rakefile +1 -1
  4. data/lib/abidump.rb +25 -19
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4ffdb9017adf411045359acd07b66756f48f58339604ef43354e59b46430e27
4
- data.tar.gz: 4b405724f017886a0fedb5662125358a068b916ae39b721abe476ed73e3b9c35
3
+ metadata.gz: 0f2dc33040c14d033301c064a4d7c55689c43f2419e3dc948158f07152e8c1ec
4
+ data.tar.gz: 890e3b8b95fda78b3d4dc537f6f703a0ae54078852d327132b439c065d03097c
5
5
  SHA512:
6
- metadata.gz: 7624386685f09523f23dc64b53cdecde1e88dae0b7c2c7e2ace3d8cc75b92f720ca1e49f50960b011538f84711ccc5380237803909f1cc2a748e50cfefadc0c5
7
- data.tar.gz: 9f76dad3a9f5d83ae5db4ab1ce935c719edcbc9f7e5132567760dfefc8202841dd27b97e3b430207b4aeed5c22ea396ccfa0d590715c84c381f686d77aef5b14
6
+ metadata.gz: 8d306476559852cb6317ba0b451033df61ea3b66d7f17f99f063e86114acf7d3f85d471a792e1d5fce53c7f4ddec9249d2335ba6b5d35a5de7ac12576609086c
7
+ data.tar.gz: 6c8a2646ac45ae3825f774b2f8005913d4b4b6d28e4a5797500e97b52ab484f2dda7a52c8da170769d7a52aac75207f86cf55b122f1517d47cc620c5c0ee6419
data/README.md CHANGED
@@ -60,82 +60,56 @@ resulting in:
60
60
 
61
61
  ==> constructor:
62
62
  payable: true
63
- inputs (0):
64
- []
63
+ inputs (0)
65
64
 
66
65
  ==> event Assign:
67
66
  anonymous: false
68
67
  inputs (2):
69
- - type: address
70
- indexed: true
71
- name: to
72
- - type: uint256
73
- indexed: false
74
- name: punkIndex
68
+ address indexed to
69
+ uint256 punkIndex
75
70
 
76
71
  ==> event Transfer:
77
72
  anonymous: false
78
73
  inputs (3):
79
- - type: address
80
- indexed: true
81
- name: from
82
- - type: address
83
- indexed: true
84
- name: to
85
- - type: uint256
86
- indexed: false
87
- name: value
74
+ address indexed from
75
+ address indexed to
76
+ uint256 value
88
77
 
89
78
  ==> event PunkTransfer:
90
79
  anonymous: false
91
80
  inputs (3):
92
- - type: address
93
- indexed: true
94
- name: from
95
- - type: address
96
- indexed: true
97
- name: to
98
- - type: uint256
99
- indexed: false
100
- name: punkIndex
81
+ address indexed from
82
+ address indexed to
83
+ uint256 punkIndex
101
84
 
102
85
  ...
103
86
 
87
+
104
88
  ==> function name:
105
89
  constant: true
106
90
  payable: false
107
- inputs (0):
108
- []
91
+ inputs (0)
109
92
  outputs (1):
110
- - type: string
111
- name: _
93
+ string _
112
94
 
113
95
  ==> function reservePunksForOwner:
114
96
  constant: false
115
97
  payable: false
116
98
  inputs (1):
117
- - type: uint256
118
- name: maxForThisRun
119
- outputs (0):
120
- []
99
+ uint256 maxForThisRun
100
+ outputs (0)
121
101
 
122
102
  ==> function punksOfferedForSale:
123
103
  constant: true
124
104
  payable: false
125
105
  inputs (1):
126
- - type: uint256
127
- name: _
106
+ uint256 _
128
107
  outputs (5):
129
- - type: bool
130
- name: isForSale
131
- - type: uint256
132
- name: punkIndex
133
- - type: address
134
- name: seller
135
- - type: uint256
136
- name: minValue
137
- - type: address
138
- name: onlySellTo
108
+ bool isForSale
109
+ uint256 punkIndex
110
+ address seller
111
+ uint256 minValue
112
+ address onlySellTo
139
113
 
140
114
  ...
141
115
  ```
@@ -162,94 +136,64 @@ resulting in:
162
136
 
163
137
  ==> constructor:
164
138
  stateMutability: nonpayable
165
- inputs (0):
166
- []
139
+ inputs (0)
167
140
 
168
141
  ==> event NewBlock:
169
142
  anonymous: false
170
143
  inputs (3):
171
- - type: address
172
- indexed: false
173
- name: _
174
- - type: uint256
175
- indexed: false
176
- name: _
177
- - type: string
178
- indexed: false
179
- name: _
144
+ address _
145
+ uint256 _
146
+ string _
180
147
 
181
148
  ==> function blocks:
182
149
  stateMutability: view
183
150
  inputs (1):
184
- - type: bytes32
185
- name: _
151
+ bytes32 _
186
152
  outputs (3):
187
- - type: uint8 (enum PunkBlocks.Layer)
188
- name: layer
189
- - type: bytes
190
- name: dataMale
191
- - type: bytes
192
- name: dataFemale
153
+ uint8 layer - enum PunkBlocks.Layer
154
+ bytes dataMale
155
+ bytes dataFemale
193
156
 
194
157
  ==> function getBlocks:
195
158
  stateMutability: view
196
159
  inputs (2):
197
- - type: uint256
198
- name: _fromID
199
- - type: uint256
200
- name: _count
160
+ uint256 _fromID
161
+ uint256 _count
201
162
  outputs (2):
202
- - type: tuple[] (struct PunkBlocks.Block[])
203
- name: _
204
- components:
205
- - type: uint8 (enum PunkBlocks.Layer)
206
- name: layer
207
- - type: bytes
208
- name: dataMale
209
- - type: bytes
210
- name: dataFemale
211
- - type: uint256
212
- name: _
163
+ tuple[] _ - struct PunkBlocks.Block[]
164
+ uint8 layer - enum PunkBlocks.Layer
165
+ bytes dataMale
166
+ bytes dataFemale
167
+ uint256 _
213
168
 
214
169
  ==> function index:
215
170
  stateMutability: view
216
171
  inputs (1):
217
- - type: uint256
218
- name: _
172
+ uint256 _
219
173
  outputs (1):
220
- - type: bytes32
221
- name: _
174
+ bytes32 _
222
175
 
223
176
  ==> function nextId:
224
177
  stateMutability: view
225
- inputs (0):
226
- []
178
+ inputs (0)
227
179
  outputs (1):
228
- - type: uint256
229
- name: _
180
+ uint256 _
230
181
 
231
182
  ==> function registerBlock:
232
183
  stateMutability: nonpayable
233
184
  inputs (4):
234
- - type: bytes
235
- name: _dataMale
236
- - type: bytes
237
- name: _dataFemale
238
- - type: uint8
239
- name: _layer
240
- - type: string
241
- name: _name
242
- outputs (0):
243
- []
185
+ bytes _dataMale
186
+ bytes _dataFemale
187
+ uint8 _layer
188
+ string _name
189
+ outputs (0)
244
190
 
245
191
  ==> function svgFromIDs:
246
192
  stateMutability: view
247
193
  inputs (1):
248
- - type: uint256[]
249
- name: _ids
194
+ uint256[] _ids
250
195
  outputs (1):
251
- - type: string
252
- name: _
196
+ string _
253
197
 
254
198
  ...
255
199
  ```
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  Hoe.spec 'abidump' do
12
12
 
13
- self.version = '0.1.0'
13
+ self.version = '0.1.1'
14
14
 
15
15
  self.summary = "abidump gem - command-line tool to dump / pretty print or (re)format application binary interfaces (abi) for Ethereum & Co."
16
16
  self.description = summary
data/lib/abidump.rb CHANGED
@@ -72,7 +72,7 @@ module ABIDump
72
72
  puts buf
73
73
  end
74
74
 
75
- def self._norm_types( data )
75
+ def self._dump_types( data, indent: 2 )
76
76
  ## hack: remove items and re-add to sort key order!!!
77
77
  ##
78
78
  ## clean-up / normalize type
@@ -91,26 +91,24 @@ module ABIDump
91
91
  exit 1
92
92
  end
93
93
 
94
- h['type'] = type if type
95
- if type && internal_type && type != internal_type
96
- h['type'] += " (#{internal_type})"
97
- end
98
-
99
- h['indexed'] = indexed unless indexed.nil? ## note: indexed is a true/false prop
100
-
94
+ print ' ' * indent
95
+ print type
96
+ print ' indexed' if indexed ## note: indexed is a true/false prop
101
97
  ## note: change empty name e.g. '' to _ - why? why not?
102
98
  if name
103
- h['name'] = name.empty? ? "_" : name
99
+ print ' '
100
+ print name.empty? ? "_" : name
104
101
  end
105
102
 
106
- if components
107
- h['components'] = components
108
- _norm_types( components)
109
- end
103
+ print " - #{internal_type}" if type && internal_type && type != internal_type
104
+ print "\n"
105
+
106
+ _dump_types( components, indent: indent+2 ) if components
110
107
  end
111
108
  end
112
109
 
113
110
 
111
+
114
112
  def self._dump( data, indent: 2 )
115
113
  buf = YAML.dump( data )
116
114
  buf = buf.sub( /^---\n?/, '' ) ## remove leading --- if present
@@ -153,15 +151,23 @@ module ABIDump
153
151
  _dump( h, indent: 6 )
154
152
 
155
153
  if inputs
156
- puts " inputs (#{inputs.size}):"
157
- _norm_types( inputs )
158
- _dump( inputs, indent: 6 )
154
+ print " inputs (#{inputs.size})"
155
+ if inputs.size > 0
156
+ print ":\n"
157
+ _dump_types( inputs, indent: 6 )
158
+ else
159
+ print "\n"
160
+ end
159
161
  end
160
162
 
161
163
  if outputs
162
- puts " outputs (#{outputs.size}):"
163
- _norm_types( outputs )
164
- _dump( outputs, indent: 6 )
164
+ print " outputs (#{outputs.size})"
165
+ if outputs.size > 0
166
+ print ":\n"
167
+ _dump_types( outputs, indent: 6 )
168
+ else
169
+ print "\n"
170
+ end
165
171
  end
166
172
  end
167
173
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abidump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-06 00:00:00.000000000 Z
11
+ date: 2023-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos