Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldb committed Feb 7, 2023
1 parent 9ff47ac commit 7b5a471
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 122 deletions.
148 changes: 46 additions & 102 deletions abidump/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,82 +60,56 @@ resulting in:
==> constructor:
payable: true
inputs (0):
[]
inputs (0)
==> event Assign:
anonymous: false
inputs (2):
- type: address
indexed: true
name: to
- type: uint256
indexed: false
name: punkIndex
address indexed to
uint256 punkIndex
==> event Transfer:
anonymous: false
inputs (3):
- type: address
indexed: true
name: from
- type: address
indexed: true
name: to
- type: uint256
indexed: false
name: value
address indexed from
address indexed to
uint256 value
==> event PunkTransfer:
anonymous: false
inputs (3):
- type: address
indexed: true
name: from
- type: address
indexed: true
name: to
- type: uint256
indexed: false
name: punkIndex
address indexed from
address indexed to
uint256 punkIndex
...
==> function name:
constant: true
payable: false
inputs (0):
[]
inputs (0)
outputs (1):
- type: string
name: _
string _
==> function reservePunksForOwner:
constant: false
payable: false
inputs (1):
- type: uint256
name: maxForThisRun
outputs (0):
[]
uint256 maxForThisRun
outputs (0)
==> function punksOfferedForSale:
constant: true
payable: false
inputs (1):
- type: uint256
name: _
uint256 _
outputs (5):
- type: bool
name: isForSale
- type: uint256
name: punkIndex
- type: address
name: seller
- type: uint256
name: minValue
- type: address
name: onlySellTo
bool isForSale
uint256 punkIndex
address seller
uint256 minValue
address onlySellTo
...
```
Expand All @@ -162,94 +136,64 @@ resulting in:
==> constructor:
stateMutability: nonpayable
inputs (0):
[]
inputs (0)
==> event NewBlock:
anonymous: false
inputs (3):
- type: address
indexed: false
name: _
- type: uint256
indexed: false
name: _
- type: string
indexed: false
name: _
address _
uint256 _
string _
==> function blocks:
stateMutability: view
inputs (1):
- type: bytes32
name: _
bytes32 _
outputs (3):
- type: uint8 (enum PunkBlocks.Layer)
name: layer
- type: bytes
name: dataMale
- type: bytes
name: dataFemale
uint8 layer - enum PunkBlocks.Layer
bytes dataMale
bytes dataFemale
==> function getBlocks:
stateMutability: view
inputs (2):
- type: uint256
name: _fromID
- type: uint256
name: _count
uint256 _fromID
uint256 _count
outputs (2):
- type: tuple[] (struct PunkBlocks.Block[])
name: _
components:
- type: uint8 (enum PunkBlocks.Layer)
name: layer
- type: bytes
name: dataMale
- type: bytes
name: dataFemale
- type: uint256
name: _
tuple[] _ - struct PunkBlocks.Block[]
uint8 layer - enum PunkBlocks.Layer
bytes dataMale
bytes dataFemale
uint256 _
==> function index:
stateMutability: view
inputs (1):
- type: uint256
name: _
uint256 _
outputs (1):
- type: bytes32
name: _
bytes32 _
==> function nextId:
stateMutability: view
inputs (0):
[]
inputs (0)
outputs (1):
- type: uint256
name: _
uint256 _
==> function registerBlock:
stateMutability: nonpayable
inputs (4):
- type: bytes
name: _dataMale
- type: bytes
name: _dataFemale
- type: uint8
name: _layer
- type: string
name: _name
outputs (0):
[]
bytes _dataMale
bytes _dataFemale
uint8 _layer
string _name
outputs (0)
==> function svgFromIDs:
stateMutability: view
inputs (1):
- type: uint256[]
name: _ids
uint256[] _ids
outputs (1):
- type: string
name: _
string _
...
```
Expand Down
2 changes: 1 addition & 1 deletion abidump/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end

Hoe.spec 'abidump' do

self.version = '0.1.0'
self.version = '0.1.1'

self.summary = "abidump gem - command-line tool to dump / pretty print or (re)format application binary interfaces (abi) for Ethereum & Co."
self.description = summary
Expand Down
44 changes: 25 additions & 19 deletions abidump/lib/abidump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def self.do_dump_json( data )
puts buf
end

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

h['type'] = type if type
if type && internal_type && type != internal_type
h['type'] += " (#{internal_type})"
end

h['indexed'] = indexed unless indexed.nil? ## note: indexed is a true/false prop

print ' ' * indent
print type
print ' indexed' if indexed ## note: indexed is a true/false prop
## note: change empty name e.g. '' to _ - why? why not?
if name
h['name'] = name.empty? ? "_" : name
print ' '
print name.empty? ? "_" : name
end

if components
h['components'] = components
_norm_types( components)
end
print " - #{internal_type}" if type && internal_type && type != internal_type
print "\n"

_dump_types( components, indent: indent+2 ) if components
end
end



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

if inputs
puts " inputs (#{inputs.size}):"
_norm_types( inputs )
_dump( inputs, indent: 6 )
print " inputs (#{inputs.size})"
if inputs.size > 0
print ":\n"
_dump_types( inputs, indent: 6 )
else
print "\n"
end
end

if outputs
puts " outputs (#{outputs.size}):"
_norm_types( outputs )
_dump( outputs, indent: 6 )
print " outputs (#{outputs.size})"
if outputs.size > 0
print ":\n"
_dump_types( outputs, indent: 6 )
else
print "\n"
end
end
end

Expand Down

0 comments on commit 7b5a471

Please sign in to comment.