"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const getContract_1 = require("../../../../utils/solidity/getContract");
const Contracts_1 = require("../../../../Contracts");
const onTransfer = (environment, contractAddress, filter) => {
    const contract = getContract_1.getContract(environment, Contracts_1.Contracts.PreminedToken, contractAddress);
    const eventEmitter = contract.events.Transfer({
        from: filter.from.toString(),
    });
    // TODO: Error handling
    return rxjs_1.fromEvent(eventEmitter, 'data').pipe(operators_1.map(log => ({
        from: log.returnValues.from,
        to: log.returnValues.to,
        value: log.returnValues.value,
    })));
};
exports.onTransfer = onTransfer;
