"use strict";
var __read = (this && this.__read) || function (o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
};
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 });
var react_1 = __importStar(require("react"));
var ethers_1 = require("ethers");
var Asset_1 = require("./Asset");
require("./../styles/assetsList.sass");
require("./../styles/assetsListDefaults.sass");
var useAsyncEffect_1 = require("../hooks/useAsyncEffect");
var getStyleForTopLevelComponent_1 = require("../../core/utils/getStyleForTopLevelComponent");
var getIconForToken_1 = require("../../core/utils/getIconForToken");
exports.Assets = function (_a) {
    var deployedWallet = _a.deployedWallet, className = _a.className;
    var _b = __read(react_1.useState([]), 2), tokenDetailsWithBalance = _b[0], setTokenDetailsWithBalance = _b[1];
    useAsyncEffect_1.useAsyncEffect(function () { return deployedWallet.subscribeToBalances(setTokenDetailsWithBalance); }, []);
    return (react_1.default.createElement("div", { className: "universal-login-assets" },
        react_1.default.createElement("div", { className: getStyleForTopLevelComponent_1.getStyleForTopLevelComponent(className) },
            react_1.default.createElement("div", { className: "assets" },
                react_1.default.createElement("p", { className: "assets-title" }, "My Assets"),
                react_1.default.createElement("div", { className: "assets-list" }, tokenDetailsWithBalance.map(function (_a) {
                    var name = _a.name, symbol = _a.symbol, balance = _a.balance;
                    return (react_1.default.createElement(Asset_1.Asset, { key: name + "-" + symbol, sdk: deployedWallet.sdk, name: name, symbol: symbol, balance: ethers_1.utils.formatEther(balance), icon: getIconForToken_1.getIconForToken(symbol), className: className }));
                }))))));
};
//# sourceMappingURL=Assets.js.map