-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLA-1770] Adds Balances.Teleport + LimitedTeleportAssets method. (#171)
- Loading branch information
1 parent
d7c2a44
commit 4653bd2
Showing
5 changed files
with
169 additions
and
25 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Enjin\Platform\Enums\Substrate; | ||
|
||
use Enjin\Platform\Traits\EnumExtensions; | ||
|
||
enum XcmOutcome: string | ||
{ | ||
use EnumExtensions; | ||
|
||
case COMPLETE = 'Complete'; | ||
case INCOMPLETE = 'Incomplete'; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Enjin\Platform\Events\Substrate\Balances; | ||
|
||
use Enjin\Platform\Channels\PlatformAppChannel; | ||
use Enjin\Platform\Events\PlatformBroadcastEvent; | ||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Teleport extends PlatformBroadcastEvent | ||
{ | ||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct(Model $from, Model $to, string $amount, string $destination, ?Model $transaction = null) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->broadcastData = [ | ||
'idempotencyKey' => $transaction?->idempotency_key, | ||
'transactionHash' => $transaction?->transaction_chain_hash, | ||
'from' => $from->address, | ||
'to' => $to->address, | ||
'amount' => $amount, | ||
'destination' => $destination, | ||
]; | ||
|
||
$this->broadcastChannels = [ | ||
new Channel($from->address), | ||
new Channel($to->address), | ||
new PlatformAppChannel(), | ||
]; | ||
} | ||
} |
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
74 changes: 74 additions & 0 deletions
74
src/Services/Processor/Substrate/Codec/Polkadart/Events/XcmPallet/Attempted.php
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Enjin\Platform\Services\Processor\Substrate\Codec\Polkadart\Events\XcmPallet; | ||
|
||
use Enjin\Platform\Enums\Substrate\XcmOutcome; | ||
use Enjin\Platform\Services\Processor\Substrate\Codec\Polkadart\Events\Event; | ||
use Enjin\Platform\Services\Processor\Substrate\Codec\Polkadart\PolkadartEvent; | ||
use Illuminate\Support\Arr; | ||
|
||
class Attempted extends Event implements PolkadartEvent | ||
{ | ||
public readonly ?string $extrinsicIndex; | ||
public readonly string $module; | ||
public readonly string $name; | ||
public readonly XcmOutcome $outcome; | ||
|
||
public static function fromChain(array $data): self | ||
{ | ||
$self = new self(); | ||
|
||
$self->extrinsicIndex = Arr::get($data, 'phase.ApplyExtrinsic'); | ||
$self->module = array_key_first(Arr::get($data, 'event')); | ||
$self->name = array_key_first(Arr::get($data, 'event.' . $self->module)); | ||
$self->outcome = XcmOutcome::tryFrom(array_key_first($self->getValue($data, ['xcm::latest::Outcome']))) ?? XcmOutcome::INCOMPLETE; | ||
|
||
return $self; | ||
} | ||
|
||
public function getPallet(): string | ||
{ | ||
return $this->module; | ||
} | ||
|
||
public function getParams(): array | ||
{ | ||
return [ | ||
['type' => 'outcome', 'value' => $this->outcome], | ||
]; | ||
} | ||
} | ||
|
||
// - Complete | ||
// +extrinsicIndex: "2" | ||
// +module: "XcmPallet" | ||
// +name: "Attempted" | ||
// +data: array:1 [▼ | ||
// "xcm::latest::Outcome" => array:1 [▼ | ||
// "Complete" => array:2 [▼ | ||
// "ref_time" => "450000000" | ||
// "proof_size" => "3072" | ||
// ] | ||
// ] | ||
// ] | ||
// +outcome: "Complete" | ||
// | ||
// | ||
// - Incomplete | ||
// +extrinsicIndex: "2" | ||
// +module: "XcmPallet" | ||
// +name: "Attempted" | ||
// +data: array:1 [▼ | ||
// "xcm::latest::Outcome" => array:1 [▼ | ||
// "Incomplete" => array:2 [▼ | ||
// 0 => array:2 [▼ | ||
// "ref_time" => "150000000" | ||
// "proof_size" => "1024" | ||
// ] | ||
// 1 => array:1 [▼ | ||
// "FailedToTransactAsset" => null | ||
// ] | ||
// ] | ||
// ] | ||
// ] | ||
// +outcome: "Incomplete" |