Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaldonkey committed Feb 26, 2018
2 parents d009bc8 + 5787c76 commit 9c8a748
Show file tree
Hide file tree
Showing 70 changed files with 6,355 additions and 4,345 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
vendor
composer.lock
TRASH
# Documentation is autogenerated by doxygen.
docs
doc
*generatedTest.php

!docs/.gitkeep

# General OSX
# See: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
.DS_Store
.AppleDouble
.LSOverride
._*

75 changes: 75 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# API development

### Schema based API

In order to keep this API up do date it is build schema based.
(resources/ethjs-schema.json)

Ethereum **JsonRPC Methods** are on ethereum-schema->methods. Implemented in Ethereum class.
Check out the JsonRpcInterface.

To regenerate src/EthMethods.php and src/JsonRpcInterface.php run

```
composer run-script generate-methods
```


**Complex Data types**
are generated ethereum-schema->objects.
Currently these are:

```
EthSyncing
SendTransaction
EstimateTransaction
CallTransaction
Block
Transaction
Receipt
Filter
FilterChange
SHHPost
SHHFilter
SHHFilterChange
SHHMessage
```

To regenerate run

```
composer run-script generate-complex-datatypes
```


### Testing

```
composer install
vendor/bin/phpunit
```

See phpunit.xml and tests/

### API doc generation

