"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContractCallTxBuider = void 0;
var transactionBuilder_1 = require("./transactionBuilder");
var bn_js_1 = __importDefault(require("bn.js"));
var nearAPI = __importStar(require("near-api-js"));
var errors_1 = require("../baseCoin/errors");
var ContractCallTxBuider = /** @class */ (function (_super) {
    __extends(ContractCallTxBuider, _super);
    function ContractCallTxBuider() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ContractCallTxBuider.prototype.functionCallParams = function (params) {
        this._methodName = params.methodName;
        this._args = params.args;
        if (!this.isValidAmount(params.gas)) {
            throw new errors_1.BuildTransactionError("Invalid gas amount " + params.gas);
        }
        this._gas = params.gas;
        if (!this.isValidAmount(params.deposit)) {
            throw new errors_1.BuildTransactionError("Invalid deposit amount " + params.deposit);
        }
        this._deposit = params.deposit;
        return this;
    };
    ContractCallTxBuider.prototype.isValidAmount = function (gas) {
        return gas.gte(new bn_js_1.default(0, 10));
    };
    ContractCallTxBuider.prototype.createFuncionCall = function () {
        this._actions = [nearAPI.transactions.functionCall(this._methodName, this._args, this._gas, this._deposit)];
        return this;
    };
    return ContractCallTxBuider;
}(transactionBuilder_1.TransactionBuilder));
exports.ContractCallTxBuider = ContractCallTxBuider;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RDYWxsVHhCdWlsZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2NvaW4vbmVhci9jb250cmFjdENhbGxUeEJ1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLDJEQUEwRDtBQUMxRCxnREFBdUI7QUFDdkIsbURBQXVDO0FBQ3ZDLDZDQUEyRDtBQVMzRDtJQUFtRCx3Q0FBa0I7SUFBckU7O0lBNEJBLENBQUM7SUF0QkMsaURBQWtCLEdBQWxCLFVBQW1CLE1BQTBCO1FBQzNDLElBQUksQ0FBQyxXQUFXLEdBQUcsTUFBTSxDQUFDLFVBQVUsQ0FBQztRQUNyQyxJQUFJLENBQUMsS0FBSyxHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUM7UUFDekIsSUFBSSxDQUFDLElBQUksQ0FBQyxhQUFhLENBQUMsTUFBTSxDQUFDLEdBQUcsQ0FBQyxFQUFFO1lBQ25DLE1BQU0sSUFBSSw4QkFBcUIsQ0FBQyx3QkFBc0IsTUFBTSxDQU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