import { Effect } from "effect";
import * as KupmiosEffects from "./internal/KupmiosEffects.js";
/**
 * Kupmios provider for Cardano blockchain data access.
 * Provides support for interacting with both Kupo and Ogmios APIs.
 * Supports custom headers for authentication with Demeter or other providers.
 *
 * @since 2.0.0
 * @category constructors
 */
export class KupmiosProvider {
  kupoUrl;
  ogmiosUrl;
  headers;
  effect;
  constructor(kupoUrl, ogmiosUrl, headers) {
    this.kupoUrl = kupoUrl;
    this.ogmiosUrl = ogmiosUrl;
    this.headers = headers;
    this.effect = {
      getProtocolParameters: () => KupmiosEffects.getProtocolParametersEffect(this.ogmiosUrl, this.headers),
      getUtxos: KupmiosEffects.getUtxosEffect(this.kupoUrl, this.headers),
      getUtxosWithUnit: KupmiosEffects.getUtxosWithUnitEffect(this.kupoUrl, this.headers),
      getUtxoByUnit: KupmiosEffects.getUtxoByUnitEffect(this.kupoUrl, this.headers),
      getUtxosByOutRef: KupmiosEffects.getUtxosByOutRefEffect(this.kupoUrl, this.headers),
      getDelegation: KupmiosEffects.getDelegationEffect(this.ogmiosUrl, this.headers),
      getDatum: KupmiosEffects.getDatumEffect(this.kupoUrl, this.headers),
      awaitTx: KupmiosEffects.awaitTxEffect(this.kupoUrl, this.headers),
      evaluateTx: KupmiosEffects.evaluateTxEffect(this.ogmiosUrl, this.headers),
      submitTx: KupmiosEffects.submitTxEffect(this.ogmiosUrl, this.headers)
    };
  }
  getProtocolParameters = () => Effect.runPromise(this.effect.getProtocolParameters());
  getUtxos = addressOrCredential => Effect.runPromise(this.effect.getUtxos(addressOrCredential));
  getUtxosWithUnit = (addressOrCredential, unit) => Effect.runPromise(this.effect.getUtxosWithUnit(addressOrCredential, unit));
  getUtxoByUnit = unit => Effect.runPromise(this.effect.getUtxoByUnit(unit));
  getUtxosByOutRef = outRefs => Effect.runPromise(this.effect.getUtxosByOutRef(outRefs));
  getDelegation = rewardAddress => Effect.runPromise(this.effect.getDelegation(rewardAddress));
  getDatum = datumHash => Effect.runPromise(this.effect.getDatum(datumHash));
  awaitTx = (txHash, checkInterval, timeout) => Effect.runPromise(this.effect.awaitTx(txHash, checkInterval, timeout));
  evaluateTx = (tx, additionalUTxOs) => Effect.runPromise(this.effect.evaluateTx(tx, additionalUTxOs));
  submitTx = tx => Effect.runPromise(this.effect.submitTx(tx));
}
//# sourceMappingURL=Kupmios.js.map