Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLA-1986] Removes migration support #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

leonardocustodio
Copy link
Member

@leonardocustodio leonardocustodio commented Sep 11, 2024

PR Type

enhancement


Description

  • Reformatted constructors and class definitions across multiple files to use multi-line blocks for better readability and consistency.
  • Simplified the decoding process in Decoder.php by removing exception handling.

Changes walkthrough 📝

Relevant files
Formatting
19 files
StorageKey.php
Reformat constructor for better readability                           

src/Enums/Substrate/StorageKey.php

  • Reformatted constructor to use a multi-line block.
+3/-1     
FuelTank.php
Reformat class definition for consistency                               

src/Models/FuelTank.php

  • Reformatted class to use a multi-line block.
+3/-1     
FuelTankAccount.php
Reformat class definition for consistency                               

src/Models/FuelTankAccount.php

  • Reformatted class to use a multi-line block.
+3/-1     
AccountRulesParams.php
Reformat constructor for better readability                           

src/Models/Substrate/AccountRulesParams.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
DispatchRulesParams.php
Reformat constructor for better readability                           

src/Models/Substrate/DispatchRulesParams.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
MaxFuelBurnPerTransactionParams.php
Reformat constructor for better readability                           

src/Models/Substrate/MaxFuelBurnPerTransactionParams.php

  • Reformatted constructor to use a multi-line block.
+3/-1     
RequireSignatureParams.php
Reformat constructor for better readability                           

src/Models/Substrate/RequireSignatureParams.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
RequireTokenParams.php
Reformat constructor for better readability                           

src/Models/Substrate/RequireTokenParams.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
TankFuelBudgetParams.php
Reformat constructor for better readability                           

src/Models/Substrate/TankFuelBudgetParams.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
UserAccountManagementParams.php
Reformat constructor for better readability                           

src/Models/Substrate/UserAccountManagementParams.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
UserFuelBudgetParams.php
Reformat constructor for better readability                           

src/Models/Substrate/UserFuelBudgetParams.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
WhitelistedCollectionsParams.php
Reformat constructor for better readability                           

src/Models/Substrate/WhitelistedCollectionsParams.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
WhitelistedPalletsParams.php
Reformat constructor for better readability                           

src/Models/Substrate/WhitelistedPalletsParams.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
Wallet.php
Reformat class definition for consistency                               

src/Models/Wallet.php

  • Reformatted class to use a multi-line block.
+3/-1     
AccountsExistsInFuelTank.php
Reformat constructor for better readability                           

src/Rules/AccountsExistsInFuelTank.php

  • Reformatted constructor to use a multi-line block.
+3/-1     
AccountsNotInFuelTank.php
Reformat constructor for better readability                           

src/Rules/AccountsNotInFuelTank.php

  • Reformatted constructor to use a multi-line block.
+3/-1     
TokenExistsInCollection.php
Reformat constructor for better readability                           

src/Rules/TokenExistsInCollection.php

  • Reformatted constructor to use a multi-line block.
+3/-1     
AccountRuleDataRemoved.php
Reformat methods for better readability                                   

src/Services/Processor/Substrate/Events/Implementations/FuelTanks/AccountRuleDataRemoved.php

  • Reformatted methods to use multi-line blocks.
+6/-2     
TransactionService.php
Reformat constructor for better readability                           

src/Services/TransactionService.php

  • Reformatted constructor to use a multi-line block.
+2/-1     
Enhancement
1 files
Decoder.php
Simplify decoding process by removing exception handling 

src/Services/Processor/Substrate/Codec/Decoder.php

  • Removed exception handling for decoding process.
+2/-10   

💡 PR-Agent usage:
Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

@leonardocustodio leonardocustodio self-assigned this Sep 11, 2024
Copy link

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ No key issues to review

Copy link

github-actions bot commented Sep 11, 2024

PR Code Suggestions ✨

CategorySuggestion                                                                                                                                    Score
Possible issue
Add exception handling to the decoding process to improve robustness

Add exception handling for the decoding process to manage potential failures
gracefully.

src/Services/Processor/Substrate/Codec/Decoder.php [31]

-$decoded = $this->codec->process('TankStorageDataV1010', new ScaleBytes($data));
+try {
+    $decoded = $this->codec->process('TankStorageDataV1010', new ScaleBytes($data));
+} catch (\Exception $e) {
+    // Handle exception or fallback to a different decoding strategy
+    $decoded = [];
+}
 
Suggestion importance[1-10]: 9

Why: The suggestion to add exception handling is crucial for robustness, as it addresses potential failures in the decoding process which were removed in the PR.

9
Security
Validate or sanitize constructor parameters to enhance security and stability

Ensure that the constructor parameters are validated or sanitized to prevent
potential security risks or bugs.

src/Enums/Substrate/StorageKey.php [9]

-public function __construct(public StorageType $type, public string $value)
+public function __construct(public StorageType $type, public string $value) {
+    // Validate or sanitize input parameters
+    $this->type = $type; // Assuming StorageType is an enum or similar
+    $this->value = filter_var($value, FILTER_SANITIZE_STRING);
+}
 
Suggestion importance[1-10]: 7

Why: The suggestion to validate or sanitize constructor parameters is a good practice for enhancing security and stability, though not critical given the context.

7
Enhancement
Add initialization checks to the constructor to ensure all dependencies are properly provided

Initialize additional components or perform necessary checks inside the constructor
to ensure all dependencies are correctly set up.

src/Services/TransactionService.php [17-19]

 public function __construct(
     public readonly Codec $codec,
     public readonly WalletService $wallet
-)
+) {
+    if (!$codec || !$wallet) {
+        throw new InvalidArgumentException("Codec and WalletService must be provided.");
+    }
+    // Additional initialization or checks can be performed here
+}
 
Suggestion importance[1-10]: 6

Why: Adding checks for constructor dependencies can prevent runtime errors, but the suggestion is more of a precautionary measure rather than addressing an existing issue.

6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

1 participant