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 ledger sdk and replace webusb with webhid #1434

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .yarn/versions/afe58fcb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
releases:
"@fluent-wallet/cfx_send-transaction": patch
"@fluent-wallet/cfx_sign-transaction": patch
"@fluent-wallet/cfx_sign-tx-with-ledger-nano-s": patch
"@fluent-wallet/eth_send-transaction": patch
"@fluent-wallet/eth_sign-transaction": patch
"@fluent-wallet/eth_sign-tx-with-ledger-nano-s": patch
"@fluent-wallet/ledger": minor
"@fluent-wallet/wallet_import-hardware-wallet-account-group-or-account": patch
"@fluent-wallet/wallet_send-transaction": patch
"@fluent-wallet/wallet_send-transaction-with-action": patch
browser-extension: patch
helios-background: patch
helios-popup: patch

declined:
- helios
22 changes: 15 additions & 7 deletions packages/ledger/conflux.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TransportWebUSB from '@ledgerhq/hw-transport-webusb'
import TransportWebHID from '@ledgerhq/hw-transport-webhid'
import {decode} from '@fluent-wallet/base32-address'
import {LEDGER_APP_NAME, LEDGER_CLA, INS, HDPATH, ERROR} from './const.js'
import {handleName} from './index.js'
Expand All @@ -20,12 +20,17 @@ export default class Conflux {
this.transport = null
}

async createApp(transport) {
const App = await import('@fluent-wallet/hw-app-conflux')
this.app = new App.default(transport)
this.transport = transport
}

