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

chore: spellchecker #166

Merged
merged 3 commits into from
Nov 15, 2024
Merged

chore: spellchecker #166

merged 3 commits into from
Nov 15, 2024

Conversation

Vritra4
Copy link
Contributor

@Vritra4 Vritra4 commented Nov 14, 2024

Description

add a workflow for spellchecking and fix typos with this
due to typos in contracts, some of precompiled binaries are also updated.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

  • Documentation
    • Enhanced clarity and corrected typographical errors in various module documents, including README.md, coin.md, collection.md, dex.md, dispatchable_fungible_asset.md, ed25519.md, fungible_asset.md, math128.md, math64.md, nft.md, object.md, primary_fungible_store.md, property_map.md, and stableswap.md.
    • Updated comments in the code to correct spelling errors and improve readability.
  • Bug Fixes
    • Corrected comments and descriptions in several functions and modules to ensure accurate documentation.
  • New Features
    • Introduced constants for error handling in the fungible_asset module.

@Vritra4 Vritra4 requested review from ALPAC-4 and beer-1 November 14, 2024 09:56
@Vritra4 Vritra4 requested a review from a team as a code owner November 14, 2024 09:56
Copy link

coderabbitai bot commented Nov 14, 2024

Walkthrough

This pull request introduces several changes focused on improving documentation and correcting typographical errors across various modules in the codebase. Key modifications include updates to the .codespellignore file to exclude specific terms from spell checking and the addition of a new GitHub Actions workflow for automating spell checking during pull requests. The changes also encompass minor corrections in comments and documentation throughout multiple modules, ensuring clarity and consistency without altering any underlying functionality.

Changes

File Path Change Summary
.github/config/.codespellignore Added entries: initia, minitia, expRes, crate, Hel, ser to ignore during spell checking.
.github/workflows/spellcheck.yml Introduced a new GitHub Actions workflow for automated spell checking on pull requests.
api/memory_test.go Corrected comment: "assumtions" to "assumptions" in TestCreateAndDestroyUnmanagedVector.
api/mocks.go Corrected comments in methods of the Lookup type from "panicing" to "panicking".
crates/compiler/src/clean.rs Corrected comment: "pakcage path" to "package path" in validate_manifest.
crates/gas/src/lib.rs Corrected comment: "upgrate" to "upgrade".
crates/gas/src/meter.rs Corrected comment: "calculations" to "calculations."
crates/json/src/json_to_move.rs Enhanced error handling and validation logic in deserialize_json_args and convert_json_value_to_move_value.
crates/json/src/json_to_value.rs Improved error handling and validation in deserialize_json_to_value and convert_json_value_to_value.
crates/natives/src/function_info.rs Corrected comment: "Identifer" to "Identifier".
crates/natives/src/move_stdlib/bcs.rs Updated comment for clarity in native_serialized_size.
crates/types/src/compiler.rs Updated comment for references_file field in CompilerDocgenOptions from "fpr" to "for".
precompile/modules/initia_stdlib/doc/coin.md Corrected "metadat" to "metadata" in function descriptions.
precompile/modules/initia_stdlib/doc/collection.md Enhanced documentation clarity and corrected minor errors.
precompile/modules/initia_stdlib/doc/dex.md Updated function descriptions and corrected minor errors.
precompile/modules/initia_stdlib/doc/dispatchable_fungible_asset.md Clarified functionality and corrected "transferred".
precompile/modules/initia_stdlib/doc/ed25519.md Corrected comment: "Contructs" to "Constructs".
precompile/modules/initia_stdlib/doc/fungible_asset.md Corrected "Retrun" to "Return" in function description.
precompile/modules/initia_stdlib/doc/math128.md Updated comments for clarity and corrected "treshold" to "threshold".
precompile/modules/initia_stdlib/doc/math64.md Corrected "treshold" to "threshold" and improved error handling in ceil_div.
precompile/modules/initia_stdlib/doc/nft.md Corrected "descritpion" to "description" in MutatorRef.
precompile/modules/initia_stdlib/doc/object.md Enhanced clarity in object model documentation.
precompile/modules/minitia_stdlib/README.md Corrected "Standar" to "Standard" and "stardarads" to "standards".
precompile/modules/minitia_stdlib/doc/primary_fungible_store.md Minor corrections in documentation for clarity.
precompile/modules/minitia_stdlib/doc/property_map.md Corrected "hanlde" to "handle" in documentation.
precompile/modules/minitia_stdlib/sources/coin.move Updated comments to correct "metadat" to "metadata".
precompile/modules/minitia_stdlib/sources/crypto/ed25519.move Corrected comment: "Contructs" to "Constructs".
precompile/modules/minitia_stdlib/sources/dex.move Corrected comments: "Signle" to "Single" and "resonable" to "reasonable".
precompile/modules/minitia_stdlib/sources/fa/dispatchable_fungible_asset.move Corrected "transfered" to "transferred" and "guranteed" to "guaranteed".
precompile/modules/minitia_stdlib/sources/fa/fungible_asset.move Corrected "Retrun" to "Return".
precompile/modules/minitia_stdlib/sources/fa/primary_fungible_store.move Corrected "receipient" to "recipient".
precompile/modules/minitia_stdlib/sources/fixed_point64.move Renamed parameter precission to precision in assert_approx_the_same.
precompile/modules/minitia_stdlib/sources/math128.move Corrected "precission" to "precision" and improved error handling in ceil_div.
precompile/modules/minitia_stdlib/sources/math64.move Corrected "precission" to "precision" in assert_approx_the_same.
precompile/modules/minitia_stdlib/sources/multisig.move Corrected "errros" to "errors" and "voting preiod" to "voting period".
precompile/modules/minitia_stdlib/sources/object.move Corrected "infinte" to "infinite" in MAXIMUM_OBJECT_NESTING.
precompile/modules/minitia_stdlib/sources/token/collection.move Corrected "seach" to "search" and updated variable name receipient to recipient.
precompile/modules/minitia_stdlib/sources/token/nft.move Corrected "descritpion" to "description" in MutatorRef.
precompile/modules/minitia_stdlib/sources/token/property_map.move Corrected "hanlde" to "handle" in documentation.
precompile/modules/move_nursery/doc/compare.md Corrected "comparion" to "comparison" in documentation.
precompile/modules/move_nursery/sources/compare.move Corrected "comparion" to "comparison" in cmp_bcs_bytes.
precompile/modules/move_stdlib/sources/signer.move Corrected "arround" to "around" in comments.

