How to use the stellar-base.StrKey.isValidEd25519PublicKey function in stellar-base

To help you get started, we’ve selected a few stellar-base 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 stellar / js-stellar-sdk / src / federation_server.ts View on Github external
public static async resolve(
    value: string,
    opts: FederationServer.Options = {},
  ): Promise {
    // Check if `value` is in account ID format
    if (value.indexOf("*") < 0) {
      if (!StrKey.isValidEd25519PublicKey(value)) {
        return Promise.reject(new Error("Invalid Account ID"));
      }
      return Promise.resolve({ account_id: value });
    }

    const addressParts = value.split("*");
    const [, domain] = addressParts;

    if (addressParts.length !== 2 || !domain) {
      return Promise.reject(new Error("Invalid Stellar address"));
    }
    const federationServer = await FederationServer.createForDomain(
      domain,
      opts,
    );
    return federationServer.resolveAddress(value);
github orbitlens / stellar-notifier / util / asset-helper.js View on Github external
function isValidAsset(asset) {
    if (asset.asset_type === 0 && !asset.asset_code && !asset.asset_issuer) return true
    if (!StrKey.isValidEd25519PublicKey(asset.asset_issuer)) return false
    if (!asset.asset_code) return false
    if (!/^[a-zA-Z0-9]{1,12}$/.test(asset.asset_code)) return false
    if (normalizeAssetType(asset.asset_code) !== asset.asset_type) return false
    return true
}