From 89d84a0706b55276557bcfc897e93494e22d9508 Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Wed, 10 Jan 2024 10:22:13 -0300 Subject: [PATCH] [PLA-1537] Support filter (#32) --- src/Enums/Substrate/StorageKey.php | 24 ++++++++++++++++-------- src/Enums/Substrate/StorageType.php | 9 +++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 src/Enums/Substrate/StorageType.php diff --git a/src/Enums/Substrate/StorageKey.php b/src/Enums/Substrate/StorageKey.php index 726eefb..62c98b7 100644 --- a/src/Enums/Substrate/StorageKey.php +++ b/src/Enums/Substrate/StorageKey.php @@ -3,23 +3,31 @@ namespace Enjin\Platform\FuelTanks\Enums\Substrate; use Enjin\Platform\Exceptions\PlatformException; -use Enjin\Platform\Traits\EnumExtensions; -enum StorageKey: string +class StorageKey { - use EnumExtensions; + public function __construct(public StorageType $type, public string $value) + { + } - case TANKS = '0xb8ed204d2f9b209f43a0487b80cceca11dff2785cc2c6efead5657dc32a2065e'; - case ACCOUNTS = '0xb8ed204d2f9b209f43a0487b80cceca18ee7418a6531173d60d1f6a82d8f4d51'; + public static function tanks(?string $value = null): self + { + return new self(StorageType::TANKS, $value ?? '0xb8ed204d2f9b209f43a0487b80cceca11dff2785cc2c6efead5657dc32a2065e'); + } + + public static function accounts(?string $value = null): self + { + return new self(StorageType::ACCOUNTS, $value ?? '0xb8ed204d2f9b209f43a0487b80cceca18ee7418a6531173d60d1f6a82d8f4d51'); + } /** * Get the parser for this storage key. */ public function parser(): string { - return match ($this) { - self::TANKS => 'tanksStorages', - self::ACCOUNTS => 'accountsStorages', + return match ($this->type) { + StorageType::TANKS => 'tanksStorages', + StorageType::ACCOUNTS => 'accountsStorages', default => throw new PlatformException('No parser for this storage key.'), }; } diff --git a/src/Enums/Substrate/StorageType.php b/src/Enums/Substrate/StorageType.php new file mode 100644 index 0000000..07b4887 --- /dev/null +++ b/src/Enums/Substrate/StorageType.php @@ -0,0 +1,9 @@ +