How to use the @cityofzion/neon-js.wallet.isAddress function in @cityofzion/neon-js

To help you get started, we’ve selected a few @cityofzion/neon-js 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 nos / client / src / actions / dapps / makeSendActions.js View on Github external
const send = async ({ net, asset, amount, receiver, address, wif }) => {
  if (![GAS, NEO].includes(asset)) {
    throw new Error(`Invalid asset: ${asset}`);
  }

  // TODO check if user has enough balance
  if (!wallet.isAddress(receiver)) {
    throw new Error(`Invalid script hash: "${receiver}"`);
  }

  if (amount <= 0) {
    throw new Error(`Invalid amount: "${amount}"`);
  }

  const selectedAsset = asset === NEO ? 'NEO' : 'GAS';
  const intents = await api.makeIntent({ [selectedAsset]: amount }, receiver);

  const config = {
    net,
    address,
    privateKey: new wallet.Account(wif).privateKey,
    intents
  };
github nos / client / src / shared / util / getBalances.js View on Github external
export default async function getBalances({ net, address, tokens }) {
  const endpoint = await api.loadBalance(api.getRPCEndpointFrom, { net });

  if (!wallet.isAddress(address)) {
    throw new Error(`Invalid script hash: "${address}"`);
  }

  // token balances
  const promises = tokens.map(async (token) => {
    const { scriptHash } = token;

    try {
      const response = await api.nep5.getToken(endpoint, scriptHash, address);
      const balance = (response.balance || 0).toString();

      return {
        [scriptHash]: { ...response, scriptHash, balance }
      };
    } catch (err) {
      // invalid scriptHash
github nos / client / src / shared / util / sendAsset.js View on Github external
export default async function sendAsset({ net, asset, amount, receiver, address, wif }) {
  if (!keys(ASSETS).includes(asset)) {
    throw new Error(`Invalid asset: ${asset}`);
  }

  if (!wallet.isAddress(receiver)) {
    throw new Error(`Invalid script hash: "${receiver}"`);
  }

  if (amount <= 0) {
    throw new Error(`Invalid amount: "${amount}"`);
  }

  const selectedAsset = ASSETS[asset];
  const intents = await api.makeIntent({ [selectedAsset]: amount }, receiver);

  const config = {
    net,
    address,
    privateKey: new wallet.Account(wif).privateKey,
    intents
  };
github CityOfZion / neon-wallet / app / hocs / helpers / didLogin.js View on Github external
export default function didLogin(oldAddress: ?string, newAddress: ?string) {
  return !oldAddress && wallet.isAddress(newAddress)
}
github CityOfZion / neon-wallet / app / hocs / helpers / didLogout.js View on Github external
export default function didLogout(oldAddress: ?string, newAddress: ?string) {
  return wallet.isAddress(oldAddress) && !newAddress
}
github nos / client / src / renderer / shared / util / sendAsset.js View on Github external
export default async function sendAsset(
  { net, asset, amount, receiver, address, wif, publicKey, signingFunction, remark, fee = 0 },
  getBalance = api.neoscan.getBalance,
  doSendAsset = api.sendAsset,
  doInvoke = api.doInvoke,
  doGetRPCEndpoint = getRPCEndpoint
) {
  if (!wallet.isAddress(receiver)) {
    throw new Error(`Invalid script hash: "${receiver}"`);
  }

  if (amount <= 0) {
    throw new Error(`Invalid amount: "${amount}"`);
  }

  if (remark !== undefined) {
    validateRemark(remark);
  }

  const send = async () => {
    const url = await doGetRPCEndpoint(net);
    const config = {
      net,
      url,
github CityOfZion / neon-wallet / app / actions / authActions.js View on Github external
({ address }: WatchOnlyLoginProps) => async (): Promise => {
    if (!wallet.isAddress(address)) {
      throw new Error('Invalid public key entered')
    }
    const hasInternetConnectivity = await checkForInternetConnectivity()

    return {
      address,
      isHardwareLogin: false,
      isWatchOnly: true,
      hasInternetConnectivity,
    }
  },
)
github CityOfZion / neon-wallet / app / components / Contacts / ContactForm / ContactForm.jsx View on Github external
disableButton = (name: string, address: string) => {
    if (name.length === 0) {
      return true
    }

    if (name.length > 100) {
      return true
    }

    if (!wallet.isAddress(address)) {
      return true
    }

    return false
  }
github nos / client / src / renderer / shared / util / getBalances.js View on Github external
export default async function getBalances({ net, address }) {
  const endpoint = await getRPCEndpoint(net);

  if (!wallet.isAddress(address)) {
    throw new Error(`Invalid address: "${address}"`);
  }

  const assets = await getAssetBalances(endpoint, address);
  const tokens = await getTokenBalances(endpoint, address);

  return { ...assets, ...tokens };
}
github nos / client / src / renderer / account / components / Portfolio / TransactionsPanel / Send / Send.js View on Github external
isValid = () => {
    const { amount, receiver, asset, balances } = this.props;
    const bigNumAmount = this.getAmount(amount);
    const bigNumBalance = this.getAmount(balances[asset].balance);

    return (
      bigNumBalance >= bigNumAmount &&
      bigNumAmount > 0 &&
      isNumeric(amount) &&
      wallet.isAddress(receiver)
    );
  };
}