Skip to content

Conversation

@danjm
Copy link
Contributor

@danjm danjm commented Aug 3, 2022

Fixes: #15413

The problem was that we were representing a contract interaction as a simple send when first arriving at the confirm screen. The solution is to ensure that if we are sending to a contract address, we apply the contract interaction type to the transaction when creating it from the send screen.

Some other changes were needed to get this fully working:

  • added TRANSACTION_TYPES.CONTRACT_INTERACTION as a valid transaction type when adding a new unapproved transaction
  • added a suffix to the currency display on the confirm screen if it is a contract interaction and no eth logo is being shown, so that the user has the information they need about what value would be sent to the contract
  • fixed the isSmartContractAddress function which was previously broken because it was attempting to get the wrong property from the result of readAddressAsContract()

Before:

after-aug3-1250.mp4

After:

after-aug3-1246.mp4

@danjm danjm requested a review from a team as a code owner August 3, 2022 15:16
@danjm danjm requested a review from ryanml August 3, 2022 15:16
@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@danjm danjm added this to the v10.18.2 milestone Aug 3, 2022
Comment on lines +50 to +53
const RECIPIENT_TYPES = {
SMART_CONTRACT: 'SMART_CONTRACT',
NON_CONTRACT: 'NON_CONTRACT',
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Love this.

brad-decker
brad-decker previously approved these changes Aug 3, 2022
Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

Good work!

@metamaskbot
Copy link
Collaborator

Builds ready [158e2ec]
Page Load Metrics (1693 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint892031152713
domContentLoaded15411946168111354
load15411964169311555
domInteractive15411946168111354

highlights:

storybook

brad-decker
brad-decker previously approved these changes Aug 3, 2022
Comment on lines 1889 to 1892
if (smartContractAddress) {
dispatch(actions.updateRecipientType(RECIPIENT_TYPES.SMART_CONTRACT));
}
if (smartContractAddress) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason you made a new if (smartContractAddress) conditional? The same if statement is right below on line 1892?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

uh, no... I originally had this outside the if block two lines above, and then copy pasted it to here, will refactor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed in latest commit

useTokenDetection,
tokenAddressList,
isProbablyAnAssetContract,
smartContractAddress,
Copy link
Contributor

Choose a reason for hiding this comment

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

is this being used? Sorry If I'm missing it? validateRecipientUserInput doesn't appear to make use of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, will remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed


const inputIsValidHexAddress = isValidHexAddress(userInput);
let isProbablyAnAssetContract = false;
let smartContractAddress;
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is not longer passed to the validation method this can go back to being a const inside the if (inputIsValidHexAddress) { conditional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

linting should tell me this stuff

adonesky1
adonesky1 previously approved these changes Aug 3, 2022
Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

Not a blocker since we're trying to get this out the door but lets note that we should make test cases for this?

@danjm
Copy link
Contributor Author

danjm commented Aug 3, 2022

Not a blocker since we're trying to get this out the door but lets note that we should make test cases for this?

Absolutely. I am preparing tests for PRs I have merged over the past couple of day, and will submit another PR for those

brad-decker
brad-decker previously approved these changes Aug 3, 2022
@danjm danjm dismissed stale reviews from brad-decker and adonesky1 via a3e5d45 August 3, 2022 18:40
@metamaskbot
Copy link
Collaborator

Builds ready [a3e5d45]
Page Load Metrics (1711 ± 57 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint943021194421
domContentLoaded15632029169012158
load15692029171111857
domInteractive15632029169012158

highlights:

storybook

@danjm danjm merged commit 6602e4a into develop Aug 3, 2022
@danjm danjm deleted the fix-contract-confirm-representation branch August 3, 2022 19:35
@github-actions github-actions bot locked and limited conversation to collaborators Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Send Amount disappears on Edit Send tx to a Contract

5 participants