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

PP 102: convert to ts, apply lint and prettier #16

Merged
merged 12 commits into from
Mar 10, 2022
Merged

Conversation

antomor
Copy link
Collaborator

@antomor antomor commented Mar 7, 2022

What

  • Convert the project to use typescript (instead of js)
  • Apply lint, prettier, and lint-staged (to perform those checks on commit)

Why

  • We can take advantage of typescript, and avoid some common errors (e.g.: unused variables, parameters not required)
  • The code doesn't follow any rule linting/formatting rule

@antomor antomor requested a review from mortelli March 7, 2022 13:35
@antomor antomor self-assigned this Mar 7, 2022
REACT_APP_CONTRACTS_SMART_WALLET_FACTORY=0x03F23ae1917722d5A27a2Ea0Bcc98725a2a2a49a
REACT_APP_CONTRACTS_SMART_WALLET=0x73ec81da0C72DD112e06c09A6ec03B5544d26F05
REACT_APP_CONTRACTS_RIF_TOKEN=0x726ECC75d5D51356AA4d0a5B648790cC345985ED
REACT_APP_CONTRACTS_RELAY_WORKER=0x69862e277eab81e6a7ea6a7b387c39b2a996e533
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These changes aren't required and can be reverted

Copy link

Choose a reason for hiding this comment

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

is there a reason to prefer one set of values over the other?

Copy link
Collaborator Author

@antomor antomor Mar 9, 2022

Choose a reason for hiding this comment

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

Actually not, these are the ones that are generated from my local env, but it doesn't really matter for me

Copy link

Choose a reason for hiding this comment

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

leave as-is then 👍

@@ -3,14 +3,20 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@rsksmart/rif-relay-client": "https://github.com/infuy/rif-relay-client",
"@rsksmart/rif-relay-common": "https://github.com/infuy/rif-relay-common",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to remove these dependencies after fixing the SDK.

Copy link

Choose a reason for hiding this comment

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

agreed

package.json Outdated
"abi-decoder": "^2.4.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"relaying-services-sdk": "github:infuy/relaying-services-sdk",
"relaying-services-sdk": "github:antomor/relaying-services-sdk#PP-102/dapp-review",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this change needs to be reverted after merging the SDK PR

Copy link

@mortelli mortelli left a comment

Choose a reason for hiding this comment

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

thanks for this technical debt PR 🙌

leaving mostly questions down below; here are some more general comments:

  1. is it safe to delete the src/modals/Execute.cssfile?
  2. regarding the eslint-disables: do you think we should create a follow up task to fix these, or are the ones left acceptable to keep for the foreseeable future?
  3. i noticed some changes to the contract json files. aren't these automatically generated? should we maybe skip the linting on these?
  4. there are some console errors when running the dapp that we've been ignoring up until now, and i am wondering whether we can fix them now (if not, leave them for a later PR). these are:
    4.1 The stylesheet http://localhost:3000/css/style.css was not loaded because its MIME type, “text/html”, is not “text/css” when starting the dapp
    4.2 Uncaught TypeError: document.getElementById(...) is null when displaying the deploy wallet popup
    4.3 a similar error when displaying the transfer popup

finally: i manually compared the diff for each js file turned tsx. i may have missed some of the chnages (specially when code is being moved around) so i tried to complement this with manual testing.

the dapp boots OK and the wallets are deployed correctly (sponsored or not) but i was not able to execute a transfer successfully. i'm getting the verifier rejected in local view call : view call to 'relayCall' reverted in verifier: Internal JSON-RPC error failure, and process is not defined when trying again for the same wallet.

could you please verify that you are able to execute transfers successfully? if so i will double check my steps.

thanks

REACT_APP_CONTRACTS_SMART_WALLET_FACTORY=0x03F23ae1917722d5A27a2Ea0Bcc98725a2a2a49a
REACT_APP_CONTRACTS_SMART_WALLET=0x73ec81da0C72DD112e06c09A6ec03B5544d26F05
REACT_APP_CONTRACTS_RIF_TOKEN=0x726ECC75d5D51356AA4d0a5B648790cC345985ED
REACT_APP_CONTRACTS_RELAY_WORKER=0x69862e277eab81e6a7ea6a7b387c39b2a996e533
Copy link

Choose a reason for hiding this comment

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

is there a reason to prefer one set of values over the other?

.husky/.gitignore Show resolved Hide resolved
@@ -3,14 +3,20 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@rsksmart/rif-relay-client": "https://github.com/infuy/rif-relay-client",
"@rsksmart/rif-relay-common": "https://github.com/infuy/rif-relay-common",
Copy link

Choose a reason for hiding this comment

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

agreed

