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

Add eth_signTransaction and eth_sendRawTransaction #16247

Merged
merged 7 commits into from
Dec 8, 2022
Merged

Conversation

darkdh
Copy link
Member

@darkdh darkdh commented Dec 6, 2022

Resolves brave/brave-browser#23582

  1. Add eth_sendRawTransaction which doesn't need confirmation like MetaMask because it doesn't have account actions
  2. Add eth_signTransaction by adding additional signOnly and signedTransaction passed along with eth_sendTransaction code flow
  3. Use idl for transaction request params parsing
  4. Introduce a new state "Signed" which indicates the transaction is signed but not submitted. When we confirm that dapps has broadcast it into blocks, it will be moved to "Confirmed" state. "Signed" transaction won't be taken into account when calculating nonce and it will be dropped when its nonce became too low.
  5. Confirmation panel is same as same transaction but post confirmation panel is different

Screen Shot 2022-12-01 at 17 53 49

Submitter Checklist:

eth_signTransaction is basically same as eth_sendTransaction but without sending. And eth_sendRawTransaction is just forwarding request to rpc endpoint without account involved

  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Normal flow

  1. Setup wallet
  2. Setup https://github.com/bbondy/eth-manual-tests
  3. Change to any test network and visit http://localhost:8081/request.html
  4. Click ethereum.enable and grant permission
  5. Fill to address next to eth_signTransaction and click it
  6. Check transactions on brave://wallet/crypto/portfolio/ETH and there should be a "Signed" transaction
  7. Go back to the console of http://localhost:8081/request.html
  8. Paste the return signed transaction in console to eth_sendRawTransaction and click
  9. Check transactions on brave://wallet/crypto/portfolio/ETH and previously "Signed" transaction should be "Confirmed" after a while

Nonce drop

  1. Setup wallet
  2. Setup https://github.com/bbondy/eth-manual-tests
  3. Change to any test network and visit http://localhost:8081/request.html
  4. Click ethereum.enable and grant permission
  5. Fill to address next to eth_signTransaction and click it
  6. Fill to address next to eth_signTransaction (1559) and click it
  7. Check transactions on brave://wallet/crypto/portfolio/ETH and there should be TWO "Signed" transactions
  8. Go back to the console of http://localhost:8081/request.html
  9. Paste one of the return signed transactions in console to eth_sendRawTransaction and click
  10. Check transactions on brave://wallet/crypto/portfolio/ETH and previously one "Signed" transaction should be "Confirmed" and one "Signed" transaction should be deleted after a while

@darkdh darkdh requested a review from bbondy December 6, 2022 02:14
@darkdh darkdh requested a review from a team as a code owner December 6, 2022 02:14
@darkdh darkdh self-assigned this Dec 6, 2022
@darkdh darkdh requested review from a team as code owners December 6, 2022 02:14
@github-actions github-actions bot added CI/run-audit-deps Check for known npm/cargo vulnerabilities (audit_deps) CI/storybook-url Deploy storybook and provide a unique URL for each build labels Dec 6, 2022
@darkdh darkdh force-pushed the eth_sign_transaction branch 2 times, most recently from f151950 to 628422f Compare December 6, 2022 18:45
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@darkdh darkdh force-pushed the eth_sign_transaction branch from 628422f to b134c0f Compare December 6, 2022 19:43
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@darkdh darkdh force-pushed the eth_sign_transaction branch from 8dac776 to 1602724 Compare December 6, 2022 21:16
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

Copy link
Contributor

@wchen342 wchen342 left a comment

Choose a reason for hiding this comment

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

++

Copy link
Member

@bbondy bbondy 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, just some questions and a minor text correction.

@@ -510,6 +511,8 @@
<message name="IDS_BRAVE_WALLET_ACCOUNT_FILTER_ALL_ACCOUNTS" desc="Account Filter Selector All Accounts">All Accounts</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_SUBMITTED_TITLE" desc="Transaction submitted title">Transaction submitted</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_SUBMITTED_DESCRIPTION" desc="Transaction submitted description">Transaction has been successfully sent to the network and awaits confirmation.</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_SIGNED_TITLE" desc="Transaction signed title">Transaction signed</message>
<message name="IDS_BRAVE_WALLET_TRANSACTION_SIGNED_DESCRIPTION" desc="Transaction signed description">Transaction has been signed and will be sent to network by dapps and awaits confirmation</message>
Copy link
Member

Choose a reason for hiding this comment

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

The transaction has been signed and will be sent to the network by the DApp

@@ -982,7 +984,8 @@ enum TransactionStatus {
Submitted = 3,
Confirmed = 4,
Error = 5,
Dropped = 6
Dropped = 6,
Signed = 7 // dapps will submit the transaction
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be flagged to iOS or Android for handling in any switches?For Android is there anything in this PR that is needed?

Copy link
Member

Choose a reason for hiding this comment

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

For Desktop, do we need anything in any of these which have other switch cases?

  • components/brave_wallet_ui/components/shared/style.tsx
  • components/brave_wallet_ui/components/extension/confirm-transaction-panel/confirm-solana-transaction-panel.tsx
  • components/brave_wallet_ui/components/desktop/portfolio-transaction-item/index.tsx (You have one covered in this file but there's another place)

I just did git grep \\.Dropped to get this list.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, iOS and Android need to handle the new tx status on UI. cc @SergeyZhukovsky @StephenHeaps.
git grep TransactionStatus\\. is more precise so you can see what is being used on Android.
I will check desktop UI for missing parts.

Copy link
Member Author

@darkdh darkdh Dec 7, 2022

Choose a reason for hiding this comment

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

I don't see other changes needed on desktop UI except components/brave_wallet_ui/components/shared/style.tsx to update its opacity

Copy link
Member Author

Choose a reason for hiding this comment

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

I will open two issues for iOS and Android as follow-up

Copy link
Member Author

Choose a reason for hiding this comment

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

@darkdh darkdh force-pushed the eth_sign_transaction branch from 8980246 to bc1a0fe Compare December 7, 2022 20:24
@darkdh darkdh removed the request for review from a team December 7, 2022 20:25
@darkdh darkdh force-pushed the eth_sign_transaction branch from bc1a0fe to 8be035a Compare December 7, 2022 20:29
@darkdh darkdh force-pushed the eth_sign_transaction branch from 8be035a to bb75b2c Compare December 7, 2022 20:33
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@darkdh darkdh merged commit 85227ab into master Dec 8, 2022
@darkdh darkdh deleted the eth_sign_transaction branch December 8, 2022 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-audit-deps Check for known npm/cargo vulnerabilities (audit_deps) CI/storybook-url Deploy storybook and provide a unique URL for each build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support eth_signTransaction and eth_sendRawTransaction
4 participants