-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove obsolete transactions (#125)
- Loading branch information
1 parent
e7e5dd4
commit 0d7e9c0
Showing
29 changed files
with
74 additions
and
608 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -13,32 +13,68 @@ | |
|
||
namespace ArkEcosystem\Crypto\Enums; | ||
|
||
use ArkEcosystem\Crypto\Transactions\Types\MultiPayment; | ||
use ArkEcosystem\Crypto\Transactions\Types\MultiSignatureRegistration; | ||
use ArkEcosystem\Crypto\Transactions\Types\Transfer; | ||
use ArkEcosystem\Crypto\Transactions\Types\UsernameRegistration; | ||
use ArkEcosystem\Crypto\Transactions\Types\UsernameResignation; | ||
use ArkEcosystem\Crypto\Transactions\Types\ValidatorRegistration; | ||
use ArkEcosystem\Crypto\Transactions\Types\ValidatorResignation; | ||
use ArkEcosystem\Crypto\Transactions\Types\Vote; | ||
use ReflectionEnum; | ||
|
||
/** | ||
* This is the transaction types class. | ||
* | ||
* @author Brian Faust <[email protected]> | ||
* This is the transaction types enum. | ||
*/ | ||
class Types | ||
enum Types: int | ||
{ | ||
public const TRANSFER = 0; | ||
|
||
public const SECOND_SIGNATURE_REGISTRATION = 1; | ||
|
||
public const VALIDATOR_REGISTRATION = 2; | ||
|
||
public const VOTE = 3; | ||
|
||
public const MULTI_SIGNATURE_REGISTRATION = 4; | ||
|
||
public const IPFS = 5; | ||
case TRANSFER = 0; | ||
case VALIDATOR_REGISTRATION = 2; | ||
case VOTE = 3; | ||
case MULTI_SIGNATURE_REGISTRATION = 4; | ||
case MULTI_PAYMENT = 6; | ||
case VALIDATOR_RESIGNATION = 7; | ||
case USERNAME_REGISTRATION = 8; | ||
case USERNAME_RESIGNATION = 9; | ||
|
||
public const MULTI_PAYMENT = 6; | ||
public function transactionClass(): string | ||
{ | ||
return match ($this) { | ||
Types::TRANSFER => Transfer::class, | ||
Types::VALIDATOR_REGISTRATION => ValidatorRegistration::class, | ||
Types::VOTE => Vote::class, | ||
Types::MULTI_SIGNATURE_REGISTRATION => MultiSignatureRegistration::class, | ||
Types::MULTI_PAYMENT => MultiPayment::class, | ||
Types::VALIDATOR_RESIGNATION => ValidatorResignation::class, | ||
Types::USERNAME_REGISTRATION => UsernameRegistration::class, | ||
Types::USERNAME_RESIGNATION => UsernameResignation::class, | ||
}; | ||
} | ||
|
||
public const VALIDATOR_RESIGNATION = 7; | ||
public function defaultFee(): string | ||
{ | ||
return match ($this) { | ||
Types::TRANSFER => Fees::TRANSFER, | ||
Types::VALIDATOR_REGISTRATION => Fees::VALIDATOR_REGISTRATION, | ||
Types::VOTE => Fees::VOTE, | ||
Types::MULTI_SIGNATURE_REGISTRATION => Fees::MULTI_SIGNATURE_REGISTRATION, | ||
Types::MULTI_PAYMENT => Fees::MULTI_PAYMENT, | ||
Types::VALIDATOR_RESIGNATION => Fees::VALIDATOR_RESIGNATION, | ||
Types::USERNAME_REGISTRATION => Fees::USERNAME_REGISTRATION, | ||
Types::USERNAME_RESIGNATION => Fees::USERNAME_RESIGNATION, | ||
}; | ||
} | ||
|
||
public const USERNAME_REGISTRATION = 8; | ||
public static function fromValue(int $value): ?self | ||
{ | ||
$enum = new ReflectionEnum(self::class); | ||
|
||
public const USERNAME_RESIGNATION = 9; | ||
foreach ($enum->getCases() as $case) { | ||
if ($case->getValue()->value === $value) { | ||
return $case->getValue(); | ||
} | ||
} | ||
|
||
public const HTLC_REFUND = 10; | ||
throw new \InvalidArgumentException("Invalid value: {$value}"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.