src/App.tsx Show resolved Hide resolved
src/App.tsx Show resolved Hide resolved
src/App.tsx Show resolved Hide resolved
src/Utils.ts Show resolved Hide resolved
src/components/SmartWallet.tsx Outdated Show resolved Hide resolved
src/modals/Deploy.tsx Outdated Show resolved Hide resolved
src/modals/Deploy.tsx Show resolved Hide resolved
@antomor
Copy link
Collaborator Author

antomor commented Mar 9, 2022

Thanks for reviewing, I know it was huge 🙏🏼 .

Down below you find my replies

  • is it safe to delete the src/modals/Execute.cssfile?

I noticed this file wasn't used hence I'd prefer to remove it. However yes, it's safe to remove as far as we remove its reference from the Execute.tsx (see the old Execute.js file ;-)

  • regarding the eslint-disables: do you think we should create a follow up task to fix these, or are the ones left acceptable to keep for the foreseeable future?

I tried to leave TODO comments for those I think we may remove in the future, while I wouldn't remove the rules set on on .eslintrc.js

  • i noticed some changes to the contract json files. aren't these automatically generated? should we maybe skip the linting on these?

Are you talking about the files under src/contracts. If so, yes, we could ignore them but here is my point of view.
If we ignore them, the user is entitled to paste there any valid JSON, while in this way, we are enforcing formatting rules each time they change, so they will be consistent among each other and over time.

  • there are some console errors when running the dapp that we've been ignoring up until now, and i am wondering whether we can fix them now (if not, leave them for a later PR). these are:
    4.1 The stylesheet http://localhost:3000/css/style.css was not loaded because its MIME type, “text/html”, is not “text/css” when starting the dapp
    4.2 Uncaught TypeError: document.getElementById(...) is null when displaying the deploy wallet popup
    4.3 a similar error when displaying the transfer popup

I'd glad to tackle these issues after merging this PR, but at the moment I see different errors on the browser console:

materialize.js:2990 Uncaught TypeError: Cannot read properties of null (reading 'M_Modal')
    at HTMLBodyElement._handleTriggerClick (materialize.js:2990:63)

However I think they may be related since they appear each time I open a popup (either a deploy or a transfer or a execute)

could you please verify that you are able to execute transfers successfully? if so i will double check my steps.

As discussed, I confirm that I'm able to deploy,transfer and execute successfully. If you still have those errors, let me know and I can investigate on them

@mortelli
Copy link

mortelli commented Mar 9, 2022

  • is it safe to delete the src/modals/Execute.cssfile?

I noticed this file wasn't used hence I'd prefer to remove it. However yes, it's safe to remove as far as we remove its reference from the Execute.tsx (see the old Execute.js file ;-)

my bad, i thought this was just empty and was suggesting to delete it 😅

  • regarding the eslint-disables: do you think we should create a follow up task to fix these, or are the ones left acceptable to keep for the foreseeable future?

I tried to leave TODO comments for those I think we may remove in the future, while I wouldn't remove the rules set on on .eslintrc.js

sounds GTM 👍

  • i noticed some changes to the contract json files. aren't these automatically generated? should we maybe skip the linting on these?

Are you talking about the files under src/contracts. If so, yes, we could ignore them but here is my point of view. If we ignore them, the user is entitled to paste there any valid JSON, while in this way, we are enforcing formatting rules each time they change, so they will be consistent among each other and over time.

fair enough 🤝

  • there are some console errors when running the dapp that we've been ignoring up until now, and i am wondering whether we can fix them now (if not, leave them for a later PR). these are:
    4.1 The stylesheet http://localhost:3000/css/style.css was not loaded because its MIME type, “text/html”, is not “text/css” when starting the dapp
    4.2 Uncaught TypeError: document.getElementById(...) is null when displaying the deploy wallet popup
    4.3 a similar error when displaying the transfer popup

I'd glad to tackle these issues after merging this PR, but at the moment I see different errors on the browser console:

materialize.js:2990 Uncaught TypeError: Cannot read properties of null (reading 'M_Modal')
    at HTMLBodyElement._handleTriggerClick (materialize.js:2990:63)

However I think they may be related since they appear each time I open a popup (either a deploy or a transfer or a execute)

yes, i've seen that one too.

could you please verify that you are able to execute transfers successfully? if so i will double check my steps.

As discussed, I confirm that I'm able to deploy,transfer and execute successfully. If you still have those errors, let me know and I can investigate on them

running another check now with the correct contracts code 🙃

@antomor
Copy link
Collaborator Author

antomor commented Mar 9, 2022

Thank you for the additional review 🙏🏼

Copy link

@mortelli mortelli left a comment

Choose a reason for hiding this comment

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

running another check now with the correct contracts code 🙃

all seems to be working 👍

@antomor antomor merged commit cf1665b into dev Mar 10, 2022
@antomor antomor deleted the PP-102/ts-lint-prettier branch March 10, 2022 13:28
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