Possibly related PRs

Suggested reviewers

  • beer-1

"In code we hop, with changes bright,
Spelling fixed, we bring to light.
From metadat to metadata clear,
Our documentation now brings cheer!
With workflows set to check the spell,
In the land of code, all is well!" 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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: 3

🧹 Outside diff range and nitpick comments (34)
.github/workflows/spellcheck.yml (3)

3-5: Enhance workflow trigger configuration

Consider specifying event types and paths to make the workflow more efficient:

 on:
   pull_request:
+    types: [opened, synchronize, reopened]
+    paths:
+      - '**/*.md'
+      - '**/*.txt'
+      - '**/*.rs'
+      - '**/*.py'
+      - '**/*.js'
+      - '**/*.ts'
+      - '**/*.yaml'
+      - '**/*.yml'

17-28: Enhance PR creation configuration

The PR creation step could be improved with additional metadata and better documentation:

       - uses: peter-evans/create-pull-request@v7.0.5
         if: github.event_name != 'pull_request'
         with:
           token: ${{ secrets.GITHUB_TOKEN }}
           commit-message: "chore: fix typos"
           title: "chore: fix typos"
           branch: "chore/fix-typos"
           delete-branch: true
+          labels: |
+            typo
+            automated
+          assignees: ${{ github.actor }}
           body: |
             This PR fixes typos in the codebase.
-            Please review it, and merge if everything is fine.
-            If there are proto changes, run `make proto-gen` and commit the changes.
+            ## Changes Made
+            This PR was automatically generated to fix spelling errors found by codespell.
+            
+            ## Review Instructions
+            1. Please review the changes carefully
+            2. If proto files were modified, run `make proto-gen`
+            3. Verify no code logic was accidentally modified
+            
+            ## Verification
+            - [ ] Changes only affect comments and strings
+            - [ ] No code logic was modified
+            - [ ] Proto files are in sync (if applicable)

13-13: Improve error handling and reporting

Using continue-on-error: true without proper error reporting could hide important issues.

Consider:

  1. Adding a step to save spell check results as artifacts
  2. Creating a comment on the PR with the results
  3. Using a custom action to parse and report errors in a more structured way
precompile/modules/minitia_stdlib/sources/math64.move (1)

277-283: LGTM! Parameter rename with documentation suggestion.

The parameter rename from "precission" to "precision" improves consistency. Consider adding a brief doc comment explaining the precision parameter's role (e.g., number of significant digits to compare).

    #[test_only]
    /// For functions that approximate a value it's useful to test a value is close
    /// to the most correct value up to last digit
