Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
),
s: hexSequenceNormalizer(
multipleOfTwoHexValueNormalizer(String(SIGNATURE.S)),
),
v: hexSequenceNormalizer(
/*
* @TODO Add `bigNumber` `toHexString` wrapper method
*
* Flow confuses bigNumber's `toString` with the String object
* prototype `toString` method
*/
/* $FlowFixMe */
multipleOfTwoHexValueNormalizer(chainId.toString(16)),
),
},
getChainDefinition(chainId),
);
/*
* Modify the default payload to set the transaction details
*/
const modifiedPayloadObject: Object = Object.assign(
{},
PAYLOAD_SIGNTX,
{
/*
* Path needs to be sent in as an derivation path array
*/
address_n: fromString(
derivationPathNormalizer(derivationPath),
true,
).toPathArray(),
/*
multipleOfTwoHexValueNormalizer(String(SIGNATURE.S)),
),
v: hexSequenceNormalizer(
/*
* @TODO Add `bigNumber` `toHexString` wrapper method
*
* Flow confuses bigNumber's `toString` with the String object
* prototype `toString` method
*/
/* $FlowFixMe */
multipleOfTwoHexValueNormalizer(chainId.toString(16)),
),
},
to ? { to: addressNormalizer(to) } : {},
),
getChainDefinition(chainId),
);
/*
* Sign the transaction object via your Ledger Wallet
*
* We also warn the user here, since the device will need confirmation, but only in dev mode.
*/
warning(messages.userSignInteractionWarning);
const {
r: rSignatureComponent,
s: sSignatureComponent,
v: recoveryParameter,
} = await ledger.signTransaction(
derivationPathNormalizer(derivationPath),
unsignedTransaction.serialize().toString(HEX_HASH_TYPE),
);
/*
* RLP encode (to hex string) with ethereumjs-tx, prefix with
* `0x` and return. Convert to BN all the numbers-as-strings.
*/
const signedTransaction = new EthereumTx(
{
data: signedData,
gasLimit: new BigNumber(gas),
gasPrice: new BigNumber(signedGasPrice),
nonce: new BigNumber(nonce),
r,
s,
to: signedTo,
v,
value: new BigNumber(signedValue),
},
getChainDefinition(chainId),
);
const serializedSignedTransaction = signedTransaction
.serialize()
.toString(HEX_HASH_TYPE);
const normalizedSignedTransaction = hexSequenceNormalizer(
serializedSignedTransaction,
);
return resolve(normalizedSignedTransaction);
} catch (caughtError) {
return reject(caughtError);
}
};