"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const Eth = __importStar(require("web3-eth"));
// Websocket could be the problem
// HTTP is faster, but same error
const eth = new Eth(new Eth.providers.HttpProvider('http://localhost:8545'));
const rawABI = fs.readFileSync(path.join(process.cwd(), 'out', 'factory', 'FundFactory.abi'), { encoding: 'utf-8' });
const ABI = JSON.parse(rawABI);
const fundFactoryAddress = '0x801cd3BCa02ffB46Ee5cf43B023Aa3619089d16b';
const contract = new eth.Contract(ABI, fundFactoryAddress);
const args = [
    ['0x9a8D6f20b917eA9542EEE886c78fE41C638A3d45'],
    [],
    ['0x4b1a08B5DBcf3386f22DB1d694beF84d8EF4B340'],
    [
        '0xc0dd7a9D5470216eaf97DD2CEcAc259da1f7Af2E',
        '0x2B83156799AB55F5581263Cd544372B9af2c2Cfe',
    ],
    [false],
    '0x0BD6f791464E1c6BaD8C8bb7a78999BE831C2691',
];
const exec = () => __awaiter(this, void 0, void 0, function* () {
    const accounts = yield eth.getAccounts();
    console.log(accounts);
    try {
        const receipt = yield contract.methods
            // ... is good!
            .createComponents(...args)
            .send({ from: accounts[0] });
        console.log(receipt);
    }
    catch (e) {
        console.error(e);
    }
});
exec(); // .finally(process.exit);
