-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
887cf54
commit 0198c21
Showing
21 changed files
with
1,320 additions
and
311 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
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
153 changes: 153 additions & 0 deletions
153
Soneso/StellarSDK/Soroban/Responses/LedgerEntryChange.php
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,153 @@ | ||
<?php declare(strict_types=1); | ||
|
||
// Copyright 2024 The Stellar PHP SDK Authors. All rights reserved. | ||
// Use of this source code is governed by a license that can be | ||
// found in the LICENSE file. | ||
|
||
|
||
namespace Soneso\StellarSDK\Soroban\Responses; | ||
|
||
use Soneso\StellarSDK\Xdr\XdrLedgerEntry; | ||
use Soneso\StellarSDK\Xdr\XdrLedgerKey; | ||
|
||
class LedgerEntryChange | ||
{ | ||
/** | ||
* @var string $type 'created', 'updated' or 'deleted' | ||
*/ | ||
public string $type; | ||
/** | ||
* @var string $key XdrLedgerKey in base64 | ||
*/ | ||
public string $key; | ||
|
||
/** | ||
* @var string|null $before XdrLedgerEntry in base64 | ||
*/ | ||
public ?string $before; | ||
|
||
/** | ||
* @var string|null $after XdrLedgerEntry in base64 | ||
*/ | ||
public ?string $after; | ||
|
||
/** | ||
* @param string $type | ||
* @param string $key | ||
* @param string|null $before | ||
* @param string|null $after | ||
*/ | ||
public function __construct( | ||
string $type, | ||
string $key, | ||
?string $before = null, | ||
?string $after = null, | ||
) | ||
{ | ||
$this->type = $type; | ||
$this->key = $key; | ||
$this->before = $before; | ||
$this->after = $after; | ||
} | ||
|
||
public static function fromJson(array $json) : LedgerEntryChange { | ||
$before = null; | ||
if(isset($json['before'])) { | ||
$before = $json['before']; | ||
} | ||
|
||
$after = null; | ||
if(isset($json['after'])) { | ||
$after = $json['after']; | ||
} | ||
return new LedgerEntryChange( | ||
type: $json['type'], | ||
key: $json['key'], | ||
before: $before, | ||
after: $after, | ||
); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getType(): string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
/** | ||
* @param string $type | ||
*/ | ||
public function setType(string $type): void | ||
{ | ||
$this->type = $type; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getKey(): string | ||
{ | ||
return $this->key; | ||
} | ||
|
||
/** | ||
* @param string $key | ||
*/ | ||
public function setKey(string $key): void | ||
{ | ||
$this->key = $key; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getBefore(): ?string | ||
{ | ||
return $this->before; | ||
} | ||
|
||
/** | ||
* @param string|null $before | ||
*/ | ||
public function setBefore(?string $before): void | ||
{ | ||
$this->before = $before; | ||
} | ||
|
||
/** | ||
* @return string|null | ||
*/ | ||
public function getAfter(): ?string | ||
{ | ||
return $this->after; | ||
} | ||
|
||
/** | ||
* @param string|null $after | ||
*/ | ||
public function setAfter(?string $after): void | ||
{ | ||
$this->after = $after; | ||
} | ||
|
||
public function getKeyXdr() : XdrLedgerKey { | ||
return XdrLedgerKey::fromBase64Xdr($this->key); | ||
} | ||
|
||
public function getAfterXdr() : ?XdrLedgerEntry { | ||
if($this->after !== null) { | ||
return XdrLedgerEntry::fromBase64Xdr($this->after); | ||
} | ||
return null; | ||
} | ||
|
||
public function getBeforeXdr() : ?XdrLedgerEntry { | ||
if($this->before !== null) { | ||
return XdrLedgerEntry::fromBase64Xdr($this->before); | ||
} | ||
return null; | ||
} | ||
|
||
} |
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
Oops, something went wrong.