Mintbase / mintbase-js

Powerful open-source library for doing all things NFTs on the NEAR protocol.
https://docs.mintbase.xyz
MIT License
63 stars 24 forks source link

add bitte wallet support to react package 2 #529

Closed rubenmarcus closed 3 months ago

rubenmarcus commented 3 months ago

PR Type

Enhancement


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
wallet.ts
Add Bitte Wallet support and refactor wallet setup             

packages/react/src/wallet/wallet.ts
  • Added support for Bitte Wallet.
  • Refactored wallet setup to use a base module configuration.
  • Reordered imports for better readability.
  • Updated wallet selector setup logic to include Bitte Wallet.
  • +26/-17 

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

    mintbase-codium-pr-agent[bot] commented 3 months ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review: 3 ๐Ÿ”ต๐Ÿ”ต๐Ÿ”ตโšชโšช
    ๐Ÿงช No relevant tests
    ๐Ÿ”’ No security concerns identified
    โšก Key issues to review

    Code Duplication
    The logic for setting up the `baseModuleWallet` and `moduleWallet` is repeated in two different sections of the code (lines 80-91 and 106-110). Consider refactoring this to a single function to avoid duplication and improve maintainability. Error Handling
    There is no error handling for the asynchronous operations within `setupMintbaseWalletSelector`. Consider adding try-catch blocks or error handling callbacks to manage exceptions and provide feedback.
    mintbase-codium-pr-agent[bot] commented 3 months ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Correct the logic to set the appropriate URL for failure cases ___ **Ensure that the failureUrl is correctly set to a failure-specific URL or handle
    appropriately, as currently it mistakenly uses successUrl.** [packages/react/src/wallet/wallet.ts [90]](https://github.com/Mintbase/mintbase-js/pull/529/files#diff-ef93d4fc45125c35c15776fe7de2174ee8dd53a8392140f750680a68c2ed958cR90-R90) ```diff -failureUrl: successUrl || window.location.href, +failureUrl: failureUrl || window.location.href, ```
    Suggestion importance[1-10]: 10 Why: This suggestion addresses a potential bug by ensuring that the `failureUrl` is correctly set, which is crucial for handling failure cases appropriately.
    10
    Maintainability
    Reduce redundancy by using a single variable for repeated logic ___ **Replace the repeated use of successUrl || window.location.href with a single
    variable to avoid redundancy and potential errors if the logic changes in the
    future.** [packages/react/src/wallet/wallet.ts [89-90]](https://github.com/Mintbase/mintbase-js/pull/529/files#diff-ef93d4fc45125c35c15776fe7de2174ee8dd53a8392140f750680a68c2ed958cR89-R90) ```diff -successUrl: successUrl || window.location.href, -failureUrl: successUrl || window.location.href, +const resolvedUrl = successUrl || window.location.href; +successUrl: resolvedUrl, +failureUrl: resolvedUrl, ```
    Suggestion importance[1-10]: 8 Why: This suggestion reduces redundancy and potential errors by consolidating repeated logic into a single variable, which enhances maintainability and readability.
    8
    Best practice
    Improve code clarity and reduce redundancy by using parameter destructuring ___ **Consider using destructuring for walletUrls and callbackUrl from the options object
    directly in the function parameters to improve code clarity and reduce redundancy.** [packages/react/src/wallet/wallet.ts [81-82]](https://github.com/Mintbase/mintbase-js/pull/529/files#diff-ef93d4fc45125c35c15776fe7de2174ee8dd53a8392140f750680a68c2ed958cR81-R82) ```diff -walletUrl: walletUrls[network], -callbackUrl: callbackUrl, +const setupMintbaseWalletSelector = async ({ walletUrls, callbackUrl, ...otherParams }: SetupOptions) => { + const baseModuleWallet = { + walletUrl: walletUrls[network], + callbackUrl: callbackUrl, + ... + }; ```
    Suggestion importance[1-10]: 7 Why: Using parameter destructuring can improve code clarity and reduce redundancy, although it is more of a best practice than a critical change.
    7
    Use descriptive variable names to enhance code readability ___ **Use a more descriptive variable name than baseModuleWallet to reflect that it
    contains URL and contract configurations.** [packages/react/src/wallet/wallet.ts [80-84]](https://github.com/Mintbase/mintbase-js/pull/529/files#diff-ef93d4fc45125c35c15776fe7de2174ee8dd53a8392140f750680a68c2ed958cR80-R84) ```diff -const baseModuleWallet = { +const walletConfig = { walletUrl: walletUrls[network], callbackUrl: callbackUrl, contractId: contractAddress, }; ```
    Suggestion importance[1-10]: 6 Why: While using more descriptive variable names can enhance readability, the current name is not misleading, so this suggestion is more about improving best practices.
    6