+   /// @param precision: number of significant digits to compare
    fun assert_approx_the_same(x: u128, y: u128, precision: u64) {
precompile/modules/initia_stdlib/doc/dispatchable_fungible_asset.md (1)

288-288: Add missing article in documentation

The sentence should include an article before "asset". Consider:

-The recipient is guaranteed to receive asset greater than the expected amount.
+The recipient is guaranteed to receive an asset greater than the expected amount.

or

-The recipient is guaranteed to receive asset greater than the expected amount.
+The recipient is guaranteed to receive assets greater than the expected amount.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~288-~288: Possible missing article found.
Context: ... The recipient is guaranteed to receive asset greater than the expected amount. Note:...

(AI_HYDRA_LEO_MISSING_AN)

precompile/modules/minitia_stdlib/doc/dispatchable_fungible_asset.md (1)

288-288: Improve grammar and clarity in the documentation.

The sentence should be revised for better grammar and clarity.

-The recipient is guaranteed to receive asset greater than the expected amount.
+The recipient is guaranteed to receive assets greater than or equal to the expected amount.
crates/json/src/json_to_value.rs (1)

454-454: LGTM! Consider enhancing the test case description.

The comment correction accurately describes the test case. Consider adding more context about what makes the address invalid (i.e., non-hexadecimal characters 'gg').

-        // invalid inner address
+        // invalid inner address (non-hexadecimal characters)
precompile/modules/minitia_stdlib/doc/nft.md (1)

129-129: Enhance the MutatorRef struct documentation.

Consider expanding the documentation to provide more details about:

  • Which fields can be mutated using this reference
  • Security implications of mutation capabilities
  • Best practices for handling MutatorRef

Apply this diff to improve the documentation:

-This enables mutating description and URI by higher level services.
+This reference enables controlled mutation of specific NFT fields (description and URI) by higher level services. The separation of mutation capabilities helps maintain security by restricting which services can modify NFT metadata. Handle with care as it provides persistent mutation access.
precompile/modules/minitia_stdlib/doc/coin.md (2)

478-478: Enhance function documentation with parameter and return value descriptions.

The function descriptions for mint, mint_to, and burn could be more comprehensive. Consider adding:

  • Parameter descriptions
  • Return value descriptions
  • Usage examples

Example enhancement for mint:

-Mint FAs as the owner of metadata object.
+Mint fungible assets as the owner of metadata object.
+
+Parameters:
+- mint_cap: The capability required to mint new assets
+- amount: The amount of assets to mint
+
+Returns:
+- A new fungible asset of the specified amount
+
+Example:
+```move
+let mint_cap = /* ... */;
+let coins = coin::mint(&mint_cap, 100);
+```

Also applies to: 509-509, 542-542


Line range hint 12-24: Revise discount calculation logic to prevent negative customer benefit.

The current implementation has a critical flaw where adding a flat $20 fee after applying the discount can result in a higher final bill than without a discount, especially for small purchase amounts.

Example:

  • Purchase amount: $100
  • 10% discount (3-4 years loyalty): -$10
  • Flat fee: +$20
  • Final amount: $110 (higher than original $100)

Consider these alternatives:

  1. Apply the flat fee before the discount
  2. Scale the fee based on the purchase amount
  3. Remove the fee for smaller purchase amounts

Here's an example implementation of option 1:

-    discounted_amount = amount - (amount * discount)
-    if discount > 0:
-      final_amount = discounted_amount + 20
-    else:
-      final_amount = discounted_amount
+    base_amount = amount + (discount > 0 ? 20 : 0)
+    final_amount = base_amount - (base_amount * discount)
precompile/modules/initia_stdlib/doc/collection.md (3)

875-876: Fix typo in function documentation.

The word "seach" should be "search" in the nfts function documentation.

-if `start_after` is not none, seach nfts in range (start_after, ...]
+if `start_after` is not none, search nfts in range (start_after, ...]

Line range hint 892-902: Clarify table iterator direction parameter.

The table iterator direction is set to 2 which is a magic number. Consider using a named constant to improve code readability and maintainability.

    let nfts_iter = table::iter(
        &collection.nfts,
        option::none(),
        start_after,
-        2
+        ASCENDING // or appropriate constant name
    );

Line range hint 242-242: Document URI length limit rationale.

Consider adding a comment explaining why 512 bytes was chosen as the maximum URI length. This helps future maintainers understand if this limit needs adjustment.

+// 512 bytes is chosen as a reasonable limit that accommodates most URIs while preventing excessive storage usage
const MAX_URI_LENGTH: u64 = 512;
precompile/modules/minitia_stdlib/doc/collection.md (2)

875-876: Improve clarity of the nfts function documentation.

The current documentation could be clearer. Consider this revision:

-if `start_after` is not none, search nfts in range (start_after, ...]
+If `start_after` is provided, returns NFTs with token IDs lexicographically greater than the specified value.

Line range hint 892-897: Consider improving the nfts function implementation.

  1. The iterator direction parameter is hardcoded to 2 without explanation. Consider using a named constant to clarify its purpose.
  2. The function silently caps the limit parameter. Consider either:
    • Returning the actual limit used
    • Throwing an error if the requested limit exceeds MAX_QUERY_LIMIT
    • Documenting this behavior clearly in the function's documentation
precompile/modules/initia_stdlib/doc/primary_fungible_store.md (2)

663-663: Fix grammatical error in documentation

Add the missing article "the" before "minimum deposit assertion api".

-Use the minimum deposit assertion api to make sure recipient will receive a minimum amount of fund.
+Use the minimum deposit assertion API to make sure the recipient will receive a minimum amount of funds.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~663-~663: Possible missing article found.
Context: ...imum deposit assertion api to make sure recipient will receive a minimum amount of fund. ...

(AI_HYDRA_LEO_MISSING_THE)


Line range hint 663-676: Add input validation for minimum deposit

The function should validate that the transfer amount is greater than or equal to the expected minimum deposit to prevent unnecessary transfers that would fail the assertion.

 public entry fun transfer_assert_minimum_deposit<T: key>(
     sender: &signer,
     metadata: Object<T>,
     recipient: address,
     amount: u64,
     expected: u64
 ) acquires DeriveRefPod, ModuleStore {
+    assert!(amount >= expected, 0x1); // Add error code as per your error category
     let sender_store =
         ensure_primary_store_exists(signer::address_of(sender), metadata);
     let recipient_store = ensure_primary_store_exists(recipient, metadata);
     dispatchable_fungible_asset::transfer_assert_minimum_deposit(
         sender,
         sender_store,
         recipient_store,
         amount,
         expected
     );
 }
🧰 Tools
🪛 LanguageTool

[uncategorized] ~663-~663: Possible missing article found.
Context: ...imum deposit assertion api to make sure recipient will receive a minimum amount of fund. ...

(AI_HYDRA_LEO_MISSING_THE)

precompile/modules/initia_stdlib/sources/fa/fungible_asset.move (1)

Line range hint 91-91: Fix typo in error constant name

The constant name has a typo: ECONNOT_MANIPULATE_MODULE_ACCOUNT_STORE should be ECANNOT_MANIPULATE_MODULE_ACCOUNT_STORE.

-    const ECONNOT_MANIPULATE_MODULE_ACCOUNT_STORE: u64 = 91;
+    const ECANNOT_MANIPULATE_MODULE_ACCOUNT_STORE: u64 = 91;
precompile/modules/initia_stdlib/doc/object.md (4)

553-553: Add documentation about the rationale for maximum nesting depth.

The constant MAXIMUM_OBJECT_NESTING would benefit from additional documentation explaining:

  • Why the value 8 was chosen
  • Performance implications of different nesting levels
  • Potential impact on gas costs

Line range hint 1124-1159: Consider optimizing ownership verification for common cases.

The owns function performs recursive ownership checking which could be gas-intensive for deeply nested objects. Consider:

  1. Caching intermediate ownership results
  2. Adding a non-recursive fast path for common cases
  3. Documenting the gas cost implications of deep nesting

Line range hint 1001-1013: Consider emitting transfer event before state change.

In transfer_raw, the ownership state is modified after emitting the event. This could lead to inconsistencies if the transaction fails after the state change but before event emission. Consider:

  1. Emitting the event before changing the state
  2. Adding a try-catch block for better error handling
 public fun transfer_raw(owner: &signer, object: address, to: address) acquires ObjectCore {
     let owner_address = signer::address_of(owner);
     verify_ungated_and_descendant(owner_address, object);
 
     let object_core = borrow_global_mut<ObjectCore>(object);
     if (object_core.owner == to) { return };
 
+    // Emit event before state change
+    event::emit(TransferEvent { object, from: object_core.owner, to });
+
     object_core.owner = to;
-    event::emit(TransferEvent { object, from: object_core.owner, to });
 }

Line range hint 401-451: Enhance error constant documentation.

The error constants would benefit from more detailed documentation including:

  1. Specific scenarios that trigger each error
  2. Recommended actions for handling these errors
  3. Examples of proper error handling
precompile/modules/minitia_stdlib/doc/object.md (2)

553-553: Document the rationale for MAXIMUM_OBJECT_NESTING value

The value 8 for maximum nesting depth seems arbitrary. Consider adding documentation explaining why this specific value was chosen and what trade-offs were considered.


Line range hint 12-24: Fix potential pricing anomaly in discount calculation

The current implementation has a critical business logic issue where applying a discount can result in a higher final price than without a discount. For example:

  • Purchase of $100 with 10% discount = $90 + $20 fee = $110 (more than original price)
  • Purchase of $100 with no discount = $100 (no fee)

This creates a negative incentive for customer loyalty.

Consider these alternatives:

  1. Apply the fee before the discount
  2. Scale the fee based on the purchase amount
  3. Only apply the fee for purchases above a certain threshold

Would you like me to propose a revised implementation?

precompile/modules/initia_stdlib/doc/stableswap.md (1)

Line range hint 1-1000: Consider enhancing the documentation with examples.

While the documentation is comprehensive, consider adding:

  • Usage examples for key functions
  • Common scenarios and best practices
  • Parameter constraints and valid ranges
precompile/modules/initia_stdlib/doc/staking.md (4)

2119-2119: Remove unnecessary line number comments

The line number comments (2119~, 2488~, 2579~) before function definitions don't provide any value and could confuse readers. Consider removing them to maintain clean documentation.

 /// Destroy empty delegation
 public fun destroy_empty_delegation(delegation: Delegation)
 /// Destroy empty unbonding
 public fun destroy_empty_unbonding(unbonding: Unbonding)
 /// Withdraw specified `amount` of unbonding_amount from the unbonding.
 public fun withdraw_unbonding(account: &signer, metadata: Object<Metadata>,...)

Also applies to: 2488-2488, 2579-2579


Line range hint 2051-2077: Add reward index validation in merge_delegation

The merge_delegation function merges two delegations but doesn't validate that their reward indices match. This could lead to incorrect reward calculations if the delegations have different reward indices.

Consider adding a validation check:

 public fun merge_delegation(
     dst_delegation: &mut Delegation, source_delegation: Delegation
 ): FungibleAsset acquires ModuleStore {
     assert!(
         dst_delegation.metadata == source_delegation.metadata,
         error::invalid_argument(EMETADATA_MISMATCH)
     );
     assert!(
         dst_delegation.validator == source_delegation.validator,
         error::invalid_argument(EVALIDATOR_MISMATCH)
     );
+    assert!(
+        dst_delegation.reward_index == source_delegation.reward_index,
+        error::invalid_argument(EREWARD_INDEX_MISMATCH)
+    );

Line range hint 378-379: Improve error handling organization and messages

The error constants could be better organized and have more descriptive messages. Consider:

  1. Grouping related errors together (e.g., all delegation errors, all unbonding errors)
  2. Adding more descriptive error messages in comments
-const ENOT_EMPTY: u64 = 7;
+/// The delegation or unbonding still has non-zero share and cannot be destroyed
+const ENOT_EMPTY: u64 = 7;

-const ERELEASE_TIME: u64 = 9;
+/// The source unbonding's release time must be <= destination's release time
+const ERELEASE_TIME: u64 = 9;

-const EDELEGATION_NOT_FOUND: u64 = 13;
+/// The requested delegation entry was not found in storage
+const EDELEGATION_NOT_FOUND: u64 = 13;

-const EINSUFFICIENT_AMOUNT: u64 = 11;
+/// The requested amount exceeds the available balance
+const EINSUFFICIENT_AMOUNT: u64 = 11;

-const EINVALID_START_AFTER: u64 = 14;
+/// Invalid pagination parameters: start_after values must be consistently provided
+const EINVALID_START_AFTER: u64 = 14;

Also applies to: 384-385, 390-391, 396-397, 402-403


Line range hint 2673-2683: Add detailed documentation for native functions

The native functions share_to_amount and amount_to_share lack detailed documentation about their behavior, edge cases, and potential failure scenarios.

Consider adding comprehensive documentation:

+/// Converts a share amount to the corresponding token amount for a validator.
+/// * `validator` - The validator's address in bytes
+/// * `metadata` - The token metadata
+/// * `share` - The share amount to convert
+/// 
+/// # Errors
+/// * Returns 0 if the validator has no total shares
+/// * Rounds down to the nearest whole token amount
 native public fun share_to_amount(
     validator: vector<u8>, metadata: &Object<Metadata>, share: &BigDecimal
 ): u64;

+/// Converts a token amount to the corresponding share amount for a validator.
+/// * `validator` - The validator's address in bytes
+/// * `metadata` - The token metadata
+/// * `amount` - The token amount to convert
+///
+/// # Errors
+/// * Returns 0 shares if the validator has no total tokens
+/// * May return fractional shares
 native public fun amount_to_share(
     validator: vector<u8>, metadata: &Object<Metadata>, amount: u64
 ): BigDecimal;
precompile/modules/initia_stdlib/doc/dex.md (1)

2587-2587: Fix grammar in function documentation

The documentation for single_asset_provide_liquidity has a grammatical error. The sentence structure needs improvement.

-Single asset provide liquidity directly
+Provides liquidity using a single asset directly
🧰 Tools
🪛 LanguageTool

[grammar] ~2587-~2587: There seems to be a noun/verb agreement error. Did you mean “provides” or “provided”?
Context: ..._asset_provide_liquidity` Single asset provide liquidity directly CONTRACT: cannot pro...

(SINGULAR_NOUN_VERB_AGREEMENT)

precompile/modules/minitia_stdlib/doc/dex.md (2)

2587-2587: Function signatures are accurate and well-documented.

The function signatures match the changes mentioned in the AI summary, particularly for functions like single_asset_provide_liquidity, withdraw_liquidity, swap, create_pair, and provide_liquidity.

However, there's a minor grammatical issue in the comment:

-Single asset provide liquidity directly
+Single asset provides liquidity directly
🧰 Tools
🪛 LanguageTool

[grammar] ~2587-~2587: There seems to be a noun/verb agreement error. Did you mean “provides” or “provided”?
Context: ..._asset_provide_liquidity` Single asset provide liquidity directly CONTRACT: cannot pro...

(SINGULAR_NOUN_VERB_AGREEMENT)


Line range hint 1-2587: Consider improving documentation clarity with consistent grammar.

The documentation is technically accurate, but some sections could benefit from more consistent grammar in the comments. For example:

  • Use consistent tense (present tense) throughout function descriptions
  • Ensure subject-verb agreement in function documentation
  • Maintain consistent punctuation at the end of comments

Would you like me to help identify specific sections that could be improved?

🧰 Tools
🪛 LanguageTool

[grammar] ~2587-~2587: There seems to be a noun/verb agreement error. Did you mean “provides” or “provided”?
Context: ..._asset_provide_liquidity` Single asset provide liquidity directly CONTRACT: cannot pro...

(SINGULAR_NOUN_VERB_AGREEMENT)

precompile/modules/initia_stdlib/doc/minitswap.md (2)

3965-3965: Fix typo in comment: "metdata" should be "metadata"

The word "metadata" is misspelled in the comment.

-    // check metdata
+    // check metadata

4369-4369: Fix typo in comment: "recalculate" should be "re-calculate"

For better readability and consistency, the word "recalculate" should be hyphenated.

-            // and recalculate offer amount repeatedly until return amount <= actual return amount
+            // and re-calculate offer amount repeatedly until return amount <= actual return amount
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fd11008 and 1a913c2.

📒 Files selected for processing (75)
  • .github/config/.codespellignore (1 hunks)
  • .github/workflows/spellcheck.yml (1 hunks)
  • api/memory_test.go (1 hunks)
  • api/mocks.go (3 hunks)
  • crates/compiler/src/clean.rs (1 hunks)
  • crates/gas/src/lib.rs (1 hunks)
  • crates/gas/src/meter.rs (1 hunks)
  • crates/json/src/json_to_move.rs (1 hunks)
  • crates/json/src/json_to_value.rs (1 hunks)
  • crates/natives/src/function_info.rs (1 hunks)
  • crates/natives/src/move_stdlib/bcs.rs (1 hunks)
  • crates/types/src/compiler.rs (1 hunks)
  • crates/types/src/serde_helper/vec_bytes.rs (1 hunks)
  • precompile/modules/initia_stdlib/doc/coin.md (3 hunks)
  • precompile/modules/initia_stdlib/doc/collection.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/dex.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/dispatchable_fungible_asset.md (2 hunks)
  • precompile/modules/initia_stdlib/doc/ed25519.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/fungible_asset.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/math128.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/math64.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/minitswap.md (2 hunks)
  • precompile/modules/initia_stdlib/doc/nft.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/object.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/primary_fungible_store.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/property_map.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/stableswap.md (1 hunks)
  • precompile/modules/initia_stdlib/doc/staking.md (4 hunks)
  • precompile/modules/initia_stdlib/sources/coin.move (3 hunks)
  • precompile/modules/initia_stdlib/sources/crypto/ed25519.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/dex.move (2 hunks)
  • precompile/modules/initia_stdlib/sources/fa/dispatchable_fungible_asset.move (2 hunks)
  • precompile/modules/initia_stdlib/sources/fa/fungible_asset.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/fa/primary_fungible_store.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/fixed_point64.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/math128.move (2 hunks)
  • precompile/modules/initia_stdlib/sources/math64.move (2 hunks)
  • precompile/modules/initia_stdlib/sources/minitswap.move (2 hunks)
  • precompile/modules/initia_stdlib/sources/multisig.move (2 hunks)
  • precompile/modules/initia_stdlib/sources/object.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/stableswap.move (3 hunks)
  • precompile/modules/initia_stdlib/sources/staking.move (4 hunks)
  • precompile/modules/initia_stdlib/sources/token/collection.move (3 hunks)
  • precompile/modules/initia_stdlib/sources/token/nft.move (1 hunks)
  • precompile/modules/initia_stdlib/sources/token/property_map.move (1 hunks)
  • precompile/modules/minitia_stdlib/README.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/coin.md (3 hunks)
  • precompile/modules/minitia_stdlib/doc/collection.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/dex.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/dispatchable_fungible_asset.md (2 hunks)
  • precompile/modules/minitia_stdlib/doc/ed25519.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/fungible_asset.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/math128.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/math64.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/nft.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/object.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/primary_fungible_store.md (1 hunks)
  • precompile/modules/minitia_stdlib/doc/property_map.md (1 hunks)
  • precompile/modules/minitia_stdlib/sources/coin.move (3 hunks)
  • precompile/modules/minitia_stdlib/sources/crypto/ed25519.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/dex.move (2 hunks)
  • precompile/modules/minitia_stdlib/sources/fa/dispatchable_fungible_asset.move (2 hunks)
  • precompile/modules/minitia_stdlib/sources/fa/fungible_asset.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/fa/primary_fungible_store.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/fixed_point64.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/math128.move (2 hunks)
  • precompile/modules/minitia_stdlib/sources/math64.move (2 hunks)
  • precompile/modules/minitia_stdlib/sources/multisig.move (2 hunks)
  • precompile/modules/minitia_stdlib/sources/object.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/token/collection.move (3 hunks)
  • precompile/modules/minitia_stdlib/sources/token/nft.move (1 hunks)
  • precompile/modules/minitia_stdlib/sources/token/property_map.move (1 hunks)
  • precompile/modules/move_nursery/doc/compare.md (1 hunks)
  • precompile/modules/move_nursery/sources/compare.move (1 hunks)
  • precompile/modules/move_stdlib/sources/signer.move (1 hunks)
✅ Files skipped from review due to trivial changes (51)
  • .github/config/.codespellignore
  • api/memory_test.go
  • api/mocks.go
  • crates/compiler/src/clean.rs
  • crates/gas/src/lib.rs
  • crates/gas/src/meter.rs
  • crates/natives/src/function_info.rs
  • crates/natives/src/move_stdlib/bcs.rs
  • crates/types/src/compiler.rs
  • precompile/modules/initia_stdlib/doc/coin.md
  • precompile/modules/initia_stdlib/doc/ed25519.md
  • precompile/modules/initia_stdlib/doc/math128.md
  • precompile/modules/initia_stdlib/doc/nft.md
  • precompile/modules/initia_stdlib/doc/property_map.md
  • precompile/modules/initia_stdlib/sources/coin.move
  • precompile/modules/initia_stdlib/sources/crypto/ed25519.move
  • precompile/modules/initia_stdlib/sources/dex.move
  • precompile/modules/initia_stdlib/sources/fa/dispatchable_fungible_asset.move
  • precompile/modules/initia_stdlib/sources/fa/primary_fungible_store.move
  • precompile/modules/initia_stdlib/sources/fixed_point64.move
  • precompile/modules/initia_stdlib/sources/minitswap.move
  • precompile/modules/initia_stdlib/sources/multisig.move
  • precompile/modules/initia_stdlib/sources/object.move
  • precompile/modules/initia_stdlib/sources/stableswap.move
  • precompile/modules/initia_stdlib/sources/staking.move
  • precompile/modules/initia_stdlib/sources/token/collection.move
  • precompile/modules/initia_stdlib/sources/token/nft.move
  • precompile/modules/initia_stdlib/sources/token/property_map.move
  • precompile/modules/minitia_stdlib/README.md
  • precompile/modules/minitia_stdlib/doc/ed25519.md
  • precompile/modules/minitia_stdlib/doc/fungible_asset.md
  • precompile/modules/minitia_stdlib/doc/math128.md
  • precompile/modules/minitia_stdlib/doc/math64.md
  • precompile/modules/minitia_stdlib/doc/primary_fungible_store.md
  • precompile/modules/minitia_stdlib/doc/property_map.md
  • precompile/modules/minitia_stdlib/sources/coin.move
  • precompile/modules/minitia_stdlib/sources/crypto/ed25519.move
  • precompile/modules/minitia_stdlib/sources/dex.move
  • precompile/modules/minitia_stdlib/sources/fa/dispatchable_fungible_asset.move
  • precompile/modules/minitia_stdlib/sources/fa/fungible_asset.move
  • precompile/modules/minitia_stdlib/sources/fa/primary_fungible_store.move
  • precompile/modules/minitia_stdlib/sources/fixed_point64.move
  • precompile/modules/minitia_stdlib/sources/math128.move
  • precompile/modules/minitia_stdlib/sources/multisig.move
  • precompile/modules/minitia_stdlib/sources/object.move
  • precompile/modules/minitia_stdlib/sources/token/collection.move
  • precompile/modules/minitia_stdlib/sources/token/nft.move
  • precompile/modules/minitia_stdlib/sources/token/property_map.move
  • precompile/modules/move_nursery/doc/compare.md
  • precompile/modules/move_nursery/sources/compare.move
  • precompile/modules/move_stdlib/sources/signer.move
🧰 Additional context used
🪛 LanguageTool
precompile/modules/initia_stdlib/doc/dex.md

[grammar] ~2587-~2587: There seems to be a noun/verb agreement error. Did you mean “provides” or “provided”?
Context: ..._asset_provide_liquidity` Single asset provide liquidity directly CONTRACT: cannot pro...

(SINGULAR_NOUN_VERB_AGREEMENT)

precompile/modules/initia_stdlib/doc/dispatchable_fungible_asset.md

[uncategorized] ~288-~288: Possible missing article found.
Context: ... The recipient is guaranteed to receive asset greater than the expected amount. Note:...

(AI_HYDRA_LEO_MISSING_AN)

precompile/modules/initia_stdlib/doc/primary_fungible_store.md

[uncategorized] ~663-~663: Possible missing article found.
Context: ...imum deposit assertion api to make sure recipient will receive a minimum amount of fund. ...

(AI_HYDRA_LEO_MISSING_THE)

precompile/modules/minitia_stdlib/doc/dex.md

[grammar] ~2587-~2587: There seems to be a noun/verb agreement error. Did you mean “provides” or “provided”?
Context: ..._asset_provide_liquidity` Single asset provide liquidity directly CONTRACT: cannot pro...

(SINGULAR_NOUN_VERB_AGREEMENT)

🔇 Additional comments (24)
.github/workflows/spellcheck.yml (1)

16-16: Verify configuration file paths and existing workflows

Let's verify the configuration setup and check for potential conflicts.

✅ Verification successful

Configuration paths and workflow setup are correctly configured

The verification shows that:

  • The .codespellignore file exists at the correct location (.github/config/.codespellignore)
  • The file contains valid ignore patterns
  • The workflow configuration is properly set up with the correct path reference
  • No conflicting .codespellignore files were found in the repository
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify .codespellignore file location and check for similar workflows

# Check if .codespellignore exists in the specified location
if [ -f ".github/config/.codespellignore" ]; then
    echo "✓ .codespellignore found"
else
    echo "✗ .codespellignore not found at .github/config/.codespellignore"
fi

# Check for similar spell checking workflows
fd -e yml -e yaml . .github/workflows/ --exec grep -l "codespell" {}

Length of output: 207


Script:

#!/bin/bash
# Let's verify the content of both the workflow and ignore file to ensure proper configuration

# Check the content of .codespellignore
echo "=== .codespellignore content ==="
cat .github/config/.codespellignore

# Check the complete workflow configuration
echo -e "\n=== spellcheck.yml content ==="
cat .github/workflows/spellcheck.yml

# Check if there are any other .codespellignore files that might conflict
echo -e "\n=== Looking for other .codespellignore files ==="
fd codespellignore

Length of output: 1238

precompile/modules/initia_stdlib/sources/math64.move (2)

114-114: LGTM: Comment spelling correction

The spelling correction from "treshold" to "threshold" improves documentation clarity.


277-283: LGTM: Parameter name correction

The parameter name correction from "precission" to "precision" in the test helper function improves code clarity and consistency.

precompile/modules/minitia_stdlib/sources/math64.move (1)

114-114: LGTM! Spelling correction in comment.

The spelling of "threshold" has been corrected, improving documentation quality.

precompile/modules/initia_stdlib/doc/math64.md (1)

304-304: LGTM! Documentation improvement enhances clarity.

The spelling correction from "treshold" to "threshold" and the technical explanation about the quadratic convergence reaching below 2^-32 after 4 iterations provides valuable context for the implementation.

precompile/modules/initia_stdlib/sources/math128.move (1)

140-140: LGTM: Spelling correction in comment

The spelling correction from "treshold" to "threshold" improves documentation clarity.

precompile/modules/initia_stdlib/doc/dispatchable_fungible_asset.md (2)

13-13: LGTM: Spelling correction

The spelling correction from "transfered" to "transferred" is accurate.


Line range hint 1-24: LGTM: Well-implemented dispatchable fungible asset module

The implementation demonstrates:

  • Proper error handling with descriptive error codes
  • Strong security controls for transfers and balance management
  • Clear documentation and type safety
  • Appropriate use of Move language patterns
precompile/modules/minitia_stdlib/doc/dispatchable_fungible_asset.md (1)

13-13: LGTM!

The explanation of the transfer allowlist feature is clear and correctly written.

precompile/modules/minitia_stdlib/doc/nft.md (1)

Line range hint 1-24: Implementation follows Move best practices.

The code demonstrates solid implementation with:

  • Proper error handling and input validation
  • Strong access control using capability pattern
  • Event emission for tracking mutations
  • Clear separation of concerns

Also applies to: 129-600

precompile/modules/minitia_stdlib/doc/coin.md (1)

Line range hint 1-1: Verify all instances of the typo have been fixed.

The AI summary mentions fixing "metadat object" to "metadata object". Let's verify all instances have been corrected.

✅ Verification successful

Based on the search results, I can see that the term "metadat" appears only in legitimate contexts like "metadata" throughout the codebase, and there are no instances of the typo "metadat object". This suggests that the typo mentioned in the AI summary has already been fixed.

All instances of the term have been properly spelled as "metadata object"

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of the typo

# Search for any remaining instances of "metadat"
rg -i "metadat" --type md

Length of output: 335314

crates/json/src/json_to_move.rs (1)

673-675: LGTM! Good addition of error case test coverage.

The added test case verifies that the deserialization properly handles and rejects invalid hex addresses in vector elements, strengthening the validation of error handling paths.

precompile/modules/initia_stdlib/doc/collection.md (1)

Line range hint 447-456: Enhance collection name validation.

The function only validates the length of the collection name but not its content. Consider adding validation for invalid characters to prevent potential security issues.

precompile/modules/minitia_stdlib/doc/collection.md (1)

Line range hint 392-396: LGTM! Error handling is well-implemented.

The error handling using custom error codes and constants is well-structured and follows best practices.

precompile/modules/initia_stdlib/doc/primary_fungible_store.md (2)

Line range hint 1-9: LGTM!

The module structure and imports are well-organized and follow Move language conventions.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~663-~663: Possible missing article found.
Context: ...imum deposit assertion api to make sure recipient will receive a minimum amount of fund. ...

(AI_HYDRA_LEO_MISSING_THE)


Line range hint 10-50: LGTM!

The resource and struct definitions are well-designed with appropriate capabilities and documentation.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~663-~663: Possible missing article found.
Context: ...imum deposit assertion api to make sure recipient will receive a minimum amount of fund. ...

(AI_HYDRA_LEO_MISSING_THE)

precompile/modules/initia_stdlib/sources/fa/fungible_asset.move (2)

446-449: LGTM!

The comment correction and function implementation are correct. The function properly checks for the existence of Metadata at the given address.


Line range hint 91-92: Verify consistent usage of new error constants

Let's verify that the new error constants are used consistently throughout the codebase.

✅ Verification successful

Error constants are used consistently and appropriately

The verification shows that both error constants are used consistently and appropriately in the codebase:

  • ECONNOT_MANIPULATE_MODULE_ACCOUNT_STORE (91) is used in module account store manipulation checks
  • ECANNOT_DEPOSIT_TO_BLOCKED_ACCOUNT (92) is used in deposit validation checks for blocked accounts

Both constants are properly documented and used in their respective error scenarios without any conflicting or inconsistent usage.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of new error constants

# Check for usage of module account store error
rg "ECONNOT_MANIPULATE_MODULE_ACCOUNT_STORE" -A 2

# Check for usage of blocked account error
rg "ECANNOT_DEPOSIT_TO_BLOCKED_ACCOUNT" -A 2

# Check for any other similar error constant names to avoid confusion
rg "E.*MANIPULATE.*STORE|E.*DEPOSIT.*BLOCKED" -A 2

Length of output: 21651

precompile/modules/initia_stdlib/doc/stableswap.md (1)

115-115: LGTM: Documentation typo fix.

The correction from "Refernce" to "Reference" in the field description improves the documentation's accuracy.

precompile/modules/initia_stdlib/doc/fungible_asset.md (2)

1304-1304: LGTM! The typographical error has been fixed.

The description for is_fungible_asset function has been corrected from "Retrun" to "Return".


Line range hint 1-1304: Documentation is comprehensive and well-structured.

The documentation provides clear and detailed information about:

  • Resource and struct definitions with field descriptions
  • Function signatures with parameter details
  • Error codes with descriptive messages
  • Event definitions and their usage
  • Implementation details with proper code examples
precompile/modules/initia_stdlib/doc/staking.md (1)

Line range hint 1052-1102: Review security implications of signer creation and fund movement

The slash_unbonding_for_chain function creates a signer for the relayer account and handles fund movement. This requires careful security considerations:

  1. The create_signer call could be dangerous if not properly controlled
  2. The function moves funds to the relayer account and then to the community pool

Consider:

  • Adding explicit access control checks
  • Documenting the security assumptions and requirements
  • Adding events to track fund movements for transparency
precompile/modules/minitia_stdlib/doc/dex.md (2)

Line range hint 1-24: Documentation structure looks good!

The documentation is well-organized with clear sections for resources, structs, functions, and events. The table of contents with anchor links provides good navigation.

🧰 Tools
🪛 LanguageTool

[grammar] ~2587-~2587: There seems to be a noun/verb agreement error. Did you mean “provides” or “provided”?
Context: ..._asset_provide_liquidity` Single asset provide liquidity directly CONTRACT: cannot pro...

(SINGULAR_NOUN_VERB_AGREEMENT)


Line range hint 1-2587: Technical documentation is comprehensive and accurate.

The documentation effectively covers:

  • Contract constraints and preconditions
  • Error codes and their meanings
  • Function behaviors and parameter descriptions
  • Event emissions and their purposes
🧰 Tools
🪛 LanguageTool

[grammar] ~2587-~2587: There seems to be a noun/verb agreement error. Did you mean “provides” or “provided”?
Context: ..._asset_provide_liquidity` Single asset provide liquidity directly CONTRACT: cannot pro...

(SINGULAR_NOUN_VERB_AGREEMENT)

Copy link
Member

@beer-1 beer-1 left a comment

Choose a reason for hiding this comment

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

LGTM

@beer-1 beer-1 merged commit 782f4ca into main Nov 15, 2024
4 checks passed
@beer-1 beer-1 deleted the chore/spellcheck branch November 15, 2024 06:10
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.

2 participants