"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ethers_1 = require("ethers");
const fs_1 = __importDefault(require("fs"));
const dotenv_1 = require("dotenv");
from;
"./helpers";
(0, dotenv_1.config)({ path: ".env" });
class Momiji {
constructor(provider) {
this.queue = { transactions: [] };
const abi = JSON.parse(fs_1.default.readFileSync("./abis/state.json", "utf8"));
const address = process.env["STATE_CONTRACT_ADDRESS"];
if (!address)
throw new Error("momiji.constructor: STATE_CONTRACT_ADDRESS is not set, but is required");
this.contract = new ethers_1.Contract(address, abi, provider);
// Fetch existing queue from chain
}
watchEvents() {
this.contract.on("TransactionSent", (event) => {
console.log(`Event received: ${event}`);
// Add it to the queue and start proving in the background
});
this.contract.on("BatchPublish", (event) => {
console.log(`Event received: ${event}`);
// Clear the queue and flush the batch object
this.queue = { transactions: [] }; // reset the queue
});
}
}
exports.default = Momiji;
-
Johnny authored5ce6ae55