"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());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const token_math_1 = require("@melonproject/token-math");
const initTestEnvironment_1 = require("../../../../tests/utils/initTestEnvironment");
const approve_1 = require("../transactions/approve");
const transferFrom_1 = require("../transactions/transferFrom");
const deploy_1 = require("../transactions/deploy");
const getToken_1 = require("../calls/getToken");
describe('transferFrom', () => {
    const shared = {};
    beforeAll(() => __awaiter(this, void 0, void 0, function* () {
        shared.env = yield initTestEnvironment_1.initTestEnvironment();
        shared.address = yield deploy_1.deployToken(shared.env);
        shared.token = yield getToken_1.getToken(shared.env, shared.address);
    }));
    it('transferFrom', () => __awaiter(this, void 0, void 0, function* () {
        const accounts = yield shared.env.eth.getAccounts();
        const howMuch = token_math_1.createQuantity(shared.token, '1000000000000000000');
        yield approve_1.approve(shared.env, { howMuch, spender: new token_math_1.Address(accounts[0]) });
        const receipt = yield transferFrom_1.transferFrom(shared.env, {
            from: new token_math_1.Address(accounts[0]),
            howMuch,
            to: new token_math_1.Address(accounts[1]),
        });
        expect(receipt).toBeTruthy();
    }));
});
