Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio committed Apr 10, 2024
1 parent 55fe358 commit be0fcf7
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ class AccountAdded extends FuelTankSubstrateEvent
*/
public function run(Event $event, Block $block, Codec $codec): void
{
ray($event);

if (!$event instanceof AccountAddedPolkadart) {
return;
}

throw new \Exception('Account rules are not supported yet');
// Fails if it doesn't find the fuel tank
$fuelTank = $this->getFuelTank($event->tankId);
$account = $this->firstOrStoreAccount($event->userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ class AccountRemoved extends FuelTankSubstrateEvent
*/
public function run(Event $event, Block $block, Codec $codec): void
{
ray($event);

if (!$event instanceof AccountRemovedPolkadart) {
return;
}

throw new \Exception('Account rules are not supported yet');
// Fails if it doesn't find the fuel tank
$fuelTank = $this->getFuelTank($event->tankId);
$account = $this->firstOrStoreAccount($event->userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
use Enjin\Platform\Models\Laravel\Block;
use Enjin\Platform\Services\Processor\Substrate\Codec\Codec;
use Enjin\Platform\Services\Processor\Substrate\Codec\Polkadart\Events\FuelTanks\AccountRuleDataRemoved as AccountRuleDataPolkadart;
use Enjin\Platform\Services\Processor\Substrate\Codec\Polkadart\PolkadartEvent;
use Enjin\Platform\Services\Processor\Substrate\Codec\Polkadart\Events\Event;

class AccountRuleDataRemoved extends FuelTankSubstrateEvent
{
/**
* Handle the account rule data removed event.
*/
public function run(PolkadartEvent $event, Block $block, Codec $codec): void
public function run(Event $event, Block $block, Codec $codec): void
{
ray($event);

if (!$event instanceof AccountRuleDataPolkadart) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ class CallDispatched extends FuelTankSubstrateEvent
*/
public function run(Event $event, Block $block, Codec $codec): void
{
ray($event);

if (!$event instanceof CallDispatchedPolkadart) {
return;
}

throw new \Exception('Account rules are not supported yet');
// Fail if it doesn't find the fuel tank
$fuelTank = $this->getFuelTank($event->tankId);
$account = $this->firstOrStoreAccount($event->caller);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

use Enjin\Platform\Exceptions\PlatformException;
use Enjin\Platform\FuelTanks\Events\Substrate\FuelTanks\FuelTankDestroyed as FuelTankDestroyedEvent;
use Enjin\Platform\FuelTanks\Models\Laravel\FuelTank;
use Enjin\Platform\FuelTanks\Services\Processor\Substrate\Events\FuelTankSubstrateEvent;
use Enjin\Platform\Models\Laravel\Block;
use Enjin\Platform\Services\Processor\Substrate\Codec\Codec;
use Enjin\Platform\Services\Processor\Substrate\Codec\Polkadart\Events\FuelTanks\FuelTankDestroyed as FuelTankDestroyedPolkadart;
use Enjin\Platform\Services\Processor\Substrate\Codec\Polkadart\Events\Event;
use Enjin\Platform\Support\Account;
use Illuminate\Support\Facades\Log;

class FuelTankDestroyed extends FuelTankSubstrateEvent
Expand All @@ -26,9 +24,10 @@ public function run(Event $event, Block $block, Codec $codec): void
return;
}

FuelTank::where([
'public_key' => Account::parseAccount($event->tankId),
])?->delete();
$fuelTank = $this->getFuelTank(
$event->tankId
);
$fuelTank->delete();

Log::info(
sprintf(
Expand All @@ -37,9 +36,9 @@ public function run(Event $event, Block $block, Codec $codec): void
)
);

// FuelTankDestroyedEvent::safeBroadcast(
// $fuelTank,
// $this->getTransaction($block, $event->extrinsicIndex),
// );
FuelTankDestroyedEvent::safeBroadcast(
$fuelTank,
$this->getTransaction($block, $event->extrinsicIndex),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ class FuelTankMutated extends FuelTankSubstrateEvent
*/
public function run(Event $event, Block $block, Codec $codec): void
{
ray($event);

if (!$event instanceof FuelTankMutatedPolkadart) {
return;
}

throw new \Exception('Account rules are not supported yet');
// Fail if it doesn't find the fuel tank
$fuelTank = $this->getFuelTank($event->tankId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ public function run(Event $event, Block $block, Codec $codec): void
return;
}

throw new \Exception('Account rules are not supported yet');
$extrinsic = $block->extrinsics[$event->extrinsicIndex];
$params = $extrinsic->params;
$rules = Arr::get($params, 'rules', []);

// Fail if it doesn't find the fuel tank
$fuelTank = $this->getFuelTank($event->tankId);

ray($extrinsic);
ray($params);

// throw new \Exception('Account rules are not supported yet');
$insertRules = [];
foreach ($rules as $rule) {
$ruleName = array_key_first($rule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@ class RuleSetRemoved extends FuelTankSubstrateEvent
*/
public function run(Event $event, Block $block, Codec $codec): void
{
ray($event);

if (!$event instanceof RuleSetRemovedPolkadart) {
return;
}

throw new \Exception('Account rules are not supported yet');
// Fail if it doesn't find the fuel tank
$fuelTank = $this->getFuelTank($event->tankId);
$rules = DispatchRule::where([
Expand Down

0 comments on commit be0fcf7

Please sign in to comment.