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

feat(trezor): add withdraw eth with trezor #2005

Merged
merged 62 commits into from
Mar 8, 2024

Conversation

dimxy
Copy link
Collaborator

@dimxy dimxy commented Nov 13, 2023

Changes to EVM wallet to enable trezor:

  • pulled trezor emulator support from another PR
  • added platform coin with tokens init code with the Task manager to allow trezor policy to be added
  • added withdraw eth coin with trezor
  • added a test to create withdraw eth transaction with trezor

dimxy added 21 commits December 10, 2023 17:57
… emulator support (via udp), add test config helpers, add layer to connect to Trezor or emulator over usb and udp (cherry-picked cdcb384)
…me, better naming and constraints, thanks to shamardy)
…on-taskman call;
refactor PrivKeyPolicy::Trezor to eliminate unneeded field; 
refactor platform_coin_with_tokens (var names, remove extra bounds);

added test code to withdraw JST token
@dimxy dimxy force-pushed the evm-hd-wallet-trezor branch from 270d9fa to e0a4565 Compare December 10, 2023 13:34
@dimxy dimxy changed the title [draft] add platform coin init via task manager and withdraw eth with trezor feat(trezor): add platform coin init via task manager and withdraw eth with trezor Dec 19, 2023
@dimxy dimxy changed the title feat(trezor): add platform coin init via task manager and withdraw eth with trezor feat(trezor): add withdraw eth with trezor Dec 19, 2023
@shamardy shamardy self-requested a review January 15, 2024 10:07
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the huge work! First review iteration!

mm2src/coins/eth.rs Outdated Show resolved Hide resolved
mm2src/trezor/src/transport/usb.rs Outdated Show resolved Hide resolved
mm2src/trezor/src/transport/usb.rs Outdated Show resolved Hide resolved
mm2src/coins/eth/v2_activation.rs Outdated Show resolved Hide resolved
mm2src/coins/eth/eth_withdraw.rs Outdated Show resolved Hide resolved
@dimxy
Copy link
Collaborator Author

dimxy commented Feb 14, 2024

I hope I fixed review notes above in the last push.
There is still one thing to do: we need to eliminate use of simple ack_all and handle trezor requests for signing eth. (I have already done this for utxo, not it's time for eth)

* evm-hd-wallet: (27 commits)
  Fix todo comments
  Fix HDAddressOps::Address trait bounds
  fix(indexeddb): fix IDB cursor.continue_() call after drop (#2028)
  security bump for `h2` (#2062)
  fix(makerbot): allow more than one prices url in makerbot (#2027)
  fix(wasm worker env): refactor direct usage of `window` (#1953)
  feat(nft): nft abi in withdraw_nft RPC, clear_nft_db RPC (#2039)
  refactor(utxo): refactor utxo output script creation (#1960)
  feat(ETH): balance event streaming for ETH (#2041)
  chore(release): bump mm2 version to 2.1.0-beta (#2044)
  feat(trezor): add segwit support for withdraw with trezor (#1984)
  chore(config): remove vscode launchjson (#2040)
  feat(trading-proto-upgrade): wasm DB, kickstart, refund states, v2 RPCs (#2015)
  feat(UTXO): balance event streaming for Electrum clients (#2013)
  feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins (#1930)
  fix(p2p): handle encode_and_sign errors (#2038)
  chore(release): add changelog entries for v2.0.0-beta (#2037)
  chore(network): write network information to stdout (#2034)
  fix(price_endpoints): add cached url (#2032)
  deps(network): sync with upstream yamux (#2030)
  ...
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Next review iteration!

mm2src/coins/eth/eth_withdraw.rs Outdated Show resolved Hide resolved
mm2src/coins/eth/eth_withdraw.rs Outdated Show resolved Hide resolved
mm2src/coins/eth/eth_withdraw.rs Show resolved Hide resolved
mm2src/coins/eth.rs Outdated Show resolved Hide resolved
mm2src/coins/eth.rs Outdated Show resolved Hide resolved
add wasm_test_withdraw_eth test
move eth test coin creators in for_test mod for use in wasm
Copy link
Collaborator

@shamardy shamardy left a comment

Choose a reason for hiding this comment

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

Just some questions before finalizing and merging this PR!

Comment on lines +46 to +54
/// Get external token definition by token contract address and chain id
/// check this doc how to find token definition files https://docs.trezor.io/trezor-firmware/common/ethereum-definitions.html
#[allow(dead_code)]
fn get_eth_token_def(address_bytes: &[u8], chain_id: ChainId) -> Option<Vec<u8>> {
ETH_TOKEN_DEFS
.iter()
.find(|(address, def)| address == &&address_bytes && def.0 == chain_id)
.map(|found| found.1 .1.to_vec())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Collaborator Author

@dimxy dimxy Mar 5, 2024

Choose a reason for hiding this comment

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

this is needed to show the chain name on the device display (when it asks for signing confirmation)
(they support couple test chains internally and I just added sepolia)

// if we have it, pass network or token definition info to show on the device screen:
let eth_defs = proto_ethereum_definitions::EthereumDefinitions {
encoded_network: get_eth_network_def(chain_id),
encoded_token: None, // TODO add looking for tokens defs
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please explain this todo in more details?

Copy link
Collaborator Author

@dimxy dimxy Mar 5, 2024

Choose a reason for hiding this comment

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

they support a list of tokens embedded into the firmware (this allows to show token name on the display, when confirming).
We can put additional tokens here (but only if they have their definitions on their website, bcz definitions are signed with trezor key).
maybe now it's time to look for such tokens?

mm2src/coins_activation/src/platform_coin_with_tokens.rs Outdated Show resolved Hide resolved
@shamardy shamardy merged commit 4ca5491 into evm-hd-wallet Mar 8, 2024
22 of 29 checks passed
@shamardy shamardy deleted the evm-hd-wallet-trezor branch March 8, 2024 14:31
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