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

Debug tools for Antelope lib #690

Merged
merged 23 commits into from
Jan 10, 2024
Merged

Conversation

Viterbo
Copy link
Collaborator

@Viterbo Viterbo commented Nov 27, 2023

Fixes #689 and #745

Description

This PR includes changes for two different issues. First, it incorporates a whole new functionality on the Antlib to provide tools for debugging. Then, there are some code refactors to remove unnecessary dependencies.

Antlib debug tools (#689)

This is the list of features implemented.

  • The debug mode can be turned on (and off) using a URL parameter like this trace=true but now is remembered in localStorage. It remains on if you lose the parameter while you navigate.
  • You can print the current state of the stores to see the actual data
  • When debug mode is on, you can access Antlib from the console and execute any valid function

Dependencies removed (#745)

All proposed changes here were made. I will explain how I replaced those dependencies.

  • Chan: needs to query the current stake/unstake ratio and for that, it used Account and Contract stores. That was removed with a direct ethers.Contract creation using the getAntelope().wallets.getWeb3Provider(); global function to solve the provider.
  • Contract: was using the Account store to get the authenticator and provide a signer for the contracts. The code was copied from OBE's code but the reality is that we don't need them anymore because we solve all signing with the EVMAuthenticators and they use their own signer. So, although there's no need for this functionality anymore, I refactored all functions to receive a final optional parameter bringing an ethers.Signer if for some reason the developer wants to sign this way.
  • EVM: was using the Account store to initialize an InjectedAuthenticator. Now that initialization occurs inside the Authenticator itself. So, the EVM store now does not need to depend on Account store anymore
  • Account: was calling a clear function one by one on all its dependencies. That code was replaced with a new event called getAntelope().events.onClear that passes the label indicating which context we need to clear (thinking of the future when we have multiple connections, we don't want to clean them all).

Test scenarios

Let's check the new Library debugging features:

Debug mode (on & off)

Print:

Filtering traces

  • Turn on debug mode again: https://deploy-preview-690--wallet-staging.netlify.app/?trace=true
  • Login
  • Open and lean the console
    • You will see that the update-related functions are called every now and then, which is annoying for debugging.
  • Enter the following text in the console: ant.debug.filterStart()
    • you will notice that the traces continue but don't repeat.
    • after you get everything filtered, enter the following text: ant.debug.filterEnd()
    • now you will get trace only for your actions

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have cleaned up the code in the areas my change touches
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • I have removed any unnecessary console messages
  • I have included all english text to the translation file and/or created a new issue with the required translations for the currently supported languages
  • I have tested for mobile functionality and responsiveness
  • I have added appropriate test coverage

@Viterbo Viterbo self-assigned this Nov 27, 2023
@Viterbo Viterbo linked an issue Nov 27, 2023 that may be closed by this pull request
Copy link

netlify bot commented Nov 27, 2023

Deploy Preview for wallet-develop-mainnet ready!

Name Link
🔨 Latest commit 067879b
🔍 Latest deploy log https://app.netlify.com/sites/wallet-develop-mainnet/deploys/659edf9eb3ed280008b4fa5c
😎 Deploy Preview https://deploy-preview-690--wallet-develop-mainnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 27, 2023

Deploy Preview for wallet-staging ready!

Name Link
🔨 Latest commit 067879b
🔍 Latest deploy log https://app.netlify.com/sites/wallet-staging/deploys/659edf9e3c1c3900088f5c04
😎 Deploy Preview https://deploy-preview-690--wallet-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Viterbo Viterbo marked this pull request as draft November 28, 2023 15:57
@Viterbo Viterbo force-pushed the 689-debug-tools-for-antelope-lib branch from bde97d8 to 02f9eec Compare November 30, 2023 19:37
src/antelope/config/AntelopeDebug.ts Show resolved Hide resolved
src/antelope/stores/account.ts Show resolved Hide resolved
src/antelope/stores/account.ts Show resolved Hide resolved
src/antelope/stores/allowances.ts Show resolved Hide resolved
src/antelope/stores/balances.ts Show resolved Hide resolved
test/jest/utils/antelope/index.ts Show resolved Hide resolved
src/antelope/config/AntelopeConfig.ts Show resolved Hide resolved
src/antelope/config/AntelopeConfig.ts Show resolved Hide resolved
src/boot/antelope.ts Show resolved Hide resolved
@Viterbo Viterbo marked this pull request as ready for review January 9, 2024 20:35
ezra-sg
ezra-sg previously approved these changes Jan 10, 2024
Copy link
Contributor

@ezra-sg ezra-sg left a comment

Choose a reason for hiding this comment

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

🔥 great job

Co-authored-by: Ezra Sowden-Guzman <[email protected]>
ezra-sg
ezra-sg previously approved these changes Jan 10, 2024
Copy link
Contributor

@donnyquixotic donnyquixotic left a comment

Choose a reason for hiding this comment

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

translation & unused import

src/antelope/config/AntelopeDebug.ts Outdated Show resolved Hide resolved
@donnyquixotic donnyquixotic merged commit cb1bcef into develop Jan 10, 2024
9 checks passed
@donnyquixotic donnyquixotic deleted the 689-debug-tools-for-antelope-lib branch January 10, 2024 19:03
@donnyquixotic donnyquixotic mentioned this pull request Jan 10, 2024
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.

Debug tools for Antelope lib
3 participants