diff --git a/src/Services/Processor/Substrate/Codec/Decoder.php b/src/Services/Processor/Substrate/Codec/Decoder.php index 07793c4..26469b6 100644 --- a/src/Services/Processor/Substrate/Codec/Decoder.php +++ b/src/Services/Processor/Substrate/Codec/Decoder.php @@ -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, endBlock: Compact } + // Offer = { expiration: Option } + // 'state' => Now has FixedPrice, Auction, Offer + // FixedPrice = { amountFilled: Compact } + // Auction = { highBid: Option } + // Bid = { bidder: AccountId, price: Compact } + // Offer = { counter: Option } + // CounterOffer = { accountId: AccountId, price: u128 } ]; } }