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

Fix RSK EIP1191 checksum issues #4151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

7alip
Copy link

@7alip 7alip commented Sep 30, 2021

Description

I created new PR according to requesting changes in #4139

Changes

  • Renamed isValidETHRecipientAddress with isValidRecipientAddress which now takes chainId parameter.
  • Removed unnecessary network state and updated schema validation.
  • Added network parameter to TO_FIELD_ERROR translation.
  • Reverted changes in providerHandler to find a better solution.

This changes are supposed to fix checksum errors in the following scenarios:

  • Send Asset through RSK and RSK Testnet networks and
  • In Settings add RSK and RSK Testnet addresses to Address Book

Issues

There are more scenarios where EIP1191 checksum validation needs to be fixed.

  • Interact with Contracts
  • Add Custom Token

We discussed for the better solution as to have support for it in Ethers.js.

@7alip 7alip changed the title Fix RSK EIP1101 checksum issues Fix RSK EIP1191 checksum issues Sep 30, 2021
@@ -154,7 +155,7 @@ const FormSchema = object().shape({
address: object({
value: string().test(
'check-eth-address',
translateRaw('TO_FIELD_ERROR'),
translateRaw('TO_FIELD_ERROR', { $network: DEFAULT_NETWORK }),
Copy link
Author

@7alip 7alip Sep 30, 2021

Choose a reason for hiding this comment

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

I provided network to avoid it to be displayed as Enter a valid $network address, ENS name, or blockchain domain

Copy link
Collaborator

Choose a reason for hiding this comment

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

Couldn't you move the schema inside the component so it can access the network prop and use that instead?

@FrederikBolding
Copy link
Collaborator

/ok-to-test

@codecov
Copy link

codecov bot commented Oct 4, 2021

Codecov Report

Merging #4151 (2a0fed9) into master (56f7210) will decrease coverage by 0.01%.
The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4151      +/-   ##
==========================================
- Coverage   77.43%   77.42%   -0.02%     
==========================================
  Files         551      551              
  Lines       12016    12018       +2     
  Branches     3197     3197              
==========================================
  Hits         9305     9305              
- Misses       2678     2680       +2     
  Partials       33       33              
Impacted Files Coverage Δ
...ures/InteractWithContracts/components/Interact.tsx 69.00% <ø> (ø)
.../features/Settings/components/AddToAddressBook.tsx 15.15% <0.00%> (-0.98%) ⬇️
src/components/GeneralLookupField.tsx 89.01% <100.00%> (ø)
.../features/SendAssets/components/SendAssetsForm.tsx 77.17% <100.00%> (+0.09%) ⬆️
src/services/EthService/validators.ts 95.93% <100.00%> (+0.12%) ⬆️
src/features/Faucet/helpers.tsx 100.00% <0.00%> (ø)
.../features/Dashboard/components/MembershipPanel.tsx 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 56f7210...2a0fed9. Read the comment docs.

@FrederikBolding
Copy link
Collaborator

[sc-7907]

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #7907: Fix address validation for RSK network in custom token form.

Copy link
Collaborator

@FrederikBolding FrederikBolding left a comment

Choose a reason for hiding this comment

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

Looks good - a few small comments!

address: string,
resolutionErr: ResolutionError | undefined
resolutionErr: ResolutionError | undefined,
network: Network = NETWORKS_CONFIG.Ethereum
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would prefer having network be undefined by default here. You can use ?? DEFAULT_NETWORK in cases where it is undefined. NETWORK_CONFIG is not the correct type.

@@ -154,7 +155,7 @@ const FormSchema = object().shape({
address: object({
value: string().test(
'check-eth-address',
translateRaw('TO_FIELD_ERROR'),
translateRaw('TO_FIELD_ERROR', { $network: DEFAULT_NETWORK }),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Couldn't you move the schema inside the component so it can access the network prop and use that instead?

schema.test('valid', translateRaw('TO_FIELD_ERROR', { $network: network.name }), function (
value
) {
return value && value.value && isValidAddress(value.value, network.chainId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks to work, but I am not sure it will be possible to send without fixing the issues in Ethers. Balance scanning etc seems to be failing on RSK right now. Have you talked to ricmoo or is there an open issue?

@stale
Copy link

stale bot commented Dec 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 3, 2021
@FrederikBolding
Copy link
Collaborator

Don't close. @7alip have you looked more at this?

@stale stale bot removed the wontfix label Dec 3, 2021
@stale
Copy link

stale bot commented Feb 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Feb 2, 2022
@stale
Copy link

stale bot commented Apr 6, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 6, 2022
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.

None yet

2 participants