UNPKG

crypto-wallet-core

Version:

A multi-currency support library for address derivation, private key creation, and transaction creation

34 lines 983 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SolValidation = void 0; const kit_1 = require("@solana/kit"); class SolValidation { regex; constructor() { this.regex = /solana/i; } validateAddress(_network, address) { try { (0, kit_1.address)(address); return true; } catch (error) { return false; } } validateUri(addressUri) { if (!addressUri) { return false; } const address = this.extractAddress(addressUri); const prefix = this.regex.exec(addressUri); return !!prefix && this.validateAddress('livenet', address); } extractAddress(data) { const prefix = /^[a-z]+:/i; const params = /([\?\&](amount|fee)=(\d+([\,\.]\d+)?))+/i; return data.replace(prefix, '').replace(params, ''); } } exports.SolValidation = SolValidation; //# sourceMappingURL=index.js.map