How to use the @cityofzion/neon-js.u.reverseHex 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 / getBalances.js View on Github external
function getRawTokenBalances(url, tokens, address) {
  const addrScriptHash = u.reverseHex(wallet.getScriptHashFromAddress(address));
  const sb = new sc.ScriptBuilder();

  tokens.forEach(({ scriptHash }) => {
    sb.emitAppCall(scriptHash, 'balanceOf', [addrScriptHash]);
  });

  return rpc.Query.invokeScript(sb.str, false)
    .execute(url)
    .then((res) => {
      const tokenList = {};

      if (res && res.result && res.result.stack && res.result.stack.length >= 1) {
        for (let i = 0; i < res.result.stack.length; i += 1) {
          const { scriptHash, decimals } = tokens[i];
          const value = parseHexNum(res.result.stack[i].value);
          if (value !== 0 || scriptHash === NOS) {
github nos / client / src / renderer / browser / util / encodeArgs.js View on Github external
        expression ${wallet.isAddress} ${() => u.reverseHex(wallet.getScriptHashFromAddress(arg))}
        expression ${Array.isArray} ${() => encodeArgs(arg)}
github nos / client / src / renderer / shared / util / getBalances.js View on Github external
function parseHexNum(hex) {
  return hex ? parseInt(u.reverseHex(hex), 16) : 0;
}
github CityOfZion / neon-wallet / app / modules / transactions.js View on Github external
tokenEntries.forEach(({ address, amount, symbol }) => {
    const toAcct = new wallet.Account(address)
    const { scriptHash, decimals } = tokensBalanceMap[symbol]
    const args = [
      u.reverseHex(fromAcct.scriptHash),
      u.reverseHex(toAcct.scriptHash),
      sc.ContractParam.byteArray(toNumber(amount), 'fixed8', decimals),
    ]

    scriptBuilder.emitAppCall(scriptHash, 'transfer', args)
  })