@bcpros/crypto-wallet-core
Version:
A multi-currency support library for address derivation, private key creation, and transaction creation
28 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EthValidation = void 0;
var utils = require('web3-utils');
var EthValidation = (function () {
function EthValidation() {
this.regex = /ethereum/i;
}
EthValidation.prototype.validateAddress = function (_network, address) {
return utils.isAddress(address);
};
EthValidation.prototype.validateUri = function (addressUri) {
if (!addressUri) {
return false;
}
var address = this.extractAddress(addressUri);
var prefix = this.regex.exec(addressUri);
return !!prefix && utils.isAddress(address);
};
EthValidation.prototype.extractAddress = function (data) {
var prefix = /^[a-z]+:/i;
var params = /([\?\&](value|gas|gasPrice|gasLimit)=(\d+([\,\.]\d+)?))+/i;
return data.replace(prefix, '').replace(params, '');
};
return EthValidation;
}());
exports.EthValidation = EthValidation;
//# sourceMappingURL=index.js.map