diff --git a/docs/WavesKit.md b/docs/WavesKit.md index e4f283f..9a89558 100644 --- a/docs/WavesKit.md +++ b/docs/WavesKit.md @@ -72,6 +72,7 @@ |[txBroadcast](#waveskittxbroadcast)|Broadcasts a transaction| |[txBurn](#waveskittxburn)|Makes burn transaction as an array| |[txData](#waveskittxdata)|Makes data transaction as an array| +|[txEvaluate](#waveskittxevaluate)|Evaluates a transaction| |[txInvokeScript](#waveskittxinvokescript)|Makes invoke script transaction as an array| |[txIssue](#waveskittxissue)|Makes issue transaction as an array| |[txLease](#waveskittxlease)|Makes lease transaction as an array| @@ -456,7 +457,7 @@ Encrypts data with cryptash parameters **Description** ```php -public ensure (array $tx, int $confirmations, int $sleep, int $timeout, bool $hard) +public ensure (array $tx, int $confirmations, int|float $sleep, int $timeout, bool $hard) ``` Ensures a transaction confirmed and reached required confirmations @@ -469,8 +470,8 @@ Ensures a transaction confirmed and reached required confirmations : Transaction as an array * `(int) $confirmations` : Number of confirmations to reach (default: 0) -* `(int) $sleep` -: Seconds to sleep between requests (default: 1) +* `(int|float) $sleep` +: Seconds to sleep between requests (default: 0.5) * `(int) $timeout` : Timeout to reach lost status (default: 30) * `(bool) $hard` @@ -1423,7 +1424,7 @@ Sets matcher settings **Description** ```php -public setNodeAddress (string|array $nodeAddress, int $cacheLifetime, array|null $backupNodes) +public setNodeAddress (string|array $nodeAddress, int|float $cacheLifetime, array|null $backupNodes) ``` Sets node address with cache lifetime and backup node addresses @@ -1434,8 +1435,8 @@ Sets node address with cache lifetime and backup node addresses * `(string|array) $nodeAddress` : Main node address to work with -* `(int) $cacheLifetime` -: Cache lifetime in seconds (default: 1) +* `(int|float) $cacheLifetime` +: Cache lifetime in seconds (default: 0.5) * `(array|null) $backupNodes` : Backup node addresses to fallback @@ -1932,6 +1933,33 @@ Makes data transaction as an array
+### WavesKit::txEvaluate + +**Description** + +```php +public txEvaluate (array $tx) +``` + +Evaluates a transaction + + + +**Parameters** + +* `(array) $tx` +: Transaction as an array + +**Return Values** + +`array|false` + +> Evaluated transaction as an array or FALSE on failure + + +
+ + ### WavesKit::txInvokeScript **Description** diff --git a/src/WavesKit.php b/src/WavesKit.php index 7d96e07..2a9787f 100644 --- a/src/WavesKit.php +++ b/src/WavesKit.php @@ -1420,6 +1420,31 @@ public function txValidate( $tx ) return $json; } + /** + * Evaluates a transaction + * + * @param array $tx Transaction as an array + * + * @return array|false Evaluated transaction as an array or FALSE on failure + */ + public function txEvaluate( $tx ) + { + if( !isset( $tx['dApp'] ) ) + return false; + + if( false === ( $json = $this->fetch( '/utils/script/evaluate/' . $tx['dApp'], true, json_encode( $tx ) ) ) ) + return false; + + if( false === ( $json = $this->json_decode( $json ) ) ) + return false; + + if( !isset( $json['stateChanges'] ) && !isset( $json['error'] ) ) + return false; + + $json['valid'] = isset( $json['stateChanges'] ) && !isset( $json['error'] ); + return $json; + } + /** * Broadcasts a transaction *