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

refactor: metamask handling #402

Merged
merged 15 commits into from
Jan 10, 2025
Merged

Conversation

cswni
Copy link
Contributor

@cswni cswni commented Jan 10, 2025

This pull request includes significant changes to integrate MetaMask SDK into the application and refactor the wallet connection logic. The most important changes include adding the MetaMaskProvider in App.tsx, refactoring the wallet connection logic to use the MetaMask SDK, and updating several hooks to align with the new MetaMask integration.

Integration of MetaMask SDK:

  • src/App.tsx: Added MetaMaskProvider to wrap the application and configured it with necessary options for MetaMask integration. [1] [2] [3]

Refactoring wallet connection logic:

Updating hooks for MetaMask integration:

Additional changes:

cswni and others added 15 commits January 9, 2025 13:11
This component is no longer in use and has been fully removed.
Key changes include:
- Deleted `src/sections/finance/components/finance-change-wallet.tsx`.
The removal helps in cleaning up obsolete code and improving maintainability.
- Updated `src/clients/viem/walletClient.ts` to remove the use of `infuraAPIKey` from the MetaMaskSDK configuration.
- This change simplifies the wallet client setup by eliminating unnecessary dependency on `GLOBAL_CONSTANTS`.
- Ensures a cleaner and more maintainable code structure for wallet integration.
- **finance-withdraw.tsx**: Removed `autoFocus` prop from the "Amount to withdraw" `TextField`.
- **finance-deposit.tsx**:
  - Removed unused `enqueueSnackbar` import.
  - Removed `enqueueSnackbar` call for error logging.
  - Removed `autoFocus` prop from the "Amount to deposit" `TextField`.

These changes simplify the components by removing redundant props and unused imports, improving code clarity and maintainability.
- src/hooks/use-deposit.ts: Added detailed error logs using `console.error`.
- src/hooks/use-transfer.ts, src/hooks/use-authorize-policy.ts: Introduced `console.log` for easier error debugging.
- src/hooks/use-deposit-metamask.ts: Replaced `enqueueSnackbar` with `console.log` for error messages, removing extra dependency.
- src/utils/metamask.ts: Removed unused `GLOBAL_CONSTANTS`, refined MetaMask redirection logic, and ensured better compatibility across platforms.
- **finance-withdraw.tsx**:
  - Updated `amount` state to accept `number | string` to fix type mismatch issues.
  - Ensured `amount` is converted to `Number` before validations, operations, and API calls.
  - Adjusted `amount` value used in the display to handle proper type casting.

- **finance-deposit.tsx**:
  - Similar changes as withdraw: updated `amount` state to `number | string`.
  - Converted `amount` to `Number` for validations, operations, and API calls.
  - Refactored type handling for better consistency across inputs.
…unt' into app/refactor/quick-trasnsfer-amount
- Introduced `FinanceMetamaskHelper` to guide users without MetaMask.
- Updated `finance-withdraw-from-metamask.tsx` to render helper alongside the button.
- Updated `finance-deposit-from-metamask.tsx` similarly to include the helper.
- Adjusted margin styling in `FinanceMetamaskButton` for consistency.
@cswni cswni added the Refactor label Jan 10, 2025
@cswni cswni requested a review from geolffreym January 10, 2025 18:08
@cswni cswni self-assigned this Jan 10, 2025
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@geolffreym geolffreym merged commit b88d766 into next Jan 10, 2025
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants