From b7226995ba948acc3870419ee3b2364f11233ca3 Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Thu, 10 Oct 2024 22:47:02 -0300 Subject: [PATCH] [PLA-2033] Removes old codecs from encoder (#263) --- .../Substrate/Mutations/BatchMintMutation.php | 3 +- .../Mutations/BatchSetAttributeMutation.php | 3 +- .../Mutations/BatchTransferMutation.php | 5 +- .../Substrate/Mutations/BurnMutation.php | 5 +- .../Mutations/MutateTokenMutation.php | 12 +--- .../OperatorTransferTokenMutation.php | 2 +- .../SetCollectionAttributeMutation.php | 2 +- .../Mutations/SetTokenAttributeMutation.php | 2 +- .../Mutations/SimpleTransferTokenMutation.php | 2 +- src/Models/Substrate/BurnParams.php | 12 ++-- .../Substrate/OperatorTransferParams.php | 14 +--- src/Models/Substrate/SimpleTransferParams.php | 14 +--- .../Blockchain/Implementations/Substrate.php | 2 - .../Processor/Substrate/Codec/Decoder.php | 1 - .../Processor/Substrate/Codec/Encoder.php | 6 -- .../Codec/Types/BatchSetAttribute.json | 8 +-- .../Substrate/Codec/Types/BatchTransfer.json | 9 --- .../Processor/Substrate/Codec/Types/Burn.json | 11 ---- .../Substrate/Codec/Types/CreateListing.json | 17 +---- .../Substrate/Codec/Types/ListingStorage.json | 66 ++++++------------- .../Substrate/Codec/Types/MutateToken.json | 15 +---- .../Substrate/Codec/Types/SetAttribute.json | 7 -- .../Codec/Types/TokenAccountsStorage.json | 9 --- .../Substrate/Codec/Types/Transfer.json | 25 +------ .../GraphQL/Mutations/BatchTransferTest.php | 6 -- tests/Feature/GraphQL/Mutations/BurnTest.php | 3 - .../Mutations/OperatorTransferTokenTest.php | 12 ---- .../Mutations/SimpleTransferTokenTest.php | 11 ---- tests/Unit/DecodingTest.php | 3 +- tests/Unit/EncodingTest.php | 17 ++--- 30 files changed, 52 insertions(+), 252 deletions(-) diff --git a/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchMintMutation.php b/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchMintMutation.php index a4a413e9..db1bc8e1 100644 --- a/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchMintMutation.php +++ b/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchMintMutation.php @@ -135,8 +135,7 @@ function ($recipient) use ($blockchainService, $walletService) { // TODO: With the v1010 upgrade we run into a bug with the php-scale-codec lib where it cannot // Encode the transaction with `0x` the solution here is to use Batch and within each call append the 0's $continueOnFailure = true; - $method = isRunningLatest() ? $this->getMutationName() . 'V1010' : $this->getMutationName(); - $encodedData = $serializationService->encode($continueOnFailure ? 'Batch' : $method, static::getEncodableParams( + $encodedData = $serializationService->encode($continueOnFailure ? 'Batch' : $this->getMutationName(), static::getEncodableParams( collectionId: $args['collectionId'], recipients: $recipients->toArray(), continueOnFailure: $continueOnFailure diff --git a/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchSetAttributeMutation.php b/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchSetAttributeMutation.php index edf1a5a9..c2e67749 100644 --- a/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchSetAttributeMutation.php +++ b/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchSetAttributeMutation.php @@ -99,8 +99,7 @@ public function resolve( TransactionService $transactionService ): mixed { $continueOnFailure = $args['continueOnFailure']; - $method = isRunningLatest() ? $this->getMutationName() . 'V1010' : $this->getMutationName(); - $encodedData = $serializationService->encode($continueOnFailure ? 'Batch' : $method, static::getEncodableParams( + $encodedData = $serializationService->encode($continueOnFailure ? 'Batch' : $this->getMutationName(), static::getEncodableParams( collectionId: $args['collectionId'], tokenId: $this->encodeTokenId($args), attributes: $args['attributes'], diff --git a/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchTransferMutation.php b/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchTransferMutation.php index b21f4b95..af16d0d0 100644 --- a/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchTransferMutation.php +++ b/src/GraphQL/Schemas/Primary/Substrate/Mutations/BatchTransferMutation.php @@ -126,8 +126,7 @@ function ($recipient) use ($blockchainService, $walletService) { ); $continueOnFailure = $args['continueOnFailure']; - $method = isRunningLatest() ? $this->getMutationName() . 'V1010' : $this->getMutationName(); - $encodedData = $serializationService->encode($continueOnFailure ? 'Batch' : $method, static::getEncodableParams( + $encodedData = $serializationService->encode($continueOnFailure ? 'Batch' : $this->getMutationName(), static::getEncodableParams( collectionId: $args['collectionId'], recipients: $recipients->toArray(), continueOnFailure: $continueOnFailure @@ -148,7 +147,7 @@ public static function getEncodableParams(...$params): array if ($continueOnFailure) { $encodedData = collect($recipients)->map( - fn ($recipient) => $serializationService->encode(isRunningLatest() ? 'TransferV1010' : 'TransferToken', [ + fn ($recipient) => $serializationService->encode('Transfer', [ 'recipient' => [ 'Id' => HexConverter::unPrefix($recipient['accountId']), ], diff --git a/src/GraphQL/Schemas/Primary/Substrate/Mutations/BurnMutation.php b/src/GraphQL/Schemas/Primary/Substrate/Mutations/BurnMutation.php index 5d1a87d1..5273dc66 100644 --- a/src/GraphQL/Schemas/Primary/Substrate/Mutations/BurnMutation.php +++ b/src/GraphQL/Schemas/Primary/Substrate/Mutations/BurnMutation.php @@ -94,10 +94,9 @@ public function resolve( TransactionService $transactionService, ): mixed { $args['params']['tokenId'] = $this->encodeTokenId($args['params']); - unset($args['params']['encodeTokenId']); + unset($args['params']['encodeTokenId'], $args['params']['keepAlive']); - $method = isRunningLatest() ? $this->getMutationName() . 'V1010' : $this->getMutationName(); - $encodedData = $serializationService->encode($method, static::getEncodableParams( + $encodedData = $serializationService->encode($this->getMutationName(), static::getEncodableParams( collectionId: $args['collectionId'], burnParams: new BurnParams(...$args['params']) )); diff --git a/src/GraphQL/Schemas/Primary/Substrate/Mutations/MutateTokenMutation.php b/src/GraphQL/Schemas/Primary/Substrate/Mutations/MutateTokenMutation.php index 29043b44..254ee170 100644 --- a/src/GraphQL/Schemas/Primary/Substrate/Mutations/MutateTokenMutation.php +++ b/src/GraphQL/Schemas/Primary/Substrate/Mutations/MutateTokenMutation.php @@ -95,8 +95,7 @@ public function resolve( TransactionService $transactionService, Substrate $blockchainService ): mixed { - $method = isRunningLatest() ? $this->getMutationName() . 'V1010' : $this->getMutationName(); - $encodedData = $serializationService->encode($method, static::getEncodableParams( + $encodedData = $serializationService->encode($this->getMutationName(), static::getEncodableParams( collectionId: $args['collectionId'], tokenId: $this->encodeTokenId($args), behavior: $blockchainService->getMutateTokenBehavior(Arr::get($args, 'mutation')), @@ -122,12 +121,6 @@ public function validationErrorMessages(array $args = []): array public static function getEncodableParams(...$params): array { $behavior = Arr::get($params, 'behavior'); - $extra = isRunningLatest() ? [ - 'anyoneCanInfuse' => null, - 'name' => null, - ] : [ - 'metadata' => null, - ]; return [ 'collectionId' => gmp_init(Arr::get($params, 'collectionId', 0)), @@ -135,7 +128,8 @@ public static function getEncodableParams(...$params): array 'mutation' => [ 'behavior' => is_array($behavior) ? ['NoMutation' => null] : ['SomeMutation' => $behavior?->toEncodable()], 'listingForbidden' => Arr::get($params, 'listingForbidden'), - ...$extra, + 'anyoneCanInfuse' => null, // TODO: Add this when the mutation is changed + 'name' => null, // TODO: Add this when the mutation is changed ], ]; } diff --git a/src/GraphQL/Schemas/Primary/Substrate/Mutations/OperatorTransferTokenMutation.php b/src/GraphQL/Schemas/Primary/Substrate/Mutations/OperatorTransferTokenMutation.php index 51f41dd9..64f73710 100644 --- a/src/GraphQL/Schemas/Primary/Substrate/Mutations/OperatorTransferTokenMutation.php +++ b/src/GraphQL/Schemas/Primary/Substrate/Mutations/OperatorTransferTokenMutation.php @@ -121,7 +121,7 @@ public function resolve( */ public function getMethodName(): string { - return isRunningLatest() ? 'TransferV1010' : 'Transfer'; + return 'Transfer'; } public static function getEncodableParams(...$params): array diff --git a/src/GraphQL/Schemas/Primary/Substrate/Mutations/SetCollectionAttributeMutation.php b/src/GraphQL/Schemas/Primary/Substrate/Mutations/SetCollectionAttributeMutation.php index 9f24606f..4e235e4a 100644 --- a/src/GraphQL/Schemas/Primary/Substrate/Mutations/SetCollectionAttributeMutation.php +++ b/src/GraphQL/Schemas/Primary/Substrate/Mutations/SetCollectionAttributeMutation.php @@ -103,7 +103,7 @@ public function resolve( */ public function getMethodName(): string { - return isRunningLatest() ? 'SetAttributeV1010' : 'SetAttribute'; + return 'SetAttribute'; } public static function getEncodableParams(...$params): array diff --git a/src/GraphQL/Schemas/Primary/Substrate/Mutations/SetTokenAttributeMutation.php b/src/GraphQL/Schemas/Primary/Substrate/Mutations/SetTokenAttributeMutation.php index 9d3a6ae4..d266b11d 100644 --- a/src/GraphQL/Schemas/Primary/Substrate/Mutations/SetTokenAttributeMutation.php +++ b/src/GraphQL/Schemas/Primary/Substrate/Mutations/SetTokenAttributeMutation.php @@ -115,7 +115,7 @@ public function resolve( */ public function getMethodName(): string { - return isRunningLatest() ? 'SetAttributeV1010' : 'SetAttribute'; + return 'SetAttribute'; } public static function getEncodableParams(...$params): array diff --git a/src/GraphQL/Schemas/Primary/Substrate/Mutations/SimpleTransferTokenMutation.php b/src/GraphQL/Schemas/Primary/Substrate/Mutations/SimpleTransferTokenMutation.php index 0e272c2c..e9197dd1 100644 --- a/src/GraphQL/Schemas/Primary/Substrate/Mutations/SimpleTransferTokenMutation.php +++ b/src/GraphQL/Schemas/Primary/Substrate/Mutations/SimpleTransferTokenMutation.php @@ -120,7 +120,7 @@ public function resolve( */ public function getMethodName(): string { - return isRunningLatest() ? 'TransferV1010' : 'Transfer'; + return 'Transfer'; } public static function getEncodableParams(...$params): array diff --git a/src/Models/Substrate/BurnParams.php b/src/Models/Substrate/BurnParams.php index 84f52847..b64882f8 100644 --- a/src/Models/Substrate/BurnParams.php +++ b/src/Models/Substrate/BurnParams.php @@ -12,7 +12,6 @@ class BurnParams public function __construct( public string $tokenId, public string $amount, - public ?bool $keepAlive = false, public ?bool $removeTokenStorage = false, ) {} @@ -24,7 +23,6 @@ public static function fromEncodable(array $params): self return new self( tokenId: gmp_strval(Arr::get($params, 'tokenId')), amount: gmp_strval(Arr::get($params, 'amount')), - keepAlive: Arr::get($params, 'keepAlive'), removeTokenStorage: Arr::get($params, 'removeTokenStorage'), ); } @@ -37,7 +35,6 @@ public static function fromArray(array $params): self return new self( tokenId: Arr::get($params, 'tokenId'), amount: Arr::get($params, 'amount'), - keepAlive: Arr::get($params, 'keepAlive'), removeTokenStorage: Arr::get($params, 'removeTokenStorage') ); } @@ -47,11 +44,11 @@ public static function fromArray(array $params): self */ public function toEncodable(): array { - return array_merge([ + return [ 'tokenId' => gmp_init($this->tokenId), 'amount' => gmp_init($this->amount), 'removeTokenStorage' => $this->removeTokenStorage, - ], isRunningLatest() ? [] : ['keepAlive' => $this->keepAlive]); + ]; } /** @@ -59,11 +56,10 @@ public function toEncodable(): array */ public function toArray(): array { - return array_merge([ + return [ 'tokenId' => $this->tokenId, 'amount' => $this->amount, - 'keepAlive' => $this->keepAlive, 'removeTokenStorage' => $this->removeTokenStorage, - ], isRunningLatest() ? [] : ['keepAlive' => $this->keepAlive]); + ]; } } diff --git a/src/Models/Substrate/OperatorTransferParams.php b/src/Models/Substrate/OperatorTransferParams.php index 5a5f6356..3e4a2ece 100644 --- a/src/Models/Substrate/OperatorTransferParams.php +++ b/src/Models/Substrate/OperatorTransferParams.php @@ -14,7 +14,6 @@ public function __construct( public string $tokenId, public string $source, public string $amount, - public ?bool $keepAlive = false ) {} /** @@ -26,7 +25,6 @@ public static function fromEncodable(array $params): self tokenId: gmp_strval(Arr::get($params, 'tokenId')), source: SS58Address::encode(Arr::get($params, 'source')), amount: gmp_strval(Arr::get($params, 'amount')), - keepAlive: Arr::get($params, 'keepAlive', false), ); } @@ -39,7 +37,6 @@ public static function fromArray(array $params): self tokenId: Arr::get($params, 'tokenId'), source: SS58Address::encode(Arr::get($params, 'source')), amount: Arr::get($params, 'amount'), - keepAlive: Arr::get($params, 'keepAlive', false), ); } @@ -48,16 +45,12 @@ public static function fromArray(array $params): self */ public function toEncodable(): array { - $extra = isRunningLatest() - ? ['depositor' => null] - : ['keepAlive' => $this->keepAlive]; - return [ 'Operator' => [ 'tokenId' => gmp_init($this->tokenId), 'source' => SS58Address::getPublicKey($this->source), 'amount' => gmp_init($this->amount), - ...$extra, + 'depositor' => null, ], ]; } @@ -67,16 +60,11 @@ public function toEncodable(): array */ public function toArray(): array { - isRunningLatest() - ? $extra['depositor'] = null - : $extra['keepAlive'] = $this->keepAlive; - return [ 'Operator' => [ 'tokenId' => $this->tokenId, 'source' => $this->source, 'amount' => $this->amount, - ...$extra, ], ]; } diff --git a/src/Models/Substrate/SimpleTransferParams.php b/src/Models/Substrate/SimpleTransferParams.php index bd4176d7..5d6a3d24 100644 --- a/src/Models/Substrate/SimpleTransferParams.php +++ b/src/Models/Substrate/SimpleTransferParams.php @@ -12,7 +12,6 @@ class SimpleTransferParams public function __construct( public string $tokenId, public string $amount, - public ?bool $keepAlive = false ) {} /** @@ -23,7 +22,6 @@ public static function fromEncodable(array $params): self return new self( tokenId: gmp_strval(Arr::get($params, 'tokenId')), amount: gmp_strval(Arr::get($params, 'amount')), - keepAlive: Arr::get($params, 'keepAlive', false), ); } @@ -35,7 +33,6 @@ public static function fromArray(array $params): self return new self( tokenId: Arr::get($params, 'tokenId'), amount: Arr::get($params, 'amount'), - keepAlive: Arr::get($params, 'keepAlive', false), ); } @@ -44,15 +41,11 @@ public static function fromArray(array $params): self */ public function toEncodable(): array { - $extra = isRunningLatest() - ? ['depositor' => null] - : ['keepAlive' => $this->keepAlive]; - return [ 'Simple' => [ 'tokenId' => gmp_init($this->tokenId), 'amount' => gmp_init($this->amount), - ...$extra, + 'depositor' => null, ], ]; } @@ -62,15 +55,10 @@ public function toEncodable(): array */ public function toArray(): array { - isRunningLatest() - ? $extra['depositor'] = null - : $extra['keepAlive'] = $this->keepAlive; - return [ 'Simple' => [ 'tokenId' => $this->tokenId, 'amount' => $this->amount, - ...$extra, ], ]; } diff --git a/src/Services/Blockchain/Implementations/Substrate.php b/src/Services/Blockchain/Implementations/Substrate.php index 2e733d0b..63b0f2a6 100644 --- a/src/Services/Blockchain/Implementations/Substrate.php +++ b/src/Services/Blockchain/Implementations/Substrate.php @@ -332,7 +332,6 @@ public function getOperatorTransferParams(array $args): OperatorTransferParams $this->encodeTokenId($args), $args['source'], $args['amount'], - $args['keepAlive'], ]; return new OperatorTransferParams(...$data); @@ -346,7 +345,6 @@ public function getSimpleTransferParams(array $args): SimpleTransferParams $data = [ $this->encodeTokenId($args), $args['amount'], - $args['keepAlive'], ]; return new SimpleTransferParams(...$data); diff --git a/src/Services/Processor/Substrate/Codec/Decoder.php b/src/Services/Processor/Substrate/Codec/Decoder.php index fc7f9696..77afdf42 100644 --- a/src/Services/Processor/Substrate/Codec/Decoder.php +++ b/src/Services/Processor/Substrate/Codec/Decoder.php @@ -85,7 +85,6 @@ public function burn(string $data): array 'collectionId' => gmp_strval(Arr::get($decoded, 'collectionId')), 'tokenId' => gmp_strval(Arr::get($decoded, 'params.tokenId')), 'amount' => gmp_strval(Arr::get($decoded, 'params.amount')), - 'keepAlive' => Arr::get($decoded, 'params.keepAlive'), 'removeTokenStorage' => Arr::get($decoded, 'params.removeTokenStorage'), ]; } diff --git a/src/Services/Processor/Substrate/Codec/Encoder.php b/src/Services/Processor/Substrate/Codec/Encoder.php index ccb4dc32..34e0b111 100644 --- a/src/Services/Processor/Substrate/Codec/Encoder.php +++ b/src/Services/Processor/Substrate/Codec/Encoder.php @@ -33,26 +33,20 @@ class Encoder 'ApproveToken' => 'MultiTokens.approve_token', 'UnapproveToken' => 'MultiTokens.unapprove_token', 'BatchSetAttribute' => 'MultiTokens.batch_set_attribute', - 'BatchSetAttributeV1010' => 'MultiTokens.batch_set_attribute', 'BatchTransfer' => 'MultiTokens.batch_transfer', - 'BatchTransferV1010' => 'MultiTokens.batch_transfer', 'Transfer' => 'MultiTokens.transfer', - 'TransferV1010' => 'MultiTokens.transfer', 'CreateCollection' => 'MultiTokens.create_collection', 'DestroyCollection' => 'MultiTokens.destroy_collection', 'MutateCollection' => 'MultiTokens.mutate_collection', 'MutateToken' => 'MultiTokens.mutate_token', - 'MutateTokenV1010' => 'MultiTokens.mutate_token', 'Mint' => 'MultiTokens.mint', 'BatchMint' => 'MultiTokens.batch_mint', 'Burn' => 'MultiTokens.burn', - 'BurnV1010' => 'MultiTokens.burn', 'Infuse' => 'MultiTokens.infuse', 'Freeze' => 'MultiTokens.freeze', 'Thaw' => 'MultiTokens.thaw', 'SetRoyalty' => 'MultiTokens.set_royalty', 'SetAttribute' => 'MultiTokens.set_attribute', - 'SetAttributeV1010' => 'MultiTokens.set_attribute', 'RemoveAttribute' => 'MultiTokens.remove_attribute', 'RemoveAllAttributes' => 'MultiTokens.remove_all_attributes', 'AcceptCollectionTransfer' => 'MultiTokens.accept_collection_transfer', diff --git a/src/Services/Processor/Substrate/Codec/Types/BatchSetAttribute.json b/src/Services/Processor/Substrate/Codec/Types/BatchSetAttribute.json index c754af74..9f904c27 100644 --- a/src/Services/Processor/Substrate/Codec/Types/BatchSetAttribute.json +++ b/src/Services/Processor/Substrate/Codec/Types/BatchSetAttribute.json @@ -1,15 +1,9 @@ { - "BatchSetAttribute": { - "callIndex": "(u8, u8)", - "collectionId": "Compact", - "tokenId": "Option", - "attributes": "Vec" - }, "Attribute": { "key": "Bytes", "value": "Bytes" }, - "BatchSetAttributeV1010": { + "BatchSetAttribute": { "callIndex": "(u8, u8)", "collectionId": "Compact", "tokenId": "Option", diff --git a/src/Services/Processor/Substrate/Codec/Types/BatchTransfer.json b/src/Services/Processor/Substrate/Codec/Types/BatchTransfer.json index 09868c34..0f9f56e9 100644 --- a/src/Services/Processor/Substrate/Codec/Types/BatchTransfer.json +++ b/src/Services/Processor/Substrate/Codec/Types/BatchTransfer.json @@ -7,14 +7,5 @@ "TransferRecipient": { "accountId": "AccountId", "params": "TransferParamsOf" - }, - "BatchTransferV1010": { - "callIndex": "(u8, u8)", - "collectionId": "Compact", - "recipients": "Vec" - }, - "TransferRecipientV1010": { - "accountId": "AccountId", - "params": "TransferParamsOfV1010" } } \ No newline at end of file diff --git a/src/Services/Processor/Substrate/Codec/Types/Burn.json b/src/Services/Processor/Substrate/Codec/Types/Burn.json index 2bdce322..fc063144 100644 --- a/src/Services/Processor/Substrate/Codec/Types/Burn.json +++ b/src/Services/Processor/Substrate/Codec/Types/Burn.json @@ -5,17 +5,6 @@ "params": "BurnParamsOf" }, "BurnParamsOf": { - "tokenId": "Compact", - "amount": "Compact", - "keepAlive": "bool", - "removeTokenStorage": "bool" - }, - "BurnV1010": { - "callIndex": "(u8, u8)", - "collectionId": "Compact", - "params": "BurnParamsOfV1010" - }, - "BurnParamsOfV1010": { "tokenId": "Compact", "amount": "Compact", "removeTokenStorage": "bool" diff --git a/src/Services/Processor/Substrate/Codec/Types/CreateListing.json b/src/Services/Processor/Substrate/Codec/Types/CreateListing.json index a24873e2..4afcc51c 100644 --- a/src/Services/Processor/Substrate/Codec/Types/CreateListing.json +++ b/src/Services/Processor/Substrate/Codec/Types/CreateListing.json @@ -6,23 +6,10 @@ "amount": "Compact", "price": "Compact", "salt": "Bytes", - "auctionData": "Option" - }, - "AuctionData": { - "startBlock": "Compact", - "endBlock": "Compact" - }, - "CreateListingV1010": { - "callIndex": "(u8, u8)", - "makeAssetId": "MultiTokensAssetId", - "takeAssetId": "MultiTokensAssetId", - "amount": "Compact", - "price": "Compact", - "salt": "Bytes", - "listingData": "ListingDataV1010", + "listingData": "ListingData", "depositor": "Option" }, - "ListingDataV1010": { + "ListingData": { "_enum": { "FixedPrice": "Null", "Auction": "AuctionData", diff --git a/src/Services/Processor/Substrate/Codec/Types/ListingStorage.json b/src/Services/Processor/Substrate/Codec/Types/ListingStorage.json index eaf74afd..87676e54 100644 --- a/src/Services/Processor/Substrate/Codec/Types/ListingStorage.json +++ b/src/Services/Processor/Substrate/Codec/Types/ListingStorage.json @@ -5,38 +5,46 @@ "listingId": "h256" }, "ListingStorageData": { - "seller": "AccountId", + "creator": "AccountId", "makeAssetId": "MultiTokensAssetId", "takeAssetId": "MultiTokensAssetId", "amount": "Compact", "price": "Compact", - "minTakeValue": "Compact", + "minReceived": "Compact", "feeSide": "ListingFeeSide", "creationBlock": "Compact", - "deposit": "Compact", + "deposit": "CreationDeposit", "salt": "Bytes", "data": "ListingData", "state": "ListingState" }, - "ListingFeeSide": { - "_enum": [ - "NoFee", - "Make", - "Take" - ] - }, "ListingData": { "_enum": { "FixedPrice": "Null", - "Auction": "AuctionData" + "Auction": "AuctionData", + "Offer": "OfferData" } }, + "OfferData": { + "expiration": "Option" + }, "ListingState": { "_enum": { "FixedPrice": "FixedPriceState", - "Auction": "AuctionState" + "Auction": "AuctionState", + "Offer": "OfferState" } }, + "OfferState": { + "counterOfferCount": "u32" + }, + "ListingFeeSide": { + "_enum": [ + "NoFee", + "Make", + "Take" + ] + }, "FixedPriceState": { "amountFilled": "Compact" }, @@ -46,39 +54,5 @@ "AuctionBid": { "bidder": "AccountId", "price": "Compact" - }, - "ListingStorageDataV1010": { - "creator": "AccountId", - "makeAssetId": "MultiTokensAssetId", - "takeAssetId": "MultiTokensAssetId", - "amount": "Compact", - "price": "Compact", - "minReceived": "Compact", - "feeSide": "ListingFeeSide", - "creationBlock": "Compact", - "deposit": "CreationDeposit", - "salt": "Bytes", - "data": "ListingDataV1010", - "state": "ListingStateV1010" - }, - "ListingDataV1010": { - "_enum": { - "FixedPrice": "Null", - "Auction": "AuctionData", - "Offer": "OfferDataV1010" - } - }, - "OfferDataV1010": { - "expiration": "Option" - }, - "ListingStateV1010": { - "_enum": { - "FixedPrice": "FixedPriceState", - "Auction": "AuctionState", - "Offer": "OfferStateV1011" - } - }, - "OfferStateV1011": { - "counterOfferCount": "u32" } } diff --git a/src/Services/Processor/Substrate/Codec/Types/MutateToken.json b/src/Services/Processor/Substrate/Codec/Types/MutateToken.json index 329b4896..5360cff6 100644 --- a/src/Services/Processor/Substrate/Codec/Types/MutateToken.json +++ b/src/Services/Processor/Substrate/Codec/Types/MutateToken.json @@ -8,24 +8,13 @@ "TokenMutation": { "behavior": "BehaviorParamOf", "listingForbidden": "Option", - "metadata": "Option" + "anyoneCanInfuse": "Option", + "name": "Option" }, "BehaviorParamOf": { "_enum": { "NoMutation": "Null", "SomeMutation": "Option" } - }, - "MutateTokenV1010": { - "callIndex": "(u8, u8)", - "collectionId": "Compact", - "tokenId": "Compact", - "mutation": "TokenMutationV1010" - }, - "TokenMutationV1010": { - "behavior": "BehaviorParamOf", - "listingForbidden": "Option", - "anyoneCanInfuse": "Option", - "name": "Option" } } \ No newline at end of file diff --git a/src/Services/Processor/Substrate/Codec/Types/SetAttribute.json b/src/Services/Processor/Substrate/Codec/Types/SetAttribute.json index 9443a2e1..a4b6322a 100644 --- a/src/Services/Processor/Substrate/Codec/Types/SetAttribute.json +++ b/src/Services/Processor/Substrate/Codec/Types/SetAttribute.json @@ -1,12 +1,5 @@ { "SetAttribute": { - "callIndex": "(u8, u8)", - "collectionId": "Compact", - "tokenId": "Option", - "key": "Bytes", - "value": "Bytes" - }, - "SetAttributeV1010": { "callIndex": "(u8, u8)", "collectionId": "Compact", "tokenId": "Option", diff --git a/src/Services/Processor/Substrate/Codec/Types/TokenAccountsStorage.json b/src/Services/Processor/Substrate/Codec/Types/TokenAccountsStorage.json index f34510ab..af57e963 100644 --- a/src/Services/Processor/Substrate/Codec/Types/TokenAccountsStorage.json +++ b/src/Services/Processor/Substrate/Codec/Types/TokenAccountsStorage.json @@ -10,15 +10,6 @@ "accountId": "AccountId" }, "TokenAccountsStorageData": { - "balance": "Compact", - "reservedBalance": "Compact", - "lockedBalance": "Compact", - "namedReserves": "BTreeMap<[u8;8],u128>", - "locks": "BTreeMap<[u8;8],u128>", - "approvals": "BTreeMap", - "isFrozen": "bool" - }, - "TokenAccountsStorageDataV1010": { "balance": "Compact", "reservedBalance": "Compact", "lockedBalance": "Compact", diff --git a/src/Services/Processor/Substrate/Codec/Types/Transfer.json b/src/Services/Processor/Substrate/Codec/Types/Transfer.json index dcdbaa20..cd851cce 100644 --- a/src/Services/Processor/Substrate/Codec/Types/Transfer.json +++ b/src/Services/Processor/Substrate/Codec/Types/Transfer.json @@ -12,34 +12,11 @@ } }, "SimpleTransferParams": { - "tokenId": "Compact", - "amount": "Compact", - "keepAlive": "bool" - }, - "OperatorTransferParams": { - "tokenId": "Compact", - "source": "AccountId", - "amount": "Compact", - "keepAlive": "bool" - }, - "TransferV1010": { - "callIndex": "(u8, u8)", - "recipient": "MultiAddress", - "collectionId": "Compact", - "params": "TransferParamsOfV1010" - }, - "TransferParamsOfV1010": { - "_enum": { - "Simple": "SimpleTransferParamsV1010", - "Operator": "OperatorTransferParamsV1010" - } - }, - "SimpleTransferParamsV1010": { "tokenId": "Compact", "amount": "Compact", "depositor": "Option" }, - "OperatorTransferParamsV1010": { + "OperatorTransferParams": { "tokenId": "Compact", "source": "AccountId", "amount": "Compact", diff --git a/tests/Feature/GraphQL/Mutations/BatchTransferTest.php b/tests/Feature/GraphQL/Mutations/BatchTransferTest.php index 3b00c328..543739d5 100644 --- a/tests/Feature/GraphQL/Mutations/BatchTransferTest.php +++ b/tests/Feature/GraphQL/Mutations/BatchTransferTest.php @@ -400,7 +400,6 @@ public function test_it_can_batch_simple_single_transfer_with_keep_alive(): void 'params' => new SimpleTransferParams( tokenId: $this->tokenIdEncoder->encode(), amount: $amount = fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: $keepAlive = fake()->boolean(), ), ], ] @@ -414,7 +413,6 @@ public function test_it_can_batch_simple_single_transfer_with_keep_alive(): void 'simpleParams' => [ 'tokenId' => $this->tokenIdEncoder->toEncodable(), 'amount' => $amount, - 'keepAlive' => $keepAlive, ], ], ], @@ -447,7 +445,6 @@ public function test_it_can_batch_simple_single_transfer_with_null_keep_alive(): 'params' => new SimpleTransferParams( tokenId: $this->tokenIdEncoder->encode(), amount: $amount = fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: null, ), ], ] @@ -544,7 +541,6 @@ public function test_it_can_batch_operator_single_transfer_with_keep_alive(): vo tokenId: $this->tokenIdEncoder->encode(), source: $source = $this->wallet->public_key, amount: $amount = fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: $keepAlive = fake()->boolean(), ), ], ] @@ -560,7 +556,6 @@ public function test_it_can_batch_operator_single_transfer_with_keep_alive(): vo 'tokenId' => $this->tokenIdEncoder->toEncodable(), 'source' => SS58Address::encode($source), 'amount' => $amount, - 'keepAlive' => $keepAlive, ], ], ], @@ -596,7 +591,6 @@ public function test_it_can_batch_operator_single_transfer_with_null_keep_alive( tokenId: $this->tokenIdEncoder->encode(), source: $source = $this->wallet->public_key, amount: $amount = fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: null, ), ], ] diff --git a/tests/Feature/GraphQL/Mutations/BurnTest.php b/tests/Feature/GraphQL/Mutations/BurnTest.php index 1644a57f..ef6dff1c 100644 --- a/tests/Feature/GraphQL/Mutations/BurnTest.php +++ b/tests/Feature/GraphQL/Mutations/BurnTest.php @@ -363,7 +363,6 @@ public function test_can_burn_a_token_with_keepalive(): void burnParams: new BurnParams( tokenId: $this->tokenIdEncoder->encode(), amount: $amount = fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: $keepAlive = fake()->boolean(), ) ), ); @@ -373,7 +372,6 @@ public function test_can_burn_a_token_with_keepalive(): void 'params' => [ 'tokenId' => $this->tokenIdEncoder->toEncodable(), 'amount' => $amount, - 'keepAlive' => $keepAlive, ], ]); @@ -542,7 +540,6 @@ public function test_can_burn_a_token_with_all_args(): void burnParams: $params = new BurnParams( tokenId: $this->tokenIdEncoder->encode(), amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), removeTokenStorage: fake()->boolean(), ), )); diff --git a/tests/Feature/GraphQL/Mutations/OperatorTransferTokenTest.php b/tests/Feature/GraphQL/Mutations/OperatorTransferTokenTest.php index 7a488770..56cb4756 100644 --- a/tests/Feature/GraphQL/Mutations/OperatorTransferTokenTest.php +++ b/tests/Feature/GraphQL/Mutations/OperatorTransferTokenTest.php @@ -78,7 +78,6 @@ public function test_it_can_skip_validation(): void tokenId: $this->tokenIdEncoder->encode(), source: $this->wallet->public_key, amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -123,7 +122,6 @@ public function test_it_can_transfer_token_using_adapter(): void tokenId: $this->tokenIdEncoder->encode(), source: $this->wallet->public_key, amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -160,7 +158,6 @@ public function test_it_can_simulate(): void tokenId: $this->tokenIdEncoder->encode(), source: $this->wallet->public_key, amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -244,7 +241,6 @@ public function test_it_can_transfer_token(): void tokenId: $this->tokenIdEncoder->encode(), source: $this->wallet->public_key, amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -306,7 +302,6 @@ public function test_it_can_transfer_token_with_ss58_signing_account(): void tokenId: $this->tokenIdEncoder->encode($token->token_chain_id), source: $signingWallet->public_key, amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -367,7 +362,6 @@ public function test_it_can_transfer_token_with_public_key_signing_account(): vo tokenId: $this->tokenIdEncoder->encode($token->token_chain_id), source: $signingWallet->public_key, amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -469,7 +463,6 @@ public function test_it_can_transfer_token_with_signing_wallet(): void tokenId: $this->tokenIdEncoder->encode($token->token_chain_id), source: $signingWallet->public_key, amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -513,7 +506,6 @@ public function test_it_can_transfer_token_with_null_signing_wallet(): void tokenId: $this->tokenIdEncoder->encode(), source: $this->wallet->public_key, amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -553,7 +545,6 @@ public function test_it_can_transfer_token_with_empty_signing_wallet_and_works_a tokenId: $this->tokenIdEncoder->encode(), source: $this->wallet->public_key, amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -595,7 +586,6 @@ public function test_it_can_transfer_token_with_recipient_that_doesnt_exists(): tokenId: $this->tokenIdEncoder->encode(), source: $this->wallet->public_key, amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -657,7 +647,6 @@ public function test_it_can_transfer_token_with_bigint_collection_id(): void tokenId: $this->tokenIdEncoder->encode($token->token_chain_id), source: $this->wallet->public_key, amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -713,7 +702,6 @@ public function test_it_can_transfer_token_with_bigint_token_id(): void tokenId: $this->tokenIdEncoder->encode($token->token_chain_id), source: $this->wallet->public_key, amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); diff --git a/tests/Feature/GraphQL/Mutations/SimpleTransferTokenTest.php b/tests/Feature/GraphQL/Mutations/SimpleTransferTokenTest.php index 5541ac0e..cca07d54 100644 --- a/tests/Feature/GraphQL/Mutations/SimpleTransferTokenTest.php +++ b/tests/Feature/GraphQL/Mutations/SimpleTransferTokenTest.php @@ -86,7 +86,6 @@ public function test_it_can_skip_validation(): void simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode($token->token_chain_id), amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -130,7 +129,6 @@ public function test_it_can_transfer_token_using_adapter(): void simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode(), amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -166,7 +164,6 @@ public function test_it_can_simulate(): void simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode(), amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -240,7 +237,6 @@ public function test_it_can_transfer_token(): void simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode(), amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -336,7 +332,6 @@ public function test_it_can_transfer_token_with_signing_wallet(): void simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode($token->token_chain_id), amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -395,7 +390,6 @@ public function test_it_can_transfer_token_with_public_keysigning_wallet(): void simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode($token->token_chain_id), amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -438,7 +432,6 @@ public function test_it_can_transfer_token_with_null_signing_wallet(): void simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode(), amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -477,7 +470,6 @@ public function test_it_can_transfer_token_with_empty_signing_account_and_works_ simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode(), amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -518,7 +510,6 @@ public function test_it_can_transfer_token_with_recipient_that_doesnt_exists(): simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode(), amount: fake()->numberBetween(1, $this->tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -577,7 +568,6 @@ public function test_it_can_transfer_token_with_bigint_collection_id(): void simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode($token->token_chain_id), amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); @@ -632,7 +622,6 @@ public function test_it_can_transfer_token_with_bigint_token_id(): void simpleTransferParams: $params = new SimpleTransferParams( tokenId: $this->tokenIdInput->encode($token->token_chain_id), amount: fake()->numberBetween(1, $tokenAccount->balance), - keepAlive: fake()->boolean(), ), )); diff --git a/tests/Unit/DecodingTest.php b/tests/Unit/DecodingTest.php index 8e87ed95..799ca508 100644 --- a/tests/Unit/DecodingTest.php +++ b/tests/Unit/DecodingTest.php @@ -104,14 +104,13 @@ public function test_it_can_decode_destroy_collection() public function test_it_can_decode_burn() { - $data = $this->codec->decoder()->burn('0x2804b67a0300fd03040100'); + $data = $this->codec->decoder()->burn('0x2805b67a0300fd030400'); $this->assertEquals( [ 'collectionId' => '57005', 'tokenId' => '255', 'amount' => '1', - 'keepAlive' => true, 'removeTokenStorage' => false, ], $data diff --git a/tests/Unit/EncodingTest.php b/tests/Unit/EncodingTest.php index e9302743..2f720bf7 100644 --- a/tests/Unit/EncodingTest.php +++ b/tests/Unit/EncodingTest.php @@ -267,7 +267,6 @@ public function test_it_can_encode_batch_transfer_simple_transfer() 'params' => new SimpleTransferParams( tokenId: '255', amount: '1', - keepAlive: false, ), ]; @@ -291,7 +290,6 @@ public function test_it_can_encode_batch_transfer_operator_transfer() tokenId: '1', source: '0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d', amount: '1', - keepAlive: false, ), ]; @@ -315,7 +313,6 @@ public function test_it_can_encode_simple_transfer() simpleTransferParams: new SimpleTransferParams( tokenId: '255', amount: '1', - keepAlive: false, ), )); @@ -335,7 +332,6 @@ public function test_it_can_encode_operator_transfer() tokenId: '255', source: 'rf8YmxhSe9WGJZvCH8wtzAndweEmz6dTV6DjmSHgHvPEFNLAJ', amount: '1', - keepAlive: false, ), )); @@ -484,7 +480,7 @@ public function test_it_can_encode_mutate_token() $callIndex = $this->codec->encoder()->getCallIndex('MultiTokens.mutate_token', true); $this->assertEquals( - "0x{$callIndex}b67a0300fd0301000000", + "0x{$callIndex}b67a0300fd030100000000", $data ); } @@ -499,7 +495,7 @@ public function test_it_can_encode_mutate_token_with_empty_behavior() $callIndex = $this->codec->encoder()->getCallIndex('MultiTokens.mutate_token', true); $this->assertEquals( - "0x{$callIndex}b67a0300fd03000000", + "0x{$callIndex}b67a0300fd0300000000", $data ); } @@ -514,7 +510,7 @@ public function test_it_can_encode_mutate_token_with_listing_true() $callIndex = $this->codec->encoder()->getCallIndex('MultiTokens.mutate_token', true); $this->assertEquals( - "0x{$callIndex}b67a0300fd030100010100", + "0x{$callIndex}b67a0300fd03010001010000", $data ); } @@ -529,7 +525,7 @@ public function test_it_can_encode_mutate_token_with_is_currency_true() $callIndex = $this->codec->encoder()->getCallIndex('MultiTokens.mutate_token', true); $this->assertEquals( - "0x{$callIndex}b67a0300fd030101010000", + "0x{$callIndex}b67a0300fd03010101000000", $data ); } @@ -585,14 +581,13 @@ public function test_it_can_encode_burn() burnParams: new BurnParams( tokenId: '57005', amount: 100, - keepAlive: true, removeTokenStorage: true ) )); $callIndex = $this->codec->encoder()->getCallIndex('MultiTokens.burn', true); $this->assertEquals( - "0x{$callIndex}411fb67a030091010101", + "0x{$callIndex}411fb67a0300910101", $data ); } @@ -789,7 +784,7 @@ public function test_it_can_encode_set_attribute_from_token() $callIndex = $this->codec->encoder()->getCallIndex('MultiTokens.set_attribute', true); $this->assertEquals( - "0x{$callIndex}b67a030001ff000000000000000000000000000000106e616d6530476f6c64656e2053776f7264", + "0x{$callIndex}b67a030001ff000000000000000000000000000000106e616d6530476f6c64656e2053776f726400", $data ); }