/**
 * SubmitBuilder Implementation
 *
 * Handles transaction submission by delegating to the provider's submitTx method.
 * The SubmitBuilder is responsible for:
 * 1. Converting the signed transaction to CBOR hex format
 * 2. Submitting to the provider's Effect.submitTx
 * 3. Returning the transaction hash
 *
 * @since 2.0.0
 * @category builders
 */
import { Effect } from "effect";
import { TransactionBuilderError } from "./TransactionBuilder.js";
/**
 * Create a SubmitBuilder instance for a signed transaction.
 *
 * @since 2.0.0
 * @category constructors
 */
export const makeSubmitBuilder = (signedTransaction, witnessSet, provider) => {
  const submitEffect = {
    submit: () => Effect.gen(function* () {
      yield* Effect.logDebug("Submitting transaction to provider");
      // Submit via provider's effect.submitTx (accepts Transaction directly)
      const txHash = yield* provider.effect.submitTx(signedTransaction).pipe(Effect.mapError(providerError => new TransactionBuilderError({
        message: `Failed to submit transaction: ${providerError.message}`,
        cause: providerError
      })));
      yield* Effect.logDebug(`Transaction submitted successfully: ${txHash}`);
      return txHash;
    })
  };
  return {
    effect: submitEffect,
    submit: () => Effect.runPromise(submitEffect.submit()),
    witnessSet
  };
};
//# sourceMappingURL=SubmitBuilderImpl.js.map