Commit 5ce6ae55 authored by Johnny's avatar Johnny
Browse files

initial commit

parents
Pipeline #43 canceled with stages
{
"files": [
"./src/index.ts"
],
"compilerOptions": {
"lib": [
"es2021"
],
"target": "es2021",
"module": "commonjs",
"outDir": "./dist",
"skipLibCheck": true
}
}
\ No newline at end of file
"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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment