Skip to content

Commit

Permalink
end point Changes handler added
Browse files Browse the repository at this point in the history
  • Loading branch information
neha0921 committed Aug 10, 2021
1 parent 8b9ee8c commit 0e78f0d
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ composer require neha0921/substrate-interface-package
## Usage (Just Like)

```php
$testClass = new ApiHandler("http_url");
$testClass = new SubstrateInterface("http_url");
echo $testClass->rpc->system->name();
```

Expand Down
4 changes: 2 additions & 2 deletions public/CallHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require __DIR__ . '/../vendor/autoload.php';


// $obj = new ApiHandler("http://127.0.0.1:8000");
// $obj = new SubstrateInterface("http://127.0.0.1:8000");
// echo $obj->rpc->rpc->methods();

/*Call selected method with input parameter */
Expand All @@ -16,7 +16,7 @@
$params = isset($_POST['params']) ? $_POST['params'] : [];
$id = isset($_POST['id']) ? $_POST['id'] : 1;

$obj = new ApiHandler("http://127.0.0.1:8000");
$obj = new SubstrateInterface("http://127.0.0.1:8000");

switch ($methodName) {

Expand Down
2 changes: 1 addition & 1 deletion public/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<?php

/* $obj = new ApiHandler("http://127.0.0.1:8000");
/* $obj = new SubstrateInterface("http://127.0.0.1:8000");
echo "Name :: ". $obj->rpc->system->name().'<br>';
Expand Down
2 changes: 1 addition & 1 deletion src/ApiHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use neha0921\SubstrateInterfacePackage\Rpc\Rpc;

class ApiHandler
class SubstrateInterface
{
const API_URL = "http://127.0.0.1:8000";

Expand Down
4 changes: 2 additions & 2 deletions src/Rpc/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace neha0921\SubstrateInterfacePackage\Rpc;

use neha0921\SubstrateInterfacePackage\ApiHandler;
use neha0921\SubstrateInterfacePackage\SubstrateInterface;

class Author
{
const AUTHOR_PREFIX = 'author_';

public $apiHandler;

public function __construct(ApiHandler $apiHandler)
public function __construct(SubstrateInterface $apiHandler)
{
$this->apiHandler = $apiHandler;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rpc/Chain.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace neha0921\SubstrateInterfacePackage\Rpc;

use neha0921\SubstrateInterfacePackage\ApiHandler;
use neha0921\SubstrateInterfacePackage\SubstrateInterface;

class Chain
{
const CHAIN_PREFIX = 'chain_';

public $apiHandler;

public function __construct(ApiHandler $apiHandler)
public function __construct(SubstrateInterface $apiHandler)
{
$this->apiHandler = $apiHandler;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rpc/Grandpa.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace neha0921\SubstrateInterfacePackage\Rpc;

use neha0921\SubstrateInterfacePackage\ApiHandler;
use neha0921\SubstrateInterfacePackage\SubstrateInterface;

class Grandpa
{
const GRANDPA_PREFIX = 'grandpa_';

public $apiHandler;

public function __construct(ApiHandler $apiHandler)
public function __construct(SubstrateInterface $apiHandler)
{
$this->apiHandler = $apiHandler;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rpc/Keypair.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace neha0921\SubstrateInterfacePackage\Rpc;

use neha0921\SubstrateInterfacePackage\ApiHandler;
use neha0921\SubstrateInterfacePackage\SubstrateInterface;

class Keypair
{
const KEYPAIR_PREFIX = 'keypair_';

public $apiHandler;

public function __construct(ApiHandler $apiHandler)
public function __construct(SubstrateInterface $apiHandler)
{
$this->apiHandler = $apiHandler;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rpc/Rpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace neha0921\SubstrateInterfacePackage\Rpc;

use neha0921\SubstrateInterfacePackage\ApiHandler;
use neha0921\SubstrateInterfacePackage\SubstrateInterface;

class Rpc
{
const RPC_PREFIX = 'rpc_';
public $system;
private $apiHandler;
public function __construct(ApiHandler $apiHandler)
public function __construct(SubstrateInterface $apiHandler)
{
$this->apiHandler = $apiHandler;
$this->system = new System($apiHandler);
Expand Down
4 changes: 2 additions & 2 deletions src/Rpc/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace neha0921\SubstrateInterfacePackage\Rpc;

use neha0921\SubstrateInterfacePackage\ApiHandler;
use neha0921\SubstrateInterfacePackage\SubstrateInterface;

class State
{
const STATE_PREFIX = 'state_';

public $apiHandler;

public function __construct(ApiHandler $apiHandler)
public function __construct(SubstrateInterface $apiHandler)
{
$this->apiHandler = $apiHandler;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rpc/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace neha0921\SubstrateInterfacePackage\Rpc;

use neha0921\SubstrateInterfacePackage\ApiHandler;
use neha0921\SubstrateInterfacePackage\SubstrateInterface;

class System
{
Expand All @@ -11,7 +11,7 @@ class System
public $apiHandler;

private $a;
public function __construct(ApiHandler $apiHandler)
public function __construct(SubstrateInterface $apiHandler)
{
$this->apiHandler = $apiHandler;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ApiHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace TheTestCoder\PhpPackageStructure\Tests;

use neha0921\SubstrateInterfacePackage\ApiHandler;
use neha0921\SubstrateInterfacePackage\SubstrateInterface;
use PHPUnit\Framework\TestCase;

class ApiHandlerTest extends TestCase
class SubstrateInterfaceTest extends TestCase
{
/** @test */
public function testSystemName()
{

$obj = new ApiHandler("http://127.0.0.1:8000");
$obj = new SubstrateInterface("http://127.0.0.1:8000");

$expectedResultContainsPartial = 'Parity Polkadot';
$actualResult = $obj->rpc->system->name();
Expand Down

0 comments on commit 0e78f0d

Please sign in to comment.