UNPKG

@0xfacet/sdk

Version:

A toolkit for Facet blockchain integration.

52 lines (51 loc) 2.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.walletL1FacetActions = void 0; const utils_1 = require("../utils"); const sendFacetTransaction_1 = require("./sendFacetTransaction"); const writeFacetContract_1 = require("./writeFacetContract"); /** * Creates a set of L1 facet actions bound to the provided wallet client * @param l1WalletClient - The viem wallet client for L1 interactions * @returns Object containing facet transaction functions */ const walletL1FacetActions = (l1WalletClient) => ({ /** * Sends a transaction through the Facet protocol using the bound L1 wallet client * * @param parameters - The transaction parameters * @returns A promise that resolves to the transaction hash */ sendFacetTransaction: (parameters) => { return (0, sendFacetTransaction_1.sendFacetTransaction)(l1WalletClient, parameters); }, /** * Sends a raw transaction through the Facet protocol using the bound L1 wallet client * * @param parameters - The Facet transaction parameters * @returns A promise that resolves to the transaction result containing L1 and Facet transaction hashes */ sendRawFacetTransaction: (parameters) => { if (!l1WalletClient.account) { throw new Error("No account"); } if (!l1WalletClient.chain) { throw new Error("No chain"); } return (0, utils_1.sendRawFacetTransaction)(l1WalletClient.chain.id, l1WalletClient.account.address, parameters, (l1Transaction) => l1WalletClient.sendTransaction({ ...l1Transaction, chain: l1WalletClient.chain, account: (l1WalletClient.account ?? l1Transaction.account), }), l1WalletClient.transport?.url); }, /** * Writes to a contract through the Facet protocol using the bound L1 wallet client * * @param parameters - The contract write parameters * @returns A promise that resolves to the transaction hash */ writeFacetContract: (parameters) => { return (0, writeFacetContract_1.writeFacetContract)(l1WalletClient, parameters); }, }); exports.walletL1FacetActions = walletL1FacetActions;