Skip to content

Commit

Permalink
Added new RPC endpoint (speculative_exec, query_balance, info_get_cha…
Browse files Browse the repository at this point in the history
…inspec)

Signed-off-by: Roman Bylbas <romka.bulbas@gmail.com>
  • Loading branch information
Roman Bylbas committed Jul 26, 2023
1 parent 58d419a commit f53ab5c
Show file tree
Hide file tree
Showing 23 changed files with 670 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
- name: Run test suite
run: composer run-script test
env:
CASPER_PHP_SDK_TEST_NODE_URL: "136.243.187.84:7777"
CASPER_PHP_SDK_TEST_NODE_URL: "65.21.237.160:7777"
36 changes: 36 additions & 0 deletions docs/API/RpcClientAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ Returns purse's balance from the network
| `$stateRootHash` | `string` | Hex-encoded hash of the state root | Yes |
| `$balanceUref` | `CLURef` | Balance URef object | Yes |

---
## Query balance
```php
queryBalance(
string $purseIdentifierType,
string $purseIdentifier,
string $stateRootHash = null
): \GMP
```
Returns a purse’s balance from global state at a given [Block](../Entity/Block.md) or state root hash.
### Parameters
| Name | Type | Description | Required |
|---|----------|-----------------------------------------------------------------------------------------------------------------------|----------|
| `$purseIdentifierType` | `string` | Purse identifier type. Available values: `purse_uref`, `main_purse_under_public_key`, `main_purse_under_account_hash` | Yes |
| `$purseIdentifier` | `string` | Purse identifier | Yes |
| `$stateRootHash` | `string` | Hex-encoded hash of the state root | No |

---
## Get account balance URef by account hash
```php
Expand Down Expand Up @@ -238,3 +255,22 @@ Returns an [GlobalState](../Entity/GlobalState.md) object by the given state roo
| `$stateRootHash` | `string` | Hex-encoded hash of the state root | Yes |
| `$key` | `string` | `casper_types::Key` as formatted string | Yes |
| `$path` | `array` | The path components starting from the key as base | No |

---
## Get chainspec info
```php
getChainspecInfo(): ChainspecRegistryBytes
```
Returns a [ChainspecRegistryBytes](../Entity/ChainspecRegistryBytes.md) object

---
## Speculative deploy
```php
speculativeDeploy(Deploy $signedDeploy, string $blockHash)
```
Puts a [Deploy](../Entity/Deploy.md) to a single node for speculative execution on that node only.
### Parameters
| Name | Type | Description | Required |
|---|------|-------------|----|
| `$signedDeploy` | `Deploy` | Signed [Deploy](../Entity/Deploy.md) object | Yes |
| `$blockHash` | `string` | Hex-encoded hash of the block | Yes |
10 changes: 10 additions & 0 deletions docs/Entity/BlockRange.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# BlockRange

```php
getLow(): int
```

---
```php
getHigh(): int
```
18 changes: 18 additions & 0 deletions docs/Entity/ChainspecRegistryBytes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ChainspecRegistryBytes

```php
getChainspecBytes(): string
```
Returns Chainspec.toml bytes

---
```php
getGenesisAccountsBytes(): ?string
```
Returns Accounts.toml bytes or `null`

---
```php
getGlobalStateBytes(): ?string
```
Returns GlobalState.toml bytes or `null`
29 changes: 29 additions & 0 deletions docs/Entity/Status.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Status

```php
getApiVersion(): string
```
Returns node's RPC API version

```php
getChainspecName(): string
```
Expand Down Expand Up @@ -46,3 +51,27 @@ Returns [NextUpgrade](NextUpgrade.md) object or `null`
getPeers(): array
```
Returns a list of [Peer](Peer.md) objects that connected to the network

---
```php
getUptime(): string
```
Returns time that passed since the node has started.

---
```php
getReactorState(): string
```
Returns node's reactor state

---
```php
getLastProgress(): \DateTime
```
Returns node's last progress

---
```php
getLastProgress(): BlockRange
```
Returns [BlockRange](BlockRange.md) object
26 changes: 26 additions & 0 deletions src/Entity/BlockRange.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Casper\Entity;

class BlockRange
{
private int $low;

private int $high;

public function __construct(int $low, int $high)
{
$this->low = $low;
$this->high = $high;
}

public function getLow(): int
{
return $this->low;
}

public function getHigh(): int
{
return $this->high;
}
}
38 changes: 38 additions & 0 deletions src/Entity/ChainspecRegistryBytes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Casper\Entity;

class ChainspecRegistryBytes
{
private string $chainspecBytes;

private ?string $genesisAccountsBytes;

private ?string $globalStateBytes;

public function __construct(
string $chainspecBytes,
?string $genesisAccountsBytes,
?string $globalStateBytes
)
{
$this->chainspecBytes = $chainspecBytes;
$this->genesisAccountsBytes = $genesisAccountsBytes;
$this->globalStateBytes = $globalStateBytes;
}

public function getChainspecBytes(): string
{
return $this->chainspecBytes;
}

public function getGenesisAccountsBytes(): ?string
{
return $this->genesisAccountsBytes;
}

public function getGlobalStateBytes(): ?string
{
return $this->globalStateBytes;
}
}
26 changes: 26 additions & 0 deletions src/Entity/DeployExecutionResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Casper\Entity;

class DeployExecutionResult
{
private string $blockHash;

private DeployExecutionResultData $data;

public function __construct(string $blockHash, DeployExecutionResultData $data)
{
$this->blockHash = $blockHash;
$this->data = $data;
}

public function getBlockHash(): string
{
return $this->blockHash;
}

public function getData(): DeployExecutionResultData
{
return $this->data;
}
}
50 changes: 50 additions & 0 deletions src/Entity/DeployExecutionResultData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Casper\Entity;

class DeployExecutionResultData
{
private string $status;

private Effect $effect;

private array $transfers;

private \GMP $cost;

private ?string $errorMessage = null;

public function __construct(string $status, Effect $effect, array $transfers, \GMP $cost, ?string $errorMessage)
{
$this->status = $status;
$this->effect = $effect;
$this->transfers = $transfers;
$this->cost = $cost;
$this->errorMessage = $errorMessage;
}

public function getStatus(): string
{
return $this->status;
}

public function getEffect(): Effect
{
return $this->effect;
}

public function getTransfers(): array
{
return $this->transfers;
}

public function getCost(): \GMP
{
return $this->cost;
}

public function getErrorMessage(): ?string
{
return $this->errorMessage;
}
}
32 changes: 32 additions & 0 deletions src/Entity/Effect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Casper\Entity;

class Effect
{
/**
* @var Operation[]
*/
private array $operations;

/**
* @var Transform[]
*/
private array $transforms;

public function __construct(array $operations, array $transforms)
{
$this->operations = $operations;
$this->transforms = $transforms;
}

public function getOperations(): array
{
return $this->operations;
}

public function getTransforms(): array
{
return $this->transforms;
}
}
26 changes: 26 additions & 0 deletions src/Entity/Operation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Casper\Entity;

class Operation
{
private string $key;

private string $kind;

public function __construct(string $key, string $kind)
{
$this->key = $key;
$this->kind = $kind;
}

public function getKey(): string
{
return $this->key;
}

public function getKind(): string
{
return $this->kind;
}
}
Loading

0 comments on commit f53ab5c

Please sign in to comment.