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

Update nonce channels to use masks #891

Merged
merged 1 commit into from
Oct 21, 2024
Merged

Update nonce channels to use masks #891

merged 1 commit into from
Oct 21, 2024

Conversation

tarrencev
Copy link
Contributor

@tarrencev tarrencev commented Oct 18, 2024

Summary by CodeRabbit

  • New Features

    • Updated the nonce handling in the OutsideExecution struct to improve data processing.
    • Enhanced methods for validating and retrieving channel nonces, now supporting a wider range of operations with the new nonce type.
    • Introduced new methods for querying ERC20 token properties, including allowance, balance, and total supply.
    • Improved event handling capabilities for ERC20 contracts with new event-related structures.
  • Bug Fixes

    • Adjusted serialization and deserialization logic to ensure compatibility with the updated nonce type.

Copy link

vercel bot commented Oct 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Oct 21, 2024 1:19pm
ui ✅ Ready (Inspect) Visit Preview Oct 21, 2024 1:19pm
ui-next ✅ Ready (Inspect) Visit Preview Oct 21, 2024 1:19pm

Copy link

coderabbitai bot commented Oct 18, 2024

Walkthrough

The pull request introduces modifications to the OutsideExecution struct in the packages/account_sdk/src/abigen/controller.rs file. The nonce field is changed from a tuple of two Felt types to a tuple of a Felt and a u128. Corresponding methods, including get_outside_execution_v3_channel_nonce and is_valid_outside_execution_v3_nonce, are updated to reflect this change in type. Additionally, serialization and deserialization logic for the nonce field is revised to accommodate the new type. The erc_20.rs file is also updated to enhance the ERC20 interface with new methods for querying allowances and balances, along with improved event handling capabilities.

Changes

File Path Change Summary
packages/account_sdk/src/abigen/controller.rs - Updated OutsideExecution struct's nonce field from (Felt, Felt) to (Felt, u128).
- Modified get_outside_execution_v3_channel_nonce method return type to u128.
- Changed is_valid_outside_execution_v3_nonce method signature to accept the new nonce type.
- Adjusted serialization and deserialization methods for the nonce field.
packages/account_sdk/src/abigen/erc_20.rs - Added allowance, balanceOf, balance_of, decimals, name, owner, symbol, totalSupply, and total_supply methods to Erc20 and Erc20Reader structs.
- Introduced new structs and enums for event handling, including Approval, OwnershipTransferStarted, OwnershipTransferred, Transfer, Upgraded, ERC20ComponentEvent, Event, and OwnableComponentEvent.

Possibly related PRs

  • Migrate to channel nonces #854: The changes in this PR involve modifications to the OutsideExecution struct and its methods, specifically updating the nonce field, which directly relates to the changes made in the main PR regarding the nonce field type and method signatures.
  • Session off chain signature contract changes #883: This PR also modifies the Controller and ControllerReader structs, which are relevant to the changes in the main PR that affect method signatures and serialization related to the OutsideExecution struct.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2aaf05b and f648d8e.

⛔ Files ignored due to path filters (14)
  • Cargo.toml is excluded by none and included by none
  • Scarb.toml is excluded by none and included by none
  • packages/account-wasm/src/account.rs is excluded by none and included by none
  • packages/account-wasm/src/session.rs is excluded by none and included by none
  • packages/account_sdk/artifacts/controller.latest.compiled_contract_class.json is excluded by none and included by none
  • packages/account_sdk/artifacts/controller.latest.contract_class.json is excluded by none and included by none
  • packages/account_sdk/cmd/bench.rs is excluded by none and included by none
  • packages/account_sdk/src/account/outside_execution.rs is excluded by none and included by none
  • packages/account_sdk/src/artifacts.rs is excluded by none and included by none
  • packages/account_sdk/src/controller.rs is excluded by none and included by none
  • packages/account_sdk/src/execute_from_outside.rs is excluded by none and included by none
  • packages/account_sdk/src/execute_from_outside_test.rs is excluded by none and included by none
  • packages/account_sdk/src/tests/runners/test_data/session_execute_outside.json is excluded by none and included by none
  • packages/account_sdk/src/tests/runners/test_data/webauthn_execute_outside.json is excluded by none and included by none
📒 Files selected for processing (2)
  • packages/account_sdk/src/abigen/controller.rs (10 hunks)
  • packages/account_sdk/src/abigen/erc_20.rs (1 hunks)
