"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const src_1 = require("../../../src");
const testUtils_1 = require("../../testUtils");
const XRPMccConnection = {
    url: process.env.XRP_URL || "https://xrplcluster.com",
    username: process.env.XRP_USERNAME || "",
    password: process.env.XRP_PASSWORD || "",
    apiTokenKey: process.env.FLARE_API_PORTAL_KEY || "",
};
// Find Escrow examples with XRP where offer is actually accepted.
describe(`NFTokens types (${(0, testUtils_1.getTestFile)(__filename)})`, function () {
    let MccClient;
    before(async function () {
        src_1.traceManager.displayRuntimeTrace = false;
        src_1.traceManager.displayStateOnException = false;
        MccClient = new src_1.MCC.XRP(XRPMccConnection);
    });
    describe("NFTokenAcceptOffer", function () {
        let transaction;
        const txId = "BEB64444C36D1072820BAED317BE2E6470AFDAD9D8FB2D16A15A4D46E5A71909";
        const fee = "12";
        const value = "1000";
        const minterFee = "58";
        const addressSell = "rDuck4z5jdAJLDaRMwpc2xZhsCKqqTMRsr";
        const addressBuy = "rsa614fckHaBjDpCcZNQqfvVFVPYZzPvE2";
        const minter = "rpAETGuhJW5ZYfg3PdsCTELv4ho147AoE9";
        before(async function () {
            transaction = await MccClient.getTransaction(txId);
        });
        it("should correctly parse sourceAddresses", async function () {
            (0, chai_1.expect)(transaction.sourceAddresses.sort()).to.deep.equal([addressBuy].sort());
        });
        it("should correctly parse receivingAddresses", async function () {
            (0, chai_1.expect)(transaction.receivingAddresses).to.deep.equal([minter, addressSell]);
        });
        it("should correctly parse spentAmounts", async function () {
            const expected = [{ address: addressBuy, amount: (0, src_1.toBN)(value) }];
            (0, chai_1.expect)((0, testUtils_1.AddressAmountEqual)(transaction.spentAmounts, expected)).to.be.true;
        });
        it("should correctly parse receivedAmounts", async function () {
            const expected = [
                { address: minter, amount: (0, src_1.toBN)(minterFee) },
                { address: addressSell, amount: (0, src_1.toBN)(value).sub((0, src_1.toBN)(fee)).sub((0, src_1.toBN)(minterFee)) },
            ];
            (0, chai_1.expect)((0, testUtils_1.AddressAmountEqual)(transaction.receivedAmounts, expected)).to.be.true;
        });
        it("should get balanceDecreasingSummary #1", async function () {
            const summary = await transaction.balanceDecreasingSummary({ sourceAddressIndicator: (0, src_1.standardAddressHash)(addressSell) });
            (0, chai_1.expect)(summary.status).to.eq(src_1.BalanceDecreasingSummaryStatus.Success);
            (0, chai_1.expect)(summary.response.spentAmount.toString()).to.eq((0, src_1.toBN)(fee).sub((0, src_1.toBN)(value)).add((0, src_1.toBN)(minterFee)).toString());
        });
        it("should get balanceDecreasingSummary #2", async function () {
            const summary = await transaction.balanceDecreasingSummary({ sourceAddressIndicator: (0, src_1.standardAddressHash)(addressBuy) });
            (0, chai_1.expect)(summary.status).to.eq(src_1.BalanceDecreasingSummaryStatus.Success);
            (0, chai_1.expect)(summary.response.spentAmount.toString()).to.eq((0, src_1.toBN)(value).toString());
        });
        // // Token transfers
        // it.skip("should correctly parse assetSourceAddresses", async function () {
        //    expect(transaction.assetSourceAddresses).to.deep.equal([]);
        // });
        // it.skip("should correctly parse assetReceivingAddresses", async function () {
        //    expect(transaction.assetReceivingAddresses).to.deep.equal([]);
        // });
        // it.skip("should correctly parse assetSpentAmounts", async function () {
        //    expect(transaction.assetSpentAmounts).to.deep.equal([]);
        // });
        // it.skip("should correctly parse assetReceivedAmounts", async function () {
        //    expect(transaction.assetReceivedAmounts).to.deep.equal([]);
        // });
    });
});
//# sourceMappingURL=NFToken.test.js.map