How to use the @cityofzion/neon-js.api.neoscan 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 / renderer / shared / util / claimGas.js View on Github external
// limit number of claims for ledger devices due to memory constraints
  const claimableClaims = publicKey ? claims.slice(0, 25) : claims;

  // send claim request
  const {
    response: { result, txid }
  } = await api.claimGas(
    {
      net,
      address,
      publicKey,
      privateKey,
      signingFunction,
      claims: claimableClaims
    },
    api.neoscan
  );

  if (!result) {
    throw new Error('Transaction rejected by blockchain');
  }

  return txid;
}
github CityOfZion / neon-wallet / app / actions / transactionHistoryActions.js View on Github external
}: Props = {}) => async () => {
    // If refresh action dispatched reset pagination
    // to grab the most recent abstracts
    if (!shouldIncrementPagination) {
      page = 1
    }

    const endpoint = api.neoscan.getAPIEndpoint(net)
    const { data } = await axios.get(
      `${endpoint}/v1/get_address_abstracts/${address}/${page}`,
    )

    const parsedEntries = await parseAbstractData(data.entries, address, net)
    page += 1
    if (shouldIncrementPagination) {
      if (page === 1) entries = []
      entries.push(...parsedEntries)
      return entries
    }
    entries = [...parsedEntries]
    return entries
  },
)
github PacktPublishing / Foundations-of-Blockchain / Chapter07 / NEO / proof_of_ownership_app / interface / src / App.js View on Github external
async componentDidMount(){

        const mainNetNeoscan = new api.neoscan.instance("TestNet");
        const neoscanBalance = await mainNetNeoscan.getBalance('AH4dqfuyaT1tGthQiQQ2RQ8c7Xksuphb7k');
        console.log(neoscanBalance)

    }
github nos / client / src / renderer / shared / util / claimGas.js View on Github external
}) {
  const url = await getRPCEndpoint(net);

  const {
    response: { result }
  } = await api.sendAsset(
    {
      net,
      url,
      address,
      publicKey,
      privateKey,
      signingFunction,
      intents: api.makeIntent({ NEO: balance }, address)
    },
    api.neoscan
  );

  if (!result) {
    throw new Error('Transaction rejected by blockchain');
  }

  return result.response;
}
github nos / client / src / renderer / shared / util / sendAsset.js View on Github external
} else if (Array.isArray(remark)) {
        for (let i = 0; i < remark.length; i += 1) {
          transaction.addAttribute(tx.TxAttrUsage.Remark + i, remark[i]);
        }
      }

      return doSendAsset({ ...config, balance, tx: transaction }, api.neoscan);
    } else {
      const script = createScript(
        asset,
        'transfer',
        [address, receiver, new u.Fixed8(amount)],
        true
      );

      return doInvoke({ ...config, script, gas: 0 }, api.neoscan);
    }
  };
github nos / client / src / renderer / browser / actions / makeInvokeActions.js View on Github external
privateKey: wif,
    publicKey,
    signingFunction,
    gas: 0,
    fees: fee
  };

  if (assets) {
    const scAddress = wallet.getAddressFromScriptHash(scriptHash);
    const intentConfig = mapKeys(formatAssets(assets), (value, key) => ASSETS[key].symbol);
    config.intents = api.makeIntent(intentConfig, scAddress);
  }

  const {
    response: { result, txid }
  } = await api.doInvoke(config, api.neoscan);

  if (!result) {
    throw new Error('Invocation failed.');
  }

  return txid;
}
github nos / client / src / shared / util / sendAsset.js View on Github external
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
  };

  const { response: { result, txid } } = await api.sendAsset(config, api.neoscan);

  if (!result) {
    throw new Error('Invocation failed.');
  }

  return txid;
}
github CityOfZion / neon-wallet / app / containers / TransactionHistory / TransactionHistory.jsx View on Github external
fetchHistory = async () => {
    const { showInfoNotification, net, address } = this.props
    const infoNotification = showInfoNotification({
      message: 'Fetching entire transaction history...',
    })
    const abstracts = []
    const endpoint = api.neoscan.getAPIEndpoint(net)
    let numberOfPages = 1
    let currentPage = 1
    let shouldFetchAdditionalPages = true

    while (
      (currentPage - 1 !== numberOfPages || currentPage === 1) &&
      shouldFetchAdditionalPages
    ) {
      const { data } = await axios.get(
        `${endpoint}/v1/get_address_abstracts/${address}/${currentPage}`,
      )
      abstracts.push(...data.entries)
      numberOfPages = data.total_pages
      currentPage += 1

      if (data.total_pages === 1 || data.total_pages === 0) {
github CityOfZion / neon-wallet / app / actions / voteActions.js View on Github external
({ networkId, address }: Props = {}) => async (state: Object) => {
    const net = getNetworkById(networkId)
    const endpoint = await api.getRPCEndpointFrom({ net }, api.neoscan)
    const client = new rpc.RPCClient(endpoint)

    const validators = await client.getValidators()
    const accountState = await client.getAccountState(address)

    return {
      validators,
      votes: accountState.votes,
    }
  },
)