diff --git a/packages/trezor/package.json b/packages/trezor/package.json index 0e289a49b..f032d7f5b 100644 --- a/packages/trezor/package.json +++ b/packages/trezor/package.json @@ -1,6 +1,6 @@ { "name": "@web3-onboard/trezor", - "version": "2.1.7-alpha.1", + "version": "2.1.7-alpha.2", "description": "Trezor hardware wallet module for connecting to Web3-Onboard. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.", "keywords": [ "Ethereum", diff --git a/packages/trezor/src/index.ts b/packages/trezor/src/index.ts index ab17d16dc..64100833a 100644 --- a/packages/trezor/src/index.ts +++ b/packages/trezor/src/index.ts @@ -284,7 +284,7 @@ function trezor(options: TrezorOptions): WalletInit { maxFeePerGas: transactionData.maxFeePerGas!, maxPriorityFeePerGas: transactionData.maxPriorityFeePerGas!, nonce: transactionData.nonce!, - chainId: parseInt(currentChain.id), + chainId: Number(currentChain.id), data: transactionData.hasOwnProperty('data') ? transactionData.data : '' @@ -296,7 +296,7 @@ function trezor(options: TrezorOptions): WalletInit { gasPrice: transactionData.gasPrice!, gasLimit: gasLimit!, nonce: transactionData.nonce!, - chainId: parseInt(currentChain.id), + chainId: Number(currentChain.id), data: transactionData.hasOwnProperty('data') ? transactionData.data : '' @@ -353,6 +353,15 @@ function trezor(options: TrezorOptions): WalletInit { ) { populatedTransaction.nonce = populatedTransaction.nonce.toString(16) } + if ( + populatedTransaction.hasOwnProperty('nonce') && + typeof populatedTransaction.nonce === 'string' + ) { + // Adds "0x" to a given `String` if it does not already start with "0x". + populatedTransaction.nonce = ethUtil.addHexPrefix( + populatedTransaction.nonce + ) + } const updateBigNumberFields = bigNumberFieldsToStrings(populatedTransaction) @@ -363,7 +372,7 @@ function trezor(options: TrezorOptions): WalletInit { ) const chainId = currentChain.hasOwnProperty('id') - ? Number.parseInt(currentChain.id) + ? Number(currentChain.id) : 1 const common = await getCommon({ customNetwork, chainId }) @@ -386,7 +395,7 @@ function trezor(options: TrezorOptions): WalletInit { // EIP155 support. check/recalc signature v value. const rv = parseInt(v, 16) - let cv = parseInt(currentChain.id) * 2 + 35 + let cv = Number(currentChain.id) * 2 + 35 if (rv !== cv && (rv & cv) !== rv) { cv += 1 // add signature v bit. } @@ -477,7 +486,7 @@ function trezor(options: TrezorOptions): WalletInit { ? [accounts[0].address] : [], eth_chainId: async () => - currentChain.hasOwnProperty('id') ? currentChain.id : '', + currentChain.hasOwnProperty('id') ? String(currentChain.id) : '', eth_signTransaction: async ({ params: [transactionObject] }) => signTransaction(transactionObject), eth_sendTransaction: async ({ baseRequest, params }) => {