Skip to content

Commit

Permalink
MinInfusion
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio committed Dec 20, 2024
1 parent 6b64592 commit 44f4668
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Enums/DispatchRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Enjin\Platform\FuelTanks\Models\Substrate\FuelTankRules;
use Enjin\Platform\FuelTanks\Models\Substrate\MaxFuelBurnPerTransactionParams;
use Enjin\Platform\FuelTanks\Models\Substrate\MinimumInfusionParams;
use Enjin\Platform\FuelTanks\Models\Substrate\PermittedCallsParams;
use Enjin\Platform\FuelTanks\Models\Substrate\PermittedExtrinsicsParams;
use Enjin\Platform\FuelTanks\Models\Substrate\RequireSignatureParams;
Expand All @@ -29,6 +30,7 @@ enum DispatchRule: string
case PERMITTED_CALLS = 'PermittedCalls';
case WHITELISTED_PALLETS = 'WhitelistedPallets';
case REQUIRE_SIGNATURE = 'RequireSignature';
case MINIMUM_INFUSION = 'MinimumInfusion';

/**
* Convert enum case to FuelTankRules.
Expand All @@ -46,6 +48,7 @@ public function toKind(): FuelTankRules
self::PERMITTED_CALLS => new PermittedCallsParams(),
self::WHITELISTED_PALLETS => new WhitelistedPalletsParams(),
self::REQUIRE_SIGNATURE => new RequireSignatureParams(''),
self::MINIMUM_INFUSION => new MinimumInfusionParams('')
};
}
}
9 changes: 9 additions & 0 deletions src/Models/Substrate/DispatchRulesParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct(
public ?PermittedExtrinsicsParams $permittedExtrinsics = null,
public ?WhitelistedPalletsParams $whitelistedPallets = null,
public ?RequireSignatureParams $requireSignature = null,
public ?MinimumInfusionParams $minimumInfusion = null,
public ?bool $isFrozen = false,
) {}

Expand Down Expand Up @@ -85,6 +86,10 @@ public function toEncodable(): array
$params[] = ['PermittedExtrinsics' => ['extrinsics' => []]];
}

if ($this->minimumInfusion) {
$params[] = $this->minimumInfusion->toEncodable();
}


return $params;
}
Expand Down Expand Up @@ -133,6 +138,10 @@ public function toArray(): array
$params[] = $this->requireSignature->toArray();
}

if ($this->minimumInfusion) {
$params[] = $this->minimumInfusion->toArray();
}

return $params;
}
}
45 changes: 45 additions & 0 deletions src/Models/Substrate/MinimumInfusionParams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Enjin\Platform\FuelTanks\Models\Substrate;

use Illuminate\Support\Arr;

class MinimumInfusionParams extends FuelTankRules
{
/**
* Creates a new instance.
*/
public function __construct(public string $min) {}

/**
* Creates a new instance from the given array.
*/
public static function fromEncodable(array $params): self
{
return new self(
min: gmp_strval(Arr::get($params, 'MinimumInfusion')),
);
}

/**
* Returns the encodable representation of this instance.
*/
public function toEncodable(): array
{
return [
'MinimumInfusion' => $this->min,
];
}

public function toArray(): array
{
return [
'MinimumInfusion' => $this->min,
];
}

public function validate(string $value): bool
{
return true;
}
}

0 comments on commit 44f4668

Please sign in to comment.