UNPKG

@tunghm/relay-kit

Version:
108 lines (107 loc) 5.61 kB
import { SigningMethod, ContractNetworksConfig } from '@safe-global/protocol-kit'; import { RelayKitBasePack } from '../../RelayKitBasePack'; import SafeOperation from './SafeOperation'; import { EstimateFeeProps, Safe4337CreateTransactionProps, Safe4337ExecutableProps, Safe4337InitOptions, Safe4337Options, UserOperationReceipt, UserOperationWithPayload } from './types'; export type InheritWalletOptions = { inheritWallet?: string; owners?: string[]; initCode?: string; version?: string; contractNetworks?: ContractNetworksConfig; }; /** * Safe4337Pack class that extends RelayKitBasePack. * This class provides an implementation of the ERC-4337 that enables Safe accounts to wrk with UserOperations. * It allows to create, sign and execute transactions using the Safe 4337 Module. * * @class * @link https://github.com/safe-global/safe-modules/blob/main/modules/4337/contracts/Safe4337Module.sol * @link https://eips.ethereum.org/EIPS/eip-4337 */ export declare class Safe4337Pack extends RelayKitBasePack<{ EstimateFeeProps: EstimateFeeProps; EstimateFeeResult: SafeOperation; CreateTransactionProps: Safe4337CreateTransactionProps; CreateTransactionResult: SafeOperation; ExecuteTransactionProps: Safe4337ExecutableProps; ExecuteTransactionResult: string; }> { #private; /** * Creates an instance of the Safe4337Pack. * * @param {Safe4337Options} options - The initialization parameters. */ constructor({ protocolKit, bundlerClient, publicClient, bundlerUrl, paymasterOptions, entryPointAddress, safe4337ModuleAddress }: Safe4337Options, inheritOptions?: InheritWalletOptions); /** * Initializes a Safe4337Pack class. * This method creates the protocolKit instance based on the input parameters. * When the Safe address is provided, it will use the existing Safe. * When the Safe address is not provided, it will use the predictedSafe feature with the provided owners and threshold. * It will use the correct contract addresses for the fallbackHandler and the module and will add the data to enable the 4337 module. * * @param {Safe4337InitOptions} initOptions - The initialization parameters. * @return {Promise<Safe4337Pack>} The Promise object that will be resolved into an instance of Safe4337Pack. */ static init(initOptions: Safe4337InitOptions, inheritOptions?: InheritWalletOptions): Promise<Safe4337Pack>; getFeeData(): Promise<any>; /** * Estimates gas for the SafeOperation. * * @param {EstimateFeeProps} props - The parameters for the gas estimation. * @param {SafeOperation} props.safeOperation - The SafeOperation to estimate the gas. * @param {IFeeEstimator} props.feeEstimator - The function to estimate the gas. * @return {Promise<SafeOperation>} The Promise object that will be resolved into the gas estimation. */ getEstimateFee({ safeOperation, feeEstimator }: EstimateFeeProps): Promise<SafeOperation>; /** * Creates a relayed transaction based on the provided parameters. * * @param {MetaTransactionData[]} transactions - The transactions to batch in a SafeOperation. * @param options - Optional configuration options for the transaction creation. * @return {Promise<SafeOperation>} The Promise object will resolve a SafeOperation. */ createTransaction({ transactions, options }: Safe4337CreateTransactionProps): Promise<SafeOperation>; /** * Signs a safe operation. * * @param {SafeOperation} safeOperation - The SafeOperation to sign. * @param {SigningMethod} signingMethod - The signing method to use. * @return {Promise<SafeOperation>} The Promise object will resolve to the signed SafeOperation. */ signSafeOperation(safeOperation: SafeOperation, signingMethod?: SigningMethod): Promise<SafeOperation>; /** * Executes the relay transaction. * * @param {SafeOperation} safeOperation - The SafeOperation to execute. * @return {Promise<string>} The user operation hash. */ executeTransaction({ executable: safeOperation }: Safe4337ExecutableProps): Promise<string>; /** * Return a UserOperation based on a hash (userOpHash) returned by eth_sendUserOperation * * @param {string} userOpHash - The hash of the user operation to fetch. Returned from the #sendUserOperation method * @returns {UserOperation} - null in case the UserOperation is not yet included in a block, or a full UserOperation, with the addition of entryPoint, blockNumber, blockHash and transactionHash */ getUserOperationByHash(userOpHash: string): Promise<UserOperationWithPayload>; /** * Return a UserOperation receipt based on a hash (userOpHash) returned by eth_sendUserOperation * * @param {string} userOpHash - The hash of the user operation to fetch. Returned from the #sendUserOperation method * @returns {UserOperationReceipt} - null in case the UserOperation is not yet included in a block, or UserOperationReceipt object */ getUserOperationReceipt(userOpHash: string): Promise<UserOperationReceipt | null>; /** * Returns an array of the entryPoint addresses supported by the client. * The first element of the array SHOULD be the entryPoint addressed preferred by the client. * * @returns {string[]} - The supported entry points. */ getSupportedEntryPoints(): Promise<string[]>; /** * Returns EIP-155 Chain ID. * * @returns {string} - The chain id. */ getChainId(): Promise<string>; }