🧰 Additional context used
🔇 Additional comments (8)
packages/account_sdk/src/abigen/erc_20.rs (1)

5-7: Changes Approved

No issues found with the updated code segment.

packages/account_sdk/src/abigen/controller.rs (7)

233-237: Update to nonce field in OutsideExecution is correctly implemented.

The nonce field in the OutsideExecution struct has been updated to (starknet::core::types::Felt, u128), and the associated serde attributes are appropriately specified, ensuring correct serialization and deserialization.


Line range hint 257-270: Serialization methods updated to handle new nonce type.

The cairo_serialized_size, cairo_serialize, and cairo_deserialize methods for OutsideExecution have been correctly updated to accommodate the new nonce type, ensuring data integrity during serialization processes.


Line range hint 2279-2284: Method return type updated in get_outside_execution_v3_channel_nonce.

The return type of get_outside_execution_v3_channel_nonce has been updated to u128, aligning with the new nonce field type. This ensures consistency across method signatures and data handling.


2384-2390: Parameter type and serialization updated in is_valid_outside_execution_v3_nonce.

The nonce parameter has been updated to (starknet::core::types::Felt, u128), and serialization logic has been correctly adjusted to handle the new tuple structure.


429-432: Serialization attributes added to expires_at in Session struct.

The serde attributes for serialize_with and deserialize_with have been correctly added to the expires_at field, ensuring proper serialization and deserialization of this field.


Line range hint 2928-2933: Method return type updated in get_outside_execution_v3_channel_nonce of ControllerReader.

The return type of get_outside_execution_v3_channel_nonce in ControllerReader has been updated to u128, matching the changes in the OutsideExecution struct.


3033-3039: Parameter type and serialization updated in is_valid_outside_execution_v3_nonce of ControllerReader.

The nonce parameter has been updated to (starknet::core::types::Felt, u128), and the serialization logic is correctly adjusted, ensuring consistency and correctness in data handling.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 3728d5a and 62141de.

⛔ Files ignored due to path filters (13)
  • Scarb.toml is excluded by none and included by none
  • packages/account-wasm/src/account.rs is excluded by none and included by none
  • packages/account-wasm/src/session.rs is excluded by none and included by none
  • packages/account_sdk/artifacts/controller.latest.compiled_contract_class.json is excluded by none and included by none
  • packages/account_sdk/artifacts/controller.latest.contract_class.json is excluded by none and included by none
  • packages/account_sdk/cmd/bench.rs is excluded by none and included by none
  • packages/account_sdk/src/account/outside_execution.rs is excluded by none and included by none
  • packages/account_sdk/src/artifacts.rs is excluded by none and included by none
  • packages/account_sdk/src/controller.rs is excluded by none and included by none
  • packages/account_sdk/src/execute_from_outside.rs is excluded by none and included by none
  • packages/account_sdk/src/execute_from_outside_test.rs is excluded by none and included by none
  • packages/account_sdk/src/tests/runners/test_data/session_execute_outside.json is excluded by none and included by none
  • packages/account_sdk/src/tests/runners/test_data/webauthn_execute_outside.json is excluded by none and included by none
📒 Files selected for processing (1)
  • packages/account_sdk/src/abigen/controller.rs (8 hunks)
🧰 Additional context used
🔇 Additional comments (8)
packages/account_sdk/src/abigen/controller.rs (8)

242-242: Update serialization size calculation for nonce

The serialization size calculation now correctly uses the new type <(starknet::core::types::Felt, u128)>. This ensures proper serialization of the updated nonce field.


253-255: Ensure correct serialization of the updated nonce field

The serialization logic for nonce has been updated to use <(starknet::core::types::Felt, u128)>::cairo_serialize(&__rust.nonce). This change correctly handles the new tuple structure of the nonce field.


268-269: Update deserialization logic for the new nonce type

The deserialization process now uses the updated type <(starknet::core::types::Felt, u128)> to correctly deserialize the nonce field.


2260-2260: Update return type of get_outside_execution_v3_channel_nonce to u128

The return type of get_outside_execution_v3_channel_nonce has been updated from Felt to u128. This reflects the change in the nonce type and ensures consistent handling of the nonce as a u128 value.


2365-2371: Update is_valid_outside_execution_v3_nonce to accept the new nonce type

The method is_valid_outside_execution_v3_nonce now accepts a nonce parameter of type &(starknet::core::types::Felt, u128). The serialization of the nonce parameter has been updated accordingly.


