Near-One / rainbow-token-connector

ERC-20/NEP-141 Token Connector for Rainbow Bridge
62 stars 18 forks source link

Bridge transfers support for accounts secured with Ledger #48

Open alexauroradev opened 3 years ago

alexauroradev commented 3 years ago

At the moment accounts secured with Ledger (at least Ledger Nano S) are not able to receive transfers because of the low amount of RAM in Ledger. Deposit transaction has quite a large input (see an example here), that won't able to fit into the device.

Here're screenshots of the wallet behaviour in this case:

Screenshot 2021-03-18 at 16 15 02 Screenshot 2021-03-18 at 16 15 13

In NEAR -> Ethereum transfers, Metamask & LedgerApp use the following flow:

The issue is fundamental and cannot be solved on the level of the NEAR Wallet / Metamask, smart contract interface changes should be applied to reduce the size of the parameters.

Potential ways of solving the problem

  1. Change the proofs in deposit and unlockToken methods into their hashes. Add additional methods for recording proofs. In this case any 3rd party account will be able to submit proof, while the user will only do the withdrawal. deposit and unlockToken will take additional funds from the user, which will be sent to the account that submitted the proof to pay for his transaction.
  2. On NEAR side there's an ability to create an additional multisig contract, that works as following: the app-specific key submits the request with a proof. User Ledger key confirms the request. Same payment logic is applicable in this case.
alexauroradev commented 3 years ago

According to the logic of the deposit transaction, it can be called by any account in NEAR, not only by the recipient account. This allows Ledger users in the bridge FE to login using different account and finalise the transfer. Thus, the funds will never be in non-Ledger-protected wallet. However, the need for re-login is cumbersome. Also, at the moment it requires to register additional keys.

mfornet commented 3 years ago

Related issue in near-cli: https://github.com/near/near-cli/issues/612