How to use the @cityofzion/neon-core.u.str2hexstring function in @cityofzion/neon-core

To help you get started, we’ve selected a few @cityofzion/neon-core 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 NeoNextClub / neoline / src / app / popup / notification / invoke / invoke.component.ts View on Github external
} else {
                    if (this.fee > 0) {
                        try {
                            newTx = await this.addFee(this.neon.wallet.accounts[0].address, newTx, this.fee);
                        } catch (error) {
                            console.log(error);
                        }
                    }
                }
            } else {
                newTx.outputs = this.assetIntentOverrides.outlets;
                newTx.inputs = this.assetIntentOverrides.inputs;
            }
            newTx.addAttribute(tx.TxAttrUsage.Script, u.reverseHex(fromScript));
            const uniqTag = `from NEOLine at ${new Date().getTime()}`;
            newTx.addAttribute(tx.TxAttrUsage.Remark1, u.reverseHex(u.str2hexstring(uniqTag)));
            resolve(newTx);
        });
    }
github CityOfZion / neon-js / packages / neon-domain / src / provider / NeoNS / core.ts View on Github external
): Promise {
  const protocol = {
    type: "String",
    value: "addr"
  };

  const empty = {
    type: "String",
    value: ""
  };

  const tld = domain.split(".").reverse()[0];
  const regExp = new RegExp(`.${tld}$`);

  const subdomain = domain.replace(regExp, "");
  const hashSubdomain = u.sha256(u.str2hexstring(subdomain));
  const hashDomain = u.sha256(u.str2hexstring(tld));

  const hashName = u.sha256(hashSubdomain.concat(hashDomain));
  const parsedName = sc.ContractParam.byteArray(hashName, "name");

  const args = [protocol, parsedName, empty];

  const sb = new sc.ScriptBuilder();
  const script = sb.emitAppCall(contract, operation, args).str;
  const res = await rpc.Query.invokeScript(script).execute(url);

  return rpc.StringParser(res.result.stack[0]);
}
github CityOfZion / neon-js / packages / neon-domain / src / provider / NeoNS / core.ts View on Github external
const protocol = {
    type: "String",
    value: "addr"
  };

  const empty = {
    type: "String",
    value: ""
  };

  const tld = domain.split(".").reverse()[0];
  const regExp = new RegExp(`.${tld}$`);

  const subdomain = domain.replace(regExp, "");
  const hashSubdomain = u.sha256(u.str2hexstring(subdomain));
  const hashDomain = u.sha256(u.str2hexstring(tld));

  const hashName = u.sha256(hashSubdomain.concat(hashDomain));
  const parsedName = sc.ContractParam.byteArray(hashName, "name");

  const args = [protocol, parsedName, empty];

  const sb = new sc.ScriptBuilder();
  const script = sb.emitAppCall(contract, operation, args).str;
  const res = await rpc.Query.invokeScript(script).execute(url);

  return rpc.StringParser(res.result.stack[0]);
}
github NeoNextClub / neoline / src / app / popup / notification / deploy / deploy.component.ts View on Github external
newTx.script = sb.str;
            } catch (error) {
                reject(error);
            }
            try {
                newTx = await this.addFee(fromAddress, newTx, amount + parseFloat(this.pramsData.networkFee));
            } catch (error) {
                this.chrome.windowCallback({
                    error: ERRORS.INSUFFICIENT_FUNDS,
                    return: requestTarget.Deploy,
                    ID: this.messageID
                });
                window.close();
            }
            const uniqTag = `from NEOLine at ${new Date().getTime()}`;
            newTx.addAttribute(tx.TxAttrUsage.Remark1, u.reverseHex(u.str2hexstring(uniqTag)));
            newTx.gas = new Fixed8(amount);
            resolve(newTx);
        });
    }
github CityOfZion / neon-js / packages / neon-nep9 / src / extract.ts View on Github external
function processAscii(data: string): string {
  return u.str2hexstring(decodeURIComponent(data));
}
github NeoNextClub / neoline / src / app / core / services / neon.service.ts View on Github external
if (fromScript.length !== 40 || toScript.length !== 40) {
            throw new Error('target address error');
        }
        const newTx = new tx.InvocationTransaction();
        newTx.script = sc.createScript({
            scriptHash: scriptHash.startsWith('0x') && scriptHash.length === 42 ? scriptHash.substring(2) : scriptHash,
            operation: 'transfer',
            args: [
                u.reverseHex(fromScript),
                u.reverseHex(toScript),
                amount * Math.pow(10, decimals)
            ]
        }) + 'f1';
        newTx.addAttribute(tx.TxAttrUsage.Script, u.reverseHex(fromScript));
        const uniqTag = `from NEOLine at ${new Date().getTime()}`;
        newTx.addAttribute(tx.TxAttrUsage.Remark1, u.reverseHex(u.str2hexstring(uniqTag)));
        return newTx;
    }
    public claimGAS(claims: Array, value: number): Observable {