2909-2909: Update return type of get_outside_execution_v3_channel_nonce in ControllerReader to u128

The return type has been updated to u128 to match the changes in the nonce type.


3014-3020: Update is_valid_outside_execution_v3_nonce in ControllerReader to accept the new nonce type

The method now accepts the nonce parameter as a &(starknet::core::types::Felt, u128), and the serialization logic has been updated to reflect this change.


Line range hint 230-269: Verify correct serialization and deserialization of u128 in nonce

The nonce field now includes a u128 type. Ensure that the cairo_serialize and cairo_deserialize implementations correctly handle the u128 value, considering any endianness or size considerations that may affect serialization between Rust and Cairo types.

To automate the verification, you can run the following script:

@@ -227,7 +227,7 @@ impl cainome::cairo_serde::CairoSerde for ExternalOwnerRemoved {
#[derive(Clone, serde::Serialize, serde::Deserialize, PartialEq, Debug)]
pub struct OutsideExecution {
pub caller: cainome::cairo_serde::ContractAddress,
pub nonce: (starknet::core::types::Felt, starknet::core::types::Felt),
pub nonce: (starknet::core::types::Felt, u128),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Consider the impact of changing nonce type on backward compatibility

Changing the nonce field from (Felt, Felt) to (Felt, u128) may affect clients or systems that rely on the previous structure. Ensure that this change is compatible with existing data and consider providing migration paths or versioning to handle this update smoothly.


💡 Codebase verification

Nonce Field Usage Requires Updates to Handle Tuple Structure

  • In packages/account_sdk/src/controller.rs:
    • Line 176: .nonce(Felt::from(u64::MAX)) should be updated to assign both elements of the tuple.
    • Line 237: .nonce(nonce) should ensure nonce is a tuple.
    • Lines 245, 278, 294, 351: Operations like self.nonce += Felt::ONE; and assignments need to handle both elements of the tuple.
🔗 Analysis chain

Update the nonce field type to reflect the new tuple structure

The nonce field in the OutsideExecution struct has been updated to a tuple of (starknet::core::types::Felt, u128). Ensure that all references and usages of this field throughout the codebase correctly handle this new type.

To verify that all instances have been updated correctly, you can run the following script:


Run additional verification scripts to locate all nonce field accesses in OutsideExecution.


Run updated verification scripts targeting the correct directory.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for all usages of 'OutsideExecution' and verify 'nonce' field access.

# Find all Rust files that contain 'OutsideExecution'.
fd --extension rs 'OutsideExecution'

# Search for 'nonce' field access in 'OutsideExecution' usages.
rg --type rust 'OutsideExecution.*\.nonce'

Length of output: 81


Script:

#!/bin/bash
# Description: Use ast-grep to find all accesses to the 'nonce' field in 'OutsideExecution' struct.

ast-grep --lang rust --pattern 'OutsideExecution { $$$, nonce: $_, $$$ }' src/**/*.rs

ast-grep --lang rust --pattern '$_ = OutsideExecution.nonce'

Length of output: 211


Script:

#!/bin/bash
# Description: Use ast-grep to find all accesses to the 'nonce' field in 'OutsideExecution' struct within packages/account_sdk.

# Search for struct definitions with the updated 'nonce' field.
ast-grep --lang rust --pattern 'OutsideExecution { $$$, nonce: $_, $$$ }' packages/account_sdk/**/*.rs

# Search for all accesses to the 'nonce' field in 'OutsideExecution'.
ast-grep --lang rust --pattern '$_.nonce' packages/account_sdk/**/*.rs

Length of output: 3706

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (7)
packages/account_sdk/src/abigen/erc_20.rs (7)

Line range hint 145-153: Ensure Consistent Method Naming Convention

The methods balanceOf and balance_of are both defined in Erc20 and Erc20Reader. Having duplicate methods with different naming conventions can cause confusion. Rust naming conventions prefer snake_case for function and method names.

Consider consolidating to a single method using snake_case:

-    pub fn balanceOf(&self, account: &cainome::cairo_serde::ContractAddress) -> ...
+    pub fn balance_of(&self, account: &cainome::cairo_serde::ContractAddress) -> ...

And update any references accordingly.

Also applies to: 246-254


Line range hint 160-168: Unify Method Naming for totalSupply

Both totalSupply and total_supply methods are implemented. This duplication with differing naming styles can lead to errors. Stick to snake_case to align with Rust conventions.

Update the method to use snake_case consistently:

-    pub fn totalSupply(&self) -> ...
+    pub fn total_supply(&self) -> ...

And adjust all calls to this method.

Also applies to: 260-268


Line range hint 181-192: Standardize Method Names for Transfer Functions

Methods transferFrom and transfer_from are both present. Consistent naming enhances readability and prevents mistakes. Prefer snake_case in method names.

Modify the method name to follow snake_case:

-    pub fn transferFrom(&self, ...) -> ...
+    pub fn transfer_from(&self, ...) -> ...

Ensure all invocations are updated to match the new name.

Also applies to: 281-292


Line range hint 195-206: Consistent Naming for Ownership Transfer Methods

The methods transferOwnership and transfer_ownership are both defined. To maintain clarity, use a single naming style.

Adopt snake_case for method names:

-    pub fn transferOwnership(&self, newOwner: &cainome::cairo_serde::ContractAddress) -> ...
+    pub fn transfer_ownership(&self, new_owner: &cainome::cairo_serde::ContractAddress) -> ...

Update parameter names and usages accordingly.

Also applies to: 295-306


Line range hint 225-232: Handle Potential Enum Deserialization Errors Gracefully

In the try_from implementation for ERC20ComponentEvent, the panic messages use unwrap_or_else with panic!, which can cause the entire program to exit on failure.

Consider handling errors without panicking, returning an appropriate Result::Err instead:

-    .unwrap_or_else(|_| panic!("Invalid selector for {}", "Transfer"))
+    .map_err(|_| format!("Invalid selector for {}", "Transfer"))?

Apply similar changes to other event parsing sections to improve robustness.


Line range hint 320-330: Consider Using Constants for Selectors

Magic strings like "transfer" and "approve" are used directly in selectors. This can lead to typos and makes updates harder.

Define constants for these selectors to improve maintainability:

const TRANSFER_SELECTOR: &str = "transfer";
const APPROVE_SELECTOR: &str = "approve";

Use these constants in your code:

-    selector: starknet::macros::selector!("transfer"),
+    selector: starknet::macros::selector!(TRANSFER_SELECTOR),

Line range hint 145-306: Remove Unused Duplicate Methods

Having methods like balanceOf and balance_of may not be necessary if they perform the same functionality. This applies to other similarly duplicated methods.

Retain only one version of each method to reduce redundancy and potential confusion.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9edf87e and 0291158.

⛔ Files ignored due to path filters (14)
  • Cargo.toml is excluded by none and included by none
  • Scarb.toml is excluded by none and included by none
  • packages/account-wasm/src/account.rs is excluded by none and included by none
  • packages/account-wasm/src/session.rs is excluded by none and included by none
  • packages/account_sdk/artifacts/controller.latest.compiled_contract_class.json is excluded by none and included by none
  • packages/account_sdk/artifacts/controller.latest.contract_class.json is excluded by none and included by none
  • packages/account_sdk/cmd/bench.rs is excluded by none and included by none
  • packages/account_sdk/src/account/outside_execution.rs is excluded by none and included by none
  • packages/account_sdk/src/artifacts.rs is excluded by none and included by none
  • packages/account_sdk/src/controller.rs is excluded by none and included by none
  • packages/account_sdk/src/execute_from_outside.rs is excluded by none and included by none
  • packages/account_sdk/src/execute_from_outside_test.rs is excluded by none and included by none
  • packages/account_sdk/src/tests/runners/test_data/session_execute_outside.json is excluded by none and included by none
  • packages/account_sdk/src/tests/runners/test_data/webauthn_execute_outside.json is excluded by none and included by none
📒 Files selected for processing (2)
  • packages/account_sdk/src/abigen/controller.rs (10 hunks)
  • packages/account_sdk/src/abigen/erc_20.rs (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
packages/account_sdk/src/abigen/erc_20.rs (1)

5-7: ⚠️ Potential issue

Duplicate Allow Attributes

The #![allow(clippy::all)] and #![allow(warnings)] attributes are specified twice at the top of the file.

Ensure that attributes are not duplicated to keep the code clean.

Comment on lines +5 to +7
#![allow(clippy::all)]
#![allow(warnings)]

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid Suppressing All Clippy Lints and Warnings

Adding #![allow(clippy::all)] and #![allow(warnings)] suppresses all Clippy lints and compiler warnings for the entire module. This can hide potential issues and decrease code quality. It's better to address warnings individually or allow specific lints when necessary.

Consider removing these directives or refining them to target specific warnings:

-#![allow(clippy::all)]
-#![allow(warnings)]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#![allow(clippy::all)]
#![allow(warnings)]

pub nonce: (starknet::core::types::Felt, starknet::core::types::Felt),
#[serde(serialize_with = "cainome::cairo_serde::serialize_as_hex_t2")]
pub nonce: (starknet::core::types::Felt, u128),
#[serde(serialize_with = "cainome::cairo_serde::serialize_as_hex")]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the placement of the serde attribute

The #[serde(serialize_with = "cainome::cairo_serde::serialize_as_hex")] attribute on line 235 should be placed immediately before the field it annotates (execute_after). Currently, it's placed after the nonce field, which can lead to incorrect serialization behavior.

Apply this diff to correct the attribute placement:

 pub nonce: (starknet::core::types::Felt, u128),
-#[serde(serialize_with = "cainome::cairo_serde::serialize_as_hex")]
 pub execute_after: u64,
+#[serde(serialize_with = "cainome::cairo_serde::serialize_as_hex")]

Committable suggestion was skipped due to low confidence.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
packages/account_sdk/src/abigen/erc_20.rs (2)

Line range hint 115-148: Inconsistent method naming conventions in Erc20<A> struct

The methods balanceOf and totalSupply are using camelCase, whereas Rust conventionally uses snake_case for function and method names. Additionally, you have both balanceOf and balance_of, as well as totalSupply and total_supply, which can lead to confusion and redundancy.

Please consider renaming balanceOf to balance_of and totalSupply to total_supply, and remove any duplicate methods to adhere to Rust's naming conventions and improve code clarity.


Line range hint 285-318: Inconsistent method naming conventions in Erc20Reader<P> struct

Similar to the Erc20<A> struct, the Erc20Reader<P> struct contains methods balanceOf and totalSupply that do not follow Rust's snake_case naming convention. There are also duplicate methods with both camelCase and snake_case names.

Please standardize the method names to use snake_case and eliminate duplicates to maintain consistency and improve readability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0291158 and 2aaf05b.

⛔ Files ignored due to path filters (14)
  • Cargo.toml is excluded by none and included by none
  • Scarb.toml is excluded by none and included by none
  • packages/account-wasm/src/account.rs is excluded by none and included by none
  • packages/account-wasm/src/session.rs is excluded by none and included by none
  • packages/account_sdk/artifacts/controller.latest.compiled_contract_class.json is excluded by none and included by none
  • packages/account_sdk/artifacts/controller.latest.contract_class.json is excluded by none and included by none
  • packages/account_sdk/cmd/bench.rs is excluded by none and included by none
  • packages/account_sdk/src/account/outside_execution.rs is excluded by none and included by none
  • packages/account_sdk/src/artifacts.rs is excluded by none and included by none
  • packages/account_sdk/src/controller.rs is excluded by none and included by none
  • packages/account_sdk/src/execute_from_outside.rs is excluded by none and included by none
  • packages/account_sdk/src/execute_from_outside_test.rs is excluded by none and included by none
  • packages/account_sdk/src/tests/runners/test_data/session_execute_outside.json is excluded by none and included by none
  • packages/account_sdk/src/tests/runners/test_data/webauthn_execute_outside.json is excluded by none and included by none
📒 Files selected for processing (2)
  • packages/account_sdk/src/abigen/controller.rs (10 hunks)
  • packages/account_sdk/src/abigen/erc_20.rs (1 hunks)
🧰 Additional context used
🔇 Additional comments (4)
packages/account_sdk/src/abigen/controller.rs (3)

Line range hint 1-3067: Summary of changes and potential impact

This update primarily focuses on changing the nonce field in the OutsideExecution struct from (Felt, Felt) to (Felt, u128). This change has cascading effects throughout the file, including:

  1. Updated serialization and deserialization logic for the nonce field.
  2. Modified method signatures and return types for nonce-related functions.
  3. Potential impacts on nonce generation, processing, and storage throughout the system.

While the changes appear consistent within this file, it's crucial to ensure that:

  1. All parts of the system interacting with nonces have been updated to handle the new type.
  2. Backward compatibility has been considered, especially for stored data or external integrations.
  3. Performance implications of the type change have been evaluated.

Additionally, the global disabling of Clippy lints and warnings should be reconsidered to maintain code quality.

To ensure a smooth transition, consider running integration tests and reviewing any external systems or contracts that interact with this code.


2267-2267: Verify callers of updated nonce-related methods

The following methods have been updated to use u128 instead of Felt for the nonce:

  • get_outside_execution_v3_channel_nonce
  • is_valid_outside_execution_v3_nonce

Ensure that all callers of these methods have been updated to handle the new u128 type correctly. This change might affect:

  1. How nonce values are generated and processed
  2. Any arithmetic or comparison operations performed on nonce values
  3. Storage and retrieval of nonce values

To verify the impact of this change, run the following script:

#!/bin/bash
# Description: Find all calls to the updated nonce-related methods

echo "Calls to get_outside_execution_v3_channel_nonce:"
rg -p 'get_outside_execution_v3_channel_nonce' packages/account_sdk/src

echo "\nCalls to is_valid_outside_execution_v3_nonce:"
rg -p 'is_valid_outside_execution_v3_nonce' packages/account_sdk/src

Also applies to: 2372-2378, 2916-2916, 3021-3027


233-235: ⚠️ Potential issue

Verify all usages of the nonce field after type change

The nonce field in the OutsideExecution struct has been changed from (Felt, Felt) to (Felt, u128). This change may have significant implications:

  1. Backward Compatibility: Ensure this change doesn't break existing functionality or stored data.
  2. Performance: Verify if this change affects performance, especially in serialization/deserialization.
  3. Usage: Check all places where nonce is used to ensure they're updated to handle the new type correctly.

To verify the impact of this change, run the following script:

✅ Verification successful

All usages of the nonce field have been successfully updated to the new type (Felt, u128). No instances of the old type (Felt, Felt) were found, ensuring consistency and preventing potential type mismatches.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of the OutsideExecution struct and its nonce field

# Search for OutsideExecution struct usage
echo "OutsideExecution struct usage:"
rg -p 'OutsideExecution' packages/account_sdk/src

# Search for nonce field access
echo "\nNonce field access:"
rg -p 'OutsideExecution.*\.nonce' packages/account_sdk/src

Length of output: 1009


Script:

#!/bin/bash
# Description: Refined search for usages of the OutsideExecution struct and its nonce field

# Search for OutsideExecution struct definitions
echo "Searching for OutsideExecution struct definitions:"
rg 'struct\s+OutsideExecution' packages/account_sdk/src

# Search for nonce field within OutsideExecution
echo "\nSearching for nonce field within OutsideExecution:"
rg 'nonce\s*:' packages/account_sdk/src

Length of output: 1600


Script:

#!/bin/bash
# Description: Identify usages of the nonce field with the old type (Felt, Felt)

# Search for nonce field initialized or defined with (Felt, Felt)
echo "Searching for nonce field with type (Felt, Felt):"
rg 'nonce\s*:\s*\(starknet::core::types::Felt,\s*starknet::core::types::Felt\)' packages/account_sdk/src

# Search for nonce field assignments with (Felt, Felt)
echo "\nSearching for nonce assignments with (Felt, Felt):"
rg 'nonce\s*=\s*\(.*starknet::core::types::Felt,.*starknet::core::types::Felt\)' packages/account_sdk/src

# Search for function signatures using nonce with the old type
echo "\nSearching for function signatures using nonce with type (Felt, Felt):"
rg 'fn\s+\w+\s*\(.*nonce\s*:\s*\(starknet::core::types::Felt,\s*starknet::core::types::Felt\).*?\)' packages/account_sdk/src

Length of output: 718

packages/account_sdk/src/abigen/erc_20.rs (1)

5-6: Previous comment about suppressing Clippy lints still applies

The use of #![allow(clippy::all)] and #![allow(warnings)] suppresses all Clippy lints and compiler warnings for the entire module. This can hide potential issues and decrease code quality. Please consider addressing warnings individually or allowing specific lints as necessary.

Comment on lines +5 to +6
#![allow(clippy::all)]
#![allow(warnings)]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Reconsider globally disabling all Clippy lints and warnings

Disabling all Clippy lints and warnings can mask potential issues and reduce code quality. It's recommended to:

  1. Address specific warnings individually.
  2. If necessary, disable only specific lints that are not applicable to this auto-generated code.
  3. Consider using #[allow(...)] attributes on specific items rather than the entire file.

This approach will help maintain code quality and catch potential issues early.

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

Successfully merging this pull request may close these issues.

1 participant