Skip to content

Commit

Permalink
[PLA-1537] Support filter (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio authored Jan 10, 2024
1 parent e5fb96f commit 89d84a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/Enums/Substrate/StorageKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'),
};
}
Expand Down
9 changes: 9 additions & 0 deletions src/Enums/Substrate/StorageType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Enjin\Platform\FuelTanks\Enums\Substrate;

enum StorageType
{
case TANKS;
case ACCOUNTS;
}

0 comments on commit 89d84a0

Please sign in to comment.