index.js 2.53 KB
Newer Older
Johnny's avatar
Johnny committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const momiji_1 = require("./modules/momiji");
const interfaces_1 = require("./lib/utils/interfaces");
const fs = __importStar(require("fs"));
require("dotenv/config");
require('dotenv').config({ path: "../.env" }); // TODO: Make sure this path is correct
// If process.env.RPC_URL is not set, use localhost
if (!process.env.RPC_URL) {
    process.env.RPC_URL = "http://127.0.0.1:8545";
}
const main = async () => {
    let publisher = new momiji_1.Publisher({
        tree: {
            utxoDepth: Number(process.env.UTXO_DEPTH),
            txDepth: Number(process.env.TX_DEPTH),
            stateDepth: Number(process.env.STATE_DEPTH),
            treeSum: 0
        },
        stateContract: {
            address: process.env.STATE_CONTRACT_ADDRESS,
            abi: JSON.parse(fs.readFileSync(process.env.STATE_CONTRACT_ABI, 'utf8'))
        },
        recursionVerifier: {
            address: process.env.REC_VERIFIER_ADDRESS,
            abi: JSON.parse(fs.readFileSync(process.env.REC_VERIFIER_ABI, 'utf8'))
        },
        transactionCircuit: JSON.parse(fs.readFileSync(process.env.TX_CIRCUIT, 'utf8')),
        recursionCircuit: JSON.parse(fs.readFileSync(process.env.REC_CIRCUIT, 'utf8')),
        transactionVk: JSON.parse(fs.readFileSync(process.env.TX_VK, 'utf8')).vkAsFields,
        transactionVkHash: JSON.parse(fs.readFileSync(process.env.TX_VK, 'utf8')).vkHash,
        provider: process.env.RPC_URL,
        PRIVATE_KEY: undefined
    }, new interfaces_1.Wallet(process.env.PRIVATE_KEY, new interfaces_1.JsonRpcProvider(process.env.RPC_URL)));
    await publisher.initialize();
};
console.log(`💫 Starting publisher...`);
main();