-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from iota-community/develop
Update 0.1.0
- Loading branch information
Showing
217 changed files
with
6,479 additions
and
4,625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
on: push | ||
name: PHPUnit | ||
jobs: | ||
phpunit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: php-actions/composer@v1 | ||
- name: PHPUnit for PHP 8 | ||
uses: chindit/actions-phpunit@1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
![IOTA.php](./help/images/IOTA_PHP_Banner_Interact.png) | ||
|
||
<p style="text-align:center;"> | ||
<a href="https://discord.iota.org/" style="text-decoration:none;"><img src="https://img.shields.io/badge/Discord-9cf.svg?style=social&logo=discord" alt="Discord"></a> | ||
<a href="https://twitter.com/IOTAphp/" style="text-decoration:none;"><img src="https://img.shields.io/badge/Twitter-9cf.svg?style=social&logo=twitter" alt="Twitter"></a> | ||
<br> | ||
<a href="https://github.com/iota-community/iota.php/LICENSE" style="text-decoration:none;"><img src="https://img.shields.io/badge/license-Apache--2.0-green?style=flat-square" alt="Apache-2.0 license"></a> | ||
<a href="https://www.iota.org/" style="text-decoration:none;"><img src="https://img.shields.io/badge/IOTA-lightgrey?style=flat&logo=iota" alt="IOTA"></a> | ||
<a href="https://www.php.net/" style="text-decoration:none;"><img src="https://img.shields.io/badge/PHP->= 8.x-blue?style=flat-square" alt=">PHP 8"></a> | ||
<img src="https://github.com/iota-community/iota.php/actions/workflows/phpunit.yml/badge.svg" alt="WorkflowUnitTest"> | ||
</p> | ||
|
||
# Changelog | ||
|
||
## 0.1.0 - 2021-06-28 | ||
|
||
### Added | ||
|
||
- Builder | ||
- iota.phar | ||
- phpunit tests | ||
- autoloader.php | ||
- composer.json | ||
|
||
### Changed | ||
|
||
- New [Iota.php](https://github.com/iota-community/iota.php) lib structure | ||
- New [example](./examples) structure | ||
- [Iota.php Help](./help/000_index.md) | ||
|
||
### Removed | ||
|
||
- Old lib structure | ||
- Old example structure | ||
- client/Api |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
![IOTA.php](./help/images/IOTA_PHP_Banner_Interact.png) | ||
|
||
<p style="text-align:center;"> | ||
<a href="https://discord.iota.org/" style="text-decoration:none;"><img src="https://img.shields.io/badge/Discord-9cf.svg?style=social&logo=discord" alt="Discord"></a> | ||
<a href="https://twitter.com/IOTAphp/" style="text-decoration:none;"><img src="https://img.shields.io/badge/Twitter-9cf.svg?style=social&logo=twitter" alt="Twitter"></a> | ||
<br> | ||
<a href="https://github.com/iota-community/iota.php/LICENSE" style="text-decoration:none;"><img src="https://img.shields.io/badge/license-Apache--2.0-green?style=flat-square" alt="Apache-2.0 license"></a> | ||
<a href="https://www.iota.org/" style="text-decoration:none;"><img src="https://img.shields.io/badge/IOTA-lightgrey?style=flat&logo=iota" alt="IOTA"></a> | ||
<a href="https://www.php.net/" style="text-decoration:none;"><img src="https://img.shields.io/badge/PHP->= 8.x-blue?style=flat-square" alt=">PHP 8"></a> | ||
<img src="https://github.com/iota-community/iota.php/actions/workflows/phpunit.yml/badge.svg" alt="WorkflowUnitTest"> | ||
</p> | ||
|
||
### In Progress | ||
|
||
- [ ] Wallet lib | ||
- [ ] expand PHPUnit tests | ||
- [ ] expand new Actions | ||
- [ ] expand Builder class | ||
|
||
--- | ||
|
||
### Todo | ||
|
||
- [ ] Wallet lib | ||
- [ ] Address Searcher | ||
- [ ] Safe Saving Seeds, according to Iota Stronghold Standard | ||
|
||
|
||
- [ ] expand new Actions | ||
- [ ] expand Builder class | ||
- [ ] expand PHPUnit tests | ||
|
||
|
||
- [ ] Amount class | ||
- [ ] QR Code class | ||
|
||
|
||
- [ ] IOTA Native Digital Assets | ||
- [ ] Interact with IOTA Streams | ||
- [ ] Interact with IOTA Identity | ||
|
||
--- | ||
|
||
### Done ✓ | ||
|
||
- [x] Builder class | ||
- [x] Create ToDo | ||
- [x] Create phar | ||
- [x] Change lib structure | ||
- [x] PHPUnit tests | ||
- [x] New Design (logo, header,...) | ||
|
||
|
||
- [x] Interact with the IOTA Faucet Api | ||
- [x] Get funds on testnet | ||
|
||
|
||
- [x] Create help | ||
|
||
|
||
- [x] Interact with an IOTA node | ||
- [x] Create messages transaction payloads | ||
- [x] Create messages with indexation | ||
- [x] Get messages and outputs | ||
- [x] Generate addresses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
<?php | ||
$autoload = null; | ||
$autoloadFiles = [ | ||
__DIR__ . '/../vendor/autoload.php', | ||
]; | ||
foreach($autoloadFiles as $autoloadFile) { | ||
if(file_exists($autoloadFile)) { | ||
$autoload = $autoloadFile; | ||
break; | ||
} | ||
} | ||
if(!$autoload) { | ||
if(0 > version_compare(PHP_VERSION, '8.0.0')) { | ||
die('PHP >= 8.0.0 needed (' . PHP_VERSION . " is installed)"); | ||
} | ||
if(!extension_loaded('curl')) { | ||
die("'curl' extension not loaded!"); | ||
} | ||
$autoload = new autoload(); | ||
$autoload->addNamespace('IOTA\\', __DIR__ . '/src'); | ||
$autoload->register(); | ||
} | ||
else { | ||
echo $autoload . PHP_EOL; | ||
require $autoload; | ||
} | ||
/** | ||
* Class autoload | ||
*/ | ||
class autoload { | ||
/** | ||
* An associative array where the key is a namespace prefix and the value | ||
* is an array of base directories for classes in that namespace. | ||
* | ||
* @var array | ||
*/ | ||
protected array $prefixes = []; | ||
|
||
/** | ||
* Register loader with SPL autoloader stack. | ||
* | ||
* @return void | ||
*/ | ||
public function register() { | ||
spl_autoload_register([ | ||
$this, | ||
'loadClass', | ||
]); | ||
} | ||
|
||
/** | ||
* Adds a base directory for a namespace prefix. | ||
* | ||
* @param string $prefix The namespace prefix. | ||
* @param string $base_dir A base directory for class files in the | ||
* namespace. | ||
* @param bool $prepend If true, prepend the base directory to the stack | ||
* instead of appending it; this causes it to be searched first rather | ||
* than last. | ||
* | ||
* @return void | ||
*/ | ||
public function addNamespace(string $prefix, string $base_dir, bool $prepend = false) { | ||
// normalize namespace prefix | ||
$prefix = trim($prefix, '\\') . '\\'; | ||
// normalize the base directory with a trailing separator | ||
$base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR) . '/'; | ||
// initialize the namespace prefix array | ||
if(isset($this->prefixes[$prefix]) === false) { | ||
$this->prefixes[$prefix] = []; | ||
} | ||
// retain the base directory for the namespace prefix | ||
if($prepend) { | ||
array_unshift($this->prefixes[$prefix], $base_dir); | ||
} | ||
else { | ||
array_push($this->prefixes[$prefix], $base_dir); | ||
} | ||
} | ||
|
||
/** | ||
* Loads the class file for a given class name. | ||
* | ||
* @param string $class The fully-qualified class name. | ||
* | ||
* @return string|bool The mapped file name on success, or boolean false on | ||
* failure. | ||
*/ | ||
public function loadClass(string $class): string|bool { | ||
// the current namespace prefix | ||
$prefix = $class; | ||
// work backwards through the namespace names of the fully-qualified | ||
// class name to find a mapped file name | ||
while(false !== $pos = strrpos($prefix, '\\')) { | ||
|
||
// retain the trailing namespace separator in the prefix | ||
$prefix = substr($class, 0, $pos + 1); | ||
// the rest is the relative class name | ||
$relative_class = substr($class, $pos + 1); | ||
// try to load a mapped file for the prefix and relative class | ||
$mapped_file = $this->loadMappedFile($prefix, $relative_class); | ||
if($mapped_file) { | ||
return $mapped_file; | ||
} | ||
// remove the trailing namespace separator for the next iteration | ||
// of strrpos() | ||
$prefix = rtrim($prefix, '\\'); | ||
} | ||
// never found a mapped file | ||
return false; | ||
} | ||
|
||
/** | ||
* Load the mapped file for a namespace prefix and relative class. | ||
* | ||
* @param string $prefix The namespace prefix. | ||
* @param string $relative_class The relative class name. | ||
* | ||
* @return false|string Boolean false if no mapped file can be loaded, or the | ||
* name of the mapped file that was loaded. | ||
*/ | ||
protected function loadMappedFile(string $prefix, string $relative_class): bool|string { | ||
// are there any base directories for this namespace prefix? | ||
if(isset($this->prefixes[$prefix]) === false) { | ||
return false; | ||
} | ||
// look through base directories for this namespace prefix | ||
foreach($this->prefixes[$prefix] as $base_dir) { | ||
|
||
// replace the namespace prefix with the base directory, | ||
// replace namespace separators with directory separators | ||
// in the relative class name, append with .php | ||
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; | ||
// if the mapped file exists, require it | ||
if($this->requireFile($file)) { | ||
// yes, we're done | ||
return $file; | ||
} | ||
} | ||
// never found it | ||
return false; | ||
} | ||
|
||
/** | ||
* If a file exists, require it from the file system. | ||
* | ||
* @param string $file The file to require. | ||
* | ||
* @return bool True if the file exists, false if not. | ||
*/ | ||
protected function requireFile(string $file): bool { | ||
if(file_exists($file)) { | ||
require $file; | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
Oops, something went wrong.