@0xfacet/sdk
Version:
A toolkit for Facet blockchain integration.
32 lines (31 loc) • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.computeFacetTransactionHash = void 0;
const viem_1 = require("viem");
/**
* Computes a hash for a Facet transaction.
*
* @param l1TransactionHash - The hash of the L1 transaction
* @param from - The address sending the transaction
* @param to - The recipient address of the transaction
* @param value - The amount of FCT to send with the transaction
* @param data - The calldata for the transaction
* @param gasLimit - The maximum amount of gas the transaction can use
* @param mint - The amount of FCT mint in the transaction. This value is here only to preserve the function signature. It is not used in the hash computation.
* @returns A keccak256 hash of the encoded transaction
*/
const computeFacetTransactionHash = (sourceHash, from, to, value, data, gasLimit, mint) => {
const serializedTransaction = [
sourceHash,
from,
to ?? "0x",
"0x",
value ? (0, viem_1.toHex)(value) : "0x",
gasLimit ? (0, viem_1.toHex)(gasLimit) : "0x",
"0x",
data,
];
const encodedTx = (0, viem_1.concatHex)(["0x7d", (0, viem_1.toRlp)(serializedTransaction)]);
return (0, viem_1.keccak256)(encodedTx);
};
exports.computeFacetTransactionHash = computeFacetTransactionHash;