@ethersproject/bytes#SignatureLike TypeScript Examples
The following examples show how to use
@ethersproject/bytes#SignatureLike.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: serializeTransaction.ts From bodhi.js with Apache License 2.0 | 6 votes |
// rlp([chainId, salt, nonce, gasLimit, storageLimit, to, value, data, validUntil, tip, accessList, eip712sig])
export function serializeEip712(transaction: UnsignedAcalaEvmTX, signature?: SignatureLike): string {
const fields: any = [
formatNumber(transaction.chainId || 0, 'chainId'),
transaction.salt || '0x',
formatNumber(transaction.nonce || 0, 'nonce'),
formatNumber(transaction.gasLimit || 0, 'gasLimit'),
formatNumber(transaction.storageLimit || 0, 'storageLimit'),
transaction.to === null || transaction.to === undefined ? '0x' : getAddress(transaction.to),
formatNumber(transaction.value || 0, 'value'),
transaction.data || '0x',
formatNumber(transaction.validUntil || MAX_UINT256, 'validUntil'),
formatNumber(transaction.tip || 0, 'tip'),
formatAccessList(transaction.accessList || [])
];
if (signature) {
const sig = splitSignature(signature);
fields.push(formatNumber(sig.recoveryParam, 'recoveryParam'));
fields.push(stripZeros(sig.r));
fields.push(stripZeros(sig.s));
}
return hexConcat(['0x60', RLP.encode(fields)]);
}
Example #2
Source File: serializeTransaction.ts From bodhi.js with Apache License 2.0 | 6 votes |
export function serializeTransaction(transaction: UnsignedAcalaEvmTX, signature?: SignatureLike): string {
// Ethereum Transactions
if (
transaction.type === null ||
transaction.type === undefined ||
transaction.type === 0 ||
transaction.type === 1 ||
transaction.type === 2
) {
return serialize(transaction, signature);
}
// eip712
if (transaction.type === 96) {
return serializeEip712(transaction as UnsignedAcalaEvmTX, signature);
}
return logger.throwError(`unsupported transaction type: ${transaction.type}`, Logger.errors.UNSUPPORTED_OPERATION, {
operation: 'serializeTransaction',
transactionType: transaction.type
});
}
Example #3
Source File: keylessDeployment.ts From hubble-contracts with MIT License | 5 votes |
signature: SignatureLike = {
v: 27,
r: "0x0001abb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1e",
s: "0x0002abb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1eabb1e"
}