# All files / web3-eth-abi/src/types address.js

100% Statements 14/14
100% Branches 4/4
100% Functions 3/3
100% Lines 14/14

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    321x
    1x
    1x

    1x
    1x
    63x
    63x
    63x

    1x

    1x
    1x

    1x
    439x

    1x
     var f = require('../formatters');
    var formatters = require('web3-core-helpers').formatters;
    var SolidityType = require('../type');

    /**
     * SolidityTypeAddress is a protoype that represents address type
     * It matches:
     * address
     * address[]
     * address[4]
     * address[][]
     * address[3][]
     * address[][6][], ...
     */
    var SolidityTypeAddress = function () {
        this._inputFormatter = function(){
            var args = Array.prototype.slice.call(arguments);
            args[0] = (!args[0] || args[0] === '0x0') ? '' : formatters.inputAddressFormatter(args[0]);
            return f.formatInputInt.apply(this, args);
        };
        this._outputFormatter = f.formatOutputAddress;
    };

    SolidityTypeAddress.prototype = new SolidityType({});
    SolidityTypeAddress.prototype.constructor = SolidityTypeAddress;

    SolidityTypeAddress.prototype.isType = function (name) {
        return !!name.match(/address(\[([0-9]*)\])?/);
    };

    module.exports = SolidityTypeAddress;