How to use the web3-utils.isHexStrict function in web3-utils

To help you get started, we’ve selected a few web3-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MyEtherWallet / MyEtherWallet / src / directives / AddrResolver.js View on Github external
parentCurrency === 'ETH' ? toChecksumAddress(e) : e;
        } else {
          if (canValidate(parentCurrency)) {
            const isValid = MAValidator.validate(e, parentCurrency);
            if (isValid) {
              _this.isValidAddress = isValid;
              _this.hexAddress = e;
            } else {
              _this.isValidAddress = false;
              _this.hexAddress = '';
              removeElements();

              if (e.length > 0) {
                if (
                  parentCurrency === 'ETH' &&
                  (e.length !== 42 || !utils.isHexStrict(e))
                ) {
                  errorPar.innerText = _this.$t(
                    'ens.ens-resolver.invalid-eth-addr'
                  );
                } else if (
                  parentCurrency === 'ETH' &&
                  !utils.checkAddressChecksum(e)
                ) {
                  errorPar.innerText = _this.$t(
                    'ens.ens-resolver.addr-not-checksummed'
                  );
                  // 'Incorrect checksum: check address format on EthVM';
                } else {
                  errorPar.innerText = _this.$t(
                    'ens.ens-resolver.invalid-addr',
                    { coin: parentCurrency }
github ConsenSys / ethql / packages / core / src / resolvers / scalars.ts View on Github external
parseValue: input => {
    return !web3Utils.isHexStrict(input) || web3Utils.hexToBytes(input).length !== 32 ? undefined : input;
  },
  parseLiteral: ast => {
github ethereum / web3.js / packages / web3-core-helpers / src / formatters.js View on Github external
var inputBlockNumberFormatter = function (blockNumber) {
    if (blockNumber === undefined) {
        return undefined;
    } else if (isPredefinedBlockNumber(blockNumber)) {
        return blockNumber;
    }
    return (utils.isHexStrict(blockNumber)) ? ((_.isString(blockNumber)) ? blockNumber.toLowerCase() : blockNumber) : utils.numberToHex(blockNumber);
};
github bodhiproject / bodhi-ui / src / helpers / utility.js View on Github external
export function numToHex(number) {
  if (isUndefined(number)) return number;
  if (isHexStrict(number)) return number;
  return numberToHex(number);
}
github Neufund / platform-contracts / scripts / fixtures / addFixture.js View on Github external
validate: text => {
          if (!utils.isHexStrict(text) && !utils.isAddress(text)) {
            return "Provide correct checksumed Ethereum address. Start with 0x ";
          }
          return true;
        },
      },
github melonproject / protocol / src / utils / checks / isAddress.ts View on Github external
export const isAddress = (address: string | Address): boolean =>
  `${address}`.length === 42 &&
  web3Utils.isAddress(`${address}`) &&
  web3Utils.isHexStrict(`${address}`);
github JoinColony / colonyJS / packages / colony-js-contract-client / src / classes / MultisigOperation.js View on Github external
static _validatePayload(payload: any) {
    const assert = makeAssert('Invalid payload');

    assert(isPlainObject(payload), 'Payload must be an object');

    const { data, destinationAddress, sourceAddress, value } = payload || {};

    assert(isHexStrict(data), 'data must be a hex string');

    assert(
      isValidAddress(destinationAddress),
      'destinationAddress must be a valid address',
    );

    assert(
      isValidAddress(sourceAddress),
      'sourceAddress must be a valid address',
    );

    return assert(
      Number(value) === value && value >= 0,
      'value must be a positive number',
    );
  }
github ethereum / web3.js / packages / web3-core-helpers / src / formatters.js View on Github external
var inputSignFormatter = function (data) {
    return (utils.isHexStrict(data)) ? data : utils.utf8ToHex(data);
};
github magmo / apps / packages / rps-poc / src / wallet / domain / Signature.ts View on Github external
constructor(signature: string) {
    if (!isHexStrict(signature)) {
      throw new Error('Invalid input: signature must be a hex string');
    }

    if (signature.length !== 132) {
      throw new Error('Invalid input: signature must be 65 bytes');
    }

    this.signature = signature;
    this.r = '0x' + signature.slice(2, 66);
    this.s = '0x' + signature.slice(66, 130);
    this.v = toDecimal('0x' + signature.slice(130, 132));
  }
}