Skip to content

Commit 5e986d8

Browse files
authored
Merge pull request #31 from KunBojiMan/fix/putdeploy-cltype
Fix PutDeployResult instantiation and CLTypeSerializer string handling
2 parents 3db096e + 9e67d03 commit 5e986d8

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/Rpc/ResultTypes/PutDeployResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class PutDeployResult extends AbstractResult
88

99
public static function fromJSON(array $json): self
1010
{
11-
return self($json, $json['deploy_hash']);
11+
return new self($json, $json['deploy_hash']);
1212
}
1313

1414
public function __construct(array $rawJSON, string $deployHash)

src/Types/Serializer/CLTypeSerializer.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ public static function toJson($clType): array
2525
}
2626

2727
/**
28+
* @param array|string $json
2829
* @throws \Exception
2930
*/
30-
public static function fromJson(array $json): CLType
31+
public static function fromJson($json): CLType
3132
{
3233
$classPrefix = 'Casper\Types\CLValue\CLType\CL';
3334

35+
if (is_string($json)) {
36+
$clTypeClass = $classPrefix . $json . 'Type';
37+
return new $clTypeClass();
38+
}
39+
3440
if (ArrayUtil::isMap($json)) {
3541
$typeName = array_key_first($json);
3642
$clTypeClass = $classPrefix . $typeName . 'Type';

0 commit comments

Comments
 (0)