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

new module for ledger related utils #193

Merged
merged 6 commits into from
Aug 21, 2024
Merged

Conversation

dssei
Copy link
Contributor

@dssei dssei commented Aug 16, 2024

Helper methods for working with ledger hardware wallet on Sei

  • the current version includes methods of signature conversion to make it possible to work with Stargate client.

Testing

  • tested library by creating a new app and using the helper methos

Copy link

changeset-bot bot commented Aug 16, 2024

🦋 Changeset detected

Latest commit: 4749846

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sei-js/ledger Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.47%. Comparing base (35c62d0) to head (4749846).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #193   +/-   ##
=======================================
  Coverage   84.47%   84.47%           
=======================================
  Files          16       16           
  Lines         161      161           
  Branches       25       25           
=======================================
  Hits          136      136           
  Misses         25       25           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dssei dssei marked this pull request as ready for review August 19, 2024 22:31
@dssei dssei self-assigned this Aug 19, 2024
};

const signDoc = createSignDoc(aminoMsg, fee, chainId, memo, account);
const broadcastResponse = await signAndBroadcast(app, path, signDoc, client, nativeAddress);
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of adding a signAndBroadcast helper, can we create an offline signer that can be plugged into SigningStargateClient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, attempted refactoring

* @param memo transaction memo
* @param account account
*/
export const createSignDoc = (aminoMsg: AminoMsg, fee: StdFee, chainId: string, memo: string, account: Account) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

can aminoMsg be extended to be a list of messages in case a user wants to sign multiple messages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With latest refactoring, might be obsolete

@dssei
Copy link
Contributor Author

dssei commented Aug 20, 2024

@besated Switched to offline signer, but am not sure about implementation. Please have a look

/**
* A signer implementation that uses a Ledger device to sign transactions
*/
export class LedgerOfflineAminoSigner implements OfflineAminoSigner {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, this is great! should we name this SeiLedgerOfflineAminoSigner so it's more specific?

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

*
* @returns {Promise<{transport: Transport, app: SeiApp}>} transport and app instances
*/
export const createTransportAndApp = async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we keep this in the utils.ts file and move LedgerOfflineAminoSigner into another file to make it cleaner (maybe called signer.ts)?

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

@dssei
Copy link
Contributor Author

dssei commented Aug 21, 2024

@besated addressed the latest comment, ptal

@dssei dssei merged commit c0cd7a0 into main Aug 21, 2024
2 checks passed
@dssei dssei deleted the feature/ledger_helper_functions branch August 21, 2024 18:08
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.

3 participants