Skip to content

Commit 7b5a471

Browse files
committed
up
1 parent 9ff47ac commit 7b5a471

File tree

3 files changed

+72
-122
lines changed

3 files changed

+72
-122
lines changed

abidump/README.md

Lines changed: 46 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -60,82 +60,56 @@ resulting in:
6060
6161
==> constructor:
6262
payable: true
63-
inputs (0):
64-
[]
63+
inputs (0)
6564
6665
==> event Assign:
6766
anonymous: false
6867
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
7570
7671
==> event Transfer:
7772
anonymous: false
7873
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
8877
8978
==> event PunkTransfer:
9079
anonymous: false
9180
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
10184
10285
...
10386
87+
10488
==> function name:
10589
constant: true
10690
payable: false
107-
inputs (0):
108-
[]
91+
inputs (0)
10992
outputs (1):
110-
- type: string
111-
name: _
93+
string _
11294
11395
==> function reservePunksForOwner:
11496
constant: false
11597
payable: false
11698
inputs (1):
117-
- type: uint256
118-
name: maxForThisRun
119-
outputs (0):
120-
[]
99+
uint256 maxForThisRun
100+
outputs (0)
121101
122102
==> function punksOfferedForSale:
123103
constant: true
124104
payable: false
125105
inputs (1):
126-
- type: uint256
127-
name: _
106+
uint256 _
128107
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
139113
140114
...
141115
```
@@ -162,94 +136,64 @@ resulting in:
162136
163137
==> constructor:
164138
stateMutability: nonpayable
165-
inputs (0):
166-
[]
139+
inputs (0)
167140
168141
==> event NewBlock:
169142
anonymous: false
170143
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 _
180147
181148
==> function blocks:
182149
stateMutability: view
183150
inputs (1):
184-
- type: bytes32
185-
name: _
151+
bytes32 _
186152
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
193156
194157
==> function getBlocks:
195158
stateMutability: view
196159
inputs (2):
197-
- type: uint256
198-
name: _fromID
199-
- type: uint256
200-
name: _count
160+
uint256 _fromID
161+
uint256 _count
201162
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 _
213168
214169
==> function index:
215170
stateMutability: view
216171
inputs (1):
217-
- type: uint256
218-
name: _
172+
uint256 _
219173
outputs (1):
220-
- type: bytes32
221-
name: _
174+
bytes32 _
222175
223176
==> function nextId:
224177
stateMutability: view
225-
inputs (0):
226-
[]
178+
inputs (0)
227179
outputs (1):
228-
- type: uint256
229-
name: _
180+
uint256 _
230181
231182
==> function registerBlock:
232183
stateMutability: nonpayable
233184
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)
244190
245191
==> function svgFromIDs:
246192
stateMutability: view
247193
inputs (1):
248-
- type: uint256[]
249-
name: _ids
194+
uint256[] _ids
250195
outputs (1):
251-
- type: string
252-
name: _
196+
string _
253197
254198
...
255199
```

abidump/Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ end
1010

1111
Hoe.spec 'abidump' do
1212

13-
self.version = '0.1.0'
13+
self.version = '0.1.1'
1414

1515
self.summary = "abidump gem - command-line tool to dump / pretty print or (re)format application binary interfaces (abi) for Ethereum & Co."
1616
self.description = summary

abidump/lib/abidump.rb

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def self.do_dump_json( data )
7272
puts buf
7373
end
7474

75-
def self._norm_types( data )
75+
def self._dump_types( data, indent: 2 )
7676
## hack: remove items and re-add to sort key order!!!
7777
##
7878
## clean-up / normalize type
@@ -91,26 +91,24 @@ def self._norm_types( data )
9191
exit 1
9292
end
9393

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
10197
## note: change empty name e.g. '' to _ - why? why not?
10298
if name
103-
h['name'] = name.empty? ? "_" : name
99+
print ' '
100+
print name.empty? ? "_" : name
104101
end
105102

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
110107
end
111108
end
112109

113110

111+
114112
def self._dump( data, indent: 2 )
115113
buf = YAML.dump( data )
116114
buf = buf.sub( /^---\n?/, '' ) ## remove leading --- if present
@@ -153,15 +151,23 @@ def self.do_dump( data )
153151
_dump( h, indent: 6 )
154152

155153
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
159161
end
160162

161163
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
165171
end
166172
end
167173

0 commit comments

Comments
 (0)