import { ah as a, au as i } from "./platform-Cil_UtAQ.mjs";
import { k as c, G as d } from "./unsignedTransaction-DCDxTFq8.mjs";
import { c as h } from "./create-CChLkbGc.mjs";
class o {
  network;
  chain;
  provider;
  contracts;
  chainId;
  coreBridgePackageId;
  constructor(t, s, r, n) {
    this.network = t, this.chain = s, this.provider = r, this.contracts = n, this.chainId = a(s);
    const e = n.coreBridge;
    if (!e)
      throw new Error(`CoreBridge contract Address for chain ${s} not found`);
    this.coreBridgePackageId = e;
  }
  getGuardianSet(t) {
    throw new Error("Method not implemented.");
  }
  getMessageFee() {
    throw new Error("Method not implemented.");
  }
  static async fromRpc(t, s) {
    const [r, n] = await c.chainFromRpc(t), e = s[n];
    if (e.network !== r)
      throw new Error(`Network mismatch: ${e.network} !== ${r}`);
    return new o(r, n, t, e.contracts);
  }
  async *verifyMessage(t, s) {
    throw new Error("Method not implemented.");
  }
  async *publishMessage(t, s) {
    throw new Error("Method not implemented.");
  }
  async parseTransaction(t) {
    return (await this.parseMessages(t)).map((r) => ({
      emitter: r.emitterAddress,
      sequence: r.sequence,
      chain: this.chain
    }));
  }
  async getGuardianSetIndex() {
    throw new Error("Method not implemented.");
  }
  async parseMessages(t) {
    const r = (await this.provider.getTransactionBlock({
      digest: t,
      options: { showEvents: !0, showEffects: !0, showInput: !0 }
    })).events?.filter((n) => n.type.endsWith("WormholeMessage"));
    if (!r || r.length == 0)
      throw new Error("WormholeMessage not found");
    return r.map((n) => {
      const e = n.parsedJson;
      return h("Uint8Array", {
        emitterChain: this.chain,
        emitterAddress: new d(e.sender).toUniversalAddress(),
        sequence: BigInt(e.sequence),
        guardianSet: 0,
        // TODO: need to implement guardian set idx
        timestamp: Number(e.timestamp),
        consistencyLevel: e.consistency_level,
        nonce: e.nonce,
        signatures: [],
        payload: new Uint8Array(e.payload)
      });
    });
  }
}
i("Sui", "WormholeCore", o);
export {
  o as SuiWormholeCore
};
