Skip to content

Commit

Permalink
Merge pull request #16609 from brave/pr16602_fix-trezor-approve-trans…
Browse files Browse the repository at this point in the history
…action-prompt_1.47.x

fix(wallet): Trezor Approve Transaction Prompt (uplift to 1.47.x)
  • Loading branch information
kjozwiak authored Jan 11, 2023
2 parents d6b1970 + eb8d21b commit 7fe1710
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/brave_wallet_ui/common/async/hardware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const signTransactionWithTrezor = (signed: Success<EthereumSignedTx> | Unsuccess
const txInfo = getMockedTransactionInfo()
const expectedPath = 'path'
const mockedKeyring = getMockedTrezorKeyring(expectedPath, txInfo, signed)
const apiProxy = getMockedProxyServices(txInfo.id, { nonce: '0x1' }, undefined, signatureResponse)
const apiProxy = getMockedProxyServices(txInfo.id, { nonce: '0x03' }, undefined, signatureResponse)
return signTrezorTransaction(apiProxy as unknown as WalletApiProxy,
expectedPath, txInfo, mockedKeyring as unknown as TrezorBridgeKeyring)
}
Expand Down
18 changes: 15 additions & 3 deletions components/brave_wallet_ui/common/async/hardware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,20 @@ export async function signTrezorTransaction (
if (!txInfo.txDataUnion.ethTxData1559) {
return { success: false, error: getLocale('braveWalletApproveTransactionError') }
}
txInfo.txDataUnion.ethTxData1559.baseData.nonce = nonce.nonce
const signed = await deviceKeyring.signTransaction(path, txInfo, chainId.chainId)
const tx = {
...txInfo,
txDataUnion: {
...txInfo.txDataUnion,
ethTxData1559: {
...txInfo.txDataUnion.ethTxData1559,
baseData: {
...txInfo.txDataUnion.ethTxData1559?.baseData,
nonce: nonce.nonce
}
}
}
} as SerializableTransactionInfo
const signed = await deviceKeyring.signTransaction(path, tx, chainId.chainId)
if (!signed || !signed.success || !signed.payload) {
const error = (signed.error ? signed.error : getLocale('braveWalletSignOnDeviceError')) as string
if (signed.code === TrezorErrorsCodes.CommandInProgress) {
Expand All @@ -83,7 +95,7 @@ export async function signTrezorTransaction (
}
const { v, r, s } = ethereumSignedTx
const result =
await apiProxy.ethTxManagerProxy.processHardwareSignature(txInfo.id, v, r, s)
await apiProxy.ethTxManagerProxy.processHardwareSignature(tx.id, v, r, s)
if (!result.status) {
return { success: false, error: getLocale('braveWalletProcessTransactionError') }
}
Expand Down

0 comments on commit 7fe1710

Please sign in to comment.