<commit_before>const cryptoSchemes = [
  { scheme: 'bitcoin', cryptoId: 'bitcoin@bitcoin' },
  { scheme: 'bitcoincash', cryptoId: 'bitcoin-cash@bitcoin-cash' },
  { scheme: 'bitcoinsv', cryptoId: 'bitcoin-sv@bitcoin-sv' },
  { scheme: 'ethereum', cryptoId: 'ethereum@ethereum' },
  { scheme: 'litecoin', cryptoId: 'litecoin@litecoin' },
  { scheme: 'ripple', cryptoId: 'xrp@ripple' },
  { scheme: 'stellar', cryptoId: 'stellar@stellar' },
  { scheme: 'eos', cryptoId: 'eos@eos' },
  { scheme: 'dogecoin', cryptoId: 'dogecoin@dogecoin' },
  { scheme: 'dash', cryptoId: 'dash@dash' },
  { scheme: 'monero', cryptoId: 'monero@monero' },
];

function getSchemeCryptoId(url) {
  if (!url) return false;
  const scheme = url.split(':')[0];
  return cryptoSchemes.find((item) => item.scheme === scheme);
}

function decode(url) {
  url = url || '';
  const address = url.split('?')[0].split(':').pop();
  const data = { address };
  let match;
  match = url.match(/amount=([0-9.]+)/);
  if (match && match[1]) {
    data.value = match[1];
  }
  match = url.match(/dt=(\d+)/);
  if (match && match[1]) {
    data.tag = match[1];
  }
  return data;
}

function registerProtocolHandler(crypto) {
  if (process.env.BUILD_PLATFORM !== 'web') return;
  if (!navigator.registerProtocolHandler) return;
  const scheme = cryptoSchemes.find((item) => item.cryptoId === crypto._id);
  if (!scheme) return;
  try {
    navigator.registerProtocolHandler(
      scheme,
      `${process.env.SITE_URL}wallet/?crypto=${crypto._id}&bip21=%s`, 'Coin Wallet'
    );
    // eslint-disable-next-line
  } catch (e) {}
}

export default {
  getSchemeCryptoId,
  decode,
  registerProtocolHandler,
};
<commit_msg>chore: use crypto-db in lib/bip21<commit_after>import bitcoin from '@coinspace/crypto-db/crypto/bitcoin@bitcoin.json';
import litecoin from '@coinspace/crypto-db/crypto/litecoin@litecoin.json';
import dash from '@coinspace/crypto-db/crypto/dash@dash.json';
import bitcoinCash from '@coinspace/crypto-db/crypto/bitcoin-cash@bitcoin-cash.json';
import bitcoinSv from '@coinspace/crypto-db/crypto/bitcoin-sv@bitcoin-sv.json';
import ethereum from '@coinspace/crypto-db/crypto/ethereum@ethereum.json';
import dogecoin from '@coinspace/crypto-db/crypto/dogecoin@dogecoin.json';
import xrp from '@coinspace/crypto-db/crypto/xrp@ripple.json';
import stellar from '@coinspace/crypto-db/crypto/stellar@stellar.json';
import eos from '@coinspace/crypto-db/crypto/eos@eos.json';
import monero from '@coinspace/crypto-db/crypto/monero@monero.json';

const cryptoSchemes = [
  bitcoin,
  bitcoinCash,
  bitcoinSv,
  litecoin,
  ethereum,
  xrp,
  stellar,
  eos,
  dogecoin,
  dash,
  monero,
].map((item) => {
  return {
    scheme: item.scheme,
    cryptoId: item._id,
  };
});

function getSchemeCryptoId(url) {
  if (!url) return false;
  const scheme = url.split(':')[0];
  return cryptoSchemes.find((item) => item.scheme === scheme);
}

function decode(url) {
  url = url || '';
  const address = url.split('?')[0].split(':').pop();
  const data = { address };
  let match;
  match = url.match(/amount=([0-9.]+)/);
  if (match && match[1]) {
    data.value = match[1];
  }
  match = url.match(/dt=(\d+)/);
  if (match && match[1]) {
    data.tag = match[1];
  }
  return data;
}

function registerProtocolHandler(crypto) {
  if (process.env.BUILD_PLATFORM !== 'web') return;
  if (!navigator.registerProtocolHandler) return;
  const scheme = cryptoSchemes.find((item) => item.cryptoId === crypto._id);
  if (!scheme) return;
  try {
    navigator.registerProtocolHandler(
      scheme,
      `${process.env.SITE_URL}wallet/?crypto=${crypto._id}&bip21=%s`, 'Coin Wallet'
    );
    // eslint-disable-next-line
  } catch (e) {}
}

export default {
  getSchemeCryptoId,
  decode,
  registerProtocolHandler,
};

{'fraction_non_alphanumeric': 0.1795346377578001, 'fraction_numerical': 0.005817028027498678, 'mean_word_length': 4.261474269819193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 11, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1512170', 'n_tokens_mistral': 1382, 'n_tokens_neox': 1358, 'n_words': 257}