The API documentation is auto-generated by [doxygen](http://www.stack.nl/~dimitri/doxygen/).

```
doxygen Doxyfile
```

There is a onlin version of this API documentation at [http://ethereum-php.org/dev](http://ethereum-php.org/dev)

### Other files

### Credits

Ethereum-PHP library is part of the [Drupal Ethereum Module](https://www.drupal.org/project/ethereum).

**Many thanks to...**

* [ConsenSys](https://consensys.net) for sponsoring the Development of Ethereum-PHP library and Drupal module.
* Nick Dodson and Dan Finlay for therir work on [ethjs-schema](https://github.com/digitaldonkey/ethjs-schema). This API is based on it.
* Jim Wigginton for the [Math_BigInteger](https://pear.php.net/package/Math_BigInteger/docs/latest/Math_BigInteger/Math_BigInteger.html) pear package.

35 changes: 18 additions & 17 deletions Doxyfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Doxyfile 1.8.13
# Doxyfile 1.8.7

#---------------------------------------------------------------------------
# Project related configuration options
Expand All @@ -7,7 +7,7 @@ DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "Ethereum PHP"
PROJECT_NUMBER =
PROJECT_BRIEF = "PHP interface to Ethereum JSON-RPC API."
PROJECT_LOGO = "./resources/doxygen-assets/ethereum-php-logo.jpg"
PROJECT_LOGO = "./doxygen-assets/ethereum-php-logo.jpg"
OUTPUT_DIRECTORY = "./doc"
CREATE_SUBDIRS = YES
ALLOW_UNICODE_NAMES = NO
Expand Down Expand Up @@ -37,7 +37,7 @@ MULTILINE_CPP_IS_BRIEF = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 2
ALIASES = "method=\"\fn \par\""
ALIASES =
TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
Expand Down Expand Up @@ -112,12 +112,13 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ./README.md ./API.md ./src ./tests ./public
INPUT = ./README.md ./src ./tests ./scripts ./resources ./public ./tests ./API.md
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.php \
*.inc \
*.markdown \
*.md
*.md \
ethjs-schema.json
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
Expand All @@ -136,20 +137,19 @@ USE_MDFILE_AS_MAINPAGE = ./README.md
# Configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
SOURCE_TOOLTIPS = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
# CLANG_ASSISTED_PARSING = NO
# CLANG_OPTIONS =

#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
Expand All @@ -158,16 +158,17 @@ IGNORE_PREFIX =
GENERATE_HTML = YES
HTML_OUTPUT = .
HTML_FILE_EXTENSION = .html
HTML_HEADER = ./resources/doxygen-assets/header.html
HTML_HEADER = ./doxygen-assets/header.html
HTML_FOOTER =
HTML_STYLESHEET =
HTML_EXTRA_STYLESHEET = ./resources/doxygen-assets/custom-styles.css
HTML_EXTRA_STYLESHEET = ./doxygen-assets/custom-styles.css
HTML_EXTRA_FILES =
HTML_COLORSTYLE_HUE = 226
HTML_COLORSTYLE_SAT = 30
HTML_COLORSTYLE_GAMMA = 41
HTML_TIMESTAMP = NO
HTML_DYNAMIC_SECTIONS = NO
# Dynamic html
HTML_DYNAMIC_SECTIONS = YES
HTML_INDEX_NUM_ENTRIES = 100
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
Expand Down Expand Up @@ -289,7 +290,7 @@ SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
ALLEXTERNALS = YES
EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
PERL_PATH = /usr/bin/perl
Expand All @@ -300,7 +301,7 @@ CLASS_DIAGRAMS = YES
MSCGEN_PATH =
DIA_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
HAVE_DOT = YES
DOT_NUM_THREADS = 0
DOT_FONTNAME = Helvetica
DOT_FONTSIZE = 10
Expand All @@ -313,12 +314,12 @@ UML_LIMIT_NUM_FIELDS = 10
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
CALL_GRAPH = YES
CALLER_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
INTERACTIVE_SVG = NO
INTERACTIVE_SVG = YES
DOT_PATH =
DOTFILE_DIRS =
MSCFILE_DIRS =
Expand Down
65 changes: 33 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Getting started
# Ethereum-PHP

Ethereum-PHP is a typed PHP-7 interface to [Ethereum JSON-RPC API](https://github.com/ethereum/wiki/wiki/JSON-RPC).
is a typed PHP-7 interface to [Ethereum JSON-RPC API](https://github.com/ethereum/wiki/wiki/JSON-RPC).

Check out the latest [API documentation](http://ethereum-php.org/dev/).

### Install the library in a composer file
### Add library in a [composer.json](https://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup) file


```
```yaml
{
"repositories": [
{
Expand All @@ -19,46 +18,48 @@ Check out the latest [API documentation](http://ethereum-php.org/dev/).
"digitaldonkey/ethereum-php": "dev-master",
}
}
```
This is the important part of [composer.json](https://github.com/digitaldonkey/ethereum/blob/8.x-1.x/composer.json) in [Drupal Ethereum Module](https://drupal.org/project/ethereum).

### Usage

#### Extend

```sh
composer require digitaldonkey/ethereum-php
```
use Ethereum\EthereumClient;
use Ethereum\Ethereum_Message;
use Ethereum\Ethereum_Transaction;
class EthereumController extends ControllerBase {

public $client;
This is the important part of [composer.json](https://github.com/digitaldonkey/ethereum/blob/8.x-1.x/composer.json) in [Drupal Ethereum Module](https://drupal.org/project/ethereum).

public function __construct($host = FALSE) {
if (!$host) {
$host = 'http://localhost:8445'
}
$this->client = new EthereumClient($host);
}

```php
try {
$eth = new EthereumController('http://localhost:8445');
echo $eth->client->eth_protocolVersion();
}
catch (\Exception $exception) {
die ("Unable to connect.");
}
```

#### Use
### Limitations & Architecture

```
try {
$eth = new EthereumController();
echo $eth->client->eth_protocolVersion();
}
catch (\Exception $exception) {
die ("Unable to connect.");
}
Currently only primitive data types are supported, but [RLP](https://github.com/ethereum/wiki/wiki/RLP) will come soon.

**Read-only**
This library is read-only for now. this means you can retrieve information stored in Ethereum Blockchain.

In order to *write* to the blockchain you need a to sign transactions with a private key. I discourage using a unlocked Ethereum client, as a hacker of your website would be able to spend your eth.

```

![architecture diagram](https://raw.githubusercontent.com/digitaldonkey/ethereum-php/dev/doxygen-assets/ArchitectureDiagrammCS6.png "Drupal Ethereum architecture")

### Documentation
For reference see the [Ethereum RPC documentation](https://github.com/ethereum/wiki/wiki/JSON-RPC) and for data encoding [RLP ddcumentation](https://github.com/ethereum/wiki/wiki/RLP) in [Ethereum Wiki](https://github.com/ethereum/wiki).

There is also a more readyble [Ethereum Frontier Guide](http://ethereum.gitbooks.io/frontier-guide/content/rpc.html) version.
For reference see the [Ethereum RPC documentation](https://github.com/ethereum/wiki/wiki/JSON-RPC) and for data encoding [RLP dcumentation](https://github.com/ethereum/wiki/wiki/RLP) in [Ethereum Wiki](https://github.com/ethereum/wiki).

There is also a more readable [Ethereum Frontier Guide](http://ethereum.gitbooks.io/frontier-guide/content/rpc.html) version.

More to read and watch

* [Drupalcon Vienna talk](https://events.drupal.org/vienna2017/sessions/drupal-and-ethereum-blockchain)
* [Drupalcon Baltimore talk](https://events.drupal.org/baltimore2017/sessions/drupal-and-ethereum-blockchain)

11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
"graze/guzzle-jsonrpc": "~3.0",
"pear/math_biginteger": "^1.0"
},
"scripts": {
"generate-methods": [
"php scripts/generate-methods.php"
],
"generate-complex-datatypes": [
"php scripts/generate-complex-datatypes.php"
]
},
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0"
"phpunit/phpunit": "^4.0 || ^5.0",
"gossi/php-code-generator": "^0.5.0"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions doc/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This keeps this directory in git.
Binary file added doxygen-assets/ArchitectureDiagrammCS6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9c8a748

Please sign in to comment.