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

Update gh-pages to receive chainId, update Ledger library to 6.5.0 #95

Merged
merged 9 commits into from
Aug 30, 2021

Conversation

darkwing
Copy link
Contributor

@darkwing darkwing commented Aug 16, 2021

It's been requested that we update to 6.5.0 to fix Ledger issues with Palm. This PR:

  • Updates to 6.5.0 of the core Ledger library for the gh-pages branch
  • Receives the chainId from the eth-ledger-bridge-keyring package, since this version has a breaking change that sees byContractAddress become byContractAddressAndChainId.
  • removes the call to provideERC20TokenInformation as it is no longer needed, after v5.52.0

edited by Dan M on Aug 26

ledger-bridge.js Outdated Show resolved Hide resolved
ledger-bridge.js Outdated
if (to) {
const isKnownERC20Token = byContractAddress(to)
if (to && chainId) {
const isKnownERC20Token = byContractAddressAndChainId(to, chainId)
if (isKnownERC20Token) await this.app.provideERC20TokenInformation(isKnownERC20Token)
Copy link
Member

Choose a reason for hiding this comment

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

Apparently we don't need to call this anymore, as of v5.52.0? https://github.com/LedgerHQ/ledgerjs/releases/tag/v5.52.0
I'm not 100% sure though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can confirm that we do not need this any more. The PR where this was fixed was:

LedgerHQ/ledgerjs#587

The provideERC20TokenInformation method had the description:

  • This commands provides a trusted description of an ERC 20 token
  • to associate a contract address with a ticker and number of decimals.
  • It shall be run immediately before performing a transaction involving a contract
  • calling this contract address to display the proper token information to the user if necessary.

The PR made a change so that the method is run before every transaction: https://github.com/LedgerHQ/ledgerjs/pull/587/files#diff-2a96855bc41e2457f03a382c30057bb9257533493bad6acba9730305db50dd60R252-R279

Meanwhile, the need to get the chainId is also covered by that library internally. It gets the chainId from the transaction data: https://github.com/LedgerHQ/ledgerjs/pull/647/files#diff-d69d98013c437f5ecea9591706f3c1319cfa49c1ec50130f8a6346291517ba3dL229

Finally, I tested ERC20 token sends with ledger + metamask + this current branch of github pages, and it works the same as prod today, with the token symbol displaying on the device.

@danjm
Copy link
Contributor

danjm commented Aug 18, 2021

So no changes to ledger-bridge.js are needed?

@darkwing
Copy link
Contributor Author

Right

@darkwing
Copy link
Contributor Author

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

I did not review the diff of the package-lock.json files and bundle.js files

I did verify that the same diff (in terms of line count) is produced when I build locally

I did review the ledgerjs changelog to see that this change is safe

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

this needs changes actually

@danjm danjm mentioned this pull request Aug 25, 2021
Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

We should get another review because I ended up authoring a chunk of this PR, but I'm removing my requested change

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

It looks like the lockfile and the bundle require updating. When I checkout this branch and run npm install, the package-lock.json file changes. Then when I run npm run build, the bundle changes.

@danjm
Copy link
Contributor

danjm commented Aug 26, 2021

@Gudahtt Interesting. I run:
rm -rf node_modules
npm install
npm run build

There are no changes in git.

What versions of npm and node are you on?

@@ -1,13 +1,11349 @@
{
"name": "gupltest",
"version": "0.0.0",
"lockfileVersion": 1,
"lockfileVersion": 2,
Copy link
Member

Choose a reason for hiding this comment

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

Ah, this is the issue. You must be using npm v7 - previously this repo was using v6 (which is what I was using).

v7 is fine but we should bump the npm version in the engines field at least, so this mistake can be prevented.

@danjm danjm changed the title Update gh-pages to receive chainId, update Ledger library to 6.4.1 Update gh-pages to receive chainId, update Ledger library to 6.5.0 Aug 26, 2021
@Gudahtt
Copy link
Member

Gudahtt commented Aug 26, 2021

The lockfile is still dirty, because the new engines field gets copied into the lockfile 😅

ledger-bridge.js Outdated
@@ -143,10 +142,6 @@ export default class LedgerBridge {
async signTransaction (replyAction, hdPath, tx, to) {
Copy link
Member

Choose a reason for hiding this comment

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

The to parameter is now unused

Copy link
Contributor

Choose a reason for hiding this comment

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

Removed in 231bd5d

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

danjm added a commit that referenced this pull request Aug 27, 2021
danjm added a commit that referenced this pull request Aug 27, 2021
… signTransaction (#98)

* Safe property access / allow transaction with undefined to fields, in signTransaction

* Revert "Safe property access / allow transaction with undefined to fields, in signTransaction"

This reverts commit 3c148ba.

* Remove passage of to param to ledger bridge, which will not be needed after PR #95
@adonesky1 adonesky1 merged commit 74a0747 into MetaMask:gh-pages Aug 30, 2021
@adonesky1 adonesky1 mentioned this pull request Aug 31, 2021
@pscott
Copy link

pscott commented Sep 9, 2021

Thanks for your work! I think #90 can be closed now!

However I would like to point out that Ledgerjs recently released v6.6.0. This release fixes an important bug that prevented ERC20 token information to get passed to the device when using EIP1559 typed transactions (type 2). This means that currently, users sending EIP1559 transactions will be blind-signing rather than seing exactly which token is being transfered.

Bumping this version does not introduce any breaking changes, and would benefit the whole ecosystem, hence this message!

Thank you!

julianariel pushed a commit to block-wallet/eth-ledger-bridge-keyring that referenced this pull request Apr 27, 2022
… signTransaction (MetaMask#98)

* Safe property access / allow transaction with undefined to fields, in signTransaction

* Revert "Safe property access / allow transaction with undefined to fields, in signTransaction"

This reverts commit 3c148ba.

* Remove passage of to param to ledger bridge, which will not be needed after PR MetaMask#95
Akaryatrh pushed a commit to MetaMask/ledger-iframe-bridge that referenced this pull request Dec 13, 2024
…etaMask#95)

* Update gh-pages to receive chainId, update Ledger library to 6.4.1

* Add safety so that old and new lookup work properly

* Address feedback: check for chainId

* Pin to specific version to avoid semver issues

* v6.5.0 bycontractaddress removal

* Removed unused import

* Specificy npm v7.6.1 in engines property of package.json

* Update lockfile

* Remove unused parameter from signTransaction in ledger-bridge

Co-authored-by: Dan Miller <[email protected]>
Co-authored-by: Mark Stacey <[email protected]>
Akaryatrh pushed a commit to MetaMask/ledger-iframe-bridge that referenced this pull request Dec 13, 2024
…etaMask#95)

* Update gh-pages to receive chainId, update Ledger library to 6.4.1

* Add safety so that old and new lookup work properly

* Address feedback: check for chainId

* Pin to specific version to avoid semver issues

* v6.5.0 bycontractaddress removal

* Removed unused import

* Specificy npm v7.6.1 in engines property of package.json

* Update lockfile

* Remove unused parameter from signTransaction in ledger-bridge

Co-authored-by: Dan Miller <[email protected]>
Co-authored-by: Mark Stacey <[email protected]>
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.

6 participants