"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = __importDefault(require("lodash"));
var ErrorCodes;
(function (ErrorCodes) {
    ErrorCodes["IncompatibleBrowser"] = "IncompatibleBrowser";
    ErrorCodes["UserDeniedAccess"] = "UserDeniedAccess";
    ErrorCodes["WalletIsLocked"] = "WalletIsLocked";
    ErrorCodes["ProcedureValidationError"] = "ProcedureValidationError";
    ErrorCodes["FetcherValidationError"] = "FetcherValidationError";
    ErrorCodes["TransactionRejectedByUser"] = "TransactionRejectedByUser";
    ErrorCodes["TransactionReverted"] = "TransactionReverted";
    ErrorCodes["FatalError"] = "FatalError";
    ErrorCodes["UnexpectedReturnData"] = "UnexpectedReturnData";
    ErrorCodes["InvalidAddress"] = "InvalidAddress";
    ErrorCodes["InsufficientBalance"] = "InsufficientBalance";
})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
exports.ErrorMessagesPerCode = {
    [ErrorCodes.IncompatibleBrowser]: 'The browser bring used is not compatible with Ethereum',
    [ErrorCodes.WalletIsLocked]: 'The wallet is locked, if Metamask extension is being used, the user needs to unlock it first',
    [ErrorCodes.UserDeniedAccess]: 'The user denied access',
    [ErrorCodes.TransactionRejectedByUser]: 'The user rejected the transaction',
    [ErrorCodes.UnexpectedReturnData]: 'The data returned by the smart contract has an unexpected format. Please report this issue to the Polymath team',
    [ErrorCodes.InvalidAddress]: 'Invalid Address',
};
class PolymathError extends Error {
    constructor({ message, code }) {
        super(message || exports.ErrorMessagesPerCode[code] || `Unknown error, code: ${code}`);
        // eslint:disable-next-line
        // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
        // Object.setPrototypeOf(this, PolymathError);
        this.code = code;
    }
}
exports.PolymathError = PolymathError;
var ProcedureTypes;
(function (ProcedureTypes) {
    ProcedureTypes["UnnamedProcedure"] = "UnnamedProcedure";
    ProcedureTypes["Approve"] = "Approve";
    ProcedureTypes["CreateCheckpoint"] = "CreateCheckpoint";
    ProcedureTypes["EnableDividendModules"] = "EnableDividendModules";
    ProcedureTypes["EnableGeneralPermissionManager"] = "EnableGeneralPermissionManager";
    ProcedureTypes["CreateErc20DividendDistribution"] = "CreateErc20DividendDistribution";
    ProcedureTypes["CreateEtherDividendDistribution"] = "CreateEtherDividendDistribution";
    ProcedureTypes["CreateSecurityToken"] = "CreateSecurityToken";
    ProcedureTypes["ReclaimFunds"] = "ReclaimFunds";
    ProcedureTypes["ReserveSecurityToken"] = "ReserveSecurityToken";
    ProcedureTypes["WithdrawTaxes"] = "WithdrawTaxes";
    ProcedureTypes["UpdateDividendsTaxWithholdingList"] = "UpdateDividendsTaxWithholdingList";
    ProcedureTypes["SetDividendsWallet"] = "SetDividendsWallet";
    ProcedureTypes["PushDividendPayment"] = "PushDividendPayment";
    ProcedureTypes["ChangeDelegatePermission"] = "ChangeDelegatePermission";
    ProcedureTypes["ControllerTransfer"] = "ControllerTransfer";
    ProcedureTypes["PauseSto"] = "PauseSto";
    ProcedureTypes["SetController"] = "SetController";
})(ProcedureTypes = exports.ProcedureTypes || (exports.ProcedureTypes = {}));
var PolyTransactionTags;
(function (PolyTransactionTags) {
    PolyTransactionTags["Any"] = "Any";
    PolyTransactionTags["Approve"] = "Approve";
    PolyTransactionTags["GetTokens"] = "GetTokens";
    PolyTransactionTags["ReserveSecurityToken"] = "ReserveSecurityToken";
    PolyTransactionTags["CreateSecurityToken"] = "CreateSecurityToken";
    PolyTransactionTags["CreateCheckpoint"] = "CreateCheckpoint";
    PolyTransactionTags["CreateErc20DividendDistribution"] = "CreateErc20DividendDistribution";
    PolyTransactionTags["CreateEtherDividendDistribution"] = "CreateEtherDividendDistribution";
    PolyTransactionTags["SetErc20TaxWithholding"] = "SetErc20TaxWithholding";
    PolyTransactionTags["SetEtherTaxWithholding"] = "SetEtherTaxWithholding";
    PolyTransactionTags["EnableDividends"] = "EnableDividends";
    PolyTransactionTags["EnableGeneralPermissionManager"] = "EnableGeneralPermissionManager";
    PolyTransactionTags["ReclaimDividendFunds"] = "ReclaimDividendFunds";
    PolyTransactionTags["WithdrawTaxWithholdings"] = "WithdrawTaxWithholdings";
    PolyTransactionTags["PushDividendPayment"] = "PushDividendPayment";
    PolyTransactionTags["SetDividendsWallet"] = "SetDividendsWallet";
    PolyTransactionTags["ChangeDelegatePermission"] = "ChangeDelegatePermission";
    PolyTransactionTags["ControllerTransfer"] = "ControllerTransfer";
    PolyTransactionTags["PauseSto"] = "PauseSto";
    PolyTransactionTags["SetController"] = "SetController";
})(PolyTransactionTags = exports.PolyTransactionTags || (exports.PolyTransactionTags = {}));
var Tokens;
(function (Tokens) {
    Tokens["Poly"] = "POLY";
    Tokens["Dai"] = "DAI";
    Tokens["Ether"] = "ETH";
    Tokens["Erc20"] = "ERC20";
    Tokens["Gusd"] = "GUSD";
    Tokens["Pax"] = "PAX";
    Tokens["Usdc"] = "USDC";
    Tokens["Usdt"] = "USDT";
})(Tokens = exports.Tokens || (exports.Tokens = {}));
var TransactionStatus;
(function (TransactionStatus) {
    TransactionStatus["Idle"] = "IDLE";
    TransactionStatus["Unapproved"] = "UNAPPROVED";
    TransactionStatus["Running"] = "RUNNING";
    TransactionStatus["Rejected"] = "REJECTED";
    TransactionStatus["Succeeded"] = "SUCCEEDED";
    TransactionStatus["Failed"] = "FAILED";
})(TransactionStatus = exports.TransactionStatus || (exports.TransactionStatus = {}));
var TransactionQueueStatus;
(function (TransactionQueueStatus) {
    TransactionQueueStatus["Idle"] = "IDLE";
    TransactionQueueStatus["Running"] = "RUNNING";
    TransactionQueueStatus["Failed"] = "FAILED";
    TransactionQueueStatus["Succeeded"] = "SUCCEEDED";
})(TransactionQueueStatus = exports.TransactionQueueStatus || (exports.TransactionQueueStatus = {}));
var DividendModuleTypes;
(function (DividendModuleTypes) {
    DividendModuleTypes["Erc20"] = "erc20";
    DividendModuleTypes["Eth"] = "eth";
})(DividendModuleTypes = exports.DividendModuleTypes || (exports.DividendModuleTypes = {}));
function isPojo(pojo) {
    if (!pojo) {
        return false;
    }
    const props = Object.getOwnPropertyNames(pojo);
    return (lodash_1.default.every(props, prop => {
        return typeof pojo[prop] !== 'function';
    }) && lodash_1.default.isPlainObject(pojo));
}
exports.isPojo = isPojo;
//# sourceMappingURL=types.js.map