Skip to content

Commit

Permalink
chore: update ledger package and sign code
Browse files Browse the repository at this point in the history
  • Loading branch information
iosh committed Aug 15, 2024
1 parent b1b9c26 commit fdf18a5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/json-rpc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* @name index.js
*/

import * as utils from './utils'
import * as utils from './utils.js'
export {utils}
4 changes: 2 additions & 2 deletions packages/ledger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dependencies": {
"@fluent-wallet/base32-address": "workspace:packages/base32-address",
"@fluent-wallet/hw-app-conflux": "0.0.8",
"@ledgerhq/hw-app-eth": "6.24.1",
"@ledgerhq/hw-transport-webusb": "6.19.0"
"@ledgerhq/hw-app-eth": "6.38.0",
"@ledgerhq/hw-transport-webusb": "6.29.2"
}
}
11 changes: 5 additions & 6 deletions packages/rpcs/eth_signTxWithLedgerNanoS/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {decrypt} from 'browser-passworder'
import {Ethereum as LedgerEthereum} from '@fluent-wallet/ledger'
import {TransactionFactory} from '@ethereumjs/tx'
import {RLP} from '@ethereumjs/rlp'
import {bufArrToArr} from '@ethereumjs/util'
import {Common} from '@ethereumjs/common'
import {addHexPrefix} from '@fluent-wallet/utils'
import {bytesToHex} from '@ethereumjs/util'

export const NAME = 'eth_signTxWithLedgerNanoS'

Expand Down Expand Up @@ -63,10 +63,9 @@ export const main = async ({
const common = Common.custom({chainId: tx.chainId})
const txData = TransactionFactory.fromTxData(newTx, {common})

let messageToSign = txData.getMessageToSign(false)
const rawTxHex = Buffer.isBuffer(messageToSign)
? messageToSign.toString('hex')
: Buffer.from(RLP.encode(bufArrToArr(messageToSign)))
const messageToSign = txData.getMessageToSign()
const rawTxHex =
txData.type === 0 ? RLP.encode(messageToSign) : messageToSign

const {r, s, v} = await new LedgerEthereum().signTransaction(
hdPath,
Expand All @@ -85,8 +84,8 @@ export const main = async ({
throw InvalidParams(
`The address in LedgerNanoS (${recoveredAddr}) doesn't match the address in fluent (${addr.value})`,
)
const rawTx = bytesToHex(signedTx.serialize())

const rawTx = signedTx.serialize().toString('hex')
return addHexPrefix(rawTx)
} catch (err) {
const newError = UserRejected(
Expand Down
6 changes: 3 additions & 3 deletions packages/rpcs/eth_signTxWithLedgerNanoS/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"packageManager": "yarn@3.1.0",
"version": "0.0.4",
"dependencies": {
"@ethereumjs/rlp": "4.0.1",
"@ethereumjs/tx": "4.1.1",
"@ethereumjs/util": "8.0.5",
"@ethereumjs/rlp": "5.0.2",
"@ethereumjs/tx": "5.3.0",
"@ethereumjs/util": "9.0.3",
"@fluent-wallet/ledger": "workspace:*",
"@fluent-wallet/spec": "workspace:*",
"@fluent-wallet/utils": "workspace:packages/utils",
Expand Down

0 comments on commit fdf18a5

Please sign in to comment.