Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

6.22.x

Compare
Choose a tag to compare
@gre gre released this 06 Jan 16:57
· 102 commits to master since this release
753cf3f

Rework hw-app-eth to split out "ledger services" from the app logic #747

eth.signTransaction(path, txHex)

becomes deprecated in favor of

eth.signTransaction(path, txHex, resolution)

where resolution is an object with following shape:

{
  erc20Tokens: Array<string>;
  nfts: Array<string>;
  externalPlugin: Array<{ payload: string; signature: string }>;
  plugin: Array<string>;
}

This object contains all the hex serialized data the device may need to clear sign information on device screen.

Hopefully we also provide a default "service" to resolve this data, example:

import ledgerService from "@ledgerhq/hw-app-eth/lib/services/ledger"
async function main() {
  ...
  const resolution = await ledgerService.resolveTransaction(txHex, loadConfig, resolutionConfig)
    .catch(() => null); // <-- up to you if you want a fallback to blind sign. (which was previous behavior)
   const result = eth.signTransaction("44'/60'/0'/0/0", txHex, resolution);
}

This allows us to decouple the transaction resolution from the device signature logic itself in order for you to have better control and for more usecases

  • an alternative service (rather than Ledger's) could be used.
  • we plan to make even more things dynamic, typically the way we load and resolve ERC20 and plugins are too monolithic. This rework pave the path to allow this even more easily.
  • you may want to load the resolve data way ahead in your "validation process" and typically inform the user if an error occurs before it reach the device phase.
  • you may want a finer control weither you allow blind sign or not. Typically, you may or may not use .catch(() => null) in the snippet above

loadConfig

loadConfig is a configuration file that allows to configure what endpoints are used for the resolution mecanism.

NFT resolution is not yet active in this current version but will be soon. That said, you need to explicitly request it in resolutionConfig.

you can set {} object and it will be fallback to default values.

resolutionConfig

This is an object that specifies what need to be resolved, if any.

Here are all the possible flag to set at the moment:

{ nft: true, externalPlugins: true, erc20: true }

you can just { erc20: true } if you just need to resolve ERC20 token signature. It gives context for the resolver to do the minimum.

You can also see:

  • nft: is the mecanics to do clear signing. (it is not yet active, unless you set the correct loadConfig API)
  • externalPlugins: is the plugin mecanics (e.g. LIDO) to see what you sign in Ledger Live apps.

New libraries in ledgerjs

  • LL-8827 Introduce types libraries (#748)
  • Add Speculos Http API transport (#746) thanks @r4mmer

Others

  • Update ERC20 list – LL-8868
  • fix: cryptoassets exchange erc20 & coins import names (#752)