Creit-Tech / Stellar-Wallets-Kit

A kit to handle all Stellar Wallets at once with a simple API
https://stellarwalletskit.dev
MIT License
36 stars 20 forks source link

Add Trezor Wallet connection #11

Open earrietadev opened 10 months ago

NueloSE commented 5 months ago

@earrietadev can I be assigned this task

lauchaves commented 5 months ago

Hey @earrietadev ! I'm Lau Chaves, I would like to contribute on this one! I think this might take me 2-5 days to completed. I have over 5 years of experience working with react,ts... this is my first OD Hack! So I'm pretty excited about it!

here's my onlydust profile https://app.onlydust.com/u/lauchaves not so much there since I'm starting in this world but here's my git as well https://github.com/lauchaves

lauchaves commented 5 months ago

Hey! @earrietadev, I'll give you a heads-up if I come across any issues. Thanks!

ktarun1419 commented 4 months ago

Hi @earrietadev i want to work on this issue

lauchaves commented 4 months ago

@earrietadev hey πŸ‘‹ ! I have a couple of questions...

Regarding the signTx method, I noticed that the Trezor wallet's signTransaction method requires specifying a coin. Do we need to specify one? In my review of other wallet integrations, they do not require specifying a coin, and also that method doesn’t have a transaction parameter for the transaction: params.xdr like the other wallets.

Additionally, I found another Trezor method called stellarSignTransaction, which accepts a transaction directly instead of an XDR string,

the transaction for stellar approach should be something like this: image which is close to what is intended but no the same, idk if there's a way to decode the XDR

Given this, do we need to refactor our approach to match any of those methods?

Lastly, I tried to run the Stellar Wallet Kits on a simple project but had no luck. Is there a specific Node.js or TypeScript version required? I encountered errors related to TypeScript and ESM. Even after installing the necessary packages, it still didn't work. Is there another workaround to get it running, or might I be missing something? I followed the steps in the README.

btw is there a Discord or Telegram group chat for support, or is it okay to ask questions here on GitHub? πŸ˜„

earrietadev commented 4 months ago

Hi @lauchaves it's ok to ask questions here,

I encountered errors related to TypeScript and ESM

You can try with the latest version, the kit is intended to be used in ES Module environment but I've seen some users asking for it to work on CommonJS workspaces too so I added the support for that.

Additionally, I found another Trezor method called stellarSignTransaction, which accepts a transaction directly instead of an XDR string

Most likely this will be the approach, and yeah Trezor requires the XDR to be parsed in their own way. You will need to include the Stellar SDK library into the kit and decode the XDR into a Stellar Transaction so you can then parse it in the way Trezor requires it.

Also, make sure to use the extended versions of the Trezor libraries... That's where they put all the utils when handling Stellar transactions (not sure why but the Trezor team is not that quick when it comes to Stellar compatibility)

lauchaves commented 4 months ago

Hey πŸ‘‹ @earrietadev Im still having issues testing it, I got the Trezor integration ready to test it... (I can open the PR in the meantime If you would like to go ahead and do some code review)

I tried with type: "module", es6 and even commonjs still no luck :c

I'm getting image

I tried installing esm package as well didn't work either

earrietadev commented 4 months ago

@lauchaves make sure your bundle is importing all the dependencies correctly. The kit works with Angular, React, Vue, Svelte and others.

If you're not sure if your bundle is correctly importing everything, you can create a blank React project with npx create-react-app my-app or a blank Angular app, they will import everything correctly

lauchaves commented 4 months ago

@earrietadev got it πŸš€ thanks! will test it now!

lauchaves commented 4 months ago

Hey @earrietadev, I just open a PR for this!

Deepakraja03 commented 1 week ago

Can I take this issue?

joaquinsoza commented 1 day ago

Here is a sample implementation ive been working on to implement trezor on a extension, maybe u could take ideas from here, there is also the stellar Account viewer that has an implementation for trezor https://github.com/joaquinsoza/trezor-link

earrietadev commented 1 day ago

Hi @joaquinsoza thanks for sharing it, I will be looking at it later. I've already implemented Trezor in extensions and websites (xBull Wallet has been supporting Trezor for a couple of years already).

Currently the issue with hardware wallets libraries are the dependencies instead of the integration itself, I'm trying to keep the kit as dependency clean as possible while for example the Ledger USB transport library tries to use NodeJS specific features like the Native Buffer module.