Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
geraldb committed Feb 6, 2023
1 parent f91914e commit 9ff47ac
Show file tree
Hide file tree
Showing 8 changed files with 603 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Gems:
- [abiparser](abiparser) - application binary interface (abi) parser machinery / helper for Ethereum & Co. (blockchain) contracts
- [abidoc](abidoc) - application binary interface (abi) documentation generator for Ethereum & Co. (blockchain) contracts
- [abigen](abigen) - generate ready-to-use (blockchain) contract services / function calls for ethereum & co. via application binary interfaces (abis)
- [abidump](abidump) - command-line tool to dump / pretty print or (re)format application binary interfaces (abi) for Ethereum & Co.
- [abi2sol](abi2sol) - command-line tool for application binary interface (abi) to solidity (contract) source code generation for Ethereum & Co.
- [abibase](abibase) - command line tool / helper to manage application binary interfaces (abis)
- [solidity](solidity) - (fuzzy) parser for (crypto) contracts for ethereum & co.
Expand Down
58 changes: 58 additions & 0 deletions abidump/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/test/tmp/
/test/version_tmp/
/tmp/

## Specific to RubyMotion:
.dat*
.repl_history
build/

## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/

## Environment normalisation:
/.bundle/
/vendor/bundle
/lib/bundler/man/

# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
.ruby-version
.ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc

# Gladiator (Glimmer Editor)
.gladiator
.DS_Store



####
# exclude all tmp & tmp2 and o directory (in all levels)
tmp/
tmp2/
o/

########
# exclude all dbs e.g. artbase.db etc.
*.db

######
# exclude all zips (in /dl)
*.zip



3 changes: 3 additions & 0 deletions abidump/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### 0.0.1 / 2023-02-06

* Everything is new. First release
6 changes: 6 additions & 0 deletions abidump/Manifest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CHANGELOG.md
Manifest.txt
README.md
Rakefile
bin/abidump
lib/abidump.rb
284 changes: 284 additions & 0 deletions abidump/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
# abidump


abidump gem - command-line tool to dump / pretty print or (re)format application binary interfaces (abi) for Ethereum & Co.


* home :: [github.com/rubycocos/blockchain](https://github.com/rubycocos/blockchain)
* bugs :: [github.com/rubycocos/blockchain/issues](https://github.com/rubycocos/blockchain/issues)
* gem :: [rubygems.org/gems/abidump](https://rubygems.org/gems/abidump)
* rdoc :: [rubydoc.info/gems/abidump](http://rubydoc.info/gems/abidump)



## New to the Solidity (Contract) Programming Language?

See [**Awesome Solidity @ Open Blockchains »**](https://github.com/openblockchains/awesome-solidity)




## Usage


Let's try a dry run:

```
$ abidump --help
```

resulting in:

```
==> welcome to the abidump tool
Usage: abidump [options]
-j, --json use json format (default: false)
-y, --yaml use yaml format (default: false)
-h, --help Prints this help
```


Let's pretty print (dump) the application binary interface (abi)
for punks v1 (anno 2017):

```
$ abidump ./address/0x6ba6f2207e343923ba692e5cae646fb0f566db8d/abi.json
```

resulting in:


```
==> summary:
29 abi item(s):
1 constructor
6 events
Assign, Transfer, PunkTransfer, PunkOffered, PunkBought, PunkNoLongerForSale
22 functions
name, reservePunksForOwner, punksOfferedForSale, totalSupply, decimals, withdraw, imageHash, nextPunkIndexToAssign, punkIndexToAddress, standard, balanceOf, buyPunk, transferPunk, symbol, numberOfPunksToReserve, numberOfPunksReserved, offerPunkForSaleToAddress, punksRemainingToAssign, offerPunkForSale, getPunk, pendingWithdrawals, punkNoLongerForSale
==> constructor:
payable: true
inputs (0):
[]
==> event Assign:
anonymous: false
inputs (2):
- type: address
indexed: true
name: to
- type: uint256
indexed: false
name: 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
==> event PunkTransfer:
anonymous: false
inputs (3):
- type: address
indexed: true
name: from
- type: address
indexed: true
name: to
- type: uint256
indexed: false
name: punkIndex
...
==> function name:
constant: true
payable: false
inputs (0):
[]
outputs (1):
- type: string
name: _
==> function reservePunksForOwner:
constant: false
payable: false
inputs (1):
- type: uint256
name: maxForThisRun
outputs (0):
[]
==> function punksOfferedForSale:
constant: true
payable: false
inputs (1):
- type: uint256
name: _
outputs (5):
- type: bool
name: isForSale
- type: uint256
name: punkIndex
- type: address
name: seller
- type: uint256
name: minValue
- type: address
name: onlySellTo
...
```


Let's try to dump (pretty print) the
application binary interface (abi)
for punk blocks (anno 2022):

```
$ abidump ./address/0x58e90596c2065befd3060767736c829c18f3474c/abi.json
```

resulting in:

```
==> summary:
11 abi item(s):
1 constructor
1 event
NewBlock
9 functions
blocks, getBlocks, index, nextId, registerBlock, svgFromIDs, svgFromKeys, svgFromNames, svgFromPunkID
==> constructor:
stateMutability: nonpayable
inputs (0):
[]
==> event NewBlock:
anonymous: false
inputs (3):
- type: address
indexed: false
name: _
- type: uint256
indexed: false
name: _
- type: string
indexed: false
name: _
==> function blocks:
stateMutability: view
inputs (1):
- type: bytes32
name: _
outputs (3):
- type: uint8 (enum PunkBlocks.Layer)
name: layer
- type: bytes
name: dataMale
- type: bytes
name: dataFemale
==> function getBlocks:
stateMutability: view
inputs (2):
- type: uint256
name: _fromID
- type: uint256
name: _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: _
==> function index:
stateMutability: view
inputs (1):
- type: uint256
name: _
outputs (1):
- type: bytes32
name: _
==> function nextId:
stateMutability: view
inputs (0):
[]
outputs (1):
- type: uint256
name: _
==> function registerBlock:
stateMutability: nonpayable
inputs (4):
- type: bytes
name: _dataMale
- type: bytes
name: _dataFemale
- type: uint8
name: _layer
- type: string
name: _name
outputs (0):
[]
==> function svgFromIDs:
stateMutability: view
inputs (1):
- type: uint256[]
name: _ids
outputs (1):
- type: string
name: _
...
```


and so on.


Bonus - Using the `-j / --json` switch / flag
or `-y / --yaml` you can (re)export or (re)format
the application binary interface (abi)
to pretty printed json or yaml. Example.


```
$ abidump --json ./address/0x58e90596c2065befd3060767736c829c18f3474c/abi.json
$ abidump --yaml ./address/0x58e90596c2065befd3060767736c829c18f3474c/abi.json
```



## License

The scripts are dedicated to the public domain.
Use it as you please with no restrictions whatsoever.


## Questions? Comments?


Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.

Loading

0 comments on commit 9ff47ac

Please sign in to comment.