async setApp() {
if (!this.app) {
try {
this.transport = await TransportWebUSB.create()
const App = await import('@fluent-wallet/hw-app-conflux')
this.app = new App.default(this.transport)
const transport = await TransportWebHID.create()
await this.createApp(transport)
} catch (error) {
console.warn(error)
}
Expand Down Expand Up @@ -85,7 +90,7 @@ export default class Conflux {
}

async isDeviceAuthed() {
const devices = await TransportWebUSB.list()
const devices = await TransportWebHID.list()
return Boolean(devices.length)
}

Expand Down Expand Up @@ -123,7 +128,10 @@ export default class Conflux {
*/
async requestAuth() {
try {
await TransportWebUSB?.request()
const transport = await TransportWebHID?.request()
if (!this.app) {
await this.createApp(transport)
}
return true
} catch (error) {
return false
Expand Down Expand Up @@ -154,7 +162,7 @@ export default class Conflux {
}

async getDeviceInfo() {
const devices = await TransportWebUSB.list()
const devices = await TransportWebHID.list()
if (devices.length > 0) {
const device = devices[0]
return {
Expand Down
21 changes: 14 additions & 7 deletions packages/ledger/ethereum.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TransportWebUSB from '@ledgerhq/hw-transport-webusb'
import TransportWebHID from '@ledgerhq/hw-transport-webhid'

import {LEDGER_APP_NAME, LEDGER_CLA, INS, HDPATH, ERROR} from './const.js'
import {handleName} from './index.js'
Expand All @@ -19,13 +19,17 @@ export default class Ethereum {
this.app = null
this.transport = null
}
async createApp(transport) {
const App = await import('@ledgerhq/hw-app-eth')
this.app = new App.default(transport)
this.transport = transport
}

async setApp() {
if (!this.app) {
try {
this.transport = await TransportWebUSB.create()
const App = await import('@ledgerhq/hw-app-eth')
this.app = new App.default(this.transport)
const transport = await TransportWebHID.create()
await this.createApp(transport)
} catch (error) {
console.warn(error)
}
Expand Down Expand Up @@ -103,7 +107,7 @@ export default class Ethereum {
}

async isDeviceAuthed() {
const devices = await TransportWebUSB.list()
const devices = await TransportWebHID.list()
return Boolean(devices.length)
}

Expand Down Expand Up @@ -155,7 +159,10 @@ export default class Ethereum {
*/
async requestAuth() {
try {
await TransportWebUSB?.request()
const transport = await TransportWebHID?.request()
if (!this.app) {
await this.createApp(transport)
}
return true
} catch (error) {
return false
Expand Down Expand Up @@ -185,7 +192,7 @@ export default class Ethereum {
}

async getDeviceInfo() {
const devices = await TransportWebUSB.list()
const devices = await TransportWebHID.list()
if (devices.length > 0) {
const device = devices[0]
return {
Expand Down
4 changes: 2 additions & 2 deletions packages/ledger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"version": "0.0.9",
"dependencies": {
"@fluent-wallet/base32-address": "workspace:packages/base32-address",
"@fluent-wallet/hw-app-conflux": "0.0.8",
"@fluent-wallet/hw-app-conflux": "0.1.1",
"@ledgerhq/hw-app-eth": "6.24.1",
"@ledgerhq/hw-transport-webusb": "6.29.2"
"@ledgerhq/hw-transport-webhid": "6.29.4"
}
}
95 changes: 50 additions & 45 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4751,18 +4751,13 @@ __metadata:
languageName: unknown
linkType: soft

"@fluent-wallet/hw-app-conflux@npm:0.0.8":
version: 0.0.8
resolution: "@fluent-wallet/hw-app-conflux@npm:0.0.8"
"@fluent-wallet/hw-app-conflux@npm:0.1.1":
version: 0.1.1
resolution: "@fluent-wallet/hw-app-conflux@npm:0.1.1"
dependencies:
"@ledgerhq/cryptoassets": "npm:^6.18.0"
"@ledgerhq/errors": "npm:^6.10.0"
"@ledgerhq/hw-transport": "npm:^6.11.2"
"@ledgerhq/logs": "npm:^6.10.0"
axios: "npm:^0.24.0"
"@ledgerhq/hw-transport": "npm:^6.31.4"
bip32-path: "npm:^0.4.2"
js-conflux-sdk: "npm:^2.0.7"
checksum: 10/9cbe5af1cd7cc935a7430805d13b6cc28b2e788e861bd7d1a72dc0cd05d3ec19923cab19223388690907f2ccc9da8dd0b73dc29b8f37f5024b36c4bd8a10ebba
checksum: 10/59ad9397b50cc45d9905e8332daae33554c81bd732346c7f513ffc470b8bb60c6af15a9c215f685af0f3c972af82e97fa53e931e497f412f21e9f110303f8d76
languageName: node
linkType: hard

Expand Down Expand Up @@ -4817,9 +4812,9 @@ __metadata:
resolution: "@fluent-wallet/ledger@workspace:packages/ledger"
dependencies:
"@fluent-wallet/base32-address": "workspace:packages/base32-address"
"@fluent-wallet/hw-app-conflux": "npm:0.0.8"
"@fluent-wallet/hw-app-conflux": "npm:0.1.1"
"@ledgerhq/hw-app-eth": "npm:6.24.1"
"@ledgerhq/hw-transport-webusb": "npm:6.29.2"
"@ledgerhq/hw-transport-webhid": "npm:6.29.4"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -6290,7 +6285,7 @@ __metadata:
languageName: node
linkType: hard

"@ledgerhq/cryptoassets@npm:^6.18.0, @ledgerhq/cryptoassets@npm:^6.24.1":
"@ledgerhq/cryptoassets@npm:^6.24.1":
version: 6.37.0
resolution: "@ledgerhq/cryptoassets@npm:6.37.0"
dependencies:
Expand All @@ -6299,7 +6294,7 @@ __metadata:
languageName: node
linkType: hard

"@ledgerhq/devices@npm:^8.4.2, @ledgerhq/devices@npm:^8.4.3":
"@ledgerhq/devices@npm:^8.4.3":
version: 8.4.3
resolution: "@ledgerhq/devices@npm:8.4.3"
dependencies:
Expand All @@ -6311,13 +6306,32 @@ __metadata:
languageName: node
linkType: hard

"@ledgerhq/errors@npm:^6.10.0, @ledgerhq/errors@npm:^6.18.0, @ledgerhq/errors@npm:^6.19.0":
"@ledgerhq/devices@npm:^8.4.4":
version: 8.4.4
resolution: "@ledgerhq/devices@npm:8.4.4"
dependencies:
"@ledgerhq/errors": "npm:^6.19.1"
"@ledgerhq/logs": "npm:^6.12.0"
rxjs: "npm:^7.8.1"
semver: "npm:^7.3.5"
checksum: 10/57136fc45ae2fa42b3cf93eb7cc3542fd84010390b3d0a536d342c7e92f90e475d608b1774f17a547419edddd7df0d0b1b1dbd6d2c778009ebab0fc3ec313f67
languageName: node
linkType: hard

"@ledgerhq/errors@npm:^6.10.0, @ledgerhq/errors@npm:^6.19.0":
version: 6.19.0
resolution: "@ledgerhq/errors@npm:6.19.0"
checksum: 10/944d7a86f4dedd3cac611d704a36667ff66294403ab6e552b8c14ce742574a2b50fa71de89c28827fc442233af68b88ae2971e73cdb03ea98ec4e65239d76d88
languageName: node
linkType: hard

"@ledgerhq/errors@npm:^6.19.1":
version: 6.19.1
resolution: "@ledgerhq/errors@npm:6.19.1"
checksum: 10/8265c6d73c314a4aabbe060ec29e2feebb4e904fe811bf7a9c53cde08e713dcbceded9d927ebb2f0ffc47a7b16524379d4a7e9aa3d61945b8a832be7cd5cf69b
languageName: node
linkType: hard

"@ledgerhq/hw-app-eth@npm:6.24.1":
version: 6.24.1
resolution: "@ledgerhq/hw-app-eth@npm:6.24.1"
Expand All @@ -6334,19 +6348,19 @@ __metadata:
languageName: node
linkType: hard

"@ledgerhq/hw-transport-webusb@npm:6.29.2":
version: 6.29.2
resolution: "@ledgerhq/hw-transport-webusb@npm:6.29.2"
"@ledgerhq/hw-transport-webhid@npm:6.29.4":
version: 6.29.4
resolution: "@ledgerhq/hw-transport-webhid@npm:6.29.4"
dependencies:
"@ledgerhq/devices": "npm:^8.4.2"
"@ledgerhq/errors": "npm:^6.18.0"
"@ledgerhq/hw-transport": "npm:^6.31.2"
"@ledgerhq/devices": "npm:^8.4.4"
"@ledgerhq/errors": "npm:^6.19.1"
"@ledgerhq/hw-transport": "npm:^6.31.4"
"@ledgerhq/logs": "npm:^6.12.0"
checksum: 10/e6548cfa5618b8ae2430b3b6daa504e87b76ba6ec02476a30d1239d68f4347341c43d7673eb279ca114bdec0b9a8fe5541da464be1105cc9282e1d7fc333bf65
checksum: 10/48d4a1e84c268682bf3fa59a2e55b0c771861f7c56a9961d3a7eeb38908cb54cdbfd6f9cb6ab9fa0e4e8c5f603894455c53ee85c186c6c9cb0d62453f2d94cce
languageName: node
linkType: hard

"@ledgerhq/hw-transport@npm:^6.11.2, @ledgerhq/hw-transport@npm:^6.24.1, @ledgerhq/hw-transport@npm:^6.31.2":
"@ledgerhq/hw-transport@npm:^6.24.1":
version: 6.31.3
resolution: "@ledgerhq/hw-transport@npm:6.31.3"
dependencies:
Expand All @@ -6358,6 +6372,18 @@ __metadata:
languageName: node
linkType: hard

"@ledgerhq/hw-transport@npm:^6.31.4":
version: 6.31.4
resolution: "@ledgerhq/hw-transport@npm:6.31.4"
dependencies:
"@ledgerhq/devices": "npm:^8.4.4"
"@ledgerhq/errors": "npm:^6.19.1"
"@ledgerhq/logs": "npm:^6.12.0"
events: "npm:^3.3.0"
checksum: 10/cf101e5b818e95e59031241d556dbec24658f54104910e414be493bc4b90b0aea50f5d4b3339a237dd0b12845bb2683c845f3a82f2ea9da4e077b68d1e1f7e48
languageName: node
linkType: hard

"@ledgerhq/logs@npm:^6.10.0, @ledgerhq/logs@npm:^6.12.0":
version: 6.12.0
resolution: "@ledgerhq/logs@npm:6.12.0"
Expand Down Expand Up @@ -20328,27 +20354,6 @@ __metadata:
languageName: node
linkType: hard

"js-conflux-sdk@npm:2.0.7":
version: 2.0.7
resolution: "js-conflux-sdk@npm:2.0.7"
dependencies:
"@conflux-dev/conflux-address-js": "npm:^1.3.10"
abi-util-lite: "npm:^0.1.0"
big.js: "npm:^5.2.2"
commander: "npm:^8.0.0"
keccak: "npm:^2.0.0"
lodash: "npm:^4.17.19"
rlp: "npm:^2.2.7"
scrypt-js: "npm:^3.0.1"
secp256k1: "npm:^3.7.1"
superagent: "npm:^6.1.0"
websocket: "npm:^1.0.31"
bin:
cfxjs: bin/cfxjs.js
checksum: 10/51af708525879bab6e4d6f4281d34e9dc3370ebd69e7ac339d0c95e09b42daf6d97106953e1b907b8ba325a5a5b26af10433ddc11abee99f6fc2ae583becef79
languageName: node
linkType: hard

"js-conflux-sdk@npm:^2.1.9":
version: 2.4.10
resolution: "js-conflux-sdk@npm:2.4.10"
Expand Down Expand Up @@ -30932,7 +30937,7 @@ __metadata:
languageName: node
linkType: hard

"websocket@npm:^1.0.31, websocket@npm:^1.0.32, websocket@npm:^1.0.35":
"websocket@npm:^1.0.32, websocket@npm:^1.0.35":
version: 1.0.35
resolution: "websocket@npm:1.0.35"
dependencies:
Expand Down
Loading