"use strict";
// Copyright 2017-2020 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
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 });
const util_1 = require("@polkadot/util");
const AbstractInt_1 = __importStar(require("./AbstractInt"));
/**
 * @name Int
 * @description
 * A generic signed integer codec. For Substrate all numbers are Little Endian encoded,
 * this handles the encoding and decoding of those numbers. Upon construction
 * the bitLength is provided and any additional use keeps the number to this
 * length. This extends `BN`, so all methods available on a normal `BN` object
 * is available here.
 * @noInheritDoc
 */
class Int extends AbstractInt_1.default {
    constructor(registry, value = 0, bitLength = AbstractInt_1.DEFAULT_UINT_BITS, isHexJson = true) {
        super(registry, true, value, bitLength, isHexJson);
    }
    /**
     * @description Returns a hex string representation of the value
     */
    toHex(isLe = false) {
        return util_1.bnToHex(this, {
            bitLength: this._bitLength,
            isLe,
            isNegative: true
        });
    }
    /**
     * @description Returns the base runtime type name for this instance
     */
    toRawType() {
        return `i${this._bitLength}`;
    }
    /**
     * @description Encodes the value as a Uint8Array as per the SCALE specifications
     * @param isBare true when the value has none of the type-specific prefixes (internal)
     */
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    toU8a(isBare) {
        return util_1.bnToU8a(this, {
            bitLength: this._bitLength,
            isLe: true,
            isNegative: true
        });
    }
}
exports.default = Int;
