Skip to content

Commit

Permalink
[PLA-1875] Supports v1010 on sync (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio authored Jul 4, 2024
1 parent 8e95c42 commit 96c5f07
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/Services/Processor/Substrate/Codec/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,33 @@ public function listingStorageKey(string $data): array
*/
public function listingStorageData(string $data): array
{
$decoded = $this->codec->process('ListingStorageData', new ScaleBytes($data));
$decoded = $this->codec->process(isRunningLatest() ? 'ListingStorageDataV1010' : 'ListingStorageData', new ScaleBytes($data));

return [
'seller' => ($seller = Arr::get($decoded, 'seller')) !== null ? HexConverter::prefix($seller) : null,
'seller' => ($seller = $this->getValue($decoded, ['seller', 'creator'])) !== null ? HexConverter::prefix($seller) : null,
'makeAssetId' => MultiTokensTokenAssetIdParams::fromEncodable(Arr::get($decoded, 'makeAssetId')),
'takeAssetId' => MultiTokensTokenAssetIdParams::fromEncodable(Arr::get($decoded, 'takeAssetId')),
'amount' => gmp_strval(Arr::get($decoded, 'amount')),
'price' => gmp_strval(Arr::get($decoded, 'price')),
'minTakeValue' => gmp_strval(Arr::get($decoded, 'minTakeValue')),
'minTakeValue' => gmp_strval($this->getValue($decoded, ['minTakeValue', 'minReceived'])),
'feeSide' => FeeSide::from(Arr::get($decoded, 'feeSide', 'NoFee')),
'creationBlock' => gmp_strval(Arr::get($decoded, 'creationBlock')),
'deposit' => gmp_strval(Arr::get($decoded, 'deposit')),
'deposit' => gmp_strval($this->getValue($decoded, ['deposit.amount', 'deposit'])),
'salt' => Arr::get($decoded, 'salt'),
'data' => Arr::get($decoded, 'data'), // TODO: Check
'state' => Arr::get($decoded, 'state'), // TODO; Check
'data' => Arr::get($decoded, 'data'),
'state' => Arr::get($decoded, 'state'),
// TODO: This are new fields added in v1010
// 'depositDepositor' => Arr::get($decoded, 'deposit.depositor'),
// 'data' => Now has FixedPrice, Auction, Offer
// FixedPrice = boolean
// Auction = { startBlock: Compact<u32>, endBlock: Compact<u32> }
// Offer = { expiration: Option<u32> }
// 'state' => Now has FixedPrice, Auction, Offer
// FixedPrice = { amountFilled: Compact<u128> }
// Auction = { highBid: Option<Bid> }
// Bid = { bidder: AccountId, price: Compact<u128> }
// Offer = { counter: Option<CounterOffer> }
// CounterOffer = { accountId: AccountId, price: u128 }
];
}
}

0 comments on commit 96c5f07

Please sign in to comment.